mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-20 02:38:32 +00:00
add general flag param to iface_enumerate IPv6 callback
This commit is contained in:
10
src/dhcp6.c
10
src/dhcp6.c
@@ -25,7 +25,7 @@ struct iface_param {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int complete_context6(struct in6_addr *local, int prefix,
|
static int complete_context6(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam);
|
int preferred, int valid, void *vparam);
|
||||||
|
|
||||||
static int make_duid1(int index, unsigned int type, char *mac, size_t maclen, void *parm);
|
static int make_duid1(int index, unsigned int type, char *mac, size_t maclen, void *parm);
|
||||||
@@ -182,7 +182,7 @@ void dhcp6_packet(time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int complete_context6(struct in6_addr *local, int prefix,
|
static int complete_context6(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad, int preferred,
|
int scope, int if_index, int flags, int preferred,
|
||||||
int valid, void *vparam)
|
int valid, void *vparam)
|
||||||
{
|
{
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
@@ -190,7 +190,7 @@ static int complete_context6(struct in6_addr *local, int prefix,
|
|||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
|
|
||||||
(void)scope; /* warning */
|
(void)scope; /* warning */
|
||||||
(void)dad;
|
(void)flags;
|
||||||
(void)preferred;
|
(void)preferred;
|
||||||
(void)valid;
|
(void)valid;
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ struct cparam {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int construct_worker(struct in6_addr *local, int prefix,
|
static int construct_worker(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam)
|
int preferred, int valid, void *vparam)
|
||||||
{
|
{
|
||||||
char ifrn_name[IFNAMSIZ];
|
char ifrn_name[IFNAMSIZ];
|
||||||
@@ -487,7 +487,7 @@ static int construct_worker(struct in6_addr *local, int prefix,
|
|||||||
struct dhcp_context *template, *context;
|
struct dhcp_context *template, *context;
|
||||||
|
|
||||||
(void)scope;
|
(void)scope;
|
||||||
(void)dad;
|
(void)flags;
|
||||||
|
|
||||||
struct cparam *param = vparam;
|
struct cparam *param = vparam;
|
||||||
|
|
||||||
|
|||||||
@@ -389,6 +389,11 @@ union mysockaddr {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* bits in flag param to IPv6 callbacks from iface_enumerate() */
|
||||||
|
#define IFACE_TENTATIVE 1
|
||||||
|
#define IFACE_DEPRECATED 2
|
||||||
|
|
||||||
|
|
||||||
#define SERV_FROM_RESOLV 1 /* 1 for servers from resolv, 0 for command line. */
|
#define SERV_FROM_RESOLV 1 /* 1 for servers from resolv, 0 for command line. */
|
||||||
#define SERV_NO_ADDR 2 /* no server, this domain is local only */
|
#define SERV_NO_ADDR 2 /* no server, this domain is local only */
|
||||||
#define SERV_LITERAL_ADDRESS 4 /* addr is the answer, not the server */
|
#define SERV_LITERAL_ADDRESS 4 /* addr is the answer, not the server */
|
||||||
|
|||||||
@@ -363,13 +363,13 @@ static int find_interface_v4(struct in_addr local, int if_index,
|
|||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
static int find_interface_v6(struct in6_addr *local, int prefix,
|
static int find_interface_v6(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam)
|
int preferred, int valid, void *vparam)
|
||||||
{
|
{
|
||||||
struct dhcp_lease *lease;
|
struct dhcp_lease *lease;
|
||||||
|
|
||||||
(void)scope;
|
(void)scope;
|
||||||
(void)dad;
|
(void)flags;
|
||||||
(void)preferred;
|
(void)preferred;
|
||||||
(void)valid;
|
(void)valid;
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
{
|
{
|
||||||
struct in6_addr *addrp = NULL;
|
struct in6_addr *addrp = NULL;
|
||||||
u32 valid = 0, preferred = 0;
|
u32 valid = 0, preferred = 0;
|
||||||
|
int flags = 0;
|
||||||
|
|
||||||
while (RTA_OK(rta, len1))
|
while (RTA_OK(rta, len1))
|
||||||
{
|
{
|
||||||
if (rta->rta_type == IFA_ADDRESS)
|
if (rta->rta_type == IFA_ADDRESS)
|
||||||
@@ -252,9 +254,15 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
rta = RTA_NEXT(rta, len1);
|
rta = RTA_NEXT(rta, len1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ifa->ifa_flags & IFA_F_TENTATIVE)
|
||||||
|
flags |= IFACE_TENTATIVE;
|
||||||
|
|
||||||
|
if (ifa->ifa_flags & IFA_F_DEPRECATED)
|
||||||
|
flags |= IFACE_DEPRECATED;
|
||||||
|
|
||||||
if (addrp && callback_ok)
|
if (addrp && callback_ok)
|
||||||
if (!((*callback)(addrp, (int)(ifa->ifa_prefixlen), (int)(ifa->ifa_scope),
|
if (!((*callback)(addrp, (int)(ifa->ifa_prefixlen), (int)(ifa->ifa_scope),
|
||||||
(int)(ifa->ifa_index), (int)(ifa->ifa_flags & IFA_F_TENTATIVE),
|
(int)(ifa->ifa_index), flags,
|
||||||
(int) preferred, (int)valid, parm)))
|
(int) preferred, (int)valid, parm)))
|
||||||
callback_ok = 0;
|
callback_ok = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
static int iface_allowed_v6(struct in6_addr *local, int prefix,
|
static int iface_allowed_v6(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam)
|
int preferred, int valid, void *vparam)
|
||||||
{
|
{
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
@@ -312,7 +312,7 @@ static int iface_allowed_v6(struct in6_addr *local, int prefix,
|
|||||||
addr.in6.sin6_port = htons(daemon->port);
|
addr.in6.sin6_port = htons(daemon->port);
|
||||||
addr.in6.sin6_scope_id = if_index;
|
addr.in6.sin6_scope_id = if_index;
|
||||||
|
|
||||||
return iface_allowed((struct irec **)vparam, if_index, &addr, netmask, dad);
|
return iface_allowed((struct irec **)vparam, if_index, &addr, netmask, !!(flags & IFACE_TENTATIVE));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
13
src/radv.c
13
src/radv.c
@@ -40,10 +40,10 @@ struct search_param {
|
|||||||
|
|
||||||
static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest);
|
static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest);
|
||||||
static int add_prefixes(struct in6_addr *local, int prefix,
|
static int add_prefixes(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam);
|
int preferred, int valid, void *vparam);
|
||||||
static int iface_search(struct in6_addr *local, int prefix,
|
static int iface_search(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int prefered, int valid, void *vparam);
|
int prefered, int valid, void *vparam);
|
||||||
static int add_lla(int index, unsigned int type, char *mac, size_t maclen, void *parm);
|
static int add_lla(int index, unsigned int type, char *mac, size_t maclen, void *parm);
|
||||||
|
|
||||||
@@ -325,13 +325,13 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int add_prefixes(struct in6_addr *local, int prefix,
|
static int add_prefixes(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam)
|
int preferred, int valid, void *vparam)
|
||||||
{
|
{
|
||||||
struct ra_param *param = vparam;
|
struct ra_param *param = vparam;
|
||||||
|
|
||||||
(void)scope; /* warning */
|
(void)scope; /* warning */
|
||||||
(void)dad;
|
(void)flags;
|
||||||
(void)preferred;
|
(void)preferred;
|
||||||
(void)valid;
|
(void)valid;
|
||||||
|
|
||||||
@@ -526,14 +526,13 @@ time_t periodic_ra(time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int iface_search(struct in6_addr *local, int prefix,
|
static int iface_search(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad,
|
int scope, int if_index, int flags,
|
||||||
int preferred, int valid, void *vparam)
|
int preferred, int valid, void *vparam)
|
||||||
{
|
{
|
||||||
struct search_param *param = vparam;
|
struct search_param *param = vparam;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
|
||||||
(void)scope;
|
(void)scope;
|
||||||
(void)dad;
|
|
||||||
(void)preferred;
|
(void)preferred;
|
||||||
(void)valid;
|
(void)valid;
|
||||||
|
|
||||||
@@ -549,7 +548,7 @@ static int iface_search(struct in6_addr *local, int prefix,
|
|||||||
timeout value and arrange for RA to be sent unless interface is
|
timeout value and arrange for RA to be sent unless interface is
|
||||||
still doing DAD.*/
|
still doing DAD.*/
|
||||||
|
|
||||||
if (!dad)
|
if (!(flags & IFACE_TENTATIVE))
|
||||||
param->iface = if_index;
|
param->iface = if_index;
|
||||||
|
|
||||||
if (difftime(param->now, context->ra_short_period_start) < 60.0)
|
if (difftime(param->now, context->ra_short_period_start) < 60.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user