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 
00033 
00034 
00035 #ifndef __LWIP_UDP_H__
00036 #define __LWIP_UDP_H__
00037 
00038 #include "net/arch.h"
00039 
00040 #include "net/pbuf.h"
00041 
00042 #include "net/ipv4/inet.h"
00043 
00044 #include "net/ipv4/ip.h"
00045 
00046 #include "net/err.h"
00047 
00048 #define UDP_HLEN 8
00049 
00050 struct udp_hdr {
00051   PACK_STRUCT_FIELD(uInt16 src);
00052   PACK_STRUCT_FIELD(uInt16 dest);  
00053   PACK_STRUCT_FIELD(uInt16 len);
00054   PACK_STRUCT_FIELD(uInt16 chksum);
00055 } PACK_STRUCT_STRUCT;
00056 
00057 #define UDP_FLAGS_NOCHKSUM 0x01
00058 #define UDP_FLAGS_UDPLITE  0x02
00059 
00060 struct udp_pcb {
00061   struct udp_pcb *next;
00062 
00063   struct ip_addr local_ip, remote_ip;
00064   uInt16 local_port, remote_port;
00065   
00066   uInt8 flags;
00067   uInt16 chksum_len;
00068   
00069   void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
00070                 struct ip_addr *addr, uInt16 port);
00071   void *recv_arg;  
00072 };
00073 
00074 
00075 
00076 struct udp_pcb * udp_new        (void);
00077 void             udp_remove     (struct udp_pcb *pcb);
00078 err_t            udp_bind       (struct udp_pcb *pcb, struct ip_addr *ipaddr,
00079                                  uInt16 port);
00080 err_t            udp_connect    (struct udp_pcb *pcb, struct ip_addr *ipaddr,
00081                                  uInt16 port);
00082 void             udp_recv       (struct udp_pcb *pcb,
00083                                  void (* recv)(void *arg, struct udp_pcb *upcb,
00084                                                struct pbuf *p,
00085                                                struct ip_addr *addr,
00086                                                uInt16 port),
00087                                  void *recv_arg);
00088 err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);
00089 
00090 #define          udp_flags(pcb)  ((pcb)->flags)
00091 #define          udp_setflags(pcb, f)  ((pcb)->flags = (f))
00092 
00093 
00094 
00095 uInt8             udp_lookup     (struct ip_hdr *iphdr, struct netif *inp);
00096 void             udp_input      (struct pbuf *p, struct netif *inp);
00097 void             udp_init       (void);
00098 
00099 
00100 #endif 
00101 
00102