nf 0.1.0

A port of the netfilter framework written entirely in rust.
Documentation
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#![allow(non_upper_case_globals, non_snake_case, non_camel_case_types)]

/// Netlink conntrack message types for connection tracking
#[repr(u32)]
pub enum ctnl_msg_types {
    /// Create a new conntrack entry
    IPCTNL_MSG_CT_NEW,
    /// Get a conntrack entry
    IPCTNL_MSG_CT_GET,
    /// Delete a conntrack entry
    IPCTNL_MSG_CT_DELETE,
    /// Atomically get and reset counters
    IPCTNL_MSG_CT_GET_CTRZERO,
    /// Get CPU-specific statistics
    IPCTNL_MSG_CT_GET_STATS_CPU,
    /// Get global statistics
    IPCTNL_MSG_CT_GET_STATS,
    /// Get dying connections
    IPCTNL_MSG_CT_GET_DYING,
    /// Get unconfirmed connections
    IPCTNL_MSG_CT_GET_UNCONFIRMED,
    /// Maximum message type value
    IPCTNL_MSG_MAX,
}

/// Netlink conntrack message types for expectation handling
#[repr(u32)]
pub enum ctnl_exp_msg_types {
    /// Create a new expectation
    IPCTNL_MSG_EXP_NEW,
    /// Get an expectation
    IPCTNL_MSG_EXP_GET,
    /// Delete an expectation
    IPCTNL_MSG_EXP_DELETE,
    /// Get CPU-specific statistics
    IPCTNL_MSG_EXP_GET_STATS_CPU,
    /// Maximum message type value
    IPCTNL_MSG_EXP_MAX,
}

/// Conntrack attribute types for netlink messages
#[repr(u32)]
pub enum ctattr_type {
    /// Unspecified attribute
    CTA_UNSPEC,
    /// Original tuple
    CTA_TUPLE_ORIG,
    /// Reply tuple
    CTA_TUPLE_REPLY,
    /// Connection status
    CTA_STATUS,
    /// Protocol specific information
    CTA_PROTOINFO,
    /// Helper name
    CTA_HELP,
    /// Source NAT information
    CTA_NAT_SRC,
    /// Connection timeout
    CTA_TIMEOUT,
    /// Connection mark
    CTA_MARK,
    /// Original direction counters
    CTA_COUNTERS_ORIG,
    /// Reply direction counters
    CTA_COUNTERS_REPLY,
    /// Connection usage counter
    CTA_USE,
    /// Connection ID
    CTA_ID,
    /// Destination NAT information
    CTA_NAT_DST,
    /// Master connection tuple
    CTA_TUPLE_MASTER,
    /// Original direction NAT sequence adjustment
    CTA_NAT_SEQ_ADJ_ORIG,
    /// Reply direction NAT sequence adjustment
    CTA_NAT_SEQ_ADJ_REPLY,
    /// Security mark (obsolete)
    CTA_SECMARK, /* obsolete */
    /// Connection zone
    CTA_ZONE,
    /// Security context
    CTA_SECCTX,
    /// Connection timestamp information
    CTA_TIMESTAMP,
    /// Connection mark mask
    CTA_MARK_MASK,
    /// Connection labels
    CTA_LABELS,
    /// Connection labels mask
    CTA_LABELS_MASK,
    /// Maximum attribute type value
    __CTA_MAX,
}

/// Backward compatibility alias for CTA_NAT_SRC
pub const CTA_NAT: u32 = ctattr_type::CTA_NAT_SRC as u32; /* backwards compatibility */
/// Maximum usable attribute type value
pub const CTA_MAX: u32 = ctattr_type::__CTA_MAX as u32 - 1;

/// Conntrack tuple attribute types
#[repr(u32)]
pub enum ctattr_tuple {
    /// Unspecified tuple attribute
    CTA_TUPLE_UNSPEC,
    /// IP address information
    CTA_TUPLE_IP,
    /// Protocol information
    CTA_TUPLE_PROTO,
    /// Maximum tuple attribute type value
    __CTA_TUPLE_MAX,
}

/// Maximum usable tuple attribute type value
pub const CTA_TUPLE_MAX: u32 = ctattr_tuple::__CTA_TUPLE_MAX as u32 - 1;

/// Conntrack IP address attribute types
#[repr(u32)]
pub enum ctattr_ip {
    /// Unspecified IP attribute
    CTA_IP_UNSPEC,
    /// IPv4 source address
    CTA_IP_V4_SRC,
    /// IPv4 destination address
    CTA_IP_V4_DST,
    /// IPv6 source address
    CTA_IP_V6_SRC,
    /// IPv6 destination address
    CTA_IP_V6_DST,
    /// Maximum IP attribute type value
    __CTA_IP_MAX,
}

