diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-08-12 22:44:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-12 22:44:57 +0300 |
| commit | 4f562467dbdf819395e138617c2a057e02595b9e (patch) | |
| tree | 901034d82cd545fb8974e580cbec325576b1c2a9 /accel-pppd/include/ipv6_dns.h | |
| parent | ead8a7839bf2a8dbb4358fb115ed98d688bf2c28 (diff) | |
| parent | 58ef850d1705d88f006d761d32c55bde5205a27d (diff) | |
| download | accel-ppp-4f562467dbdf819395e138617c2a057e02595b9e.tar.gz accel-ppp-4f562467dbdf819395e138617c2a057e02595b9e.zip | |
Merge pull request #344 from nuclearcat/accel-ng-ported
l2tp hidden-AVP length fix, per-session IPv6 DNS, crypto.h cleanup
Diffstat (limited to 'accel-pppd/include/ipv6_dns.h')
| -rw-r--r-- | accel-pppd/include/ipv6_dns.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/accel-pppd/include/ipv6_dns.h b/accel-pppd/include/ipv6_dns.h new file mode 100644 index 00000000..b604d006 --- /dev/null +++ b/accel-pppd/include/ipv6_dns.h @@ -0,0 +1,48 @@ +#ifndef __IPV6_DNS_H +#define __IPV6_DNS_H + +#include <netinet/in.h> + +#include "list.h" +#include "ipdb.h" +#include "ap_session.h" + +/* + * Pick the IPv6 DNS servers to advertise to a session. + * + * A session may have been assigned its own servers (currently by the radius + * module, from the DNS-Server-IPv6-Address attribute of RFC 6911); those take + * 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. + */ +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) +{ + 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++; + } + + return count; +} + +#endif |
