From c7167af362a6942984dc765242185785fc8d1ac1 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 7 May 2015 13:49:23 +0200 Subject: [PATCH] radius: added support for Delegated-IPv6-Prefix --- doc/README.radius | 1 + src/auth/radius.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/README.radius b/doc/README.radius index e69a47a9..0bd522b6 100644 --- a/doc/README.radius +++ b/doc/README.radius @@ -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 diff --git a/src/auth/radius.c b/src/auth/radius.c index 5a4b9c51..0ccb0685 100644 --- a/src/auth/radius.c +++ b/src/auth/radius.c @@ -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 */