Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
GordonSin
Date:
Fri May 31 04:09:54 2013 +0000
Revision:
0:0ed2a7c7190c
31/5/2013;

Who changed what in which revision?

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