From: Alarig Le Lay <alarig@swordarmor.fr>
To: linux-ppp@vger.kernel.org
Subject: Add support for IPv6 RADIUS attributes
Date: Fri, 08 Jan 2016 14:20:12 +0000 [thread overview]
Message-ID: <20160108142012.GL19014@drscott.swordarmor.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 3992 bytes --]
Hi,
This patch aims to handle IPv6 RADIUS attributes. The current ppp does
not handle them and raise an error that looks like 'rc_read_dictionary:
invalid type on line 89 of dictionary /etc/radiusclient/dictionary'.
I use those attributes to put it into the radvd conf from
/run/vpn/radvd-user.${PPP_IFACE}.conf.
From 5c0cac0eeecc32e5023d353a8420633827800e8e Mon Sep 17 00:00:00 2001
From: Benjamin Cama <benoar@dolka.fr>
Date: Sun, 11 Oct 2015 18:08:11 +0200
Subject: [PATCH] Handle IPv6 RADIUS attributes
---
pppd/plugins/radius/avpair.c | 26 +++++++++++++++++++++++++-
pppd/plugins/radius/dict.c | 12 ++++++++++++
pppd/plugins/radius/radiusclient.h | 11 +++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/pppd/plugins/radius/avpair.c b/pppd/plugins/radius/avpair.c
index 716d23f..7536941 100644
--- a/pppd/plugins/radius/avpair.c
+++ b/pppd/plugins/radius/avpair.c
@@ -222,6 +222,9 @@ VALUE_PAIR *rc_avpair_gen (AUTH_HDR *auth)
{
case PW_TYPE_STRING:
+ case PW_TYPE_IFID:
+ case PW_TYPE_IPV6ADDR:
+ case PW_TYPE_IPV6PREFIX:
memcpy (pair->strvalue, (char *) ptr,
(size_t) attrlen);
pair->strvalue[attrlen] = '\0';
pair->lvalue = attrlen;
@@ -692,9 +695,10 @@ int rc_avpair_parse (char *buffer, VALUE_PAIR
**first_pair)
int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value,
int lv)
{
DICT_VALUE *dval;
- char buffer[32];
+ char buffer[INET6_ADDRSTRLEN + 4]; // for a prefix:
addr + '/' + prefixlen
struct in_addr inad;
unsigned char *ptr;
+ char *str;
*name = *value = '\0';
@@ -753,6 +757,26 @@ int rc_avpair_tostr (VALUE_PAIR *pair, char *name,
int ln, char *value, int lv)
strncpy(value, buffer, lv-1);
break;
+ case PW_TYPE_IFID:
+ ptr = pair->strvalue;
+ snprintf(buffer, sizeof (buffer), "%x:%x:%x:%x",
+ (ptr[0] << 8) + ptr[1], (ptr[2] << 8) + ptr[3],
+ (ptr[4] << 8) + ptr[5], (ptr[6] << 8) +
ptr[7]);
+ strncpy(value, buffer, lv-1);
+ break;
+
+ case PW_TYPE_IPV6ADDR:
+ inet_ntop(AF_INET6, pair->strvalue, buffer, sizeof
(buffer));
+ strncpy(value, buffer, lv-1);
+ break;
+
+ case PW_TYPE_IPV6PREFIX:
+ inet_ntop(AF_INET6, pair->strvalue + 2, buffer, sizeof
(buffer));
+ str = buffer + strlen(buffer);
+ snprintf(str, sizeof (buffer) - (str - buffer), "/%d",
*(pair->strvalue + 1));
+ strncpy(value, buffer, lv-1);
+ break;
+
default:
error("rc_avpair_tostr: unknown attribute type %d",
pair->type);
return (-1);
diff --git a/pppd/plugins/radius/dict.c b/pppd/plugins/radius/dict.c
index 72b3e70..3b2add2 100644
--- a/pppd/plugins/radius/dict.c
+++ b/pppd/plugins/radius/dict.c
@@ -158,6 +158,18 @@ int rc_read_dictionary (char *filename)
{
type = PW_TYPE_DATE;
}
+ else if (strcmp (typestr, "ifid") == 0)
+ {
+ type = PW_TYPE_IFID;
+ }
+ else if (strcmp (typestr, "ipv6addr") == 0)
+ {
+ type = PW_TYPE_IPV6ADDR;
+ }
+ else if (strcmp (typestr, "ipv6prefix") == 0)
+ {
+ type = PW_TYPE_IPV6PREFIX;
+ }
else
{
error("rc_read_dictionary: invalid type
on line %d of dictionary %s",
diff --git a/pppd/plugins/radius/radiusclient.h
b/pppd/plugins/radius/radiusclient.h
index 51b959a..ab4ef2d 100644
--- a/pppd/plugins/radius/radiusclient.h
+++ b/pppd/plugins/radius/radiusclient.h
@@ -77,6 +77,17 @@ typedef struct pw_auth_hdr
#define PW_TYPE_INTEGER 1
#define PW_TYPE_IPADDR 2
#define PW_TYPE_DATE 3
+#define PW_TYPE_ABINARY 4
+#define PW_TYPE_OCTETS 5
+#define PW_TYPE_IFID 6
+#define PW_TYPE_IPV6ADDR 7
+#define PW_TYPE_IPV6PREFIX 8
+#define PW_TYPE_BYTE 9
+#define PW_TYPE_SHORT 10
+#define PW_TYPE_ETHERNET 11
+#define PW_TYPE_SIGNED 12
+#define PW_TYPE_COMBO_IP 13
+#define PW_TYPE_TLV 14
/* standard RADIUS codes */
--
2.1.4
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next reply other threads:[~2016-01-08 14:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 14:20 Alarig Le Lay [this message]
2016-01-09 0:49 ` Add support for IPv6 RADIUS attributes Charlie Brady
2016-01-10 19:03 ` Michael Richardson
2016-01-10 22:52 ` Charlie Brady
2016-01-10 22:58 ` Charlie Brady
2016-01-10 23:13 ` Michael O'Connor
2016-01-11 9:51 ` Alarig Le Lay
2016-03-08 20:19 ` Benjamin Cama
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160108142012.GL19014@drscott.swordarmor.fr \
--to=alarig@swordarmor.fr \
--cc=linux-ppp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox