![]() |
|
|||
Warning, cross-references for /kernel/include/lwip/udp.h need to be fixed.
0001 /* 0002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 0003 * All rights reserved. 0004 * 0005 * Redistribution and use in source and binary forms, with or without modification, 0006 * are permitted provided that the following conditions are met: 0007 * 0008 * 1. Redistributions of source code must retain the above copyright notice, 0009 * this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright notice, 0011 * this list of conditions and the following disclaimer in the documentation 0012 * and/or other materials provided with the distribution. 0013 * 3. The name of the author may not be used to endorse or promote products 0014 * derived from this software without specific prior written permission. 0015 * 0016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 0017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 0018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 0019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 0021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 0024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 0025 * OF SUCH DAMAGE. 0026 * 0027 * This file is part of the lwIP TCP/IP stack. 0028 * 0029 * Author: Adam Dunkels <adam@sics.se> 0030 * 0031 */ 0032 #ifndef __LWIP_UDP_H__ 0033 #define __LWIP_UDP_H__ 0034 0035 #include "lwip/opt.h" 0036 0037 #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ 0038 0039 #include "lwip/pbuf.h" 0040 #include "lwip/netif.h" 0041 #include "lwip/ip_addr.h" 0042 #include "lwip/ip.h" 0043 0044 #ifdef __cplusplus 0045 extern "C" { 0046 #endif 0047 0048 #define UDP_HLEN 8 0049 0050 /* Fields are (of course) in network byte order. */ 0051 #ifdef PACK_STRUCT_USE_INCLUDES 0052 # include "arch/bpstruct.h" 0053 #endif 0054 PACK_STRUCT_BEGIN 0055 struct udp_hdr { 0056 PACK_STRUCT_FIELD(u16_t src); 0057 PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 0058 PACK_STRUCT_FIELD(u16_t len); 0059 PACK_STRUCT_FIELD(u16_t chksum); 0060 } PACK_STRUCT_STRUCT; 0061 PACK_STRUCT_END 0062 #ifdef PACK_STRUCT_USE_INCLUDES 0063 # include "arch/epstruct.h" 0064 #endif 0065 0066 #define UDP_FLAGS_NOCHKSUM 0x01U 0067 #define UDP_FLAGS_UDPLITE 0x02U 0068 #define UDP_FLAGS_CONNECTED 0x04U 0069 0070 struct udp_pcb { 0071 /* Common members of all PCB types */ 0072 IP_PCB; 0073 0074 /* Protocol specific PCB members */ 0075 0076 struct udp_pcb *next; 0077 0078 u8_t flags; 0079 /* ports are in host byte order */ 0080 u16_t local_port, remote_port; 0081 0082 #if LWIP_IGMP 0083 /* outgoing network interface for multicast packets */ 0084 struct ip_addr multicast_ip; 0085 #endif /* LWIP_IGMP */ 0086 0087 #if LWIP_UDPLITE 0088 /* used for UDP_LITE only */ 0089 u16_t chksum_len_rx, chksum_len_tx; 0090 #endif /* LWIP_UDPLITE */ 0091 0092 /* receive callback function 0093 * addr and port are in same byte order as in the pcb 0094 * The callback is responsible for freeing the pbuf 0095 * if it's not used any more. 0096 * 0097 * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf 0098 * makes 'addr' invalid, too. 0099 * 0100 * @param arg user supplied argument (udp_pcb.recv_arg) 0101 * @param pcb the udp_pcb which received data 0102 * @param p the packet buffer that was received 0103 * @param addr the remote IP address from which the packet was received 0104 * @param port the remote port from which the packet was received 0105 */ 0106 void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, 0107 struct ip_addr *addr, u16_t port); 0108 /* user-supplied argument for the recv callback */ 0109 void *recv_arg; 0110 }; 0111 /* udp_pcbs export for exernal reference (e.g. SNMP agent) */ 0112 extern struct udp_pcb *udp_pcbs; 0113 0114 /* The following functions is the application layer interface to the 0115 UDP code. */ 0116 struct udp_pcb * udp_new (void); 0117 void udp_remove (struct udp_pcb *pcb); 0118 err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr, 0119 u16_t port); 0120 err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr, 0121 u16_t port); 0122 void udp_disconnect (struct udp_pcb *pcb); 0123 void udp_recv (struct udp_pcb *pcb, 0124 void (* recv)(void *arg, struct udp_pcb *upcb, 0125 struct pbuf *p, 0126 struct ip_addr *addr, 0127 u16_t port), 0128 void *recv_arg); 0129 err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif); 0130 err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port); 0131 err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); 0132 0133 #define udp_flags(pcb) ((pcb)->flags) 0134 #define udp_setflags(pcb, f) ((pcb)->flags = (f)) 0135 0136 /* The following functions are the lower layer interface to UDP. */ 0137 void udp_input (struct pbuf *p, struct netif *inp); 0138 0139 #define udp_init() /* Compatibility define, not init needed. */ 0140 0141 #if UDP_DEBUG 0142 void udp_debug_print(struct udp_hdr *udphdr); 0143 #else 0144 #define udp_debug_print(udphdr) 0145 #endif 0146 0147 #ifdef __cplusplus 0148 } 0149 #endif 0150 0151 #endif /* LWIP_UDP */ 0152 0153 #endif /* __LWIP_UDP_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |