Parsing options
Ted Lemon
Ted.Lemon at nominum.com
Thu Jun 16 16:49:54 UTC 2005
On Jun 16, 2005, at 6:18 AM, Erik Alap=E4=E4 wrote:
> What I need is a routine that
> simply takes a raw dhcp_packet or a dhcp packet struct as defined in
> includes/dhcpd.h and gets me lease time, circuit and remote id. Looks
> like I will have to build one from scratch :(
>
Version 3.0 of the relay agent already has code in it to abstract out =20=
the relay agent information option. You could trivially hack it to =20
also abstract out the lease information. Check out =20
strip_relay_agent_options - just add more entries to the switch =20
statement. Bear in mind that the contents of the options are in =20
network byte order and not aligned, and you need to sanity check them =20=
to avoid buffer overflows.
The reason the option parsing code is so complicated is because it =20
works both for generating options from configuration files on the =20
server side and for dumping them into shell scripts on the client =20
side - nothing so complicated is needed for the relay agent. For =20
completeness you might want to add support for the overload option, =20
but you'll probably never need it.
More information about the dhcp-hackers
mailing list