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

Wireshark-dev: Re: [Wireshark-dev] [patch] update for ETHERNET Powerlink dissector

From: David Büchi <bhd@xxxxxxxx>
Date: Sat, 03 Mar 2007 09:38:42 +0100
Hi Daniel,

thank you for your contribution!

The "SDO over UDP" and the improvement of the "Info column" were both on my ToDo-list for a long time ;-)

Based on your improvements I would propose the following additional changes (see attached patch) to the info column:
 - don't show EPL src- and dst-address of SoC frame (same as SoA)
 - show SoA requested service only if it's not "NO_SERVICE"
 - NMT state in StatusResponse in words, not numbers
- don't show MC and PS flags in SoC (it's now configurable via "Preferences")

Furthermore I extended the value_string struct for the NMT-Command-IDs (asnd_cid_vals). This change is used to fully decode the NMTRequest frames.


As we have now the support of "SDO over UDP" we should propably change the display filter of the SDO fields from "epl.asnd.sdo.xxxx" to a more generic "epl.sdo.xxxx".


Best regards,
David


--
David Buechi            Zurich University of Applied Sciences Winterthur
Dipl. Ing. FH                         Institute of Embedded Systems InES
Realtime Communication                                Technikumstrasse 9
Tel: +41 52 267 70 60                                        P.O.Box 805
Fax: +41 52 268 70 60                                 CH-8401 Winterthur




Daniel Krï¿œger schrieb:
> Hello,
>
> thanks to David Buechi for his EPL v2 dissector.
>
> I attached a patch to this dissector, which includes some corrections,
> updates and SDO by UDP support. I will upload a sample capture of SDO by
> UDP to the wiki. The patch is fuzzy tested against the current SVN rev
> under Linux and it builds also under MSVC2005. Maybe I will provide
> further updates in the future.
>
> I have a feature request: is it possible to add a shortcut for "Start
> capture". I start and stop capturing very often and a shortcut is very
> handy. I know that capturing must be configured at first.
>
> cu
>   Daniel
Index: epan/dissectors/packet-epl.c
===================================================================
--- epan/dissectors/packet-epl.c	(revision 20956)
+++ epan/dissectors/packet-epl.c	(working copy)
@@ -1,14 +1,14 @@
 /* packet-epl.c
- * Routines for "Ethernet Powerlink 2.0" dissection 
+ * Routines for "Ethernet Powerlink 2.0" dissection
  * (ETHERNET Powerlink V2.0 Communication Profile Specification Draft Standard Version 1.0.0)
  *
  * Copyright (c) 2006: Zurich University of Applied Sciences Winterthur (ZHW)
  *                     Institute of Embedded Systems (InES)
  *                     http://ines.zhwin.ch
- *                     
- *                     - Dominic B'chaz <bdo[AT]zhwin.ch>
+ *
+ *                     - Dominic Bechaz <bdo[AT]zhwin.ch>
  *                     - Damir Bursic <bum[AT]zhwin.ch>
- *                     - David B_chi <bhd[AT]zhwin.ch>
+ *                     - David Buechi <bhd[AT]zhwin.ch>
  *
  * Copyright (c) 2007: SYS TEC electronic GmbH
  *                     http://www.systec-electronic.com
@@ -45,6 +45,7 @@
 #include <epan/packet.h>
 #include <epan/etypes.h>
 #include <epan/emem.h>
+#include <epan/prefs.h>
 
 #include "packet-epl.h"
 
@@ -222,6 +223,10 @@
 static gint ett_epl_el_entry_type   = -1;
 static gint ett_epl_sdo_entry_type  = -1;
 
+/* preference whether or not display the SoC flags in info column */
+gboolean show_soc_flags = FALSE;
+
+
 /* Define the tap for epl */
 /*static gint epl_tap = -1;*/
 
