nfnetlink_sys/
bindings.rs

1/* automatically generated by rust-bindgen */
2
3pub const NLM_F_REQUEST: u32 = 1;
4pub const NLM_F_MULTI: u32 = 2;
5pub const NLM_F_ACK: u32 = 4;
6pub const NLM_F_ECHO: u32 = 8;
7pub const NLM_F_DUMP_INTR: u32 = 16;
8pub const NLM_F_DUMP_FILTERED: u32 = 32;
9pub const NLM_F_ROOT: u32 = 256;
10pub const NLM_F_MATCH: u32 = 512;
11pub const NLM_F_ATOMIC: u32 = 1024;
12pub const NLM_F_DUMP: u32 = 768;
13pub const NLM_F_REPLACE: u32 = 256;
14pub const NLM_F_EXCL: u32 = 512;
15pub const NLM_F_CREATE: u32 = 1024;
16pub const NLM_F_APPEND: u32 = 2048;
17pub const NLMSG_ALIGNTO: u32 = 4;
18pub const NL_MMAP_MSG_ALIGNMENT: u32 = 4;
19pub const NLA_F_NESTED: u32 = 32768;
20pub const NLA_F_NET_BYTEORDER: u32 = 16384;
21pub const NLA_TYPE_MASK: i32 = -49153;
22pub const NLA_ALIGNTO: u32 = 4;
23pub const NF_NETLINK_CONNTRACK_NEW: u32 = 1;
24pub const NF_NETLINK_CONNTRACK_UPDATE: u32 = 2;
25pub const NF_NETLINK_CONNTRACK_DESTROY: u32 = 4;
26pub const NF_NETLINK_CONNTRACK_EXP_NEW: u32 = 8;
27pub const NF_NETLINK_CONNTRACK_EXP_UPDATE: u32 = 16;
28pub const NF_NETLINK_CONNTRACK_EXP_DESTROY: u32 = 32;
29pub const NFNL_NFA_NEST: u32 = 32768;
30pub const NFA_ALIGNTO: u32 = 4;
31pub const NFNETLINK_V0: u32 = 0;
32pub const NFNL_SUBSYS_NONE: u32 = 0;
33pub const NFNL_SUBSYS_CTNETLINK: u32 = 1;
34pub const NFNL_SUBSYS_CTNETLINK_EXP: u32 = 2;
35pub const NFNL_SUBSYS_QUEUE: u32 = 3;
36pub const NFNL_SUBSYS_ULOG: u32 = 4;
37pub const NFNL_SUBSYS_COUNT: u32 = 5;
38pub const NETLINK_BROADCAST_SEND_ERROR: u32 = 4;
39pub const NFNL_BUFFSIZE: u32 = 8192;
40
41pub const NETLINK_UNCONNECTED: u32 = 0;
42pub const NETLINK_CONNECTED: u32 = 1;
43
44#[repr(C)]
45#[derive(Debug, Copy, Clone)]
46pub struct nfattr {
47    pub nfa_len: u16,
48    pub nfa_type: u16,
49}
50
51#[test]
52fn bindgen_test_layout_nfattr() {
53    assert_eq!(
54        ::std::mem::size_of::<nfattr>(),
55        4usize,
56        concat!("Size of: ", stringify!(nfattr))
57    );
58    assert_eq!(
59        ::std::mem::align_of::<nfattr>(),
60        2usize,
61        concat!("Alignment of ", stringify!(nfattr))
62    );
63    assert_eq!(
64        unsafe { &(*(::std::ptr::null::<nfattr>())).nfa_len as *const _ as usize },
65        0usize,
66        concat!(
67            "Offset of field: ",
68            stringify!(nfattr),
69            "::",
70            stringify!(nfa_len)
71        )
72    );
73    assert_eq!(
74        unsafe { &(*(::std::ptr::null::<nfattr>())).nfa_type as *const _ as usize },
75        2usize,
76        concat!(
77            "Offset of field: ",
78            stringify!(nfattr),
79            "::",
80            stringify!(nfa_type)
81        )
82    );
83}
84pub const nfnetlink_groups_NFNLGRP_NONE: nfnetlink_groups = 0;
85pub const nfnetlink_groups_NFNLGRP_CONNTRACK_NEW: nfnetlink_groups = 1;
86pub const nfnetlink_groups_NFNLGRP_CONNTRACK_UPDATE: nfnetlink_groups = 2;
87pub const nfnetlink_groups_NFNLGRP_CONNTRACK_DESTROY: nfnetlink_groups = 3;
88pub const nfnetlink_groups_NFNLGRP_CONNTRACK_EXP_NEW: nfnetlink_groups = 4;
89pub const nfnetlink_groups_NFNLGRP_CONNTRACK_EXP_UPDATE: nfnetlink_groups = 5;
90pub const nfnetlink_groups_NFNLGRP_CONNTRACK_EXP_DESTROY: nfnetlink_groups = 6;
91pub const nfnetlink_groups___NFNLGRP_MAX: nfnetlink_groups = 7;
92pub type nfnetlink_groups = u32;
93
94#[repr(C)]
95#[derive(Debug, Copy, Clone)]
96pub struct nfgenmsg {
97    /// AF_xxx
98    pub nfgen_family: u8,
99    /// nfnetlink version
100    pub version: u8,
101    /// resource ID (Big endian)
102    pub res_id: u16,
103}
104#[test]
105fn bindgen_test_layout_nfgenmsg() {
106    assert_eq!(
107        ::std::mem::size_of::<nfgenmsg>(),
108        4usize,
109        concat!("Size of: ", stringify!(nfgenmsg))
110    );
111    assert_eq!(
112        ::std::mem::align_of::<nfgenmsg>(),
113        2usize,
114        concat!("Alignment of ", stringify!(nfgenmsg))
115    );
116    assert_eq!(
117        unsafe { &(*(::std::ptr::null::<nfgenmsg>())).nfgen_family as *const _ as usize },
118        0usize,
119        concat!(
120            "Offset of field: ",
121            stringify!(nfgenmsg),
122            "::",
123            stringify!(nfgen_family)
124        )
125    );
126    assert_eq!(
127        unsafe { &(*(::std::ptr::null::<nfgenmsg>())).version as *const _ as usize },
128        1usize,
129        concat!(
130            "Offset of field: ",
131            stringify!(nfgenmsg),
132            "::",
133            stringify!(version)
134        )
135    );
136    assert_eq!(
137        unsafe { &(*(::std::ptr::null::<nfgenmsg>())).res_id as *const _ as usize },
138        2usize,
139        concat!(
140            "Offset of field: ",
141            stringify!(nfgenmsg),
142            "::",
143            stringify!(res_id)
144        )
145    );
146}
147#[repr(C)]
148#[derive(Copy, Clone)]
149pub struct nfnlhdr {
150    pub nlh: nlmsghdr,
151    pub nfmsg: nfgenmsg,
152}
153#[test]
154fn bindgen_test_layout_nfnlhdr() {
155    assert_eq!(
156        ::std::mem::size_of::<nfnlhdr>(),
157        20usize,
158        concat!("Size of: ", stringify!(nfnlhdr))
159    );
160    assert_eq!(
161        ::std::mem::align_of::<nfnlhdr>(),
162        4usize,
163        concat!("Alignment of ", stringify!(nfnlhdr))
164    );
165    assert_eq!(
166        unsafe { &(*(::std::ptr::null::<nfnlhdr>())).nlh as *const _ as usize },
167        0usize,
168        concat!(
169            "Offset of field: ",
170            stringify!(nfnlhdr),
171            "::",
172            stringify!(nlh)
173        )
174    );
175    assert_eq!(
176        unsafe { &(*(::std::ptr::null::<nfnlhdr>())).nfmsg as *const _ as usize },
177        16usize,
178        concat!(
179            "Offset of field: ",
180            stringify!(nfnlhdr),
181            "::",
182            stringify!(nfmsg)
183        )
184    );
185}
186
187#[repr(C)]
188#[derive(Debug, Copy, Clone)]
189pub struct nfnl_callback {
190    pub call: ::std::option::Option<
191        unsafe extern "C" fn(
192            nlh: *mut nlmsghdr,
193            nfa: *mut *mut nfattr,
194            data: *mut ::std::os::raw::c_void,
195        ) -> ::std::os::raw::c_int,
196    >,
197    pub data: *mut ::std::os::raw::c_void,
198    pub attr_count: u16,
199}
200#[test]
201fn bindgen_test_layout_nfnl_callback() {
202    assert_eq!(
203        ::std::mem::size_of::<nfnl_callback>(),
204        24usize,
205        concat!("Size of: ", stringify!(nfnl_callback))
206    );
207    assert_eq!(
208        ::std::mem::align_of::<nfnl_callback>(),
209        8usize,
210        concat!("Alignment of ", stringify!(nfnl_callback))
211    );
212    assert_eq!(
213        unsafe { &(*(::std::ptr::null::<nfnl_callback>())).call as *const _ as usize },
214        0usize,
215        concat!(
216            "Offset of field: ",
217            stringify!(nfnl_callback),
218            "::",
219            stringify!(call)
220        )
221    );
222    assert_eq!(
223        unsafe { &(*(::std::ptr::null::<nfnl_callback>())).data as *const _ as usize },
224        8usize,
225        concat!(
226            "Offset of field: ",
227            stringify!(nfnl_callback),
228            "::",
229            stringify!(data)
230        )
231    );
232    assert_eq!(
233        unsafe { &(*(::std::ptr::null::<nfnl_callback>())).attr_count as *const _ as usize },
234        16usize,
235        concat!(
236            "Offset of field: ",
237            stringify!(nfnl_callback),
238            "::",
239            stringify!(attr_count)
240        )
241    );
242}
243#[repr(C)]
244#[derive(Debug, Copy, Clone)]
245pub struct nfnl_handle {
246    _unused: [u8; 0],
247}
248
249#[repr(C)]
250#[derive(Debug, Copy, Clone)]
251pub struct nfnl_subsys_handle {
252    _unused: [u8; 0],
253}
254
255extern "C" {
256    pub fn nfnl_fd(h: *mut nfnl_handle) -> ::std::os::raw::c_int;
257    pub fn nfnl_portid(h: *const nfnl_handle) -> ::std::os::raw::c_uint;
258    pub fn nfnl_open() -> *mut nfnl_handle;
259    pub fn nfnl_close(arg1: *mut nfnl_handle) -> ::std::os::raw::c_int;
260    pub fn nfnl_subsys_open(
261        arg1: *mut nfnl_handle,
262        arg2: u8,
263        arg3: u8,
264        arg4: ::std::os::raw::c_uint,
265    ) -> *mut nfnl_subsys_handle;
266    pub fn nfnl_subsys_close(arg1: *mut nfnl_subsys_handle);
267    pub fn nfnl_set_sequence_tracking(h: *mut nfnl_handle);
268    pub fn nfnl_unset_sequence_tracking(h: *mut nfnl_handle);
269    pub fn nfnl_set_rcv_buffer_size(h: *mut nfnl_handle, size: ::std::os::raw::c_uint);
270    pub fn nfnl_send(arg1: *mut nfnl_handle, arg2: *mut nlmsghdr) -> ::std::os::raw::c_int;
271    pub fn nfnl_sendmsg(
272        arg1: *const nfnl_handle,
273        msg: *const msghdr,
274        flags: ::std::os::raw::c_uint,
275    ) -> ::std::os::raw::c_int;
276    pub fn nfnl_sendiov(
277        nfnlh: *const nfnl_handle,
278        iov: *const iovec,
279        num: ::std::os::raw::c_uint,
280        flags: ::std::os::raw::c_uint,
281    ) -> ::std::os::raw::c_int;
282    pub fn nfnl_fill_hdr(
283        arg1: *mut nfnl_subsys_handle,
284        arg2: *mut nlmsghdr,
285        arg3: ::std::os::raw::c_uint,
286        arg4: u8,
287        arg5: u16,
288        arg6: u16,
289        arg7: u16,
290    );
291    pub fn nfnl_talk(
292        arg1: *mut nfnl_handle,
293        arg2: *mut nlmsghdr,
294        arg3: pid_t,
295        arg4: ::std::os::raw::c_uint,
296        arg5: *mut nlmsghdr,
297        arg6: ::std::option::Option<
298            unsafe extern "C" fn(
299                arg1: *mut sockaddr_nl,
300                arg2: *mut nlmsghdr,
301                arg3: *mut ::std::os::raw::c_void,
302            ) -> ::std::os::raw::c_int,
303        >,
304        arg7: *mut ::std::os::raw::c_void,
305    ) -> ::std::os::raw::c_int;
306    pub fn nfnl_listen(
307        arg1: *mut nfnl_handle,
308        arg2: ::std::option::Option<
309            unsafe extern "C" fn(
310                arg1: *mut sockaddr_nl,
311                arg2: *mut nlmsghdr,
312                arg3: *mut ::std::os::raw::c_void,
313            ) -> ::std::os::raw::c_int,
314        >,
315        arg3: *mut ::std::os::raw::c_void,
316    ) -> ::std::os::raw::c_int;
317    pub fn nfnl_recv(h: *const nfnl_handle, buf: *mut ::std::os::raw::c_uchar, len: usize)
318        -> isize;
319    pub fn nfnl_callback_register(
320        arg1: *mut nfnl_subsys_handle,
321        type_: u8,
322        cb: *mut nfnl_callback,
323    ) -> ::std::os::raw::c_int;
324    pub fn nfnl_callback_unregister(
325        arg1: *mut nfnl_subsys_handle,
326        type_: u8,
327    ) -> ::std::os::raw::c_int;
328    pub fn nfnl_handle_packet(
329        arg1: *mut nfnl_handle,
330        buf: *mut ::std::os::raw::c_char,
331        len: ::std::os::raw::c_int,
332    ) -> ::std::os::raw::c_int;
333    pub fn nfnl_parse_hdr(
334        nfnlh: *const nfnl_handle,
335        nlh: *const nlmsghdr,
336        genmsg: *mut *mut nfgenmsg,
337    ) -> *mut nfattr;
338    pub fn nfnl_check_attributes(
339        nfnlh: *const nfnl_handle,
340        nlh: *const nlmsghdr,
341        tb: *mut *mut nfattr,
342    ) -> ::std::os::raw::c_int;
343    pub fn nfnl_get_msg_first(
344        h: *mut nfnl_handle,
345        buf: *const ::std::os::raw::c_uchar,
346        len: usize,
347    ) -> *mut nlmsghdr;
348    pub fn nfnl_get_msg_next(
349        h: *mut nfnl_handle,
350        buf: *const ::std::os::raw::c_uchar,
351        len: usize,
352    ) -> *mut nlmsghdr;
353}
354
355/// Callback verdict
356pub const NFNL_CB_FAILURE: i32 = -1;
357/// Callback verdict
358pub const NFNL_CB_STOP: i32 = 0;
359/// Callback verdict
360pub const NFNL_CB_CONTINUE: i32 = 1;
361
362extern "C" {
363    pub fn nfnl_join(
364        nfnlh: *const nfnl_handle,
365        group: ::std::os::raw::c_uint,
366    ) -> ::std::os::raw::c_int;
367    pub fn nfnl_process(
368        h: *mut nfnl_handle,
369        buf: *const ::std::os::raw::c_uchar,
370        len: usize,
371    ) -> ::std::os::raw::c_int;
372}
373#[repr(C)]
374#[derive(Debug, Copy, Clone)]
375pub struct nfnl_iterator {
376    _unused: [u8; 0],
377}
378
379extern "C" {
380    pub fn nfnl_iterator_create(
381        h: *const nfnl_handle,
382        buf: *const ::std::os::raw::c_char,
383        len: usize,
384    ) -> *mut nfnl_iterator;
385    pub fn nfnl_iterator_destroy(it: *mut nfnl_iterator);
386    pub fn nfnl_iterator_process(
387        h: *mut nfnl_handle,
388        it: *mut nfnl_iterator,
389    ) -> ::std::os::raw::c_int;
390    pub fn nfnl_iterator_next(
391        h: *const nfnl_handle,
392        it: *mut nfnl_iterator,
393    ) -> ::std::os::raw::c_int;
394    pub fn nfnl_catch(h: *mut nfnl_handle) -> ::std::os::raw::c_int;
395    pub fn nfnl_query(h: *mut nfnl_handle, nlh: *mut nlmsghdr) -> ::std::os::raw::c_int;
396    pub fn nfnl_addattr_l(
397        arg1: *mut nlmsghdr,
398        arg2: ::std::os::raw::c_int,
399        arg3: ::std::os::raw::c_int,
400        arg4: *const ::std::os::raw::c_void,
401        arg5: ::std::os::raw::c_int,
402    ) -> ::std::os::raw::c_int;
403    pub fn nfnl_addattr8(
404        arg1: *mut nlmsghdr,
405        arg2: ::std::os::raw::c_int,
406        arg3: ::std::os::raw::c_int,
407        arg4: u8,
408    ) -> ::std::os::raw::c_int;
409    pub fn nfnl_addattr16(
410        arg1: *mut nlmsghdr,
411        arg2: ::std::os::raw::c_int,
412        arg3: ::std::os::raw::c_int,
413        arg4: u16,
414    ) -> ::std::os::raw::c_int;
415    pub fn nfnl_addattr32(
416        arg1: *mut nlmsghdr,
417        arg2: ::std::os::raw::c_int,
418        arg3: ::std::os::raw::c_int,
419        arg4: u32,
420    ) -> ::std::os::raw::c_int;
421    pub fn nfnl_nfa_addattr_l(
422        arg1: *mut nfattr,
423        arg2: ::std::os::raw::c_int,
424        arg3: ::std::os::raw::c_int,
425        arg4: *const ::std::os::raw::c_void,
426        arg5: ::std::os::raw::c_int,
427    ) -> ::std::os::raw::c_int;
428    pub fn nfnl_nfa_addattr16(
429        arg1: *mut nfattr,
430        arg2: ::std::os::raw::c_int,
431        arg3: ::std::os::raw::c_int,
432        arg4: u16,
433    ) -> ::std::os::raw::c_int;
434    pub fn nfnl_nfa_addattr32(
435        arg1: *mut nfattr,
436        arg2: ::std::os::raw::c_int,
437        arg3: ::std::os::raw::c_int,
438        arg4: u32,
439    ) -> ::std::os::raw::c_int;
440    pub fn nfnl_parse_attr(
441        arg1: *mut *mut nfattr,
442        arg2: ::std::os::raw::c_int,
443        arg3: *mut nfattr,
444        arg4: ::std::os::raw::c_int,
445    ) -> ::std::os::raw::c_int;
446    pub fn nfnl_build_nfa_iovec(
447        iov: *mut iovec,
448        nfa: *mut nfattr,
449        type_: u16,
450        len: u32,
451        val: *mut ::std::os::raw::c_uchar,
452    );
453    pub fn nfnl_rcvbufsiz(
454        h: *const nfnl_handle,
455        size: ::std::os::raw::c_uint,
456    ) -> ::std::os::raw::c_uint;
457    pub fn nfnl_dump_packet(
458        arg1: *mut nlmsghdr,
459        arg2: ::std::os::raw::c_int,
460        arg3: *mut ::std::os::raw::c_char,
461    );
462}
463
464#[repr(C)]
465#[derive(Debug, Copy, Clone)]
466pub struct nlif_handle {
467    _unused: [u8; 0],
468}
469
470extern "C" {
471    pub fn nlif_open() -> *mut nlif_handle;
472    pub fn nlif_close(orig: *mut nlif_handle);
473    pub fn nlif_fd(nlif_handle: *mut nlif_handle) -> ::std::os::raw::c_int;
474    pub fn nlif_query(nlif_handle: *mut nlif_handle) -> ::std::os::raw::c_int;
475    pub fn nlif_catch(nlif_handle: *mut nlif_handle) -> ::std::os::raw::c_int;
476    pub fn nlif_index2name(
477        nlif_handle: *mut nlif_handle,
478        if_index: ::std::os::raw::c_uint,
479        name: *mut ::std::os::raw::c_char,
480    ) -> ::std::os::raw::c_int;
481    pub fn nlif_get_ifflags(
482        h: *const nlif_handle,
483        index: ::std::os::raw::c_uint,
484        flags: *mut ::std::os::raw::c_uint,
485    ) -> ::std::os::raw::c_int;
486}