xref: /original-bsd/sys/sys/socket.h (revision 53787e02)
1 /*
2  * Copyright (c) 1982 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)socket.h	6.6 (Berkeley) 06/08/85
7  */
8 
9 /*
10  * Definitions related to sockets: types, address families, options.
11  */
12 
13 /*
14  * Types
15  */
16 #define	SOCK_STREAM	1		/* stream socket */
17 #define	SOCK_DGRAM	2		/* datagram socket */
18 #define	SOCK_RAW	3		/* raw-protocol interface */
19 #define	SOCK_RDM	4		/* reliably-delivered message */
20 #define	SOCK_SEQPACKET	5		/* sequenced packet stream */
21 
22 /*
23  * Option flags per-socket.
24  */
25 #define	SO_DEBUG	0x01		/* turn on debugging info recording */
26 #define	SO_ACCEPTCONN	0x02		/* socket has had listen() */
27 #define	SO_REUSEADDR	0x04		/* allow local address reuse */
28 #define	SO_KEEPALIVE	0x08		/* keep connections alive */
29 #define	SO_DONTROUTE	0x10		/* just use interface addresses */
30 #define	SO_BROADCAST	0x20		/* permit sending of broadcast msgs */
31 #define	SO_USELOOPBACK	0x40		/* bypass hardware when possible */
32 #define	SO_LINGER	0x80		/* linger on close if data present */
33 
34 /*
35  * Additional options, not kept in so_options.
36  */
37 #define SO_SNDBUF	0x1001		/* send buffer size */
38 #define SO_RCVBUF	0x1002		/* receive buffer size */
39 #define SO_SNDLOWAT	0x1003		/* send low-water mark */
40 #define SO_RCVLOWAT	0x1004		/* receive low-water mark */
41 #define SO_SNDTIMEO	0x1005		/* send timeout */
42 #define SO_RCVTIMEO	0x1006		/* receive timeout */
43 
44 /*
45  * Structure used for manipulating linger option.
46  */
47 struct	linger {
48 	int	l_onoff;		/* option on/off */
49 	int	l_linger;		/* linger time */
50 };
51 
52 /*
53  * Level number for (get/set)sockopt() to apply to socket itself.
54  */
55 #define	SOL_SOCKET	0xffff		/* options for socket level */
56 
57 /*
58  * Address families.
59  */
60 #define	AF_UNSPEC	0		/* unspecified */
61 #define	AF_UNIX		1		/* local to host (pipes, portals) */
62 #define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
63 #define	AF_IMPLINK	3		/* arpanet imp addresses */
64 #define	AF_PUP		4		/* pup protocols: e.g. BSP */
65 #define	AF_CHAOS	5		/* mit CHAOS protocols */
66 #define	AF_NS		6		/* XEROX NS protocols */
67 #define	AF_NBS		7		/* nbs protocols */
68 #define	AF_ECMA		8		/* european computer manufacturers */
69 #define	AF_DATAKIT	9		/* datakit protocols */
70 #define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
71 #define	AF_SNA		11		/* IBM SNA */
72 
73 #define	AF_MAX		12
74 
75 /*
76  * Structure used by kernel to store most
77  * addresses.
78  */
79 struct sockaddr {
80 	u_short	sa_family;		/* address family */
81 	char	sa_data[14];		/* up to 14 bytes of direct address */
82 };
83 
84 /*
85  * Structure used by kernel to pass protocol
86  * information in raw sockets.
87  */
88 struct sockproto {
89 	u_short	sp_family;		/* address family */
90 	u_short	sp_protocol;		/* protocol */
91 };
92 
93 /*
94  * Protocol families, same as address families for now.
95  */
96 #define	PF_UNSPEC	AF_UNSPEC
97 #define	PF_UNIX		AF_UNIX
98 #define	PF_INET		AF_INET
99 #define	PF_IMPLINK	AF_IMPLINK
100 #define	PF_PUP		AF_PUP
101 #define	PF_CHAOS	AF_CHAOS
102 #define	PF_NS		AF_NS
103 #define	PF_NBS		AF_NBS
104 #define	PF_ECMA		AF_ECMA
105 #define	PF_DATAKIT	AF_DATAKIT
106 #define	PF_CCITT	AF_CCITT
107 #define	PF_SNA		AF_SNA
108 
109 #define	PF_MAX		12
110 
111 /*
112  * Maximum queue length specifiable by listen.
113  */
114 #define	SOMAXCONN	5
115 
116 /*
117  * Message header for recvmsg and sendmsg calls.
118  */
119 struct msghdr {
120 	caddr_t	msg_name;		/* optional address */
121 	int	msg_namelen;		/* size of address */
122 	struct	iovec *msg_iov;		/* scatter/gather array */
123 	int	msg_iovlen;		/* # elements in msg_iov */
124 	caddr_t	msg_accrights;		/* access rights sent/received */
125 	int	msg_accrightslen;
126 };
127 
128 #define	MSG_OOB		0x1		/* process out-of-band data */
129 #define	MSG_PEEK	0x2		/* peek at incoming message */
130 #define	MSG_DONTROUTE	0x4		/* send without using routing tables */
131 
132 #define	MSG_MAXIOVLEN	16
133