/// Maximum usable IP attribute type value
pub const CTA_IP_MAX: u32 = ctattr_ip::__CTA_IP_MAX as u32 - 1;

/// Conntrack layer 4 protocol attribute types
#[repr(u32)]
pub enum ctattr_l4proto {
    /// Unspecified protocol attribute
    CTA_PROTO_UNSPEC,
    /// Protocol number
    CTA_PROTO_NUM,
    /// Source port
    CTA_PROTO_SRC_PORT,
    /// Destination port
    CTA_PROTO_DST_PORT,
    /// ICMP identifier
    CTA_PROTO_ICMP_ID,
    /// ICMP type
    CTA_PROTO_ICMP_TYPE,
    /// ICMP code
    CTA_PROTO_ICMP_CODE,
    /// ICMPv6 identifier
    CTA_PROTO_ICMPV6_ID,
    /// ICMPv6 type
    CTA_PROTO_ICMPV6_TYPE,
    /// ICMPv6 code
    CTA_PROTO_ICMPV6_CODE,
    /// Maximum protocol attribute type value
    __CTA_PROTO_MAX,
}

/// Maximum usable protocol attribute type value
pub const CTA_PROTO_MAX: u32 = ctattr_l4proto::__CTA_PROTO_MAX as u32 - 1;

/// Conntrack protocol-specific information attribute types
#[repr(u32)]
pub enum ctattr_protoinfo {
    /// Unspecified protocol information
    CTA_PROTOINFO_UNSPEC,
    /// TCP-specific information
    CTA_PROTOINFO_TCP,
    /// DCCP-specific information
    CTA_PROTOINFO_DCCP,
    /// SCTP-specific information
    CTA_PROTOINFO_SCTP,
    /// Maximum protocol information attribute type value
    __CTA_PROTOINFO_MAX,
}

/// Maximum usable protocol information attribute type value
pub const CTA_PROTOINFO_MAX: u32 = ctattr_protoinfo::__CTA_PROTOINFO_MAX as u32 - 1;

/// TCP-specific protocol information attribute types
#[repr(u32)]
pub enum ctattr_protoinfo_tcp {
    /// Unspecified TCP information
    CTA_PROTOINFO_TCP_UNSPEC,
    /// TCP connection state
    CTA_PROTOINFO_TCP_STATE,
    /// Original direction TCP window scale
    CTA_PROTOINFO_TCP_WSCALE_ORIGINAL,
    /// Reply direction TCP window scale
    CTA_PROTOINFO_TCP_WSCALE_REPLY,
    /// Original direction TCP flags
    CTA_PROTOINFO_TCP_FLAGS_ORIGINAL,
    /// Reply direction TCP flags
    CTA_PROTOINFO_TCP_FLAGS_REPLY,
    /// Maximum TCP information attribute type value
    __CTA_PROTOINFO_TCP_MAX,
}

/// Maximum usable TCP information attribute type value
pub const CTA_PROTOINFO_TCP_MAX: u32 = ctattr_protoinfo_tcp::__CTA_PROTOINFO_TCP_MAX as u32 - 1;

/// DCCP-specific protocol information attribute types
#[repr(u32)]
pub enum ctattr_protoinfo_dccp {
    /// Unspecified DCCP information
    CTA_PROTOINFO_DCCP_UNSPEC,
    /// DCCP connection state
    CTA_PROTOINFO_DCCP_STATE,
    /// DCCP role
    CTA_PROTOINFO_DCCP_ROLE,
    /// DCCP handshake sequence
    CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ,
    /// Maximum DCCP information attribute type value
    __CTA_PROTOINFO_DCCP_MAX,
}

/// Maximum usable DCCP information attribute type value
pub const CTA_PROTOINFO_DCCP_MAX: u32 = ctattr_protoinfo_dccp::__CTA_PROTOINFO_DCCP_MAX as u32 - 1;

/// SCTP-specific protocol information attribute types
#[repr(u32)]
pub enum ctattr_protoinfo_sctp {
    /// Unspecified SCTP information
    CTA_PROTOINFO_SCTP_UNSPEC,
    /// SCTP connection state
    CTA_PROTOINFO_SCTP_STATE,
    /// Original direction SCTP verification tag
    CTA_PROTOINFO_SCTP_VTAG_ORIGINAL,
    /// Reply direction SCTP verification tag
    CTA_PROTOINFO_SCTP_VTAG_REPLY,
    /// Maximum SCTP information attribute type value
    __CTA_PROTOINFO_SCTP_MAX,
}

/// Maximum usable SCTP information attribute type value
pub const CTA_PROTOINFO_SCTP_MAX: u32 = ctattr_protoinfo_sctp::__CTA_PROTOINFO_SCTP_MAX as u32 - 1;

