41 Commits

Author SHA1 Message Date
Nicholas J. Kain
3d0f46580a options.c: Add an add_option_clientid() variant for ndhs to use, and silence
an unused function warning that triggers when compiling ndhs.
2014-03-18 01:51:58 -04:00
Nicholas J. Kain
071e91941f Unify options.[ch] with the one used in ndhs. 2011-09-02 02:12:51 -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
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
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
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
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
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
801ec356f4 Convert DHCP option code numbers to an enum.
Convert many remaining /**/ comments to // where it makes for less visual
clutter.
2011-07-02 06:31:57 -04:00
Nicholas J. Kain
46ed7f5998 Enforce stronger type checking on DHCP option values. Fix some endianness
issues as well.
2011-07-02 04:45:11 -04:00
Nicholas J. Kain
cfd9822252 Rename packet.[ch] to dhcp.[ch]. 2011-07-02 03:51:44 -04:00
Nicholas J. Kain
d9571c62cf Don't use malloc in ndhc. The only place it was used is in the options code.
Allow the user to specify the vendor identification option value using the
-V switch.  The default value is still "ndhc".
2011-07-02 03:48:08 -04:00
Nicholas J. Kain
38ad2399ed Clean up the DHCP packet sending functions and make them more RFC-compliant.
Rename cs->requestedIP to cs->clientAddr.
Move the IFS_* defines into netlink.c.
Cosmetic cleanups.
2011-07-01 11:37:13 -04:00
Nicholas J. Kain
55f24fd2a3 Make the various functions in options.c that take a pointer to an options
buffer and length instead take a pointer to a struct dhcpmsg.  This argument
list choice implicitly gives safe length checks and is simpler.

Remove DHCP_OPTIONS_LENGTH.
Fold set_option() into alloc_option().
Make some more functions in options.[ch] static.
2011-06-27 12:53:35 -04:00
Nicholas J. Kain
864ad73b20 Remove pointless length-checking in get_raw_packet() that can never be triggered
because safe_read() already protects against reads longer than a DHCP
packet in length.

Lots of cosmetic cleanups.  Highlights:
- Remove pointless enums that just define sizeof for various structures.
- Rename struct dhcpMessage to struct dhcpmsg.
2011-06-26 17:25:00 -04:00
Nicholas J. Kain
d72b24a2fe Theoretical correctness fix:
Handle EAGAIN and EWOULDBLOCK more gracefully when dealing with safe_read().
All occurrences of safe_read() should only be invoked on fds that have signaled
ready-to-read state via the epoll() mechanism, so this change should not
result in any observable difference, but it is best to be safe.

Additionally, a constant stack variable is converted to an equivalent
macro define for cleanliness.

Finally, print the error type encountered if reading data from an ARP response
fails with a read error.
2011-05-30 10:54:05 -04:00
Nicholas J. Kain
da193ae35a Add support for writing lease files. 2011-04-19 16:37:43 -04:00
Nicholas J. Kain
6265a0e973 Untabify options.[ch]. 2011-03-30 16:35:23 -04:00
Nicholas J. Kain
09613fd77a Fold req_opts[] and list_opts[] into options[].type, and modify accessors
accordingly.
2011-03-30 16:34:09 -04:00
Nicholas J. Kain
5d7bcbb2d4 Change parameters for add_option_request_list().
Make all unsigned char into uint8_t in options.[ch].
2011-03-30 16:05:28 -04:00
Nicholas J. Kain
ddf9daf8e4 Do more boundary and sanity checking when adding dhcp options.
Simplify parameter list for ifchd_cmd().
2011-03-30 15:57:01 -04:00
Nicholas J. Kain
0e62d46f8b Explicitly track length in get_end_option_idx().
Rename get_options() to get_option_data() and end_options() to
get_end_option_idx().
2011-03-30 12:04:38 -04:00
Nicholas J. Kain
97978711de Isolate the dhcp_option options[] array to options.c and provide abstract
accessors for its data.
2011-03-30 11:36:27 -04:00
Nicholas J. Kain
7c32f968c9 Perform length and type checking in ifchange.c:fill_options.c(). 2011-03-30 10:13:34 -04:00
Nicholas J. Kain
1437f520ca Rewrite get_option(): new version fixes at least one bug, and is much easier
to understand and verify as correct.  It also returns the length of the
extracted option.
2011-03-30 09:35:17 -04:00
Nicholas J. Kain
f0865812d2 Kill unused function find_options() and unused struct option_set. 2011-03-30 08:21:06 -04:00
Nicholas J. Kain
2719d12d3c struct dhcp_option flags field is now exclusively for type, so rename it.
Remove unused struct dhcp_option types.
2011-03-30 08:19:08 -04:00
Nicholas J. Kain
f28c0c7445 OPTION_LIST is unused, remove it. 2011-03-30 08:12:56 -04:00
Nicholas J. Kain
d4171420a1 Fix sending DHCP_MAX_SIZE option.
Move DHCP_PARAM_REQ message types out of the options[] structure.
Make ipchange.c:translation_option() less insane.
2011-03-30 08:02:25 -04:00
Nicholas J. Kain
811cc67e16 Move add_requests() from dhcpmsg.c to options.c. Fixes a layering violation.
Document an ugly-as-hell code bit in ifchange.c.
Add some debugging messages for the netlink response code.
Clean headers a bit more.
2011-03-30 07:26:42 -04:00
Nicholas J. Kain
3c85228aaf Add new code for creating DHCP option data, and use it in ndhc.c. 2011-03-30 07:05:00 -04:00
Nicholas J. Kain
13d9119f3a Remove dhcpd.h. 2011-03-30 05:55:12 -04:00
Nicholas J. Kain
ef9d9d26df Move some defines out of dhcpd.h. 2011-03-30 05:37:22 -04:00
Nicholas J. Kain
ba553e5d94 Clean up end_option(), and fix a possible off-by-one in the bound check. 2010-11-14 07:50:21 -05:00
Nicholas J. Kain
5a38e49a81 Update get_option() to use the function from busybox's udhcp variant;
it's much easier to read.  The original one is indecipherable, and thus
it is difficult to verify correctness.
2010-11-14 03:41:36 -05:00
Nicholas J. Kain
edf3b02b6a Fix header include guards to not use leading underscores. 2010-11-13 06:51:57 -05:00
Nicholas J. Kain
c0703fc8c9 Handle option lists properly in script.c. 2010-11-12 18:04:54 -05:00
Nicholas J. Kain
7a09ba2cf7 Initial commit. 2010-11-12 04:02:18 -05:00