Commit Graph

491 Commits

Author SHA1 Message Date
Nicholas J. Kain
071e91941f Unify options.[ch] with the one used in ndhs. 2011-09-02 02:12:51 -04:00
Nicholas J. Kain
c4b4938a59 Validate that server reply has the client hardware address field set
to be equal to our MAC address.  Win7 verifies this field, so it should
be safe enough to check it, too.
2011-09-01 23:05:56 -04:00
Nicholas J. Kain
ab4a2e0b97 Switch to using clock_gettime() rather than gettimeofday(). 2011-07-31 01:27:59 -04:00
Nicholas J. Kain
45c76dd548 More comment cleanups. Make the DHCP packet field comments more accurate. 2011-07-27 08:03:42 -04:00
Nicholas J. Kain
f864a0317c Cosmetic cleanups of comments. 2011-07-27 07:49:30 -04:00
Nicholas J. Kain
916ddf10e5 Update documentation: options concatenation is now supported. 2011-07-27 07:43:09 -04:00
Nicholas J. Kain
13f5ab56e2 Rewrite DHCP options parsing to conform to RFC 3396: options concatenation is
now fully supported.
2011-07-27 07:39:45 -04:00
Nicholas J. Kain
d7103c887d Move the length check in ifchd_cmd_str() before the snprintf() call, so that
failure cannot leave the ifchd_cmd in a state with unbalanced ':'.
2011-07-27 00:42:16 -04:00
Nicholas J. Kain
7ef7fa8a8d Fix the return value of ifchd_cmd_str() and correct its length check. 2011-07-27 00:37:11 -04:00
Nicholas J. Kain
17a2403635 Cosmetic fixes. 2011-07-26 06:43:12 -04:00
Nicholas J. Kain
f2618ef79d Delete a lot of code that is now unused thanks to the previous commit. 2011-07-26 06:24:30 -04:00
Nicholas J. Kain
0431b7d439 Replace the options -> ifchd command code with a much simpler translator. 2011-07-26 06:15:21 -04:00
Nicholas J. Kain
b935180a2f Just keep a statically constructed options request payload. It's simpler
and more compact.
2011-07-26 01:58:05 -04:00
Nicholas J. Kain
d00922df51 Abstract uses of get_option_data() outside of ifchange.c and options.c.
The eventual goal is to eliminate uses of get_option_data() in ifchange.c and
will make it a static function in options.c.
2011-07-26 01:04:59 -04:00
Nicholas J. Kain
ea5d472424 Encapsulate all string option additions into options.c. Note that these
functions already existed, but were in dhcp.c -- this is just code motion
between compilation units.
2011-07-25 23:48:35 -04:00
Nicholas J. Kain
286548b754 Encapsulate all numeric option additions into options.c. 2011-07-25 23:34:32 -04:00
Nicholas J. Kain
0229373378 Remove the overkill type checking for sent options. 2011-07-25 04:34:14 -04:00
Nicholas J. Kain
31d6d4cd92 Some options are never sent to ifchd, but we unfortunately would need to
sacrifice type checking to remove them from the options table.  It may
be worth doing that, but I want to audit each call point before.
2011-07-25 04:26:34 -04:00
Nicholas J. Kain
e4a4c58856 BADOPTION -> BAD 2011-07-25 03:45:05 -04:00
Nicholas J. Kain
8caf9e7d7a Remove support for RFC868 Time Server options. Totally obsolete, and
ifchd just had empty hooks that never received work messages anyway.

