2 * Routines for Time Triggered Ethernet dissection
4 * Author: Valentin Ecker, valentin.ecker (AT) tttech.com
5 * Author: Benjamin Roch, benjamin.roch (AT) tttech.com
7 * TTTech Computertechnik AG, Austria.
8 * http://www.tttech.com/solutions/ttethernet/
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
38 #include <epan/packet.h>
39 #include <epan/prefs.h>
40 #include <epan/etypes.h>
42 #include "packet-tte.h"
44 /* Initialize the protocol and registered fields */
45 static int proto_tte = -1;
47 static int hf_eth_dst = -1;
48 static int hf_tte_dst_cf = -1;
49 static int hf_tte_ctid = -1;
50 static int hf_eth_src = -1;
51 static int hf_eth_type = -1;
53 /* preference value pointers */
54 static guint32 tte_pref_ct_marker = 0xFFFFFFFF;
55 static guint32 tte_pref_ct_mask = 0x0;
57 /* Initialize the subtree pointers */
58 static gint ett_tte = -1;
59 static gint ett_tte_macdest = -1;
62 /* Code to actually dissect the packets */
64 dissect_tte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
68 /* Set up structures needed to add the protocol subtree and manage it */
69 proto_item *tte_root_item, *tte_macdest_item;
70 proto_tree *tte_tree, *tte_macdest_tree;
72 /* Check that there's enough data */
73 if (tvb_length(tvb) < TTE_HEADER_LENGTH)
76 /* check if data of pcf frame */
78 (tvb_get_ntohs(tvb, TTE_MAC_LENGTH * 2) == ETHERTYPE_TTE_PCF);
80 /* return if no valid constant field is found */
83 if ( (tvb_get_ntohl(tvb, 0) & tte_pref_ct_mask) != tte_pref_ct_marker)
87 /* Make entries in Protocol column and Info column on summary display */
88 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TTE ");
90 col_set_str(pinfo->cinfo, COL_INFO, "Bogus TTEthernet Frame");
94 /* create display subtree for the protocol */
95 tte_root_item = proto_tree_add_item(tree, proto_tte, tvb, 0,
96 TTE_HEADER_LENGTH, ENC_NA);
98 tte_tree = proto_item_add_subtree(tte_root_item, ett_tte);
100 tte_macdest_item = proto_tree_add_item(tte_tree,
101 hf_eth_dst, tvb, 0, TTE_MAC_LENGTH, FALSE);
103 proto_tree_add_item(tte_tree,
104 hf_eth_src, tvb, TTE_MAC_LENGTH, TTE_MAC_LENGTH, FALSE);
106 proto_tree_add_item(tte_tree,
107 hf_eth_type, tvb, TTE_MAC_LENGTH*2, TTE_ETHERTYPE_LENGTH,
111 tte_macdest_tree = proto_item_add_subtree(tte_macdest_item,
114 proto_tree_add_item(tte_macdest_tree,
115 hf_tte_dst_cf, tvb, 0, TTE_MACDEST_CF_LENGTH, ENC_BIG_ENDIAN);
117 proto_tree_add_item(tte_macdest_tree,
118 hf_tte_ctid, tvb, TTE_MACDEST_CF_LENGTH,
119 TTE_MACDEST_CTID_LENGTH, ENC_BIG_ENDIAN);
122 /* prevent clearing the Columns...appending cannot be prevented */
123 col_set_fence(pinfo->cinfo, COL_PROTOCOL);
125 /* call std Ethernet dissector */
126 ethertype (tvb_get_ntohs(tvb, TTE_MAC_LENGTH * 2), tvb
127 , 14, pinfo, tree, NULL, hf_eth_type, 0, 0 );
129 return tvb_length(tvb);
134 proto_register_tte(void)
136 module_t *tte_module;
138 static hf_register_info hf[] = {
140 { "Constant Field", "tte.cf",
141 FT_UINT32, BASE_HEX, NULL, 0x0,
145 { "Critical Traffic Identifier", "tte.ctid",
146 FT_UINT16, BASE_HEX, NULL, 0x0,
151 /* Setup protocol subtree array */
152 static gint *ett[] = {
157 /* Register the protocol name and description */
158 proto_tte = proto_register_protocol("TTEthernet", "TTE", "tte");
160 /* Required function calls to register header fields and subtrees used */
161 proto_register_field_array(proto_tte, hf, array_length(hf));
162 proto_register_subtree_array(ett, array_length(ett));
164 /* Register preferences module */
165 tte_module = prefs_register_protocol(proto_tte, NULL);
167 /* Register preferences */
168 prefs_register_uint_preference(tte_module, "ct_mask_value",
170 "Critical Traffic Mask (base hex)",
171 16, &tte_pref_ct_mask);
173 prefs_register_uint_preference(tte_module, "ct_marker_value",
174 "CT Marker (in hex)",
175 "Critical Traffic Marker (base hex)",
176 16, &tte_pref_ct_marker);
181 proto_reg_handoff_tte(void)
183 heur_dissector_add("eth", dissect_tte, proto_tte);
185 hf_eth_dst = proto_registrar_get_byname ("eth.dst")->id;
186 hf_eth_src = proto_registrar_get_byname ("eth.src")->id;
187 hf_eth_type = proto_registrar_get_byname ("eth.type")->id;