"Fossies" - the Fresh Open Source Software Archive  

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

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

edns0.c  (dnsmasq-2.80):edns0.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 303 skipping to change at line 303
if ((maclen = find_mac(l3, mac, 1, now)) != 0) if ((maclen = find_mac(l3, mac, 1, now)) != 0)
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_MAC, mac , maclen, 0, 0); plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_MAC, mac , maclen, 0, 0);
return plen; return plen;
} }
struct subnet_opt { struct subnet_opt {
u16 family; u16 family;
u8 source_netmask, scope_netmask; u8 source_netmask, scope_netmask;
#ifdef HAVE_IPV6
u8 addr[IN6ADDRSZ]; u8 addr[IN6ADDRSZ];
#else
u8 addr[INADDRSZ];
#endif
}; };
static void *get_addrp(union mysockaddr *addr, const short family) static void *get_addrp(union mysockaddr *addr, const short family)
{ {
#ifdef HAVE_IPV6
if (family == AF_INET6) if (family == AF_INET6)
return &addr->in6.sin6_addr; return &addr->in6.sin6_addr;
#endif
return &addr->in.sin_addr; return &addr->in.sin_addr;
} }
static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source) static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source)
{ {
/* http://tools.ietf.org/html/draft-vandergaast-edns-client-subnet-02 */ /* http://tools.ietf.org/html/draft-vandergaast-edns-client-subnet-02 */
int len; int len;
void *addrp = NULL; void *addrp = NULL;
int sa_family = source->sa.sa_family; int sa_family = source->sa.sa_family;
opt->source_netmask = 0; opt->source_netmask = 0;
opt->scope_netmask = 0; opt->scope_netmask = 0;
#ifdef HAVE_IPV6
if (source->sa.sa_family == AF_INET6 && daemon->add_subnet6) if (source->sa.sa_family == AF_INET6 && daemon->add_subnet6)
{ {
opt->source_netmask = daemon->add_subnet6->mask; opt->source_netmask = daemon->add_subnet6->mask;
if (daemon->add_subnet6->addr_used) if (daemon->add_subnet6->addr_used)
{ {
sa_family = daemon->add_subnet6->addr.sa.sa_family; sa_family = daemon->add_subnet6->addr.sa.sa_family;
addrp = get_addrp(&daemon->add_subnet6->addr, sa_family); addrp = get_addrp(&daemon->add_subnet6->addr, sa_family);
} }
else else
addrp = &source->in6.sin6_addr; addrp = &source->in6.sin6_addr;
} }
#endif
if (source->sa.sa_family == AF_INET && daemon->add_subnet4) if (source->sa.sa_family == AF_INET && daemon->add_subnet4)
{ {
opt->source_netmask = daemon->add_subnet4->mask; opt->source_netmask = daemon->add_subnet4->mask;
if (daemon->add_subnet4->addr_used) if (daemon->add_subnet4->addr_used)
{ {
sa_family = daemon->add_subnet4->addr.sa.sa_family; sa_family = daemon->add_subnet4->addr.sa.sa_family;
addrp = get_addrp(&daemon->add_subnet4->addr, sa_family); addrp = get_addrp(&daemon->add_subnet4->addr, sa_family);
} }
else else
addrp = &source->in.sin_addr; addrp = &source->in.sin_addr;
} }
#ifdef HAVE_IPV6
opt->family = htons(sa_family == AF_INET6 ? 2 : 1); opt->family = htons(sa_family == AF_INET6 ? 2 : 1);
#else
opt->family = htons(1);
#endif
len = 0; len = 0;
if (addrp && opt->source_netmask != 0) if (addrp && opt->source_netmask != 0)
{ {
len = ((opt->source_netmask - 1) >> 3) + 1; len = ((opt->source_netmask - 1) >> 3) + 1;
memcpy(opt->addr, addrp, len); memcpy(opt->addr, addrp, len);
if (opt->source_netmask & 7) if (opt->source_netmask & 7)
opt->addr[len-1] &= 0xff << (8 - (opt->source_netmask & 7)); opt->addr[len-1] &= 0xff << (8 - (opt->source_netmask & 7));
} }
 End of changes. 9 change blocks. 
13 lines changed or deleted 1 lines changed or added

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