Use MAC address documentation range in filter examples
[metze/wireshark/wip.git] / epan / dissectors / packet-egd.c
index 77457a740c393a0365f98fa7b83a9ce60eb9fc8c..aba37217a03c941ff66b85dfd70060d12120e01b 100644 (file)
@@ -5,8 +5,6 @@
  * Copyright 2008
  * 29 July 2008 -- ryan wamsley
  *
- * $Id$
- *
  * Wireshark - Network traffic analyzer
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
-#include <string.h>
 #include <epan/packet.h>
 
 #define EGD_PORT 18246 /* 0x4746 */
 #define EGD_ST_CREATEERR    28
 #define EGD_ST_DELETED      30
 
+
+void proto_register_egd(void);
+void proto_reg_handoff_egd(void);
+
 /* Translate status to string */
 static const value_string egd_stat_vals[] = {
   { EGD_ST_NONEW,                  "No new status event has occurred" },
@@ -95,12 +94,9 @@ static void dissect_egd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   col_set_str(pinfo->cinfo, COL_PROTOCOL, "EGD");
 
   /* Clear out stuff in the info column */
-  if (check_col(pinfo->cinfo,COL_INFO))
-  {
-    col_clear(pinfo->cinfo, COL_INFO);
-    col_add_fstr(pinfo->cinfo, COL_INFO, "Data Msg: ExchangeID=0x%08X, RequestID=%05u",
+  col_clear(pinfo->cinfo, COL_INFO);
+  col_add_fstr(pinfo->cinfo, COL_INFO, "Data Msg: ExchangeID=0x%08X, RequestID=%05u",
                  tvb_get_letohl(tvb, 8), tvb_get_letohs(tvb, 2));
-  }
 
   if (tree)
   {
@@ -109,48 +105,48 @@ static void dissect_egd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     proto_tree *egd_tree = NULL;
     tvbuff_t *next_tvb = NULL;
     gint offset, data_length;
-    guint32 stime;
+    guint32 sectime;
     nstime_t egd_time;
 
     memset(&egd_time, 0, sizeof(nstime_t));
     offset = 0;
 
-    ti = proto_tree_add_item(tree, proto_egd, tvb, 0, -1, FALSE);
+    ti = proto_tree_add_item(tree, proto_egd, tvb, 0, -1, ENC_NA);
     egd_tree = proto_item_add_subtree(ti, ett_egd);
-    proto_tree_add_item(egd_tree, hf_egd_type, tvb, offset, 1, FALSE);
+    proto_tree_add_item(egd_tree, hf_egd_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
     offset++;
-    proto_tree_add_item(egd_tree, hf_egd_ver, tvb, offset, 1, FALSE);
+    proto_tree_add_item(egd_tree, hf_egd_ver, tvb, offset, 1, ENC_LITTLE_ENDIAN);
     offset++;
-    proto_tree_add_item(egd_tree, hf_egd_rid, tvb, offset, 2, TRUE);
+    proto_tree_add_item(egd_tree, hf_egd_rid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
     offset += 2;
-    proto_tree_add_item(egd_tree, hf_egd_pid, tvb, offset, 4, FALSE);
+    proto_tree_add_item(egd_tree, hf_egd_pid, tvb, offset, 4, ENC_BIG_ENDIAN);
     offset += 4;
-    proto_tree_add_item(egd_tree, hf_egd_exid, tvb, offset, 4, TRUE);
+    proto_tree_add_item(egd_tree, hf_egd_exid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
     offset += 4;
 
     /* time */
-    stime = tvb_get_ntohl(tvb, offset);
-    if (0 == stime)
+    sectime = tvb_get_letohl(tvb, offset);
+    if (0 == sectime)
     {
-      notime = proto_tree_add_item(egd_tree, hf_egd_notime, tvb, offset, 8, FALSE);
+      notime = proto_tree_add_item(egd_tree, hf_egd_notime, tvb, offset, 8, ENC_LITTLE_ENDIAN);
       proto_item_append_text(notime, "--No TimeStamp");
     }
     else
     {
-      egd_time.secs  = tvb_get_ntohl(tvb, offset);
-      egd_time.nsecs = tvb_get_ntohl(tvb, offset+4);
+      egd_time.secs  = tvb_get_letohl(tvb, offset);
+      egd_time.nsecs = tvb_get_letohl(tvb, offset+4);
       proto_tree_add_time(egd_tree, hf_egd_time, tvb, offset, 8, &egd_time);
     }
     offset += 8;
 
-    proto_tree_add_item(egd_tree, hf_egd_stat, tvb, offset, 4, FALSE);
+    proto_tree_add_item(egd_tree, hf_egd_stat, tvb, offset, 4, ENC_LITTLE_ENDIAN);
     offset += 4;
-    proto_tree_add_item(egd_tree, hf_egd_csig, tvb, offset, 4, FALSE);
+    proto_tree_add_item(egd_tree, hf_egd_csig, tvb, offset, 4, ENC_LITTLE_ENDIAN);
     offset += 4;
-    proto_tree_add_item(egd_tree, hf_egd_resv, tvb, offset, 4, FALSE);
+    proto_tree_add_item(egd_tree, hf_egd_resv, tvb, offset, 4, ENC_LITTLE_ENDIAN);
     offset += 4;
 
-    data_length = tvb_length_remaining(tvb, offset);
+    data_length = tvb_reported_length_remaining(tvb, offset);
     if (data_length > 0)
     {
       next_tvb = tvb_new_subset_remaining(tvb, offset);
@@ -195,12 +191,12 @@ void proto_register_egd(void)
       },
       { &hf_egd_time,
         { "Timestamp", "egd.time",
-          FT_ABSOLUTE_TIME, BASE_NONE,
+          FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
           NULL, 0x0,
           NULL, HFILL }
       },
       { &hf_egd_notime,
-        { "Timestamp", "egd.time",
+        { "Timestamp", "egd.notime",
           FT_UINT64, BASE_HEX,
           NULL, 0x0,
           NULL, HFILL }
@@ -245,9 +241,21 @@ void proto_reg_handoff_egd(void)
   dissector_handle_t egd_handle;
 
   egd_handle = create_dissector_handle(dissect_egd, proto_egd);
-  dissector_add("udp.port", EGD_PORT, egd_handle);
+  dissector_add_uint("udp.port", EGD_PORT, egd_handle);
 
   /* find data dissector */
   data_handle = find_dissector("data");
 }
 
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */