Closed bkchr closed 6 years ago
Why not
#[cfg(target_endian = "big")]
pub type u16ne = u16be;
#[cfg(target_endian = "little")]
pub type u16ne = u16le;
I think that does not work, because libpnet ignores the cfg attributes while generating the code. In the end, the struct parameter will get the same cfg attribute, but you will have two function get_type() and the compiler will throw an error :/ I think the best would be to find a solution upstream. If I have time, I will open an issue at libpnet. Currently I just need to get it working.
I created a pr for libpnet: https://github.com/libpnet/libpnet/pull/295
If that is accepted, this pull request will get a lot of simpler :)
@polachok yeah, I can not approve my own pull requests. It would be nice if you approve the changes :)
Netlink packages are always in the same endianess as the host system. libpnet does not support to create packages with data types that are bigger than u8 without a fixed endianess. So, we create two different files, one for big and one for little endian.
This solution is only a "hack", it would be nice if libpnet would support adding "normal" data types.