Ethereal-dev: [Ethereal-dev] radius patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Joost Yervante Damad <Joost.Damad@xxxxxxxxxxx>
Date: Fri, 9 Jan 2004 15:26:11 +0100
Hi,

the following diff adds 3 new vendors, 3 non-encapsulated Merit vendor
specifics, displaying of the authenticator in the protocol tree and
possibility to display-filter on selected attributes:

User Name, NAS IP Address, NAS Port, NAS identifier, Called Station Id,
Calling Station Id

Greetings, Joost Damad

--- packet-radius.c.orig	2004-01-09 15:15:05.000000000 +0100
+++ packet-radius.c	2004-01-09 15:17:47.000000000 +0100
@@ -49,6 +49,13 @@
 static int hf_radius_length = -1;
 static int hf_radius_code = -1;
 static int hf_radius_id =-1;
+static int hf_radius_user_name =-1;
+static int hf_radius_nas_ip_address =-1;
+static int hf_radius_nas_port =-1;
+static int hf_radius_nas_identifier =-1;
+static int hf_radius_called_station_id =-1;
+static int hf_radius_calling_station_id =-1;
+
 static char *shared_secret = NULL;
 static gpointer authenticator = NULL;
 
@@ -290,6 +297,7 @@
  */
 #define VENDOR_ACC			5
 #define VENDOR_CISCO			9
+#define VENDOR_MERIT			61
 #define VENDOR_SHIVA			166
 #define VENDOR_LIVINGSTON		307
 #define VENDOR_MICROSOFT		311
@@ -304,9 +312,11 @@
 #define VENDOR_COSINE			3085
 #define VENDOR_SHASTA			3199
 #define VENDOR_NOMADIX			3309
+#define VENDOR_SIEMENS			4329
 #define VENDOR_UNISPHERE		4874
 #define VENDOR_ISSANNI			5948
 #define VENDOR_QUINTUM			6618
+#define VENDOR_INTERLINK		6728
 #define VENDOR_COLUBRIS			8744
 #define VENDOR_COLUMBIA_UNIVERSITY	11862
 #define VENDOR_THE3GPP			10415
@@ -315,6 +325,7 @@
 {
   {VENDOR_ACC,			"ACC"},
   {VENDOR_CISCO,		"Cisco"},
+  {VENDOR_MERIT,		"Merit"},
   {VENDOR_SHIVA,		"Shiva"},
   {VENDOR_MICROSOFT,		"Microsoft"},
   {VENDOR_LIVINGSTON,		"Livingston"},
@@ -329,9 +340,11 @@
   {VENDOR_COSINE,		"CoSine Communications"},
   {VENDOR_SHASTA,		"Shasta"},
   {VENDOR_NOMADIX,		"Nomadix"},
+  {VENDOR_SIEMENS,		"SIEMENS"},
   {VENDOR_UNISPHERE,		"Unisphere Networks"},
   {VENDOR_ISSANNI,		"Issanni Communications"},
   {VENDOR_QUINTUM,		"Quintum"},
+  {VENDOR_INTERLINK,	"Interlink"},
   {VENDOR_COLUBRIS,		"Colubris"},
   {VENDOR_COLUMBIA_UNIVERSITY,	"Columbia University"},
   {VENDOR_THE3GPP,		"3GPP"},
@@ -459,7 +472,10 @@
   {196,	RADIUS_INTEGER4,		"Ascend Connect Progress"},
   {197,	RADIUS_INTEGER4,		"Ascend Data Rate"},
   {198,	RADIUS_INTEGER4,		"Ascend PreSession Time"},
+  {211,	RADIUS_STRING,			"Merit Proxy-Action"},
   {218,	RADIUS_INTEGER4,		"Ascend Assign IP Pool"},
+  {222,	RADIUS_STRING,			"Merit User-Id"},
+  {223,	RADIUS_STRING,			"Merit User-Realm"},
   {255,	RADIUS_INTEGER4,		"Ascend Xmit Rate"},
   {0, 0, NULL}
 };
