mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Set interface with longest prefix in DHCP & DHCPv6 lease
- With nested prefixes reside on different interfaces of single host (e.g., in 6to4, 2002::/16 on WAN and 2002:<IPv4>:<subnet>::/64 on LAN), current matching mechanism might return the interface with shorter prefix length instead of the longer one, if it appears later in the netlink message. Signed-off-by: Lung-Pin Chang <changlp@cs.nctu.edu.tw>
This commit is contained in:
12
src/util.c
12
src/util.c
@@ -319,6 +319,18 @@ time_t dnsmasq_time(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
int netmask_length(struct in_addr mask)
|
||||
{
|
||||
int zero_count = 0;
|
||||
|
||||
while (0x0 == (mask.s_addr & 0x1)) {
|
||||
mask.s_addr >>= 1;
|
||||
++zero_count;
|
||||
}
|
||||
|
||||
return 32 - zero_count;
|
||||
}
|
||||
|
||||
int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask)
|
||||
{
|
||||
return (a.s_addr & mask.s_addr) == (b.s_addr & mask.s_addr);
|
||||
|
||||
Reference in New Issue
Block a user