Ethereal-dev: [Ethereal-dev] Patches for packet-diameter.c

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

From: David Frascone <dave@xxxxxxxxxxxx>
Date: Fri, 20 Oct 2000 12:31:55 -0500
These patches changes the default TCP port, and brings the dissector up to
spec with the most recent diameter-api document.

Specifically, the commandCode and vendorId being in the header.

One last TBD thing, is to parse the ICV in a subtree, but I'm waiting until
the aaa-wg decides if complex data types are going to be removed in favor of
nested groups.


----------------------cvs diff output------------------------------
Index: packet-diameter.c
===================================================================
RCS file: /cvsroot/ethereal/packet-diameter.c,v
retrieving revision 1.5
diff -u -r1.5 packet-diameter.c
--- packet-diameter.c	2000/08/13 14:08:08	1.5
+++ packet-diameter.c	2000/10/20 18:00:50
@@ -70,9 +70,9 @@
 #undef SCTP_DISSECTORS_ENABLED
 
 #define UDP_PORT_DIAMETER	2645
-#define TCP_PORT_DIAMETER	2645
+#define TCP_PORT_DIAMETER	1812
 #ifdef SCTP_DISSECTORS_ENABLED
-#define SCTP_PORT_DIAMETER	2645
+#define SCTP_PORT_DIAMETER	1812
 #endif
 /* #define UDP_PORT_DIAMETER	1812  -- Compiling this in breaks RADIUS */
 
@@ -481,9 +481,6 @@
 			    avph.avp_length - dataOffset, valstr);
 		}
 		offset=offset+avph.avp_length + fixAmt;
-		if (avph.avp_length == 0) {
-			break;
-		}
 	}
 }
 
@@ -522,6 +519,8 @@
       dh.u.new.nextReceived = ntohs(dh.u.new.nextReceived);
       nextSend = dh.u.new.nextSend;
       nextReceived = dh.u.new.nextReceived;
+    } else {
+        hdrlength -= 4;
     }
     commandCode = dh.u.new.commandCode;
   } else {
@@ -530,6 +529,8 @@
       dh.u.old.nextReceived = ntohs(dh.u.old.nextReceived);
       nextSend = dh.u.old.nextSend;
       nextReceived = dh.u.old.nextReceived;
+    } else {
+        hdrlength -= 4;
     }
     memcpy(&commandCode, &pd[offset+COMMAND_CODE_OFFSET], 4);
     commandCode = ntohl(commandCode);
@@ -542,15 +543,26 @@
   if (check_col(fd, COL_PROTOCOL))
     col_add_str(fd, COL_PROTOCOL, "DIAMETER");
   if (check_col(fd, COL_INFO)) {
-    if (DIAM_FLAGS_A & dh.flagsVer) {
-      sprintf(buffer,"ACK (id=%d, l=%d, s=%d, r=%d)",
-	      dh.identifier, dh.pktLength, nextSend,
-	      nextReceived);
+    if (DIAM_FLAGS_W & dh.flagsVer) {
+       if (DIAM_FLAGS_A & dh.flagsVer) {
+         sprintf(buffer,"ACK (id=%d, l=%d, s=%d, r=%d)",
+	         dh.identifier, dh.pktLength, nextSend,
+	         nextReceived);
+       } else {
+         sprintf(buffer,"%s(%d) (id=%d, l=%d, s=%d, r=%d)",
+	         codestrval,commandCode, dh.identifier, dh.pktLength,
+	         nextSend, nextReceived);
+       }
     } else {
-      sprintf(buffer,"%s(%d) (id=%d, l=%d, s=%d, r=%d)",
-	      codestrval,commandCode, dh.identifier, dh.pktLength,
-	      nextSend, nextReceived);
-    }
+       if (DIAM_FLAGS_A & dh.flagsVer) {
+         sprintf(buffer,"ACK (id=%d, l=%d)",
+	         dh.identifier, dh.pktLength);
+       } else {
+         sprintf(buffer,"%s(%d) (id=%d, l=%d)",
+	         codestrval,commandCode,
+		dh.identifier, dh.pktLength);
+       }
+   }
     col_add_fstr(fd,COL_INFO,buffer);
   }
   
@@ -745,8 +757,10 @@
 
 	strcpy(gbl_diameterString, "Diameter Protocol");
 
-	old_dissector_add("udp.port", gbl_diameterUdpPort, dissect_diameter);
+        /* g_warning ("Diameter: Adding tcp dissector to port %d",
+		gbl_diameterTcpPort); */
 	old_dissector_add("tcp.port", gbl_diameterTcpPort, dissect_diameter);
+	old_dissector_add("udp.port", gbl_diameterUdpPort, dissect_diameter);
 #ifdef SCTP_DISSECTORS_ENABLED
 	old_dissector_add("sctp.srcport", gbl_diameterSctpPort, dissect_diameter);
 	old_dissector_add("sctp.destport", gbl_diameterSctpPort, dissect_diameter);
-------------------------------------------------------------------