Open mon opened 2 months ago
Specifically, you'd listen on all ports for a BOOTP request, then reply to the port it came from to start upload.
I'm not as familiar with the protocol, so take that in consideration for the next comments.
It would help me if you could share an example/bootp.rs
file of the desired API for me to understand it better.
p.s. I hope you're not too bothered by all my activity!
Not at all :) Feel free to keep posting issues, I just can't promise you any fast response tho.
MulticastSocket::all_interfaces/with_options 1) Could using
SocketAddrV4::new([172, 31, 255, 255].into(), 0)
possibly work already?Binding to a port - make it so this is the required argument instead? 2) There is already support for specifying a port to listen, so I'm unsure on this part.
MulticastSocket::send - split into send with an address and send_to_group, or keep send as-is and add send_to?
I think a send_to
might be the best option from my current understanding.
I guess I should explain BOOTP a little better, as it may help. The existing way to specify a port won't work, because it forces me to pick a multicast group (which BOOTP doesn't have).
BOOTP is pretty much just DHCP (DHCP is actually an extension of the BOOTP protocol). A good chunk of embedded devices' bootloaders will
The pseudocode would be something like:
let mut socket = MulticastSocket::new_on_port_only(67); // broadcast only, no multicast ADD_MEMBERSHIP
while let message = socket.recv() {
if !valid_bootp_packet(message.data) {
continue;
}
let mut reply = create_bootp_response(message.data);
reply.to = message.origin_address;
reply.server_addr = message.interface.ip;
socket.send_to(&message.interface, &reply.to_vec(), INADDR_BROADCAST);
}
I'd like to use this library to program a device that uses BOOTP. BOOTP benefits greatly from the "which interface did this packet come from" aspect of the library, but uses broadcast packets instead of multicast. Specifically, you'd listen on all ports for a BOOTP request, then reply to the port it came from to start upload.
Before I start work, I'd like to check on the best way to implement
MulticastSocket::all_interfaces/with_options
- Change the argument to anOption<>
, or move it into the options struct with a default of "no group"? I don't think it's possible to avoid an API break, unless you'd prefer newall_interfaces_without_group
or somethingMulticastSocket::send
- split intosend
with an address andsend_to_group
, or keepsend
as-is and addsend_to
?p.s. I hope you're not too bothered by all my activity! Basically, I have an unpublished crate similar to multicast-socket, but then I found yours which uses far fewer resources, doesn't need threads, works properly on Linux etc... So I'm slowly bringing across features so I can drop my terrible impl.