kenji tanaka / Mbed 2 deprecated Sha1Test

Dependencies:   mbed

Committer:
gtk2k
Date:
Sun Apr 29 03:58:08 2012 +0000
Revision:
0:74be48b504a5
WebSocketServer

Who changed what in which revision?

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