32 #ifndef __LWIP_UDP_H__
33 #define __LWIP_UDP_H__
39 #include "lwip/pbuf.h"
40 #include "lwip/netif.h"
41 #include "lwip/ip_addr.h"
51 #ifdef PACK_STRUCT_USE_INCLUDES
52 # include "arch/bpstruct.h"
56 PACK_STRUCT_FIELD(u16_t src);
57 PACK_STRUCT_FIELD(u16_t dest);
58 PACK_STRUCT_FIELD(u16_t len);
59 PACK_STRUCT_FIELD(u16_t chksum);
62 #ifdef PACK_STRUCT_USE_INCLUDES
63 # include "arch/epstruct.h"
66 #define UDP_FLAGS_NOCHKSUM 0x01U
67 #define UDP_FLAGS_UDPLITE 0x02U
68 #define UDP_FLAGS_CONNECTED 0x04U
69 #define UDP_FLAGS_MULTICAST_LOOP 0x08U
87 typedef void (*udp_recv_fn)(
void *arg,
struct udp_pcb *pcb,
struct pbuf *p,
88 ip_addr_t *addr, u16_t port);
101 u16_t local_port, remote_port;
105 ip_addr_t multicast_ip;
110 u16_t chksum_len_rx, chksum_len_tx;
119 extern struct udp_pcb *udp_pcbs;
123 struct udp_pcb * udp_new (
void)ICACHE_FLASH_ATTR;
124 void udp_remove (struct udp_pcb *pcb)ICACHE_FLASH_ATTR;
125 err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr,
126 u16_t port)ICACHE_FLASH_ATTR;
127 err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr,
128 u16_t port)ICACHE_FLASH_ATTR;
129 void udp_disconnect (struct udp_pcb *pcb)ICACHE_FLASH_ATTR;
130 void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv,
131 void *recv_arg)ICACHE_FLASH_ATTR;
132 err_t udp_sendto_if (struct udp_pcb *pcb, struct
pbuf *p,
133 ip_addr_t *dst_ip, u16_t dst_port,
135 err_t udp_sendto (struct udp_pcb *pcb, struct
pbuf *p,
136 ip_addr_t *dst_ip, u16_t dst_port)ICACHE_FLASH_ATTR;
137 err_t udp_send (struct udp_pcb *pcb, struct
pbuf *p)ICACHE_FLASH_ATTR;
139 #if LWIP_CHECKSUM_ON_COPY
140 err_t udp_sendto_if_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
141 ip_addr_t *dst_ip, u16_t dst_port,
143 u16_t chksum)ICACHE_FLASH_ATTR;
144 err_t udp_sendto_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
145 ip_addr_t *dst_ip, u16_t dst_port,
146 u8_t have_chksum, u16_t chksum)ICACHE_FLASH_ATTR;
147 err_t udp_send_chksum(
struct udp_pcb *pcb,
struct pbuf *p,
148 u8_t have_chksum, u16_t chksum)ICACHE_FLASH_ATTR;
151 #define udp_flags(pcb) ((pcb)->flags)
152 #define udp_setflags(pcb, f) ((pcb)->flags = (f))
155 void udp_input (
struct pbuf *p,
struct netif *inp)ICACHE_FLASH_ATTR;
160 void udp_debug_print(
struct udp_hdr *udphdr)ICACHE_FLASH_ATTR;
162 #define udp_debug_print(udphdr)