xref: /cloud-hypervisor/net_gen/src/lib.rs (revision f6cd3bd86ded632da437b6dd6077f4237d2f71fe)
1 // Copyright TUNTAP, 2017 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the THIRD-PARTY file.
4 //
5 // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
6 
7 #![allow(non_upper_case_globals)]
8 #![allow(non_camel_case_types)]
9 #![allow(non_snake_case)]
10 
11 #[macro_use]
12 extern crate vmm_sys_util;
13 
14 // generated with bindgen /usr/include/linux/if.h --no-unstable-rust
15 // --constified-enum '*' --with-derive-default -- -D __UAPI_DEF_IF_IFNAMSIZ -D
16 // __UAPI_DEF_IF_NET_DEVICE_FLAGS -D __UAPI_DEF_IF_IFREQ -D __UAPI_DEF_IF_IFMAP
17 // Name is "iff" to avoid conflicting with "if" keyword.
18 // Generated against Linux 4.11 to include fix "uapi: fix linux/if.h userspace
19 // compilation errors".
20 // Manual fixup of ifrn_name to be of type c_uchar instead of c_char.
21 pub mod iff;
22 // generated with bindgen /usr/include/linux/if_tun.h --no-unstable-rust
23 // --constified-enum '*' --with-derive-default
24 pub mod if_tun;
25 // generated with bindgen /usr/include/linux/in.h --no-unstable-rust
26 // --constified-enum '*' --with-derive-default
27 // Name is "inn" to avoid conflicting with "in" keyword.
28 pub mod inn;
29 // generated with bindgen /usr/include/linux/sockios.h --no-unstable-rust
30 // --constified-enum '*' --with-derive-default
31 pub mod sockios;
32 pub use if_tun::{
33     sock_fprog, IFF_MULTI_QUEUE, IFF_NO_PI, IFF_TAP, IFF_VNET_HDR, TUN_F_CSUM, TUN_F_TSO4,
34     TUN_F_TSO6, TUN_F_TSO_ECN, TUN_F_UFO,
35 };
36 pub use iff::{ifreq, net_device_flags_IFF_UP, setsockopt, sockaddr, AF_INET};
37 pub use inn::sockaddr_in;
38 
39 pub const TUNTAP: ::std::os::raw::c_uint = 84;
40 
41 ioctl_iow_nr!(TUNSETNOCSUM, TUNTAP, 200, ::std::os::raw::c_int);
42 ioctl_iow_nr!(TUNSETDEBUG, TUNTAP, 201, ::std::os::raw::c_int);
43 ioctl_iow_nr!(TUNSETIFF, TUNTAP, 202, ::std::os::raw::c_int);
44 ioctl_iow_nr!(TUNSETPERSIST, TUNTAP, 203, ::std::os::raw::c_int);
45 ioctl_iow_nr!(TUNSETOWNER, TUNTAP, 204, ::std::os::raw::c_int);
46 ioctl_iow_nr!(TUNSETLINK, TUNTAP, 205, ::std::os::raw::c_int);
47 ioctl_iow_nr!(TUNSETGROUP, TUNTAP, 206, ::std::os::raw::c_int);
48 ioctl_ior_nr!(TUNGETFEATURES, TUNTAP, 207, ::std::os::raw::c_uint);
49 ioctl_iow_nr!(TUNSETOFFLOAD, TUNTAP, 208, ::std::os::raw::c_uint);
50 ioctl_iow_nr!(TUNSETTXFILTER, TUNTAP, 209, ::std::os::raw::c_uint);
51 ioctl_ior_nr!(TUNGETIFF, TUNTAP, 210, ::std::os::raw::c_uint);
52 ioctl_ior_nr!(TUNGETSNDBUF, TUNTAP, 211, ::std::os::raw::c_int);
53 ioctl_iow_nr!(TUNSETSNDBUF, TUNTAP, 212, ::std::os::raw::c_int);
54 ioctl_iow_nr!(TUNATTACHFILTER, TUNTAP, 213, sock_fprog);
55 ioctl_iow_nr!(TUNDETACHFILTER, TUNTAP, 214, sock_fprog);
56 ioctl_ior_nr!(TUNGETVNETHDRSZ, TUNTAP, 215, ::std::os::raw::c_int);
57 ioctl_iow_nr!(TUNSETVNETHDRSZ, TUNTAP, 216, ::std::os::raw::c_int);
58 ioctl_iow_nr!(TUNSETQUEUE, TUNTAP, 217, ::std::os::raw::c_int);
59 ioctl_iow_nr!(TUNSETIFINDEX, TUNTAP, 218, ::std::os::raw::c_uint);
60 ioctl_ior_nr!(TUNGETFILTER, TUNTAP, 219, sock_fprog);
61 ioctl_iow_nr!(TUNSETVNETLE, TUNTAP, 220, ::std::os::raw::c_int);
62 ioctl_ior_nr!(TUNGETVNETLE, TUNTAP, 221, ::std::os::raw::c_int);
63 ioctl_iow_nr!(TUNSETVNETBE, TUNTAP, 222, ::std::os::raw::c_int);
64 ioctl_ior_nr!(TUNGETVNETBE, TUNTAP, 223, ::std::os::raw::c_int);
65