ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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