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,
32 #include <epan/packet.h>
33 #include <epan/etypes.h>
35 #include "packet-tte.h"
37 void proto_register_tte_pcf(void);
38 void proto_reg_handoff_tte_pcf(void);
40 /* Initialize the protocol and registered fields */
41 static int proto_tte_pcf = -1;
43 static int hf_tte_pcf_ic = -1;
44 static int hf_tte_pcf_mn = -1;
45 /* static int hf_tte_pcf_res0 = -1; */
46 static int hf_tte_pcf_sp = -1;
47 static int hf_tte_pcf_sd = -1;
48 static int hf_tte_pcf_type = -1;
49 /* static int hf_tte_pcf_res1 = -1; */
50 static int hf_tte_pcf_tc = -1;
52 /* Initialize the subtree pointers */
53 static gint ett_tte_pcf = -1;
55 static const value_string pcf_type_str_vals[] =
56 { {2, "integration frame"}
57 , {4, "coldstart frame"}
58 , {8, "coldstart ack frame"}
63 /* Code to actually dissect the packets */
65 dissect_tte_pcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
67 /* Set up structures needed to add the protocol subtree and manage it */
68 proto_item *tte_pcf_root_item;
69 proto_tree *tte_pcf_tree;
71 /* variables used to store the fields displayed in the info_column */
72 guint8 sync_priority = 0;
73 guint8 sync_domain = 0;
75 /* Check that there's enough data */
76 if (tvb_reported_length(tvb) < TTE_PCF_LENGTH )
81 /* get sync_priority and sync_domain */
82 sync_priority = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
84 sync_domain = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
85 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH);
87 /* Make entries in Protocol column and Info column on summary display */
88 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCF");
90 col_add_fstr(pinfo->cinfo, COL_INFO,
91 "Sync Domain: 0x%02X Sync Priority: 0x%02X",
92 sync_domain, sync_priority);
96 /* create display subtree for the protocol */
97 tte_pcf_root_item = proto_tree_add_item(tree, proto_tte_pcf, tvb, 0,
98 TTE_PCF_LENGTH, ENC_NA);
100 tte_pcf_tree = proto_item_add_subtree(tte_pcf_root_item, ett_tte_pcf);
102 proto_tree_add_item(tte_pcf_tree,
103 hf_tte_pcf_ic, tvb, 0, TTE_PCF_IC_LENGTH, ENC_BIG_ENDIAN);
105 proto_tree_add_item(tte_pcf_tree,
106 hf_tte_pcf_mn, tvb, TTE_PCF_IC_LENGTH, TTE_PCF_MN_LENGTH, ENC_BIG_ENDIAN);
108 /* RESERVED FIELD --- will not be displayed */
109 /* proto_tree_add_item(tte_pcf_tree,
110 hf_tte_pcf_res0, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH,
111 TTE_PCF_RES0_LENGTH, ENC_BIG_ENDIAN); */
113 proto_tree_add_item(tte_pcf_tree,
114 hf_tte_pcf_sp, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
115 TTE_PCF_RES0_LENGTH, TTE_PCF_SP_LENGTH, ENC_BIG_ENDIAN);
117 proto_tree_add_item(tte_pcf_tree,
118 hf_tte_pcf_sd, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
119 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH, TTE_PCF_SD_LENGTH, ENC_BIG_ENDIAN);
121 proto_tree_add_item(tte_pcf_tree,
122 hf_tte_pcf_type, 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, ENC_BIG_ENDIAN);
126 /* RESERVED FIELD --- will not be displayed */
127 /* proto_tree_add_item(tte_pcf_tree,
128 hf_tte_pcf_res1, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
129 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
130 TTE_PCF_TYPE_LENGTH, TTE_PCF_RES1_LENGTH, ENC_NA); */
132 proto_tree_add_item(tte_pcf_tree,
133 hf_tte_pcf_tc, 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, TTE_PCF_TC_LENGTH, ENC_BIG_ENDIAN);
142 proto_register_tte_pcf(void)
144 static hf_register_info hf[] = {
147 { "Integration Cycle", "tte_pcf.ic",
148 FT_UINT32, BASE_HEX, NULL, 0x0,
152 { "Membership New", "tte_pcf.mn",
153 FT_UINT32, BASE_HEX, NULL, 0x0,
158 { "Reserved 0", "tte_pcf.res0",
159 FT_UINT32, BASE_HEX, NULL, 0x0,
164 { "Sync Priority", "tte_pcf.sp",
165 FT_UINT8, BASE_HEX, NULL, 0x0,
169 { "Sync Domain", "tte_pcf.sd",
170 FT_UINT8, BASE_HEX, NULL, 0x0,
174 { "Type", "tte_pcf.type",
175 FT_UINT8, BASE_HEX, VALS(pcf_type_str_vals), 0x0F,
180 { "Reserved 1", "tte_pcf.res1",
181 FT_BYTES, BASE_NONE, NULL, 0x0,
186 { "Transparent Clock", "tte_pcf.tc",
187 FT_UINT64, BASE_HEX, NULL, 0x0,
192 /* Setup protocol subtree array */
193 static gint *ett[] = {
197 /* Register the protocol name and description */
198 proto_tte_pcf = proto_register_protocol("TTEthernet Protocol Control Frame",
199 "TTE PCF", "tte_pcf");
201 /* Required function calls to register header fields and subtrees used */
202 proto_register_field_array(proto_tte_pcf, hf, array_length(hf));
203 proto_register_subtree_array(ett, array_length(ett));
205 register_dissector("tte_pcf", dissect_tte_pcf, proto_tte_pcf);
211 proto_reg_handoff_tte_pcf(void)
213 dissector_handle_t tte_pcf_handle;
215 /* initialize the pcf handle */
216 tte_pcf_handle = find_dissector("tte_pcf");
218 dissector_add_uint("ethertype", ETHERTYPE_TTE_PCF, tte_pcf_handle);
223 * Editor modelines - http://www.wireshark.org/tools/modelines.html
228 * indent-tabs-mode: nil
231 * vi: set shiftwidth=4 tabstop=8 expandtab:
232 * :indentSize=4:tabSize=8:noTabs=true: