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 * https://www.tttech.com/technologies/time-triggered-ethernet/
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <epan/prefs.h>
21 #include <epan/etypes.h>
23 #include "packet-tte.h"
25 void proto_register_tte(void);
26 void proto_reg_handoff_tte(void);
28 static dissector_handle_t ethertype_handle
;
30 /* Initialize the protocol and registered fields */
33 static int hf_eth_dst
;
34 static int hf_tte_dst_cf
;
35 static int hf_tte_ctid
;
36 static int hf_eth_src
;
37 static int hf_eth_type
;
39 /* preference value pointers */
40 static uint32_t tte_pref_ct_marker
= 0xFFFFFFFF;
41 static uint32_t tte_pref_ct_mask
= 0x0;
43 /* Initialize the subtree pointers */
45 static int ett_tte_macdest
;
48 /* Code to actually dissect the packets */
50 dissect_tte(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
53 ethertype_data_t ethertype_data
;
55 /* Set up structures needed to add the protocol subtree and manage it */
56 proto_item
*tte_root_item
, *tte_macdest_item
;
57 proto_tree
*tte_tree
, *tte_macdest_tree
;
59 /* Check that there's enough data */
60 if (tvb_reported_length(tvb
) < TTE_HEADER_LENGTH
)
63 /* check if data of pcf frame */
65 (tvb_get_ntohs(tvb
, TTE_MAC_LENGTH
* 2) == ETHERTYPE_TTE_PCF
);
67 /* return if no valid constant field is found */
70 if ( (tvb_get_ntohl(tvb
, 0) & tte_pref_ct_mask
) != tte_pref_ct_marker
)
74 /* Make entries in Protocol column and Info column on summary display */
75 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "TTE/");
77 if (tvb_get_ntohs(tvb
, TTE_MAC_LENGTH
* 2) <= IEEE_802_3_MAX_LEN
)
79 col_set_str(pinfo
->cinfo
, COL_INFO
, "TTEthernet Frame");
83 col_set_str(pinfo
->cinfo
, COL_INFO
, "Bogus TTEthernet Frame");
88 /* create display subtree for the protocol */
89 tte_root_item
= proto_tree_add_item(tree
, proto_tte
, tvb
, 0,
90 TTE_HEADER_LENGTH
, ENC_NA
);
92 tte_tree
= proto_item_add_subtree(tte_root_item
, ett_tte
);
94 tte_macdest_item
= proto_tree_add_item(tte_tree
,
95 hf_eth_dst
, tvb
, 0, TTE_MAC_LENGTH
, ENC_NA
);
97 proto_tree_add_item(tte_tree
,
98 hf_eth_src
, tvb
, TTE_MAC_LENGTH
, TTE_MAC_LENGTH
, ENC_NA
);
100 proto_tree_add_item(tte_tree
,
101 hf_eth_type
, tvb
, TTE_MAC_LENGTH
*2, TTE_ETHERTYPE_LENGTH
,
104 tte_macdest_tree
= proto_item_add_subtree(tte_macdest_item
,
107 proto_tree_add_item(tte_macdest_tree
,
108 hf_tte_dst_cf
, tvb
, 0, TTE_MACDEST_CF_LENGTH
, ENC_BIG_ENDIAN
);
110 proto_tree_add_item(tte_macdest_tree
,
111 hf_tte_ctid
, tvb
, TTE_MACDEST_CF_LENGTH
,
112 TTE_MACDEST_CTID_LENGTH
, ENC_BIG_ENDIAN
);
115 /* prevent clearing the Columns...appending cannot be prevented */
116 col_set_fence(pinfo
->cinfo
, COL_PROTOCOL
);
118 /* call std Ethernet dissector */
119 ethertype_data
.etype
= tvb_get_ntohs(tvb
, TTE_MAC_LENGTH
* 2);
120 ethertype_data
.payload_offset
= TTE_HEADER_LENGTH
;
121 ethertype_data
.fh_tree
= NULL
;
122 ethertype_data
.trailer_id
= 0;
123 ethertype_data
.fcs_len
= 0;
125 call_dissector_with_data(ethertype_handle
, tvb
, pinfo
, tree
, ðertype_data
);
131 proto_register_tte(void)
133 module_t
*tte_module
;
135 static hf_register_info hf
[] = {
137 { "Constant Field", "tte.cf",
138 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
142 { "Critical Traffic Identifier", "tte.ctid",
143 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
148 /* Setup protocol subtree array */
149 static int *ett
[] = {
154 /* Register the protocol name and description */
155 proto_tte
= proto_register_protocol("TTEthernet", "TTE", "tte");
157 /* Required function calls to register header fields and subtrees used */
158 proto_register_field_array(proto_tte
, hf
, array_length(hf
));
159 proto_register_subtree_array(ett
, array_length(ett
));
161 /* Register preferences module */
162 tte_module
= prefs_register_protocol(proto_tte
, NULL
);
164 /* Register preferences */
165 prefs_register_uint_preference(tte_module
, "ct_mask_value",
167 "Critical Traffic Mask (base hex)",
168 16, &tte_pref_ct_mask
);
170 prefs_register_uint_preference(tte_module
, "ct_marker_value",
171 "CT Marker (in hex)",
172 "Critical Traffic Marker (base hex)",
173 16, &tte_pref_ct_marker
);
178 proto_reg_handoff_tte(void)
180 heur_dissector_add("eth", dissect_tte
, "TTEthernet", "tte_eth", proto_tte
, HEURISTIC_ENABLE
);
182 hf_eth_dst
= proto_registrar_get_id_byname ("eth.dst");
183 hf_eth_src
= proto_registrar_get_id_byname ("eth.src");
184 hf_eth_type
= proto_registrar_get_id_byname ("eth.type");
186 ethertype_handle
= find_dissector_add_dependency("ethertype", proto_tte
);
190 * Editor modelines - https://www.wireshark.org/tools/modelines.html
195 * indent-tabs-mode: nil
198 * vi: set shiftwidth=4 tabstop=8 expandtab:
199 * :indentSize=4:tabSize=8:noTabs=true: