ndhc/ndhc
Nicholas J. Kain 01c4731403 Make sure that the netlink socket will never block after program
initialization.  Fetching if/address/index/mac mappings is done only once at
program init, so it is done synchronously as an exception to this rule.

Rewrite the netlink handling.  Now uses NIH code that should be safe, small,
and correct.  No external deps FTW.
2011-07-03 17:30:55 -04:00
..
arp.c Send an ARP announcement after getting a new lease. 2011-07-02 05:48:24 -04:00
arp.h Convert DHCP option code numbers to an enum. 2011-07-02 06:31:57 -04:00
CMakeLists.txt Make sure that the netlink socket will never block after program 2011-07-03 17:30:55 -04:00
config.h Add clientid-mac option for sending a MAC address as a client identifier 2011-07-03 05:36:47 -04:00
COPYING Initial commit. 2010-11-12 04:02:18 -05:00
dhcp.c Don't send host name option on DHCP decline or release packets. 2011-07-03 06:03:54 -04:00
dhcp.h Enforce stronger type checking on DHCP option values. Fix some endianness 2011-07-02 04:45:11 -04:00
ifchange.c Convert DHCP option code numbers to an enum. 2011-07-02 06:31:57 -04:00
ifchange.h Rename packet.[ch] to dhcp.[ch]. 2011-07-02 03:51:44 -04:00
leasefile.c fsync() the leasefile after writing a new lease IP so that it's instantly 2011-06-28 13:47:36 -04:00
leasefile.h Add support for writing lease files. 2011-04-19 16:37:43 -04:00
ndhc-defines.h Make write() and sendto() properly handle short writes and errors in ndhc. 2010-11-12 18:44:49 -05:00
ndhc.8 Initial commit. 2010-11-12 04:02:18 -05:00
ndhc.c Make sure that the netlink socket will never block after program 2011-07-03 17:30:55 -04:00
netlink.c Make sure that the netlink socket will never block after program 2011-07-03 17:30:55 -04:00
netlink.h Make sure that the netlink socket will never block after program 2011-07-03 17:30:55 -04:00
nl.c Make sure that the netlink socket will never block after program 2011-07-03 17:30:55 -04:00
nl.h Make sure that the netlink socket will never block after program 2011-07-03 17:30:55 -04:00
options.c Enforce stronger type checking on DHCP option values. Fix some endianness 2011-07-02 04:45:11 -04:00
options.h Convert DHCP option code numbers to an enum. 2011-07-02 06:31:57 -04:00
README Theoretical correctness fix: 2011-05-30 10:54:05 -04:00
state.c Clean up the DHCP packet sending functions and make them more RFC-compliant. 2011-07-01 11:37:13 -04:00
state.h Rename packet.[ch] to dhcp.[ch]. 2011-07-02 03:51:44 -04:00
sys.c Convert DHCP option code numbers to an enum. 2011-07-02 06:31:57 -04:00
sys.h Theoretical correctness fix: 2011-05-30 10:54:05 -04:00

ndhc client
--------------------

The ndhc client negotiates a lease with the DHCP server and notifies
ifchd when a leases is obtained or lost.


command line options
-------------------

The command line options for the ndhc client are:

-c, --clientid=CLIENTID         Client identifier
-H, --hostname=HOSTNAME         Client hostname
-h,				Alias for -H
-f, --foreground                Do not fork after getting lease
-b, --background                Fork to background if lease cannot be
                                immediately negotiated.
-i, --interface=INTERFACE       Interface to use (default: eth0)
-n, --now                       Exit with failure if lease cannot be
                                immediately negotiated.
-q, --quit                      Quit after obtaining lease
-r, --request=IP                IP address to request (default: none)
-v, --version                   Display version


If the requested IP address cannot be obtained, the client accepts the
address that the server offers.


note on ndhc's random seed
---------------------------

ndhc will seed its random number generator (used for generating xids)
by reading /dev/urandom. If you have a lot of embedded systems on the same
network, with no entropy, you can either seed /dev/urandom by a method of
your own, or doing the following on startup:

ifconfig eth0 > /dev/urandom

in order to seed /dev/urandom with some data (mac address) unique to your
system. If reading /dev/urandom fails, ndhc will fall back to its old
behavior of seeding with time(0).


signals accepted by ndhc
-------------------------

ndhc also responds to SIGUSR1 and SIGUSR2. SIGUSR1 will force a renew state,
and SIGUSR2 will force a release of the current lease, and cause ndhc to
go into an inactive state (until it is killed, or receives a SIGUSR1). You do
not need to sleep between sending signals, as signals received are processed
sequentially in the order they are received.

DHCP pitfalls
-------------

Send a packet that has an options field set to:
DHCP-OPTION-OVERLOAD:3

Then in the file and sname fields:
DHCP-OPTION-OVERLOAD:3

I suspect some bad dhcp programs will hang given this input.