"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/bpf.c" between
dnsmasq-2.80.tar.gz and dnsmasq-2.81.tar.xz

About: Dnsmasq is a lightweight caching DNS forwarder and DHCP server.

bpf.c  (dnsmasq-2.80):bpf.c  (dnsmasq-2.81.tar.xz)
/* dnsmasq is Copyright (c) 2000-2018 Simon Kelley /* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991, or the Free Software Foundation; version 2 dated June, 1991, or
(at your option) version 3 dated 29 June, 2007. (at your option) version 3 dated 29 June, 2007.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 34 skipping to change at line 34
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
#include <net/if.h> #include <net/if.h>
#include <net/route.h> #include <net/route.h>
#include <net/if_dl.h> #include <net/if_dl.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
# include <net/if_var.h> # include <net/if_var.h>
#endif #endif
#include <netinet/in_var.h> #include <netinet/in_var.h>
#ifdef HAVE_IPV6 #include <netinet6/in6_var.h>
# include <netinet6/in6_var.h>
#endif
#ifndef SA_SIZE #ifndef SA_SIZE
#define SA_SIZE(sa) \ #define SA_SIZE(sa) \
( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \ ( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \
sizeof(long) : \ sizeof(long) : \
1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) ) 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) )
#endif #endif
#ifdef HAVE_BSD_NETWORK #ifdef HAVE_BSD_NETWORK
static int del_family = 0; static int del_family = 0;
static struct all_addr del_addr; static union all_addr del_addr;
#endif #endif
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__) #if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
int arp_enumerate(void *parm, int (*callback)()) int arp_enumerate(void *parm, int (*callback)())
{ {
int mib[6]; int mib[6];
size_t needed; size_t needed;
char *next; char *next;
struct rt_msghdr *rtm; struct rt_msghdr *rtm;
skipping to change at line 123 skipping to change at line 121
return 0; /* need code for Solaris and MacOS*/ return 0; /* need code for Solaris and MacOS*/
#endif #endif
/* AF_LINK doesn't exist in Linux, so we can't use it in our API */ /* AF_LINK doesn't exist in Linux, so we can't use it in our API */
if (family == AF_LOCAL) if (family == AF_LOCAL)
family = AF_LINK; family = AF_LINK;
if (getifaddrs(&head) == -1) if (getifaddrs(&head) == -1)
return 0; return 0;
#if defined(HAVE_BSD_NETWORK) && defined(HAVE_IPV6) #if defined(HAVE_BSD_NETWORK)
if (family == AF_INET6) if (family == AF_INET6)
fd = socket(PF_INET6, SOCK_DGRAM, 0); fd = socket(PF_INET6, SOCK_DGRAM, 0);
#endif #endif
for (addrs = head; addrs; addrs = addrs->ifa_next) for (addrs = head; addrs; addrs = addrs->ifa_next)
{ {
if (addrs->ifa_addr->sa_family == family) if (addrs->ifa_addr->sa_family == family)
{ {
int iface_index = if_nametoindex(addrs->ifa_name); int iface_index = if_nametoindex(addrs->ifa_name);
if (iface_index == 0 || !addrs->ifa_addr || if (iface_index == 0 || !addrs->ifa_addr ||
(!addrs->ifa_netmask && family != AF_LINK)) (!addrs->ifa_netmask && family != AF_LINK))
continue; continue;
if (family == AF_INET) if (family == AF_INET)
{ {
struct in_addr addr, netmask, broadcast; struct in_addr addr, netmask, broadcast;
addr = ((struct sockaddr_in *) addrs->ifa_addr)->sin_addr; addr = ((struct sockaddr_in *) addrs->ifa_addr)->sin_addr;
#ifdef HAVE_BSD_NETWORK #ifdef HAVE_BSD_NETWORK
if (del_family == AF_INET && del_addr.addr.addr4.s_addr == addr.s_a ddr) if (del_family == AF_INET && del_addr.addr4.s_addr == addr.s_addr)
continue; continue;
#endif #endif
netmask = ((struct sockaddr_in *) addrs->ifa_netmask)->sin_addr; netmask = ((struct sockaddr_in *) addrs->ifa_netmask)->sin_addr;
if (addrs->ifa_broadaddr) if (addrs->ifa_broadaddr)
broadcast = ((struct sockaddr_in *) addrs->ifa_broadaddr)->sin_ad dr; broadcast = ((struct sockaddr_in *) addrs->ifa_broadaddr)->sin_ad dr;
else else
broadcast.s_addr = 0; broadcast.s_addr = 0;
if (!((*callback)(addr, iface_index, NULL, netmask, broadcast, parm ))) if (!((*callback)(addr, iface_index, NULL, netmask, broadcast, parm )))
goto err; goto err;
} }
#ifdef HAVE_IPV6
else if (family == AF_INET6) else if (family == AF_INET6)
{ {
struct in6_addr *addr = &((struct sockaddr_in6 *) addrs->ifa_addr)- >sin6_addr; struct in6_addr *addr = &((struct sockaddr_in6 *) addrs->ifa_addr)- >sin6_addr;
unsigned char *netmask = (unsigned char *) &((struct sockaddr_in6 * ) addrs->ifa_netmask)->sin6_addr; unsigned char *netmask = (unsigned char *) &((struct sockaddr_in6 * ) addrs->ifa_netmask)->sin6_addr;
int scope_id = ((struct sockaddr_in6 *) addrs->ifa_addr)->sin6_scop e_id; int scope_id = ((struct sockaddr_in6 *) addrs->ifa_addr)->sin6_scop e_id;
int i, j, prefix = 0; int i, j, prefix = 0;
u32 valid = 0xffffffff, preferred = 0xffffffff; u32 valid = 0xffffffff, preferred = 0xffffffff;
int flags = 0; int flags = 0;
#ifdef HAVE_BSD_NETWORK #ifdef HAVE_BSD_NETWORK
if (del_family == AF_INET6 && IN6_ARE_ADDR_EQUAL(&del_addr.addr.add r6, addr)) if (del_family == AF_INET6 && IN6_ARE_ADDR_EQUAL(&del_addr.addr6, a ddr))
continue; continue;
#endif #endif
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__) #if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
struct in6_ifreq ifr6; struct in6_ifreq ifr6;
memset(&ifr6, 0, sizeof(ifr6)); memset(&ifr6, 0, sizeof(ifr6));
safe_strncpy(ifr6.ifr_name, addrs->ifa_name, sizeof(ifr6.ifr_name)) ; safe_strncpy(ifr6.ifr_name, addrs->ifa_name, sizeof(ifr6.ifr_name)) ;
ifr6.ifr_addr = *((struct sockaddr_in6 *) addrs->ifa_addr); ifr6.ifr_addr = *((struct sockaddr_in6 *) addrs->ifa_addr);
if (fd != -1 && ioctl(fd, SIOCGIFAFLAG_IN6, &ifr6) != -1) if (fd != -1 && ioctl(fd, SIOCGIFAFLAG_IN6, &ifr6) != -1)
skipping to change at line 221 skipping to change at line 218
if (!option_bool(OPT_NOWILD) && IN6_IS_ADDR_LINKLOCAL(addr)) if (!option_bool(OPT_NOWILD) && IN6_IS_ADDR_LINKLOCAL(addr))
{ {
addr->s6_addr[2] = 0; addr->s6_addr[2] = 0;
addr->s6_addr[3] = 0; addr->s6_addr[3] = 0;
} }
if (!((*callback)(addr, prefix, scope_id, iface_index, flags, if (!((*callback)(addr, prefix, scope_id, iface_index, flags,
(int) preferred, (int)valid, parm))) (int) preferred, (int)valid, parm)))
goto err; goto err;
} }
#endif /* HAVE_IPV6 */
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
else if (family == AF_LINK) else if (family == AF_LINK)
{ {
/* Assume ethernet again here */ /* Assume ethernet again here */
struct sockaddr_dl *sdl = (struct sockaddr_dl *) addrs->ifa_addr; struct sockaddr_dl *sdl = (struct sockaddr_dl *) addrs->ifa_addr;
if (sdl->sdl_alen != 0 && if (sdl->sdl_alen != 0 &&
!((*callback)(iface_index, ARPHRD_ETHER, LLADDR(sdl), sdl->sdl_ alen, parm))) !((*callback)(iface_index, ARPHRD_ETHER, LLADDR(sdl), sdl->sdl_ alen, parm)))
goto err; goto err;
} }
skipping to change at line 426 skipping to change at line 422
for (i = 0, of = sizeof(struct ifa_msghdr); of < rc && i < sizeof(maskve c)/sizeof(maskvec[0]); i++) for (i = 0, of = sizeof(struct ifa_msghdr); of < rc && i < sizeof(maskve c)/sizeof(maskvec[0]); i++)
if (mask & maskvec[i]) if (mask & maskvec[i])
{ {
struct sockaddr *sa = (struct sockaddr *)((char *)msg + of); struct sockaddr *sa = (struct sockaddr *)((char *)msg + of);
size_t diff = (sa->sa_len != 0) ? sa->sa_len : sizeof(long); size_t diff = (sa->sa_len != 0) ? sa->sa_len : sizeof(long);
if (maskvec[i] == RTA_IFA) if (maskvec[i] == RTA_IFA)
{ {
del_family = sa->sa_family; del_family = sa->sa_family;
if (del_family == AF_INET) if (del_family == AF_INET)
del_addr.addr.addr4 = ((struct sockaddr_in *)sa)->sin_addr; del_addr.addr4 = ((struct sockaddr_in *)sa)->sin_addr;
#ifdef HAVE_IPV6
else if (del_family == AF_INET6) else if (del_family == AF_INET6)
del_addr.addr.addr6 = ((struct sockaddr_in6 *)sa)->sin6_addr; del_addr.addr6 = ((struct sockaddr_in6 *)sa)->sin6_addr;
#endif
else else
del_family = 0; del_family = 0;
} }
of += diff; of += diff;
/* round up as needed */ /* round up as needed */
if (diff & (sizeof(long) - 1)) if (diff & (sizeof(long) - 1))
of += sizeof(long) - (diff & (sizeof(long) - 1)); of += sizeof(long) - (diff & (sizeof(long) - 1));
} }
 End of changes. 10 change blocks. 
14 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)