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