68#ifndef UDP_LOCAL_PORT_RANGE_START
71#define UDP_LOCAL_PORT_RANGE_START 0xc000
72#define UDP_LOCAL_PORT_RANGE_END 0xffff
73#define UDP_ENSURE_LOCAL_PORT_RANGE(port) ((u16_t)(((port) & (u16_t)~UDP_LOCAL_PORT_RANGE_START) + UDP_LOCAL_PORT_RANGE_START))
77static u16_t udp_port = UDP_LOCAL_PORT_RANGE_START;
81struct udp_pcb *udp_pcbs;
90 udp_port = UDP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND());
106 if (udp_port++ == UDP_LOCAL_PORT_RANGE_END) {
107 udp_port = UDP_LOCAL_PORT_RANGE_START;
110 for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
111 if (pcb->local_port == udp_port) {
112 if (++n > (UDP_LOCAL_PORT_RANGE_END - UDP_LOCAL_PORT_RANGE_START)) {
130udp_input_local_match(
struct udp_pcb *pcb,
struct netif *inp, u8_t broadcast)
135 LWIP_ASSERT(
"udp_input_local_match: invalid pcb", pcb != NULL);
136 LWIP_ASSERT(
"udp_input_local_match: invalid netif", inp != NULL);
139 if ((pcb->netif_idx != NETIF_NO_INDEX) &&
140 (pcb->netif_idx != netif_get_index(ip_data.current_input_netif))) {
145 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) {
146#if LWIP_IPV4 && IP_SOF_BROADCAST_RECV
147 if ((broadcast != 0) && !
ip_get_option(pcb, SOF_BROADCAST)) {
159 if (broadcast != 0) {
160#if IP_SOF_BROADCAST_RECV
164 if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) ||
166 ip4_addr_net_eq(ip_2_ip4(&pcb->local_ip), ip4_current_dest_addr(), netif_ip4_netmask(inp))) {
194udp_input(
struct pbuf *p,
struct netif *inp)
197 struct udp_pcb *pcb, *prev;
198 struct udp_pcb *uncon_pcb;
207 LWIP_ASSERT(
"udp_input: invalid pbuf", p != NULL);
208 LWIP_ASSERT(
"udp_input: invalid netif", inp != NULL);
212 UDP_STATS_INC(udp.recv);
215 if (p->len < UDP_HLEN) {
218 (
"udp_input: short UDP datagram (%"U16_F
" bytes) discarded\n", p->tot_len));
219 UDP_STATS_INC(udp.lenerr);
220 UDP_STATS_INC(udp.drop);
221 MIB2_STATS_INC(mib2.udpinerrors);
226 udphdr = (
struct udp_hdr *)p->payload;
231 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_input: received datagram of length %"U16_F
"\n", p->tot_len));
234 src = lwip_ntohs(udphdr->src);
235 dest = lwip_ntohs(udphdr->dest);
237 udp_debug_print(udphdr);
242 LWIP_DEBUGF(
UDP_DEBUG, (
", %"U16_F
") <-- (", lwip_ntohs(udphdr->dest)));
244 LWIP_DEBUGF(
UDP_DEBUG, (
", %"U16_F
")\n", lwip_ntohs(udphdr->src)));
253 for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
256 ip_addr_debug_print_val(
UDP_DEBUG, pcb->local_ip);
257 LWIP_DEBUGF(
UDP_DEBUG, (
", %"U16_F
") <-- (", pcb->local_port));
258 ip_addr_debug_print_val(
UDP_DEBUG, pcb->remote_ip);
259 LWIP_DEBUGF(
UDP_DEBUG, (
", %"U16_F
")\n", pcb->remote_port));
262 if ((pcb->local_port == dest) &&
263 (udp_input_local_match(pcb, inp, broadcast) != 0)) {
264 if ((pcb->flags & UDP_FLAGS_CONNECTED) == 0) {
265 if (uncon_pcb == NULL) {
269 }
else if (broadcast && ip4_current_dest_addr()->addr ==
IPADDR_BROADCAST) {
271 if (!IP_IS_V4_VAL(uncon_pcb->local_ip) || !ip4_addr_eq(ip_2_ip4(&uncon_pcb->local_ip), netif_ip4_addr(inp))) {
273 if (IP_IS_V4_VAL(pcb->local_ip) && ip4_addr_eq(ip_2_ip4(&pcb->local_ip), netif_ip4_addr(inp))) {
281 else if (!ip_addr_isany(&pcb->local_ip)) {
289 if ((pcb->remote_port == src) &&
290 (ip_addr_isany_val(pcb->remote_ip) ||
296 prev->next = pcb->next;
297 pcb->next = udp_pcbs;
300 UDP_STATS_INC(udp.cachehit);
318 if (ip_current_is_v6()) {
319 for_us = netif_get_ip6_addr_match(inp, ip6_current_dest_addr()) >= 0;
323 if (!ip_current_is_v6()) {
324 for_us = ip4_addr_eq(netif_ip4_addr(inp), ip4_current_dest_addr());
331#if CHECKSUM_CHECK_UDP
332 IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_CHECK_UDP) {
334 if (ip_current_header_proto() == IP_PROTO_UDPLITE) {
336 u16_t chklen = lwip_ntohs(udphdr->len);
337 if (chklen <
sizeof(
struct udp_hdr)) {
348 if (ip_chksum_pseudo_partial(p, IP_PROTO_UDPLITE,
356 if (udphdr->chksum != 0) {
357 if (ip_chksum_pseudo(p, IP_PROTO_UDP, p->tot_len,
368 LWIP_ASSERT(
"pbuf_remove_header failed", 0);
369 UDP_STATS_INC(udp.drop);
370 MIB2_STATS_INC(mib2.udpinerrors);
376 MIB2_STATS_INC(mib2.udpindatagrams);
377#if SO_REUSE && SO_REUSE_RXTOALL
382 struct udp_pcb *mpcb;
383 for (mpcb = udp_pcbs; mpcb != NULL; mpcb = mpcb->next) {
386 if ((mpcb->local_port == dest) &&
387 (udp_input_local_match(mpcb, inp, broadcast) != 0)) {
389 if (mpcb->recv != NULL) {
402 if (pcb->recv != NULL) {
413#if LWIP_ICMP || LWIP_ICMP6
419 icmp_port_unreach(ip_current_is_v6(), p);
422 UDP_STATS_INC(udp.proterr);
423 UDP_STATS_INC(udp.drop);
424 MIB2_STATS_INC(mib2.udpnoports);
431 PERF_STOP(
"udp_input");
433#if CHECKSUM_CHECK_UDP
436 (
"udp_input: UDP (or UDP Lite) datagram discarded due to failing checksum\n"));
437 UDP_STATS_INC(udp.chkerr);
438 UDP_STATS_INC(udp.drop);
439 MIB2_STATS_INC(mib2.udpinerrors);
441 PERF_STOP(
"udp_input");
467udp_send(
struct udp_pcb *pcb,
struct pbuf *p)
469 LWIP_ERROR(
"udp_send: invalid pcb", pcb != NULL,
return ERR_ARG);
470 LWIP_ERROR(
"udp_send: invalid pbuf", p != NULL,
return ERR_ARG);
472 if (IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) {
477 return udp_sendto(pcb, p, &pcb->remote_ip, pcb->remote_port);
480#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
485udp_send_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
486 u8_t have_chksum, u16_t chksum)
488 LWIP_ERROR(
"udp_send_chksum: invalid pcb", pcb != NULL,
return ERR_ARG);
489 LWIP_ERROR(
"udp_send_chksum: invalid pbuf", p != NULL,
return ERR_ARG);
491 if (IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) {
496 return udp_sendto_chksum(pcb, p, &pcb->remote_ip, pcb->remote_port,
497 have_chksum, chksum);
520udp_sendto(
struct udp_pcb *pcb,
struct pbuf *p,
521 const ip_addr_t *dst_ip, u16_t dst_port)
523#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
524 return udp_sendto_chksum(pcb, p, dst_ip, dst_port, 0, 0);
530udp_sendto_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
const ip_addr_t *dst_ip,
531 u16_t dst_port, u8_t have_chksum, u16_t chksum)
536 LWIP_ERROR(
"udp_sendto: invalid pcb", pcb != NULL,
return ERR_ARG);
537 LWIP_ERROR(
"udp_sendto: invalid pbuf", p != NULL,
return ERR_ARG);
538 LWIP_ERROR(
"udp_sendto: invalid dst_ip", dst_ip != NULL,
return ERR_ARG);
540 if (!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
546 if (pcb->netif_idx != NETIF_NO_INDEX) {
549#if LWIP_MULTICAST_TX_OPTIONS
551 if (ip_addr_ismulticast(dst_ip)) {
558 if (pcb->mcast_ifindex != NETIF_NO_INDEX) {
564 if (IP_IS_V4(dst_ip))
572 if (!ip4_addr_isany_val(pcb->mcast_ip4) &&
573 !ip4_addr_eq(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) {
574 netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4);
584 netif = ip_route(&pcb->local_ip, dst_ip);
593 UDP_STATS_INC(udp.rterr);
596#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
597 return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port,
netif, have_chksum, chksum);
599 return udp_sendto_if(pcb, p, dst_ip, dst_port,
netif);
624udp_sendto_if(
struct udp_pcb *pcb,
struct pbuf *p,
625 const ip_addr_t *dst_ip, u16_t dst_port,
struct netif *
netif)
627#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
628 return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port,
netif, 0, 0);
633udp_sendto_if_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
const ip_addr_t *dst_ip,
634 u16_t dst_port,
struct netif *
netif, u8_t have_chksum,
638 const ip_addr_t *src_ip;
640 LWIP_ERROR(
"udp_sendto_if: invalid pcb", pcb != NULL,
return ERR_ARG);
641 LWIP_ERROR(
"udp_sendto_if: invalid pbuf", p != NULL,
return ERR_ARG);
642 LWIP_ERROR(
"udp_sendto_if: invalid dst_ip", dst_ip != NULL,
return ERR_ARG);
643 LWIP_ERROR(
"udp_sendto_if: invalid netif",
netif != NULL,
return ERR_ARG);
645 if (!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
651 if (IP_IS_V6(dst_ip)) {
652 if (ip6_addr_isany(ip_2_ip6(&pcb->local_ip)) ||
653 ip6_addr_ismulticast(ip_2_ip6(&pcb->local_ip))) {
654 src_ip = ip6_select_source_address(
netif, ip_2_ip6(dst_ip));
655 if (src_ip == NULL) {
661 if (netif_get_ip6_addr_match(
netif, ip_2_ip6(&pcb->local_ip)) < 0) {
665 src_ip = &pcb->local_ip;
669#if LWIP_IPV4 && LWIP_IPV6
673 if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) ||
674 ip4_addr_ismulticast(ip_2_ip4(&pcb->local_ip))) {
677 src_ip = netif_ip_addr4(
netif);
681 if (!ip4_addr_eq(ip_2_ip4(&(pcb->local_ip)), netif_ip4_addr(
netif))) {
686 src_ip = &pcb->local_ip;
689#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
690 return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port,
netif, have_chksum, chksum, src_ip);
692 return udp_sendto_if_src(pcb, p, dst_ip, dst_port,
netif, src_ip);
699udp_sendto_if_src(
struct udp_pcb *pcb,
struct pbuf *p,
700 const ip_addr_t *dst_ip, u16_t dst_port,
struct netif *
netif,
const ip_addr_t *src_ip)
702#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
703 return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port,
netif, 0, 0, src_ip);
708udp_sendto_if_src_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
const ip_addr_t *dst_ip,
709 u16_t dst_port,
struct netif *
netif, u8_t have_chksum,
710 u16_t chksum,
const ip_addr_t *src_ip)
721 LWIP_ERROR(
"udp_sendto_if_src: invalid pcb", pcb != NULL,
return ERR_ARG);
722 LWIP_ERROR(
"udp_sendto_if_src: invalid pbuf", p != NULL,
return ERR_ARG);
723 LWIP_ERROR(
"udp_sendto_if_src: invalid dst_ip", dst_ip != NULL,
return ERR_ARG);
724 LWIP_ERROR(
"udp_sendto_if_src: invalid src_ip", src_ip != NULL,
return ERR_ARG);
725 LWIP_ERROR(
"udp_sendto_if_src: invalid netif",
netif != NULL,
return ERR_ARG);
727 if (!IP_ADDR_PCB_VERSION_MATCH(pcb, src_ip) ||
728 !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
732#if LWIP_IPV4 && IP_SOF_BROADCAST
738 ip_addr_isbroadcast(dst_ip,
netif)) {
740 (
"udp_sendto_if: SOF_BROADCAST not enabled on pcb %p\n", (
void *)pcb));
746 if (pcb->local_port == 0) {
748 err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
756 if ((u16_t)(p->tot_len + UDP_HLEN) < p->tot_len) {
768 if (p->tot_len != 0) {
774 (
"udp_send: added header pbuf %p before given pbuf %p\n", (
void *)q, (
void *)p));
779 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: added header in given pbuf %p\n", (
void *)p));
781 LWIP_ASSERT(
"check that first pbuf can hold struct udp_hdr",
782 (q->len >=
sizeof(
struct udp_hdr)));
784 udphdr = (
struct udp_hdr *)q->payload;
785 udphdr->src = lwip_htons(pcb->local_port);
786 udphdr->dest = lwip_htons(dst_port);
788 udphdr->chksum = 0x0000;
791#if LWIP_MULTICAST_TX_OPTIONS
792 if (((pcb->flags & UDP_FLAGS_MULTICAST_LOOP) != 0) && ip_addr_ismulticast(dst_ip)) {
797 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: sending datagram of length %"U16_F
"\n", q->tot_len));
801 if (pcb->flags & UDP_FLAGS_UDPLITE) {
802 u16_t chklen, chklen_hdr;
803 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: UDP LITE packet length %"U16_F
"\n", q->tot_len));
805 chklen_hdr = chklen = pcb->chksum_len_tx;
806 if ((chklen <
sizeof(
struct udp_hdr)) || (chklen > q->tot_len)) {
808 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: UDP LITE pcb->chksum_len is illegal: %"U16_F
"\n", chklen));
819 udphdr->len = lwip_htons(chklen_hdr);
822 IF__NETIF_CHECKSUM_ENABLED(
netif, NETIF_CHECKSUM_GEN_UDP) {
823#if LWIP_CHECKSUM_ON_COPY
828 udphdr->chksum = ip_chksum_pseudo_partial(q, IP_PROTO_UDPLITE,
829 q->tot_len, chklen, src_ip, dst_ip);
830#if LWIP_CHECKSUM_ON_COPY
833 acc = udphdr->chksum + (u16_t)~(chksum);
839 if (udphdr->chksum == 0x0000) {
840 udphdr->chksum = 0xffff;
845 ip_proto = IP_PROTO_UDPLITE;
849 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: UDP packet length %"U16_F
"\n", q->tot_len));
850 udphdr->len = lwip_htons(q->tot_len);
853 IF__NETIF_CHECKSUM_ENABLED(
netif, NETIF_CHECKSUM_GEN_UDP) {
855 if (IP_IS_V6(dst_ip) || (pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) {
857#if LWIP_CHECKSUM_ON_COPY
860 udpchksum = ip_chksum_pseudo_partial(q, IP_PROTO_UDP,
861 q->tot_len, UDP_HLEN, src_ip, dst_ip);
862 acc = udpchksum + (u16_t)~(chksum);
867 udpchksum = ip_chksum_pseudo(q, IP_PROTO_UDP, q->tot_len,
872 if (udpchksum == 0x0000) {
875 udphdr->chksum = udpchksum;
879 ip_proto = IP_PROTO_UDP;
883#if LWIP_MULTICAST_TX_OPTIONS
884 ttl = (ip_addr_ismulticast(dst_ip) ? udp_get_multicast_ttl(pcb) : pcb->ttl);
889 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: UDP checksum 0x%04"X16_F
"\n", udphdr->chksum));
890 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_send: ip_output_if (,,,,0x%02"X16_F
",)\n", (u16_t)ip_proto));
892 NETIF_SET_HINTS(
netif, &(pcb->netif_hints));
893 err = ip_output_if_src(q, src_ip, dst_ip, ttl, pcb->tos, ip_proto,
netif);
894 NETIF_RESET_HINTS(
netif);
897 MIB2_STATS_INC(mib2.udpoutdatagrams);
907 UDP_STATS_INC(udp.xmit);
932udp_bind(
struct udp_pcb *pcb,
const ip_addr_t *ipaddr, u16_t port)
934 struct udp_pcb *ipcb;
936#if LWIP_IPV6 && LWIP_IPV6_SCOPES
937 ip_addr_t zoned_ipaddr;
944 if (ipaddr == NULL) {
948 LWIP_ERROR(
"udp_bind: invalid ipaddr", ipaddr != NULL,
return ERR_ARG);
951 LWIP_ERROR(
"udp_bind: invalid pcb", pcb != NULL,
return ERR_ARG);
959 for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
967#if LWIP_IPV6 && LWIP_IPV6_SCOPES
972 if (IP_IS_V6(ipaddr) && ip6_addr_lacks_zone(ip_2_ip6(ipaddr), IP6_UNKNOWN)) {
973 ip_addr_copy(zoned_ipaddr, *ipaddr);
974 ip6_addr_select_zone(ip_2_ip6(&zoned_ipaddr), ip_2_ip6(&zoned_ipaddr));
975 ipaddr = &zoned_ipaddr;
981 port = udp_new_port();
984 LWIP_DEBUGF(
UDP_DEBUG, (
"udp_bind: out of free UDP ports\n"));
988 for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
999 if ((ipcb->local_port == port) &&
1000 (((IP_GET_TYPE(&ipcb->local_ip) == IP_GET_TYPE(ipaddr)) &&
1002 (ip_addr_eq(&ipcb->local_ip, ipaddr) ||
1003 ip_addr_isany(ipaddr) ||
1004 ip_addr_isany(&ipcb->local_ip))) ||
1009 (
"udp_bind: local port %"U16_F
" already bound by another pcb\n", port));
1017 ip_addr_set_ipaddr(&pcb->local_ip, ipaddr);
1019 pcb->local_port = port;
1024 pcb->next = udp_pcbs;
1046udp_bind_netif(
struct udp_pcb *pcb,
const struct netif *
netif)
1050 if (
netif != NULL) {
1051 pcb->netif_idx = netif_get_index(
netif);
1053 pcb->netif_idx = NETIF_NO_INDEX;
1075udp_connect(
struct udp_pcb *pcb,
const ip_addr_t *ipaddr, u16_t port)
1077 struct udp_pcb *ipcb;
1081 LWIP_ERROR(
"udp_connect: invalid pcb", pcb != NULL,
return ERR_ARG);
1082 LWIP_ERROR(
"udp_connect: invalid ipaddr", ipaddr != NULL,
return ERR_ARG);
1084 if (pcb->local_port == 0) {
1085 err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
1091 ip_addr_set_ipaddr(&pcb->remote_ip, ipaddr);
1092#if LWIP_IPV6 && LWIP_IPV6_SCOPES
1095 if (IP_IS_V6(&pcb->remote_ip) &&
1096 ip6_addr_lacks_zone(ip_2_ip6(&pcb->remote_ip), IP6_UNKNOWN)) {
1097 ip6_addr_select_zone(ip_2_ip6(&pcb->remote_ip), ip_2_ip6(&pcb->local_ip));
1101 pcb->remote_port = port;
1102 pcb->flags |= UDP_FLAGS_CONNECTED;
1110 for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
1117 pcb->next = udp_pcbs;
1130udp_disconnect(
struct udp_pcb *pcb)
1134 LWIP_ERROR(
"udp_disconnect: invalid pcb", pcb != NULL,
return);
1137#if LWIP_IPV4 && LWIP_IPV6
1138 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) {
1139 ip_addr_copy(pcb->remote_ip, *IP_ANY_TYPE);
1142 ip_addr_set_any(IP_IS_V6_VAL(pcb->remote_ip), &pcb->remote_ip);
1143#if LWIP_IPV4 && LWIP_IPV6
1146 pcb->remote_port = 0;
1147 pcb->netif_idx = NETIF_NO_INDEX;
1149 udp_clear_flags(pcb, UDP_FLAGS_CONNECTED);
1162udp_recv(
struct udp_pcb *pcb, udp_recv_fn recv,
void *recv_arg)
1166 LWIP_ERROR(
"udp_recv: invalid pcb", pcb != NULL,
return);
1170 pcb->recv_arg = recv_arg;
1183udp_remove(
struct udp_pcb *pcb)
1185 struct udp_pcb *pcb2;
1189 LWIP_ERROR(
"udp_remove: invalid pcb", pcb != NULL,
return);
1191 mib2_udp_unbind(pcb);
1193 if (udp_pcbs == pcb) {
1195 udp_pcbs = udp_pcbs->next;
1198 for (pcb2 = udp_pcbs; pcb2 != NULL; pcb2 = pcb2->next) {
1200 if (pcb2->next != NULL && pcb2->next == pcb) {
1202 pcb2->next = pcb->next;
1225 struct udp_pcb *pcb;
1229 pcb = (
struct udp_pcb *)
memp_malloc(MEMP_UDP_PCB);
1236 memset(pcb, 0,
sizeof(
struct udp_pcb));
1238#if LWIP_MULTICAST_TX_OPTIONS
1239 udp_set_multicast_ttl(pcb,
UDP_TTL);
1262udp_new_ip_type(u8_t type)
1264 struct udp_pcb *pcb;
1269#if LWIP_IPV4 && LWIP_IPV6
1271 IP_SET_TYPE_VAL(pcb->local_ip, type);
1272 IP_SET_TYPE_VAL(pcb->remote_ip, type);
1285void udp_netif_ip_addr_changed(
const ip_addr_t *old_addr,
const ip_addr_t *new_addr)
1287 struct udp_pcb *upcb;
1289 if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
1290 for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) {
1292 if (ip_addr_eq(&upcb->local_ip, old_addr)) {
1295 ip_addr_copy(upcb->local_ip, *new_addr);
1308udp_debug_print(
struct udp_hdr *udphdr)
1310 LWIP_DEBUGF(
UDP_DEBUG, (
"UDP header:\n"));
1311 LWIP_DEBUGF(
UDP_DEBUG, (
"+-------------------------------+\n"));
1312 LWIP_DEBUGF(
UDP_DEBUG, (
"| %5"U16_F
" | %5"U16_F
" | (src port, dest port)\n",
1313 lwip_ntohs(udphdr->src), lwip_ntohs(udphdr->dest)));
1314 LWIP_DEBUGF(
UDP_DEBUG, (
"+-------------------------------+\n"));
1315 LWIP_DEBUGF(
UDP_DEBUG, (
"| %5"U16_F
" | 0x%04"X16_F
" | (len, chksum)\n",
1316 lwip_ntohs(udphdr->len), lwip_ntohs(udphdr->chksum)));
1317 LWIP_DEBUGF(
UDP_DEBUG, (
"+-------------------------------+\n"));
#define LWIP_UNUSED_ARG(x)
#define LWIP_DBG_LEVEL_SERIOUS
#define LWIP_ASSERT_CORE_LOCKED()
struct netif * netif_get_by_index(u8_t idx)
void pbuf_chain(struct pbuf *h, struct pbuf *t)
u8 pbuf_free(struct pbuf *p)
struct pbuf * pbuf_clone(pbuf_layer l, pbuf_type type, struct pbuf *p)
#define ip_get_option(pcb, opt)
#define ip_current_header_tot_len()
#define ip_current_src_addr()
#define ip_current_dest_addr()
#define ip_current_netif()
void * memp_malloc(memp_t type)
void memp_free(memp_t type, void *mem)
u8_t pbuf_header_force(struct pbuf *p, s16_t header_size)
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
u8_t pbuf_remove_header(struct pbuf *p, size_t header_size)
#define PBUF_FLAG_MCASTLOOP