Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / network / stacks / AROSTCP / netinclude / sys / socket.h
blob98be0cfeefdef7d50a7841e079c6942cc82c9fbe
1 #ifndef _SYS_SOCKET_H_
2 #define _SYS_SOCKET_H_
4 #ifndef _SYS_TYPES_H_
5 #include <sys/types.h>
6 #endif
9 /*
10 * AmiTCP asynchronous event definitions
12 #define FD_ACCEPT 0x001 /* there is a connection to accept() */
13 #define FD_CONNECT 0x002 /* connect() completed */
14 #define FD_OOB 0x004 /* socket has out-of-band data */
15 #define FD_READ 0x008 /* socket is readable */
16 #define FD_WRITE 0x010 /* socket is writeable */
17 #define FD_ERROR 0x020 /* asynchronous error on socket */
18 #define FD_CLOSE 0x040 /* connection closed (graceful or not) */
22 * Definitions related to sockets: types, address families, options.
26 * Types
28 #define SOCK_STREAM 1 /* stream socket */
29 #define SOCK_DGRAM 2 /* datagram socket */
30 #define SOCK_RAW 3 /* raw-protocol interface */
31 #define SOCK_RDM 4 /* reliably-delivered message */
32 #define SOCK_SEQPACKET 5 /* sequenced packet stream */
35 * Option flags per-socket.
37 #define SO_DEBUG 0x0001 /* turn on debugging info recording */
38 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
39 #define SO_REUSEADDR 0x0004 /* allow local address reuse */
40 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
41 #define SO_DONTROUTE 0x0010 /* just use interface addresses */
42 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
43 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
44 #define SO_LINGER 0x0080 /* linger on close if data present */
45 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
46 #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
49 * Additional options, not kept in so_options.
51 #define SO_SNDBUF 0x1001 /* send buffer size */
52 #define SO_RCVBUF 0x1002 /* receive buffer size */
53 #define SO_SNDLOWAT 0x1003 /* send low-water mark */
54 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
55 #define SO_SNDTIMEO 0x1005 /* send timeout */
56 #define SO_RCVTIMEO 0x1006 /* receive timeout */
57 #define SO_ERROR 0x1007 /* get error status and clear */
58 #define SO_TYPE 0x1008 /* get socket type */
60 #define SO_EVENTMASK 0x2001
63 * Structure used for manipulating linger option.
65 struct linger {
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 */
76 * Address families.
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 */
87 #define AF_OSI AF_ISO
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 */
111 #define AF_MAX 29
114 * Structure used by kernel to store most
115 * addresses.
117 struct sockaddr {
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.
127 struct sockproto {
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
142 #define PF_NS AF_NS
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
165 #define PF_MAX AF_MAX
168 * Definitions for network related sysctl, CTL_NET.
170 * Second level is protocol family.
171 * Third level is protocol number.
173 * Further levels are defined by the individual families below.
175 #define NET_MAXID AF_MAX
177 #define CTL_NET_NAMES { \
178 { 0, 0 }, \
179 { 0, 0 }, \
180 { "inet", CTLTYPE_NODE }, \
181 { 0, 0 }, \
182 { 0, 0 }, \
183 { 0, 0 }, \
184 { 0, 0 }, \
185 { 0, 0 }, \
186 { 0, 0 }, \
187 { 0, 0 }, \
188 { 0, 0 }, \
189 { 0, 0 }, \
190 { 0, 0 }, \
191 { 0, 0 }, \
192 { 0, 0 }, \
193 { 0, 0 }, \
194 { 0, 0 }, \
195 { "route", CTLTYPE_NODE }, \
196 { "link_layer", CTLTYPE_NODE }, \
197 { 0, 0 }, \
198 { 0, 0 }, \
199 { 0, 0 }, \
200 { 0, 0 }, \
201 { 0, 0 }, \
202 { 0, 0 }, \
203 { 0, 0 }, \
207 * PF_ROUTE - Routing table
209 * Three additional levels are defined:
210 * Fourth: address family, 0 is wildcard
211 * Fifth: type of info, defined below
212 * Sixth: flag(s) to mask with for NET_RT_FLAGS
214 #define NET_RT_DUMP 1 /* dump; may limit to a.f. */
215 #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
216 #define NET_RT_IFLIST 3 /* survey interface list */
217 #define NET_RT_MAXID 4
219 #define CTL_NET_RT_NAMES { \
220 { 0, 0 }, \
221 { "dump", CTLTYPE_STRUCT }, \
222 { "flags", CTLTYPE_STRUCT }, \
223 { "iflist", CTLTYPE_STRUCT }, \
227 * Maximum queue length specifiable by listen.
229 #define SOMAXCONN 128
232 * Message header for recvmsg and sendmsg calls.
233 * Used value-result for recvmsg, value only for sendmsg.
235 struct msghdr {
236 caddr_t msg_name; /* optional address */
237 u_int msg_namelen; /* size of address */
238 struct iovec *msg_iov; /* scatter/gather array */
239 u_int msg_iovlen; /* # elements in msg_iov */
240 caddr_t msg_control; /* ancillary data, see below */
241 u_int msg_controllen; /* ancillary data buffer len */
242 long msg_flags; /* flags on received message */
245 #define MSG_OOB 0x1 /* process out-of-band data */
246 #define MSG_PEEK 0x2 /* peek at incoming message */
247 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
248 #define MSG_EOR 0x8 /* data completes record */
249 #define MSG_TRUNC 0x10 /* data discarded before delivery */
250 #define MSG_CTRUNC 0x20 /* control data lost before delivery */
251 #define MSG_WAITALL 0x40 /* wait for full request or error */
252 #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
253 #define MSG_EOF 0x100 /* data completes connection */
254 #define MSG_COMPAT 0x8000 /* used in sendit() */
257 * Header for ancillary data objects in msg_control buffer.
258 * Used for additional information with/about a datagram
259 * not expressible by flags. The format is a sequence
260 * of message elements headed by cmsghdr structures.
262 struct cmsghdr {
263 u_int cmsg_len; /* data byte count, including hdr */
264 long cmsg_level; /* originating protocol */
265 long cmsg_type; /* protocol-specific type */
266 /* followed by u_char cmsg_data[]; */
269 /* given pointer to struct cmsghdr, return pointer to data */
270 #define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
272 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
273 #define CMSG_NXTHDR(mhdr, cmsg) \
274 (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
275 (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
276 (struct cmsghdr *)NULL : \
277 (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
279 #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
281 /* "Socket"-level control message types: */
282 #define SCM_RIGHTS 0x01 /* access rights (array of int) */
285 * 4.3 compat sockaddr, move to compat file later
287 struct osockaddr {
288 u_short sa_family; /* address family */
289 char sa_data[14]; /* up to 14 bytes of direct address */
293 * 4.3-compat message header (move to compat file later).
295 struct omsghdr {
296 caddr_t msg_name; /* optional address */
297 long msg_namelen; /* size of address */
298 struct iovec *msg_iov; /* scatter/gather array */
299 long msg_iovlen; /* # elements in msg_iov */
300 caddr_t msg_accrights; /* access rights sent/received */
301 long msg_accrightslen;
304 #ifndef SHUT_RD /* these three Posix.1g names are quite new */
305 #define SHUT_RD 0 /* shutdown for reading */
306 #define SHUT_WR 1 /* shutdown for writing */
307 #define SHUT_RDWR 2 /* shutdown for reading and writing */
308 #endif
310 #endif /* !_SYS_SOCKET_H_ */