Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-tte-pcf.c
blob08a41cfec24ee711ebd7fbab013d7c0fa278fff7
1 /* packet-tte-pcf.c
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
17 #include "config.h"
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"}
48 , {0, NULL}
52 /* Code to actually dissect the packets */
53 static int
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 )
67 return 0;
70 /* get sync_priority and sync_domain */
71 sync_priority = tvb_get_uint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
72 TTE_PCF_RES0_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);
83 if (tree) {
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);
131 void
132 proto_register_tte_pcf(void)
134 static hf_register_info hf[] = {
136 { &hf_tte_pcf_ic,
137 { "Integration Cycle", "tte_pcf.ic",
138 FT_UINT32, BASE_HEX, NULL, 0x0,
139 NULL, HFILL }
141 { &hf_tte_pcf_mn,
142 { "Membership New", "tte_pcf.mn",
143 FT_UINT32, BASE_HEX, NULL, 0x0,
144 NULL, HFILL }
146 #if 0
147 { &hf_tte_pcf_res0,
148 { "Reserved 0", "tte_pcf.res0",
149 FT_UINT32, BASE_HEX, NULL, 0x0,
150 NULL, HFILL }
152 #endif
153 { &hf_tte_pcf_sp,
154 { "Sync Priority", "tte_pcf.sp",
155 FT_UINT8, BASE_HEX, NULL, 0x0,
156 NULL, HFILL }
158 { &hf_tte_pcf_sd,
159 { "Sync Domain", "tte_pcf.sd",
160 FT_UINT8, BASE_HEX, NULL, 0x0,
161 NULL, HFILL }
163 { &hf_tte_pcf_type,
164 { "Type", "tte_pcf.type",
165 FT_UINT8, BASE_HEX, VALS(pcf_type_str_vals), 0x0F,
166 NULL, HFILL }
168 #if 0
169 { &hf_tte_pcf_res1,
170 { "Reserved 1", "tte_pcf.res1",
171 FT_BYTES, BASE_NONE, NULL, 0x0,
172 NULL, HFILL }
174 #endif
175 { &hf_tte_pcf_tc,
176 { "Transparent Clock", "tte_pcf.tc",
177 FT_UINT64, BASE_HEX, NULL, 0x0,
178 NULL, HFILL }
182 /* Setup protocol subtree array */
183 static int *ett[] = {
184 &ett_tte_pcf
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);
199 void
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
209 * Local variables:
210 * c-basic-offset: 4
211 * tab-width: 8
212 * indent-tabs-mode: nil
213 * End:
215 * vi: set shiftwidth=4 tabstop=8 expandtab:
216 * :indentSize=4:tabSize=8:noTabs=true: