Have the PROTOCOL field for ONC RPC just give the RPC program
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 29 Oct 1999 02:25:54 +0000 (02:25 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 29 Oct 1999 02:25:54 +0000 (02:25 +0000)
name/number, and put the call/reply info, procedure, and version number
into the INFO field.

Implement "col_append_fstr()", and use it to add information to the info
field.

Make "col_add_fstr()" aware that COL_INFO fields can have more data than
other COL_XXX fields (as "col_add_str()" and "col_append_str()" already
were).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@947 f5534014-38df-0310-8fa8-9805f1628bb7

packet-rpc.c
packet.c

index 9d456c6fec8b37da16d5ab65fc23c6851e5ae9a1..284c60f9597dc1071d13698637059bb6c6f56c6e 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for rpc dissection
  * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de>
  * 
- * $Id: packet-rpc.c,v 1.1 1999/10/29 01:11:22 guy Exp $
+ * $Id: packet-rpc.c,v 1.2 1999/10/29 02:25:53 guy Exp $
  * 
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@unicom.net>
@@ -546,10 +546,6 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                        "XID: 0x%x (%d)", xid, xid);
        }
 
-       if (check_col(fd, COL_INFO)) {
-               col_add_fstr(fd, COL_INFO, "XID 0x%x", xid);
-       }
-
        /* we should better compare this with the argument?! */
        msg_type = EXTRACT_UINT(pd,offset+4);
        msg_type_name = val_to_str(msg_type,rpc_msg_type,"%d");
@@ -559,11 +555,6 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                        msg_type_name, msg_type);
        }
 
-       if (check_col(fd, COL_PROTOCOL)) {
-               col_add_fstr(fd, COL_PROTOCOL, "RPC %s",
-                       val_to_str(msg_type,rpc_msg_type,"%d"));
-       }
-
        offset += 8;
 
        if (msg_type==RPC_CALL) {
@@ -587,16 +578,16 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                }
                
                if (check_col(fd, COL_PROTOCOL)) {
-                       col_add_fstr(fd, COL_PROTOCOL,"%s %s",
-                               progname,
-                               msg_type_name);
+                       /* Set the protocol name to the underlying
+                          program name. */
+                       col_add_fstr(fd, COL_PROTOCOL, "%s", progname);
                }
 
                if (!BYTES_ARE_IN_FRAME(offset+8,4)) return;
                vers = EXTRACT_UINT(pd,offset+8);
                if (rpc_tree) {
                        proto_tree_add_text(rpc_tree,offset+8,4,
-                               "Program Version: %d",vers);
+                               "Program Version: %u",vers);
                }
 
                if (!BYTES_ARE_IN_FRAME(offset+12,4)) return;
@@ -623,11 +614,12 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                                "Procedure: %s (%d)", procname, proc);
                }
 
-               if (check_col(fd, COL_PROTOCOL)) {
-                       col_add_fstr(fd, COL_PROTOCOL,"%s %s %s",
-                               progname,
+               if (check_col(fd, COL_INFO)) {
+                       col_add_fstr(fd, COL_INFO,"V%u %s %s XID 0x%x",
+                               vers,
                                procname,
-                               msg_type_name);
+                               msg_type_name,
+                               xid);
                }
 
                conversation = find_conversation(&pi.src, &pi.dst, pi.ptype,
@@ -646,7 +638,7 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                if (rpc_call_lookup(&rpc_call_msg)) {
                        /* duplicate request */
                        if (check_col(fd, COL_INFO)) {
-                               col_add_fstr(fd, COL_INFO, "dup XID 0x%x", xid);
+                               col_append_fstr(fd, COL_INFO, " dup XID 0x%x", xid);
                        }
                }
                else {
@@ -703,13 +695,21 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                        proto = rpc_prog->proto;
                        ett = rpc_prog->ett;
                        progname = rpc_prog->progname;
+
+                       if (check_col(fd, COL_PROTOCOL)) {
+                               /* Set the protocol name to the underlying
+                                  program name. */
+                               col_add_fstr(fd, COL_PROTOCOL, "%s",
+                                   progname);
+                       }
                }
 
-               if (check_col(fd, COL_PROTOCOL)) {
-                       col_add_fstr(fd, COL_PROTOCOL,"%s %s %s",
-                               progname,
+               if (check_col(fd, COL_INFO)) {
+                       col_add_fstr(fd, COL_INFO,"V%u %s %s XID 0x%x",
+                               vers,
                                procname,
-                               msg_type_name);
+                               msg_type_name,
+                               xid);
                }
 
                if (rpc_tree) {
@@ -717,14 +717,14 @@ dissect_rpc( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                                "Program: %s (%d)", 
                                progname, prog);
                        proto_tree_add_text(rpc_tree,0,0,
-                               "Program Version: %d", vers);
+                               "Program Version: %u", vers);
                        proto_tree_add_text(rpc_tree,0,0,
                                "Procedure: %s (%d)", procname, proc);
                }
 
                if (rpc_call->replies>1) {
                        if (check_col(fd, COL_INFO)) {
-                                       col_add_fstr(fd, COL_INFO, "dup XID 0x%x", xid);
+                               col_append_fstr(fd, COL_INFO, " dup XID 0x%x", xid);
                        }
                }
 
index 71b996f033f55197bbd4643f5d35debffdb636af..f14880d56fb3c7a0ec7dd280b49547ef0dd90f8d 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
 /* packet.c
  * Routines for packet disassembly
  *
- * $Id: packet.c,v 1.51 1999/10/22 07:17:45 guy Exp $
+ * $Id: packet.c,v 1.52 1999/10/29 02:25:54 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -637,19 +637,25 @@ check_col(frame_data *fd, gint el) {
 /* Adds a vararg list to a packet info string. */
 void
 col_add_fstr(frame_data *fd, gint el, gchar *format, ...) {
-  va_list    ap;
-  int        i;
+  va_list ap;
+  int     i;
+  size_t  max_len;
   
   va_start(ap, format);
   for (i = 0; i < fd->cinfo->num_cols; i++) {
-    if (fd->cinfo->fmt_matx[i][el])
-      vsnprintf(fd->cinfo->col_data[i], COL_MAX_LEN, format, ap);
+    if (fd->cinfo->fmt_matx[i][el]) {
+      if (el == COL_INFO)
+       max_len = COL_MAX_INFO_LEN;
+      else
+       max_len = COL_MAX_LEN;
+      vsnprintf(fd->cinfo->col_data[i], max_len, format, ap);
+    }
   }
 }
 
 void
 col_add_str(frame_data *fd, gint el, const gchar* str) {
-  int i;
+  int    i;
   size_t max_len;
 
   for (i = 0; i < fd->cinfo->num_cols; i++) {
@@ -664,22 +670,42 @@ col_add_str(frame_data *fd, gint el, const gchar* str) {
   }
 }
 
+/* Appends a vararg list to a packet info string. */
+void
+col_append_fstr(frame_data *fd, gint el, gchar *format, ...) {
+  va_list ap;
+  int     i;
+  size_t  len, max_len;
+  
+  va_start(ap, format);
+  for (i = 0; i < fd->cinfo->num_cols; i++) {
+    if (fd->cinfo->fmt_matx[i][el]) {
+      len = strlen(fd->cinfo->col_data[i]);
+      if (el == COL_INFO)
+       max_len = COL_MAX_INFO_LEN;
+      else
+       max_len = COL_MAX_LEN;
+      vsnprintf(&fd->cinfo->col_data[i][len], max_len - len, format, ap);
+    }
+  }
+}
+
 void
 col_append_str(frame_data *fd, gint el, gchar* str) {
-    int i;
-    size_t len, max_len;
+  int    i;
+  size_t len, max_len;
 
-    for (i = 0; i < fd->cinfo->num_cols; i++) {
-        if (fd->cinfo->fmt_matx[i][el]) {
-           len = strlen(fd->cinfo->col_data[i]);
-           if (el == COL_INFO)
-               max_len = COL_MAX_LEN;
-           else
-               max_len = COL_MAX_INFO_LEN;
-           strncat(fd->cinfo->col_data[i], str, max_len - len);
-           fd->cinfo->col_data[i][max_len - 1] = 0;
-        }
+  for (i = 0; i < fd->cinfo->num_cols; i++) {
+    if (fd->cinfo->fmt_matx[i][el]) {
+      len = strlen(fd->cinfo->col_data[i]);
+      if (el == COL_INFO)
+       max_len = COL_MAX_LEN;
+      else
+       max_len = COL_MAX_INFO_LEN;
+      strncat(fd->cinfo->col_data[i], str, max_len - len);
+      fd->cinfo->col_data[i][max_len - 1] = 0;
     }
+  }
 }
        
 void blank_packetinfo(void)