-
Notifications
You must be signed in to change notification settings - Fork 680
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
SockProtocol::ETH_P_* SockProtocol::Htons(u16) and SockProtocol::Integer(i32) #865
base: master
Are you sure you want to change the base?
Conversation
src/sys/socket/mod.rs
Outdated
/// Allows applications and other KEXTs to be notified when certain kernel events occur | ||
pub enum SockProtocol { | ||
/// htons conversion for RAW type | ||
Htons(u16), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are going to use plain numbers instead of fixed enums, why not make an entry like Custom
that accept just an integer instead of Htons
?
I mean a procotol number (in general) is just an arbitrary number, which (again, in general) doesn't have to do anything with the byte order, at least that is my understanding.
What'd you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing the code!
Htons gives a conversion from u16
to htons(u16)
,
but yes, perhaps it might be best to also have a Integer(i32).
Two things:
man socket(2)
correctly states thatThe protocol number to use is specific to the communication domain in which communication is to take place.
meaning that, as you said, a protocol is just an arbitrary number for the sock type.- I like the idea of looking at API documentation and getting a feel for what is possible. That's what makes the enum so great.
So, how about keeping the existing enums, but adding an Integer(i32)
enum type?
/// ([ref](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/control/control.html)) | ||
#[cfg(any(target_os = "ios", target_os = "macos"))] | ||
KextEvent = libc::SYSPROTO_EVENT, | ||
/// Allows applications to configure and control a KEXT | ||
KextControl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why did you reorder the items? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetic ordering :)
…twork byte order; ref nix-rust#865
Well, as I've said on gitter, I would rather go with just that And I would definitely keep Just for the record, I'm not the one to decide :) |
Two reasons:
There is not an enum for u64 because the man
The reason for From man
Thanks for the questions. |
Add ETH_* constants on Android Adding ETH_* constants that were found here on Linux but not on Android. Source Reference is [linux/if_ether.h](https://android.googlesource.com/platform/bionic/+/master/libc/kernel/uapi/linux/if_ether.h) on Google OpenSource. Thank-you. /cc nix-rust/nix#865
This PR closes #854.
SockProtocol::ETH_P_*
included inlibc
hereSockProtocol::Htons(u16)
for any ethernet frames not included directly in the headersSockProtocol::Integer(i32)
as an override for any protocols that may be defined on custom systems that we have limited knowledge about.Welcome to comments and suggestions. Thanks.
/cc @mexus @Susurrus