Commit Graph

  • 7d5b6ddc7e Whitelist clock_gettime() for seccomp. Not necessary so long as vdso is enabled, but otherwise... Nicholas J. Kain 2012-07-21 19:46:50 -0400
  • b53b8585d5 Use clock_gettime(CLOCK_MONOTONIC) instead of time() in ifchd. Standardize license/copyright and version prints. Nicholas J. Kain 2012-07-21 14:02:42 -0400
  • 87db9c70fd Enforce minimum physical MTU in ifchd. Skip zero-length commands in execute_buffer(). Nicholas J. Kain 2012-07-20 20:37:41 -0400
  • 2bf7306bb9 Add some more syscalls to the ndhc permit filter. Netlink sockets were broken before because of too-strict filters. Nicholas J. Kain 2012-07-20 18:48:26 -0400
  • f9c2059d37 Quit using malloc entirely in ifchd and reduce buffer copies. Nicholas J. Kain 2012-07-20 17:31:15 -0400
  • a60a5fddb1 Remove use of dynamic memory (strlist_t) from linux.c. Nicholas J. Kain 2012-07-20 15:17:44 -0400
  • 6e9d856a9d Code cleanup. Create struct ifchd_client and pull all of the global static arrays that are indexed by the socket slot index into an array of struct ifchd_clients. Nicholas J. Kain 2012-07-20 14:56:17 -0400
  • c3272f07f4 Update copyright and license print spam. Nicholas J. Kain 2012-07-20 09:37:41 -0400
  • 25ce5cceaa Use seccomp system call filtering if present. Nicholas J. Kain 2012-07-20 09:23:18 -0400
  • f4f9d02afd Enforce seccomp syscall restrictions when kernel support exists. Nicholas J. Kain 2012-07-20 07:05:56 -0400
  • e990246207 Move nlbuf onto stack and don't share a single buffer for sending and receiving. Move nlportid into client state structure. Nicholas J. Kain 2012-04-12 20:06:05 -0400
  • 659aafaec8 Silence new kernel warning introduced in 3.3: 'netlink: 12 bytes leftover after parsing attributes.' RTM_GETLINK messages should have a struct rtattr as payload. Nicholas J. Kain 2012-04-12 04:52:26 -0400
  • a8a761da14 Shrink stack use of nl_getifdata(). Nicholas J. Kain 2012-04-03 22:00:47 -0400
  • 93b44ed48d Tidy up nl_getifdata() a bit. Eliminate some unnecessary local variables, and use NLMSG_LENGTH(). Nicholas J. Kain 2012-04-03 10:06:00 -0400
  • a419b85e4f Typo fix in documentation. Nicholas J. Kain 2012-04-03 10:04:58 -0400
  • c3c76e48d5 Enable stricter warnings on format strings. Nicholas J. Kain 2012-04-03 10:04:47 -0400
  • ed2ffbb862 Constify some invariant structures. Nicholas J. Kain 2011-09-17 02:30:52 -0400
  • 071e91941f Unify options.[ch] with the one used in ndhs. Nicholas J. Kain 2011-09-02 02:12:51 -0400
  • 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. Nicholas J. Kain 2011-09-01 23:05:56 -0400
  • ab4a2e0b97 Switch to using clock_gettime() rather than gettimeofday(). Nicholas J. Kain 2011-07-31 01:27:59 -0400
  • 45c76dd548 More comment cleanups. Make the DHCP packet field comments more accurate. Nicholas J. Kain 2011-07-27 08:03:42 -0400
  • f864a0317c Cosmetic cleanups of comments. Nicholas J. Kain 2011-07-27 07:49:30 -0400
  • 916ddf10e5 Update documentation: options concatenation is now supported. Nicholas J. Kain 2011-07-27 07:43:09 -0400
  • 13f5ab56e2 Rewrite DHCP options parsing to conform to RFC 3396: options concatenation is now fully supported. Nicholas J. Kain 2011-07-27 07:39:45 -0400
  • 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 ':'. Nicholas J. Kain 2011-07-27 00:42:16 -0400
  • 7ef7fa8a8d Fix the return value of ifchd_cmd_str() and correct its length check. Nicholas J. Kain 2011-07-27 00:37:11 -0400
  • 17a2403635 Cosmetic fixes. Nicholas J. Kain 2011-07-26 06:43:12 -0400
  • f2618ef79d Delete a lot of code that is now unused thanks to the previous commit. Nicholas J. Kain 2011-07-26 06:24:30 -0400
  • 0431b7d439 Replace the options -> ifchd command code with a much simpler translator. Nicholas J. Kain 2011-07-26 06:15:21 -0400
  • b935180a2f Just keep a statically constructed options request payload. It's simpler and more compact. Nicholas J. Kain 2011-07-26 01:58:05 -0400
  • 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. Nicholas J. Kain 2011-07-26 01:04:59 -0400
  • 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. Nicholas J. Kain 2011-07-25 23:48:35 -0400
  • 286548b754 Encapsulate all numeric option additions into options.c. Nicholas J. Kain 2011-07-25 23:34:32 -0400
  • 0229373378 Remove the overkill type checking for sent options. Nicholas J. Kain 2011-07-25 04:34:14 -0400
  • 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. Nicholas J. Kain 2011-07-25 04:26:34 -0400
  • e4a4c58856 BADOPTION -> BAD Nicholas J. Kain 2011-07-25 03:45:05 -0400
  • 8caf9e7d7a Remove support for RFC868 Time Server options. Totally obsolete, and ifchd just had empty hooks that never received work messages anyway. Nicholas J. Kain 2011-07-25 03:39:17 -0400
  • 544a837944 Shrink and reorder the options table. Nicholas J. Kain 2011-07-25 03:28:04 -0400
  • 2cb0b9227d Consolidate DHCP option code numbers. Nicholas J. Kain 2011-07-25 03:11:47 -0400
  • 77af1d81fe Relicense under New BSD (2-clause) license. I don't see any advantage to restricting use unnecessarily, and simple attribution is fine. Nicholas J. Kain 2011-07-25 02:30:57 -0400
  • 7e1e902b34 Share ifchd command defines between ifchd and ndhc. Nicholas J. Kain 2011-07-25 02:01:38 -0400
  • fe85e52a4b Be less harsh to udhcp in HISTORY... there was no better choice among the considered options at the time. Nicholas J. Kain 2011-07-24 18:02:25 -0400
  • 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. Nicholas J. Kain 2011-07-18 10:47:35 -0400
  • 27081be84f Make netlink action logging messages more consistent: prefix with 'nl: ' and always print the actual interface identifier. Nicholas J. Kain 2011-07-18 10:29:36 -0400
  • 19ad80bb57 Minor doc fix. I'm going to keep using libcap. Nicholas J. Kain 2011-07-13 04:54:15 -0400
  • 24db573005 Write man pages and do some misc cleanup on old files. Add more documentation to the README. Nicholas J. Kain 2011-07-13 02:30:10 -0400
  • 2a1885bab4 Move the objs directory underneath the build directory when building with the Makefile. Nicholas J. Kain 2011-07-12 18:45:29 -0400
  • 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. Nicholas J. Kain 2011-07-12 04:09:05 -0400
  • efe50a30a6 Even more cosmetic log message changes. Nicholas J. Kain 2011-07-11 23:51:55 -0400
  • 0a0c74efcc Yet more log message tweaking. Nicholas J. Kain 2011-07-11 23:45:37 -0400
  • 8f80a10905 Remove some redundant log messages, and make the forced-release print a bit more user-friendly. Nicholas J. Kain 2011-07-11 23:41:38 -0400
  • af365be9b7 Convert all inet_aton() to inet_pton() since inet_pton() is POSIX. Nicholas J. Kain 2011-07-11 17:11:19 -0400
  • 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. Nicholas J. Kain 2011-07-11 17:02:32 -0400
  • 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. Nicholas J. Kain 2011-07-11 16:33:57 -0400
  • 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. Nicholas J. Kain 2011-07-11 13:24:59 -0400
  • 83594bce4a Track pending events in time by using absolute times rather than relative timeouts. Nicholas J. Kain 2011-07-11 11:31:27 -0400
  • 9b3e1872cb Rather than use a single cs.timeout value, track individual timeouts for every ARP state and for the current DHCP state. Nicholas J. Kain 2011-07-11 10:39:36 -0400
  • 8c30c82240 Optimize timeout calculations so that curms() is called fewer times and the timeout intervals are a bit more exact. Nicholas J. Kain 2011-07-11 08:59:50 -0400
  • 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. Nicholas J. Kain 2011-07-11 08:01:56 -0400
  • 9762fa5315 Constify some more static structs. Nicholas J. Kain 2011-07-11 05:35:40 -0400
  • 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. Nicholas J. Kain 2011-07-11 05:09:38 -0400
  • 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. Nicholas J. Kain 2011-07-06 11:41:49 -0400
  • 080fefaea0 Handle hardware link state loss and restoration on networks that lack a default gw properly. Nicholas J. Kain 2011-07-06 11:32:22 -0400
  • 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. Nicholas J. Kain 2011-07-06 09:26:07 -0400
  • a92cb1c4c6 Randomize the DHCP timeout by +[0,1000]ms to comply with RFC. Nicholas J. Kain 2011-07-06 08:46:05 -0400
  • 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. Nicholas J. Kain 2011-07-05 19:25:19 -0400
  • 3316505f3c Define set_released() and use it for entering the DS_RELEASED state. Nicholas J. Kain 2011-07-05 18:29:06 -0400
  • 3f496f7997 Clean up frenew(). It should only perform work in DS_RELEASED and DS_BOUND. Nicholas J. Kain 2011-07-05 18:18:57 -0400
  • 04c380cd3b Call arp_close_fd() from reinit_selecting(). Nicholas J. Kain 2011-07-05 16:02:11 -0400
  • 3205f823d9 Handle DS_REBINDING and DS_RENEWING states just like DS_BOUND when the hardware link returns after having been lost. Nicholas J. Kain 2011-07-05 15:57:11 -0400
  • 3196ad750e cs->packetNum is not descriptive and is not used outside of state.c. Rename it to num_dhcp_requests that is a static global to state.c. Nicholas J. Kain 2011-07-05 15:44:11 -0400
  • 315cf6b135 Send probe requests in COLLISION_CHECK state in a way that is compliant with RFC5227. Rate-limiting is also supported. Nicholas J. Kain 2011-07-05 15:40:57 -0400
  • 751ef43b45 Remove DEBUG prints. Nicholas J. Kain 2011-07-05 13:04:34 -0400
  • 8b27b41c0c Enable active defense of IP address / lease, as described in RFC5227. Nicholas J. Kain 2011-07-05 13:03:55 -0400
  • 74a79314d7 Document the --vendorid and --leasefile options in --help. Nicholas J. Kain 2011-07-05 11:18:28 -0400
  • f9809d74a4 Remove the -H alias for --hostname. Nicholas J. Kain 2011-07-05 11:14:35 -0400
  • f1fcd4dc16 Perform timeout-based ARP retransmission for AS_GW_CHECK and AS_GW_QUERY. Nicholas J. Kain 2011-07-05 11:07:42 -0400
  • a9c807c1df Rename DS_ARP_CHECK to the less confusing DS_COLLISION_CHECK. Nicholas J. Kain 2011-07-04 22:59:07 -0400
  • b3acad9166 Use reinit_selecting() in arp.c. Nicholas J. Kain 2011-07-04 22:52:53 -0400
  • c79c65454c If sending on the arp fd fails, then re-open the arp fd and restore arp state to what it was before closing the fd. It may allow the client to continue working in the face of error, as arp functionality is not critical for simply holding a lease. Nicholas J. Kain 2011-07-04 22:35:53 -0400
  • 4453391154 Move dhcp state handling code out of netlink.c and into state.c. netlink.c now just calls hooks exposed by state.c, just like the dhcp packet, poll timeout, and signal code. Nicholas J. Kain 2011-07-04 22:10:14 -0400
  • 88804e0102 Cache the last configured dhcp packet in ifchange.c. Only send updates that differ from what already existed. Nicholas J. Kain 2011-07-04 21:40:32 -0400
  • 9ef66af020 Simplify the ifchange API. Nicholas J. Kain 2011-07-04 20:51:27 -0400
  • bb83b14237 Refactor the common ARP structure fields between arp sending functions into the BASE_ARPMSG() macro to make it more obvious what is shared. Nicholas J. Kain 2011-07-04 20:19:30 -0400
  • dca662cd27 Massive overhaul to arp.c in preparation for adding address defense: Nicholas J. Kain 2011-07-04 20:07:16 -0400
  • be44bf0a04 Resequence operations in selecting_timeout() so that two packets are sent with corresponding waits for responses rather than sending two packets and immediately backgrounding or failing after the second is sent without waiting for a response. Nicholas J. Kain 2011-07-03 18:56:57 -0400
  • e4ff1e9261 Remove the ugly hack for forcing nl_getifdata() to be synchronous. It now properly performs a synchronous wait using poll(). Nicholas J. Kain 2011-07-03 18:10:00 -0400
  • 01c4731403 Make sure that the netlink socket will never block after program initialization. Fetching if/address/index/mac mappings is done only once at program init, so it is done synchronously as an exception to this rule. Nicholas J. Kain 2011-07-03 17:30:55 -0400
  • 2c2cc1cf22 Don't send host name option on DHCP decline or release packets. Nicholas J. Kain 2011-07-03 06:03:54 -0400
  • aa61d71f7d Autodetect if the clientid parameter is a valid mac address and treat it accordingly. Don't require an explicit parameter for it. Nicholas J. Kain 2011-07-03 05:45:05 -0400
  • f08c174725 Add clientid-mac option for sending a MAC address as a client identifier other than our own. Nicholas J. Kain 2011-07-03 05:36:47 -0400
  • f84cdbde1e Fix regression: Make the clientid to attach the ethernet type byte prefix to the option. Nicholas J. Kain 2011-07-03 04:33:16 -0400
  • 801ec356f4 Convert DHCP option code numbers to an enum. Convert many remaining /**/ comments to // where it makes for less visual clutter. Nicholas J. Kain 2011-07-02 06:31:57 -0400
  • 9224374d98 Send an ARP announcement after getting a new lease. Nicholas J. Kain 2011-07-02 05:48:24 -0400
  • d304fb6b38 Only bring down the interface at startup time if it is not already up and running. ndhc does its job entirely with raw sockets before a lease is established, so it will work just fine, and this change allows for the dhcp client to be re-run without causing downtime on an interface. Nicholas J. Kain 2011-07-02 04:58:58 -0400
  • 46ed7f5998 Enforce stronger type checking on DHCP option values. Fix some endianness issues as well. Nicholas J. Kain 2011-07-02 04:45:11 -0400
  • cfd9822252 Rename packet.[ch] to dhcp.[ch]. Nicholas J. Kain 2011-07-02 03:51:44 -0400
  • d9571c62cf Don't use malloc in ndhc. The only place it was used is in the options code. Nicholas J. Kain 2011-07-02 03:48:08 -0400
  • 7104b56ab9 Change netlink event handling so that the DHCP client will sleep if the interface carrier is lost or the interface is deconfigured but still exists, eg via ifconfig down. If the hardware is removed, then ndhcp will exit. Nicholas J. Kain 2011-07-02 01:51:32 -0400
  • 17570e9a38 Rewrite the netlink handling code to use libmnl. The size cost is very small, and it is hard to do netlink completely correctly as it is poorly documented. Nicholas J. Kain 2011-07-02 01:34:50 -0400