2 * Routines for M3 Application Protocol packet dissection
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Reference: 3GPP TS 36.444 v11.0.0
27 #include <epan/packet.h>
29 #include <epan/strutil.h>
30 #include <epan/asn1.h>
31 #include <epan/sctpppids.h>
32 #include <epan/expert.h>
34 #include "packet-ber.h"
35 #include "packet-per.h"
36 #include "packet-e212.h"
37 #include "packet-gtpv2.h"
38 #include "packet-ntp.h"
40 #define PNAME "M3 Application Protocol"
44 void proto_register_m3ap(void);
45 void proto_reg_handoff_m3ap(void);
47 /* M3AP uses port 36444 as recommended by IANA. */
48 #define M3AP_PORT 36444
49 static dissector_handle_t m3ap_handle=NULL;
51 #include "packet-m3ap-val.h"
53 /* Initialize the protocol and registered fields */
54 static int proto_m3ap = -1;
56 static int hf_m3ap_Absolute_Time_ofMBMS_Data_value = -1;
57 static int hf_m3ap_IPAddress_v4 = -1;
58 static int hf_m3ap_IPAddress_v6 = -1;
60 #include "packet-m3ap-hf.c"
62 /* Initialize the subtree pointers */
63 static int ett_m3ap = -1;
65 #include "packet-m3ap-ett.c"
67 static expert_field ei_m3ap_invalid_ip_address_len = EI_INIT;
75 /* Global variables */
76 static guint32 ProcedureCode;
77 static guint32 ProtocolIE_ID;
78 /*static guint32 ProtocolExtensionID; */
79 static int global_m3ap_port = M3AP_PORT;
80 static guint32 message_type;
82 /* Dissector tables */
83 static dissector_table_t m3ap_ies_dissector_table;
84 static dissector_table_t m3ap_extension_dissector_table;
85 static dissector_table_t m3ap_proc_imsg_dissector_table;
86 static dissector_table_t m3ap_proc_sout_dissector_table;
87 static dissector_table_t m3ap_proc_uout_dissector_table;
89 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
90 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
91 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
92 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
93 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
95 #include "packet-m3ap-fn.c"
97 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
99 return (dissector_try_uint(m3ap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
102 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
104 return (dissector_try_uint(m3ap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
107 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
109 return (dissector_try_uint(m3ap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
112 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
114 return (dissector_try_uint(m3ap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
117 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
119 return (dissector_try_uint(m3ap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
124 dissect_m3ap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
126 proto_item *m3ap_item = NULL;
127 proto_tree *m3ap_tree = NULL;
129 /* make entry in the Protocol column on summary display */
130 col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
132 /* create the m3ap protocol tree */
134 m3ap_item = proto_tree_add_item(tree, proto_m3ap, tvb, 0, -1, ENC_NA);
135 m3ap_tree = proto_item_add_subtree(m3ap_item, ett_m3ap);
137 dissect_M3AP_PDU_PDU(tvb, pinfo, m3ap_tree, NULL);
139 return tvb_captured_length(tvb);
141 /*--- proto_register_m3ap -------------------------------------------*/
142 void proto_register_m3ap(void) {
145 static hf_register_info hf[] = {
146 { &hf_m3ap_Absolute_Time_ofMBMS_Data_value,
147 { "Absolute-Time-ofMBMS-Data-value", "m3ap.Absolute_Time_ofMBMS_Data_value",
148 FT_STRING, BASE_NONE, NULL, 0,
151 { &hf_m3ap_IPAddress_v4,
152 { "IPAddress", "m3ap.IPAddress_v4",
153 FT_IPv4, BASE_NONE, NULL, 0,
156 { &hf_m3ap_IPAddress_v6,
157 { "IPAddress", "m3ap.IPAddress_v6",
158 FT_IPv6, BASE_NONE, NULL, 0,
162 #include "packet-m3ap-hfarr.c"
165 /* List of subtrees */
166 static gint *ett[] = {
168 #include "packet-m3ap-ettarr.c"
171 expert_module_t* expert_m3ap;
173 static ei_register_info ei[] = {
174 { &ei_m3ap_invalid_ip_address_len, { "m3ap.invalid_ip_address_len", PI_MALFORMED, PI_ERROR, "Invalid IP address length", EXPFILL }}
177 /* Register protocol */
178 proto_m3ap = proto_register_protocol(PNAME, PSNAME, PFNAME);
179 /* Register fields and subtrees */
180 proto_register_field_array(proto_m3ap, hf, array_length(hf));
181 proto_register_subtree_array(ett, array_length(ett));
182 expert_m3ap = expert_register_protocol(proto_m3ap);
183 expert_register_field_array(expert_m3ap, ei, array_length(ei));
185 /* Register dissector tables */
186 m3ap_ies_dissector_table = register_dissector_table("m3ap.ies", "M3AP-PROTOCOL-IES", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
187 m3ap_extension_dissector_table = register_dissector_table("m3ap.extension", "M3AP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
188 m3ap_proc_imsg_dissector_table = register_dissector_table("m3ap.proc.imsg", "M3AP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
189 m3ap_proc_sout_dissector_table = register_dissector_table("m3ap.proc.sout", "M3AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
190 m3ap_proc_uout_dissector_table = register_dissector_table("m3ap.proc.uout", "M3AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
194 /*--- proto_reg_handoff_m3ap ---------------------------------------*/
196 proto_reg_handoff_m3ap(void)
198 static gboolean inited = FALSE;
199 static guint SctpPort;
202 m3ap_handle = create_dissector_handle(dissect_m3ap, proto_m3ap);
203 dissector_add_uint("sctp.ppi", PROTO_3GPP_M3AP_PROTOCOL_ID, m3ap_handle);
205 #include "packet-m3ap-dis-tab.c"
206 dissector_add_uint("m3ap.extension", 17, create_dissector_handle(dissect_AllocationAndRetentionPriority_PDU, proto_m3ap));
210 dissector_delete_uint("sctp.port", SctpPort, m3ap_handle);
214 SctpPort = global_m3ap_port;
216 dissector_add_uint("sctp.port", SctpPort, m3ap_handle);