diff options
author | Jaap Keuter <jaap.keuter@xs4all.nl> | 2008-12-10 07:00:26 +0000 |
---|---|---|
committer | Jaap Keuter <jaap.keuter@xs4all.nl> | 2008-12-10 07:00:26 +0000 |
commit | 66d54fa2cef93752e757c8d36e4a4c9fefc6d165 (patch) | |
tree | a146ddc21404ef0a4dd0e1e1b74a606a3159e2e6 | |
parent | 6f659679f7e1dd8b7056ed2aa2fedf149b7d22d4 (diff) |
From Benjamin Roch:
This contains the source for dissecting TTEthernet packets (including Protocol Control Frames) conforming to our TTEthernet specification as dissector for Wireshark.
svn path=/trunk/; revision=26955
-rw-r--r-- | epan/dissectors/Makefile.common | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-ethertype.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-tte-pcf.c | 226 | ||||
-rw-r--r-- | epan/dissectors/packet-tte.c | 216 | ||||
-rw-r--r-- | epan/dissectors/packet-tte.h | 56 | ||||
-rw-r--r-- | epan/etypes.h | 4 |
6 files changed, 506 insertions, 0 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 64a7caa18a..1d2aca5275 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -798,6 +798,8 @@ DISSECTOR_SRC = \ packet-tr.c \ packet-trmac.c \ packet-tsp.c \ + packet-tte.c \ + packet-tte-pcf.c \ packet-turbocell.c \ packet-turnchannel.c \ packet-tuxedo.c \ @@ -1139,6 +1141,7 @@ DISSECTOR_INCLUDES = \ packet-tns.h \ packet-tpkt.h \ packet-tr.h \ + packet-tte.h \ packet-udp.h \ packet-umts_fp.h \ packet-usb.h \ diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c index dbcdb8b18f..3a7a4b2bde 100644 --- a/epan/dissectors/packet-ethertype.c +++ b/epan/dissectors/packet-ethertype.c @@ -114,6 +114,7 @@ const value_string etype_vals[] = { {ETHERTYPE_TIPC, "Transparent Inter Process Communication" }, {ETHERTYPE_LLDP, "802.1 Link Layer Discovery Protocol (LLDP)" }, {ETHERTYPE_3GPP2, "CDMA2000 A10 3GPP2 Packet" }, + {ETHERTYPE_TTE_PCF, "TTEthernet Protocol Control Frame" }, {ETHERTYPE_LLTD, "Link Layer Topology Discovery (LLTD)" }, {ETHERTYPE_WSMP, "(WAVE) Short Message Protocol (WSM)" }, {ETHERTYPE_COBRANET, "Cirrus Cobranet Packet" }, diff --git a/epan/dissectors/packet-tte-pcf.c b/epan/dissectors/packet-tte-pcf.c new file mode 100644 index 0000000000..d2832daef7 --- /dev/null +++ b/epan/dissectors/packet-tte-pcf.c @@ -0,0 +1,226 @@ +/* packet-tte-pcf.c + * Routines for Time Triggered Ethernet Protocol Control Frame dissection + * + * Author: Valentin Ecker, valentin.ecker (AT) tttech.com + * TTTech Computertechnik AG, Austria. + * http://www.tttech.com/solutions/ttethernet/ + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <glib.h> + +#include <epan/packet.h> +#include <epan/etypes.h> + +#include "packet-tte.h" + + +/* Forward declaration we need below */ +void proto_reg_handoff_tte_pcf(void); + +/* Initialize the protocol and registered fields */ +static int proto_tte_pcf = -1; + +static int hf_tte_pcf = -1; +static int hf_tte_pcf_ic = -1; +static int hf_tte_pcf_mn = -1; +static int hf_tte_pcf_res0 = -1; +static int hf_tte_pcf_sp = -1; +static int hf_tte_pcf_sd = -1; +static int hf_tte_pcf_type = -1; +static int hf_tte_pcf_res1 = -1; +static int hf_tte_pcf_tc = -1; + +/* Initialize the subtree pointers */ +static gint ett_tte_pcf = -1; + + +/* Code to actually dissect the packets */ +static void +dissect_tte_pcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + /* Set up structures needed to add the protocol subtree and manage it */ + proto_item *tte_pcf_root_item; + proto_tree *tte_pcf_tree; + + /* variables used to store the fields displayed in the info_column */ + guint8 sync_priority = 0; + guint8 sync_domain = 0; + + /* Check that there's enough data */ + if (tvb_length(tvb) < TTE_PCF_LENGTH ) + { + return; + } + + /* get sync_priority and sync_domain */ + sync_priority = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH); + sync_domain = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH); + + /* Make entries in Protocol column and Info column on summary display */ + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCF"); + + if (check_col(pinfo->cinfo, COL_INFO)) + col_add_fstr(pinfo->cinfo, COL_INFO, + "Sync Domain: 0x%02X Sync Priority: 0x%02X", + sync_domain, sync_priority); + + if (tree) { + + /* create display subtree for the protocol */ + tte_pcf_root_item = proto_tree_add_item(tree, proto_tte_pcf, tvb, 0, + TTE_PCF_LENGTH, FALSE); + + tte_pcf_tree = proto_item_add_subtree(tte_pcf_root_item, ett_tte_pcf); + + proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_ic, tvb, 0, TTE_PCF_IC_LENGTH, FALSE); + + proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_mn, tvb, TTE_PCF_IC_LENGTH, TTE_PCF_MN_LENGTH, FALSE); + + /* RESERVED FIELD --- will not be displayed */ + /* proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_res0, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH, + TTE_PCF_RES0_LENGTH, FALSE); */ + + proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_sp, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH, TTE_PCF_SP_LENGTH, FALSE); + + proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_sd, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH, TTE_PCF_SD_LENGTH, FALSE); + + proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_type, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH, + TTE_PCF_TYPE_LENGTH, FALSE); + + /* RESERVED FIELD --- will not be displayed */ + /* proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_res1, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+ + TTE_PCF_TYPE_LENGTH, TTE_PCF_RES1_LENGTH, FALSE); */ + + proto_tree_add_item(tte_pcf_tree, + hf_tte_pcf_tc, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+ + TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+ + TTE_PCF_TYPE_LENGTH+TTE_PCF_RES1_LENGTH, TTE_PCF_TC_LENGTH, FALSE); + } + +} + + +void +proto_register_tte_pcf(void) +{ + static hf_register_info hf[] = { + + { &hf_tte_pcf, + { "Protocol Control Frame", "tte.pcf", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_ic, + { "Integration Cycle", "tte.pcf.ic", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_mn, + { "Membership New", "tte.pcf.mn", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_res0, + { "Reserved 0", "tte.pcf.res0", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_sp, + { "Sync Priority", "tte.pcf.sp", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_sd, + { "Sync Domain", "tte.pcf.sd", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_type, + { "Type", "tte.pcf.type", + FT_UINT8, BASE_HEX, NULL, 0xF0, + NULL, HFILL } + }, + { &hf_tte_pcf_res1, + { "Reserved 1", "tte.pcf.res1", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_pcf_tc, + { "Transparent Clock", "tte.pcf.tc", + FT_UINT64, BASE_HEX, NULL, 0x0, + NULL, HFILL } + } + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_tte_pcf + }; + + /* Register the protocol name and description */ + proto_tte_pcf = proto_register_protocol("TTEthernet Protocol Control Frame", + "TTE PCF", "tte_pcf"); + + /* Required function calls to register header fields and subtrees used */ + proto_register_field_array(proto_tte_pcf, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + register_dissector("tte_pcf", dissect_tte_pcf, proto_tte_pcf); + +} + + +void +proto_reg_handoff_tte_pcf(void) +{ + dissector_handle_t tte_pcf_handle; + + /* initialize the pcf handle */ + tte_pcf_handle = create_dissector_handle(dissect_tte_pcf, proto_tte_pcf); + + dissector_add("ethertype", ETHERTYPE_TTE_PCF, tte_pcf_handle); + +} + diff --git a/epan/dissectors/packet-tte.c b/epan/dissectors/packet-tte.c new file mode 100644 index 0000000000..2c29a454a5 --- /dev/null +++ b/epan/dissectors/packet-tte.c @@ -0,0 +1,216 @@ +/* packet-tte.c + * Routines for Time Triggered Ethernet dissection + * + * Author: Valentin Ecker, valentin.ecker (AT) tttech.com + * TTTech Computertechnik AG, Austria. + * http://www.tttech.com/solutions/ttethernet/ + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <glib.h> + +#include <epan/packet.h> +#include <epan/prefs.h> +#include <epan/etypes.h> + +#include "packet-tte.h" + + +/* Forward declaration we need below */ +void proto_reg_handoff_tte(void); + +/* Initialize the protocol and registered fields */ +static int proto_tte = -1; + +static int hf_tte_macdest = -1; +static int hf_tte_macdest_cf1 = -1; +static int hf_tte_macdest_ctid = -1; +static int hf_tte_macsrc = -1; +static int hf_tte_ethertype = -1; + +/* preference value pointers */ +static guint32 tte_pref_ct_marker = 0xFFFFFFFF; +static guint32 tte_pref_ct_mask = 0x0; +static dissector_table_t ethertype_dissector_table; + +/* Initialize the subtree pointers */ +static gint ett_tte = -1; +static gint ett_tte_macdest = -1; +static gint ett_tte_macsrc = -1; + + + +/* Code to actually dissect the packets */ +static int +dissect_tte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + tvbuff_t* tvb_next; + int is_frame_pcf; + + /* Set up structures needed to add the protocol subtree and manage it */ + proto_item *tte_root_item, *tte_macdest_item, *tte_macsrc_item; + proto_tree *tte_tree, *tte_macdest_tree/*, *tte_macsrc_tree*/; + + /* Check that there's enough data */ + if (tvb_length(tvb) < TTE_HEADER_LENGTH) + return 0; + + /* check if data of pcf frame */ + is_frame_pcf = + (tvb_get_ntohs(tvb, TTE_MAC_LENGTH * 2) == ETHERTYPE_TTE_PCF); + + /* return if no valid cosntant field is found */ + if (!is_frame_pcf) + { + if ( (tvb_get_ntohl(tvb, 0) & tte_pref_ct_mask) != tte_pref_ct_marker) + return 0; + } + + /* Make entries in Protocol column and Info column on summary display */ + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "TTE "); + + if (check_col(pinfo->cinfo, COL_INFO)) + col_set_str(pinfo->cinfo, COL_INFO, "Bogus TTEthernet Frame"); + + if (tree) { + + /* create display subtree for the protocol */ + tte_root_item = proto_tree_add_item(tree, proto_tte, tvb, 0, + TTE_HEADER_LENGTH, FALSE); + + tte_tree = proto_item_add_subtree(tte_root_item, ett_tte); + + tte_macdest_item = proto_tree_add_item(tte_tree, + hf_tte_macdest, tvb, 0, TTE_MAC_LENGTH, FALSE); + + tte_macsrc_item = proto_tree_add_item(tte_tree, + hf_tte_macsrc, tvb, TTE_MAC_LENGTH, TTE_MAC_LENGTH, FALSE); + + proto_tree_add_item(tte_tree, + hf_tte_ethertype, tvb, TTE_MAC_LENGTH*2, TTE_ETHERTYPE_LENGTH, + FALSE); + + tte_macdest_tree = proto_item_add_subtree(tte_macdest_item, + ett_tte_macdest); + + proto_tree_add_item(tte_macdest_tree, + hf_tte_macdest_cf1, tvb, 0, TTE_MACDEST_CF_LENGTH, FALSE); + + proto_tree_add_item(tte_macdest_tree, + hf_tte_macdest_ctid, tvb, TTE_MACDEST_CF_LENGTH, + TTE_MACDEST_CTID_LENGTH, FALSE); + } + + tvb_next = tvb_new_subset(tvb, TTE_HEADER_LENGTH, -1, -1); + + /* prevent the Columns to be cleared...appending cannot be prevented */ + col_set_fence(pinfo->cinfo, COL_PROTOCOL); + + /* call std Ethernet dissector */ + dissector_try_port(ethertype_dissector_table, + tvb_get_ntohs(tvb, TTE_MAC_LENGTH * 2), tvb_next, pinfo, tree); + + return tvb_length(tvb); +} + + +void +proto_register_tte(void) +{ + module_t *tte_module; + + static hf_register_info hf[] = { + + { &hf_tte_macdest, + { "Destination", "tte.macdest", + FT_ETHER, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_macdest_cf1, + { "Constant Field", "tte.cf1", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_macdest_ctid, + { "Critical Traffic Identifier", "tte.ctid", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_macsrc, + { "Source", "tte.macsrc", + FT_ETHER, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, + { &hf_tte_ethertype, + { "Type", "tte.type", + FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, + NULL, HFILL } + } + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_tte, + &ett_tte_macdest, + &ett_tte_macsrc + }; + + /* Register the protocol name and description */ + proto_tte = proto_register_protocol("TTEthernet", "TTE", "tte"); + + /* Required function calls to register header fields and subtrees used */ + proto_register_field_array(proto_tte, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + /* Register preferences module */ + tte_module = prefs_register_protocol(proto_tte, proto_reg_handoff_tte); + + /* Register preferences */ + prefs_register_uint_preference(tte_module, "ct_mask_value", + "CT Mask", + "Critical Traffic Mask (base hex)", + 16, &tte_pref_ct_mask); + + prefs_register_uint_preference(tte_module, "ct_marker_value", + "CT Marker", + "Critical Traffic Marker (base hex)", + 16, &tte_pref_ct_marker); +} + + +void +proto_reg_handoff_tte(void) +{ + heur_dissector_add("eth", dissect_tte, proto_tte); + + /* find the ethertype dissector table */ + ethertype_dissector_table = find_dissector_table("ethertype"); +} diff --git a/epan/dissectors/packet-tte.h b/epan/dissectors/packet-tte.h new file mode 100644 index 0000000000..323b56af80 --- /dev/null +++ b/epan/dissectors/packet-tte.h @@ -0,0 +1,56 @@ +/* packet-tte.h + * Header for Time Triggered Ethernet dissection + * + * Author: Valentin Ecker, valentin.ecker (AT) tttech.com + * TTTech Computertechnik AG, Austria. + * http://www.tttech.com/solutions/ttethernet/ + * + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#ifndef _PACKET_TTE_H_ +#define _PACKET_TTE_H_ + +/* in bytes, at least MAC dest/source and EthernetType must be there + to look for TTE */ +#define TTE_HEADER_LENGTH 14 + +#define TTE_MAC_LENGTH 6 /* in bytes */ +#define TTE_MACDEST_CF_LENGTH 4 /* in bytes */ +#define TTE_MACDEST_CTID_LENGTH 2 /* in bytes */ + +#define TTE_ETHERTYPE_LENGTH 2 /* in bytes */ + +#define TTE_PCF_LENGTH 28 /* in bytes */ +#define TTE_PCF_IC_LENGTH 4 /* in bytes */ +#define TTE_PCF_MN_LENGTH 4 /* in bytes */ +#define TTE_PCF_RES0_LENGTH 4 /* in bytes */ +#define TTE_PCF_SP_LENGTH 1 /* in bytes */ +#define TTE_PCF_SD_LENGTH 1 /* in bytes */ +#define TTE_PCF_TYPE_LENGTH 1 /* in bytes ( actually 4 bits ) */ +#define TTE_PCF_RES1_LENGTH 5 /* in bytes ( actually 44 bits ) */ +#define TTE_PCF_TC_LENGTH 8 /* in bytes */ + + +#endif /* _PACKET_TTE_H_ */ + diff --git a/epan/etypes.h b/epan/etypes.h index c7c91d16da..b419793e56 100644 --- a/epan/etypes.h +++ b/epan/etypes.h @@ -390,6 +390,10 @@ #define ETHERTYPE_FIP 0x8914 /* FCoE Initialization Protocol */ #endif +#ifndef ETHERTYPE_TTE_PCF +#define ETHERTYPE_TTE_PCF 0x891d /* TTEthernet Protocol Control Frame */ +#endif + #ifndef ETHERTYPE_LOOP #define ETHERTYPE_LOOP 0x9000 /* used for layer 2 testing (do i see my own frames on the wire) */ #endif |