Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:48:09 2011 +0000
Revision:
0:850eacf3e945
revised fixed length to 178 bytes

Who changed what in which revision?

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