Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] COS DSCP Column patch

From: "Thomas Sillaber" <Thomas.Sillaber@xxxxxx>
Date: Sun, 03 Dec 2006 17:49:25 +0100
Hi list,

attached you find a diff to display COS and DSCP Columns in wireshark. Please apply!

brgds
Tia

TS

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal f�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
Index: epan/column.c
===================================================================
--- epan/column.c	(revision 20033)
+++ epan/column.c	(working copy)
@@ -91,12 +91,16 @@
     "%H", 
     "%P", 
     "%y", 
-    "%z", 
-    "%v", 
+	"%v",
+	"%q",
+	"%f",
+    "%U",  
     "%E",
 	"%C",
-	"%l"
+	"%l",
+	"%z"
 };
+
                      
   if (fmt < 0 || fmt >= NUM_COL_FMTS)
     return NULL;
@@ -155,6 +159,8 @@
 	"DCE/RPC call (cn_call_id / dg_seqnum)",    /* COL_DCE_CALL */
 	"DCE/RPC context ID (cn_ctx_id)",           /* COL_DCE_CTX */
 	"802.1Q VLAN id",                           /* COL_8021Q_VLAN_ID */
+	"IP DSCP Value",							/* COL_DSCP_VALUE */
+	"L2 COS Value",								/* COL_COS_VALUE */
 	"TEI",                                      /* XXX - why is it missing in column_utils.c and elsewhere? */
 	"Frame Relay DLCI",							/* COL_FR_DLCI */
 	"GPRS BSSGP TLLI",							/* COL_BSSGP_TLLI */
@@ -261,6 +267,12 @@
     case COL_8021Q_VLAN_ID:
       fmt_list[COL_8021Q_VLAN_ID] = TRUE;
       break;
+	case COL_DSCP_VALUE:
+	  fmt_list[COL_DSCP_VALUE] = TRUE;
+	  break;
+	case COL_COS_VALUE:
+      fmt_list[COL_COS_VALUE] = TRUE;
+	  break;
     case COL_TEI:
       fmt_list[COL_TEI] = TRUE;
       break;
@@ -493,6 +505,12 @@
     case COL_8021Q_VLAN_ID:
       return "0000";
       break;
+	case COL_DSCP_VALUE:
+	  return "00";
+	  break;
+    case COL_COS_VALUE:
+	  return "0";
+	  break;
     case COL_TEI:
       return "127";
       break;
@@ -651,9 +669,15 @@
       case 'z':
 	return COL_DCE_CTX;
 	break;
-      case 'v':
+      case 'q':
 	return COL_8021Q_VLAN_ID;
 	break;
+	  case 'f':
+    return COL_DSCP_VALUE;
+    break;
+	  case 'U':
+    return COL_COS_VALUE;
+    break;
       case 'E':
 	return COL_TEI;
       case 'C':
Index: epan/column-utils.c
===================================================================
--- epan/column-utils.c	(revision 20033)
+++ epan/column-utils.c	(working copy)
@@ -1241,7 +1241,14 @@
 
     case COL_8021Q_VLAN_ID:
         break;
+    
+	case COL_DSCP_VALUE:	/* done by packet-ip */
+		break;
 
+
+	case COL_COS_VALUE:		/* done by packet-vlan */
+		break;
+
     case COL_FR_DLCI:	/* done by packet-fr.c */
     case COL_BSSGP_TLLI: /* done by packet-bssgp.c */
         break;
Index: epan/dissectors/packet-vlan.c
===================================================================
--- epan/dissectors/packet-vlan.c	(revision 20033)
+++ epan/dissectors/packet-vlan.c	(working copy)
@@ -91,6 +91,9 @@
   if ( check_col(pinfo->cinfo, COL_8021Q_VLAN_ID)) {
       col_add_fstr(pinfo->cinfo, COL_8021Q_VLAN_ID, "%u", (tci & 0xFFF));
   }
+  if ( check_col(pinfo->cinfo, COL_COS_VALUE)) {
+      col_add_fstr(pinfo->cinfo, COL_COS_VALUE, "%u", (tci >> 13));
+    }
 
   vlan_tree = NULL;
 
Index: epan/dissectors/packet-ip.c
===================================================================
--- epan/dissectors/packet-ip.c	(revision 20033)
+++ epan/dissectors/packet-ip.c	(working copy)
@@ -929,7 +929,11 @@
 
   iph->ip_tos = tvb_get_guint8(tvb, offset + 1);
   if (tree) {
-    if (g_ip_dscp_actif) {
+      
+	  if ( check_col(pinfo->cinfo, COL_DSCP_VALUE)) {
+		col_add_fstr(pinfo->cinfo, COL_DSCP_VALUE, "%u", IPDSFIELD_DSCP(iph->ip_tos));
+      }
+	  if (g_ip_dscp_actif) {
       tf = proto_tree_add_uint_format(ip_tree, hf_ip_dsfield, tvb, offset + 1, 1, iph->ip_tos,
 	   "Differentiated Services Field: 0x%02x (DSCP 0x%02x: %s; ECN: 0x%02x)", iph->ip_tos,
 	   IPDSFIELD_DSCP(iph->ip_tos), val_to_str(IPDSFIELD_DSCP(iph->ip_tos), dscp_vals,