@@ -287,7 +292,8 @@
         switch (epl_mtyp)
         {
             case EPL_SOC:
-                col_add_fstr(pinfo->cinfo, COL_INFO, "SoC    src = %3d   dst = %3d   ", epl_src, epl_dest);
+                /* source and destination NodeID are fixed according to the spec */
+                col_add_str(pinfo->cinfo, COL_INFO, "SoC    ");
                 break;
 
             case EPL_PREQ:
@@ -450,10 +456,12 @@
     }
     offset += 2;
 
-    if (check_col(pinfo->cinfo, COL_INFO))
-    {
-        col_append_fstr(pinfo->cinfo, COL_INFO, "MC = %d   PS = %d",
-                        ((EPL_SOC_MC_MASK & flags) >> 7), ((EPL_SOC_PS_MASK & flags) >> 6));
+    if (show_soc_flags) {
+        if (check_col(pinfo->cinfo, COL_INFO))
+        {
+            col_append_fstr(pinfo->cinfo, COL_INFO, "MC = %d   PS = %d",
+                            ((EPL_SOC_MC_MASK & flags) >> 7), ((EPL_SOC_PS_MASK & flags) >> 6));
+        }
     }
 
     if (epl_tree)
@@ -634,10 +642,13 @@
     }
     offset += 1;
 
-    if (check_col(pinfo->cinfo, COL_INFO))
+    if (svid != EPL_SOA_NOSERVICE)
     {
-        col_append_fstr(pinfo->cinfo, COL_INFO, "tgt = %3d   %s",
-                        target, match_strval(svid, soa_svid_vals));
+        if (check_col(pinfo->cinfo, COL_INFO))
+        {
+            col_append_fstr(pinfo->cinfo, COL_INFO, "tgt = %3d   %s",
+                            target, match_strval(svid, soa_svid_vals));
+        }
     }
 
     if (epl_tree)
@@ -927,7 +938,7 @@
     nmt_state = tvb_get_guint8(tvb, offset);
     if (check_col(pinfo->cinfo, COL_INFO))
     {
-        col_append_fstr(pinfo->cinfo, COL_INFO, "NMTState = 0x%02X", nmt_state);
+        col_append_fstr(pinfo->cinfo, COL_INFO, "%s   ", match_strval(nmt_state, epl_nmt_cs_vals));
     }
 
     if (epl_tree)
@@ -1482,6 +1493,8 @@
         &ett_epl_el_entry_type,
         &ett_epl_sdo_entry_type,
     };
+    
+    module_t *epl_module;
 
     /* Register the protocol name and description */
     proto_epl = proto_register_protocol("ETHERNET Powerlink v2", "EPL", "epl");
@@ -1490,6 +1503,12 @@
     proto_register_field_array(proto_epl, hf, array_length(hf));
     proto_register_subtree_array(ett, array_length(ett));
 
+    /* register preferences */
+    epl_module = prefs_register_protocol(proto_epl, NULL);
+    
+    prefs_register_bool_preference(epl_module, "show_soc_flags", "Show flags of SoC frame in Info column",
+        "If you are capturing in networks with multiplexed or slow nodes, this can be usefull", &show_soc_flags);
+    
     /* tap-registration */
     /*  epl_tap = register_tap("epl");*/
 }
Index: epan/dissectors/packet-epl.h
===================================================================
--- epan/dissectors/packet-epl.h	(revision 20956)
+++ epan/dissectors/packet-epl.h	(working copy)
@@ -228,6 +228,9 @@
     {EPL_ASND_NMTCOMMAND_NMTPUBLISHEMERGENCYNEW,      "NMTPublishEmergencyNew"    },
     {EPL_ASND_NMTCOMMAND_NMTPUBLISHTIME,              "NMTPublishTime"            },
     {EPL_ASND_NMTCOMMAND_NMTINVALIDSERVICE,           "NMTInvalidService"         },
+    /* "special" values to cover all possibilities of CommandID in NMTRequests */
+    {EPL_ASND_IDENTRESPONSE,                          "IdentResponse"             },
+    {EPL_ASND_STATUSRESPONSE,                         "StatusResponse"            },
     {0,NULL}
 };