blob: 97f203a541cae8005757664ed8ec294580c35c05 [file] [log] [blame]
Harald Welte2d112ad2009-06-10 05:42:52 +08001Index: epan/dissectors/Makefile.common
2===================================================================
Harald Welted64d2ad2009-06-25 20:50:33 +02003--- epan/dissectors/Makefile.common.orig 2009-02-28 15:39:56.000000000 +0100
4+++ epan/dissectors/Makefile.common 2009-06-25 15:04:16.000000000 +0200
Harald Welte2d112ad2009-06-10 05:42:52 +08005@@ -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===================================================================
Harald Welted64d2ad2009-06-25 20:50:33 +020015--- epan/dissectors/packet-rsl.c.orig 2009-02-28 15:39:51.000000000 +0100
16+++ epan/dissectors/packet-rsl.c 2009-02-28 15:39:56.000000000 +0100
Harald Welte2d112ad2009-06-10 05:42:52 +080017@@ -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===================================================================
Harald Welted64d2ad2009-06-25 20:50:33 +020027--- /dev/null 1970-01-01 00:00:00.000000000 +0000
28+++ epan/dissectors/packet-abis_ip.c 2009-06-25 15:04:42.000000000 +0200
29@@ -0,0 +1,279 @@
Harald Welte2d112ad2009-06-10 05:42:52 +080030+/* 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) {
Harald Welted64d2ad2009-06-25 20:50:33 +0200212+ ti = proto_tree_add_protocol_format(tree, proto_abisip,
213+ tvb, offset, len+3,
214+ "A-bis/IP protocol ip.access, type: %s",
215+ val_to_str(msg_type, abisip_protocol_vals,
216+ "unknown 0x%02x"));
Harald Welte2d112ad2009-06-10 05:42:52 +0800217+ abisip_tree = proto_item_add_subtree(ti, ett_abisip);
218+ proto_tree_add_item(abisip_tree, hf_abisip_data_len,
219+ tvb, offset+1, 1, FALSE);
220+ proto_tree_add_item(abisip_tree, hf_abisip_protocol,
221+ tvb, offset+2, 1, FALSE);
222+ }
223+
224+ next_tvb = tvb_new_subset(tvb, offset+3, len, len);
225+
226+ switch (msg_type) {
227+ case ABISIP_RSL:
228+ /* hand this off to the standard A-bis RSL dissector */
229+ call_dissector(sub_handles[SUB_RSL], next_tvb, pinfo, tree);
230+ break;
231+ case ABISIP_OML:
232+ /* hand this off to the standard A-bis OML dissector */
Harald Welted64d2ad2009-06-25 20:50:33 +0200233+ if (sub_handles[SUB_OML])
234+ call_dissector(sub_handles[SUB_OML], next_tvb,
235+ pinfo, tree);
Harald Welte2d112ad2009-06-10 05:42:52 +0800236+ break;
237+ case ABISIP_IPACCESS:
238+ dissect_ipaccess(next_tvb, pinfo, tree);
239+ break;
240+ }
241+ offset += len + 3;
242+ }
243+}
244+
245+void proto_register_abisip(void)
246+{
247+ static hf_register_info hf[] = {
248+ {&hf_abisip_data_len,
249+ {"DataLen", "abisip.data_len",
250+ FT_UINT8, BASE_DEC, NULL, 0x0,
251+ "The length of the data (in bytes)", HFILL}
252+ },
253+ {&hf_abisip_protocol,
254+ {"Protocol", "abisip.protocol",
255+ FT_UINT8, BASE_HEX, VALS(abisip_protocol_vals), 0x0,
256+ "The A-bis/IP Sub-Protocol", HFILL}
257+ },
258+ };
259+ static hf_register_info hf_ipa[] = {
260+ {&hf_ipaccess_msgtype,
261+ {"MessageType", "ipaccess.msg_type",
262+ FT_UINT8, BASE_HEX, VALS(ipaccess_msgtype_vals), 0x0,
263+ "type of ip.access messsage", HFILL}
264+ },
265+ {&hf_ipaccess_attr_tag,
266+ {"Tag", "ipaccess.attr_tag",
267+ FT_UINT8, BASE_HEX, VALS(ipaccess_idtag_vals), 0x0,
268+ "Attribute Tag", HFILL}
269+ },
270+ {&hf_ipaccess_attr_string,
271+ {"String", "ipaccess.attr_string",
272+ FT_STRING, BASE_NONE, NULL, 0x0,
273+ "String attribute", HFILL}
274+ },
275+ };
276+
277+ static gint *ett[] = {
278+ &ett_abisip,
279+ &ett_ipaccess,
280+ };
281+
282+ proto_abisip =
283+ proto_register_protocol("A-bis/IP protocol as used by ip.access",
284+ "A-bis/IP", "abis_ip");
285+ proto_ipaccess =
286+ proto_register_protocol("A-bis/IP ip.access sub-protocol",
287+ "IPA", "ipaccess");
288+
289+ proto_register_field_array(proto_abisip, hf, array_length(hf));
290+ proto_register_field_array(proto_ipaccess, hf_ipa, array_length(hf_ipa));
291+ proto_register_subtree_array(ett, array_length(ett));
Harald Welted64d2ad2009-06-25 20:50:33 +0200292+
293+ register_dissector("gsm_abis_ip", dissect_abisip, proto_abisip);
Harald Welte2d112ad2009-06-10 05:42:52 +0800294+}
295+
296+void proto_reg_handoff_abisip(void)
297+{
298+ dissector_handle_t abisip_handle;
299+
300+ sub_handles[SUB_RSL] = find_dissector("gsm_abis_rsl");
301+ sub_handles[SUB_OML] = find_dissector("gsm_abis_oml");
302+
303+ abisip_handle = create_dissector_handle(dissect_abisip, proto_abisip);
304+ dissector_add("tcp.port", TCP_PORT_ABISIP_PRIM, abisip_handle);
305+ dissector_add("tcp.port", TCP_PORT_ABISIP_SEC, abisip_handle);
306+ dissector_add("tcp.port", TCP_PORT_ABISIP_INST, abisip_handle);
307+ dissector_add("udp.port", TCP_PORT_ABISIP_INST, abisip_handle);
308+}