libpnet / netmap_sys Goto Github PK
View Code? Open in Web Editor NEWRust bindings to netmap.
Rust bindings to netmap.
The original NIOCGREGIF
is defined in netmap_legacy.h
as the following:
/*
* FreeBSD uses the size value embedded in the _IOWR to determine
* how much to copy in/out. So we need it to match the actual
* data structure we pass. We put some spares in the structure
* to ease compatibility with other versions
*/
#define NIOCGINFO _IOWR('i', 145, struct nmreq) /* return IF info */
#define NIOCREGIF _IOWR('i', 146, struct nmreq) /* interface register */
#define NIOCCONFIG _IOWR('i',150, struct nm_ifreq) /* for ext. modules */
The Rust's NIOCREGIF
is defined here:
#[cfg(target_os = "linux")]
pub const NIOCREGIF: c_ulong = 3225184658;
#[cfg(target_os = "freebsd")]
pub const NIOCREGIF: c_ulong = 3225184658;
They are different on Linux and libc::ioctl(fd, NIOCREGIF, &mut nmr as *mut nmreq)
results in Operation bot supported
. Valid NIOCREGIF
for Linux is 3225446802, isn't it?
in this commit luigirizzo/netmap@142ebbf
the nm_desc
struct changed. such that nm_desc.memsize
is now a uint64
consequently, anyone using a netmap_user.h
after that will get some funky errors when using this library.
There are useful things like 9d719c9 in master but not released.
It would be great if you published current version on crates.io as it would make compiling libpnet with netmap feature enabled possible on more systems (like mine).
I'm packaging netmap_sys for Fedora. I found that the LICENSE was not included in the crate. It would be good to have the LICENSE in the crate, so that it would be distributed along with the RPM package.
OK, next issue. I may be too much of a rust newbie here; feel free to tell me.
My main.rs
is simply:
extern crate "rust-netmap" as netmap;
fn main() {
println!("Hello, world!");
let n = netmap::nm_open("eth1", 0, 0, 0);
}
cargo build
fails with
[lars@tux: ~/rustcore] cargo build -v
Fresh rust-netmap v0.0.4 (https://github.com/libpnet/rust-netmap.git#ab947ee2)
Compiling rustcore v0.0.1 (file:///mnt/home/vmhome/rustcore)
Running `rustc src/main.rs --crate-name rustcore --crate-type bin -g --out-dir /mnt/home/vmhome/rustcore/target --emit=dep-info,link -L dependency=/mnt/home/vmhome/rustcore/target -L dependency=/mnt/home/vmhome/rustcore/target/deps --extern rust-netmap=/mnt/home/vmhome/rustcore/target/deps/librust-netmap-10a85511dfe14665.so --extern rust-netmap=/mnt/home/vmhome/rustcore/target/deps/librust-netmap-10a85511dfe14665.rlib -L native=/mnt/home/vmhome/rustcore/target/build/rust-netmap-10a85511dfe14665/out`
src/main.rs:6:10: 6:25 error: unresolved name `netmap::nm_open`
src/main.rs:6 let n = netmap::nm_open("eth1", 0, 0, 0);
^~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `rustcore`.
Caused by:
Process didn't exit successfully: `rustc src/main.rs --crate-name rustcore --crate-type bin -g --out-dir /mnt/home/vmhome/rustcore/target --emit=dep-info,link -L dependency=/mnt/home/vmhome/rustcore/target -L dependency=/mnt/home/vmhome/rustcore/target/deps --extern rust-netmap=/mnt/home/vmhome/rustcore/target/deps/librust-netmap-10a85511dfe14665.so --extern rust-netmap=/mnt/home/vmhome/rustcore/target/deps/librust-netmap-10a85511dfe14665.rlib -L native=/mnt/home/vmhome/rustcore/target/build/rust-netmap-10a85511dfe14665/out` (exit code: 101)
I do have features = ["netmap_with_libs"]
in my Cargo.toml
, per your README. What am I missing?
I'm trying to build this on my local Linux box, and the stuff in build.rs
seems to be failing.
First, I think I needed to install clang
, which wasn't super-obvious. But even with that done, I still hit this error:
[lars@tux: ~/rustcore] cargo build -v
Compiling rust-netmap v0.0.4 (https://github.com/libpnet/rust-netmap.git#ab947ee2)
Running `rustc /tmp/git/checkouts/rust-netmap-2baeba280d3ef56f/master/src/lib.rs --crate-name rust-netmap --crate-type rlib --crate-type dylib -C prefer-dynamic -g --cfg feature="default" --cfg feature="netmap_with_libs" -C metadata=10a85511dfe14665 -C extra-filename=-10a85511dfe14665 --out-dir /mnt/home/vmhome/rustcore/target/deps --emit=dep-info,link -L dependency=/mnt/home/vmhome/rustcore/target/deps -L dependency=/mnt/home/vmhome/rustcore/target/deps -Awarnings -L native=/mnt/home/vmhome/rustcore/target/build/rust-netmap-10a85511dfe14665/out -l static=rust_netmap_user`
error: could not find native static library `rust_netmap_user`, perhaps an -L flag is missing?
Could not compile `rust-netmap`.
Caused by:
Process didn't exit successfully: `rustc /tmp/git/checkouts/rust-netmap-2baeba280d3ef56f/master/src/lib.rs --crate-name rust-netmap --crate-type rlib --crate-type dylib -C prefer-dynamic -g --cfg feature="default" --cfg feature="netmap_with_libs" -C metadata=10a85511dfe14665 -C extra-filename=-10a85511dfe14665 --out-dir /mnt/home/vmhome/rustcore/target/deps --emit=dep-info,link -L dependency=/mnt/home/vmhome/rustcore/target/deps -L dependency=/mnt/home/vmhome/rustcore/target/deps -Awarnings -L native=/mnt/home/vmhome/rustcore/target/build/rust-netmap-10a85511dfe14665/out -l static=rust_netmap_user` (exit code: 101)
Looking at build.rs
, I noticed that /usr/include/net/netmap_user.h
does not exist on my netmap-enabled system, but even after making this a symlink to my netmap_user.h
, I see this failure.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.