xref: /freebsd/cddl/lib/libdtrace/socket.d (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1 /*
2  * Copyright (c) 2017 George V. Neville-Neil
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * Translators and flags for the socket structure.  FreeBSD specific code.
27  */
28 
29 #pragma D depends_on module kernel
30 
31 /*
32  * Option flags per-socket.
33  */
34 #pragma D binding "1.13" SO_DEBUG
35 inline int SO_DEBUG =		0x0001;		/* turn on debugging info recording */
36 #pragma D binding "1.13" SO_ACCEPTCONN
37 inline int SO_ACCEPTCONN = 	0x0002;		/* socket has had listen() */
38 #pragma D binding "1.13" SO_REUSEADDR
39 inline int SO_REUSEADDR =	0x0004;		/* allow local address reuse */
40 #pragma D binding "1.13" SO_KEEPALIVE
41 inline int SO_KEEPALIVE =	0x0008;		/* keep connections alive */
42 #pragma D binding "1.13" SO_DONTROUTE
43 inline int SO_DONTROUTE =	0x0010;		/* just use interface addresses */
44 #pragma D binding "1.13" SO_BROADCAST
45 inline int SO_BROADCAST =	0x0020;		/* permit sending of broadcast msgs */
46 #pragma D binding "1.13" SO_USELOOPBACK
47 inline int SO_USELOOPBACK =	0x0040;		/* bypass hardware when possible */
48 #pragma D binding "1.13" SO_LINGER
49 inline int SO_LINGER =		0x0080;		/* linger on close if data present */
50 #pragma D binding "1.13" SO_OOBINLINE
51 inline int SO_OOBINLINE =	0x0100;		/* leave received OOB data in line */
52 #pragma D binding "1.13" SO_REUSEPORT
53 inline int SO_REUSEPORT =	0x0200;		/* allow local address & port reuse */
54 #pragma D binding "1.13" SO_TIMESTAMP
55 inline int SO_TIMESTAMP =	0x0400;		/* timestamp received dgram traffic */
56 #pragma D binding "1.13" SO_NOSIGPIPE
57 inline int SO_NOSIGPIPE =	0x0800;		/* no SIGPIPE from EPIPE */
58 #pragma D binding "1.13" SO_ACCEPTFILTER
59 inline int SO_ACCEPTFILTER =	0x1000;		/* there is an accept filter */
60 #pragma D binding "1.13" SO_BINTIME
61 inline int SO_BINTIME =		0x2000;		/* timestamp received dgram traffic */
62 #pragma D binding "1.13" SO_NO_OFFLOAD
63 inline int SO_NO_OFFLOAD =	0x4000;		/* socket cannot be offloaded */
64 #pragma D binding "1.13" SO_NO_DDP
65 inline int SO_NO_DDP =		0x8000;		/* disable direct data placement */
66 
67 /*
68  * Additional options, not kept in so_options.
69  */
70 #pragma D binding "1.13" SO_SNDBUF
71 inline int SO_SNDBUF =		0x1001;		/* send buffer size */
72 #pragma D binding "1.13" SO_RCVBUF
73 inline int SO_RCVBUF =		0x1002;		/* receive buffer size */
74 #pragma D binding "1.13" SO_SNDLOWAT
75 inline int SO_SNDLOWAT =	0x1003;		/* send low-water mark */
76 #pragma D binding "1.13" SO_RCVLOWAT
77 inline int SO_RCVLOWAT =	0x1004;		/* receive low-water mark */
78 #pragma D binding "1.13" SO_SNDTIMEO
79 inline int SO_SNDTIMEO =	0x1005;		/* send timeout */
80 #pragma D binding "1.13" SO_RCVTIMEO
81 inline int SO_RCVTIMEO =	0x1006;		/* receive timeout */
82 #pragma D binding "1.13" SO_ERROR
83 inline int SO_ERROR =		0x1007;		/* get error status and clear */
84 #pragma D binding "1.13" SO_TYPE
85 inline int SO_TYPE =		0x1008;		/* get socket type */
86 #pragma D binding "1.13" SO_LABEL
87 inline int SO_LABEL =		0x1009;		/* socket's MAC label */
88 #pragma D binding "1.13" SO_PEERLABEL
89 inline int SO_PEERLABEL =	0x1010;		/* socket's peer's MAC label */
90 #pragma D binding "1.13" SO_LISTENQLIMIT
91 inline int SO_LISTENQLIMIT =	0x1011;		/* socket's backlog limit */
92 #pragma D binding "1.13" SO_LISTENQLEN
93 inline int SO_LISTENQLEN =	0x1012;		/* socket's complete queue length */
94 #pragma D binding "1.13" SO_LISTENINCQLEN
95 inline int SO_LISTENINCQLEN =	0x1013;		/* socket's incomplete queue length */
96 #pragma D binding "1.13" SO_SETFIB
97 inline int SO_SETFIB =		0x1014;		/* use this FIB to route */
98 #pragma D binding "1.13" SO_USER_COOKIE
99 inline int SO_USER_COOKIE =	0x1015;		/* user cookie (dummynet etc.) */
100 #pragma D binding "1.13" SO_PROTOCOL
101 inline int SO_PROTOCOL =	0x1016;		/* get socket protocol (Linux name) */
102 #pragma D binding "1.13" SO_PROTOTYPE
103 inline int SO_PROTOTYPE =	SO_PROTOCOL;	/* alias for SO_PROTOCOL (SunOS name) */
104 #pragma D binding "1.13" SO_TS_CLOCK
105 inline int SO_TS_CLOCK =	0x1017;		/* clock type used for SO_TIMESTAMP */
106 #pragma D binding "1.13" SO_MAX_PACING_RATE
107 inline int SO_MAX_PACING_RATE = 0x1018;	/* socket's max TX pacing rate (Linux name) */
108 
109 #pragma D binding "1.13" SO_TS_REALTIME_MICRO
110 inline int SO_TS_REALTIME_MICRO =	0;	/* microsecond resolution, realtime */
111 #pragma D binding "1.13" SO_TS_BINTIME
112 inline int SO_TS_BINTIME = 		1;	/* sub-nanosecond resolution, realtime */
113 #pragma D binding "1.13" SO_TS_REALTIME
114 inline int SO_TS_REALTIME = 		2;	/* nanosecond resolution, realtime */
115 #pragma D binding "1.13" SO_TS_MONOTONIC
116 inline int SO_TS_MONOTONIC =		3;	/* nanosecond resolution, monotonic */
117 #pragma D binding "1.13" SO_TS_DEFAULT
118 inline int SO_TS_DEFAULT = 		SO_TS_REALTIME_MICRO;
119 #pragma D binding "1.13" SO_TS_CLOCK_MAX
120 inline int SO_TS_CLOCK_MAX = 		SO_TS_MONOTONIC;
121 
122 #pragma D binding "1.13" AF_UNSPEC
123 inline int AF_UNSPEC =		0;		/* unspecified */
124 #pragma D binding "1.13" AF_UNIX
125 inline int AF_UNIX =		1;		/* standardized name for AF_LOCAL */
126 #pragma D binding "1.13" AF_LOCAL
127 inline int AF_LOCAL =		AF_UNIX;	/* local to host (pipes, portals) */
128 #pragma D binding "1.13" AF_INET
129 inline int AF_INET =		2;		/* internetwork: UDP, TCP, etc. */
130 #pragma D binding "1.13" AF_IMPLINK
131 inline int AF_IMPLINK =	3;		/* arpanet imp addresses */
132 #pragma D binding "1.13" AF_PUP
133 inline int AF_PUP =		4;		/* pup protocols: e.g. BSP */
134 #pragma D binding "1.13" AF_CHAOS
135 inline int AF_CHAOS =		5;		/* mit CHAOS protocols */
136 #pragma D binding "1.13" AF_NETBIOS
137 inline int AF_NETBIOS =	6;		/* SMB protocols */
138 #pragma D binding "1.13" AF_ISO
139 inline int AF_ISO =		7;		/* ISO protocols */
140 #pragma D binding "1.13" AF_OSI
141 inline int AF_OSI =		AF_ISO;
142 #pragma D binding "1.13" AF_ECMA
143 inline int AF_ECMA =		8;		/* European computer manufacturers */
144 #pragma D binding "1.13" AF_DATAKIT
145 inline int AF_DATAKIT =		9;		/* datakit protocols */
146 #pragma D binding "1.13" AF_CCITT
147 inline int AF_CCITT =		10;		/* CCITT protocols, X.25 etc */
148 #pragma D binding "1.13" AF_SNA
149 inline int AF_SNA =		11;		/* IBM SNA */
150 #pragma D binding "1.13" AF_DECnet
151 inline int AF_DECnet =		12;		/* DECnet */
152 #pragma D binding "1.13" AF_DLI
153 inline int AF_DLI =		13;		/* DEC Direct data link interface */
154 #pragma D binding "1.13" AF_LAT
155 inline int AF_LAT =		14;		/* LAT */
156 #pragma D binding "1.13" AF_HYLINK
157 inline int AF_HYLINK =		15;		/* NSC Hyperchannel */
158 #pragma D binding "1.13" AF_APPLETALK
159 inline int AF_APPLETALK =	16;		/* Apple Talk */
160 #pragma D binding "1.13" AF_ROUTE
161 inline int AF_ROUTE =		17;		/* Internal Routing Protocol */
162 #pragma D binding "1.13" AF_LINK
163 inline int AF_LINK =		18;		/* Link layer interface */
164 #pragma D binding "1.13" pseudo_AF_XTP
165 inline int pseudo_AF_XTP =	19;		/* eXpress Transfer Protocol (no AF) */
166 #pragma D binding "1.13" AF_COIP
167 inline int AF_COIP =		20;		/* connection-oriented IP, aka ST II */
168 #pragma D binding "1.13" AF_CNT
169 inline int AF_CNT =		21;		/* Computer Network Technology */
170 #pragma D binding "1.13" pseudo_AF_RTIP
171 inline int pseudo_AF_RTIP =	22;		/* Help Identify RTIP packets */
172 #pragma D binding "1.13" AF_IPX
173 inline int AF_IPX =		23;		/* Novell Internet Protocol */
174 #pragma D binding "1.13" AF_SIP
175 inline int AF_SIP =		24;		/* Simple Internet Protocol */
176 #pragma D binding "1.13" pseudo_AF_PIP
177 inline int pseudo_AF_PIP =	25;		/* Help Identify PIP packets */
178 #pragma D binding "1.13" AF_ISDN
179 inline int AF_ISDN =		26;		/* Integrated Services Digital Network*/
180 #pragma D binding "1.13" AF_E164
181 inline int AF_E164 =		AF_ISDN;	/* CCITT E.164 recommendation */
182 #pragma D binding "1.13" pseudo_AF_KEY
183 inline int pseudo_AF_KEY =	27;		/* Internal key-management function */
184 #pragma D binding "1.13" AF_INET6
185 inline int AF_INET6 =		28;		/* IPv6 */
186 #pragma D binding "1.13" AF_NATM
187 inline int AF_NATM =		29;		/* native ATM access */
188 #pragma D binding "1.13" AF_ATM
189 inline int AF_ATM =		30;		/* ATM */
190 #pragma D binding "1.13" pseudo_AF_HDRCMPLT
191 inline int pseudo_AF_HDRCMPLT = 31;	/* Used by BPF to not rewrite headers
192 					 * in interface output routine
193 					 */
194 #pragma D binding "1.13" AF_NETGRAPH
195 inline int AF_NETGRAPH =	32;		/* Netgraph sockets */
196 #pragma D binding "1.13" AF_SLOW
197 inline int AF_SLOW =		33;		/* 802.3ad slow protocol */
198 #pragma D binding "1.13" AF_SCLUSTER
199 inline int AF_SCLUSTER =	34;		/* Sitara cluster protocol */
200 #pragma D binding "1.13" AF_ARP
201 inline int AF_ARP =		35;		/* Address Resolution Protocol */
202 #pragma D binding "1.13" AF_BLUETOOTH
203 inline int AF_BLUETOOTH =	36;		/* Bluetooth sockets */
204 #pragma D binding "1.13" AF_IEEE80211
205 inline int AF_IEEE80211 =	37;		/* IEEE 802.11 protocol */
206 #pragma D binding "1.13" AF_INET_SDP
207 inline int AF_INET_SDP	=	40;		/* OFED Socket Direct Protocol ipv4 */
208 #pragma D binding "1.13" AF_INET6_SDP
209 inline int AF_INET6_SDP =	42;		/* OFED Socket Direct Protocol ipv6 */
210 #pragma D binding "1.13" AF_MAX
211 inline int AF_MAX =		42;
212 
213 /*
214  * Protocol families, same as address families for now.
215  */
216 #pragma D binding "1.13" PF_UNSPEC
217 inline int PF_UNSPEC =	AF_UNSPEC;
218 #pragma D binding "1.13" PF_LOCAL
219 inline int PF_LOCAL =	AF_LOCAL;
220 #pragma D binding "1.13" PF_UNIX
221 inline int PF_UNIX =	PF_LOCAL;	/* backward compatibility */
222 #pragma D binding "1.13" PF_INET
223 inline int PF_INET =	AF_INET;
224 #pragma D binding "1.13" PF_IMPLINK
225 inline int PF_IMPLINK =	AF_IMPLINK;
226 #pragma D binding "1.13" PF_PUP
227 inline int PF_PUP =	AF_PUP;
228 #pragma D binding "1.13" PF_CHAOS
229 inline int PF_CHAOS =	AF_CHAOS;
230 #pragma D binding "1.13" PF_NETBIOS
231 inline int PF_NETBIOS =	AF_NETBIOS;
232 #pragma D binding "1.13" PF_ISO
233 inline int PF_ISO =	AF_ISO;
234 #pragma D binding "1.13" PF_OSI
235 inline int PF_OSI =	AF_ISO;
236 #pragma D binding "1.13" PF_ECMA
237 inline int PF_ECMA =	AF_ECMA;
238 #pragma D binding "1.13" PF_DATAKIT
239 inline int PF_DATAKIT =	AF_DATAKIT;
240 #pragma D binding "1.13" PF_CCITT
241 inline int PF_CCITT =	AF_CCITT;
242 #pragma D binding "1.13" PF_SNA
243 inline int PF_SNA =	AF_SNA;
244 #pragma D binding "1.13" PF_DECnet
245 inline int PF_DECnet =	AF_DECnet;
246 #pragma D binding "1.13" PF_DLI
247 inline int PF_DLI =	AF_DLI;
248 #pragma D binding "1.13" PF_LAT
249 inline int PF_LAT =	AF_LAT;
250 #pragma D binding "1.13" PF_HYLINK
251 inline int PF_HYLINK =	AF_HYLINK;
252 #pragma D binding "1.13" PF_APPLETALK
253 inline int PF_APPLETALK =	AF_APPLETALK;
254 #pragma D binding "1.13" PF_ROUTE
255 inline int PF_ROUTE =	AF_ROUTE;
256 #pragma D binding "1.13" PF_LINK
257 inline int PF_LINK =	AF_LINK;
258 #pragma D binding "1.13" PF_XTP
259 inline int PF_XTP =	pseudo_AF_XTP;	/* really just proto family, no AF */
260 #pragma D binding "1.13" PF_COIP
261 inline int PF_COIP =	AF_COIP;
262 #pragma D binding "1.13" PF_CNT
263 inline int PF_CNT =	AF_CNT;
264 #pragma D binding "1.13" PF_SIP
265 inline int PF_SIP =	AF_SIP;
266 #pragma D binding "1.13" PF_IPX
267 inline int PF_IPX =	AF_IPX;
268 #pragma D binding "1.13" PF_RTIP
269 inline int PF_RTIP =	pseudo_AF_RTIP;	/* same format as AF_INET */
270 #pragma D binding "1.13" PF_PIP
271 inline int PF_PIP =	pseudo_AF_PIP;
272 #pragma D binding "1.13" PF_ISDN
273 inline int PF_ISDN =	AF_ISDN;
274 #pragma D binding "1.13" PF_KEY
275 inline int PF_KEY =	pseudo_AF_KEY;
276 #pragma D binding "1.13" PF_INET6
277 inline int PF_INET6 =	AF_INET6;
278 #pragma D binding "1.13" PF_NATM
279 inline int PF_NATM =	AF_NATM;
280 #pragma D binding "1.13" PF_ATM
281 inline int PF_ATM =	AF_ATM;
282 #pragma D binding "1.13" PF_NETGRAPH
283 inline int PF_NETGRAPH =	AF_NETGRAPH;
284 #pragma D binding "1.13" PF_SLOW
285 inline int PF_SLOW =	AF_SLOW;
286 #pragma D binding "1.13" PF_SCLUSTER
287 inline int PF_SCLUSTER =	AF_SCLUSTER;
288 #pragma D binding "1.13" PF_ARP
289 inline int PF_ARP =	AF_ARP;
290 #pragma D binding "1.13" PF_BLUETOOTH
291 inline int PF_BLUETOOTH =	AF_BLUETOOTH;
292 #pragma D binding "1.13" PF_IEEE80211
293 inline int PF_IEEE80211 =	AF_IEEE80211;
294 #pragma D binding "1.13" PF_INET_SDP
295 inline int PF_INET_SDP=	AF_INET_SDP;
296 #pragma D binding "1.13" PF_INET6_SDP
297 inline int PF_INET6_SDP=	AF_INET6_SDP;
298 #pragma D binding "1.13" PF_MAX
299 inline int PF_MAX =	AF_MAX;
300