| 1 | /* Modified for emx by hv and em 1994-1997
|
|---|
| 2 | * Modified for gcc/os2 by bird 2003
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright (c) 1982,1985,1986,1988 Regents of the University of California.
|
|---|
| 5 | * All rights reserved.
|
|---|
| 6 | *
|
|---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 8 | * modification, are permitted provided that the following conditions
|
|---|
| 9 | * are met:
|
|---|
| 10 | * 1. Redistributions of source code must retain the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | * 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | * documentation and/or other materials provided with the distribution.
|
|---|
| 15 | * 3. All advertising materials mentioning features or use of this software
|
|---|
| 16 | * must display the following acknowledgement:
|
|---|
| 17 | * This product includes software developed by the University of
|
|---|
| 18 | * California, Berkeley and its contributors.
|
|---|
| 19 | * 4. Neither the name of the University nor the names of its contributors
|
|---|
| 20 | * may be used to endorse or promote products derived from this software
|
|---|
| 21 | * without specific prior written permission.
|
|---|
| 22 | *
|
|---|
| 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|---|
| 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|---|
| 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|---|
| 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|---|
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|---|
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|---|
| 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|---|
| 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|---|
| 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|---|
| 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|---|
| 33 | * SUCH DAMAGE.
|
|---|
| 34 | *
|
|---|
| 35 | * from: @(#)socket.h 7.13 (Berkeley) 4/20/91
|
|---|
| 36 | * $Id: socket.h,v 1.5 1993/06/27 05:59:06 andrew Exp $
|
|---|
| 37 | */
|
|---|
| 38 |
|
|---|
| 39 | #ifndef _SYS_SOCKET_H_
|
|---|
| 40 | #define _SYS_SOCKET_H_
|
|---|
| 41 |
|
|---|
| 42 | #include <machine/ansi.h>
|
|---|
| 43 | #define _NO_NAMESPACE_POLLUTION
|
|---|
| 44 | #include <machine/param.h>
|
|---|
| 45 | #undef _NO_NAMESPACE_POLLUTION
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | /* toolkit stuff */
|
|---|
| 49 | #include <sys/types.h>
|
|---|
| 50 | #include <sys/uio.h>
|
|---|
| 51 | #include <sys/cdefs.h>
|
|---|
| 52 |
|
|---|
| 53 | #if defined (__cplusplus)
|
|---|
| 54 | extern "C" {
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 | #ifndef _EMX_TCPIP
|
|---|
| 58 | #define _EMX_TCPIP
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | /*
|
|---|
| 62 | * Definitions related to sockets: types, address families, options.
|
|---|
| 63 | */
|
|---|
| 64 |
|
|---|
| 65 | /*
|
|---|
| 66 | * Types
|
|---|
| 67 | */
|
|---|
| 68 | #define SOCK_STREAM 1 /* stream socket */
|
|---|
| 69 | #define SOCK_DGRAM 2 /* datagram socket */
|
|---|
| 70 | #define SOCK_RAW 3 /* raw-protocol interface */
|
|---|
| 71 | #define SOCK_RDM 4 /* reliably-delivered message */
|
|---|
| 72 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
|---|
| 73 |
|
|---|
| 74 | /*
|
|---|
| 75 | * Option flags per-socket.
|
|---|
| 76 | */
|
|---|
| 77 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
|---|
| 78 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
|---|
| 79 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
|---|
| 80 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
|---|
| 81 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
|---|
| 82 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
|---|
| 83 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
|---|
| 84 | #define SO_LINGER 0x0080 /* linger on close if data present */
|
|---|
| 85 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
|---|
| 86 | #define SO_L_BROADCAST 0x0200 /* limited broadcast sent on all IFs*/
|
|---|
| 87 | #define SO_RCV_SHUTDOWN 0x0400 /* set if shut down called for rcv */
|
|---|
| 88 | #define SO_SND_SHUTDOWN 0x0800 /* set if shutdown called for send */
|
|---|
| 89 | #ifndef TCPV40HDRS
|
|---|
| 90 | #define SO_REUSEPORT 0x1000 /* allow local address & port reuse */
|
|---|
| 91 | #define SO_TTCP 0x2000 /* allow t/tcp on socket */
|
|---|
| 92 | #endif
|
|---|
| 93 |
|
|---|
| 94 | /*
|
|---|
| 95 | * Additional options, not kept in so_options.
|
|---|
| 96 | */
|
|---|
| 97 | #define SO_SNDBUF 0x1001 /* send buffer size */
|
|---|
| 98 | #define SO_RCVBUF 0x1002 /* receive buffer size */
|
|---|
| 99 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
|---|
| 100 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
|---|
| 101 | #ifndef TCPV40HDRS
|
|---|
| 102 | #define SO_SNDTIMEO 0x1005 /* send timeout */
|
|---|
| 103 | #define SO_RCVTIMEO 0x1006 /* receive timeout */
|
|---|
| 104 | #endif
|
|---|
| 105 | #define SO_ERROR 0x1007 /* get error status and clear */
|
|---|
| 106 | #define SO_TYPE 0x1008 /* get socket type */
|
|---|
| 107 | #define SO_OPTIONS 0x1010 /* get socket options */
|
|---|
| 108 |
|
|---|
| 109 | /*
|
|---|
| 110 | * Structure used for manipulating linger option.
|
|---|
| 111 | */
|
|---|
| 112 | struct linger {
|
|---|
| 113 | #ifdef __RSXNT__
|
|---|
| 114 | short l_onoff; /* option on/off */
|
|---|
| 115 | short l_linger; /* linger time */
|
|---|
| 116 | #else
|
|---|
| 117 | int l_onoff; /* option on/off */
|
|---|
| 118 | int l_linger; /* linger time */
|
|---|
| 119 | #endif
|
|---|
| 120 | };
|
|---|
| 121 |
|
|---|
| 122 | /*
|
|---|
| 123 | * Level number for (get/set)sockopt() to apply to socket itself.
|
|---|
| 124 | */
|
|---|
| 125 | #define SOL_SOCKET 0xffff /* options for socket level */
|
|---|
| 126 |
|
|---|
| 127 | /*
|
|---|
| 128 | * Address families.
|
|---|
| 129 | */
|
|---|
| 130 | #define AF_UNSPEC 0 /* unspecified */
|
|---|
| 131 | #define AF_UNIX 1 /* local to host (pipes, portals) */
|
|---|
| 132 | #ifndef TCPV40HDRS
|
|---|
| 133 | #define AF_LOCAL AF_UNIX
|
|---|
| 134 | #endif
|
|---|
| 135 | #define AF_OS2 AF_UNIX
|
|---|
| 136 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
|---|
| 137 | #define AF_IMPLINK 3 /* arpanet imp addresses */
|
|---|
| 138 | #define AF_PUP 4 /* pup protocols: e.g. BSP */
|
|---|
| 139 | #define AF_CHAOS 5 /* mit CHAOS protocols */
|
|---|
| 140 | #define AF_NS 6 /* XEROX NS protocols */
|
|---|
| 141 | #ifdef TCPV40HDRS
|
|---|
| 142 | #define AF_NBS 7 /* IBM: nbs protocols */
|
|---|
| 143 | /* (hv: I think IBM is outdated here */
|
|---|
| 144 | #endif
|
|---|
| 145 | #define AF_ISO 7 /* ISO protocols */
|
|---|
| 146 | #define AF_OSI AF_ISO
|
|---|
| 147 | #define AF_ECMA 8 /* european computer manufacturers */
|
|---|
| 148 | #define AF_DATAKIT 9 /* datakit protocols */
|
|---|
| 149 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
|---|
| 150 | #define AF_SNA 11 /* IBM SNA */
|
|---|
| 151 | #define AF_DECnet 12 /* DECnet */
|
|---|
| 152 | #define AF_DLI 13 /* DEC Direct data link interface */
|
|---|
| 153 | #define AF_LAT 14 /* LAT */
|
|---|
| 154 | #define AF_HYLINK 15 /* NSC Hyperchannel */
|
|---|
| 155 | #define AF_APPLETALK 16 /* Apple Talk */
|
|---|
| 156 | #define AF_NB 17 /* Netbios */
|
|---|
| 157 | #define AF_NETBIOS AF_NB
|
|---|
| 158 |
|
|---|
| 159 | #ifdef TCPV40HDRS
|
|---|
| 160 | #define AF_MAX 18
|
|---|
| 161 | #else
|
|---|
| 162 | #define AF_LINK 18 /* Link layer interface */
|
|---|
| 163 | #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
|
|---|
| 164 | #define AF_COIP 20 /* connection-oriented IP, aka ST II */
|
|---|
| 165 | #define AF_CNT 21 /* Computer Network Technology */
|
|---|
| 166 | #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
|
|---|
| 167 | #define AF_IPX 23 /* Novell Internet Protocol */
|
|---|
| 168 | #define AF_SIP 24 /* Simple Internet Protocol */
|
|---|
| 169 | #define AF_INET6 24
|
|---|
| 170 | #define pseudo_AF_PIP 25 /* Help Identify PIP packets */
|
|---|
| 171 | #define AF_ROUTE 39 /* Internal Routing Protocol */
|
|---|
| 172 | #define AF_FWIP 40 /* firewall support */
|
|---|
| 173 | #define AF_IPSEC 41 /* IPSEC and encryption techniques */
|
|---|
| 174 | #define AF_DES 42 /* DES */
|
|---|
| 175 | #define AF_MD5 43
|
|---|
| 176 | #define AF_CDMF 44
|
|---|
| 177 |
|
|---|
| 178 | #define AF_MAX 45
|
|---|
| 179 | #endif
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 | /*
|
|---|
| 183 | * Structure used by kernel to store most
|
|---|
| 184 | * addresses.
|
|---|
| 185 | * is called struct osockaddr in 4.4BSD
|
|---|
| 186 | */
|
|---|
| 187 | struct sockaddr {
|
|---|
| 188 | #ifdef TCPV40HDRS
|
|---|
| 189 | u_short sa_family; /* address family */
|
|---|
| 190 | char sa_data[14]; /* up to 14 bytes of direct address */
|
|---|
| 191 | #else
|
|---|
| 192 | u_char sa_len; /* total length */
|
|---|
| 193 | u_char sa_family; /* address family */
|
|---|
| 194 | char sa_data[14]; /* actually longer; address value */
|
|---|
| 195 | #endif
|
|---|
| 196 | };
|
|---|
| 197 |
|
|---|
| 198 | /*
|
|---|
| 199 | * Structure used by kernel to pass protocol
|
|---|
| 200 | * information in raw sockets.
|
|---|
| 201 | */
|
|---|
| 202 | struct sockproto {
|
|---|
| 203 | u_short sp_family; /* address family */
|
|---|
| 204 | u_short sp_protocol; /* protocol */
|
|---|
| 205 | };
|
|---|
| 206 |
|
|---|
| 207 | /*
|
|---|
| 208 | * Protocol families, same as address families for now.
|
|---|
| 209 | */
|
|---|
| 210 | #define PF_UNSPEC AF_UNSPEC
|
|---|
| 211 | #define PF_UNIX AF_UNIX
|
|---|
| 212 | #ifndef TCPV40HDRS
|
|---|
| 213 | #define PF_LOCAL AF_LOCAL
|
|---|
| 214 | #endif
|
|---|
| 215 | #define PF_OS2 AF_UNIX
|
|---|
| 216 | #define PF_INET AF_INET
|
|---|
| 217 | #define PF_IMPLINK AF_IMPLINK
|
|---|
| 218 | #define PF_PUP AF_PUP
|
|---|
| 219 | #define PF_CHAOS AF_CHAOS
|
|---|
| 220 | #define PF_NS AF_NS
|
|---|
| 221 | #ifdef TCPV40HDRS
|
|---|
| 222 | #define PF_NBS AF_NBS
|
|---|
| 223 | #endif
|
|---|
| 224 | #define PF_ISO AF_ISO
|
|---|
| 225 | #define PF_OSI AF_OSI
|
|---|
| 226 | #define PF_ECMA AF_ECMA
|
|---|
| 227 | #define PF_DATAKIT AF_DATAKIT
|
|---|
| 228 | #define PF_CCITT AF_CCITT
|
|---|
| 229 | #define PF_SNA AF_SNA
|
|---|
| 230 | #define PF_DECnet AF_DECnet
|
|---|
| 231 | #define PF_DLI AF_DLI
|
|---|
| 232 | #define PF_LAT AF_LAT
|
|---|
| 233 | #define PF_HYLINK AF_HYLINK
|
|---|
| 234 | #define PF_APPLETALK AF_APPLETALK
|
|---|
| 235 | #define PF_NETBIOS AF_NB
|
|---|
| 236 | #define PF_NB AF_NB
|
|---|
| 237 | #ifndef TCPV40HDRS
|
|---|
| 238 | #define PF_ROUTE AF_ROUTE
|
|---|
| 239 | #define PF_LINK AF_LINK
|
|---|
| 240 | #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
|
|---|
| 241 | #define PF_COIP AF_COIP
|
|---|
| 242 | #define PF_CNT AF_CNT
|
|---|
| 243 | #define PF_SIP AF_SIP
|
|---|
| 244 | #define PF_INET6 AF_INET6
|
|---|
| 245 | #define PF_IPX AF_IPX /* same format as AF_NS */
|
|---|
| 246 | #define PF_RTIP pseudo_AF_FTIP /* same format as AF_INET */
|
|---|
| 247 | #define PF_PIP pseudo_AF_PIP
|
|---|
| 248 | #endif /* !TCPV40HDRS */
|
|---|
| 249 |
|
|---|
| 250 | #define PF_MAX AF_MAX
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 | #ifndef TCPV40HDRS
|
|---|
| 254 | /*
|
|---|
| 255 | * Definitions for network related sysctl, CTL_NET.
|
|---|
| 256 | *
|
|---|
| 257 | * Second level is protocol family.
|
|---|
| 258 | * Third level is protocol number.
|
|---|
| 259 | *
|
|---|
| 260 | * Further levels are defined by the individual families below.
|
|---|
| 261 | */
|
|---|
| 262 | #define NET_MAXID AF_MAX
|
|---|
| 263 |
|
|---|
| 264 | #define CTL_NET_NAMES { \
|
|---|
| 265 | { 0, 0 }, \
|
|---|
| 266 | { "local", CTLTYPE_NODE }, \
|
|---|
| 267 | { "inet", CTLTYPE_NODE }, \
|
|---|
| 268 | { "implink", CTLTYPE_NODE }, \
|
|---|
| 269 | { "pup", CTLTYPE_NODE }, \
|
|---|
| 270 | { "chaos", CTLTYPE_NODE }, \
|
|---|
| 271 | { "xerox_ns", CTLTYPE_NODE }, \
|
|---|
| 272 | { "iso", CTLTYPE_NODE }, \
|
|---|
| 273 | { "emca", CTLTYPE_NODE }, \
|
|---|
| 274 | { "datakit", CTLTYPE_NODE }, \
|
|---|
| 275 | { "ccitt", CTLTYPE_NODE }, \
|
|---|
| 276 | { "ibm_sna", CTLTYPE_NODE }, \
|
|---|
| 277 | { "decnet", CTLTYPE_NODE }, \
|
|---|
| 278 | { "dec_dli", CTLTYPE_NODE }, \
|
|---|
| 279 | { "lat", CTLTYPE_NODE }, \
|
|---|
| 280 | { "hylink", CTLTYPE_NODE }, \
|
|---|
| 281 | { "appletalk", CTLTYPE_NODE }, \
|
|---|
| 282 | { "netbios", CTLTYPE_NODE }, \
|
|---|
| 283 | { "route", CTLTYPE_NODE }, \
|
|---|
| 284 | { "link_layer", CTLTYPE_NODE }, \
|
|---|
| 285 | { "xtp", CTLTYPE_NODE }, \
|
|---|
| 286 | { "coip", CTLTYPE_NODE }, \
|
|---|
| 287 | { "cnt", CTLTYPE_NODE }, \
|
|---|
| 288 | { "rtip", CTLTYPE_NODE }, \
|
|---|
| 289 | { "ipx", CTLTYPE_NODE }, \
|
|---|
| 290 | { "sip", CTLTYPE_NODE }, \
|
|---|
| 291 | { "pip", CTLTYPE_NODE }, \
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | /*
|
|---|
| 295 | * PF_ROUTE - Routing table
|
|---|
| 296 | *
|
|---|
| 297 | * Three additional levels are defined:
|
|---|
| 298 | * Fourth: address family, 0 is wildcard
|
|---|
| 299 | * Fifth: type of info, defined below
|
|---|
| 300 | * Sixth: flag(s) to mask with for NET_RT_FLAGS
|
|---|
| 301 | */
|
|---|
| 302 | #define NET_RT_DUMP 1 /* dump; may limit to a.f. */
|
|---|
| 303 | #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
|
|---|
| 304 | #define NET_RT_IFLIST 3 /* survey interface list */
|
|---|
| 305 | #define NET_RT_MAXID 4
|
|---|
| 306 |
|
|---|
| 307 | #define CTL_NET_RT_NAMES { \
|
|---|
| 308 | { 0, 0 }, \
|
|---|
| 309 | { "dump", CTLTYPE_STRUCT }, \
|
|---|
| 310 | { "flags", CTLTYPE_STRUCT }, \
|
|---|
| 311 | { "iflist", CTLTYPE_STRUCT }, \
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | #endif /* !TCPV40HDRS */
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 | /*
|
|---|
| 318 | * Maximum queue length specifiable by listen.
|
|---|
| 319 | */
|
|---|
| 320 | #ifdef TCPV40HDRS
|
|---|
| 321 | #define SOMAXCONN 5
|
|---|
| 322 | #else
|
|---|
| 323 | #define SOMAXCONN 1024
|
|---|
| 324 | #endif
|
|---|
| 325 |
|
|---|
| 326 | /*
|
|---|
| 327 | * 4.3-compat message header (move to compat file later).
|
|---|
| 328 | * is called omsghdr in 4.4BSD
|
|---|
| 329 | */
|
|---|
| 330 | struct msghdr {
|
|---|
| 331 | caddr_t msg_name; /* optional address */
|
|---|
| 332 | #ifdef TCPV40HDRS
|
|---|
| 333 | int msg_namelen; /* size of address */
|
|---|
| 334 | struct iovec *msg_iov; /* scatter/gather array */
|
|---|
| 335 | int msg_iovlen; /* # elements in msg_iov */
|
|---|
| 336 | caddr_t msg_accrights; /* access rights sent/received */
|
|---|
| 337 | int msg_accrightslen;
|
|---|
| 338 | #else
|
|---|
| 339 | u_int msg_namelen; /* size of address */
|
|---|
| 340 | struct iovec *msg_iov; /* scatter/gather array */
|
|---|
| 341 | u_int msg_iovlen; /* # elements in msg_iov */
|
|---|
| 342 | caddr_t msg_control; /* ancillary data, see below */
|
|---|
| 343 | u_int msg_controllen; /* ancillary data buffer len */
|
|---|
| 344 | long msg_flags; /* flags on received message */
|
|---|
| 345 | #endif
|
|---|
| 346 | };
|
|---|
| 347 |
|
|---|
| 348 | #define MSG_OOB 0x1 /* process out-of-band data */
|
|---|
| 349 | #define MSG_PEEK 0x2 /* peek at incoming message */
|
|---|
| 350 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
|---|
| 351 | #define MSG_FULLREAD 0x8 /* send without using routing tables */
|
|---|
| 352 | #ifndef TCPV40HDRS
|
|---|
| 353 | #define MSG_EOR 0x10 /* data completes record */
|
|---|
| 354 | #define MSG_TRUNC 0x20 /* data discarded before delivery */
|
|---|
| 355 | #define MSG_CTRUNC 0x40 /* control data lost before delivery */
|
|---|
| 356 | #define MSG_WAITALL 0x80 /* wait for full request or error */
|
|---|
| 357 | #define MSG_DONTWAIT 0x100 /* this message should be nonblocking */
|
|---|
| 358 | #ifdef TTCP
|
|---|
| 359 | #define MSG_EOF 0x200
|
|---|
| 360 | #endif
|
|---|
| 361 | #define MSG_MAPIO 0x400 /* mem mapped io */
|
|---|
| 362 | #define MSG_CLOSE 0x800 /* close connection after succesful send_file */
|
|---|
| 363 | #endif
|
|---|
| 364 |
|
|---|
| 365 | #ifdef TCPV40HDRS
|
|---|
| 366 | #define MSG_MAXIOVLEN 16
|
|---|
| 367 | #endif
|
|---|
| 368 |
|
|---|
| 369 | /*
|
|---|
| 370 | * Header for ancillary data objects in msg_control buffer.
|
|---|
| 371 | * Used for additional information with/about a datagram
|
|---|
| 372 | * not expressible by flags. The format is a sequence
|
|---|
| 373 | * of message elements headed by cmsghdr structures.
|
|---|
| 374 | */
|
|---|
| 375 | struct cmsghdr {
|
|---|
| 376 | u_int cmsg_len; /* data byte count, including hdr */
|
|---|
| 377 | int cmsg_level; /* originating protocol */
|
|---|
| 378 | int cmsg_type; /* protocol-specific type */
|
|---|
| 379 | /* followed by u_char cmsg_data[]; */
|
|---|
| 380 | };
|
|---|
| 381 |
|
|---|
| 382 | /* given pointer to struct adatahdr, return pointer to data */
|
|---|
| 383 | #define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
|
|---|
| 384 |
|
|---|
| 385 | /* given pointer to struct adatahdr, return pointer to next adatahdr */
|
|---|
| 386 | #define CMSG_NXTHDR(mhdr, cmsg) \
|
|---|
| 387 | (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
|
|---|
| 388 | (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
|
|---|
| 389 | (struct cmsghdr *)NULL : \
|
|---|
| 390 | (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
|
|---|
| 391 |
|
|---|
| 392 | #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
|
|---|
| 393 |
|
|---|
| 394 | /* "Socket"-level control message types: */
|
|---|
| 395 | #define SCM_RIGHTS 0x01 /* access rights (array of int) */
|
|---|
| 396 |
|
|---|
| 397 | #ifndef TCPV40HDRS
|
|---|
| 398 | /*
|
|---|
| 399 | * 4.3 compat sockaddr, move to compat file later
|
|---|
| 400 | */
|
|---|
| 401 | struct osockaddr {
|
|---|
| 402 | u_short sa_family; /* address family */
|
|---|
| 403 | char sa_data[14]; /* up to 14 bytes of direct address */
|
|---|
| 404 | };
|
|---|
| 405 |
|
|---|
| 406 | /*
|
|---|
| 407 | * 4.3-compat message header (move to compat file later).
|
|---|
| 408 | */
|
|---|
| 409 | struct omsghdr {
|
|---|
| 410 | caddr_t msg_name; /* optional address */
|
|---|
| 411 | int msg_namelen; /* size of address */
|
|---|
| 412 | struct iovec *msg_iov; /* scatter/gather array */
|
|---|
| 413 | int msg_iovlen; /* # elements in msg_iov */
|
|---|
| 414 | caddr_t msg_accrights; /* access rights sent/received */
|
|---|
| 415 | int msg_accrightslen;
|
|---|
| 416 | };
|
|---|
| 417 |
|
|---|
| 418 | /*
|
|---|
| 419 | * send_file parameter structure
|
|---|
| 420 | */
|
|---|
| 421 | struct sf_parms {
|
|---|
| 422 | void *header_data; /* ptr to header data */
|
|---|
| 423 | size_t header_length; /* size of header data */
|
|---|
| 424 | int file_handle; /* file handle to send from */
|
|---|
| 425 | size_t file_size; /* size of file */
|
|---|
| 426 | int file_offset; /* byte offset in file to send from */
|
|---|
| 427 | size_t file_bytes; /* bytes of file to be sent */
|
|---|
| 428 | void *trailer_data; /* ptr to trailer data */
|
|---|
| 429 | size_t trailer_length; /* size of trailer data */
|
|---|
| 430 | size_t bytes_sent; /* bytes sent in this send_file call */
|
|---|
| 431 | };
|
|---|
| 432 | #endif
|
|---|
| 433 |
|
|---|
| 434 | int TCPCALL accept (int, struct sockaddr *, int *);
|
|---|
| 435 | int TCPCALL bind (int, __const__ struct sockaddr *, int);
|
|---|
| 436 | int TCPCALL connect (int, __const__ struct sockaddr *, int);
|
|---|
| 437 | int TCPCALL gethostid (void);
|
|---|
| 438 | int TCPCALL getpeername (int, struct sockaddr *, int *);
|
|---|
| 439 | int TCPCALL getsockname (int, struct sockaddr *, int *);
|
|---|
| 440 | int TCPCALL getsockopt (int, int, int, void *, int *);
|
|---|
| 441 | int TCPCALL listen (int, int);
|
|---|
| 442 | int TCPCALL recv (int, void *, int, int);
|
|---|
| 443 | int TCPCALL recvfrom (int, void *, int, int, struct sockaddr *, int *);
|
|---|
| 444 | int TCPCALL recvmsg (int, struct msghdr *, int);
|
|---|
| 445 | int TCPCALL send (int, __const__ void *, int, int);
|
|---|
| 446 | int TCPCALL sendto (int, __const__ void *, int, int, __const__ struct sockaddr *, int);
|
|---|
| 447 | int TCPCALL sendmsg (int, __const__ struct msghdr *, int);
|
|---|
| 448 | int TCPCALL setsockopt (int, int, int, __const__ void *, int);
|
|---|
| 449 | int TCPCALL shutdown (int, int);
|
|---|
| 450 | int TCPCALL socket (int, int, int);
|
|---|
| 451 | int TCPCALL socketpair (int, int, int, int *);
|
|---|
| 452 |
|
|---|
| 453 | /* EMX addition */
|
|---|
| 454 | int _impsockhandle (int, int);
|
|---|
| 455 |
|
|---|
| 456 | #ifndef TCPV40HDRS
|
|---|
| 457 | int TCPCALL accept_and_recv (long, long*, struct sockaddr *, long*, struct sockaddr*, long*, caddr_t, size_t);
|
|---|
| 458 | #endif
|
|---|
| 459 |
|
|---|
| 460 | /* OS/2 additions */
|
|---|
| 461 | void TCPCALL addsockettolist(int);
|
|---|
| 462 | int TCPCALL removesocketfromlist(int);
|
|---|
| 463 | #include <sys/ioccom.h>
|
|---|
| 464 | #ifdef TCPV40HDRS
|
|---|
| 465 | #include <sys/select.h>
|
|---|
| 466 | #endif
|
|---|
| 467 | int TCPCALL sock_init( void );
|
|---|
| 468 | int TCPCALL sock_errno( void );
|
|---|
| 469 | int TCPCALL os2_sock_errno( void );
|
|---|
| 470 | void TCPCALL psock_errno( char * );
|
|---|
| 471 | int TCPCALL soclose( int );
|
|---|
| 472 | int TCPCALL so_cancel(int);
|
|---|
| 473 | int TCPCALL Raccept(int, struct sockaddr *, int *);
|
|---|
| 474 | #ifdef TCPV40HDRS
|
|---|
| 475 | struct sockaddr_in;
|
|---|
| 476 | int TCPCALL Rbind(int, struct sockaddr_in *, int, struct sockaddr_in *);
|
|---|
| 477 | #else
|
|---|
| 478 | int TCPCALL Rbind(int, struct sockaddr *, int, struct sockaddr *);
|
|---|
| 479 | #endif
|
|---|
| 480 | int TCPCALL Rconnect(int, const struct sockaddr *, int);
|
|---|
| 481 | int TCPCALL Rgetsockname(int, struct sockaddr *, int *);
|
|---|
| 482 | int TCPCALL Rlisten(int, int);
|
|---|
| 483 | #ifndef TCPV40HDRS
|
|---|
| 484 | ssize_t TCPCALL send_file(int *, struct sf_parms *, int );
|
|---|
| 485 | char * TCPCALL sock_strerror(int);
|
|---|
| 486 | int TCPCALL getinetversion(char *);
|
|---|
| 487 | #endif
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 | /* more OS/2 stuff. */
|
|---|
| 491 | #ifndef MAXSOCKETS
|
|---|
| 492 | #ifdef TCPV40HDRS
|
|---|
| 493 | #define MAXSOCKETS 2048
|
|---|
| 494 | #else
|
|---|
| 495 | #define MAXSOCKETS 32768
|
|---|
| 496 | #endif
|
|---|
| 497 | #endif
|
|---|
| 498 |
|
|---|
| 499 | #define MT_FREE 0
|
|---|
| 500 | #define MT_DATA 1
|
|---|
| 501 | #define MT_HEADER 2
|
|---|
| 502 | #define MT_SOCKET 3
|
|---|
| 503 | #define MT_PCB 4
|
|---|
| 504 | #define MT_RTABLE 5
|
|---|
| 505 | #define MT_HTABLE 6
|
|---|
| 506 | #define MT_ATABLE 7
|
|---|
| 507 | #define MT_SONAME 8
|
|---|
| 508 | #define MT_ZOMBIE 9
|
|---|
| 509 | #define MT_SOOPTS 10
|
|---|
| 510 | #define MT_FTABLE 11
|
|---|
| 511 | #define MT_RIGHTS 12
|
|---|
| 512 | #define MT_IFADDR 13
|
|---|
| 513 |
|
|---|
| 514 | struct mbstat {
|
|---|
| 515 | u_short m_mbufs;
|
|---|
| 516 | u_short m_clusters;
|
|---|
| 517 | u_short m_clfree;
|
|---|
| 518 | u_short m_drops;
|
|---|
| 519 | u_long m_wait;
|
|---|
| 520 | u_short m_mtypes[256];
|
|---|
| 521 | };
|
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 | struct sostats {
|
|---|
| 525 | short count;
|
|---|
| 526 | #ifdef TCPV40HDRS
|
|---|
| 527 | short socketdata[9*MAXSOCKETS];
|
|---|
| 528 | #else
|
|---|
| 529 | short socketdata[13*MAXSOCKETS];
|
|---|
| 530 | #endif
|
|---|
| 531 | };
|
|---|
| 532 |
|
|---|
| 533 | #if defined (__cplusplus)
|
|---|
| 534 | }
|
|---|
| 535 | #endif
|
|---|
| 536 |
|
|---|
| 537 | #endif /* !_SYS_SOCKET_H_ */
|
|---|