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