4 #define __BSD_VISIBLE 1
8 * AmiTCP asynchronous event definitions
10 #define FD_ACCEPT 0x001 /* there is a connection to accept() */
11 #define FD_CONNECT 0x002 /* connect() completed */
12 #define FD_OOB 0x004 /* socket has out-of-band data */
13 #define FD_READ 0x008 /* socket is readable */
14 #define FD_WRITE 0x010 /* socket is writeable */
15 #define FD_ERROR 0x020 /* asynchronous error on socket */
16 #define FD_CLOSE 0x040 /* connection closed (graceful or not) */
20 * Definitions related to sockets: types, address families, options.
26 #define SOCK_STREAM 1 /* stream socket */
27 #define SOCK_DGRAM 2 /* datagram socket */
28 #define SOCK_RAW 3 /* raw-protocol interface */
29 #define SOCK_RDM 4 /* reliably-delivered message */
30 #define SOCK_SEQPACKET 5 /* sequenced packet stream */
33 * Option flags per-socket.
35 #define SO_DEBUG 0x0001 /* turn on debugging info recording */
36 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
37 #define SO_REUSEADDR 0x0004 /* allow local address reuse */
38 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
39 #define SO_DONTROUTE 0x0010 /* just use interface addresses */
40 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
41 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
42 #define SO_LINGER 0x0080 /* linger on close if data present */
43 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
44 #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
47 * Additional options, not kept in so_options.
49 #define SO_SNDBUF 0x1001 /* send buffer size */
50 #define SO_RCVBUF 0x1002 /* receive buffer size */
51 #define SO_SNDLOWAT 0x1003 /* send low-water mark */
52 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
53 #define SO_SNDTIMEO 0x1005 /* send timeout */
54 #define SO_RCVTIMEO 0x1006 /* receive timeout */
55 #define SO_ERROR 0x1007 /* get error status and clear */
56 #define SO_TYPE 0x1008 /* get socket type */
57 #define SO_CONTIMEO 0x1009 /* connection timeout */
58 #define SO_NO_CHECK 0x1009 /* don't create UDP checksum */
60 #define SO_EVENTMASK 0x2001
63 * Structure used for manipulating linger option.
66 long l_onoff
; /* option on/off */
67 long l_linger
; /* linger time */
71 * Level number for (get/set)sockopt() to apply to socket itself.
73 #define SOL_SOCKET 0xffff /* options for socket level */
78 #define AF_UNSPEC 0 /* unspecified */
79 #define AF_LOCAL 1 /* local to host (pipes, portals) */
80 #define AF_UNIX AF_LOCAL /* backward compatibility */
81 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
82 #define AF_IMPLINK 3 /* arpanet imp addresses */
83 #define AF_PUP 4 /* pup protocols: e.g. BSP */
84 #define AF_CHAOS 5 /* mit CHAOS protocols */
85 #define AF_NS 6 /* XEROX NS protocols */
86 #define AF_ISO 7 /* ISO protocols */
88 #define AF_ECMA 8 /* european computer manufacturers */
89 #define AF_DATAKIT 9 /* datakit protocols */
90 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
91 #define AF_SNA 11 /* IBM SNA */
92 #define AF_DECnet 12 /* DECnet */
93 #define AF_DLI 13 /* DEC Direct data link interface */
94 #define AF_LAT 14 /* LAT */
95 #define AF_HYLINK 15 /* NSC Hyperchannel */
96 #define AF_APPLETALK 16 /* Apple Talk */
97 #define AF_ROUTE 17 /* Internal Routing Protocol */
98 #define AF_LINK 18 /* Link layer interface */
99 #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
100 #define AF_COIP 20 /* connection-oriented IP, aka ST II */
101 #define AF_CNT 21 /* Computer Network Technology */
102 #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
103 #define AF_IPX 23 /* Novell Internet Protocol */
104 #define AF_SIP 24 /* Simple Internet Protocol */
105 #define pseudo_AF_PIP 25 /* Help Identify PIP packets */
106 #define AF_ISDN 26 /* Integrated Services Digital Network*/
107 #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
108 #define pseudo_AF_KEY 27 /* Internal key-management function */
109 #define AF_INET6 28 /* IPv6 */
114 * Structure used by kernel to store most
118 u_char sa_len
; /* total length */
119 u_char sa_family
; /* address family */
120 char sa_data
[14]; /* actually longer; address value */
124 * Structure used by kernel to pass protocol
125 * information in raw sockets.
128 u_short sp_family
; /* address family */
129 u_short sp_protocol
; /* protocol */
133 * Protocol families, same as address families for now.
135 #define PF_UNSPEC AF_UNSPEC
136 #define PF_LOCAL AF_LOCAL
137 #define PF_UNIX PF_LOCAL /* backward compatibility */
138 #define PF_INET AF_INET
139 #define PF_IMPLINK AF_IMPLINK
140 #define PF_PUP AF_PUP
141 #define PF_CHAOS AF_CHAOS
143 #define PF_ISO AF_ISO
144 #define PF_OSI AF_ISO
145 #define PF_ECMA AF_ECMA
146 #define PF_DATAKIT AF_DATAKIT
147 #define PF_CCITT AF_CCITT
148 #define PF_SNA AF_SNA
149 #define PF_DECnet AF_DECnet
150 #define PF_DLI AF_DLI
151 #define PF_LAT AF_LAT
152 #define PF_HYLINK AF_HYLINK
153 #define PF_APPLETALK AF_APPLETALK
154 #define PF_ROUTE AF_ROUTE
155 #define PF_LINK AF_LINK
156 #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
157 #define PF_COIP AF_COIP
158 #define PF_CNT AF_CNT
159 #define PF_SIP AF_SIP
160 #define PF_IPX AF_IPX /* same format as AF_NS */
161 #define PF_RTIP pseudo_AF_FTIP /* same format as AF_INET */
162 #define PF_PIP pseudo_AF_PIP
163 #define PF_ISDN AF_ISDN
164 #define PF_INET6 AF_INET6
166 #define PF_MAX AF_MAX
169 * Definitions for network related sysctl, CTL_NET.
171 * Second level is protocol family.
172 * Third level is protocol number.
174 * Further levels are defined by the individual families below.
176 #define NET_MAXID AF_MAX
178 #define CTL_NET_NAMES { \
181 { "inet", CTLTYPE_NODE }, \
196 { "route", CTLTYPE_NODE }, \
197 { "link_layer", CTLTYPE_NODE }, \
208 * PF_ROUTE - Routing table
210 * Three additional levels are defined:
211 * Fourth: address family, 0 is wildcard
212 * Fifth: type of info, defined below
213 * Sixth: flag(s) to mask with for NET_RT_FLAGS
215 #define NET_RT_DUMP 1 /* dump; may limit to a.f. */
216 #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
217 #define NET_RT_IFLIST 3 /* survey interface list */
218 #define NET_RT_MAXID 4
220 #define CTL_NET_RT_NAMES { \
222 { "dump", CTLTYPE_STRUCT }, \
223 { "flags", CTLTYPE_STRUCT }, \
224 { "iflist", CTLTYPE_STRUCT }, \
228 * Maximum queue length specifiable by listen.
230 #define SOMAXCONN 128
233 * Message header for recvmsg and sendmsg calls.
234 * Used value-result for recvmsg, value only for sendmsg.
237 caddr_t msg_name
; /* optional address */
238 u_int msg_namelen
; /* size of address */
239 struct iovec
*msg_iov
; /* scatter/gather array */
240 u_int msg_iovlen
; /* # elements in msg_iov */
241 caddr_t msg_control
; /* ancillary data, see below */
242 u_int msg_controllen
; /* ancillary data buffer len */
243 long msg_flags
; /* flags on received message */
246 #define MSG_OOB 0x1 /* process out-of-band data */
247 #define MSG_PEEK 0x2 /* peek at incoming message */
248 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
249 #define MSG_EOR 0x8 /* data completes record */
250 #define MSG_TRUNC 0x10 /* data discarded before delivery */
251 #define MSG_CTRUNC 0x20 /* control data lost before delivery */
252 #define MSG_WAITALL 0x40 /* wait for full request or error */
253 #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
254 #define MSG_EOF 0x100 /* data completes connection */
255 #define MSG_MORE 0x200 /* sender will send more */
256 #define MSG_COMPAT 0x8000 /* used in sendit() */
259 * Header for ancillary data objects in msg_control buffer.
260 * Used for additional information with/about a datagram
261 * not expressible by flags. The format is a sequence
262 * of message elements headed by cmsghdr structures.
265 u_int cmsg_len
; /* data byte count, including hdr */
266 long cmsg_level
; /* originating protocol */
267 long cmsg_type
; /* protocol-specific type */
268 /* followed by u_char cmsg_data[]; */
271 /* given pointer to struct cmsghdr, return pointer to data */
272 #define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
274 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
275 #define CMSG_NXTHDR(mhdr, cmsg) \
276 (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
277 (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
278 (struct cmsghdr *)NULL : \
279 (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
281 #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
283 /* "Socket"-level control message types: */
284 #define SCM_RIGHTS 0x01 /* access rights (array of int) */
287 * 4.3 compat sockaddr, move to compat file later
290 u_short sa_family
; /* address family */
291 char sa_data
[14]; /* up to 14 bytes of direct address */
295 * 4.3-compat message header (move to compat file later).
298 caddr_t msg_name
; /* optional address */
299 long msg_namelen
; /* size of address */
300 struct iovec
*msg_iov
; /* scatter/gather array */
301 long msg_iovlen
; /* # elements in msg_iov */
302 caddr_t msg_accrights
; /* access rights sent/received */
303 long msg_accrightslen
;
306 #ifndef SHUT_RD /* these three Posix.1g names are quite new */
307 #define SHUT_RD 0 /* shutdown for reading */
308 #define SHUT_WR 1 /* shutdown for writing */
309 #define SHUT_RDWR 2 /* shutdown for reading and writing */
312 #endif /* !_SYS_SOCKET_H_ */