-
Notifications
You must be signed in to change notification settings - Fork 88
Allow access to Ack messages containing data #230
Comments
@little-dude any guidance here? |
Hello @mraerino :) To be honest I don't know, really. I didn't expect these messages to have a payload. Option 1Make the payload of Done messages a #[derive(Debug, PartialEq, Eq, Clone)]
pub enum NetlinkPayload<I> {
Done(Vec<u8>),
Error(ErrorMessage),
Ack(AckMessage),
Noop,
Overrun(Vec<u8>),
InnerMessage(I),
} But then users have to do the parsing themself. Not ideal Option 2We could make the messages generic over the payload of the #[derive(Debug, PartialEq, Eq, Clone)]
pub enum NetlinkPayload<I, D> {
Done(D),
Error(ErrorMessage),
Ack(AckMessage),
Noop,
Overrun(Vec<u8>),
InnerMessage(I),
} This is a very drastic API change though... Option 3Have a generic payload for #[derive(Debug, PartialEq, Eq, Clone)]
pub enum NetlinkPayload<I> {
Done(I),
Error(ErrorMessage),
Ack(AckMessage),
Noop,
Overrun(Vec<u8>),
InnerMessage(I),
} This means that the inner message payload need to have an additional variant though. For instance for #[derive(Debug, PartialEq, Eq, Clone)]
pub enum RtnlMessage {
Done, // <- new variant
NewLink(LinkMessage),
DelLink(LinkMessage),
GetLink(LinkMessage),
SetLink(LinkMessage),
NewLinkProp(LinkMessage),
DelLinkProp(LinkMessage),
NewAddress(AddressMessage),
// ...
} But this doesn't feel right at all... Perhaps as a first step I'd prefer to go with the least invasive option, which is to parse the payload as a Another change we'll need, is for netlink/netlink-proto/src/connection.rs Line 233 in bda893b
But this should not be too much of a problem. |
How about option 2 with a default for |
good idea. i have it working with a breaking change, but your suggestion seems sensible |
Actually, modifying the I don't like Option 3 (although it would have a similar "get it to compile" pattern), because it will produce |
When implementing the W1 Netlink adapter (uses
NETLINK_CONNECTOR
) i ran into this issue:Responses to requests are send with the
message_type
set to0x3
. Therefore as responses arrive, theNetlinkPayload
enum will be set toDone
and any payload attached to the message is thrown away.Do you think there is a good way to model this behaviour in the library?
I think i could also make a custom codec and re-implement NetlinkMessage in a different way, but i'd rather solved this upstream if possible.
My (very rough) code is here: https://github.com/kalkspace/w1-netlink-rs/blob/main/examples/lowlevel.rs
This is one of the payloads coming back in that example code:
The text was updated successfully, but these errors were encountered: