00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __LWIP_UDP_H__
00033 #define __LWIP_UDP_H__
00034
00035 #include "lwip/opt.h"
00036
00037 #if LWIP_UDP
00038
00039 #include "lwip/pbuf.h"
00040 #include "lwip/netif.h"
00041 #include "lwip/ip_addr.h"
00042 #include "lwip/ip.h"
00043
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047
00048 #define UDP_HLEN 8
00049
00050
00051 #ifdef PACK_STRUCT_USE_INCLUDES
00052 # include "arch/bpstruct.h"
00053 #endif
00054 PACK_STRUCT_BEGIN
00055 struct udp_hdr {
00056 PACK_STRUCT_FIELD(u16_t src);
00057 PACK_STRUCT_FIELD(u16_t dest);
00058 PACK_STRUCT_FIELD(u16_t len);
00059 PACK_STRUCT_FIELD(u16_t chksum);
00060 } PACK_STRUCT_STRUCT;
00061 PACK_STRUCT_END
00062 #ifdef PACK_STRUCT_USE_INCLUDES
00063 # include "arch/epstruct.h"
00064 #endif
00065
00066 #define UDP_FLAGS_NOCHKSUM 0x01U
00067 #define UDP_FLAGS_UDPLITE 0x02U
00068 #define UDP_FLAGS_CONNECTED 0x04U
00069
00070 struct udp_pcb {
00071
00072 IP_PCB;
00073
00074
00075
00076 struct udp_pcb *next;
00077
00078 u8_t flags;
00079
00080 u16_t local_port, remote_port;
00081
00082 #if LWIP_IGMP
00083
00084 struct ip_addr multicast_ip;
00085 #endif
00086
00087 #if LWIP_UDPLITE
00088
00089 u16_t chksum_len_rx, chksum_len_tx;
00090 #endif
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
00107 struct ip_addr *addr, u16_t port);
00108
00109 void *recv_arg;
00110 };
00111
00112 extern struct udp_pcb *udp_pcbs;
00113
00114
00115
00116 struct udp_pcb * udp_new (void);
00117 void udp_remove (struct udp_pcb *pcb);
00118 err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr,
00119 u16_t port);
00120 err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr,
00121 u16_t port);
00122 void udp_disconnect (struct udp_pcb *pcb);
00123 void udp_recv (struct udp_pcb *pcb,
00124 void (* recv)(void *arg, struct udp_pcb *upcb,
00125 struct pbuf *p,
00126 struct ip_addr *addr,
00127 u16_t port),
00128 void *recv_arg);
00129 err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif);
00130 err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port);
00131 err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
00132
00133 #define udp_flags(pcb) ((pcb)->flags)
00134 #define udp_setflags(pcb, f) ((pcb)->flags = (f))
00135
00136
00137 void udp_input (struct pbuf *p, struct netif *inp);
00138
00139 #define udp_init()
00140
00141 #if UDP_DEBUG
00142 void udp_debug_print(struct udp_hdr *udphdr);
00143 #else
00144 #define udp_debug_print(udphdr)
00145 #endif
00146
00147 #ifdef __cplusplus
00148 }
00149 #endif
00150
00151 #endif
00152
00153 #endif