1 /* packet-bicc_mst.c
2  * (Incomplete) Dissector for the 3GPP TS 29.205 BICC MST (Mobile Service Transport)
3  *
4  * This currently only dissects a single MST IE, which is required by the BSSMAP
5  * dissector in order to decode the LCLS (Local Call Local Switch)
6  * GCR (Global Call Reference)
7  *
8  * Copyright 2019 by Harald Welte <laforge@gnumonks.org>
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
14  * SPDX-License-Identifier: GPL-2.0-or-later
15  */
16 
17 #include "config.h"
18 
19 #include <epan/packet.h>
20 #include <epan/tap.h>
21 #include <epan/expert.h>
22 
23 #include "packet-bicc_mst.h"
24 
25 void proto_register_bicc_mst(void);
26 
27 static int proto_bicc_mst = -1;
28 
29 static int hf_lcls_gcr_network_id_len = -1;
30 static int hf_lcls_gcr_network_id = -1;
31 static int hf_lcls_gcr_node_id_len = -1;
32 static int hf_lcls_gcr_node_id = -1;
33 static int hf_lcls_gcr_call_ref_id_len = -1;
34 static int hf_lcls_gcr_call_ref_id = -1;
35 
36 static int ett_lcls_gcr = -1;
37 
38 guint
dissect_bicc_mst_lcls_gcr(tvbuff_t * tvb,proto_tree * tree,guint32 offset,guint len)39 dissect_bicc_mst_lcls_gcr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
40 {
41 	guint net_id_len, node_id_len, call_ref_id_len;
42 	guint32 curr_offset = offset;
43 	proto_tree *subtree;
44 	proto_item *ti;
45 
46 	ti = proto_tree_add_protocol_format(tree, proto_bicc_mst, tvb, offset, len, "BICC MST GCR");
47 	subtree = proto_item_add_subtree(ti, ett_lcls_gcr);
48 
49 	proto_tree_add_item_ret_uint(subtree, hf_lcls_gcr_network_id_len, tvb, curr_offset++, 1, ENC_NA, &net_id_len);
50 	proto_tree_add_item(subtree, hf_lcls_gcr_network_id, tvb, curr_offset, net_id_len, ENC_NA);
51 	curr_offset += net_id_len;
52 
53 	proto_tree_add_item_ret_uint(subtree, hf_lcls_gcr_node_id_len, tvb, curr_offset++, 1, ENC_NA, &node_id_len);
54 	proto_tree_add_item(subtree, hf_lcls_gcr_node_id, tvb, curr_offset, node_id_len, ENC_NA);
55 	curr_offset += node_id_len;
56 
57 	proto_tree_add_item_ret_uint(subtree, hf_lcls_gcr_call_ref_id_len, tvb, curr_offset++, 1, ENC_NA, &call_ref_id_len);
58 	proto_tree_add_item(subtree, hf_lcls_gcr_call_ref_id, tvb, curr_offset, call_ref_id_len, ENC_NA);
59 	curr_offset += call_ref_id_len;
60 
61 	return curr_offset - offset;
62 }
63 
64 void
proto_register_bicc_mst(void)65 proto_register_bicc_mst(void)
66 {
67 	static hf_register_info hf[] = {
68 		{ &hf_lcls_gcr_network_id_len, { "Length of LCLS GCR Network ID",
69 		  "bicc_mst.lcls_gcr.network_id_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
70 		{ &hf_lcls_gcr_network_id, { "LCLS GCR Network ID",
71 		  "bicc_mst.lcls_gcr.network_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
72 		{ &hf_lcls_gcr_node_id_len, { "Length of LCLS GCR Node ID",
73 		  "bicc_mst.lcls_gcr.node_id_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
74 		{ &hf_lcls_gcr_node_id, { "LCLS GCR Network ID",
75 		  "bicc_mst.lcls_gcr.network_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
76 		{ &hf_lcls_gcr_call_ref_id_len, { "Length of LCLS GCR Call Ref ID",
77 		  "bicc_mst.lcls_gcr.call_ref_id_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
78 		{ &hf_lcls_gcr_call_ref_id, { "LCLS GCR Call Ref ID",
79 		  "bicc_mst.lcls_gcr.call_ref_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
80 	};
81 
82 	static gint *ett[] = {
83 		&ett_lcls_gcr,
84 	};
85 
86 	proto_bicc_mst = proto_register_protocol("3GPP BICC MST", "BICC-MST", "bicc_mst");
87 	proto_register_field_array(proto_bicc_mst, hf, array_length(hf));
88 	proto_register_subtree_array(ett, array_length(ett));
89 }
90 
91 /*
92  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
93  *
94  * Local variables:
95  * c-basic-offset: 8
96  * tab-width: 8
97  * indent-tabs-mode: t
98  * End:
99  *
100  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
101  * :indentSize=8:tabSize=8:noTabs=false:
102  */
103