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/
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
34 #include <epan/packet.h>
35 #include <epan/etypes.h>
37 #include "packet-tte.h"
39 void proto_register_tte_pcf(void);
40 void proto_reg_handoff_tte_pcf(void);
42 /* Initialize the protocol and registered fields */
43 static int proto_tte_pcf = -1;
45 /* static int hf_tte_pcf = -1; */
46 static int hf_tte_pcf_ic = -1;
47 static int hf_tte_pcf_mn = -1;
48 /* static int hf_tte_pcf_res0 = -1; */
49 static int hf_tte_pcf_sp = -1;
50 static int hf_tte_pcf_sd = -1;
51 static int hf_tte_pcf_type = -1;
52 /* static int hf_tte_pcf_res1 = -1; */
53 static int hf_tte_pcf_tc = -1;
55 /* Initialize the subtree pointers */
56 static gint ett_tte_pcf = -1;
58 static const value_string pcf_type_str_vals[] =
59 { {2, "integration frame"}
60 , {4, "coldstart frame"}
61 , {8, "coldstart ack frame"}
66 /* Code to actually dissect the packets */
68 dissect_tte_pcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
70 /* Set up structures needed to add the protocol subtree and manage it */
71 proto_item *tte_pcf_root_item;
72 proto_tree *tte_pcf_tree;
74 /* variables used to store the fields displayed in the info_column */
75 guint8 sync_priority = 0;
76 guint8 sync_domain = 0;
78 /* Check that there's enough data */
79 if (tvb_length(tvb) < TTE_PCF_LENGTH )
84 /* get sync_priority and sync_domain */
85 sync_priority = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
87 sync_domain = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
88 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH);
90 /* Make entries in Protocol column and Info column on summary display */
91 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCF");
93 col_add_fstr(pinfo->cinfo, COL_INFO,
94 "Sync Domain: 0x%02X Sync Priority: 0x%02X",
95 sync_domain, sync_priority);
99 /* create display subtree for the protocol */
100 tte_pcf_root_item = proto_tree_add_item(tree, proto_tte_pcf, tvb, 0,
101 TTE_PCF_LENGTH, ENC_NA);
103 tte_pcf_tree = proto_item_add_subtree(tte_pcf_root_item, ett_tte_pcf);
105 proto_tree_add_item(tte_pcf_tree,
106 hf_tte_pcf_ic, tvb, 0, TTE_PCF_IC_LENGTH, ENC_BIG_ENDIAN);
108 proto_tree_add_item(tte_pcf_tree,
109 hf_tte_pcf_mn, tvb, TTE_PCF_IC_LENGTH, TTE_PCF_MN_LENGTH, ENC_BIG_ENDIAN);
111 /* RESERVED FIELD --- will not be displayed */
112 /* proto_tree_add_item(tte_pcf_tree,
113 hf_tte_pcf_res0, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH,
114 TTE_PCF_RES0_LENGTH, ENC_BIG_ENDIAN); */
116 proto_tree_add_item(tte_pcf_tree,
117 hf_tte_pcf_sp, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
118 TTE_PCF_RES0_LENGTH, TTE_PCF_SP_LENGTH, ENC_BIG_ENDIAN);
120 proto_tree_add_item(tte_pcf_tree,
121 hf_tte_pcf_sd, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
122 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH, TTE_PCF_SD_LENGTH, ENC_BIG_ENDIAN);
124 proto_tree_add_item(tte_pcf_tree,
125 hf_tte_pcf_type, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
126 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH,
127 TTE_PCF_TYPE_LENGTH, ENC_BIG_ENDIAN);
129 /* RESERVED FIELD --- will not be displayed */
130 /* proto_tree_add_item(tte_pcf_tree,
131 hf_tte_pcf_res1, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
132 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
133 TTE_PCF_TYPE_LENGTH, TTE_PCF_RES1_LENGTH, ENC_NA); */
135 proto_tree_add_item(tte_pcf_tree,
136 hf_tte_pcf_tc, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
137 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
138 TTE_PCF_TYPE_LENGTH+TTE_PCF_RES1_LENGTH, TTE_PCF_TC_LENGTH, ENC_BIG_ENDIAN);
145 proto_register_tte_pcf(void)
147 static hf_register_info hf[] = {
151 { "Protocol Control Frame", "tte.pcf",
152 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,
168 { "Reserved 0", "tte.pcf.res0",
169 FT_UINT32, BASE_HEX, NULL, 0x0,
174 { "Sync Priority", "tte.pcf.sp",
175 FT_UINT8, BASE_HEX, NULL, 0x0,
179 { "Sync Domain", "tte.pcf.sd",
180 FT_UINT8, BASE_HEX, NULL, 0x0,
184 { "Type", "tte.pcf.type",
185 FT_UINT8, BASE_HEX, VALS(pcf_type_str_vals), 0x0F,
190 { "Reserved 1", "tte.pcf.res1",
191 FT_BYTES, BASE_NONE, NULL, 0x0,
196 { "Transparent Clock", "tte.pcf.tc",
197 FT_UINT64, BASE_HEX, NULL, 0x0,
202 /* Setup protocol subtree array */
203 static gint *ett[] = {
207 /* Register the protocol name and description */
208 proto_tte_pcf = proto_register_protocol("TTEthernet Protocol Control Frame",
209 "TTE PCF", "tte_pcf");
211 /* Required function calls to register header fields and subtrees used */
212 proto_register_field_array(proto_tte_pcf, hf, array_length(hf));
213 proto_register_subtree_array(ett, array_length(ett));
215 register_dissector("tte_pcf", dissect_tte_pcf, proto_tte_pcf);
221 proto_reg_handoff_tte_pcf(void)
223 dissector_handle_t tte_pcf_handle;
225 /* initialize the pcf handle */
226 tte_pcf_handle = find_dissector("tte_pcf");
228 dissector_add_uint("ethertype", ETHERTYPE_TTE_PCF, tte_pcf_handle);