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 * 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,
39 #include <epan/packet.h>
40 #include <epan/etypes.h>
42 #include "packet-tte.h"
44 /* Initialize the protocol and registered fields */
45 static int proto_tte_pcf = -1;
47 static int hf_tte_pcf = -1;
48 static int hf_tte_pcf_ic = -1;
49 static int hf_tte_pcf_mn = -1;
50 static int hf_tte_pcf_res0 = -1;
51 static int hf_tte_pcf_sp = -1;
52 static int hf_tte_pcf_sd = -1;
53 static int hf_tte_pcf_type = -1;
54 static int hf_tte_pcf_res1 = -1;
55 static int hf_tte_pcf_tc = -1;
57 /* Initialize the subtree pointers */
58 static gint ett_tte_pcf = -1;
60 static const value_string pcf_type_str_vals[] =
61 { {2, "integration frame"}
62 , {4, "coldstart frame"}
63 , {8, "coldstart ack frame"}
68 /* Code to actually dissect the packets */
70 dissect_tte_pcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
72 /* Set up structures needed to add the protocol subtree and manage it */
73 proto_item *tte_pcf_root_item;
74 proto_tree *tte_pcf_tree;
76 /* variables used to store the fields displayed in the info_column */
77 guint8 sync_priority = 0;
78 guint8 sync_domain = 0;
80 /* Check that there's enough data */
81 if (tvb_length(tvb) < TTE_PCF_LENGTH )
86 /* get sync_priority and sync_domain */
87 sync_priority = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
89 sync_domain = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
90 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH);
92 /* Make entries in Protocol column and Info column on summary display */
93 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCF");
95 col_add_fstr(pinfo->cinfo, COL_INFO,
96 "Sync Domain: 0x%02X Sync Priority: 0x%02X",
97 sync_domain, sync_priority);
101 /* create display subtree for the protocol */
102 tte_pcf_root_item = proto_tree_add_item(tree, proto_tte_pcf, tvb, 0,
103 TTE_PCF_LENGTH, FALSE);
105 tte_pcf_tree = proto_item_add_subtree(tte_pcf_root_item, ett_tte_pcf);
107 proto_tree_add_item(tte_pcf_tree,
108 hf_tte_pcf_ic, tvb, 0, TTE_PCF_IC_LENGTH, FALSE);
110 proto_tree_add_item(tte_pcf_tree,
111 hf_tte_pcf_mn, tvb, TTE_PCF_IC_LENGTH, TTE_PCF_MN_LENGTH, FALSE);
113 /* RESERVED FIELD --- will not be displayed */
114 /* proto_tree_add_item(tte_pcf_tree,
115 hf_tte_pcf_res0, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH,
116 TTE_PCF_RES0_LENGTH, FALSE); */
118 proto_tree_add_item(tte_pcf_tree,
119 hf_tte_pcf_sp, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
120 TTE_PCF_RES0_LENGTH, TTE_PCF_SP_LENGTH, FALSE);
122 proto_tree_add_item(tte_pcf_tree,
123 hf_tte_pcf_sd, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
124 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH, TTE_PCF_SD_LENGTH, FALSE);
126 proto_tree_add_item(tte_pcf_tree,
127 hf_tte_pcf_type, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
128 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH,
129 TTE_PCF_TYPE_LENGTH, FALSE);
131 /* RESERVED FIELD --- will not be displayed */
132 /* proto_tree_add_item(tte_pcf_tree,
133 hf_tte_pcf_res1, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
134 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
135 TTE_PCF_TYPE_LENGTH, TTE_PCF_RES1_LENGTH, FALSE); */
137 proto_tree_add_item(tte_pcf_tree,
138 hf_tte_pcf_tc, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
139 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
140 TTE_PCF_TYPE_LENGTH+TTE_PCF_RES1_LENGTH, TTE_PCF_TC_LENGTH, FALSE);
147 proto_register_tte_pcf(void)
149 static hf_register_info hf[] = {
152 { "Protocol Control Frame", "tte.pcf",
153 FT_BYTES, BASE_NONE, NULL, 0x0,
157 { "Integration Cycle", "tte.pcf.ic",
158 FT_UINT32, BASE_HEX, NULL, 0x0,
162 { "Membership New", "tte.pcf.mn",
163 FT_UINT32, BASE_HEX, NULL, 0x0,
167 { "Reserved 0", "tte.pcf.res0",
168 FT_UINT32, BASE_HEX, NULL, 0x0,
172 { "Sync Priority", "tte.pcf.sp",
173 FT_UINT8, BASE_HEX, NULL, 0x0,
177 { "Sync Domain", "tte.pcf.sd",
178 FT_UINT8, BASE_HEX, NULL, 0x0,
182 { "Type", "tte.pcf.type",
183 FT_UINT8, BASE_HEX, VALS(pcf_type_str_vals), 0x0F,
187 { "Reserved 1", "tte.pcf.res1",
188 FT_BYTES, BASE_NONE, NULL, 0x0,
192 { "Transparent Clock", "tte.pcf.tc",
193 FT_UINT64, BASE_HEX, NULL, 0x0,
198 /* Setup protocol subtree array */
199 static gint *ett[] = {
203 /* Register the protocol name and description */
204 proto_tte_pcf = proto_register_protocol("TTEthernet Protocol Control Frame",
205 "TTE PCF", "tte_pcf");
207 /* Required function calls to register header fields and subtrees used */
208 proto_register_field_array(proto_tte_pcf, hf, array_length(hf));
209 proto_register_subtree_array(ett, array_length(ett));
211 register_dissector("tte_pcf", dissect_tte_pcf, proto_tte_pcf);
217 proto_reg_handoff_tte_pcf(void)
219 dissector_handle_t tte_pcf_handle;
221 /* initialize the pcf handle */
222 tte_pcf_handle = find_dissector("tte_pcf");
224 dissector_add("ethertype", ETHERTYPE_TTE_PCF, tte_pcf_handle);