Skip to content

Commit

Permalink
Merge pull request #43 from HeroicKatora/ci
Browse files Browse the repository at this point in the history
Fix Ioctl type
  • Loading branch information
HeroicKatora authored Apr 12, 2024
2 parents 90758c6 + 36e4e16 commit de75c14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
8 changes: 7 additions & 1 deletion ethox-no-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ pub extern fn main(_nargs: i32, _args: *const *const u8) -> i32 {
let hostmac = ethernet::Address([0xab,0xff,0xff,0xff,0xff,0xff]);

let mut eth = eth::Endpoint::new(hostmac);
let mut arp_requests = [None; 16];

let mut neighbors = [arp::Neighbor::default(); 10];
let mut ip = ip::Endpoint::new(Slice::One(host.into()),
// No routes at all
ip::Routes::new(Slice::empty()),
// But do automatic arp
arp::NeighborCache::new(&mut neighbors[..]));
{
let neighbors = arp::NeighborCache::new(&mut neighbors[..]);
let buffer = arp::RequestBuffer::new((&mut arp_requests[..]).into());

arp::Endpoint::new(neighbors).with_request_buffer(buffer)
});

let mut icmp = icmp::Endpoint::new();

Expand Down
4 changes: 2 additions & 2 deletions ethox/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ macro_rules! enum_with_unknown {
enum_with_unknown! {
$( #[$enum_attr] )*
pub doc enum $name($ty) {
$($(#[$val_attr])* #[doc(shown)] $variant = $value ),+
$($(#[$val_attr])* $variant = $value ),+
}
}
};
(
$( #[$enum_attr:meta] )*
pub doc enum $name:ident($ty:ty) {
$(
$( #[$variant_attr:meta] )+
$( #[$variant_attr:meta] )*
$variant:ident = $value:expr $(,)*
),+
}
Expand Down
13 changes: 10 additions & 3 deletions ethox/src/nic/sys/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ pub(crate) trait IfIndex {
fn get_if_index(&mut self, fd: libc::c_int) -> Result<libc::c_int, Errno>;
}

// This is freaking stupid: <https://github.com/rust-lang/libc/issues/1036#issuecomment-850765498>
// At some point, the hidden public type def was dropped. Probably out of similar concerns. We only
// support linux-gnu for now. The right type according to the kernel is `c_uint`. BSD does ulong.
// Really we should just be implementing our own syscall wrapper here since the situation of using
// `libc` is so tiring.
type Ioctl = libc::c_ulong;

impl ifreq {
pub(crate) const SIOCGIFMTU: libc::Ioctl = 0x8921;
pub(crate) const SIOCGIFINDEX: libc::Ioctl = 0x8933;
pub(crate) const SIOCGIFMTU: Ioctl = 0x8921;
pub(crate) const SIOCGIFINDEX: Ioctl = 0x8933;

pub(crate) const TUNSETIFF: libc::Ioctl = 0x400454CA;
pub(crate) const TUNSETIFF: Ioctl = 0x400454CA;
pub(crate) const IFF_TAP: libc::c_int = 0x0002;
pub(crate) const IFF_NO_PI: libc::c_int = 0x1000;
}
Expand Down

0 comments on commit de75c14

Please sign in to comment.