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,
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"}
65 /* Code to actually dissect the packets */
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
)
83 /* get sync_priority and sync_domain */
84 sync_priority
= tvb_get_guint8(tvb
, TTE_PCF_IC_LENGTH
+TTE_PCF_MN_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
);
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
);
144 proto_register_tte_pcf(void)
146 static hf_register_info hf
[] = {
150 { "Protocol Control Frame", "tte.pcf",
151 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
156 { "Integration Cycle", "tte.pcf.ic",
157 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
161 { "Membership New", "tte.pcf.mn",
162 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
167 { "Reserved 0", "tte.pcf.res0",
168 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
173 { "Sync Priority", "tte.pcf.sp",
174 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
178 { "Sync Domain", "tte.pcf.sd",
179 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
183 { "Type", "tte.pcf.type",
184 FT_UINT8
, BASE_HEX
, VALS(pcf_type_str_vals
), 0x0F,
189 { "Reserved 1", "tte.pcf.res1",
190 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
195 { "Transparent Clock", "tte.pcf.tc",
196 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
201 /* Setup protocol subtree array */
202 static gint
*ett
[] = {
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
);
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
);