Commit Graph

628 Commits

Author SHA1 Message Date
Nicholas J. Kain
b5e5685d01 Fetch the gateway hardware address after receiving a router option in a DHCP
lease.

Be more aggressive about closing old arp file descriptors.

Check the ARP headers to make sure that received ARP packets are addressed to
our machine.  Whatever bug may have existed before doesn't exist on modern
Linux kernels, if it ever did.

Use the stored gateway hardware address to validate a restored link in the
DS_ARP_GW_CHECK state.

If an ARP message is received while we are in a state that does not expect
ARP messages, close the ARP socket and log a message.
2011-03-30 23:17:27 -04:00
Nicholas J. Kain
e1eb41e1c0 Remove a debugging print. 2011-03-30 20:21:44 -04:00
Nicholas J. Kain
03717e1593 If physical link state changes to UP and a lease is bound, check to see if
the currently assigned gateway/router still replies to ARP queries.  If so,
keep the lease.  If not, get a new lease.

Save the IP address of the current gateway/router.
Remove an outdated check for a buggy compiler.
Fix a typo in the previous commit that caused timeouts to be 1000x faster than
they should be.
2011-03-30 20:13:48 -04:00
Nicholas J. Kain
de23d2241d Improve timeout backoff. It's a capped linear backoff. RFC specifies
capped randomized exponential, but I don't feel like incurring the cost
when the cap is so low.
Add comments for the dhcpMessage structure members.
2011-03-30 18:58:09 -04:00
Nicholas J. Kain
18e6f8d2c6 Remove a unnecessary debug print from add_u32_option(). 2011-03-30 16:41:29 -04:00
Nicholas J. Kain
953443f688 Untabify and headerize ifchange.[ch]. 2011-03-30 16:38:53 -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
16460699fc Use inet_ntop() in ifchange.c rather than a homebrew function.
Get rid of a lousy hack in ifchange.c that translated the output of ifchd_cmd()
by changing every '=' to a ':'.  ifchd_cmd() is not called anywhere else, so
just make ifchd_cmd() generate the proper output.
Make buffer size accounting stricter.
2011-03-30 11:16:38 -04:00
Nicholas J. Kain
97137ec3fc Handle STRING options properly in fill_options and refactor a bit. 2011-03-30 10:39:11 -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
6869a3ba20 Reduce log spam by removing the "adding option" print. 2011-03-30 05:33:44 -04:00
Nicholas J. Kain
d01b104d48 Handle netlink interface-up notification for non-DS_BOUND states. 2011-03-30 05:24:16 -04:00
Nicholas J. Kain
1ef44c1e4b Document DHCP options in bound_if(). 2011-03-30 05:23:46 -04:00
Nicholas J. Kain
9d03795a15 Wire up the netlink socket to the epoll handler. Still need to actually
react to events in the processing function.
Pass the client_state structure to the netlink code explicitly rather than
making it a global variable.
2011-03-29 15:34:00 -04:00
Nicholas J. Kain
55bc002ad6 Use netlink for getting interface mac and index in ndhc instead of ioctl. 2011-03-29 14:37:45 -04:00
Nicholas J. Kain
a53a82bbc5 After fork(), a signalfd-created file descriptor still returns signal info
for the parent.  Close and recreate a new signalfd after forking into the
background.
2010-12-27 10:05:43 -05:00
Nicholas J. Kain
03d3cbfdb9 Do not treat a failure to write the pid file after backgrounding after
obtaining a lease as a fatal error.
2010-12-26 18:21:58 -05:00
Nicholas J. Kain
11e71837fd Set arp socket as nonblocking. 2010-12-26 18:19:39 -05:00
Nicholas J. Kain
6f483045f4 Remove redundant #include. 2010-12-26 18:17:41 -05:00
Nicholas J. Kain
0f3d4598ad Add a missing header and remove an unused variable. 2010-12-26 15:06:16 -05:00
Nicholas J. Kain
ea4041983d Use non-blocking sockets for the listen socket. 2010-12-26 15:05:00 -05:00
Nicholas J. Kain
8b97107b8d Allow receive of short dhcp packets over raw listen sockets. 2010-12-26 15:03:14 -05:00
Nicholas J. Kain
08301a7053 Update DESIGN 2010-12-24 10:49:45 -05:00
Nicholas J. Kain
121e4d1510 Fix --hostname option. 2010-12-24 10:44:06 -05:00
Nicholas J. Kain
d96cb14711 Fix stale declaration of arp_check(). 2010-12-24 10:40:46 -05:00
Nicholas J. Kain
87b28de015 Fix --clientid option. 2010-12-24 10:27:24 -05:00
Nicholas J. Kain
c0b699ba88 Rename script.[ch] to ifchange.[ch]. 2010-12-24 10:12:41 -05:00
Nicholas J. Kain
eab048fec7 Remove old files from original ndhc. 2010-12-24 10:04:16 -05:00
Nicholas J. Kain
08f7db1637 Rename clientpacket.c to dhcpmsg.c. 2010-12-24 10:01:12 -05:00
Nicholas J. Kain
d04916aec5 Rename arpping.[ch] to arp.[ch]. 2010-12-24 09:58:47 -05:00
Nicholas J. Kain
8e905d0611 Move background() to sys.[ch]. 2010-12-24 09:47:09 -05:00
Nicholas J. Kain
59a0661eb9 Move change_listen_mode to packet.c. 2010-12-24 09:41:52 -05:00
Nicholas J. Kain
94ad810260 Move timeout and arp handling code out to arpping.c and timeout.c. 2010-12-24 09:32:58 -05:00
Nicholas J. Kain
adcc4bdd3d Move dhcp packet reply code to packet.c. 2010-12-24 08:55:59 -05:00
Nicholas J. Kain
9390e131b6 Move client runtime state structure declaration and flags to config.h. 2010-12-24 07:07:48 -05:00
Nicholas J. Kain
8a3deb3c6a Move dhcp client runtime global state into global struct client_state_t cs. 2010-12-24 07:00:42 -05:00