mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-02 13:30:32 +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:
1 parent
cdb755c5f1
commit
dc8a1b1bcf
3 files changed
+47
-9
No files matched your search
+12
@@ -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