2 * Routines for Time Triggered Ethernet Protocol Control Frame dissection
4 * Author: Valentin Ecker
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/etypes.h>
22 #include "packet-tte.h"
24 void proto_register_tte_pcf(void);
25 void proto_reg_handoff_tte_pcf(void);
27 /* Initialize the protocol and registered fields */
28 static int proto_tte_pcf
;
30 static int hf_tte_pcf_ic
;
31 static int hf_tte_pcf_mn
;
32 /* static int hf_tte_pcf_res0; */
33 static int hf_tte_pcf_sp
;
34 static int hf_tte_pcf_sd
;
35 static int hf_tte_pcf_type
;
36 /* static int hf_tte_pcf_res1; */
37 static int hf_tte_pcf_tc
;
39 /* Initialize the subtree pointers */
40 static int ett_tte_pcf
;
42 static dissector_handle_t tte_pcf_handle
;
44 static const value_string pcf_type_str_vals
[] =
45 { {2, "integration frame"}
46 , {4, "coldstart frame"}
47 , {8, "coldstart ack frame"}
52 /* Code to actually dissect the packets */
54 dissect_tte_pcf(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
56 /* Set up structures needed to add the protocol subtree and manage it */
57 proto_item
*tte_pcf_root_item
;
58 proto_tree
*tte_pcf_tree
;
60 /* variables used to store the fields displayed in the info_column */
61 uint8_t sync_priority
= 0;
62 uint8_t sync_domain
= 0;
64 /* Check that there's enough data */
65 if (tvb_reported_length(tvb
) < TTE_PCF_LENGTH
)
70 /* get sync_priority and sync_domain */
71 sync_priority
= tvb_get_uint8(tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_LENGTH
+
73 sync_domain
= tvb_get_uint8(tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_LENGTH
+
74 TTE_PCF_RES0_LENGTH
+TTE_PCF_SP_LENGTH
);
76 /* Make entries in Protocol column and Info column on summary display */
77 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PCF");
79 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
80 "Sync Domain: 0x%02X Sync Priority: 0x%02X",
81 sync_domain
, sync_priority
);
85 /* create display subtree for the protocol */
86 tte_pcf_root_item
= proto_tree_add_item(tree
, proto_tte_pcf
, tvb
, 0,
87 TTE_PCF_LENGTH
, ENC_NA
);
89 tte_pcf_tree
= proto_item_add_subtree(tte_pcf_root_item
, ett_tte_pcf
);
91 proto_tree_add_item(tte_pcf_tree
,
92 hf_tte_pcf_ic
, tvb
, 0, TTE_PCF_IC_LENGTH
, ENC_BIG_ENDIAN
);
94 proto_tree_add_item(tte_pcf_tree
,
95 hf_tte_pcf_mn
, tvb
, TTE_PCF_IC_LENGTH
, TTE_PCF_MN_LENGTH
, ENC_BIG_ENDIAN
);
97 /* RESERVED FIELD --- will not be displayed */
98 /* proto_tree_add_item(tte_pcf_tree,
99 hf_tte_pcf_res0, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH,
100 TTE_PCF_RES0_LENGTH, ENC_BIG_ENDIAN); */
102 proto_tree_add_item(tte_pcf_tree
,
103 hf_tte_pcf_sp
, tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_LENGTH
+
104 TTE_PCF_RES0_LENGTH
, TTE_PCF_SP_LENGTH
, ENC_BIG_ENDIAN
);
106 proto_tree_add_item(tte_pcf_tree
,
107 hf_tte_pcf_sd
, tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_LENGTH
+
108 TTE_PCF_RES0_LENGTH
+TTE_PCF_SP_LENGTH
, TTE_PCF_SD_LENGTH
, ENC_BIG_ENDIAN
);
110 proto_tree_add_item(tte_pcf_tree
,
111 hf_tte_pcf_type
, tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_LENGTH
+
112 TTE_PCF_RES0_LENGTH
+TTE_PCF_SP_LENGTH
+TTE_PCF_SD_LENGTH
,
113 TTE_PCF_TYPE_LENGTH
, ENC_BIG_ENDIAN
);
115 /* RESERVED FIELD --- will not be displayed */
116 /* proto_tree_add_item(tte_pcf_tree,
117 hf_tte_pcf_res1, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
118 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
119 TTE_PCF_TYPE_LENGTH, TTE_PCF_RES1_LENGTH, ENC_NA); */
121 proto_tree_add_item(tte_pcf_tree
,
122 hf_tte_pcf_tc
, tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_LENGTH
+
123 TTE_PCF_RES0_LENGTH
+TTE_PCF_SP_LENGTH
+TTE_PCF_SD_LENGTH
+
124 TTE_PCF_TYPE_LENGTH
+TTE_PCF_RES1_LENGTH
, TTE_PCF_TC_LENGTH
, ENC_BIG_ENDIAN
);
127 return tvb_captured_length(tvb
);
132 proto_register_tte_pcf(void)
134 static hf_register_info hf
[] = {
137 { "Integration Cycle", "tte_pcf.ic",
138 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
142 { "Membership New", "tte_pcf.mn",
143 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
148 { "Reserved 0", "tte_pcf.res0",
149 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
154 { "Sync Priority", "tte_pcf.sp",
155 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
159 { "Sync Domain", "tte_pcf.sd",
160 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
164 { "Type", "tte_pcf.type",
165 FT_UINT8
, BASE_HEX
, VALS(pcf_type_str_vals
), 0x0F,
170 { "Reserved 1", "tte_pcf.res1",
171 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
176 { "Transparent Clock", "tte_pcf.tc",
177 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
182 /* Setup protocol subtree array */
183 static int *ett
[] = {
187 /* Register the protocol name and description */
188 proto_tte_pcf
= proto_register_protocol("TTEthernet Protocol Control Frame",
189 "TTE PCF", "tte_pcf");
191 /* Required function calls to register header fields and subtrees used */
192 proto_register_field_array(proto_tte_pcf
, hf
, array_length(hf
));
193 proto_register_subtree_array(ett
, array_length(ett
));
195 tte_pcf_handle
= register_dissector("tte_pcf", dissect_tte_pcf
, proto_tte_pcf
);
200 proto_reg_handoff_tte_pcf(void)
202 dissector_add_uint("ethertype", ETHERTYPE_TTE_PCF
, tte_pcf_handle
);
207 * Editor modelines - https://www.wireshark.org/tools/modelines.html
212 * indent-tabs-mode: nil
215 * vi: set shiftwidth=4 tabstop=8 expandtab:
216 * :indentSize=4:tabSize=8:noTabs=true: