kpcyrd / snail

Parasitic network manager
https://crates.io/crates/snail
GNU General Public License v3.0
15 stars 2 forks source link

Implement dhcpc in rust #7

Open kpcyrd opened 6 years ago

kpcyrd commented 6 years ago

We're currently using dhcpcd, this should be replaced by a rust implementation:

The dhcp client should be able to run standalone as well so in can be used outside of the snail project if needed.

kpcyrd commented 6 years ago

As a note: After some digging it turned out that dhpcd binds to 0.0.0.0:68, but doesn't use it. This is probably to mark the port as "in use":

socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 10
setsockopt(10, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(10, {sa_family=AF_INET, sin_port=htons(68), sin_addr=inet_addr("0.0.0.0")}, 16) = 0

Instead, a new socket is opened with AF_PACKET that is then used to send/receive dhcp packets. This explains why I couldn't get my udp socket to work correctly.