radius: added support for Delegated-IPv6-Prefix

This commit is contained in:
Nikos Mavrogiannopoulos
2015-05-07 13:49:23 +02:00
parent 41bcc9d0c0
commit c7167af362
2 changed files with 18 additions and 4 deletions

View File

@@ -61,6 +61,7 @@ ATTRIBUTE Acct-Interim-Interval 85 integer
ATTRIBUTE NAS-IPv6-Address 95 string
ATTRIBUTE Framed-IPv6-Route 99 string
ATTRIBUTE Framed-IPv6-Prefix 97 ipv6prefix
ATTRIBUTE Delegated-IPv6-Prefix 123 ipv6prefix
ATTRIBUTE Framed-IPv6-Address 168 ipv6addr
ATTRIBUTE DNS-Server-IPv6-Address 169 ipv6addr

View File

@@ -38,6 +38,14 @@
#define RAD_IPV4_DNS1 ((311<<16)|(28))
#define RAD_IPV4_DNS2 ((311<<16)|(29))
#ifndef PW_INTERIM_INTERVAL
# define PW_INTERIM_INTERVAL 85
#endif
#ifndef PW_DELEGATED_IPV6_PREFIX
# define PW_DELEGATED_IPV6_PREFIX 123
#endif
static rc_handle *rh = NULL;
static char nas_identifier[64];
static unsigned override_interim_updates = 0;
@@ -172,10 +180,6 @@ static void append_route(struct radius_ctx_st *pctx, const char *route, unsigned
}
}
#ifndef PW_INTERIM_INTERVAL
# define PW_INTERIM_INTERVAL 85
#endif
/* Returns 0 if the user is successfully authenticated, and sets the appropriate group name.
*/
static int radius_auth_pass(void *ctx, const char *pass, unsigned pass_len)
@@ -271,6 +275,15 @@ static int radius_auth_pass(void *ctx, const char *pass, unsigned pass_len)
pctx->ipv6_prefix = 64;
strlcpy(pctx->ipv6_net, pctx->ipv6, sizeof(pctx->ipv6_net));
}
} else if (vp->attribute == PW_DELEGATED_IPV6_PREFIX && vp->type == PW_TYPE_IPV6PREFIX) {
/* Delegated-IPv6-Prefix */
if (inet_ntop(AF_INET6, vp->strvalue, pctx->ipv6, sizeof(pctx->ipv6)) != NULL) {
memset(ipv6, 0, sizeof(ipv6));
memcpy(ipv6, vp->strvalue+2, vp->lvalue-2);
if (inet_ntop(AF_INET6, ipv6, pctx->ipv6, sizeof(pctx->ipv6)) != NULL) {
pctx->ipv6_prefix = (unsigned)(unsigned char)vp->strvalue[1];
}
}
} else if (vp->attribute == PW_FRAMED_IPV6_PREFIX && vp->type == PW_TYPE_IPV6PREFIX) {
if (vp->lvalue > 2 && vp->lvalue <= 18) {
/* Framed-IPv6-Prefix */