[dev][sdhcp] more updates

From: Sean MacLennan <seanm_AT_seanm.ca>
Date: Sat, 2 Feb 2019 23:38:29 -0500

Not sure if I this list allows attachments... so here we go.

First a question: how portable do we want things? The current sdhcp
works only on Linux.

This patch contains one big change and some smaller changes. The big
change is support for raw sockets on Linux. I split the raw socket code
into a file called raw.c and included it in sdhcp. I did that only to,
hopefully, make the diff more readable.

So why raw sockets? Linux has a bug, er design decision, that when you
use UDP/TCP sockets it tries really hard to assign an address to the
outgoing packet. If you have multiple interfaces, it will actually
borrow the address from another interface.

This is usually not a problem... except when the dhcp server cannot
route local addresses. For example trying to dhcp with Rogers Cable.

So a raw socket allows you to force the outgoing address to 0.0.0.0.
This code is very Linux specific. I believe it could be forced to work
with BSD, but why? BSD doesn't have the problem.

You may notice that I close the socket when we are bound. The raw
socket sees all traffic on the interface and this is done for
performance reasons.

Other fixes that are in this diff because I need them:

  * allow binary cid input. If you put 0x<cid> then it will be
    interpreted as raw bytes. You can still specify a string.

  * talking about cid, the default is now a correct mac address cid.

  * calctimeout() was dividing the timeout by 2. Not sure why so I
    removed it. Also, the check for less than 60 seconds would only
    work if you went back in time to Jan 1, 1970 for the first minute
    after midnight.

  * sdhcp now only prints Congrats on the first connection, not every
    rebind.

  * we need the interface up to work. The code now brings the interface
    up.

  * a couple of portability cleanups may have crept in too... but I
    tried to keep them to a minimum.

Cheers,
    Sean

Received on Sun Feb 03 2019 - 05:38:29 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 03 2019 - 05:48:07 CET