diff options
Diffstat (limited to 'accel-pppd/include/ipv6_dns.h')
| -rw-r--r-- | accel-pppd/include/ipv6_dns.h | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/accel-pppd/include/ipv6_dns.h b/accel-pppd/include/ipv6_dns.h index b604d006..e82812ce 100644 --- a/accel-pppd/include/ipv6_dns.h +++ b/accel-pppd/include/ipv6_dns.h @@ -3,10 +3,18 @@ #include <netinet/in.h> -#include "list.h" -#include "ipdb.h" #include "ap_session.h" +#define IPV6_DNS_INITIAL_CAPACITY 4 + +struct ipv6_dns_t { + struct in6_addr *addr; + unsigned int count; + unsigned int capacity; +}; + +int ipv6_dns_reserve(struct ipv6_dns_t *dns, unsigned int count); + /* * Pick the IPv6 DNS servers to advertise to a session. * @@ -15,34 +23,20 @@ * precedence. Sessions without any fall back to the globally configured ones, * which is what every session got before per session servers existed. * - * Up to 'max' addresses are written to 'dns', the number written is returned. - * Callers advertise nothing when that is 0. + * The selected array is returned and its length is written to 'count'. + * Callers advertise nothing when the returned count is 0. */ -static inline int ipv6_dns_get(const struct ap_session *ses, - const struct in6_addr *conf_dns, int conf_dns_count, - struct in6_addr *dns, int max) +static inline const struct in6_addr *ipv6_dns_get(const struct ap_session *ses, + const struct in6_addr *conf_dns, + int conf_dns_count, int *count) { - struct ipv6db_addr_t *a; - int count = 0; - - if (ses && ses->ipv6_dns) { - list_for_each_entry(a, &ses->ipv6_dns->addr_list, entry) { - if (count == max) - break; - dns[count++] = a->addr; - } - - /* An empty list means "nothing assigned", not "no DNS at all" */ - if (count) - return count; - } - - while (count < conf_dns_count && count < max) { - dns[count] = conf_dns[count]; - count++; + if (ses && ses->ipv6_dns && ses->ipv6_dns->count) { + *count = ses->ipv6_dns->count; + return ses->ipv6_dns->addr; } - return count; + *count = conf_dns_count; + return conf_dns; } #endif |
