IPV6PREFIX is set when Framed-IPv6-Prefix is defined, You may
want to pass the value to upper layer protocol such as DHCPv6 for prefix delegation. MFC after: 1 week
This commit is contained in:
parent
d13b5b3cdf
commit
ec3e98b8de
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116622
@ -492,6 +492,22 @@ substipv6(char *tgt, const char *oldstr, const struct ncpaddr *ip)
|
||||
{
|
||||
return subst(tgt, oldstr, ncpaddr_ntoa(ip));
|
||||
}
|
||||
|
||||
#ifndef NORADIUS
|
||||
static char *
|
||||
substipv6prefix(char *tgt, const char *oldstr, const uint8_t *ipv6prefix)
|
||||
{
|
||||
uint8_t ipv6addr[INET6_ADDRSTRLEN];
|
||||
uint8_t prefix[INET6_ADDRSTRLEN + sizeof("/128") - 1];
|
||||
|
||||
if (ipv6prefix) {
|
||||
inet_ntop(AF_INET6, &ipv6prefix[2], ipv6addr, sizeof(ipv6addr));
|
||||
snprintf(prefix, sizeof(prefix), "%s/%d", ipv6addr, ipv6prefix[1]);
|
||||
} else
|
||||
prefix[0] = '\0';
|
||||
return subst(tgt, oldstr, prefix);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void
|
||||
@ -560,6 +576,10 @@ command_Expand(char **nargv, int argc, char const *const *oargv,
|
||||
nargv[arg] = substip(nargv[arg], "MYADDR", bundle->ncp.ipcp.my_ip);
|
||||
#ifndef NOINET6
|
||||
nargv[arg] = substipv6(nargv[arg], "MYADDR6", &bundle->ncp.ipv6cp.myaddr);
|
||||
#ifndef NORADIUS
|
||||
nargv[arg] = substipv6prefix(nargv[arg], "IPV6PREFIX",
|
||||
bundle->radius.ipv6prefix);
|
||||
#endif
|
||||
#endif
|
||||
nargv[arg] = substull(nargv[arg], "OCTETSIN", oin);
|
||||
nargv[arg] = substull(nargv[arg], "OCTETSOUT", oout);
|
||||
|
@ -216,6 +216,25 @@ demangle(struct radius *r, const void *mangled, size_t mlen,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* XXX: This should go into librarius. */
|
||||
#ifndef NOINET6
|
||||
static uint8_t *
|
||||
rad_cvt_ipv6prefix(const void *data, size_t len)
|
||||
{
|
||||
const size_t ipv6len = sizeof(struct in6_addr) + 2;
|
||||
uint8_t *s;
|
||||
|
||||
if (len > ipv6len)
|
||||
return NULL;
|
||||
s = malloc(ipv6len);
|
||||
if (s != NULL) {
|
||||
memset(s, 0, ipv6len);
|
||||
memcpy(s, data, len);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* rad_continue_send_request() has given us `got' (non-zero). Deal with it.
|
||||
*/
|
||||
@ -233,6 +252,7 @@ radius_Process(struct radius *r, int got)
|
||||
u_int32_t ipaddr, vendor;
|
||||
struct in_addr ip;
|
||||
#ifndef NOINET6
|
||||
uint8_t ipv6addr[INET6_ADDRSTRLEN];
|
||||
struct in6_addr ip6;
|
||||
#endif
|
||||
|
||||
@ -407,6 +427,13 @@ radius_Process(struct radius *r, int got)
|
||||
break;
|
||||
|
||||
#ifndef NOINET6
|
||||
case RAD_FRAMED_IPV6_PREFIX:
|
||||
free(r->ipv6prefix);
|
||||
r->ipv6prefix = rad_cvt_ipv6prefix(data, len);
|
||||
inet_ntop(AF_INET6, &r->ipv6prefix[2], ipv6addr, sizeof(ipv6addr));
|
||||
log_Printf(LogPHASE, " IPv6 %s/%d\n", ipv6addr, r->ipv6prefix[1]);
|
||||
break;
|
||||
|
||||
case RAD_FRAMED_IPV6_ROUTE:
|
||||
/*
|
||||
* We expect a string of the format ``dest[/bits] gw [metrics]''
|
||||
@ -686,6 +713,7 @@ radius_Init(struct radius *r)
|
||||
r->msrepstr = NULL;
|
||||
r->repstr = NULL;
|
||||
#ifndef NOINET6
|
||||
r->ipv6prefix = NULL;
|
||||
r->ipv6routes = NULL;
|
||||
#endif
|
||||
r->errstr = NULL;
|
||||
@ -718,6 +746,10 @@ radius_Destroy(struct radius *r)
|
||||
r->msrepstr = NULL;
|
||||
free(r->repstr);
|
||||
r->repstr = NULL;
|
||||
#ifndef NOINET6
|
||||
free(r->ipv6prefix);
|
||||
r->ipv6prefix = NULL;
|
||||
#endif
|
||||
free(r->errstr);
|
||||
r->errstr = NULL;
|
||||
free(r->mppe.recvkey);
|
||||
@ -1054,6 +1086,18 @@ radius_Account(struct radius *r, struct radacct *ac, struct datalink *dl,
|
||||
rad_close(r->cx.rad);
|
||||
return;
|
||||
}
|
||||
if (r->ipv6prefix) {
|
||||
/*
|
||||
* Since PPP doesn't delegate an IPv6 prefix to a peer,
|
||||
* Framed-IPv6-Prefix may be not used, actually.
|
||||
*/
|
||||
if (rad_put_attr(r->cx.rad, RAD_FRAMED_IPV6_PREFIX, r->ipv6prefix,
|
||||
sizeof(struct in6_addr) + 2) != 0) {
|
||||
log_Printf(LogERROR, "rad_put_attr: %s\n", rad_strerror(r->cx.rad));
|
||||
rad_close(r->cx.rad);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -52,6 +52,7 @@ struct radius {
|
||||
char *repstr; /* Reply-Message */
|
||||
char *errstr; /* Error-Message */
|
||||
#ifndef NOINET6
|
||||
uint8_t *ipv6prefix; /* FRAMED IPv6 Prefix */
|
||||
struct sticky_route *ipv6routes; /* FRAMED IPv6 Routes */
|
||||
#endif
|
||||
struct {
|
||||
|
Loading…
Reference in New Issue
Block a user