Get rid of a debugging fprintf.
[obnox/wireshark/wip.git] / packet-who.c
index bfc9b05eaf288309870fc5a861c1d37b21291e15..38df766d87cdc9b107f224c2bf2bbf816dd91135 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for who protocol (see man rwhod)
  * Gilbert Ramirez <gram@xiexie.org>
  *
- * $Id: packet-who.c,v 1.3 2000/01/07 22:05:42 guy Exp $
+ * $Id: packet-who.c,v 1.7 2000/05/31 05:07:54 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -89,10 +89,11 @@ static int hf_who_idle = -1;
 static gint ett_who = -1;
 static gint ett_whoent = -1;
 
+#define UDP_PORT_WHO    513
 
 static void dissect_whoent(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
 
-void
+static void
 dissect_who(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 {
 
@@ -136,41 +137,41 @@ dissect_who(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
                /* We already know that the packet has enough data to fill in
                 * the summary info. Retrieve that data */
 
-               who_ti = proto_tree_add_item(tree, proto_who, offset, END_OF_FRAME, NULL);
+               who_ti = proto_tree_add_item(tree, proto_who, NullTVB, offset, END_OF_FRAME, FALSE);
                who_tree = proto_item_add_subtree(who_ti, ett_who);
 
-               proto_tree_add_item(who_tree, hf_who_vers, offset, 1, pd[offset]);
+               proto_tree_add_uint(who_tree, hf_who_vers, NullTVB, offset, 1, pd[offset]);
                offset += 1;
 
 
-               proto_tree_add_item(who_tree, hf_who_type, offset, 1, pd[offset]);
+               proto_tree_add_uint(who_tree, hf_who_type, NullTVB, offset, 1, pd[offset]);
                offset += 1;
 
                /* 2 filler bytes */
                offset += 2;
 
                tv.tv_sec = pntohl(&pd[offset]);
-               proto_tree_add_item(who_tree, hf_who_sendtime, offset, 4, &tv);
+               proto_tree_add_time(who_tree, hf_who_sendtime, NullTVB, offset, 4, &tv);
                offset += 4;
 
                tv.tv_sec = pntohl(&pd[offset]);
-               proto_tree_add_item(who_tree, hf_who_recvtime, offset, 4, &tv);
+               proto_tree_add_time(who_tree, hf_who_recvtime, NullTVB, offset, 4, &tv);
                offset += 4;
 
-               proto_tree_add_item(who_tree, hf_who_hostname, offset, 32, server_name);
+               proto_tree_add_string(who_tree, hf_who_hostname, NullTVB, offset, 32, server_name);
                offset += 32;
 
-               proto_tree_add_item(who_tree, hf_who_loadav_5, offset, 4, loadav_5);
+               proto_tree_add_double(who_tree, hf_who_loadav_5, NullTVB, offset, 4, loadav_5);
                offset += 4;
 
-               proto_tree_add_item(who_tree, hf_who_loadav_10, offset, 4, loadav_10);
+               proto_tree_add_double(who_tree, hf_who_loadav_10, NullTVB, offset, 4, loadav_10);
                offset += 4;
 
-               proto_tree_add_item(who_tree, hf_who_loadav_15, offset, 4, loadav_15);
+               proto_tree_add_double(who_tree, hf_who_loadav_15, NullTVB, offset, 4, loadav_15);
                offset += 4;
 
                tv.tv_sec = pntohl(&pd[offset]);
-               proto_tree_add_item(who_tree, hf_who_boottime, offset, 4, &tv);
+               proto_tree_add_time(who_tree, hf_who_boottime, NullTVB, offset, 4, &tv);
                offset += 4;
 
                dissect_whoent(pd, offset, fd, who_tree);
@@ -202,21 +203,21 @@ dissect_whoent(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
                memcpy(out_line, &pd[line_offset], 8);
                memcpy(out_name, &pd[line_offset+8], 8);
 
-               whoent_ti = proto_tree_add_item(tree, hf_who_whoent, line_offset, SIZE_OF_WHOENT, NULL);
+               whoent_ti = proto_tree_add_item(tree, hf_who_whoent, NullTVB, line_offset, SIZE_OF_WHOENT, FALSE);
                whoent_tree = proto_item_add_subtree(whoent_ti, ett_whoent);
 
-               proto_tree_add_item(whoent_tree, hf_who_tty, line_offset, 8, out_line);
+               proto_tree_add_string(whoent_tree, hf_who_tty, NullTVB, line_offset, 8, out_line);
                line_offset += 8;
 
-               proto_tree_add_item(whoent_tree, hf_who_uid, line_offset, 8, out_name);
+               proto_tree_add_string(whoent_tree, hf_who_uid, NullTVB, line_offset, 8, out_name);
                line_offset += 8;
 
                tv.tv_sec = pntohl(&pd[line_offset]);
-               proto_tree_add_item(whoent_tree, hf_who_timeon, line_offset, 4, &tv);
+               proto_tree_add_time(whoent_tree, hf_who_timeon, NullTVB, line_offset, 4, &tv);
                line_offset += 4;
 
                idle_secs = pntohl(&pd[line_offset]);
-               proto_tree_add_item_format(whoent_tree, hf_who_idle, line_offset, 4, idle_secs,
+               proto_tree_add_uint_format(whoent_tree, hf_who_idle, NullTVB, line_offset, 4, idle_secs,
                                "Idle: %s", time_secs_to_str(idle_secs));
                line_offset += 4;
 
@@ -295,3 +296,8 @@ proto_register_who(void)
        proto_register_subtree_array(ett, array_length(ett));
 }
 
+void
+proto_reg_handoff_who(void)
+{
+       dissector_add("udp.port", UDP_PORT_WHO, dissect_who);
+}