ndhc/ndhc
Nicholas J. Kain 2e328b6913 Don't strip high bit from lease time.
Change order of operations to prevent overflow with very long leases when
calculating rebind time duration.
2011-07-11 08:01:56 -04:00
..
arp.c Refactor the ARP code to be similar to the dhcp code -- timeout functions and 2011-07-11 05:09:38 -04:00
arp.h Refactor the ARP code to be similar to the dhcp code -- timeout functions and 2011-07-11 05:09:38 -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 cs->packetNum is not descriptive and is not used outside of state.c. 2011-07-05 15:44:11 -04:00
COPYING Initial commit. 2010-11-12 04:02:18 -05:00
dhcp.c Resequence operations in selecting_timeout() so that two packets are sent with 2011-07-03 18:56:57 -04:00
dhcp.h Handle hardware link state loss and restoration on networks that lack a 2011-07-06 11:32:22 -04:00
ifchange.c Change ifchange_*() so that the interface and ip keywords are only sent to 2011-07-05 19:25:19 -04:00
ifchange.h Simplify the ifchange API. 2011-07-04 20:51:27 -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 Constify some more static structs. 2011-07-11 05:35:40 -04:00
netlink.c Move dhcp state handling code out of netlink.c and into state.c. netlink.c 2011-07-04 22:10:14 -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 Constify some more static structs. 2011-07-11 05:35:40 -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 Don't strip high bit from lease time. 2011-07-11 08:01:56 -04:00
state.h Rename DS_ARP_CHECK to the less confusing DS_COLLISION_CHECK. 2011-07-04 22:59:07 -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.