]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Added RADIUS attributes from RFC3162
authorHerwin Weststrate <[email protected]>
Thu, 25 Jun 2015 13:14:46 +0000 (15:14 +0200)
committerHerwin Weststrate <[email protected]>
Fri, 22 Sep 2017 09:46:26 +0000 (11:46 +0200)
NAS IPv6 Address (95)
Framed Interface ID (96)
Framed IPv6 Prefix (97)
Login IPv6 Host (98)
Framed IPv6 Route (99)
Framed IPv6 Pool (100)

Added new functions to print ipv6 address and netmask, added unit test to test those.

print-radius.c
tests/RADIUS-RFC3162.pcap [new file with mode: 0644]
tests/TESTLIST
tests/radius-rfc3162-v.out [new file with mode: 0644]

index 8555188ee9853a834aaa0cf57182f418b3e09002..e33d4b28e6384dd347b8fc04501fba99d103700d 100644 (file)
@@ -40,6 +40,9 @@
  * RFC 2869:
  *      "RADIUS Extensions"
  *
+ * RFC 3162:
+ *      "RADIUS and IPv6"
+ *
  * RFC 3580:
  *      "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
  *      "Usage Guidelines"
@@ -178,6 +181,8 @@ static void print_attr_string(netdissect_options *, register const u_char *, u_i
 static void print_attr_num(netdissect_options *, register const u_char *, u_int, u_short );
 static void print_vendor_attr(netdissect_options *, register const u_char *, u_int, u_short );
 static void print_attr_address(netdissect_options *, register const u_char *, u_int, u_short);
+static void print_attr_address6(netdissect_options *, register const u_char *, u_int, u_short);
+static void print_attr_netmask6(netdissect_options *, register const u_char *, u_int, u_short);
 static void print_attr_time(netdissect_options *, register const u_char *, u_int, u_short);
 static void print_attr_strange(netdissect_options *, register const u_char *, u_int, u_short);
 
@@ -480,7 +485,13 @@ static struct attrtype {
      { "Tunnel-Server-Auth-ID",           NULL, 0, 0, print_attr_string },
      { "NAS-Filter-Rule",                 NULL, 0, 0, print_attr_string },
      { "Unassigned",                      NULL, 0, 0, NULL },  /*93*/
-     { "Originating-Line-Info",           NULL, 0, 0, NULL }
+     { "Originating-Line-Info",           NULL, 0, 0, NULL },
+     { "NAS-IPv6-Address",                NULL, 0, 0, print_attr_address6 },
+     { "Framed-Interface-ID",             NULL, 0, 0, NULL },
+     { "Framed-IPv6-Prefix",              NULL, 0, 0, print_attr_netmask6 },
+     { "Login-IPv6-Host",                 NULL, 0, 0, print_attr_address6 },
+     { "Framed-IPv6-Route",               NULL, 0, 0, print_attr_string },
+     { "Framed-IPv6-Pool",                NULL, 0, 0, print_attr_string }
   };
 
 
@@ -779,6 +790,63 @@ print_attr_address(netdissect_options *ndo,
      ND_PRINT((ndo, "%s", tstr));
 }
 
+/*****************************/
+/* Print an attribute IPv6   */
+/* address value pointed by  */
+/* 'data' and 'length' size. */
+/*****************************/
+/* Returns nothing.          */
+/*****************************/
+static void
+print_attr_address6(netdissect_options *ndo,
+                   register const u_char *data, u_int length, u_short attr_code _U_)
+{
+   if (length != 16)
+   {
+       ND_PRINT((ndo, "ERROR: length %u != 16", length));
+       return;
+   }
+
+   ND_TCHECK2(data[0], 16);
+
+   ND_PRINT((ndo, "%s", ip6addr_string(ndo, data)));
+
+   return;
+
+   trunc:
+     ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+print_attr_netmask6(netdissect_options *ndo,
+                    register const u_char *data, u_int length, u_short attr_code _U_)
+{
+   u_char data2[18];
+
+   if (length < 2 || length > 18)
+   {
+       ND_PRINT((ndo, "ERROR: length %u not in range (2..18)", length));
+       return;
+   }
+   else if (data[1] > 128)
+   {
+      ND_PRINT((ndo, "ERROR: netmask %u not in range (0..128)", data[1]));
+      return;
+   }
+
+   ND_TCHECK2(data[0], length);
+   memset(data2, 0, sizeof(data2));
+   if (length > 2)
+      memcpy(data2, data+2, length-2);
+
+   ND_PRINT((ndo, "%s/%u", ip6addr_string(ndo, data2), data[1]));
+
+   return;
+
+   trunc:
+     ND_PRINT((ndo, "%s", tstr));
+}
+
 /*************************************/
 /* Print an attribute of 'secs since */
 /* January 1, 1970 00:00 UTC' value  */
diff --git a/tests/RADIUS-RFC3162.pcap b/tests/RADIUS-RFC3162.pcap
new file mode 100644 (file)
index 0000000..b41d67c
Binary files /dev/null and b/tests/RADIUS-RFC3162.pcap differ
index 919c89441c3ad4aeb4701e42bea865f8a6a84d4b..41b09dfa4a1d73cb52fda0fd561027f039f2d1b8 100644 (file)
@@ -275,6 +275,7 @@ decnet              DECnet_Phone.pcap       decnet.out
 
 # RADIUS tests
 radius-v       RADIUS.pcap     radius-v.out    -v
+radius-rfc3162 RADIUS-RFC3162.pcap     radius-rfc3162-v.out    -v
 radius-rfc4675 RADIUS-RFC4675.pcap     radius-rfc4675-v.out    -v
 radius-rfc5176 RADIUS-RFC5176.pcap     radius-rfc5176-v.out    -v
 radius-port1700        RADIUS-port1700.pcap    radius-port1700-v.out   -v
diff --git a/tests/radius-rfc3162-v.out b/tests/radius-rfc3162-v.out
new file mode 100644 (file)
index 0000000..0749407
--- /dev/null
@@ -0,0 +1,12 @@
+IP (tos 0x0, ttl 64, id 60508, offset 0, flags [DF], proto UDP (17), length 169)
+    127.0.0.1.39646 > 127.0.0.1.1812: RADIUS, length: 141
+       Access-Request (1), id: 0xf0, Authenticator: 2afdb090418ac6365298fbbb15e0fd2e
+         User-Name Attribute (1), length: 5, Value: bob
+         User-Password Attribute (2), length: 18, Value: 
+         NAS-IPv6-Address Attribute (95), length: 18, Value: 2001:db8:a0b:12f0::1
+         Framed-IPv6-Prefix Attribute (97), length: 20, Value: 2001:db8:a0b:12f0::/64
+         Framed-IPv6-Prefix Attribute (97), length: 12, Value: 2001:db8:a0b:12f0::/64
+         Framed-IPv6-Prefix Attribute (97), length: 4, Value: ::/0
+         Framed-IPv6-Prefix Attribute (97), length: 3, Value: ERROR: length 1 not in range (2..18)
+         Framed-IPv6-Prefix Attribute (97), length: 21, Value: ERROR: length 19 not in range (2..18)
+         Framed-IPv6-Prefix Attribute (97), length: 20, Value: ERROR: netmask 129 not in range (0..128)