@@ -3006,6 +3022,36 @@
         proto_item *ti;
         proto_tree *vsa_tree = NULL;
         int i;
+
+		/* possible optimization: use a lookup table... */
+		switch (avph.avp_type)
+		{
+		case 1: /* User Name */
+			ti = proto_tree_add_item_hidden(tree, hf_radius_user_name, tvb,
+				offset+2, avph.avp_length-2, FALSE);
+			break;
+		case 4: /* NAS IP Address */
+			ti = proto_tree_add_item_hidden(tree, hf_radius_nas_ip_address, tvb,
+				offset+2, avph.avp_length-2, FALSE);
+			break;
+		case 5: /* NAS Port */
+			ti = proto_tree_add_item_hidden(tree, hf_radius_nas_port, tvb,
+				offset+2, avph.avp_length-2, FALSE);
+			break;
+		case 32: /* NAS identifier */
+			ti = proto_tree_add_item_hidden(tree, hf_radius_nas_identifier, tvb,
+				offset+2, avph.avp_length-2, FALSE);
+			break;
+		case 30: /* Called Station Id */
+			ti = proto_tree_add_item_hidden(tree, hf_radius_called_station_id, tvb,
+				offset+2, avph.avp_length-2, FALSE);
+			break;
+		case 31: /* Calling Station Id */
+			ti = proto_tree_add_item_hidden(tree, hf_radius_calling_station_id, tvb,
+				offset+2, avph.avp_length-2, FALSE);
+			break;
+		}
+
         /* We pre-add a text and a subtree to allow 3GPP QoS decoding
          * to access the protocol tree.
          * */
@@ -3041,6 +3087,7 @@
   guint rhident;
   guint avplength,hdrlength;
   e_radiushdr rh;
+  gchar *hex_authenticator;
 
   gchar *codestrval;
 
@@ -3098,9 +3145,12 @@
 	if ( authenticator ) {
 	    memcpy(authenticator,tvb_get_ptr(tvb,4,AUTHENTICATOR_LENGTH),AUTHENTICATOR_LENGTH);
 	}
+	hex_authenticator = g_malloc(AUTHENTICATOR_LENGTH * 2 + 1);
+	rdconvertbufftobinstr(hex_authenticator, tvb, 4, AUTHENTICATOR_LENGTH);
 	proto_tree_add_text(radius_tree, tvb, 4,
 			AUTHENTICATOR_LENGTH,
-                         "Authenticator");
+                         "Authenticator: 0x%s", hex_authenticator);
+	g_free(hex_authenticator);
   }
 
   hdrlength=RD_HDR_LENGTH+AUTHENTICATOR_LENGTH;
@@ -3136,7 +3186,25 @@
 
 		{ &hf_radius_length,
 		{ "Length","radius.length", FT_UINT16, BASE_DEC, NULL, 0x0,
-			"", HFILL }}
+			"", HFILL }},
+		{ &hf_radius_user_name,
+		{ "User Name","radius.user_name", FT_STRING, BASE_NONE, NULL, 0x0,
+			"", HFILL }},
+		{ &hf_radius_nas_ip_address,
+		{ "NAS IP Address","radius.nas_ip_address", FT_IPv4, BASE_NONE, NULL, 0x0,
+			"", HFILL }},
+		{ &hf_radius_nas_port,
+		{ "NAS Port","radius.nas_port", FT_UINT32, BASE_DEC, NULL, 0x0,
+			"", HFILL }},
+		{ &hf_radius_nas_identifier,
+		{ "NAS identifier","radius.nas_identifier", FT_STRING, BASE_NONE, NULL, 0x0,
+			"", HFILL }},
+		{ &hf_radius_called_station_id,
+		{ "Called Station Id","radius.called_station_id", FT_STRING, BASE_NONE, NULL, 0x0,
+			"", HFILL }},
+		{ &hf_radius_calling_station_id,
+		{ "Calling Station Id","radius.calling_station_id", FT_STRING, BASE_NONE, NULL, 0x0,
+			"", HFILL }},
 	};
 	static gint *ett[] = {
 		&ett_radius,