Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netlink is host-native ordering #5

Open
rbtcollins opened this issue Sep 27, 2016 · 2 comments
Open

netlink is host-native ordering #5

rbtcollins opened this issue Sep 27, 2016 · 2 comments

Comments

@rbtcollins
Copy link
Contributor

Sadly netlink doesn't have a stable wireformat - its host representation specific. E.g. a __u32 in the linux headers is neither u32be or u32le - its dependent on the architecture of the kernel. The current definitions in pnetlink are e.g. u32le which will fail on architectures with different byte orderings (such as various ARM and MIPS machines - common these days in IoT)

@polachok
Copy link
Owner

This is correct. I think it can be easily solved by using cfg, e.g.:

struct Whatever {
    #[cfg(target_endian = "little")]
    a: u32le,
    #[cfg(target_endian = "big")]
    a: i32be,
}

or alternatively with type aliases:

#[cfg(target_endian = "little")]
type u32ne = u32le;
#[cfg(target_endian = "big")]
type u32ne = u32be;

@rbtcollins
Copy link
Contributor Author

I think we need to make it hard to add modules in a buggy fashion - the cfg should apply throughout all of pnetlink, and use of u32le etc in pnetlink struct definitions should trigger compiler errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants