2 * Routines for E-UTRAN E1 Application Protocol (E1AP) packet dissection
3 * Copyright 2018-2024, Pascal Quantin <pascal@wireshark.org>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * References: 3GPP TS 37.483 V18.2.0 (2024-06)
16 #include <epan/packet.h>
18 #include <epan/asn1.h>
19 #include <epan/sctpppids.h>
20 #include <epan/proto_data.h>
22 #include <epan/unit_strings.h>
23 #include <wsutil/array.h>
25 #include "packet-e1ap.h"
26 #include "packet-per.h"
27 #include "packet-e212.h"
28 #include "packet-ntp.h"
29 #include "packet-nr-rrc.h"
30 #include "packet-tcp.h"
32 #define PNAME "E1 Application Protocol"
36 #define SCTP_PORT_E1AP 38462
38 void proto_register_e1ap(void);
39 void proto_reg_handoff_e1ap(void);
41 #include "packet-e1ap-val.h"
43 /* Initialize the protocol and registered fields */
44 static int proto_e1ap
;
46 static int hf_e1ap_transportLayerAddressIPv4
;
47 static int hf_e1ap_transportLayerAddressIPv6
;
48 static int hf_e1ap_InterfacesToTrace_NG_C
;
49 static int hf_e1ap_InterfacesToTrace_Xn_C
;
50 static int hf_e1ap_InterfacesToTrace_Uu
;
51 static int hf_e1ap_InterfacesToTrace_F1_C
;
52 static int hf_e1ap_InterfacesToTrace_E1
;
53 static int hf_e1ap_InterfacesToTrace_Reserved
;
54 static int hf_e1ap_MeasurementsToActivate_Reserved1
;
55 static int hf_e1ap_MeasurementsToActivate_M4
;
56 static int hf_e1ap_MeasurementsToActivate_Reserved2
;
57 static int hf_e1ap_MeasurementsToActivate_M6
;
58 static int hf_e1ap_MeasurementsToActivate_M7
;
59 static int hf_e1ap_ReportCharacteristics_TNLAvailableCapacityIndPeriodic
;
60 static int hf_e1ap_ReportCharacteristics_HWCapacityIndPeriodic
;
61 static int hf_e1ap_ReportCharacteristics_Reserved
;
62 static int hf_e1ap_tcp_pdu_len
;
63 #include "packet-e1ap-hf.c"
65 /* Initialize the subtree pointers */
67 static int ett_e1ap_PLMN_Identity
;
68 static int ett_e1ap_TransportLayerAddress
;
69 static int ett_e1ap_InterfacesToTrace
;
70 static int ett_e1ap_MeasurementsToActivate
;
71 static int ett_e1ap_ReportCharacteristics
;
72 static int ett_e1ap_BurstArrivalTime
;
73 #include "packet-e1ap-ett.c"
82 uint32_t message_type
;
83 uint32_t procedure_code
;
84 uint32_t protocol_ie_id
;
86 e212_number_type_t number_type
;
87 } e1ap_private_data_t
;
89 /* Global variables */
90 static dissector_handle_t e1ap_handle
;
91 static dissector_handle_t e1ap_tcp_handle
;
93 /* Dissector tables */
94 static dissector_table_t e1ap_ies_dissector_table
;
95 static dissector_table_t e1ap_extension_dissector_table
;
96 static dissector_table_t e1ap_proc_imsg_dissector_table
;
97 static dissector_table_t e1ap_proc_sout_dissector_table
;
98 static dissector_table_t e1ap_proc_uout_dissector_table
;
100 static int dissect_ProtocolIEFieldValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
101 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
102 static int dissect_InitiatingMessageValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
103 static int dissect_SuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
104 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *);
107 e1ap_MaxPacketLossRate_fmt(char *s
, uint32_t v
)
109 snprintf(s
, ITEM_LABEL_LENGTH
, "%.1f%% (%u)", (float)v
/10, v
);
113 e1ap_PacketDelayBudget_uL_D1_Result_fmt(char *s
, uint32_t v
)
115 snprintf(s
, ITEM_LABEL_LENGTH
, "%.1fms (%u)", (float)v
/2, v
);
119 e1ap_ExtendedPacketDelayBudget_fmt(char *s
, uint32_t v
)
121 snprintf(s
, ITEM_LABEL_LENGTH
, "%.2fms (%u)", (float)v
/100, v
);
125 e1ap_N6Jitter_fmt(char *s
, uint32_t v
)
127 snprintf(s
, ITEM_LABEL_LENGTH
, "%.1fms (%d)", (float)v
/2, (int32_t)v
);
130 static e1ap_private_data_t
*
131 e1ap_get_private_data(packet_info
*pinfo
)
133 e1ap_private_data_t
*e1ap_data
= (e1ap_private_data_t
*)p_get_proto_data(pinfo
->pool
, pinfo
, proto_e1ap
, 0);
135 e1ap_data
= wmem_new0(pinfo
->pool
, e1ap_private_data_t
);
136 p_add_proto_data(pinfo
->pool
, pinfo
, proto_e1ap
, 0, e1ap_data
);
141 #include "packet-e1ap-fn.c"
143 static int dissect_ProtocolIEFieldValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
146 e1ap_private_data_t
*e1ap_data
= e1ap_get_private_data(pinfo
);
148 e1ap_ctx
.message_type
= e1ap_data
->message_type
;
149 e1ap_ctx
.ProcedureCode
= e1ap_data
->procedure_code
;
150 e1ap_ctx
.ProtocolIE_ID
= e1ap_data
->protocol_ie_id
;
152 return (dissector_try_uint_with_data(e1ap_ies_dissector_table
, e1ap_data
->protocol_ie_id
, tvb
, pinfo
, tree
, false, &e1ap_ctx
)) ? tvb_captured_length(tvb
) : 0;
155 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
158 e1ap_private_data_t
*e1ap_data
= e1ap_get_private_data(pinfo
);
160 e1ap_ctx
.message_type
= e1ap_data
->message_type
;
161 e1ap_ctx
.ProcedureCode
= e1ap_data
->procedure_code
;
162 e1ap_ctx
.ProtocolIE_ID
= e1ap_data
->protocol_ie_id
;
164 return (dissector_try_uint_with_data(e1ap_extension_dissector_table
, e1ap_data
->protocol_ie_id
, tvb
, pinfo
, tree
, false, &e1ap_ctx
)) ? tvb_captured_length(tvb
) : 0;
167 static int dissect_InitiatingMessageValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
169 e1ap_private_data_t
*e1ap_data
= e1ap_get_private_data(pinfo
);
171 return (dissector_try_uint_with_data(e1ap_proc_imsg_dissector_table
, e1ap_data
->procedure_code
, tvb
, pinfo
, tree
, false, data
)) ? tvb_captured_length(tvb
) : 0;
174 static int dissect_SuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
176 e1ap_private_data_t
*e1ap_data
= e1ap_get_private_data(pinfo
);
178 return (dissector_try_uint_with_data(e1ap_proc_sout_dissector_table
, e1ap_data
->procedure_code
, tvb
, pinfo
, tree
, false, data
)) ? tvb_captured_length(tvb
) : 0;
181 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
183 e1ap_private_data_t
*e1ap_data
= e1ap_get_private_data(pinfo
);
185 return (dissector_try_uint_with_data(e1ap_proc_uout_dissector_table
, e1ap_data
->procedure_code
, tvb
, pinfo
, tree
, false, data
)) ? tvb_captured_length(tvb
) : 0;
190 dissect_e1ap(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
192 proto_item
*e1ap_item
= NULL
;
193 proto_tree
*e1ap_tree
= NULL
;
195 /* make entry in the Protocol column on summary display */
196 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "E1AP");
197 col_clear(pinfo
->cinfo
, COL_INFO
);
199 /* create the e1ap protocol tree */
200 e1ap_item
= proto_tree_add_item(tree
, proto_e1ap
, tvb
, 0, -1, ENC_NA
);
201 e1ap_tree
= proto_item_add_subtree(e1ap_item
, ett_e1ap
);
203 dissect_E1AP_PDU_PDU(tvb
, pinfo
, e1ap_tree
, NULL
);
204 return tvb_captured_length(tvb
);
208 get_e1ap_tcp_pdu_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
,
209 int offset
, void *data _U_
)
211 return tvb_get_ntohl(tvb
, offset
)+4;
215 dissect_e1ap_tcp_pdu(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
, void* data
)
219 proto_tree_add_item(tree
, hf_e1ap_tcp_pdu_len
, tvb
, 0, 4, ENC_NA
);
220 new_tvb
= tvb_new_subset_remaining(tvb
, 4);
222 return dissect_e1ap(new_tvb
, pinfo
, tree
, data
);
226 dissect_e1ap_tcp(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
, void* data
)
228 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, 4,
229 get_e1ap_tcp_pdu_len
, dissect_e1ap_tcp_pdu
, data
);
230 return tvb_captured_length(tvb
);
233 void proto_register_e1ap(void) {
237 static hf_register_info hf
[] = {
238 { &hf_e1ap_transportLayerAddressIPv4
,
239 { "IPv4 transportLayerAddress", "e1ap.transportLayerAddressIPv4",
240 FT_IPv4
, BASE_NONE
, NULL
, 0,
242 { &hf_e1ap_transportLayerAddressIPv6
,
243 { "IPv6 transportLayerAddress", "e1ap.transportLayerAddressIPv6",
244 FT_IPv6
, BASE_NONE
, NULL
, 0,
246 { &hf_e1ap_InterfacesToTrace_NG_C
,
247 { "NG-C", "e1ap.InterfacesToTrace.NG_C",
248 FT_BOOLEAN
, 8, TFS(&tfs_should_be_traced_should_not_be_traced
), 0x80,
250 { &hf_e1ap_InterfacesToTrace_Xn_C
,
251 { "Xn-C", "e1ap.InterfacesToTrace.Xn_C",
252 FT_BOOLEAN
, 8, TFS(&tfs_should_be_traced_should_not_be_traced
), 0x40,
254 { &hf_e1ap_InterfacesToTrace_Uu
,
255 { "Uu", "e1ap.InterfacesToTrace.Uu",
256 FT_BOOLEAN
, 8, TFS(&tfs_should_be_traced_should_not_be_traced
), 0x20,
258 { &hf_e1ap_InterfacesToTrace_F1_C
,
259 { "F1-C", "e1ap.InterfacesToTrace.F1_C",
260 FT_BOOLEAN
, 8, TFS(&tfs_should_be_traced_should_not_be_traced
), 0x10,
262 { &hf_e1ap_InterfacesToTrace_E1
,
263 { "E1", "e1ap.InterfacesToTrace.E1",
264 FT_BOOLEAN
, 8, TFS(&tfs_should_be_traced_should_not_be_traced
), 0x08,
266 { &hf_e1ap_InterfacesToTrace_Reserved
,
267 { "Reserved", "e1ap.InterfacesToTrace.Reserved",
268 FT_UINT8
, BASE_HEX
, NULL
, 0x07,
270 { &hf_e1ap_MeasurementsToActivate_Reserved1
,
271 { "Reserved", "e1ap.MeasurementsToActivate.Reserved",
272 FT_UINT8
, BASE_HEX
, NULL
, 0xe0,
274 { &hf_e1ap_MeasurementsToActivate_M4
,
275 { "M4", "e1ap.MeasurementsToActivate.M4",
276 FT_BOOLEAN
, 8, TFS(&tfs_activated_deactivated
), 0x10,
278 { &hf_e1ap_MeasurementsToActivate_Reserved2
,
279 { "Reserved", "e1ap.MeasurementsToActivate.Reserved",
280 FT_UINT8
, BASE_HEX
, NULL
, 0x0c,
282 { &hf_e1ap_MeasurementsToActivate_M6
,
283 { "M6", "e1ap.MeasurementsToActivate.M6",
284 FT_BOOLEAN
, 8, TFS(&tfs_activated_deactivated
), 0x02,
286 { &hf_e1ap_MeasurementsToActivate_M7
,
287 { "M7", "e1ap.MeasurementsToActivate.M7",
288 FT_BOOLEAN
, 8, TFS(&tfs_activated_deactivated
), 0x01,
290 { &hf_e1ap_ReportCharacteristics_TNLAvailableCapacityIndPeriodic
,
291 { "TNLAvailableCapacityIndPeriodic", "e1ap.ReportCharacteristics.TNLAvailableCapacityIndPeriodic",
292 FT_BOOLEAN
, 40, TFS(&tfs_requested_not_requested
), 0x8000000000,
294 { &hf_e1ap_ReportCharacteristics_HWCapacityIndPeriodic
,
295 { "HWCapacityIndPeriodic", "e1ap.ReportCharacteristics.HWCapacityIndPeriodic",
296 FT_BOOLEAN
, 40, TFS(&tfs_requested_not_requested
), 0x4000000000,
298 { &hf_e1ap_ReportCharacteristics_Reserved
,
299 { "Reserved", "e1ap.ReportCharacteristics.Reserved",
300 FT_UINT40
, BASE_HEX
, NULL
, 0x3ffffffff0,
302 { &hf_e1ap_tcp_pdu_len
,
303 { "TCP PDU length", "e1ap.tcp_pdu_len",
304 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
306 #include "packet-e1ap-hfarr.c"
309 /* List of subtrees */
310 static int *ett
[] = {
312 &ett_e1ap_PLMN_Identity
,
313 &ett_e1ap_TransportLayerAddress
,
314 &ett_e1ap_InterfacesToTrace
,
315 &ett_e1ap_MeasurementsToActivate
,
316 &ett_e1ap_ReportCharacteristics
,
317 &ett_e1ap_BurstArrivalTime
,
318 #include "packet-e1ap-ettarr.c"
321 /* Register protocol */
322 proto_e1ap
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
323 /* Register fields and subtrees */
324 proto_register_field_array(proto_e1ap
, hf
, array_length(hf
));
325 proto_register_subtree_array(ett
, array_length(ett
));
327 /* Register dissector */
328 e1ap_handle
= register_dissector("e1ap", dissect_e1ap
, proto_e1ap
);
329 e1ap_tcp_handle
= register_dissector("e1ap_tcp", dissect_e1ap_tcp
, proto_e1ap
);
331 /* Register dissector tables */
332 e1ap_ies_dissector_table
= register_dissector_table("e1ap.ies", "E1AP-PROTOCOL-IES", proto_e1ap
, FT_UINT32
, BASE_DEC
);
333 e1ap_extension_dissector_table
= register_dissector_table("e1ap.extension", "E1AP-PROTOCOL-EXTENSION", proto_e1ap
, FT_UINT32
, BASE_DEC
);
334 e1ap_proc_imsg_dissector_table
= register_dissector_table("e1ap.proc.imsg", "E1AP-ELEMENTARY-PROCEDURE InitiatingMessage", proto_e1ap
, FT_UINT32
, BASE_DEC
);
335 e1ap_proc_sout_dissector_table
= register_dissector_table("e1ap.proc.sout", "E1AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", proto_e1ap
, FT_UINT32
, BASE_DEC
);
336 e1ap_proc_uout_dissector_table
= register_dissector_table("e1ap.proc.uout", "E1AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", proto_e1ap
, FT_UINT32
, BASE_DEC
);
340 proto_reg_handoff_e1ap(void)
342 dissector_add_uint_with_preference("sctp.port", SCTP_PORT_E1AP
, e1ap_handle
);
343 dissector_add_uint_with_preference("tcp.port", 0, e1ap_tcp_handle
);
344 dissector_add_uint("sctp.ppi", E1AP_PROTOCOL_ID
, e1ap_handle
);
345 #include "packet-e1ap-dis-tab.c"
354 * indent-tabs-mode: nil
357 * ex: set shiftwidth=2 tabstop=8 expandtab:
358 * :indentSize=2:tabSize=8:noTabs=true: