LwIP with PPP & Ethernet integration

Dependents:   NetworkingCoreLib

This is the mbed port of the LwIP stack: http://savannah.nongnu.org/projects/lwip/

It includes contributed content from NXP's port for LPCxxxx devices: http://www.lpcware.com/content/project/lightweight-ip-lwip-networking-stack

Licence

LwIP is licenced under the BSD licence:

Copyright (c) 2001-2004 Swedish Institute of Computer Science. 
All rights reserved. 
Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met: 
1. Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer. 
2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution. 
3. The name of the author may not be used to endorse or promote products 
derived from this software without specific prior written permission. 
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.
Committer:
donatien
Date:
Thu May 24 15:53:48 2012 +0000
Revision:
0:8e01dca41002
Merge with Emilio's LwIp

Who changed what in which revision?

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