jtomschroeder / ether

Library for parsing and manipulating network data, packet captures.
MIT License
6 stars 1 forks source link

expected u8, found i8 #4

Closed kpcyrd closed 7 years ago

kpcyrd commented 7 years ago

I'm having trouble compiling this:

   Compiling ether v0.1.4
error[E0308]: mismatched types
   --> /some/path/.cargo/registry/src/github.com-1ecc6299db9ec823/ether-0.1.4/src/tap/tap.rs:106:37
    |
106 |                 iface.ifr_name[i] = c as i8;
    |                                     ^^^^^^^ expected u8, found i8

error: aborting due to previous error(s)

error: Could not compile `ether`.

This is rust 1.19, could you have a look into this?

kpcyrd commented 7 years ago

I've compiled the lib on another system which is x86_64 without any problems, so I assume this is system specific. The error happened on a raspberry pi 1 with archlinux arm.

jtomschroeder commented 7 years ago

Interesting. Can you try std::os::raw::c_char instead of i8? My first guess is an OS-specific difference in char.

kpcyrd commented 7 years ago

Interesting, this compiles on both my x86_64 and armv6l system:

diff --git a/src/tap/tap.rs b/src/tap/tap.rs
index 05f9ff3..cf95add 100644
--- a/src/tap/tap.rs
+++ b/src/tap/tap.rs
@@ -103,7 +103,7 @@ impl Tap {

             let mut iface: bpf::ifreq = unsafe { mem::zeroed() };
             for (i, c) in interface.bytes().enumerate() {
-                iface.ifr_name[i] = c as i8;
+                iface.ifr_name[i] = c as std::os::raw::c_char;
             }

             // Set the buffer length

I'm going to use the patched library for now, an update would be appreciated so I can drop my local version later :) Thanks!