Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:350011bf8be7 1 /*
simon 0:350011bf8be7 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
simon 0:350011bf8be7 3 * All rights reserved.
simon 0:350011bf8be7 4 *
simon 0:350011bf8be7 5 * Redistribution and use in source and binary forms, with or without modification,
simon 0:350011bf8be7 6 * are permitted provided that the following conditions are met:
simon 0:350011bf8be7 7 *
simon 0:350011bf8be7 8 * 1. Redistributions of source code must retain the above copyright notice,
simon 0:350011bf8be7 9 * this list of conditions and the following disclaimer.
simon 0:350011bf8be7 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
simon 0:350011bf8be7 11 * this list of conditions and the following disclaimer in the documentation
simon 0:350011bf8be7 12 * and/or other materials provided with the distribution.
simon 0:350011bf8be7 13 * 3. The name of the author may not be used to endorse or promote products
simon 0:350011bf8be7 14 * derived from this software without specific prior written permission.
simon 0:350011bf8be7 15 *
simon 0:350011bf8be7 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
simon 0:350011bf8be7 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
simon 0:350011bf8be7 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
simon 0:350011bf8be7 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
simon 0:350011bf8be7 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
simon 0:350011bf8be7 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
simon 0:350011bf8be7 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
simon 0:350011bf8be7 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
simon 0:350011bf8be7 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
simon 0:350011bf8be7 25 * OF SUCH DAMAGE.
simon 0:350011bf8be7 26 *
simon 0:350011bf8be7 27 * This file is part of the lwIP TCP/IP stack.
simon 0:350011bf8be7 28 *
simon 0:350011bf8be7 29 * Author: Adam Dunkels <adam@sics.se>
simon 0:350011bf8be7 30 *
simon 0:350011bf8be7 31 */
simon 0:350011bf8be7 32
simon 0:350011bf8be7 33
simon 0:350011bf8be7 34 #ifndef __LWIP_SOCKETS_H__
simon 0:350011bf8be7 35 #define __LWIP_SOCKETS_H__
simon 0:350011bf8be7 36
simon 0:350011bf8be7 37 #include "lwip/opt.h"
simon 0:350011bf8be7 38
simon 0:350011bf8be7 39 #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
simon 0:350011bf8be7 40
simon 0:350011bf8be7 41 #include <stddef.h> /* for size_t */
simon 0:350011bf8be7 42
simon 0:350011bf8be7 43 #include "lwip/ip_addr.h"
simon 0:350011bf8be7 44 #include "lwip/inet.h"
simon 0:350011bf8be7 45
simon 0:350011bf8be7 46 #ifdef __cplusplus
simon 0:350011bf8be7 47 extern "C" {
simon 0:350011bf8be7 48 #endif
simon 0:350011bf8be7 49
simon 0:350011bf8be7 50 /* members are in network byte order */
simon 0:350011bf8be7 51 struct sockaddr_in {
simon 0:350011bf8be7 52 u8_t sin_len;
simon 0:350011bf8be7 53 u8_t sin_family;
simon 0:350011bf8be7 54 u16_t sin_port;
simon 0:350011bf8be7 55 struct in_addr sin_addr;
simon 0:350011bf8be7 56 char sin_zero[8];
simon 0:350011bf8be7 57 };
simon 0:350011bf8be7 58
simon 0:350011bf8be7 59 struct sockaddr {
simon 0:350011bf8be7 60 u8_t sa_len;
simon 0:350011bf8be7 61 u8_t sa_family;
simon 0:350011bf8be7 62 u16_t sa_data[14];
simon 0:350011bf8be7 63 };
simon 0:350011bf8be7 64
simon 0:350011bf8be7 65 #ifndef socklen_t
simon 0:350011bf8be7 66 # define socklen_t u32_t
simon 0:350011bf8be7 67 #endif
simon 0:350011bf8be7 68
simon 0:350011bf8be7 69 /* Socket protocol types (TCP/UDP/RAW) */
simon 0:350011bf8be7 70 #define SOCK_STREAM 1
simon 0:350011bf8be7 71 #define SOCK_DGRAM 2
simon 0:350011bf8be7 72 #define SOCK_RAW 3
simon 0:350011bf8be7 73
simon 0:350011bf8be7 74 /*
simon 0:350011bf8be7 75 * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
simon 0:350011bf8be7 76 */
simon 0:350011bf8be7 77 #define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
simon 0:350011bf8be7 78 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
simon 0:350011bf8be7 79 #define SO_REUSEADDR 0x0004 /* Allow local address reuse */
simon 0:350011bf8be7 80 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
simon 0:350011bf8be7 81 #define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
simon 0:350011bf8be7 82 #define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
simon 0:350011bf8be7 83 #define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
simon 0:350011bf8be7 84 #define SO_LINGER 0x0080 /* linger on close if data present */
simon 0:350011bf8be7 85 #define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */
simon 0:350011bf8be7 86 #define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */
simon 0:350011bf8be7 87
simon 0:350011bf8be7 88 #define SO_DONTLINGER ((int)(~SO_LINGER))
simon 0:350011bf8be7 89
simon 0:350011bf8be7 90 /*
simon 0:350011bf8be7 91 * Additional options, not kept in so_options.
simon 0:350011bf8be7 92 */
simon 0:350011bf8be7 93 #define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */
simon 0:350011bf8be7 94 #define SO_RCVBUF 0x1002 /* receive buffer size */
simon 0:350011bf8be7 95 #define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */
simon 0:350011bf8be7 96 #define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */
simon 0:350011bf8be7 97 #define SO_SNDTIMEO 0x1005 /* Unimplemented: send timeout */
simon 0:350011bf8be7 98 #define SO_RCVTIMEO 0x1006 /* receive timeout */
simon 0:350011bf8be7 99 #define SO_ERROR 0x1007 /* get error status and clear */
simon 0:350011bf8be7 100 #define SO_TYPE 0x1008 /* get socket type */
simon 0:350011bf8be7 101 #define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
simon 0:350011bf8be7 102 #define SO_NO_CHECK 0x100a /* don't create UDP checksum */
simon 0:350011bf8be7 103
simon 0:350011bf8be7 104
simon 0:350011bf8be7 105 /*
simon 0:350011bf8be7 106 * Structure used for manipulating linger option.
simon 0:350011bf8be7 107 */
simon 0:350011bf8be7 108 struct linger {
simon 0:350011bf8be7 109 int l_onoff; /* option on/off */
simon 0:350011bf8be7 110 int l_linger; /* linger time */
simon 0:350011bf8be7 111 };
simon 0:350011bf8be7 112
simon 0:350011bf8be7 113 /*
simon 0:350011bf8be7 114 * Level number for (get/set)sockopt() to apply to socket itself.
simon 0:350011bf8be7 115 */
simon 0:350011bf8be7 116 #define SOL_SOCKET 0xfff /* options for socket level */
simon 0:350011bf8be7 117
simon 0:350011bf8be7 118
simon 0:350011bf8be7 119 #define AF_UNSPEC 0
simon 0:350011bf8be7 120 #define AF_INET 2
simon 0:350011bf8be7 121 #define PF_INET AF_INET
simon 0:350011bf8be7 122 #define PF_UNSPEC AF_UNSPEC
simon 0:350011bf8be7 123
simon 0:350011bf8be7 124 #define IPPROTO_IP 0
simon 0:350011bf8be7 125 #define IPPROTO_TCP 6
simon 0:350011bf8be7 126 #define IPPROTO_UDP 17
simon 0:350011bf8be7 127 #define IPPROTO_UDPLITE 136
simon 0:350011bf8be7 128
simon 0:350011bf8be7 129 /* Flags we can use with send and recv. */
simon 0:350011bf8be7 130 #define MSG_PEEK 0x01 /* Peeks at an incoming message */
simon 0:350011bf8be7 131 #define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
simon 0:350011bf8be7 132 #define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
simon 0:350011bf8be7 133 #define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
simon 0:350011bf8be7 134 #define MSG_MORE 0x10 /* Sender will send more */
simon 0:350011bf8be7 135
simon 0:350011bf8be7 136
simon 0:350011bf8be7 137 /*
simon 0:350011bf8be7 138 * Options for level IPPROTO_IP
simon 0:350011bf8be7 139 */
simon 0:350011bf8be7 140 #define IP_TOS 1
simon 0:350011bf8be7 141 #define IP_TTL 2
simon 0:350011bf8be7 142
simon 0:350011bf8be7 143 #if LWIP_TCP
simon 0:350011bf8be7 144 /*
simon 0:350011bf8be7 145 * Options for level IPPROTO_TCP
simon 0:350011bf8be7 146 */
simon 0:350011bf8be7 147 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
simon 0:350011bf8be7 148 #define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
simon 0:350011bf8be7 149 #define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
simon 0:350011bf8be7 150 #define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
simon 0:350011bf8be7 151 #define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
simon 0:350011bf8be7 152 #endif /* LWIP_TCP */
simon 0:350011bf8be7 153
simon 0:350011bf8be7 154 #if LWIP_UDP && LWIP_UDPLITE
simon 0:350011bf8be7 155 /*
simon 0:350011bf8be7 156 * Options for level IPPROTO_UDPLITE
simon 0:350011bf8be7 157 */
simon 0:350011bf8be7 158 #define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
simon 0:350011bf8be7 159 #define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
simon 0:350011bf8be7 160 #endif /* LWIP_UDP && LWIP_UDPLITE*/
simon 0:350011bf8be7 161
simon 0:350011bf8be7 162
simon 0:350011bf8be7 163 #if LWIP_IGMP
simon 0:350011bf8be7 164 /*
simon 0:350011bf8be7 165 * Options and types for UDP multicast traffic handling
simon 0:350011bf8be7 166 */
simon 0:350011bf8be7 167 #define IP_ADD_MEMBERSHIP 3
simon 0:350011bf8be7 168 #define IP_DROP_MEMBERSHIP 4
simon 0:350011bf8be7 169 #define IP_MULTICAST_TTL 5
simon 0:350011bf8be7 170 #define IP_MULTICAST_IF 6
simon 0:350011bf8be7 171 #define IP_MULTICAST_LOOP 7
simon 0:350011bf8be7 172
simon 0:350011bf8be7 173 typedef struct ip_mreq {
simon 0:350011bf8be7 174 struct in_addr imr_multiaddr; /* IP multicast address of group */
simon 0:350011bf8be7 175 struct in_addr imr_interface; /* local IP address of interface */
simon 0:350011bf8be7 176 } ip_mreq;
simon 0:350011bf8be7 177 #endif /* LWIP_IGMP */
simon 0:350011bf8be7 178
simon 0:350011bf8be7 179 /*
simon 0:350011bf8be7 180 * The Type of Service provides an indication of the abstract
simon 0:350011bf8be7 181 * parameters of the quality of service desired. These parameters are
simon 0:350011bf8be7 182 * to be used to guide the selection of the actual service parameters
simon 0:350011bf8be7 183 * when transmitting a datagram through a particular network. Several
simon 0:350011bf8be7 184 * networks offer service precedence, which somehow treats high
simon 0:350011bf8be7 185 * precedence traffic as more important than other traffic (generally
simon 0:350011bf8be7 186 * by accepting only traffic above a certain precedence at time of high
simon 0:350011bf8be7 187 * load). The major choice is a three way tradeoff between low-delay,
simon 0:350011bf8be7 188 * high-reliability, and high-throughput.
simon 0:350011bf8be7 189 * The use of the Delay, Throughput, and Reliability indications may
simon 0:350011bf8be7 190 * increase the cost (in some sense) of the service. In many networks
simon 0:350011bf8be7 191 * better performance for one of these parameters is coupled with worse
simon 0:350011bf8be7 192 * performance on another. Except for very unusual cases at most two
simon 0:350011bf8be7 193 * of these three indications should be set.
simon 0:350011bf8be7 194 */
simon 0:350011bf8be7 195 #define IPTOS_TOS_MASK 0x1E
simon 0:350011bf8be7 196 #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
simon 0:350011bf8be7 197 #define IPTOS_LOWDELAY 0x10
simon 0:350011bf8be7 198 #define IPTOS_THROUGHPUT 0x08
simon 0:350011bf8be7 199 #define IPTOS_RELIABILITY 0x04
simon 0:350011bf8be7 200 #define IPTOS_LOWCOST 0x02
simon 0:350011bf8be7 201 #define IPTOS_MINCOST IPTOS_LOWCOST
simon 0:350011bf8be7 202
simon 0:350011bf8be7 203 /*
simon 0:350011bf8be7 204 * The Network Control precedence designation is intended to be used
simon 0:350011bf8be7 205 * within a network only. The actual use and control of that
simon 0:350011bf8be7 206 * designation is up to each network. The Internetwork Control
simon 0:350011bf8be7 207 * designation is intended for use by gateway control originators only.
simon 0:350011bf8be7 208 * If the actual use of these precedence designations is of concern to
simon 0:350011bf8be7 209 * a particular network, it is the responsibility of that network to
simon 0:350011bf8be7 210 * control the access to, and use of, those precedence designations.
simon 0:350011bf8be7 211 */
simon 0:350011bf8be7 212 #define IPTOS_PREC_MASK 0xe0
simon 0:350011bf8be7 213 #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
simon 0:350011bf8be7 214 #define IPTOS_PREC_NETCONTROL 0xe0
simon 0:350011bf8be7 215 #define IPTOS_PREC_INTERNETCONTROL 0xc0
simon 0:350011bf8be7 216 #define IPTOS_PREC_CRITIC_ECP 0xa0
simon 0:350011bf8be7 217 #define IPTOS_PREC_FLASHOVERRIDE 0x80
simon 0:350011bf8be7 218 #define IPTOS_PREC_FLASH 0x60
simon 0:350011bf8be7 219 #define IPTOS_PREC_IMMEDIATE 0x40
simon 0:350011bf8be7 220 #define IPTOS_PREC_PRIORITY 0x20
simon 0:350011bf8be7 221 #define IPTOS_PREC_ROUTINE 0x00
simon 0:350011bf8be7 222
simon 0:350011bf8be7 223
simon 0:350011bf8be7 224 /*
simon 0:350011bf8be7 225 * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
simon 0:350011bf8be7 226 * lwip_ioctl only supports FIONREAD and FIONBIO, for now
simon 0:350011bf8be7 227 *
simon 0:350011bf8be7 228 * Ioctl's have the command encoded in the lower word,
simon 0:350011bf8be7 229 * and the size of any in or out parameters in the upper
simon 0:350011bf8be7 230 * word. The high 2 bits of the upper word are used
simon 0:350011bf8be7 231 * to encode the in/out status of the parameter; for now
simon 0:350011bf8be7 232 * we restrict parameters to at most 128 bytes.
simon 0:350011bf8be7 233 */
simon 0:350011bf8be7 234 #if !defined(FIONREAD) || !defined(FIONBIO)
simon 0:350011bf8be7 235 #define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
simon 0:350011bf8be7 236 #define IOC_VOID 0x20000000UL /* no parameters */
simon 0:350011bf8be7 237 #define IOC_OUT 0x40000000UL /* copy out parameters */
simon 0:350011bf8be7 238 #define IOC_IN 0x80000000UL /* copy in parameters */
simon 0:350011bf8be7 239 #define IOC_INOUT (IOC_IN|IOC_OUT)
simon 0:350011bf8be7 240 /* 0x20000000 distinguishes new &
simon 0:350011bf8be7 241 old ioctl's */
simon 0:350011bf8be7 242 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
simon 0:350011bf8be7 243
simon 0:350011bf8be7 244 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
simon 0:350011bf8be7 245
simon 0:350011bf8be7 246 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
simon 0:350011bf8be7 247 #endif /* !defined(FIONREAD) || !defined(FIONBIO) */
simon 0:350011bf8be7 248
simon 0:350011bf8be7 249 #ifndef FIONREAD
simon 0:350011bf8be7 250 #define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
simon 0:350011bf8be7 251 #endif
simon 0:350011bf8be7 252 #ifndef FIONBIO
simon 0:350011bf8be7 253 #define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
simon 0:350011bf8be7 254 #endif
simon 0:350011bf8be7 255
simon 0:350011bf8be7 256 /* Socket I/O Controls: unimplemented */
simon 0:350011bf8be7 257 #ifndef SIOCSHIWAT
simon 0:350011bf8be7 258 #define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
simon 0:350011bf8be7 259 #define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
simon 0:350011bf8be7 260 #define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
simon 0:350011bf8be7 261 #define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
simon 0:350011bf8be7 262 #define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
simon 0:350011bf8be7 263 #endif
simon 0:350011bf8be7 264
simon 0:350011bf8be7 265 /* commands for fnctl */
simon 0:350011bf8be7 266 #ifndef F_GETFL
simon 0:350011bf8be7 267 #define F_GETFL 3
simon 0:350011bf8be7 268 #endif
simon 0:350011bf8be7 269 #ifndef F_SETFL
simon 0:350011bf8be7 270 #define F_SETFL 4
simon 0:350011bf8be7 271 #endif
simon 0:350011bf8be7 272
simon 0:350011bf8be7 273 /* File status flags and file access modes for fnctl,
simon 0:350011bf8be7 274 these are bits in an int. */
simon 0:350011bf8be7 275 #ifndef O_NONBLOCK
simon 0:350011bf8be7 276 #define O_NONBLOCK 1 /* nonblocking I/O */
simon 0:350011bf8be7 277 #endif
simon 0:350011bf8be7 278 #ifndef O_NDELAY
simon 0:350011bf8be7 279 #define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
simon 0:350011bf8be7 280 #endif
simon 0:350011bf8be7 281
simon 0:350011bf8be7 282 #ifndef SHUT_RD
simon 0:350011bf8be7 283 #define SHUT_RD 1
simon 0:350011bf8be7 284 #define SHUT_WR 2
simon 0:350011bf8be7 285 #define SHUT_RDWR 3
simon 0:350011bf8be7 286 #endif
simon 0:350011bf8be7 287
simon 0:350011bf8be7 288 /* FD_SET used for lwip_select */
simon 0:350011bf8be7 289 #ifndef FD_SET
simon 0:350011bf8be7 290 #undef FD_SETSIZE
simon 0:350011bf8be7 291 /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
simon 0:350011bf8be7 292 #define FD_SETSIZE MEMP_NUM_NETCONN
simon 0:350011bf8be7 293 #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
simon 0:350011bf8be7 294 #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
simon 0:350011bf8be7 295 #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
simon 0:350011bf8be7 296 #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p)))
simon 0:350011bf8be7 297
simon 0:350011bf8be7 298 typedef struct fd_set {
simon 0:350011bf8be7 299 unsigned char fd_bits [(FD_SETSIZE+7)/8];
simon 0:350011bf8be7 300 } fd_set;
simon 0:350011bf8be7 301
simon 0:350011bf8be7 302 #endif /* FD_SET */
simon 0:350011bf8be7 303
simon 0:350011bf8be7 304 /** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
simon 0:350011bf8be7 305 * by your system, set this to 0 and include <sys/time.h> in cc.h */
simon 0:350011bf8be7 306 #ifndef LWIP_TIMEVAL_PRIVATE
simon 0:350011bf8be7 307 #define LWIP_TIMEVAL_PRIVATE 1
simon 0:350011bf8be7 308 #endif
simon 0:350011bf8be7 309
simon 0:350011bf8be7 310 #if LWIP_TIMEVAL_PRIVATE
simon 0:350011bf8be7 311 struct timeval {
simon 0:350011bf8be7 312 long tv_sec; /* seconds */
simon 0:350011bf8be7 313 long tv_usec; /* and microseconds */
simon 0:350011bf8be7 314 };
simon 0:350011bf8be7 315 #endif /* LWIP_TIMEVAL_PRIVATE */
simon 0:350011bf8be7 316
simon 0:350011bf8be7 317 void lwip_socket_init(void);
simon 0:350011bf8be7 318
simon 0:350011bf8be7 319 int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
simon 0:350011bf8be7 320 int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
simon 0:350011bf8be7 321 int lwip_shutdown(int s, int how);
simon 0:350011bf8be7 322 int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
simon 0:350011bf8be7 323 int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
simon 0:350011bf8be7 324 int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
simon 0:350011bf8be7 325 int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
simon 0:350011bf8be7 326 int lwip_close(int s);
simon 0:350011bf8be7 327 int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
simon 0:350011bf8be7 328 int lwip_listen(int s, int backlog);
simon 0:350011bf8be7 329 int lwip_recv(int s, void *mem, size_t len, int flags);
simon 0:350011bf8be7 330 int lwip_read(int s, void *mem, size_t len);
simon 0:350011bf8be7 331 int lwip_recvfrom(int s, void *mem, size_t len, int flags,
simon 0:350011bf8be7 332 struct sockaddr *from, socklen_t *fromlen);
simon 0:350011bf8be7 333 int lwip_send(int s, const void *dataptr, size_t size, int flags);
simon 0:350011bf8be7 334 int lwip_sendto(int s, const void *dataptr, size_t size, int flags,
simon 0:350011bf8be7 335 const struct sockaddr *to, socklen_t tolen);
simon 0:350011bf8be7 336 int lwip_socket(int domain, int type, int protocol);
simon 0:350011bf8be7 337 int lwip_write(int s, const void *dataptr, size_t size);
simon 0:350011bf8be7 338 int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
simon 0:350011bf8be7 339 struct timeval *timeout);
simon 0:350011bf8be7 340 int lwip_ioctl(int s, long cmd, void *argp);
simon 0:350011bf8be7 341 int lwip_fcntl(int s, int cmd, int val);
simon 0:350011bf8be7 342
simon 0:350011bf8be7 343 #if LWIP_COMPAT_SOCKETS
simon 0:350011bf8be7 344 #define accept(a,b,c) lwip_accept(a,b,c)
simon 0:350011bf8be7 345 #define bind(a,b,c) lwip_bind(a,b,c)
simon 0:350011bf8be7 346 #define shutdown(a,b) lwip_shutdown(a,b)
simon 0:350011bf8be7 347 #define closesocket(s) lwip_close(s)
simon 0:350011bf8be7 348 #define connect(a,b,c) lwip_connect(a,b,c)
simon 0:350011bf8be7 349 #define getsockname(a,b,c) lwip_getsockname(a,b,c)
simon 0:350011bf8be7 350 #define getpeername(a,b,c) lwip_getpeername(a,b,c)
simon 0:350011bf8be7 351 #define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e)
simon 0:350011bf8be7 352 #define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e)
simon 0:350011bf8be7 353 #define listen(a,b) lwip_listen(a,b)
simon 0:350011bf8be7 354 #define recv(a,b,c,d) lwip_recv(a,b,c,d)
simon 0:350011bf8be7 355 #define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f)
simon 0:350011bf8be7 356 #define send(a,b,c,d) lwip_send(a,b,c,d)
simon 0:350011bf8be7 357 #define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f)
simon 0:350011bf8be7 358 #define socket(a,b,c) lwip_socket(a,b,c)
simon 0:350011bf8be7 359 #define select(a,b,c,d,e) lwip_select(a,b,c,d,e)
simon 0:350011bf8be7 360 #define ioctlsocket(a,b,c) lwip_ioctl(a,b,c)
simon 0:350011bf8be7 361
simon 0:350011bf8be7 362 #if LWIP_POSIX_SOCKETS_IO_NAMES
simon 0:350011bf8be7 363 #define read(a,b,c) lwip_read(a,b,c)
simon 0:350011bf8be7 364 #define write(a,b,c) lwip_write(a,b,c)
simon 0:350011bf8be7 365 #define close(s) lwip_close(s)
simon 0:350011bf8be7 366 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
simon 0:350011bf8be7 367
simon 0:350011bf8be7 368 #endif /* LWIP_COMPAT_SOCKETS */
simon 0:350011bf8be7 369
simon 0:350011bf8be7 370 #ifdef __cplusplus
simon 0:350011bf8be7 371 }
simon 0:350011bf8be7 372 #endif
simon 0:350011bf8be7 373
simon 0:350011bf8be7 374 #endif /* LWIP_SOCKET */
simon 0:350011bf8be7 375
simon 0:350011bf8be7 376 #endif /* __LWIP_SOCKETS_H__ */