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.
are discarded, and the UDP length, IP length, and IP header size fields are
validated for consistency.
Keep track of whether the DHCP BPF has been successfully installed. If it has,
then don't perform redundant checks in DHCP validation.
Take advantage of that feature in ndhc.c when initializing the state
and config structures.
Fix some seriously stupid typos in the commit before the previous one.
is received that is discarded by ndhc's basic checks and provokes a busy
loop in the main program loop because epoll_wait() constantly sees data that
is never drained from the socket buffer since arp_offset exceeds the
maximum size of an ARP packet and would overflow the packet buffer.
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.
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.
udp packet and use them in get_raw_packet().
Print a warning if the raw UDP receive gets a quantum of data that is greater
than that of a single UDP datagram.
Remove unnecessary argument from net_checksum(). Initializing a nonzero
checksum value is not very helpful in practice.
Define a function net_checksum_add() that, for two sequences of bytes A and B
that return checksums CS(A) and CS(B), will calculate the checksum CS(AB) of
the concatenated value AB given the checksums of the individual parts CS(A)
and CS(B).
overflow when given ridiculously large data lengths. In practice, undefined
behavior would never occur with the previous function since it would have
required IP packets >128KiB bytes in length and the maximum length for an
IP packet is 64KiB.
The new checksum function is also a bit more flexible (allowing a starting
checksum value != 0), clearly is endian independent, and does no typesystem
abuse. It's boringly correct standard C.
Use C99 structure initializers for forming raw UDP packets for send.
Rename raw_packet() to send_dhcp_raw() and strip of unnecessary arguments.
Rename kernel_packet() to send_dhcp_cooked() and strip of unnecessary
arguments.
Remove the ugly bcast_raw_packet() wrapper hack.