blob: 980259561270b14160e0bd6c51fd98416240bb3d [file] [log] [blame]
Harald Welte022d7672009-06-10 05:42:52 +08001Index: epan/dissectors/Makefile.common
2===================================================================
3--- epan/dissectors/Makefile.common.orig
4+++ epan/dissectors/Makefile.common
5@@ -873,6 +873,7 @@
6 # Dissectors with warnings.
7 #
8 DIRTY_DISSECTOR_SRC = \
9+ packet-abis_ip.c \
10 packet-k12.c \
11 packet-nbd.c \
12 packet-sccp.c \
13Index: epan/dissectors/packet-rsl.c
14===================================================================
15--- epan/dissectors/packet-rsl.c.orig
16+++ epan/dissectors/packet-rsl.c
17@@ -3950,6 +3950,7 @@
18 proto_register_field_array(proto_rsl, hf, array_length(hf));
19 proto_register_subtree_array(ett, array_length(ett));
20
21+ register_dissector("gsm_abis_rsl", dissect_rsl, proto_rsl);
22
23 }
24
25Index: epan/dissectors/packet-abis_ip.c
26===================================================================
27--- /dev/null
28+++ epan/dissectors/packet-abis_ip.c
29@@ -0,0 +1,275 @@
30+/* packet-abis_ip.c
31+ * Routines for packet dissection of ip.access A-bis over IP
32+ * Copyright 2009 by Harald Welte <laforge@gnumonks.org>
33+ *
34+ * $Id$
35+ *
36+ * Wireshark - Network traffic analyzer
37+ * By Gerald Combs <gerald@wireshark.org>
38+ * Copyright 1998 Gerald Combs
39+ *
40+ * This program is free software; you can redistribute it and/or
41+ * modify it under the terms of the GNU General Public License
42+ * as published by the Free Software Foundation; either version 2
43+ * of the License, or (at your option) any later version.
44+ *
45+ * This program is distributed in the hope that it will be useful,
46+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
47+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+ * GNU General Public License for more details.
49+ *
50+ * You should have received a copy of the GNU General Public License
51+ * along with this program; if not, write to the Free Software
52+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
53+ */
54+
55+#ifdef HAVE_CONFIG_H
56+# include "config.h"
57+#endif
58+
59+#include <glib.h>
60+
61+#include <epan/packet.h>
62+#include <epan/emem.h>
63+
64+/* Initialize the protocol and registered fields */
65+static int proto_abisip = -1;
66+static int proto_ipaccess = -1;
67+
68+static int hf_abisip_data_len = -1;
69+static int hf_abisip_protocol = -1;
70+
71+static int hf_ipaccess_msgtype = -1;
72+static int hf_ipaccess_attr_tag = -1;
73+static int hf_ipaccess_attr_string = -1;
74+
75+/* Initialize the subtree pointers */
76+static gint ett_abisip = -1;
77+static gint ett_ipaccess = -1;
78+
79+enum {
80+ SUB_OML,
81+ SUB_RSL,
82+ SUB_IPACCESS,
83+
84+ SUB_MAX
85+};
86+
87+static dissector_handle_t sub_handles[SUB_MAX];
88+
89+#define TCP_PORT_ABISIP_PRIM 3002
90+#define TCP_PORT_ABISIP_SEC 3003
91+#define TCP_PORT_ABISIP_INST 3006
92+
93+#define ABISIP_RSL 0x00
94+#define ABISIP_IPACCESS 0xfe
95+#define ABISIP_OML 0xff
96+
97+static const value_string abisip_protocol_vals[] = {
98+ { 0x00, "RSL" },
99+ { 0xfe, "IPA" },
100+ { 0xff, "OML" },
101+ { 0, NULL }
102+};
103+
104+static const value_string ipaccess_msgtype_vals[] = {
105+ { 0x00, "PING?" },
106+ { 0x01, "PONG!" },
107+ { 0x04, "IDENTITY REQUEST" },
108+ { 0x05, "IDENTITY RESPONSE" },
109+ { 0x06, "IDENTITY CONF" },
110+ { 0, NULL }
111+};
112+
113+static const value_string ipaccess_idtag_vals[] = {
114+ { 0x00, "Serial Number" },
115+ { 0x01, "Unit Name" },
116+ { 0x02, "Location" },
117+ { 0x04, "Equipment Version" },
118+ { 0x05, "Software Version" },
119+ { 0x06, "IP Address" },
120+ { 0x07, "MAC Address" },
121+ { 0x08, "Unit ID" },
122+};
123+
124+static gint
125+dissect_ipa_attr(tvbuff_t *tvb, int base_offs, packet_info *pinfo, proto_tree *tree)
126+{
127+ guint8 len, tag, attr_type;
128+
129+ int offset = base_offs;
130+
131+ while (tvb_reported_length_remaining(tvb, offset) != 0) {
132+ attr_type = tvb_get_guint8(tvb, offset);
133+
134+ switch (attr_type) {
135+ case 0x00: /* a string prefixed by its length */
136+ len = tvb_get_guint8(tvb, offset+1);
137+ tag = tvb_get_guint8(tvb, offset+2);
138+ proto_tree_add_item(tree, hf_ipaccess_attr_tag,
139+ tvb, offset+2, 1, FALSE);
140+ proto_tree_add_item(tree, hf_ipaccess_attr_string,
141+ tvb, offset+3, len-1, FALSE);
142+ break;
143+ case 0x01: /* a single-byte reqest for a certain attr */
144+ len = 0;
145+ proto_tree_add_item(tree, hf_ipaccess_attr_tag,
146+ tvb, offset+1, 1, FALSE);
147+ break;
148+ };
149+ offset += len + 2;
150+ };
151+ return offset;
152+}
153+
154+/* Dissect an ip.access specific message */
155+static gint
156+dissect_ipaccess(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
157+{
158+ proto_item *ti;
159+ proto_tree *ipaccess_tree;
160+ guint8 msg_type;
161+
162+ msg_type = tvb_get_guint8(tvb, 0);
163+
164+ if (check_col(pinfo->cinfo, COL_INFO))
165+ col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
166+ val_to_str(msg_type, ipaccess_msgtype_vals,
167+ "unknown 0x%02x"));
168+ if (tree) {
169+ ti = proto_tree_add_item(tree, proto_ipaccess, tvb, 0, -1, FALSE);
170+ ipaccess_tree = proto_item_add_subtree(ti, ett_ipaccess);
171+ proto_tree_add_item(ipaccess_tree, hf_ipaccess_msgtype,
172+ tvb, 0, 1, FALSE);
173+ switch (msg_type) {
174+ case 4:
175+ case 5:
176+ dissect_ipa_attr(tvb, 1, pinfo, ipaccess_tree);
177+ break;
178+ }
179+ }
180+
181+ return 1;
182+}
183+
184+
185+/* Code to actually dissect the packets */
186+static void
187+dissect_abisip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
188+{
189+
190+ int offset = 0;
191+
192+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
193+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Abis/IP");
194+ if (check_col(pinfo->cinfo, COL_INFO))
195+ col_clear(pinfo->cinfo, COL_INFO);
196+
197+ while (tvb_reported_length_remaining(tvb, offset) != 0) {
198+ proto_item *ti;
199+ proto_tree *abisip_tree;
200+ guint8 len, msg_type;
201+ tvbuff_t *next_tvb;
202+
203+ len = tvb_get_guint8(tvb, offset+1);
204+ msg_type = tvb_get_guint8(tvb, offset+2);
205+
206+ if (check_col(pinfo->cinfo, COL_INFO))
207+ col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
208+ val_to_str(msg_type, abisip_protocol_vals,
209+ "unknown 0x%02x"));
210+
211+ if (tree) {
212+ ti = proto_tree_add_item(tree, proto_abisip, tvb,
213+ offset, len+3, FALSE);
214+ abisip_tree = proto_item_add_subtree(ti, ett_abisip);
215+ proto_tree_add_item(abisip_tree, hf_abisip_data_len,
216+ tvb, offset+1, 1, FALSE);
217+ proto_tree_add_item(abisip_tree, hf_abisip_protocol,
218+ tvb, offset+2, 1, FALSE);
219+ }
220+
221+ next_tvb = tvb_new_subset(tvb, offset+3, len, len);
222+
223+ switch (msg_type) {
224+ case ABISIP_RSL:
225+ /* hand this off to the standard A-bis RSL dissector */
226+ call_dissector(sub_handles[SUB_RSL], next_tvb, pinfo, tree);
227+ break;
228+ case ABISIP_OML:
229+ /* hand this off to the standard A-bis OML dissector */
230+#if 0
231+ call_dissector(sub_handles[SUB_OML], next_tvb,
232+ pinfo, tree);
233+#endif
234+ break;
235+ case ABISIP_IPACCESS:
236+ dissect_ipaccess(next_tvb, pinfo, tree);
237+ break;
238+ }
239+ offset += len + 3;
240+ }
241+}
242+
243+void proto_register_abisip(void)
244+{
245+ static hf_register_info hf[] = {
246+ {&hf_abisip_data_len,
247+ {"DataLen", "abisip.data_len",
248+ FT_UINT8, BASE_DEC, NULL, 0x0,
249+ "The length of the data (in bytes)", HFILL}
250+ },
251+ {&hf_abisip_protocol,
252+ {"Protocol", "abisip.protocol",
253+ FT_UINT8, BASE_HEX, VALS(abisip_protocol_vals), 0x0,
254+ "The A-bis/IP Sub-Protocol", HFILL}
255+ },
256+ };
257+ static hf_register_info hf_ipa[] = {
258+ {&hf_ipaccess_msgtype,
259+ {"MessageType", "ipaccess.msg_type",
260+ FT_UINT8, BASE_HEX, VALS(ipaccess_msgtype_vals), 0x0,
261+ "type of ip.access messsage", HFILL}
262+ },
263+ {&hf_ipaccess_attr_tag,
264+ {"Tag", "ipaccess.attr_tag",
265+ FT_UINT8, BASE_HEX, VALS(ipaccess_idtag_vals), 0x0,
266+ "Attribute Tag", HFILL}
267+ },
268+ {&hf_ipaccess_attr_string,
269+ {"String", "ipaccess.attr_string",
270+ FT_STRING, BASE_NONE, NULL, 0x0,
271+ "String attribute", HFILL}
272+ },
273+ };
274+
275+ static gint *ett[] = {
276+ &ett_abisip,
277+ &ett_ipaccess,
278+ };
279+
280+ proto_abisip =
281+ proto_register_protocol("A-bis/IP protocol as used by ip.access",
282+ "A-bis/IP", "abis_ip");
283+ proto_ipaccess =
284+ proto_register_protocol("A-bis/IP ip.access sub-protocol",
285+ "IPA", "ipaccess");
286+
287+ proto_register_field_array(proto_abisip, hf, array_length(hf));
288+ proto_register_field_array(proto_ipaccess, hf_ipa, array_length(hf_ipa));
289+ proto_register_subtree_array(ett, array_length(ett));
290+}
291+
292+void proto_reg_handoff_abisip(void)
293+{
294+ dissector_handle_t abisip_handle;
295+
296+ sub_handles[SUB_RSL] = find_dissector("gsm_abis_rsl");
297+ sub_handles[SUB_OML] = find_dissector("gsm_abis_oml");
298+
299+ abisip_handle = create_dissector_handle(dissect_abisip, proto_abisip);
300+ dissector_add("tcp.port", TCP_PORT_ABISIP_PRIM, abisip_handle);
301+ dissector_add("tcp.port", TCP_PORT_ABISIP_SEC, abisip_handle);
302+ dissector_add("tcp.port", TCP_PORT_ABISIP_INST, abisip_handle);
303+ dissector_add("udp.port", TCP_PORT_ABISIP_INST, abisip_handle);
304+}