sdhcp – A tiny dhcp client
sdhcp is a tiny implementation of dhcp. When compiled with dietlibc
CC="diet -Os gcc" make sdhcp) the executable is a mere 8.8K. It
also has the most
goto per line ratio of any program I’ve ever written.
How could this be simple you ask? As it turns out, gotos make the most
beautiful state-machine/flowchart translation ever.
About 200 of the 500 lines are for printing the contents of a dhcp header, and come from the plan9 dhcp client, without which this program never would have been possible. It must’ve been the only reasonably clear dhcp implementation on the whole internet.
make debug and
make generate an executable of the same name
with the exception that the debug one spews out every dhcp packet it
reads or writes. Both work fine, when
sdhcp is the version which contains all the code necessary to
put you on the net. It’s a bit larger, and less flexible than the other
sdhcp-helper outputs its leases to stdout, relying on another program
to configure the network. The advantage is that everything in the client