Ethereal-dev: [ethereal-dev] SRVLOC cosmetic improvements

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

From: James Coe <jammer@xxxxxxx>
Date: Tue, 14 Dec 1999 13:17:07 -0600
This patch to SRVLOC does the following:

Add the RFC number to the comments.
Change the srvlocfunctionvals variable to srvloc_functions to improve
consistency in the code.
Changes code to print the function name in the Info column.
Moves the flags breakout to a subtree.

Jamie Coe.


? README.developer
? srvloc.patch
Index: packet-srvloc.c
===================================================================
RCS file: /cvsroot/ethereal/packet-srvloc.c,v
retrieving revision 1.2
diff -u -r1.2 packet-srvloc.c
--- packet-srvloc.c	1999/12/09 20:46:28	1.2
+++ packet-srvloc.c	1999/12/14 19:09:56
@@ -12,6 +12,8 @@
  * By Gerald Combs <gerald@xxxxxxxxxx>
  * Copyright 1998 Gerald Combs
  *
+ * Service Location Protocol is RFC 2165
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -63,6 +65,7 @@
 int hf_srvloc_error = -1;
 
 static gint ett_srvloc = -1;
+gint ett_srvloc_flags = -1;
 
 /* Define function types */
 
@@ -92,7 +95,7 @@
 
 /* List to resolve function numbers to names */
 
-static const value_string srvlocfunctionvals[] = {
+static const value_string srvloc_functions[] = {
     { SRVREQ, "Service Request" }, 
     { SRVRPLY, "Service Reply" }, 
     { SRVREG, "Service Registration" }, 
@@ -171,8 +174,8 @@
 void
 dissect_srvloc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 {
-    proto_item *ti;
-    proto_tree *srvloc_tree;
+    proto_item *ti, *tf;
+    proto_tree *srvloc_tree, *srvloc_flags;
     struct srvloc_hdr srvloc_hdr;
     int count;
     int length;
@@ -181,7 +184,7 @@
         col_add_str(fd, COL_PROTOCOL, "SRVLOC");
     
     if (check_col(fd, COL_INFO))
-        col_add_str(fd, COL_INFO, "Service Location Protocol");
+        col_add_str(fd, COL_INFO, val_to_str(pd[offset + 1], srvloc_functions, "Unknown Function (%d)"));
         
     if (tree) {
         ti = proto_tree_add_item(tree, proto_srvloc, offset, END_OF_FRAME, NULL);
@@ -195,12 +198,13 @@
             proto_tree_add_item(srvloc_tree, hf_srvloc_version, offset, 1, srvloc_hdr.version);
             proto_tree_add_item(srvloc_tree, hf_srvloc_function, offset + 1, 1, srvloc_hdr.function);
             proto_tree_add_text(srvloc_tree, offset + 2, 2, "Length: %d",srvloc_hdr.length);
-            proto_tree_add_item(srvloc_tree, hf_srvloc_flags, offset + 4, 1, srvloc_hdr.flags);
-            proto_tree_add_text(srvloc_tree, offset + 4, 0, "Overflow                          %d... .xxx", (srvloc_hdr.flags & FLAG_O) >> 7 );
-            proto_tree_add_text(srvloc_tree, offset + 4, 0, "Monolingual                       .%d.. .xxx", (srvloc_hdr.flags & FLAG_M) >> 6 ); 
-            proto_tree_add_text(srvloc_tree, offset + 4, 0, "URL Authentication Present        ..%d. .xxx", (srvloc_hdr.flags & FLAG_U) >> 5 );
-            proto_tree_add_text(srvloc_tree, offset + 4, 0, "Attribute Authentication Present  ...%d .xxx", (srvloc_hdr.flags & FLAG_A) >> 4 );
-            proto_tree_add_text(srvloc_tree, offset + 4, 0, "Fresh Service Entry               .... %dxxx", (srvloc_hdr.flags & FLAG_F) >> 3 );
+            tf = proto_tree_add_item(srvloc_tree, hf_srvloc_flags, offset + 4, 1, srvloc_hdr.flags);
+            srvloc_flags = proto_item_add_subtree(tf, ett_srvloc_flags);
+            proto_tree_add_text(srvloc_flags, offset + 4, 0, "Overflow                          %d... .xxx", (srvloc_hdr.flags & FLAG_O) >> 7 );
+            proto_tree_add_text(srvloc_flags, offset + 4, 0, "Monolingual                       .%d.. .xxx", (srvloc_hdr.flags & FLAG_M) >> 6 ); 
+            proto_tree_add_text(srvloc_flags, offset + 4, 0, "URL Authentication Present        ..%d. .xxx", (srvloc_hdr.flags & FLAG_U) >> 5 );
+            proto_tree_add_text(srvloc_flags, offset + 4, 0, "Attribute Authentication Present  ...%d .xxx", (srvloc_hdr.flags & FLAG_A) >> 4 );
+            proto_tree_add_text(srvloc_flags, offset + 4, 0, "Fresh Service Entry               .... %dxxx", (srvloc_hdr.flags & FLAG_F) >> 3 );
             proto_tree_add_text(srvloc_tree, offset + 5, 1, "Dialect: %d",srvloc_hdr.dialect); 
             proto_tree_add_text(srvloc_tree, offset + 6, 2, "Language: %s", format_text(srvloc_hdr.language,2));
             proto_tree_add_text(srvloc_tree, offset + 8, 2, "Encoding: %d", srvloc_hdr.encoding);
@@ -398,7 +402,7 @@
       
         {&hf_srvloc_function,
             {"Function", "srvloc.function", 
-            FT_UINT8, BASE_DEC, VALS(srvlocfunctionvals), 0x0, 
+            FT_UINT8, BASE_DEC, VALS(srvloc_functions), 0x0, 
             ""}
         },
 
@@ -417,6 +421,7 @@
                   
    static gint *ett[] = {
       &ett_srvloc,
+      &ett_srvloc_flags,
    };
 
     proto_srvloc = proto_register_protocol("Service Location Protocol", "srvloc");