need some insight in udhcp structures size
Denys Vlasenko
vda.linux at googlemail.com
Fri Nov 23 13:11:39 UTC 2007
On Friday 23 November 2007 03:03, Cristian Ionescu-Idbohrn wrote:
> Thanks Denys,
>
> On Thu, 22 Nov 2007, Denys Vlasenko wrote:
> > 576 is a RFC-mandated max dhcp packet size (including IP header).
>
> Yes. I now took the time to look even at that part of rfc2131 ;)
>
> > 308, 128 and 64 are sizes of the fields, should be changed:
> >
> > - length = 308;
> > + length = sizeof(packet->options);
>
> Yes. I'll do that on the magic numbers.
It's already done in svn. Take a look.
> * what you suggest: bump the size of options, or
> * add a pad-variable to the structure
First. This way, sizeof() of options field will give correct value,
and no code changes will be needed.
> > Please document which devices need that:
> >
> > /* Should be 0 but there are buggy DHCP servers in the wild:
> > * <name of the device with buggy server> - needs N bytes
> > * ... ...
> > */
> > #define SPACE_FOR_BUGGY_DHCP_SERVERS 500
> > ...
> > options[308 + SPACE_FOR_BUGGY_DHCP_SERVERS];
> > ...
> > /* Let's see whether compiler understood us right */
> > struct BUG_bad_sizeof_struct_udp_dhcp_packet {
> > char BUG_bad_sizeof_struct_udp_dhcp_packet
> > [sizeof(struct udp_dhcp_packet) != (576 +
> > SPACE_FOR_BUGGY_DHCP_SERVERS) ? -1 : 1]; };
>
> I thought of doing that with a configuration option instead of hard
> coding. What do you think?
Config options are needed when people may want to exclude functionality
and save on code size. Here code size will be the same.
--
vda
More information about the busybox
mailing list