Nicholas J. Kain
4d33c00e04
Use poll() instead of epoll() for ndhc-master.
2020-10-20 05:58:29 -04:00
Nicholas J. Kain
5dc35eca6d
Merge send_renew() and send_rebind() into send_renew_or_rebind().
2020-10-19 05:26:47 -04:00
Nicholas J. Kain
23d23c108a
DHCPREQUEST in REBINDING state shouldn't have reqip option.
...
See RFC2131 pg31 paragraph 6.
2020-10-19 05:13:47 -04:00
Nicholas J. Kain
56b6ae2cd3
Quit using NULL macro.
2018-10-26 07:17:39 -04:00
Nicholas J. Kain
05a075aeb2
Replace '(c)' with 'Copyright'.
...
'(c)' may not be a valid substitute for 'Copyright' in some legal
domains/interpretations. So be safe, since I obviously am asserting
copyright on my legal work.
2018-10-26 07:11:16 -04:00
Nicholas J. Kain
8983df3c86
Update copyright dates.
2018-02-18 08:25:10 -05:00
Nicholas J. Kain
e8d97205e9
Compile cleanly with -Wsign-conversion.
...
I didn't notice anything that worried me.
2018-02-09 03:16:59 -05:00
Nicholas J. Kain
759b6bd831
Update to the new ncmlib random API.
2017-08-24 02:36:31 -04:00
Nicholas J. Kain
931530786b
Convert logically boolean client_state_t variables from uint8_t to bool.
2017-01-19 05:01:23 -05:00
Nicholas J. Kain
b8ee0bd5c2
Update copyright dates to 2017.
2017-01-13 20:15:27 -05:00
Nicholas J. Kain
c47630ffca
Rename check_carrier() to carrier_isup() and use bool return.
2017-01-12 05:25:15 -05:00
Nicholas J. Kain
6c136c3f85
Make add_option_(vendor|hostname)() not use ndhc internals.
...
This change makes it easier to fuzz test, but should have no
functional effect on ndhc's behavior.
2015-02-20 03:58:25 -05:00
Nicholas J. Kain
b3bd13d45f
Fix the return values of dhcp_packet_get and arp_packet_get.
...
This corrects a bug where stale dhcp packets would get reprocessed,
causing very bad behavior; an issue that was introduced in the
coroutine conversion.
2015-02-18 11:02:13 -05:00
Nicholas J. Kain
61387408d0
Separate event state gathering from action dispatch in main epoll loop.
...
This is the first step towards using coroutines.
2015-02-15 06:38:03 -05:00
Nicholas J. Kain
e874373dcd
Check link carrier via ifch and netlink instead of ioctl.
...
Thus, ioctl can once again be removed from the ndhc seccomp whitelist.
2015-02-15 02:50:29 -05:00
Nicholas J. Kain
b6b778831c
Add error handling for un-notified carrier downs when sending packets.
...
If a packet send failed because the carrier went down without a
netlink notification, then assume the hardware carrier was lost while
the machine was suspended (eg, ethernet cable pulled during suspend).
Simulate a netlink carrier down event and freeze the dhcp state
machine until a netlink carrier up event is received.
The ARP code is not yet handling this issue everywhere, but the
window of opportunity for it to happen there is much shorter.
2015-02-14 05:20:04 -05:00
Nicholas J. Kain
00c9479c4c
Mark more pointer arguments as never being null.
2015-02-14 01:46:02 -05:00
Nicholas J. Kain
0535b36534
dhcp.c: Make init_packet() not return a struct.
...
Just work via a pointer to not rely on the compiler being intelligent
and inlining.
2015-02-14 01:41:52 -05:00
Nicholas J. Kain
70c750f50c
get_raw_packet: The read length check is stricter than necessary.
...
Allow reads with excess data beyond the packet to succeed if the
packet is still well-formed.
2015-02-14 01:40:06 -05:00
Nicholas J. Kain
702d8b0c5b
Mark pointer arguments that cannot ever be null as [static 1].
...
Also constify some cases, too.
2015-02-13 23:14:08 -05:00
Nicholas J. Kain
cc806acc0b
Indicate that client_state_t and client_config_t pointer args
...
cannot ever be null.
Could possibly improve code generation, and makes the intention clear.
2015-02-13 22:29:03 -05:00
Nicholas J. Kain
b6554c2931
Quiet the 'UDP length [] does not match header length' message.
...
It is triggered frequently when discarding invalid packets that were
received on the DHCP port and it seems to have little significance.
2015-02-13 21:56:34 -05:00
Nicholas J. Kain
b4b6ed8fd5
Check for carrier before sendto() or write() on interface fd.
...
Linux will quietly proceed as if the data were sent even if the carrier
is down and nothing actually happened. There is still a tiny race
condition where the carrier could drop between the check and the actual
write, but we really can't do anything about that and it is a very
small race.
2015-02-13 21:53:15 -05:00
Nicholas J. Kain
c58a071f52
Update copyright dates.
2015-02-13 01:54:57 -05:00
Nicholas J. Kain
27c9e2c553
Improve fingerprinting to support DHCP relay agents.
...
Mostly reverts the previous commit and instead teaches ndhc to properly
handle the case when it is communicating with a DHCP relay agent on
its local segment rather than directly with a DHCP server.
2015-02-12 23:28:54 -05:00
Nicholas J. Kain
9f87bd8b30
udp_checksum(): Clamp the value of the UDP packet header length.
...
Without this change, it is possible for malicious UDP packets to
make the function read past the end of a buffer.
If this was ever a possibility in ndhc, the previous commit fixed
that issue, but there is no reason for udp_checksum() to have
such a subtle precondition to proper use. This change also makes
it easier to audit correctness.
2015-01-06 07:07:08 -05:00
Nicholas J. Kain
6548b5ce54
get_raw_packet(): Perform the UDP checksum after the packet length
...
checks.
This change makes it easier to verify that there can be no reads
beyond a buffer end by udp_checksum().
2015-01-06 04:32:58 -05:00
Nicholas J. Kain
c8dcf5a06b
Make sure that received DHCP packets have a valid options end marker.
2015-01-06 04:02:52 -05:00
Nicholas J. Kain
12114c9bae
Add more explicit length checks for get_raw_packet.
2014-07-25 20:34:01 -04:00
Nicholas J. Kain
ae03b6dd8f
Move the ip checksum code out to ncmlib.
2014-06-08 20:34:34 -04:00
Nicholas J. Kain
07cbd88049
Just use raw sockets for listening to DHCP requests. A UDP SO_BROADCAST
...
socket was previously used only for receiving RENEWING packets, and it
added needless complexity and was somewhat fragile.
2014-04-16 01:00:36 -04:00
Nicholas J. Kain
ca85a6ba9f
Style cleanups in dhcp.c.
2014-04-16 00:24:40 -04:00
Nicholas J. Kain
baa394af9a
UDP listen sockets should be requested with 'U' instead of 'u'.
2014-04-15 20:54:35 -04:00
Nicholas J. Kain
18604c5245
get_udp_unicast_socket() needs to have the client address as an argument
...
when sending the request to sockd.
Also, print error messages if sockd returns an invalid fd (< 0).
2014-04-15 17:55:28 -04:00
Nicholas J. Kain
58b4ba768c
If the IP header length does not match the size of the UDP packet received
...
via the raw socket, print both lengths in the warning message.
2014-04-15 15:23:52 -04:00
Nicholas J. Kain
6804be2277
Use safe_sendto where necessary, and check for short writes.
...
Also, change many log_lines to log_errors, mostly in ifset.c.
2014-04-07 04:15:02 -04:00
Nicholas J. Kain
b761889025
Move source from ndhc/ to src/ since ifchd is no longer a separate program.
2014-04-06 16:57:06 -04:00