Skip to content

Commit 179a025

Browse files
dianpopaacatangiu
authored andcommitted
net_gen: move away code that is not bindgen'd
Signed-off-by: Diana Popa <[email protected]>
1 parent 196c465 commit 179a025

File tree

5 files changed

+9
-40
lines changed

5 files changed

+9
-40
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

net_gen/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@
22
name = "net_gen"
33
version = "0.1.0"
44
authors = ["The Chromium OS Authors"]
5-
6-
[dependencies]
7-
sys_util = { path = "../sys_util" }

net_gen/src/lib.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
#![allow(non_camel_case_types)]
88
#![allow(non_snake_case)]
99

10-
#[macro_use]
11-
extern crate sys_util;
12-
1310
// generated with bindgen /usr/include/linux/if.h --no-unstable-rust
1411
// --constified-enum '*' --with-derive-default -- -D __UAPI_DEF_IF_IFNAMSIZ -D
1512
// __UAPI_DEF_IF_NET_DEVICE_FLAGS -D __UAPI_DEF_IF_IFREQ -D __UAPI_DEF_IF_IFMAP
@@ -32,30 +29,3 @@ pub use if_tun::*;
3229
pub use iff::*;
3330
pub use inn::*;
3431
pub use sockios::*;
35-
36-
pub const TUNTAP: ::std::os::raw::c_uint = 84;
37-
38-
ioctl_iow_nr!(TUNSETNOCSUM, TUNTAP, 200, ::std::os::raw::c_int);
39-
ioctl_iow_nr!(TUNSETDEBUG, TUNTAP, 201, ::std::os::raw::c_int);
40-
ioctl_iow_nr!(TUNSETIFF, TUNTAP, 202, ::std::os::raw::c_int);
41-
ioctl_iow_nr!(TUNSETPERSIST, TUNTAP, 203, ::std::os::raw::c_int);
42-
ioctl_iow_nr!(TUNSETOWNER, TUNTAP, 204, ::std::os::raw::c_int);
43-
ioctl_iow_nr!(TUNSETLINK, TUNTAP, 205, ::std::os::raw::c_int);
44-
ioctl_iow_nr!(TUNSETGROUP, TUNTAP, 206, ::std::os::raw::c_int);
45-
ioctl_ior_nr!(TUNGETFEATURES, TUNTAP, 207, ::std::os::raw::c_uint);
46-
ioctl_iow_nr!(TUNSETOFFLOAD, TUNTAP, 208, ::std::os::raw::c_uint);
47-
ioctl_iow_nr!(TUNSETTXFILTER, TUNTAP, 209, ::std::os::raw::c_uint);
48-
ioctl_ior_nr!(TUNGETIFF, TUNTAP, 210, ::std::os::raw::c_uint);
49-
ioctl_ior_nr!(TUNGETSNDBUF, TUNTAP, 211, ::std::os::raw::c_int);
50-
ioctl_iow_nr!(TUNSETSNDBUF, TUNTAP, 212, ::std::os::raw::c_int);
51-
ioctl_iow_nr!(TUNATTACHFILTER, TUNTAP, 213, sock_fprog);
52-
ioctl_iow_nr!(TUNDETACHFILTER, TUNTAP, 214, sock_fprog);
53-
ioctl_ior_nr!(TUNGETVNETHDRSZ, TUNTAP, 215, ::std::os::raw::c_int);
54-
ioctl_iow_nr!(TUNSETVNETHDRSZ, TUNTAP, 216, ::std::os::raw::c_int);
55-
ioctl_iow_nr!(TUNSETQUEUE, TUNTAP, 217, ::std::os::raw::c_int);
56-
ioctl_iow_nr!(TUNSETIFINDEX, TUNTAP, 218, ::std::os::raw::c_uint);
57-
ioctl_ior_nr!(TUNGETFILTER, TUNTAP, 219, sock_fprog);
58-
ioctl_iow_nr!(TUNSETVNETLE, TUNTAP, 220, ::std::os::raw::c_int);
59-
ioctl_ior_nr!(TUNGETVNETLE, TUNTAP, 221, ::std::os::raw::c_int);
60-
ioctl_iow_nr!(TUNSETVNETBE, TUNTAP, 222, ::std::os::raw::c_int);
61-
ioctl_ior_nr!(TUNGETVNETBE, TUNTAP, 223, ::std::os::raw::c_int);

net_util/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern crate libc;
1414
extern crate serde;
1515

1616
extern crate net_gen;
17+
#[macro_use]
1718
extern crate sys_util;
1819

1920
mod mac;

net_util/src/tap.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pub enum Error {
3131

3232
pub type Result<T> = ::std::result::Result<T, Error>;
3333

34+
const TUNTAP: ::std::os::raw::c_uint = 84;
35+
ioctl_iow_nr!(TUNSETIFF, TUNTAP, 202, ::std::os::raw::c_int);
36+
ioctl_iow_nr!(TUNSETOFFLOAD, TUNTAP, 208, ::std::os::raw::c_uint);
37+
ioctl_iow_nr!(TUNSETVNETHDRSZ, TUNTAP, 216, ::std::os::raw::c_int);
38+
3439
/// Handle for a network tap interface.
3540
///
3641
/// For now, this simply wraps the file descriptor for the tap device so methods
@@ -102,7 +107,7 @@ impl Tap {
102107

103108
// ioctl is safe since we call it with a valid tap fd and check the return
104109
// value.
105-
let ret = unsafe { ioctl_with_mut_ref(&tuntap, net_gen::TUNSETIFF(), &mut ifreq) };
110+
let ret = unsafe { ioctl_with_mut_ref(&tuntap, TUNSETIFF(), &mut ifreq) };
106111

107112
if ret < 0 {
108113
return Err(Error::CreateTap(IoError::last_os_error()));
@@ -172,8 +177,7 @@ impl Tap {
172177
pub fn set_offload(&self, flags: c_uint) -> Result<()> {
173178
// ioctl is safe. Called with a valid tap fd, and we check the return.
174179
#[allow(clippy::cast_lossless)]
175-
let ret =
176-
unsafe { ioctl_with_val(&self.tap_file, net_gen::TUNSETOFFLOAD(), flags as c_ulong) };
180+
let ret = unsafe { ioctl_with_val(&self.tap_file, TUNSETOFFLOAD(), flags as c_ulong) };
177181
if ret < 0 {
178182
return Err(Error::IoctlError(IoError::last_os_error()));
179183
}
@@ -208,7 +212,7 @@ impl Tap {
208212
/// Set the size of the vnet hdr.
209213
pub fn set_vnet_hdr_size(&self, size: c_int) -> Result<()> {
210214
// ioctl is safe. Called with a valid tap fd, and we check the return.
211-
let ret = unsafe { ioctl_with_ref(&self.tap_file, net_gen::TUNSETVNETHDRSZ(), &size) };
215+
let ret = unsafe { ioctl_with_ref(&self.tap_file, TUNSETVNETHDRSZ(), &size) };
212216
if ret < 0 {
213217
return Err(Error::IoctlError(IoError::last_os_error()));
214218
}

0 commit comments

Comments
 (0)