Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Thu Sep 26 00:44:20 2013 -0500
Revision:
5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point

Who changed what in which revision?

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