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-2008, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * 3GPP TS 36.423 V8.0.0 (2007-12)
36 #include <epan/packet.h>
41 #include <epan/asn1.h>
42 #include <epan/prefs.h>
43 #include <epan/sctpppids.h>
45 #include "packet-per.h"
46 #include "packet-e212.h"
47 #include "packet-frame.h"
48 #include "packet-lte-rrc.h"
51 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
52 #pragma warning(disable:4146)
55 #define PNAME "EUTRAN X2 Application Protocol (X2AP)"
59 /* Dissector will use SCTP PPID 27 or SCTP port. IANA assigned port = 36422 */
60 #define SCTP_PORT_X2AP 36422
62 #include "packet-x2ap-val.h"
64 /* Initialize the protocol and registered fields */
65 static int proto_x2ap = -1;
66 static int hf_x2ap_transportLayerAddressIPv4 = -1;
67 static int hf_x2ap_transportLayerAddressIPv6 = -1;
68 #include "packet-x2ap-hf.c"
70 /* Initialize the subtree pointers */
71 static int ett_x2ap = -1;
72 static int ett_x2ap_TransportLayerAddress = -1;
73 #include "packet-x2ap-ett.c"
75 /* Global variables */
76 static guint32 ProcedureCode;
77 static guint32 ProtocolIE_ID;
78 static guint gbl_x2apSctpPort=SCTP_PORT_X2AP;
80 /* Dissector tables */
81 static dissector_table_t x2ap_ies_dissector_table;
82 static dissector_table_t x2ap_extension_dissector_table;
83 static dissector_table_t x2ap_proc_imsg_dissector_table;
84 static dissector_table_t x2ap_proc_sout_dissector_table;
85 static dissector_table_t x2ap_proc_uout_dissector_table;
87 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
88 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
89 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
90 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
91 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
92 void proto_reg_handoff_x2ap(void);
94 #include "packet-x2ap-fn.c"
96 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
98 return (dissector_try_port(x2ap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
101 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
103 return (dissector_try_port(x2ap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
106 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
108 return (dissector_try_port(x2ap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
111 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
113 return (dissector_try_port(x2ap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
116 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
118 return (dissector_try_port(x2ap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
122 dissect_x2ap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
124 proto_item *x2ap_item = NULL;
125 proto_tree *x2ap_tree = NULL;
127 /* make entry in the Protocol column on summary display */
128 col_set_str(pinfo->cinfo, COL_PROTOCOL, "X2AP");
130 /* create the x2ap protocol tree */
131 x2ap_item = proto_tree_add_item(tree, proto_x2ap, tvb, 0, -1, FALSE);
132 x2ap_tree = proto_item_add_subtree(x2ap_item, ett_x2ap);
134 dissect_X2AP_PDU_PDU(tvb, pinfo, x2ap_tree);
137 /*--- proto_register_x2ap -------------------------------------------*/
138 void proto_register_x2ap(void) {
142 static hf_register_info hf[] = {
143 { &hf_x2ap_transportLayerAddressIPv4,
144 { "transportLayerAddress(IPv4)", "x2ap.transportLayerAddressIPv4",
145 FT_IPv4, BASE_NONE, NULL, 0,
147 { &hf_x2ap_transportLayerAddressIPv6,
148 { "transportLayerAddress(IPv6)", "x2ap.transportLayerAddressIPv6",
149 FT_IPv4, BASE_NONE, NULL, 0,
152 #include "packet-x2ap-hfarr.c"
155 /* List of subtrees */
156 static gint *ett[] = {
158 &ett_x2ap_TransportLayerAddress,
159 #include "packet-x2ap-ettarr.c"
162 module_t *x2ap_module;
164 /* Register protocol */
165 proto_x2ap = proto_register_protocol(PNAME, PSNAME, PFNAME);
166 /* Register fields and subtrees */
167 proto_register_field_array(proto_x2ap, hf, array_length(hf));
168 proto_register_subtree_array(ett, array_length(ett));
170 /* Register dissector */
171 register_dissector("x2ap", dissect_x2ap, proto_x2ap);
173 /* Register dissector tables */
174 x2ap_ies_dissector_table = register_dissector_table("x2ap.ies", "X2AP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
175 x2ap_extension_dissector_table = register_dissector_table("x2ap.extension", "X2AP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
176 x2ap_proc_imsg_dissector_table = register_dissector_table("x2ap.proc.imsg", "X2AP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
177 x2ap_proc_sout_dissector_table = register_dissector_table("x2ap.proc.sout", "X2AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
178 x2ap_proc_uout_dissector_table = register_dissector_table("x2ap.proc.uout", "X2AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
180 /* Register configuration options for ports */
181 x2ap_module = prefs_register_protocol(proto_x2ap, proto_reg_handoff_x2ap);
183 prefs_register_uint_preference(x2ap_module, "sctp.port",
185 "Set the SCTP port for X2AP messages",
192 /*--- proto_reg_handoff_x2ap ---------------------------------------*/
194 proto_reg_handoff_x2ap(void)
196 dissector_handle_t x2ap_handle;
197 static gboolean Initialized=FALSE;
198 static guint SctpPort;
200 x2ap_handle = find_dissector("x2ap");
202 dissector_add_handle("sctp.port", x2ap_handle); /* for "decode-as" */
203 dissector_add("sctp.ppi", X2AP_PAYLOAD_PROTOCOL_ID, x2ap_handle);
205 #include "packet-x2ap-dis-tab.c"
208 dissector_delete("sctp.port", SctpPort, x2ap_handle);
212 SctpPort=gbl_x2apSctpPort;
214 dissector_add("sctp.port", SctpPort, x2ap_handle);