HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-tte-pcf.c
blob8b5b694b44891e81273614ea72ad8167e04f3fe4
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 * http://www.tttech.com/solutions/ttethernet/
10 * $Id$
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,
29 * USA.
32 #include "config.h"
34 #include <glib.h>
36 #include <epan/packet.h>
37 #include <epan/etypes.h>
39 #include "packet-tte.h"
41 /* Initialize the protocol and registered fields */
42 static int proto_tte_pcf = -1;
44 /* static int hf_tte_pcf = -1; */
45 static int hf_tte_pcf_ic = -1;
46 static int hf_tte_pcf_mn = -1;
47 /* static int hf_tte_pcf_res0 = -1; */
48 static int hf_tte_pcf_sp = -1;
49 static int hf_tte_pcf_sd = -1;
50 static int hf_tte_pcf_type = -1;
51 /* static int hf_tte_pcf_res1 = -1; */
52 static int hf_tte_pcf_tc = -1;
54 /* Initialize the subtree pointers */
55 static gint ett_tte_pcf = -1;
57 static const value_string pcf_type_str_vals[] =
58 { {2, "integration frame"}
59 , {4, "coldstart frame"}
60 , {8, "coldstart ack frame"}
61 , {0, NULL}
65 /* Code to actually dissect the packets */
66 static void
67 dissect_tte_pcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
69 /* Set up structures needed to add the protocol subtree and manage it */
70 proto_item *tte_pcf_root_item;
71 proto_tree *tte_pcf_tree;
73 /* variables used to store the fields displayed in the info_column */
74 guint8 sync_priority = 0;
75 guint8 sync_domain = 0;
77 /* Check that there's enough data */
78 if (tvb_length(tvb) < TTE_PCF_LENGTH )
80 return;
83 /* get sync_priority and sync_domain */
84 sync_priority = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
85 TTE_PCF_RES0_LENGTH);
86 sync_domain = tvb_get_guint8(tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
87 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH);
89 /* Make entries in Protocol column and Info column on summary display */
90 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCF");
92 col_add_fstr(pinfo->cinfo, COL_INFO,
93 "Sync Domain: 0x%02X Sync Priority: 0x%02X",
94 sync_domain, sync_priority);
96 if (tree) {
98 /* create display subtree for the protocol */
99 tte_pcf_root_item = proto_tree_add_item(tree, proto_tte_pcf, tvb, 0,
100 TTE_PCF_LENGTH, ENC_NA);
102 tte_pcf_tree = proto_item_add_subtree(tte_pcf_root_item, ett_tte_pcf);
104 proto_tree_add_item(tte_pcf_tree,
105 hf_tte_pcf_ic, tvb, 0, TTE_PCF_IC_LENGTH, ENC_BIG_ENDIAN);
107 proto_tree_add_item(tte_pcf_tree,
108 hf_tte_pcf_mn, tvb, TTE_PCF_IC_LENGTH, TTE_PCF_MN_LENGTH, ENC_BIG_ENDIAN);
110 /* RESERVED FIELD --- will not be displayed */
111 /* proto_tree_add_item(tte_pcf_tree,
112 hf_tte_pcf_res0, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH,
113 TTE_PCF_RES0_LENGTH, ENC_BIG_ENDIAN); */
115 proto_tree_add_item(tte_pcf_tree,
116 hf_tte_pcf_sp, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
117 TTE_PCF_RES0_LENGTH, TTE_PCF_SP_LENGTH, ENC_BIG_ENDIAN);
119 proto_tree_add_item(tte_pcf_tree,
120 hf_tte_pcf_sd, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
121 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH, TTE_PCF_SD_LENGTH, ENC_BIG_ENDIAN);
123 proto_tree_add_item(tte_pcf_tree,
124 hf_tte_pcf_type, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
125 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH,
126 TTE_PCF_TYPE_LENGTH, ENC_BIG_ENDIAN);
128 /* RESERVED FIELD --- will not be displayed */
129 /* proto_tree_add_item(tte_pcf_tree,
130 hf_tte_pcf_res1, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
131 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
132 TTE_PCF_TYPE_LENGTH, TTE_PCF_RES1_LENGTH, ENC_NA); */
134 proto_tree_add_item(tte_pcf_tree,
135 hf_tte_pcf_tc, tvb, TTE_PCF_IC_LENGTH+TTE_PCF_MN_LENGTH+
136 TTE_PCF_RES0_LENGTH+TTE_PCF_SP_LENGTH+TTE_PCF_SD_LENGTH+
137 TTE_PCF_TYPE_LENGTH+TTE_PCF_RES1_LENGTH, TTE_PCF_TC_LENGTH, ENC_BIG_ENDIAN);
143 void
144 proto_register_tte_pcf(void)
146 static hf_register_info hf[] = {
148 #if 0
149 { &hf_tte_pcf,
150 { "Protocol Control Frame", "tte.pcf",
151 FT_BYTES, BASE_NONE, NULL, 0x0,
152 NULL, HFILL }
154 #endif
155 { &hf_tte_pcf_ic,
156 { "Integration Cycle", "tte.pcf.ic",
157 FT_UINT32, BASE_HEX, NULL, 0x0,
158 NULL, HFILL }
160 { &hf_tte_pcf_mn,
161 { "Membership New", "tte.pcf.mn",
162 FT_UINT32, BASE_HEX, NULL, 0x0,
163 NULL, HFILL }
165 #if 0
166 { &hf_tte_pcf_res0,
167 { "Reserved 0", "tte.pcf.res0",
168 FT_UINT32, BASE_HEX, NULL, 0x0,
169 NULL, HFILL }
171 #endif
172 { &hf_tte_pcf_sp,
173 { "Sync Priority", "tte.pcf.sp",
174 FT_UINT8, BASE_HEX, NULL, 0x0,
175 NULL, HFILL }
177 { &hf_tte_pcf_sd,
178 { "Sync Domain", "tte.pcf.sd",
179 FT_UINT8, BASE_HEX, NULL, 0x0,
180 NULL, HFILL }
182 { &hf_tte_pcf_type,
183 { "Type", "tte.pcf.type",
184 FT_UINT8, BASE_HEX, VALS(pcf_type_str_vals), 0x0F,
185 NULL, HFILL }
187 #if 0
188 { &hf_tte_pcf_res1,
189 { "Reserved 1", "tte.pcf.res1",
190 FT_BYTES, BASE_NONE, NULL, 0x0,
191 NULL, HFILL }
193 #endif
194 { &hf_tte_pcf_tc,
195 { "Transparent Clock", "tte.pcf.tc",
196 FT_UINT64, BASE_HEX, NULL, 0x0,
197 NULL, HFILL }
201 /* Setup protocol subtree array */
202 static gint *ett[] = {
203 &ett_tte_pcf
206 /* Register the protocol name and description */
207 proto_tte_pcf = proto_register_protocol("TTEthernet Protocol Control Frame",
208 "TTE PCF", "tte_pcf");
210 /* Required function calls to register header fields and subtrees used */
211 proto_register_field_array(proto_tte_pcf, hf, array_length(hf));
212 proto_register_subtree_array(ett, array_length(ett));
214 register_dissector("tte_pcf", dissect_tte_pcf, proto_tte_pcf);
219 void
220 proto_reg_handoff_tte_pcf(void)
222 dissector_handle_t tte_pcf_handle;
224 /* initialize the pcf handle */
225 tte_pcf_handle = find_dissector("tte_pcf");
227 dissector_add_uint("ethertype", ETHERTYPE_TTE_PCF, tte_pcf_handle);