blob: 44ca3ee7f12506bd666f12ad5a516001884f1703 [file] [log] [blame]
Harald Welte2d112ad2009-06-10 05:42:52 +08001Index: epan/dissectors/Makefile.common
2===================================================================
Harald Welteeb438442009-07-10 19:41:50 +02003--- epan/dissectors/Makefile.common.orig
4+++ epan/dissectors/Makefile.common
Harald Welte63aba292009-07-04 04:11:21 +02005@@ -471,6 +471,7 @@
6 packet-gsm_a_gm.c \
7 packet-gsm_a_rp.c \
8 packet-gsm_a_rr.c \
9+ packet-gsm_abis_ip.c \
10 packet-gsm_bsslap.c \
11 packet-gsm_bssmap_le.c \
12 packet-gsm_sms.c \
Harald Welte2d112ad2009-06-10 05:42:52 +080013Index: epan/dissectors/packet-rsl.c
14===================================================================
Harald Welteeb438442009-07-10 19:41:50 +020015--- epan/dissectors/packet-rsl.c.orig
16+++ epan/dissectors/packet-rsl.c
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
Harald Welte63aba292009-07-04 04:11:21 +020025Index: epan/dissectors/packet-gsm_abis_ip.c
Harald Welte2d112ad2009-06-10 05:42:52 +080026===================================================================
Harald Welteeb438442009-07-10 19:41:50 +020027--- /dev/null
28+++ epan/dissectors/packet-gsm_abis_ip.c
29@@ -0,0 +1,284 @@
Harald Welte63aba292009-07-04 04:11:21 +020030+/* packet-gsm_abis_ip.c
Harald Welte2d112ad2009-06-10 05:42:52 +080031+ * 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
Harald Welte63aba292009-07-04 04:11:21 +0200125+dissect_ipa_attr(tvbuff_t *tvb, int base_offs, proto_tree *tree)
Harald Welte2d112ad2009-06-10 05:42:52 +0800126+{
Harald Welteeb438442009-07-10 19:41:50 +0200127+ guint8 len, attr_type;
Harald Welte2d112ad2009-06-10 05:42:52 +0800128+
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);
Harald Welte2d112ad2009-06-10 05:42:52 +0800137+ proto_tree_add_item(tree, hf_ipaccess_attr_tag,
138+ tvb, offset+2, 1, FALSE);
139+ proto_tree_add_item(tree, hf_ipaccess_attr_string,
140+ tvb, offset+3, len-1, FALSE);
141+ break;
142+ case 0x01: /* a single-byte reqest for a certain attr */
143+ len = 0;
144+ proto_tree_add_item(tree, hf_ipaccess_attr_tag,
145+ tvb, offset+1, 1, FALSE);
146+ break;
Harald Welteeb438442009-07-10 19:41:50 +0200147+ default:
148+ len = 0;
149+ proto_tree_add_text(tree, tvb, offset+1, 1,
150+ "unknonw attribute type 0x%02x",
151+ attr_type);
152+ break;
Harald Welte2d112ad2009-06-10 05:42:52 +0800153+ };
154+ offset += len + 2;
155+ };
156+ return offset;
157+}
158+
159+/* Dissect an ip.access specific message */
160+static gint
161+dissect_ipaccess(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
162+{
163+ proto_item *ti;
164+ proto_tree *ipaccess_tree;
165+ guint8 msg_type;
166+
167+ msg_type = tvb_get_guint8(tvb, 0);
168+
169+ if (check_col(pinfo->cinfo, COL_INFO))
170+ col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
171+ val_to_str(msg_type, ipaccess_msgtype_vals,
172+ "unknown 0x%02x"));
173+ if (tree) {
174+ ti = proto_tree_add_item(tree, proto_ipaccess, tvb, 0, -1, FALSE);
175+ ipaccess_tree = proto_item_add_subtree(ti, ett_ipaccess);
176+ proto_tree_add_item(ipaccess_tree, hf_ipaccess_msgtype,
177+ tvb, 0, 1, FALSE);
178+ switch (msg_type) {
179+ case 4:
180+ case 5:
Harald Welte63aba292009-07-04 04:11:21 +0200181+ dissect_ipa_attr(tvb, 1, ipaccess_tree);
Harald Welte2d112ad2009-06-10 05:42:52 +0800182+ break;
183+ }
184+ }
185+
186+ return 1;
187+}
188+
189+
190+/* Code to actually dissect the packets */
191+static void
192+dissect_abisip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
193+{
194+
195+ int offset = 0;
196+
197+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
198+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Abis/IP");
199+ if (check_col(pinfo->cinfo, COL_INFO))
200+ col_clear(pinfo->cinfo, COL_INFO);
201+
202+ while (tvb_reported_length_remaining(tvb, offset) != 0) {
203+ proto_item *ti;
204+ proto_tree *abisip_tree;
205+ guint8 len, msg_type;
206+ tvbuff_t *next_tvb;
207+
208+ len = tvb_get_guint8(tvb, offset+1);
209+ msg_type = tvb_get_guint8(tvb, offset+2);
210+
211+ if (check_col(pinfo->cinfo, COL_INFO))
212+ col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
213+ val_to_str(msg_type, abisip_protocol_vals,
214+ "unknown 0x%02x"));
215+
216+ if (tree) {
Harald Welted64d2ad2009-06-25 20:50:33 +0200217+ ti = proto_tree_add_protocol_format(tree, proto_abisip,
218+ tvb, offset, len+3,
219+ "A-bis/IP protocol ip.access, type: %s",
220+ val_to_str(msg_type, abisip_protocol_vals,
221+ "unknown 0x%02x"));
Harald Welte2d112ad2009-06-10 05:42:52 +0800222+ abisip_tree = proto_item_add_subtree(ti, ett_abisip);
223+ proto_tree_add_item(abisip_tree, hf_abisip_data_len,
224+ tvb, offset+1, 1, FALSE);
225+ proto_tree_add_item(abisip_tree, hf_abisip_protocol,
226+ tvb, offset+2, 1, FALSE);
227+ }
228+
229+ next_tvb = tvb_new_subset(tvb, offset+3, len, len);
230+
231+ switch (msg_type) {
232+ case ABISIP_RSL:
233+ /* hand this off to the standard A-bis RSL dissector */
234+ call_dissector(sub_handles[SUB_RSL], next_tvb, pinfo, tree);
235+ break;
236+ case ABISIP_OML:
237+ /* hand this off to the standard A-bis OML dissector */
Harald Welted64d2ad2009-06-25 20:50:33 +0200238+ if (sub_handles[SUB_OML])
239+ call_dissector(sub_handles[SUB_OML], next_tvb,
240+ pinfo, tree);
Harald Welte2d112ad2009-06-10 05:42:52 +0800241+ break;
242+ case ABISIP_IPACCESS:
243+ dissect_ipaccess(next_tvb, pinfo, tree);
244+ break;
245+ }
246+ offset += len + 3;
247+ }
248+}
249+
Harald Welte63aba292009-07-04 04:11:21 +0200250+void proto_register_abis_ip(void)
Harald Welte2d112ad2009-06-10 05:42:52 +0800251+{
252+ static hf_register_info hf[] = {
253+ {&hf_abisip_data_len,
254+ {"DataLen", "abisip.data_len",
255+ FT_UINT8, BASE_DEC, NULL, 0x0,
256+ "The length of the data (in bytes)", HFILL}
257+ },
258+ {&hf_abisip_protocol,
259+ {"Protocol", "abisip.protocol",
260+ FT_UINT8, BASE_HEX, VALS(abisip_protocol_vals), 0x0,
261+ "The A-bis/IP Sub-Protocol", HFILL}
262+ },
263+ };
264+ static hf_register_info hf_ipa[] = {
265+ {&hf_ipaccess_msgtype,
266+ {"MessageType", "ipaccess.msg_type",
267+ FT_UINT8, BASE_HEX, VALS(ipaccess_msgtype_vals), 0x0,
Harald Welte63aba292009-07-04 04:11:21 +0200268+ "Type of ip.access messsage", HFILL}
Harald Welte2d112ad2009-06-10 05:42:52 +0800269+ },
270+ {&hf_ipaccess_attr_tag,
271+ {"Tag", "ipaccess.attr_tag",
272+ FT_UINT8, BASE_HEX, VALS(ipaccess_idtag_vals), 0x0,
273+ "Attribute Tag", HFILL}
274+ },
275+ {&hf_ipaccess_attr_string,
276+ {"String", "ipaccess.attr_string",
277+ FT_STRING, BASE_NONE, NULL, 0x0,
278+ "String attribute", HFILL}
279+ },
280+ };
281+
282+ static gint *ett[] = {
283+ &ett_abisip,
284+ &ett_ipaccess,
285+ };
286+
287+ proto_abisip =
Harald Welte63aba292009-07-04 04:11:21 +0200288+ proto_register_protocol("GSM A-bis/IP protocol as used by ip.access",
289+ "GSM A-bis/IP", "gsm_abis_ip");
Harald Welte2d112ad2009-06-10 05:42:52 +0800290+ proto_ipaccess =
Harald Welte63aba292009-07-04 04:11:21 +0200291+ proto_register_protocol("GSM A-bis/IP ip.access CCM sub-protocol",
Harald Welte2d112ad2009-06-10 05:42:52 +0800292+ "IPA", "ipaccess");
293+
294+ proto_register_field_array(proto_abisip, hf, array_length(hf));
295+ proto_register_field_array(proto_ipaccess, hf_ipa, array_length(hf_ipa));
296+ proto_register_subtree_array(ett, array_length(ett));
Harald Welted64d2ad2009-06-25 20:50:33 +0200297+
298+ register_dissector("gsm_abis_ip", dissect_abisip, proto_abisip);
Harald Welte2d112ad2009-06-10 05:42:52 +0800299+}
300+
Harald Welte63aba292009-07-04 04:11:21 +0200301+void proto_reg_handoff_gsm_abis_ip(void)
Harald Welte2d112ad2009-06-10 05:42:52 +0800302+{
303+ dissector_handle_t abisip_handle;
304+
305+ sub_handles[SUB_RSL] = find_dissector("gsm_abis_rsl");
306+ sub_handles[SUB_OML] = find_dissector("gsm_abis_oml");
307+
308+ abisip_handle = create_dissector_handle(dissect_abisip, proto_abisip);
309+ dissector_add("tcp.port", TCP_PORT_ABISIP_PRIM, abisip_handle);
310+ dissector_add("tcp.port", TCP_PORT_ABISIP_SEC, abisip_handle);
311+ dissector_add("tcp.port", TCP_PORT_ABISIP_INST, abisip_handle);
312+ dissector_add("udp.port", TCP_PORT_ABISIP_INST, abisip_handle);
313+}