90 |
struct ip_hdr *iphdr; |
struct ip_hdr *iphdr; |
91 |
u16_t src, dest; |
u16_t src, dest; |
92 |
|
|
|
#if SO_REUSE |
|
|
struct udp_pcb *pcb_temp; |
|
|
int reuse = 0; |
|
|
int reuse_port_1 = 0; |
|
|
int reuse_port_2 = 0; |
|
|
#endif /* SO_REUSE */ |
|
|
|
|
93 |
PERF_START; |
PERF_START; |
94 |
|
|
95 |
UDP_STATS_INC(udp.recv); |
UDP_STATS_INC(udp.recv); |
98 |
|
|
99 |
if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) { |
if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) { |
100 |
/* drop short packets */ |
/* drop short packets */ |
101 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len)); |
102 |
UDP_STATS_INC(udp.lenerr); |
UDP_STATS_INC(udp.lenerr); |
103 |
UDP_STATS_INC(udp.drop); |
UDP_STATS_INC(udp.drop); |
104 |
snmp_inc_udpinerrors(); |
snmp_inc_udpinerrors(); |
108 |
|
|
109 |
udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN); |
udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN); |
110 |
|
|
111 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %u\n", p->tot_len)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); |
112 |
|
|
113 |
src = ntohs(udphdr->src); |
src = ntohs(udphdr->src); |
114 |
dest = ntohs(udphdr->dest); |
dest = ntohs(udphdr->dest); |
116 |
udp_debug_print(udphdr); |
udp_debug_print(udphdr); |
117 |
|
|
118 |
/* print the UDP source and destination */ |
/* print the UDP source and destination */ |
119 |
LWIP_DEBUGF(UDP_DEBUG, ("udp (%u.%u.%u.%u, %u) <-- (%u.%u.%u.%u, %u)\n", |
LWIP_DEBUGF(UDP_DEBUG, ("udp (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") <-- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", |
120 |
ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest), |
ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest), |
121 |
ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest), ntohs(udphdr->dest), |
ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest), ntohs(udphdr->dest), |
122 |
ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), |
ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), |
123 |
ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src))); |
ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src))); |
124 |
|
|
|
#if SO_REUSE |
|
|
pcb_temp = udp_pcbs; |
|
|
|
|
|
again_1: |
|
|
|
|
|
/* Iterate through the UDP pcb list for a fully matching pcb */ |
|
|
for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) { |
|
|
#else /* SO_REUSE */ |
|
125 |
/* Iterate through the UDP pcb list for a fully matching pcb */ |
/* Iterate through the UDP pcb list for a fully matching pcb */ |
126 |
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
|
#endif /* SO_REUSE */ |
|
127 |
/* print the PCB local and remote address */ |
/* print the PCB local and remote address */ |
128 |
LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", |
LWIP_DEBUGF(UDP_DEBUG, ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", |
129 |
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), |
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), |
130 |
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, |
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, |
131 |
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), |
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), |
143 |
(ip_addr_isany(&pcb->local_ip) || |
(ip_addr_isany(&pcb->local_ip) || |
144 |
/* PCB local IP address matches UDP destination IP address? */ |
/* PCB local IP address matches UDP destination IP address? */ |
145 |
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { |
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { |
|
#if SO_REUSE |
|
|
if (pcb->so_options & SOF_REUSEPORT) { |
|
|
if(reuse) { |
|
|
/* We processed one PCB already */ |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n")); |
|
|
} else { |
|
|
/* First PCB with this address */ |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n")); |
|
|
reuse = 1; |
|
|
} |
|
|
|
|
|
reuse_port_1 = 1; |
|
|
p->ref++; |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref)); |
|
|
} else { |
|
|
if (reuse) { |
|
|
/* We processed one PCB already */ |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n")); |
|
|
} |
|
|
} |
|
|
#endif /* SO_REUSE */ |
|
146 |
break; |
break; |
147 |
} |
} |
148 |
} |
} |
151 |
/* Iterate through the UDP PCB list for a pcb that matches |
/* Iterate through the UDP PCB list for a pcb that matches |
152 |
the local address. */ |
the local address. */ |
153 |
|
|
|
#if SO_REUSE |
|
|
pcb_temp = udp_pcbs; |
|
|
|
|
|
again_2: |
|
|
|
|
|
for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) { |
|
|
#else /* SO_REUSE */ |
|
154 |
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
155 |
#endif /* SO_REUSE */ |
LWIP_DEBUGF(UDP_DEBUG, ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", |
|
LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", |
|
156 |
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), |
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), |
157 |
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, |
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, |
158 |
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), |
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), |
165 |
(ip_addr_isany(&pcb->local_ip) || |
(ip_addr_isany(&pcb->local_ip) || |
166 |
/* ...matching interface address? */ |
/* ...matching interface address? */ |
167 |
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { |
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { |
|
#if SO_REUSE |
|
|
if (pcb->so_options & SOF_REUSEPORT) { |
|
|
if (reuse) { |
|
|
/* We processed one PCB already */ |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n")); |
|
|
} else { |
|
|
/* First PCB with this address */ |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n")); |
|
|
reuse = 1; |
|
|
} |
|
|
|
|
|
reuse_port_2 = 1; |
|
|
p->ref++; |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref)); |
|
|
} else { |
|
|
if (reuse) { |
|
|
/* We processed one PCB already */ |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n")); |
|
|
} |
|
|
} |
|
|
#endif /* SO_REUSE */ |
|
168 |
break; |
break; |
169 |
} |
} |
170 |
} |
} |
218 |
{ |
{ |
219 |
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); |
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); |
220 |
} |
} |
|
#if SO_REUSE |
|
|
/* First socket should receive now */ |
|
|
if (reuse_port_1 || reuse_port_2) { |
|
|
/* We want to search on next socket after receiving */ |
|
|
pcb_temp = pcb->next; |
|
|
|
|
|
if (reuse_port_1) { |
|
|
/* We are searching connected sockets */ |
|
|
reuse_port_1 = 0; |
|
|
reuse_port_2 = 0; |
|
|
goto again_1; |
|
221 |
} else { |
} else { |
|
/* We are searching unconnected sockets */ |
|
|
reuse_port_1 = 0; |
|
|
reuse_port_2 = 0; |
|
|
goto again_2; |
|
|
} |
|
|
} |
|
|
#endif /* SO_REUSE */ |
|
|
} else { |
|
|
#if SO_REUSE |
|
|
if(reuse) { |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: freeing PBUF with reference counter set to %i\n", p->ref)); |
|
|
pbuf_free(p); |
|
|
goto end; |
|
|
} |
|
|
#endif /* SO_REUSE */ |
|
222 |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n")); |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n")); |
223 |
|
|
224 |
/* No match was found, send ICMP destination port unreachable unless |
/* No match was found, send ICMP destination port unreachable unless |
321 |
netif = ip_route(&(pcb->remote_ip)); |
netif = ip_route(&(pcb->remote_ip)); |
322 |
/* no outgoing network interface could be found? */ |
/* no outgoing network interface could be found? */ |
323 |
if (netif == NULL) { |
if (netif == NULL) { |
324 |
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr)); |
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%"X32_F"\n", pcb->remote_ip.addr)); |
325 |
UDP_STATS_INC(udp.rterr); |
UDP_STATS_INC(udp.rterr); |
326 |
return ERR_RTE; |
return ERR_RTE; |
327 |
} |
} |
361 |
src_ip = &(pcb->local_ip); |
src_ip = &(pcb->local_ip); |
362 |
} |
} |
363 |
|
|
364 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len)); |
365 |
|
|
366 |
/* UDP Lite protocol? */ |
/* UDP Lite protocol? */ |
367 |
if (pcb->flags & UDP_FLAGS_UDPLITE) { |
if (pcb->flags & UDP_FLAGS_UDPLITE) { |
368 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len)); |
369 |
/* set UDP message length in UDP header */ |
/* set UDP message length in UDP header */ |
370 |
udphdr->len = htons(pcb->chksum_len); |
udphdr->len = htons(pcb->chksum_len); |
371 |
/* calculate checksum */ |
/* calculate checksum */ |
382 |
err = ip_output_if (q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); |
err = ip_output_if (q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); |
383 |
/* UDP */ |
/* UDP */ |
384 |
} else { |
} else { |
385 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); |
386 |
udphdr->len = htons(q->tot_len); |
udphdr->len = htons(q->tot_len); |
387 |
/* calculate checksum */ |
/* calculate checksum */ |
388 |
#if CHECKSUM_GEN_UDP |
#if CHECKSUM_GEN_UDP |
394 |
#else |
#else |
395 |
udphdr->chksum = 0x0000; |
udphdr->chksum = 0x0000; |
396 |
#endif |
#endif |
397 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); |
398 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); |
399 |
/* output to IP */ |
/* output to IP */ |
400 |
err = ip_output_if(q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif); |
err = ip_output_if(q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif); |
433 |
{ |
{ |
434 |
struct udp_pcb *ipcb; |
struct udp_pcb *ipcb; |
435 |
u8_t rebind; |
u8_t rebind; |
436 |
#if SO_REUSE |
|
|
int reuse_port_all_set = 1; |
|
|
#endif /* SO_REUSE */ |
|
437 |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = ")); |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = ")); |
438 |
ip_addr_debug_print(UDP_DEBUG, ipaddr); |
ip_addr_debug_print(UDP_DEBUG, ipaddr); |
439 |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %u)\n", port)); |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %"U16_F")\n", port)); |
440 |
|
|
441 |
rebind = 0; |
rebind = 0; |
442 |
/* Check for double bind and rebind of the same pcb */ |
/* Check for double bind and rebind of the same pcb */ |
449 |
rebind = 1; |
rebind = 1; |
450 |
} |
} |
451 |
|
|
|
#if SO_REUSE == 0 |
|
452 |
/* this code does not allow upper layer to share a UDP port for |
/* this code does not allow upper layer to share a UDP port for |
453 |
listening to broadcast or multicast traffic (See SO_REUSE_ADDR and |
listening to broadcast or multicast traffic (See SO_REUSE_ADDR and |
454 |
SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR |
SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR |
461 |
ip_addr_isany(ipaddr) || |
ip_addr_isany(ipaddr) || |
462 |
ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { |
ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { |
463 |
/* other PCB already binds to this local IP and port */ |
/* other PCB already binds to this local IP and port */ |
464 |
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %u already bound by another pcb\n", port)); |
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %"U16_F" already bound by another pcb\n", port)); |
465 |
return ERR_USE; |
return ERR_USE; |
466 |
} |
} |
467 |
#endif |
#endif |
468 |
|
|
|
#else /* SO_REUSE */ |
|
|
/* Search through list of PCB's. |
|
|
|
|
|
If there is a PCB bound to specified port and IP_ADDR_ANY another PCB can be bound to the interface IP |
|
|
or to the loopback address on the same port if SOF_REUSEADDR is set. Any combination of PCB's bound to |
|
|
the same local port, but to one address out of {IP_ADDR_ANY, 127.0.0.1, interface IP} at a time is valid. |
|
|
But no two PCB's bound to same local port and same local address is valid. |
|
|
|
|
|
If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then |
|
|
all PCB's must have the SOF_REUSEPORT option set. |
|
|
|
|
|
When the two options aren't set and specified port is already bound, ERR_USE is returned saying that |
|
|
address is already in use. */ |
|
|
else if (ipcb->local_port == port) { |
|
|
if(ip_addr_cmp(&(ipcb->local_ip), ipaddr)) { |
|
|
if(pcb->so_options & SOF_REUSEPORT) { |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT set and same address.\n")); |
|
|
reuse_port_all_set = (reuse_port_all_set && (ipcb->so_options & SOF_REUSEPORT)); |
|
|
} |
|
|
else { |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT not set and same address.\n")); |
|
|
return ERR_USE; |
|
|
} |
|
|
} |
|
|
else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(ipcb->local_ip))) || |
|
|
(!ip_addr_isany(ipaddr) && ip_addr_isany(&(ipcb->local_ip)))) { |
|
|
if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); |
|
|
return ERR_USE; |
|
|
} |
|
|
} |
|
|
} |
|
|
#endif /* SO_REUSE */ |
|
|
|
|
|
} |
|
|
|
|
|
#if SO_REUSE |
|
|
/* If SOF_REUSEPORT isn't set in all PCB's bound to specified port and local address specified then |
|
|
{IP, port} can't be reused. */ |
|
|
if(!reuse_port_all_set) { |
|
|
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: not all sockets have SO_REUSEPORT set.\n")); |
|
|
return ERR_USE; |
|
469 |
} |
} |
|
#endif /* SO_REUSE */ |
|
470 |
|
|
471 |
ip_addr_set(&pcb->local_ip, ipaddr); |
ip_addr_set(&pcb->local_ip, ipaddr); |
472 |
/* no port specified? */ |
/* no port specified? */ |
497 |
pcb->next = udp_pcbs; |
pcb->next = udp_pcbs; |
498 |
udp_pcbs = pcb; |
udp_pcbs = pcb; |
499 |
} |
} |
500 |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %u.%u.%u.%u, port %u\n", |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n", |
501 |
(unsigned int)(ntohl(pcb->local_ip.addr) >> 24 & 0xff), |
(u16_t)(ntohl(pcb->local_ip.addr) >> 24 & 0xff), |
502 |
(unsigned int)(ntohl(pcb->local_ip.addr) >> 16 & 0xff), |
(u16_t)(ntohl(pcb->local_ip.addr) >> 16 & 0xff), |
503 |
(unsigned int)(ntohl(pcb->local_ip.addr) >> 8 & 0xff), |
(u16_t)(ntohl(pcb->local_ip.addr) >> 8 & 0xff), |
504 |
(unsigned int)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port)); |
(u16_t)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port)); |
505 |
return ERR_OK; |
return ERR_OK; |
506 |
} |
} |
507 |
/** |
/** |
550 |
pcb->local_ip.addr = 0; |
pcb->local_ip.addr = 0; |
551 |
} |
} |
552 |
#endif |
#endif |
553 |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %u.%u.%u.%u, port %u\n", |
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n", |
554 |
(unsigned int)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff), |
(u16_t)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff), |
555 |
(unsigned int)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff), |
(u16_t)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff), |
556 |
(unsigned int)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff), |
(u16_t)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff), |
557 |
(unsigned int)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port)); |
(u16_t)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port)); |
558 |
|
|
559 |
/* Insert UDP PCB into the list of active UDP PCBs. */ |
/* Insert UDP PCB into the list of active UDP PCBs. */ |
560 |
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { |
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { |
639 |
} |
} |
640 |
|
|
641 |
#if UDP_DEBUG |
#if UDP_DEBUG |
642 |
int |
void |
643 |
udp_debug_print(struct udp_hdr *udphdr) |
udp_debug_print(struct udp_hdr *udphdr) |
644 |
{ |
{ |
645 |
LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); |
LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); |
646 |
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); |
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); |
647 |
LWIP_DEBUGF(UDP_DEBUG, ("| %5u | %5u | (src port, dest port)\n", |
LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", |
648 |
ntohs(udphdr->src), ntohs(udphdr->dest))); |
ntohs(udphdr->src), ntohs(udphdr->dest))); |
649 |
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); |
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); |
650 |
LWIP_DEBUGF(UDP_DEBUG, ("| %5u | 0x%04x | (len, chksum)\n", |
LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n", |
651 |
ntohs(udphdr->len), ntohs(udphdr->chksum))); |
ntohs(udphdr->len), ntohs(udphdr->chksum))); |
652 |
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); |
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); |
|
return 0; |
|
653 |
} |
} |
654 |
#endif /* UDP_DEBUG */ |
#endif /* UDP_DEBUG */ |
655 |
|
|