@@ -90,6 +90,9 @@ UIPUDP::beginPacket(IPAddress ip, uint16_t port)
90
90
#endif
91
91
if (_uip_udp_conn)
92
92
{
93
+ // [J.A]: for UDP server, setting ripaddr and rport causes in uIP filtering
94
+ // of incoming messages. it would be better to store the IP and port in fields
95
+ // and set them only in endPacket().
93
96
_uip_udp_conn->rport = htons (port);
94
97
uip_ipaddr_copy (_uip_udp_conn->ripaddr , &ripaddr);
95
98
}
@@ -170,7 +173,7 @@ UIPUDP::endPacket()
170
173
uip_udp_periodic_conn (_uip_udp_conn);
171
174
if (uip_len > 0 )
172
175
{
173
- _send (&appdata );
176
+ _send (_uip_udp_conn );
174
177
return 1 ;
175
178
}
176
179
}
@@ -359,7 +362,8 @@ uipudp_appcall(void) {
359
362
}
360
363
361
364
void
362
- UIPUDP::_send (uip_udp_userdata_t *data) {
365
+ UIPUDP::_send (struct uip_udp_conn *uip_udp_conn) {
366
+
363
367
uip_arp_out (); // add arp
364
368
if (uip_len == UIP_ARPHDRSIZE)
365
369
{
@@ -373,9 +377,17 @@ UIPUDP::_send(uip_udp_userdata_t *data) {
373
377
else
374
378
// arp found ethaddr for ip (otherwise packet is replaced by arp-request)
375
379
{
380
+ uip_udp_userdata_t * data = (uip_udp_userdata_t *)(uip_udp_conn->appstate );
376
381
UIPEthernetClass::network_send ();
377
382
data->send = false ;
378
383
data->packet_out = NOBLOCK;
384
+
385
+ // [J.A] a listening UDP port in uIP filters received messages
386
+ // if rport and ripaddr are set. so we better clear them
387
+ uip_udp_conn->rport = 0 ;
388
+ uip_udp_conn->ripaddr [0 ] = 0 ;
389
+ uip_udp_conn->ripaddr [1 ] = 0 ;
390
+
379
391
#ifdef UIPETHERNET_DEBUG_UDP
380
392
Serial.print (F (" udp, uip_packet to send: " ));
381
393
Serial.println (UIPEthernetClass::uip_packet);
0 commit comments