/// Conntrack counters attribute types
#[repr(u32)]
pub enum ctattr_counters {
    /// Unspecified counters attribute
    CTA_COUNTERS_UNSPEC,
    /// 64-bit packet counters
    CTA_COUNTERS_PACKETS,
    /// 64-bit byte counters
    CTA_COUNTERS_BYTES,
    /// Old 32-bit packet counters (unused)
    CTA_COUNTERS32_PACKETS,
    /// Old 32-bit byte counters (unused)
    CTA_COUNTERS32_BYTES,
    /// Maximum counters attribute type value
    __CTA_COUNTERS_MAX,
}

/// Maximum usable counters attribute type value
pub const CTA_COUNTERS_MAX: u32 = ctattr_counters::__CTA_COUNTERS_MAX as u32 - 1;

/// Conntrack timestamp attribute types
#[repr(u32)]
pub enum ctattr_tstamp {
    /// Unspecified timestamp attribute
    CTA_TIMESTAMP_UNSPEC,
    /// Connection start timestamp
    CTA_TIMESTAMP_START,
    /// Connection stop timestamp
    CTA_TIMESTAMP_STOP,
    /// Maximum timestamp attribute type value
    __CTA_TIMESTAMP_MAX,
}

/// Maximum usable timestamp attribute type value
pub const CTA_TIMESTAMP_MAX: u32 = ctattr_tstamp::__CTA_TIMESTAMP_MAX as u32 - 1;

/// Conntrack NAT attribute types
#[repr(u32)]
pub enum ctattr_nat {
    /// Unspecified NAT attribute
    CTA_NAT_UNSPEC,
    /// Minimum IPv4 NAT address
    CTA_NAT_V4_MINIP,
    /// Maximum IPv4 NAT address
    CTA_NAT_V4_MAXIP,
    /// NAT protocol
    CTA_NAT_PROTO,
    /// Minimum IPv6 NAT address
    CTA_NAT_V6_MINIP,
    /// Maximum IPv6 NAT address
    CTA_NAT_V6_MAXIP,
    /// Maximum NAT attribute type value
    __CTA_NAT_MAX,
}

/// Minimum IPv4 NAT address
pub const CTA_NAT_MINIP: u32 = ctattr_nat::CTA_NAT_V4_MINIP as u32;
/// Maximum IPv4 NAT address
pub const CTA_NAT_MAXIP: u32 = ctattr_nat::CTA_NAT_V4_MAXIP as u32;
/// Maximum usable NAT attribute type value
pub const CTA_NAT_MAX: u32 = ctattr_nat::__CTA_NAT_MAX as u32 - 1;

/// Conntrack protocol NAT attribute types
#[repr(u32)]
pub enum ctattr_protonat {
    /// Unspecified protocol NAT attribute
    CTA_PROTONAT_UNSPEC,
    /// Minimum protocol NAT port
    CTA_PROTONAT_PORT_MIN,
    /// Maximum protocol NAT port
    CTA_PROTONAT_PORT_MAX,
    /// Maximum protocol NAT attribute type value
    __CTA_PROTONAT_MAX,
}

/// Maximum usable protocol NAT attribute type value
pub const CTA_PROTONAT_MAX: u32 = ctattr_protonat::__CTA_PROTONAT_MAX as u32 - 1;

/// Conntrack NAT sequence adjustment attribute types
#[repr(u32)]
pub enum ctattr_natseq {
    /// Unspecified NAT sequence adjustment attribute
    CTA_NAT_SEQ_UNSPEC,
    /// NAT sequence correction position
    CTA_NAT_SEQ_CORRECTION_POS,
    /// NAT sequence offset before correction
    CTA_NAT_SEQ_OFFSET_BEFORE,
    /// NAT sequence offset after correction
    CTA_NAT_SEQ_OFFSET_AFTER,
    /// Maximum NAT sequence adjustment attribute type value
    __CTA_NAT_SEQ_MAX,
}

/// Maximum usable NAT sequence adjustment attribute type value
pub const CTA_NAT_SEQ_MAX: u32 = ctattr_natseq::__CTA_NAT_SEQ_MAX as u32 - 1;

/// Conntrack expectation attribute types
#[repr(u32)]
pub enum ctattr_expect {
    /// Unspecified expectation attribute
    CTA_EXPECT_UNSPEC,
    /// Master connection information
    CTA_EXPECT_MASTER,
    /// Expected tuple
    CTA_EXPECT_TUPLE,
    /// Mask for the expected tuple
    CTA_EXPECT_MASK,
    /// Expectation timeout
    CTA_EXPECT_TIMEOUT,
    /// Expectation ID
    CTA_EXPECT_ID,
    /// Helper name
    CTA_EXPECT_HELP_NAME,
    /// Connection zone
    CTA_EXPECT_ZONE,
    /// Expectation flags
    CTA_EXPECT_FLAGS,
    /// Expectation class
    CTA_EXPECT_CLASS,
    /// NAT expectation
    CTA_EXPECT_NAT,
    /// Expectation function
    CTA_EXPECT_FN,
    /// Maximum expectation attribute type value
    __CTA_EXPECT_MAX,
}