Shorten the names of ifchd commands.  This breaks wire protocol, but
thankfully I haven't released yet!
2011-07-25 03:39:17 -04:00
Nicholas J. Kain
544a837944 Shrink and reorder the options table. 2011-07-25 03:28:04 -04:00
Nicholas J. Kain
2cb0b9227d Consolidate DHCP option code numbers. 2011-07-25 03:11:47 -04:00
Nicholas J. Kain
77af1d81fe Relicense under New BSD (2-clause) license. I don't see any advantage to
restricting use unnecessarily, and simple attribution is fine.
2011-07-25 02:30:57 -04:00
Nicholas J. Kain
7e1e902b34 Share ifchd command defines between ifchd and ndhc. 2011-07-25 02:01:38 -04:00
Nicholas J. Kain
fe85e52a4b Be less harsh to udhcp in HISTORY... there was no better choice among the
considered options at the time.
2011-07-24 18:02:25 -04:00
Nicholas J. Kain
7f6721bb82 Pass around the DHCP message type as the literal data, not as a character
pointer to the matching data in the options field of the DHCP packet.
2011-07-18 10:47:35 -04:00
Nicholas J. Kain
27081be84f Make netlink action logging messages more consistent: prefix with 'nl: ' and
always print the actual interface identifier.
2011-07-18 10:29:36 -04:00
Nicholas J. Kain
19ad80bb57 Minor doc fix. I'm going to keep using libcap. 2011-07-13 04:54:15 -04:00
Nicholas J. Kain
24db573005 Write man pages and do some misc cleanup on old files.
Add more documentation to the README.
2011-07-13 02:30:10 -04:00
Nicholas J. Kain
2a1885bab4 Move the objs directory underneath the build directory when building with
the Makefile.
2011-07-12 18:45:29 -04:00
Nicholas J. Kain
2aff36a274 Provide a gmake Makefile for distro builds and packagers.
Define _GNU_SOURCE in the CFLAGS.
Update the README.
Remove the duplicate Gentoo init script ndhc.sh that is in the root.
Remove DESIGN -- it's outdated.
2011-07-12 04:09:05 -04:00
Nicholas J. Kain
efe50a30a6 Even more cosmetic log message changes. 2011-07-11 23:51:55 -04:00
Nicholas J. Kain
0a0c74efcc Yet more log message tweaking. 2011-07-11 23:45:37 -04:00
Nicholas J. Kain
8f80a10905 Remove some redundant log messages, and make the forced-release print a bit
more user-friendly.
2011-07-11 23:41:38 -04:00
Nicholas J. Kain
af365be9b7 Convert all inet_aton() to inet_pton() since inet_pton() is POSIX. 2011-07-11 17:11:19 -04:00
Nicholas J. Kain
b89c694bc9 Convert all uses of inet_ntoa() to inet_ntop(). inet_ntop() is POSIX,
supports ipv6 (doesn't matter to ndhc), and does not use a stupid internal
static buffer.  This fixes some cosmetic print bugs.
2011-07-11 17:02:32 -04:00
Nicholas J. Kain
cfa22626e4 Check the server identifier option when receiving a DHCP ACK or NAK to make
sure that it matches that of our associated DHCP server.

Normalize, prune, and beautify the appearance of log messages.

Minor cosmetic cleanups/refactoring.
2011-07-11 16:33:57 -04:00
Nicholas J. Kain
e0ef11848b Record the MAC address of the DHCP server and use it to identify the network
when the hardware link carrier is dropped and comes back.  Also, don't assume
that all networks have a default gateway.

Guard against spurious arp defense attempts that might be triggered by packets
that are still in the socket buffer from before the BPF was changed.

Split apart the AS_GW_CHECK and AS_GW_QUERY timeout handlers.

Cosmetic cleanups in state.c.
2011-07-11 13:24:59 -04:00
Nicholas J. Kain
83594bce4a Track pending events in time by using absolute times rather than relative
timeouts.
2011-07-11 11:31:27 -04:00
Nicholas J. Kain
9b3e1872cb Rather than use a single cs.timeout value, track individual timeouts for every
ARP state and for the current DHCP state.
2011-07-11 10:39:36 -04:00
Nicholas J. Kain
8c30c82240 Optimize timeout calculations so that curms() is called fewer times and
the timeout intervals are a bit more exact.
2011-07-11 08:59:50 -04:00
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
Nicholas J. Kain
9762fa5315 Constify some more static structs. 2011-07-11 05:35:40 -04:00
Nicholas J. Kain
1e71f82f3a Refactor the ARP code to be similar to the dhcp code -- timeout functions and
packet response functions are handled by an array of function pointers indexed
by ARP state.

Split arp_retransmit() apart into simpler functions.

Fix a typo in renewing_timeout() that would result in too-short timeouts that
would soak cpu.

Call handle_arp_timeout() from the timeout_action() function rather than
having
explicit hooks in various <dhcpstate>_timeout() functions.

Make the function pointer arrays static const.
2011-07-11 05:09:38 -04:00
Nicholas J. Kain
8beb1d12d1 Fix a regression: if renewing or rebinding a dhcp lease that matches our
previous client ip, make sure to stop listening for dhcp packets, set the
proper timeout interval, and make sure we're in AS_DEFENSE state.
2011-07-06 11:41:49 -04:00
Nicholas J. Kain
080fefaea0 Handle hardware link state loss and restoration on networks that lack a
default gw properly.
2011-07-06 11:32:22 -04:00
Nicholas J. Kain
ad5c5d6803 Only perform arpreply_clear() after consuming an arp packet in
handle_arp_response() and when opening a new arp fd.  Do not clear the
arpreply buffer and offset on ARP state transitions.

Only perform ARP collision probing when binding a new lease from the
DS_REQUESTING state, or if we have renewed or rebound a lease with a different
IP than we had before.

Resequence the arp_dhcp_packet memcpy() in arp_check() so that the current
IP address is ARP checked rather than the previous one.
2011-07-06 09:26:07 -04:00
Nicholas J. Kain
a92cb1c4c6 Randomize the DHCP timeout by +[0,1000]ms to comply with RFC. 2011-07-06 08:46:05 -04:00
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
Nicholas J. Kain
3316505f3c Define set_released() and use it for entering the DS_RELEASED state. 2011-07-05 18:29:06 -04:00