BSD 4_2 development
[unix-history] / usr / src / sys / h / socket.h
CommitLineData
59703a43
C
1/* socket.h 6.1 83/07/29 */
2
3/*
4 * Definitions related to sockets: types, address families, options.
5 */
6
7/*
8 * Types
9 */
10#define SOCK_STREAM 1 /* stream socket */
11#define SOCK_DGRAM 2 /* datagram socket */
12#define SOCK_RAW 3 /* raw-protocol interface */
13#define SOCK_RDM 4 /* reliably-delivered message */
14#define SOCK_SEQPACKET 5 /* sequenced packet stream */
15
16/*
17 * Option flags per-socket.
18 */
19#define SO_DEBUG 0x01 /* turn on debugging info recording */
20#define SO_ACCEPTCONN 0x02 /* socket has had listen() */
21#define SO_REUSEADDR 0x04 /* allow local address reuse */
22#define SO_KEEPALIVE 0x08 /* keep connections alive */
23#define SO_DONTROUTE 0x10 /* just use interface addresses */
24 /* 0x20 was SO_NEWFDONCONN */
25#define SO_USELOOPBACK 0x40 /* bypass hardware when possible */
26#define SO_LINGER 0x80 /* linger on close if data present */
27#define SO_DONTLINGER (~SO_LINGER) /* ~SO_LINGER */
28
29/*
30 * Address families.
31 */
32#define AF_UNSPEC 0 /* unspecified */
33#define AF_UNIX 1 /* local to host (pipes, portals) */
34#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
35#define AF_IMPLINK 3 /* arpanet imp addresses */
36#define AF_PUP 4 /* pup protocols: e.g. BSP */
37#define AF_CHAOS 5 /* mit CHAOS protocols */
38#define AF_NS 6 /* XEROX NS protocols */
39#define AF_NBS 7 /* nbs protocols */
40#define AF_ECMA 8 /* european computer manufacturers */
41#define AF_DATAKIT 9 /* datakit protocols */
42#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
43#define AF_SNA 11 /* IBM SNA */
44
45#define AF_MAX 12
46
47/*
48 * Structure used by kernel to store most
49 * addresses.
50 */
51struct sockaddr {
52 u_short sa_family; /* address family */
53 char sa_data[14]; /* up to 14 bytes of direct address */
54};
55
56/*
57 * Structure used by kernel to pass protocol
58 * information in raw sockets.
59 */
60struct sockproto {
61 u_short sp_family; /* address family */
62 u_short sp_protocol; /* protocol */
63};
64
65/*
66 * Protocol families, same as address families for now.
67 */
68#define PF_UNSPEC AF_UNSPEC
69#define PF_UNIX AF_UNIX
70#define PF_INET AF_INET
71#define PF_IMPLINK AF_IMPLINK
72#define PF_PUP AF_PUP
73#define PF_CHAOS AF_CHAOS
74#define PF_NS AF_NS
75#define PF_NBS AF_NBS
76#define PF_ECMA AF_ECMA
77#define PF_DATAKIT AF_DATAKIT
78#define PF_CCITT AF_CCITT
79#define PF_SNA AF_SNA
80
81#define PF_MAX 12
82
83/*
84 * Level number for (get/set)sockopt() to apply to socket itself.
85 */
86#define SOL_SOCKET 0xffff /* options for socket level */
87
88/*
89 * Maximum queue length specifiable by listen.
90 */
91#define SOMAXCONN 5
92
93/*
94 * Message header for recvmsg and sendmsg calls.
95 */
96struct msghdr {
97 caddr_t msg_name; /* optional address */
98 int msg_namelen; /* size of address */
99 struct iovec *msg_iov; /* scatter/gather array */
100 int msg_iovlen; /* # elements in msg_iov */
101 caddr_t msg_accrights; /* access rights sent/received */
102 int msg_accrightslen;
103};
104
105#define MSG_OOB 0x1 /* process out-of-band data */
106#define MSG_PEEK 0x2 /* peek at incoming message */
107#define MSG_DONTROUTE 0x4 /* send without using routing tables */
108
109#define MSG_MAXIOVLEN 16