Re: confusions in the source code
Roy Marples
Sat Apr 06 09:18:56 2013
On 05/04/2013 21:03, jayce lee wrote:
I got to read the source code and came up with some confusion. Could
you please give me some help.
in the structure if_options
struct if_options {
int metric;
uint8_t requestmask[256 / 8];
uint8_t requiremask[256 / 8];
uint8_t nomask[256 / 8];
uint8_t requestmask6[(UINT16_MAX + 1) / 8];
uint8_t requiremask6[(UINT16_MAX + 1) / 8];
uint8_t nomask6[(UINT16_MAX + 1) / 8];
……
}
there are some masks, what's the function of the mask and why for
ipv4 the size of mask is 256/8 and for ipv6 the size is UINT16_MAX +
1
/8 ?
By the way, in the parse_config process, the function
make_option_mask change the mask value in
add_option_mask(mask,opt->option);
The macro definition is #define add_option_mask(var, val) (var[val >>
3] |= 1 << (val & 7)), I can't quite get the purpose of the source
code.
Could someone give me explanations?
We store the presence or non presence of DHCP or DHCPv6 options in a
bit mask.
The macros allow easy access to it via bit shifting.
Thanks
Roy
Archive administrator: postmaster@marples.name