2 * Routines for dissecting Evolved Universal Terrestrial Radio Access Network (EUTRAN);
3 * X2 Application Protocol (X2AP);
4 * 3GPP TS 36.423 packet dissection
5 * Copyright 2007-2010, Anders Broman <anders.broman@ericsson.com>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * 3GPP TS 36.423 V9.2.0 (2010-03)
34 #include <epan/packet.h>
36 #include <epan/asn1.h>
37 #include <epan/prefs.h>
38 #include <epan/sctpppids.h>
40 #include "packet-per.h"
41 #include "packet-e212.h"
42 #include "packet-lte-rrc.h"
45 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
46 #pragma warning(disable:4146)
49 #define PNAME "EUTRAN X2 Application Protocol (X2AP)"
53 void proto_register_x2ap(void);
55 /* Dissector will use SCTP PPID 27 or SCTP port. IANA assigned port = 36422 */
56 #define SCTP_PORT_X2AP 36422
58 #include "packet-x2ap-val.h"
60 /* Initialize the protocol and registered fields */
61 static int proto_x2ap = -1;
62 static int hf_x2ap_transportLayerAddressIPv4 = -1;
63 static int hf_x2ap_transportLayerAddressIPv6 = -1;
64 #include "packet-x2ap-hf.c"
66 /* Initialize the subtree pointers */
67 static int ett_x2ap = -1;
68 static int ett_x2ap_TransportLayerAddress = -1;
69 #include "packet-x2ap-ett.c"
71 /* Global variables */
72 static guint32 ProcedureCode;
73 static guint32 ProtocolIE_ID;
74 static guint gbl_x2apSctpPort=SCTP_PORT_X2AP;
76 /* Dissector tables */
77 static dissector_table_t x2ap_ies_dissector_table;
78 static dissector_table_t x2ap_extension_dissector_table;
79 static dissector_table_t x2ap_proc_imsg_dissector_table;
80 static dissector_table_t x2ap_proc_sout_dissector_table;
81 static dissector_table_t x2ap_proc_uout_dissector_table;
83 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
84 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
85 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
86 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
87 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
88 void proto_reg_handoff_x2ap(void);
90 #include "packet-x2ap-fn.c"
92 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
94 return (dissector_try_uint(x2ap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
97 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
99 return (dissector_try_uint(x2ap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
102 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
104 return (dissector_try_uint(x2ap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
107 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
109 return (dissector_try_uint(x2ap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
112 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
114 return (dissector_try_uint(x2ap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
118 dissect_x2ap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
120 proto_item *x2ap_item = NULL;
121 proto_tree *x2ap_tree = NULL;
123 /* make entry in the Protocol column on summary display */
124 col_set_str(pinfo->cinfo, COL_PROTOCOL, "X2AP");
126 /* create the x2ap protocol tree */
127 x2ap_item = proto_tree_add_item(tree, proto_x2ap, tvb, 0, -1, ENC_NA);
128 x2ap_tree = proto_item_add_subtree(x2ap_item, ett_x2ap);
130 dissect_X2AP_PDU_PDU(tvb, pinfo, x2ap_tree);
133 /*--- proto_register_x2ap -------------------------------------------*/
134 void proto_register_x2ap(void) {
138 static hf_register_info hf[] = {
139 { &hf_x2ap_transportLayerAddressIPv4,
140 { "transportLayerAddress(IPv4)", "x2ap.transportLayerAddressIPv4",
141 FT_IPv4, BASE_NONE, NULL, 0,
143 { &hf_x2ap_transportLayerAddressIPv6,
144 { "transportLayerAddress(IPv6)", "x2ap.transportLayerAddressIPv6",
145 FT_IPv6, BASE_NONE, NULL, 0,
148 #include "packet-x2ap-hfarr.c"
151 /* List of subtrees */
152 static gint *ett[] = {
154 &ett_x2ap_TransportLayerAddress,
155 #include "packet-x2ap-ettarr.c"
158 module_t *x2ap_module;
160 /* Register protocol */
161 proto_x2ap = proto_register_protocol(PNAME, PSNAME, PFNAME);
162 /* Register fields and subtrees */
163 proto_register_field_array(proto_x2ap, hf, array_length(hf));
164 proto_register_subtree_array(ett, array_length(ett));
166 /* Register dissector */
167 register_dissector("x2ap", dissect_x2ap, proto_x2ap);
169 /* Register dissector tables */
170 x2ap_ies_dissector_table = register_dissector_table("x2ap.ies", "X2AP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
171 x2ap_extension_dissector_table = register_dissector_table("x2ap.extension", "X2AP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
172 x2ap_proc_imsg_dissector_table = register_dissector_table("x2ap.proc.imsg", "X2AP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
173 x2ap_proc_sout_dissector_table = register_dissector_table("x2ap.proc.sout", "X2AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
174 x2ap_proc_uout_dissector_table = register_dissector_table("x2ap.proc.uout", "X2AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
176 /* Register configuration options for ports */
177 x2ap_module = prefs_register_protocol(proto_x2ap, proto_reg_handoff_x2ap);
179 prefs_register_uint_preference(x2ap_module, "sctp.port",
181 "Set the SCTP port for X2AP messages",
188 /*--- proto_reg_handoff_x2ap ---------------------------------------*/
190 proto_reg_handoff_x2ap(void)
192 dissector_handle_t x2ap_handle;
193 static gboolean Initialized=FALSE;
194 static guint SctpPort;
196 x2ap_handle = find_dissector("x2ap");
198 dissector_add_handle("sctp.port", x2ap_handle); /* for "decode-as" */
199 dissector_add_uint("sctp.ppi", X2AP_PAYLOAD_PROTOCOL_ID, x2ap_handle);
201 #include "packet-x2ap-dis-tab.c"
204 dissector_delete_uint("sctp.port", SctpPort, x2ap_handle);
208 SctpPort=gbl_x2apSctpPort;
210 dissector_add_uint("sctp.port", SctpPort, x2ap_handle);