I'm trying to build an example io_uring echo udp server here. Basically since recv_from is not available, I need to use recvmsg and somehow retrieve the source address to respond.
My first question is why this work:
let mut msg_hdr: libc::msghdr = unsafe { std::mem::zeroed() };
// I copied this from tokio/io-uring test code, I don't know why it works
// https://github.com/tokio-rs/io-uring/blob/master/io-uring-test/src/tests/net.rs
msg_hdr.msg_namelen = 16;
If I set msg_namelen to anything but 0 and 16 then I get parsing errors. If I set to 0 the msghdr is always empty (excpet the payload size). If I set to 16 then I get some data like:
But I don't know how to interpret this. How do I use this data to create a file descriptor for SendMsg?
Should I maybe set somehow the IP_PKTINFO flag?
I'm trying to build an example
io_uring
echo udp server here. Basically sincerecv_from
is not available, I need to userecvmsg
and somehow retrieve the source address to respond.My first question is why this work:
If I set
msg_namelen
to anything but 0 and 16 then I get parsing errors. If I set to 0 themsghdr
is always empty (excpet the payload size). If I set to 16 then I get some data like:But I don't know how to interpret this. How do I use this data to create a file descriptor for
SendMsg
? Should I maybe set somehow theIP_PKTINFO
flag?