aboutsummaryrefslogtreecommitdiffstats
path: root/test/packetdrill/uapi_linux.h
blob: 657b762dfa1b43604d45115ef13fe02cc3322abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
 * Copyright 2018 Google Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */
/*
 * Author: ncardwell@google.com (Neal Cardwell)
 *
 * Our own header declarations, so we have something that's
 * portable and somewhat more readable than a typical system header
 * file.
 *
 * We cannot just include the kernel's headers because this tool tries
 * to compile and work for basically any Linux/BSD kernel version. So
 * we declare our own version of various network-related definitions here.
 */

#ifndef __UAPI_LINUX_H__
#define __UAPI_LINUX_H__

#include "types.h"

#include <netinet/tcp.h>

#ifdef linux

/* From Linux include/uapi/asm-generic/socket.h: */

#define SO_MAX_PACING_RATE      47

#define SO_BPF_EXTENSIONS	48

#define SO_INCOMING_CPU		49

#define SO_ATTACH_BPF		50
#define SO_DETACH_BPF		SO_DETACH_FILTER

#define SO_ATTACH_REUSEPORT_CBPF	51
#define SO_ATTACH_REUSEPORT_EBPF	52

#define SO_CNX_ADVICE		53

#define SCM_TIMESTAMPING_OPT_STATS	54

#define SO_MEMINFO		55

#define SO_INCOMING_NAPI_ID	56

#define SO_COOKIE		57

#define SCM_TIMESTAMPING_PKTINFO	58

#define SO_PEERGROUPS		59

#define SO_ZEROCOPY		60

/* From Linux include/uapi/linux/errqueue.h: */

struct sock_extended_err {
	__u32	ee_errno;
	__u8	ee_origin;
	__u8	ee_type;
	__u8	ee_code;
	__u8	ee_pad;
	__u32   ee_info;
	__u32   ee_data;
};

#define SO_EE_ORIGIN_NONE	0
#define SO_EE_ORIGIN_LOCAL	1
#define SO_EE_ORIGIN_ICMP	2
#define SO_EE_ORIGIN_ICMP6	3
#define SO_EE_ORIGIN_TXSTATUS	4
#define SO_EE_ORIGIN_ZEROCOPY	5
#define SO_EE_ORIGIN_TIMESTAMPING SO_EE_ORIGIN_TXSTATUS

#define SO_EE_CODE_ZEROCOPY_COPIED	1

struct scm_timestamping {
	struct timespec ts[3];
};

enum {
	SCM_TSTAMP_SND,		/* driver passed skb to NIC, or HW */
	SCM_TSTAMP_SCHED,	/* data entered the packet scheduler */
	SCM_TSTAMP_ACK,		/* data acknowledged by peer */
};

/* From Linux include/uapi/linux/net_tstamp.h: */

/* SO_TIMESTAMPING gets an integer bit field comprised of these values */
enum {
	SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),
	SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1),
	SOF_TIMESTAMPING_RX_HARDWARE = (1<<2),
	SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3),
	SOF_TIMESTAMPING_SOFTWARE = (1<<4),
	SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5),
	SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),
	SOF_TIMESTAMPING_OPT_ID = (1<<7),
	SOF_TIMESTAMPING_TX_SCHED = (1<<8),
	SOF_TIMESTAMPING_TX_ACK = (1<<9),
	SOF_TIMESTAMPING_OPT_CMSG = (1<<10),
	SOF_TIMESTAMPING_OPT_TSONLY = (1<<11),
	SOF_TIMESTAMPING_OPT_STATS = (1<<12),
	SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),
	SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),

	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_TX_SWHW,

	SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
				 SOF_TIMESTAMPING_LAST
};

/* From Linux include/uapi/linux/eventpoll.h: */

#include <sys/epoll.h>

/* Set exclusive wakeup mode for the target file descriptor */
#ifndef EPOLLEXCLUSIVE
#define EPOLLEXCLUSIVE  (1U << 28)
#endif

/* From Linux include/uapi/linux/capability.h: */

#include <linux/capability.h>

#ifndef CAP_CHOWN
#define CAP_CHOWN		0
#endif

#ifndef CAP_DAC_OVERRIDE
#define CAP_DAC_OVERRIDE	1
#endif

#ifndef CAP_DAC_READ_SEARCH
#define CAP_DAC_READ_SEARCH	2
#endif

#ifndef CAP_FOWNER
#define CAP_FOWNER		3
#endif

#ifndef CAP_FSETID
#define CAP_FSETID		4
#endif

#ifndef CAP_KILL
#define CAP_KILL		5
#endif

#ifndef CAP_SETGID
#define CAP_SETGID		6
#endif

#ifndef CAP_SETUID
#define CAP_SETUID		7
#endif

#ifndef CAP_SETPCAP
#define CAP_SETPCAP		8
#endif

#ifndef CAP_LINUX_IMMUTABLE
#define CAP_LINUX_IMMUTABLE	9
#endif

#ifndef CAP_NET_BIND_SERVICE
#define CAP_NET_BIND_SERVICE	10
#endif

#ifndef CAP_NET_BROADCAST
#define CAP_NET_BROADCAST	11
#endif

#ifndef CAP_NET_ADMIN
#define CAP_NET_ADMIN		12
#endif

#ifndef CAP_NET_RAW
#define CAP_NET_RAW		13
#endif

#ifndef CAP_IPC_LOCK
#define CAP_IPC_LOCK		14
#endif

#ifndef CAP_IPC_OWNER
#define CAP_IPC_OWNER		15
#endif

#ifndef CAP_SYS_MODULE
#define CAP_SYS_MODULE		16
#endif

#ifndef CAP_SYS_RAWIO
#define CAP_SYS_RAWIO		17
#endif

#ifndef CAP_SYS_CHROOT
#define CAP_SYS_CHROOT		18
#endif

#ifndef CAP_SYS_PTRACE
#define CAP_SYS_PTRACE		19
#endif

#ifndef CAP_SYS_PACCT
#define CAP_SYS_PACCT		20
#endif

#ifndef CAP_SYS_ADMIN
#define CAP_SYS_ADMIN		21
#endif

#ifndef CAP_SYS_BOOT
#define CAP_SYS_BOOT		22
#endif

#ifndef CAP_SYS_NICE
#define CAP_SYS_NICE		23
#endif

#ifndef CAP_SYS_RESOURCE
#define CAP_SYS_RESOURCE	24
#endif

#ifndef CAP_SYS_TIME
#define CAP_SYS_TIME		25
#endif

#ifndef CAP_SYS_TTY_CONFIG
#define CAP_SYS_TTY_CONFIG	26
#endif

#ifndef CAP_MKNOD
#define CAP_MKNOD		27
#endif

#ifndef CAP_LEASE
#define CAP_LEASE		28
#endif

#ifndef CAP_AUDIT_WRITE
#define CAP_AUDIT_WRITE		29
#endif

#ifndef CAP_AUDIT_CONTROL
#define CAP_AUDIT_CONTROL	30
#endif

#ifndef CAP_SETFCAP
#define CAP_SETFCAP		31
#endif

#ifndef CAP_MAC_OVERRIDE
#define CAP_MAC_OVERRIDE	32
#endif

#ifndef CAP_MAC_ADMIN
#define CAP_MAC_ADMIN		33
#endif

#ifndef CAP_SYSLOG
#define CAP_SYSLOG		34
#endif

#ifndef CAP_WAKE_ALARM
#define CAP_WAKE_ALARM		35
#endif

#ifndef CAP_BLOCK_SUSPEND
#define CAP_BLOCK_SUSPEND	36
#endif

#ifndef CAP_AUDIT_READ
#define CAP_AUDIT_READ		37
#endif

#endif  /* linux */


#endif /* __UAPI_LINUX_H__ */