ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

udp.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00003  * All rights reserved. 
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification, 
00006  * are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright notice,
00009  *    this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright notice,
00011  *    this list of conditions and the following disclaimer in the documentation
00012  *    and/or other materials provided with the distribution.
00013  * 3. The name of the author may not be used to endorse or promote products
00014  *    derived from this software without specific prior written permission. 
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00025  * OF SUCH DAMAGE.
00026  *
00027  * This file is part of the lwIP TCP/IP stack.
00028  * 
00029  * Author: Adam Dunkels <adam@sics.se>
00030  *
00031  */
00032 #ifndef __LWIP_UDP_H__
00033 #define __LWIP_UDP_H__
00034 
00035 #include "lwip/opt.h"
00036 
00037 #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
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 /* Fields are (of course) in network byte order. */
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);  /* src/dest UDP ports */
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 #define UDP_FLAGS_MULTICAST_LOOP 0x08U
00070 
00071 struct udp_pcb;
00072 
00087 typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
00088     ip_addr_t *addr, u16_t port);
00089 
00090 
00091 struct udp_pcb {
00092 /* Common members of all PCB types */
00093   IP_PCB;
00094 
00095 /* Protocol specific PCB members */
00096 
00097   struct udp_pcb *next;
00098 
00099   u8_t flags;
00101   u16_t local_port, remote_port;
00102 
00103 #if LWIP_IGMP
00104 
00105   ip_addr_t multicast_ip;
00106 #endif /* LWIP_IGMP */
00107 
00108 #if LWIP_UDPLITE
00109 
00110   u16_t chksum_len_rx, chksum_len_tx;
00111 #endif /* LWIP_UDPLITE */
00112 
00114   udp_recv_fn recv;
00116   void *recv_arg;  
00117 };
00118 /* udp_pcbs export for exernal reference (e.g. SNMP agent) */
00119 extern struct udp_pcb *udp_pcbs;
00120 
00121 /* The following functions is the application layer interface to the
00122    UDP code. */
00123 struct udp_pcb * udp_new        (void);
00124 void             udp_remove     (struct udp_pcb *pcb);
00125 err_t            udp_bind       (struct udp_pcb *pcb, ip_addr_t *ipaddr,
00126                                  u16_t port);
00127 err_t            udp_connect    (struct udp_pcb *pcb, ip_addr_t *ipaddr,
00128                                  u16_t port);
00129 void             udp_disconnect (struct udp_pcb *pcb);
00130 void             udp_recv       (struct udp_pcb *pcb, udp_recv_fn recv,
00131                                  void *recv_arg);
00132 err_t            udp_sendto_if  (struct udp_pcb *pcb, struct pbuf *p,
00133                                  ip_addr_t *dst_ip, u16_t dst_port,
00134                                  struct netif *netif);
00135 err_t            udp_sendto     (struct udp_pcb *pcb, struct pbuf *p,
00136                                  ip_addr_t *dst_ip, u16_t dst_port);
00137 err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);
00138 
00139 #if LWIP_CHECKSUM_ON_COPY
00140 err_t            udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p,
00141                                  ip_addr_t *dst_ip, u16_t dst_port,
00142                                  struct netif *netif, u8_t have_chksum,
00143                                  u16_t chksum);
00144 err_t            udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p,
00145                                  ip_addr_t *dst_ip, u16_t dst_port,
00146                                  u8_t have_chksum, u16_t chksum);
00147 err_t            udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
00148                                  u8_t have_chksum, u16_t chksum);
00149 #endif /* LWIP_CHECKSUM_ON_COPY */
00150 
00151 #define          udp_flags(pcb) ((pcb)->flags)
00152 #define          udp_setflags(pcb, f)  ((pcb)->flags = (f))
00153 
00154 /* The following functions are the lower layer interface to UDP. */
00155 void             udp_input      (struct pbuf *p, struct netif *inp);
00156 
00157 #define udp_init() /* Compatibility define, not init needed. */
00158 
00159 #if UDP_DEBUG
00160 void udp_debug_print(struct udp_hdr *udphdr);
00161 #else
00162 #define udp_debug_print(udphdr)
00163 #endif
00164 
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168 
00169 #endif /* LWIP_UDP */
00170 
00171 #endif /* __LWIP_UDP_H__ */

Generated on Sat May 26 2012 04:26:40 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.