ndhc/ndhc
Nicholas J. Kain daf42ccb29 Change ifchange_*() so that the interface and ip keywords are only sent to
ifchd if it is necessary to do so, just as is the case for other keywords.

Make data sending in ifchange_*() collect all keywords into a buffer that
is sent in a single sockwrite() rather than performing a sockwrite() for
every keyword.

Minor documentation updates.
2011-07-05 19:25:19 -04:00
..
arp.c Call arp_close_fd() from reinit_selecting(). 2011-07-05 16:02:11 -04:00
arp.h Handle DS_REBINDING and DS_RENEWING states just like DS_BOUND when the 2011-07-05 15:57:11 -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 Enforce stronger type checking on DHCP option values. Fix some endianness 2011-07-02 04:45:11 -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 Remove DEBUG prints. 2011-07-05 13:04:34 -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 Clean up frenew(). It should only perform work in DS_RELEASED and DS_BOUND. 2011-07-05 18:18:57 -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 Define set_released() and use it for entering the DS_RELEASED state. 2011-07-05 18:29:06 -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.