/// Maximum usable expectation attribute type value
pub const CTA_EXPECT_MAX: u32 = ctattr_expect::__CTA_EXPECT_MAX as u32 - 1;

/// Conntrack NAT expectation attribute types
#[repr(u32)]
pub enum ctattr_expect_nat {
    /// Unspecified NAT expectation attribute
    CTA_EXPECT_NAT_UNSPEC,
    /// NAT expectation direction
    CTA_EXPECT_NAT_DIR,
    /// NAT expectation tuple
    CTA_EXPECT_NAT_TUPLE,
    /// Maximum NAT expectation attribute type value
    __CTA_EXPECT_NAT_MAX,
}

/// Maximum usable NAT expectation attribute type value
pub const CTA_EXPECT_NAT_MAX: u32 = ctattr_expect_nat::__CTA_EXPECT_NAT_MAX as u32 - 1;

/// Conntrack helper attribute types
#[repr(u32)]
pub enum ctattr_help {
    /// Unspecified helper attribute
    CTA_HELP_UNSPEC,
    /// Helper name
    CTA_HELP_NAME,
    /// Helper information
    CTA_HELP_INFO,
    /// Maximum helper attribute type value
    __CTA_HELP_MAX,
}

/// Maximum usable helper attribute type value
pub const CTA_HELP_MAX: u32 = ctattr_help::__CTA_HELP_MAX as u32 - 1;

/// Conntrack security context attribute types
#[repr(u32)]
pub enum ctattr_secctx {
    /// Unspecified security context attribute
    CTA_SECCTX_UNSPEC,
    /// Security context name
    CTA_SECCTX_NAME,
    /// Maximum security context attribute type value
    __CTA_SECCTX_MAX,
}

/// Maximum usable security context attribute type value
pub const CTA_SECCTX_MAX: u32 = ctattr_secctx::__CTA_SECCTX_MAX as u32 - 1;

/// Conntrack statistics attribute types
#[repr(u32)]
pub enum ctattr_stats_cpu {
    /// Unspecified statistics attribute
    CTA_STATS_UNSPEC,
    /// Number of searched connections
    CTA_STATS_SEARCHED,
    /// Number of found connections
    CTA_STATS_FOUND,
    /// Number of new connections
    CTA_STATS_NEW,
    /// Number of invalid connections
    CTA_STATS_INVALID,
    /// Number of ignored connections
    CTA_STATS_IGNORE,
    /// Number of deleted connections
    CTA_STATS_DELETE,
    /// Number of deleted connections in a list
    CTA_STATS_DELETE_LIST,
    /// Number of inserted connections
    CTA_STATS_INSERT,
    /// Number of failed insertions
    CTA_STATS_INSERT_FAILED,
    /// Number of dropped connections
    CTA_STATS_DROP,
    /// Number of early dropped connections
    CTA_STATS_EARLY_DROP,
    /// Number of errors
    CTA_STATS_ERROR,
    /// Number of search restarts
    CTA_STATS_SEARCH_RESTART,
    /// Maximum statistics attribute type value
    __CTA_STATS_MAX,
}

/// Maximum usable statistics attribute type value
pub const CTA_STATS_MAX: u32 = ctattr_stats_cpu::__CTA_STATS_MAX as u32 - 1;

/// Conntrack global statistics attribute types
#[repr(u32)]
pub enum ctattr_stats_global {
    /// Unspecified global statistics attribute
    CTA_STATS_GLOBAL_UNSPEC,
    /// Number of entries
    CTA_STATS_GLOBAL_ENTRIES,
    /// Maximum global statistics attribute type value
    __CTA_STATS_GLOBAL_MAX,
}

/// Maximum usable global statistics attribute type value
pub const CTA_STATS_GLOBAL_MAX: u32 = ctattr_stats_global::__CTA_STATS_GLOBAL_MAX as u32 - 1;

/// Conntrack expectation statistics attribute types
#[repr(u32)]
pub enum ctattr_expect_stats {
    /// Unspecified expectation statistics attribute
    CTA_STATS_EXP_UNSPEC,
    /// Number of new expectations
    CTA_STATS_EXP_NEW,
    /// Number of created expectations
    CTA_STATS_EXP_CREATE,
    /// Number of deleted expectations
    CTA_STATS_EXP_DELETE,
    /// Maximum expectation statistics attribute type value
    __CTA_STATS_EXP_MAX,
}

/// Maximum usable expectation statistics attribute type value
pub const CTA_STATS_EXP_MAX: u32 = ctattr_expect_stats::__CTA_STATS_EXP_MAX as u32 - 1;