2 * Routines for E-UTRAN S1 Application Protocol (S1AP) packet dissection
3 * Copyright 2007-2010, Anders Broman <anders.broman@ericsson.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Based on the RANAP dissector
27 * References: 3GPP TS 36.413 V9.2.0 (2010-03)
35 #include <epan/packet.h>
38 #include <epan/strutil.h>
39 #include <epan/asn1.h>
40 #include <epan/prefs.h>
41 #include <epan/sctpppids.h>
43 #include "packet-ber.h"
44 #include "packet-per.h"
45 #include "packet-e212.h"
46 #include "packet-sccp.h"
47 #include "packet-lte-rrc.h"
48 #include "packet-ranap.h"
51 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
52 #pragma warning(disable:4146)
55 #define PNAME "S1 Application Protocol"
59 /* Dissector will use SCTP PPID 18 or SCTP port. IANA assigned port = 36412 */
60 #define SCTP_PORT_S1AP 36412
62 static dissector_handle_t nas_eps_handle;
63 static dissector_handle_t lppa_handle;
64 static dissector_handle_t bssgp_handle;
66 #include "packet-s1ap-val.h"
68 /* Initialize the protocol and registered fields */
69 static int proto_s1ap = -1;
71 static int hf_s1ap_transportLayerAddressIPv4 = -1;
72 static int hf_s1ap_transportLayerAddressIPv6 = -1;
73 #include "packet-s1ap-hf.c"
75 /* Initialize the subtree pointers */
76 static int ett_s1ap = -1;
77 static int ett_s1ap_TransportLayerAddress = -1;
78 static int ett_s1ap_ToTargetTransparentContainer = -1;
79 static int ett_s1ap_ToSourceTransparentContainer = -1;
80 static int ett_s1ap_RRCContainer = -1;
81 static int ett_s1ap_UERadioCapability = -1;
82 static int ett_s1ap_RIMInformation = -1;
84 #include "packet-s1ap-ett.c"
92 /* Global variables */
93 static guint32 ProcedureCode;
94 static guint32 ProtocolIE_ID;
95 static guint32 ProtocolExtensionID;
96 static guint gbl_s1apSctpPort=SCTP_PORT_S1AP;
97 static guint32 handover_type_value;
98 static guint32 message_type;
100 /* Dissector tables */
101 static dissector_table_t s1ap_ies_dissector_table;
102 static dissector_table_t s1ap_ies_p1_dissector_table;
103 static dissector_table_t s1ap_ies_p2_dissector_table;
104 static dissector_table_t s1ap_extension_dissector_table;
105 static dissector_table_t s1ap_proc_imsg_dissector_table;
106 static dissector_table_t s1ap_proc_sout_dissector_table;
107 static dissector_table_t s1ap_proc_uout_dissector_table;
109 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
110 /* Currently not used
111 static int dissect_ProtocolIEFieldPairFirstValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
112 static int dissect_ProtocolIEFieldPairSecondValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
114 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
115 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
116 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
117 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
119 static int dissect_SourceeNB_ToTargeteNB_TransparentContainer_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
120 static int dissect_TargeteNB_ToSourceeNB_TransparentContainer_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
121 static int dissect_SourceRNC_ToTargetRNC_TransparentContainer_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
122 static int dissect_TargetRNC_ToSourceRNC_TransparentContainer_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
123 static int dissect_SourceBSS_ToTargetBSS_TransparentContainer_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
124 static int dissect_TargetBSS_ToSourceBSS_TransparentContainer_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
126 #include "packet-s1ap-fn.c"
128 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
130 return (dissector_try_uint(s1ap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
132 /* Currently not used
133 static int dissect_ProtocolIEFieldPairFirstValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
135 return (dissector_try_uint(s1ap_ies_p1_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
138 static int dissect_ProtocolIEFieldPairSecondValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
140 return (dissector_try_uint(s1ap_ies_p2_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
144 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
146 return (dissector_try_uint(s1ap_extension_dissector_table, ProtocolExtensionID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
149 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
151 return (dissector_try_uint(s1ap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
154 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
156 return (dissector_try_uint(s1ap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
159 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
161 return (dissector_try_uint(s1ap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
166 dissect_s1ap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
168 proto_item *s1ap_item = NULL;
169 proto_tree *s1ap_tree = NULL;
171 /* make entry in the Protocol column on summary display */
172 col_set_str(pinfo->cinfo, COL_PROTOCOL, "S1AP");
174 /* create the s1ap protocol tree */
175 s1ap_item = proto_tree_add_item(tree, proto_s1ap, tvb, 0, -1, ENC_NA);
176 s1ap_tree = proto_item_add_subtree(s1ap_item, ett_s1ap);
178 dissect_S1AP_PDU_PDU(tvb, pinfo, s1ap_tree);
181 /*--- proto_reg_handoff_s1ap ---------------------------------------*/
183 proto_reg_handoff_s1ap(void)
185 static gboolean Initialized=FALSE;
186 static dissector_handle_t s1ap_handle;
187 static guint SctpPort;
189 s1ap_handle = find_dissector("s1ap");
192 nas_eps_handle = find_dissector("nas-eps");
193 lppa_handle = find_dissector("lppa");
194 bssgp_handle = find_dissector("bssgp");
195 dissector_add_handle("sctp.port", s1ap_handle); /* for "decode-as" */
196 dissector_add_uint("sctp.ppi", S1AP_PAYLOAD_PROTOCOL_ID, s1ap_handle);
198 #include "packet-s1ap-dis-tab.c"
201 dissector_delete_uint("sctp.port", SctpPort, s1ap_handle);
205 SctpPort=gbl_s1apSctpPort;
207 dissector_add_uint("sctp.port", SctpPort, s1ap_handle);
211 /*--- proto_register_s1ap -------------------------------------------*/
212 void proto_register_s1ap(void) {
216 static hf_register_info hf[] = {
217 { &hf_s1ap_transportLayerAddressIPv4,
218 { "transportLayerAddress(IPv4)", "s1ap.transportLayerAddressIPv4",
219 FT_IPv4, BASE_NONE, NULL, 0,
221 { &hf_s1ap_transportLayerAddressIPv6,
222 { "transportLayerAddress(IPv6)", "s1ap.transportLayerAddressIPv6",
223 FT_IPv6, BASE_NONE, NULL, 0,
226 #include "packet-s1ap-hfarr.c"
229 /* List of subtrees */
230 static gint *ett[] = {
232 &ett_s1ap_TransportLayerAddress,
233 &ett_s1ap_ToTargetTransparentContainer,
234 &ett_s1ap_ToSourceTransparentContainer,
235 &ett_s1ap_RRCContainer,
236 &ett_s1ap_UERadioCapability,
237 &ett_s1ap_RIMInformation,
238 #include "packet-s1ap-ettarr.c"
241 module_t *s1ap_module;
243 /* Register protocol */
244 proto_s1ap = proto_register_protocol(PNAME, PSNAME, PFNAME);
245 /* Register fields and subtrees */
246 proto_register_field_array(proto_s1ap, hf, array_length(hf));
247 proto_register_subtree_array(ett, array_length(ett));
249 /* Register dissector */
250 register_dissector("s1ap", dissect_s1ap, proto_s1ap);
252 /* Register dissector tables */
253 s1ap_ies_dissector_table = register_dissector_table("s1ap.ies", "S1AP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
254 s1ap_ies_p1_dissector_table = register_dissector_table("s1ap.ies.pair.first", "S1AP-PROTOCOL-IES-PAIR FirstValue", FT_UINT32, BASE_DEC);
255 s1ap_ies_p2_dissector_table = register_dissector_table("s1ap.ies.pair.second", "S1AP-PROTOCOL-IES-PAIR SecondValue", FT_UINT32, BASE_DEC);
256 s1ap_extension_dissector_table = register_dissector_table("s1ap.extension", "S1AP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
257 s1ap_proc_imsg_dissector_table = register_dissector_table("s1ap.proc.imsg", "S1AP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
258 s1ap_proc_sout_dissector_table = register_dissector_table("s1ap.proc.sout", "S1AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
259 s1ap_proc_uout_dissector_table = register_dissector_table("s1ap.proc.uout", "S1AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
261 /* Register configuration options for ports */
262 s1ap_module = prefs_register_protocol(proto_s1ap, proto_reg_handoff_s1ap);
264 prefs_register_uint_preference(s1ap_module, "sctp.port",
266 "Set the SCTP port for S1AP messages",