Wireshark-dev: [Wireshark-dev] [PATCH] ETHERNET Powerlink enhancement
From: David Büchi <bhd@xxxxxxxx>
Date: Wed, 06 Jun 2007 07:40:17 +0200
Hi,the attached patch adds a small enhancement for the ETHERNET Powerlink dissector (some well-known CANopen device profiles are decoded in human readable plaintext in the IdentResponse frame).
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
Index: epan/dissectors/packet-epl.c =================================================================== --- epan/dissectors/packet-epl.c (revision 22053) +++ epan/dissectors/packet-epl.c (working copy) @@ -119,6 +119,7 @@ static gint hf_epl_asnd_identresponse_pos = -1; static gint hf_epl_asnd_identresponse_rst = -1; static gint hf_epl_asnd_identresponse_dt = -1; +static gint hf_epl_asnd_identresponse_profile = -1; static gint hf_epl_asnd_identresponse_vid = -1; static gint hf_epl_asnd_identresponse_productcode = -1; static gint hf_epl_asnd_identresponse_rno = -1; @@ -784,6 +785,7 @@ dissect_epl_asnd_ires(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, guint8 epl_src, gint offset) { guint8 eplversion; + guint16 profile,additional; guint32 epl_asnd_identresponse_ipa, epl_asnd_identresponse_snm, epl_asnd_identresponse_gtw; guint32 epl_asnd_ires_feat, device_type; proto_item *ti_feat; @@ -848,7 +850,13 @@ proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_rst, tvb, offset, 4, TRUE); offset += 6; - proto_tree_add_uint(epl_tree, hf_epl_asnd_identresponse_dt, tvb, offset, 4, device_type); + profile = tvb_get_letohs(tvb, offset); + additional = tvb_get_letohs(tvb, offset+2); + proto_tree_add_string_format(epl_tree, hf_epl_asnd_identresponse_dt, tvb, offset, + 4, "", "Device Type: Profil %d (%s), Additional Information: 0x%4.4X", + profile, val_to_str(profile, epl_device_profiles, "Unkown Profile"), additional); + + proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_profile, tvb, offset, 2, TRUE); offset += 4; proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_vid, tvb, offset, 4, TRUE); @@ -899,7 +907,7 @@ if (check_col(pinfo->cinfo, COL_INFO)) { - col_append_fstr(pinfo->cinfo, COL_INFO, "DevType = 0x%08X", device_type); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(profile, epl_device_profiles, "Device Profile %d")); } return offset; @@ -1392,7 +1400,8 @@ { &hf_epl_asnd_identresponse_pis, { "PollInSize", "epl.asnd.ires.pollinsize", FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL }}, { &hf_epl_asnd_identresponse_pos, { "PollOutSize", "epl.asnd.ires.polloutsizes", FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL }}, { &hf_epl_asnd_identresponse_rst, { "ResponseTime", "epl.asnd.ires.resptime", FT_UINT32, BASE_DEC, NULL, 0x00, "", HFILL }}, -{ &hf_epl_asnd_identresponse_dt, { "DeviceType", "epl.asnd.ires.devicetype", FT_UINT32, BASE_DEC_HEX, NULL, 0x00, "", HFILL }}, +{ &hf_epl_asnd_identresponse_dt, { "DeviceType", "epl.asnd.ires.devicetype", FT_STRING, BASE_DEC, NULL, 0x00, "", HFILL }}, +{ &hf_epl_asnd_identresponse_profile, { "Profile", "epl.asnd.ires.profile", FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL }}, { &hf_epl_asnd_identresponse_vid, { "VendorId", "epl.asnd.ires.vendorid", FT_UINT32, BASE_DEC_HEX, NULL, 0x00, "", HFILL }}, { &hf_epl_asnd_identresponse_productcode,{ "ProductCode", "epl.asnd.ires.productcode", FT_UINT32, BASE_DEC_HEX, NULL, 0x00, "", HFILL }}, { &hf_epl_asnd_identresponse_rno, { "RevisionNumber", "epl.asnd.ires.revisionno", FT_UINT32, BASE_DEC_HEX, NULL, 0x00, "", HFILL }}, @@ -1503,7 +1512,7 @@ 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 useful", &show_soc_flags); - + /* tap-registration */ /* epl_tap = register_tap("epl");*/ } Index: epan/dissectors/packet-epl.h =================================================================== --- epan/dissectors/packet-epl.h (revision 22053) +++ epan/dissectors/packet-epl.h (working copy) @@ -304,6 +304,30 @@ {0,NULL} }; + + +// EPL Device Profiles according to CANopen +#define EPL_PROFILE_NO 0 +#define EPL_PROFILE_GENERIC_IO 401 +#define EPL_PROFILE_DRIVE 402 +#define EPL_PROFILE_HMI 403 +#define EPL_PROFILE_MEASURING 404 +#define EPL_PROFILE_PLC 405 +#define EPL_PROFILE_ENCODER 406 + + +static const value_string epl_device_profiles[] = { + {EPL_PROFILE_NO, "No Standard Device"}, + {EPL_PROFILE_GENERIC_IO, "Generic I/O module"}, + {EPL_PROFILE_DRIVE, "Drive and motion control"}, + {EPL_PROFILE_HMI, "Human Machine Interface"}, + {EPL_PROFILE_MEASURING, "Measuring device"}, + {EPL_PROFILE_PLC, "IEC 61131-3 PLC"}, + {EPL_PROFILE_ENCODER, "Encoder"}, + {0,NULL} +}; + + /* SDO SequenceLayer */ #define EPL_ASND_SDO_SEQ_RECEIVE_SEQUENCE_NUMBER_OFFSET 4 #define EPL_ASND_SDO_SEQ_RECEIVE_CON_OFFSET 4
- Follow-Ups:
- Re: [Wireshark-dev] [PATCH] ETHERNET Powerlink enhancement
- From: Bill Meier
- Re: [Wireshark-dev] [PATCH] ETHERNET Powerlink enhancement
- Prev by Date: Re: [Wireshark-dev] how to make tcap subdissector in plugin
- Next by Date: Re: [Wireshark-dev] help needed in tracking down a bug in SSL dissector
- Previous by thread: Re: [Wireshark-dev] how to make tcap subdissector in plugin
- Next by thread: Re: [Wireshark-dev] [PATCH] ETHERNET Powerlink enhancement
- Index(es):