1 /* packet-sercosiii_1v1_hp.c
2 * Routines for SERCOS III dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include <epan/packet.h>
37 #include "packet-sercosiii.h"
39 static gint hf_siii_mdt_hotplug_address = -1;
40 static gint hf_siii_mdt_hp_ctrl = -1;
41 static gint hf_siii_mdt_hp_info = -1;
42 static gint hf_siii_at_hotplug_address = -1;
43 static gint hf_siii_at_hp_stat = -1;
44 static gint hf_siii_at_hp_info = -1;
45 static gint hf_siii_mdt_hotplug_control_param = -1;
46 static gint hf_siii_mdt_hotplug_control_svc_switch = -1;
47 static gint hf_siii_at_hotplug_status_param = -1;
48 static gint hf_siii_at_hotplug_status_hp0_finished = -1;
49 static gint hf_siii_at_hotplug_status_error = -1;
51 static gint ett_siii_mdt_hp = -1;
52 static gint ett_siii_at_hp = -1;
53 static gint ett_siii_mdt_hp_ctrl = -1;
54 static gint ett_siii_mdt_hp_info = -1;
55 static gint ett_siii_at_hp_stat = -1;
56 static gint ett_siii_at_hp_info = -1;
58 static const value_string siii_mdt_hotplug_control_functioncode_text[]=
65 {0x05, "Communication Version"},
66 {0x06, "Communication timeout"},
67 {0x10, "MDT0 Length"},
68 {0x11, "MDT1 Length"},
69 {0x12, "MDT2 Length"},
70 {0x13, "MDT3 Length"},
75 {0x80, "MDT-SVC pointer"},
76 {0x81, "MDT-RTD pointer"},
77 {0x82, "AT-SVC pointer"},
78 {0x83, "AT-RTD pointer"},
82 static const value_string siii_mdt_hotplug_control_svc_switch_text[]=
84 {0, "Transmission via HP-field"},
89 static const value_string siii_mdt_hotplug_status_ackcode_text[]=
91 {0x80, "MDT-SVC pointer"},
92 {0x81, "MDT-RTD pointer"},
93 {0x82, "AT-SVC pointer"},
94 {0x83, "AT-RTD pointer"},
95 {255, "Next Sercos Slave has same address"},
99 static const value_string siii_at_hotplug_status_error_text[]=
101 {0, "Acknowledgement in HP-1"},
102 {1, "Error in HP-1"},
106 void dissect_siii_mdt_hp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
109 proto_tree* subtree2;
112 ti = proto_tree_add_text(tree, tvb, 0, 8, "Hot-Plug");
113 subtree = proto_item_add_subtree(ti, ett_siii_mdt_hp);
115 proto_tree_add_item(subtree, hf_siii_mdt_hotplug_address, tvb, 2, 2, TRUE);
117 ti = proto_tree_add_item(subtree, hf_siii_mdt_hp_ctrl, tvb, 2, 2, TRUE);
118 subtree2 = proto_item_add_subtree(ti, ett_siii_mdt_hp_ctrl);
120 proto_tree_add_item(subtree2, hf_siii_mdt_hotplug_control_svc_switch, tvb, 2, 2, TRUE);
121 proto_tree_add_item(subtree2, hf_siii_mdt_hotplug_control_param, tvb, 2, 2, TRUE);
123 proto_tree_add_item(subtree, hf_siii_mdt_hp_info, tvb, 4, 4, TRUE);
126 void dissect_siii_at_hp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
129 proto_tree* subtree2;
132 ti = proto_tree_add_text(tree, tvb, 0, 8, "Hot-Plug");
133 subtree = proto_item_add_subtree(ti, ett_siii_at_hp);
135 proto_tree_add_item(subtree, hf_siii_at_hotplug_address, tvb, 2, 2, TRUE);
137 ti = proto_tree_add_item(subtree, hf_siii_at_hp_stat, tvb, 2, 2, TRUE);
138 subtree2 = proto_item_add_subtree(ti, ett_siii_at_hp_stat);
140 proto_tree_add_item(subtree2, hf_siii_at_hotplug_status_error, tvb, 2, 2, TRUE);
141 proto_tree_add_item(subtree2, hf_siii_at_hotplug_status_hp0_finished, tvb, 2, 2, TRUE);
142 proto_tree_add_item(subtree2, hf_siii_at_hotplug_status_param, tvb, 2, 2, TRUE);
144 proto_tree_add_item(subtree, hf_siii_at_hp_info, tvb, 4, 4, TRUE);
147 void dissect_siii_hp_init(gint proto_siii)
149 /* Setup list of header fields See Section 1.6.1 for details*/
150 static hf_register_info hf_siii_header[] = {
151 { &hf_siii_mdt_hotplug_address,
152 {"Sercos address", "siii.mdt.hp.sercosaddress",
153 FT_UINT16, BASE_HEX, NULL, 0,
156 { &hf_siii_mdt_hp_ctrl,
157 {"HP control", "siii.mdt.hp.ctrl",
158 FT_UINT16, BASE_HEX, NULL, 0,
161 { &hf_siii_mdt_hp_info,
162 {"HP info", "siii.mdt.hp.info",
163 FT_BYTES, BASE_HEX, NULL, 0,
166 { &hf_siii_at_hotplug_address,
167 {"Sercos address", "siii.at.hp.sercosaddress",
168 FT_UINT16, BASE_HEX, NULL, 0,
171 { &hf_siii_at_hp_stat,
172 {"HP status", "siii.mdt.hp.stat",
173 FT_UINT16, BASE_HEX, NULL, 0,
176 { &hf_siii_at_hp_info,
177 {"HP info", "siii.at.hp.info",
178 FT_BYTES, BASE_HEX, NULL, 0,
181 { &hf_siii_mdt_hotplug_control_param,
182 {"Parameter", "siii.mdt.hp.parameter",
183 FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_control_functioncode_text), 0xFF,
186 { &hf_siii_mdt_hotplug_control_svc_switch,
187 {"Switch to SVC", "siii.mdt.hp.switch",
188 FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_control_svc_switch_text), 0x100,
192 { &hf_siii_at_hotplug_status_param,
193 {"Parameter Received", "siii.at.hp.parameter",
194 FT_UINT16, BASE_DEC, VALS(siii_mdt_hotplug_status_ackcode_text), 0xFF,
197 { &hf_siii_at_hotplug_status_hp0_finished,
198 {"HP/SVC", "siii.at.hp.hp0_finished",
199 FT_UINT16, BASE_DEC, NULL, 0x100,
202 { &hf_siii_at_hotplug_status_error,
203 {"Error", "siii.at.hp.error",
204 FT_UINT16, BASE_DEC, VALS(siii_at_hotplug_status_error_text), 0x200,
209 /* Setup protocol subtree array */
210 static gint *ett[] = {
213 &ett_siii_mdt_hp_ctrl,
214 &ett_siii_mdt_hp_info,
215 &ett_siii_at_hp_stat,
219 /* Required function calls to register the header fields and subtrees used */
220 proto_register_field_array(proto_siii, hf_siii_header, array_length(hf_siii_header));
221 proto_register_subtree_array(ett, array_length(ett));