2021-05-25 12:29:47 +00:00
|
|
|
/* packet-e2ap.c
|
|
|
|
* Routines for E2APApplication Protocol (e2ap) packet dissection
|
|
|
|
* Copyright 2021, Martin Mathieson
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*
|
|
|
|
* References: ORAN-WG3.E2AP-v01.00, ORAN-WG3.E2SM-KPM-v01.00
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/strutil.h>
|
|
|
|
#include <epan/asn1.h>
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
#include <epan/sctpppids.h>
|
|
|
|
#include <epan/expert.h>
|
|
|
|
#include <epan/proto_data.h>
|
|
|
|
#include <epan/conversation.h>
|
|
|
|
#include <epan/exceptions.h>
|
|
|
|
#include <epan/show_exception.h>
|
|
|
|
|
|
|
|
#include "packet-e2ap.h"
|
|
|
|
#include "packet-per.h"
|
|
|
|
#define PNAME "E2 Application Protocol"
|
|
|
|
#define PSNAME "E2AP"
|
|
|
|
#define PFNAME "e2ap"
|
|
|
|
|
|
|
|
/* Dissector will use SCTP PPID 18 or SCTP port. IANA assigned port = 37464 */
|
|
|
|
#define SCTP_PORT_E2AP 37464
|
|
|
|
|
|
|
|
void proto_register_e2ap(void);
|
|
|
|
void proto_reg_handoff_e2ap(void);
|
|
|
|
|
|
|
|
static dissector_handle_t e2ap_handle;
|
|
|
|
|
|
|
|
#include "packet-e2ap-val.h"
|
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_e2ap = -1;
|
|
|
|
#include "packet-e2ap-hf.c"
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
static gint ett_e2ap = -1;
|
|
|
|
|
|
|
|
#include "packet-e2ap-ett.c"
|
|
|
|
|
|
|
|
|
|
|
|
enum{
|
|
|
|
INITIATING_MESSAGE,
|
|
|
|
SUCCESSFUL_OUTCOME,
|
|
|
|
UNSUCCESSFUL_OUTCOME
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _e2ap_ctx_t {
|
|
|
|
guint32 message_type;
|
|
|
|
guint32 ProcedureCode;
|
|
|
|
guint32 ProtocolIE_ID;
|
|
|
|
guint32 ProtocolExtensionID;
|
|
|
|
} e2ap_ctx_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct e2ap_private_data {
|
|
|
|
guint32 procedure_code;
|
|
|
|
guint32 protocol_ie_id;
|
|
|
|
guint32 protocol_extension_id;
|
|
|
|
guint32 message_type;
|
|
|
|
guint32 ran_ue_e2ap_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Dissector tables */
|
|
|
|
static dissector_table_t e2ap_ies_dissector_table;
|
|
|
|
//static dissector_table_t e2ap_ies_p1_dissector_table;
|
|
|
|
//static dissector_table_t e2ap_ies_p2_dissector_table;
|
|
|
|
static dissector_table_t e2ap_extension_dissector_table;
|
|
|
|
static dissector_table_t e2ap_proc_imsg_dissector_table;
|
|
|
|
static dissector_table_t e2ap_proc_sout_dissector_table;
|
|
|
|
static dissector_table_t e2ap_proc_uout_dissector_table;
|
|
|
|
static dissector_table_t e2ap_n2_ie_type_dissector_table;
|
|
|
|
|
|
|
|
static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
|
|
|
|
/* Currently not used
|
|
|
|
static int dissect_ProtocolIEFieldPairFirstValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
|
|
|
static int dissect_ProtocolIEFieldPairSecondValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
static int dissect_E2SM_KPM_ActionDefinition_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
|
|
|
|
static int dissect_E2SM_KPM_RANfunction_Description_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
|
|
|
|
static int dissect_E2SM_KPM_EventTriggerDefinition_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
|
|
|
|
static int dissect_E2SM_KPM_IndicationHeader_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
|
|
|
|
static int dissect_RANcallProcess_ID_string_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
|
|
|
|
static int dissect_E2SM_KPM_IndicationMessage_Format1_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_);
|
|
|
|
|
|
|
|
|
|
|
|
static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
|
|
|
|
static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
|
|
|
|
static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
|
|
|
|
|
|
|
|
static struct e2ap_private_data*
|
|
|
|
e2ap_get_private_data(packet_info *pinfo)
|
|
|
|
{
|
|
|
|
struct e2ap_private_data *e2ap_data = (struct e2ap_private_data*)p_get_proto_data(pinfo->pool, pinfo, proto_e2ap, 0);
|
|
|
|
if (!e2ap_data) {
|
|
|
|
e2ap_data = wmem_new0(pinfo->pool, struct e2ap_private_data);
|
|
|
|
p_add_proto_data(pinfo->pool, pinfo, proto_e2ap, 0, e2ap_data);
|
|
|
|
}
|
|
|
|
return e2ap_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "packet-e2ap-fn.c"
|
|
|
|
|
|
|
|
static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
|
|
|
{
|
|
|
|
e2ap_ctx_t e2ap_ctx;
|
|
|
|
struct e2ap_private_data *e2ap_data = e2ap_get_private_data(pinfo);
|
|
|
|
|
|
|
|
e2ap_ctx.message_type = e2ap_data->message_type;
|
|
|
|
e2ap_ctx.ProcedureCode = e2ap_data->procedure_code;
|
|
|
|
e2ap_ctx.ProtocolIE_ID = e2ap_data->protocol_ie_id;
|
|
|
|
e2ap_ctx.ProtocolExtensionID = e2ap_data->protocol_extension_id;
|
|
|
|
|
|
|
|
return (dissector_try_uint_new(e2ap_ies_dissector_table, e2ap_data->protocol_ie_id, tvb, pinfo, tree, FALSE, &e2ap_ctx)) ? tvb_captured_length(tvb) : 0;
|
|
|
|
}
|
|
|
|
/* Currently not used
|
|
|
|
static int dissect_ProtocolIEFieldPairFirstValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
struct e2ap_private_data *e2ap_data = e2ap_get_private_data(pinfo);
|
|
|
|
|
|
|
|
return (dissector_try_uint(e2ap_ies_p1_dissector_table, e2ap_data->protocol_ie_id, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dissect_ProtocolIEFieldPairSecondValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
struct e2ap_private_data *e2ap_data = e2ap_get_private_data(pinfo);
|
|
|
|
|
|
|
|
return (dissector_try_uint(e2ap_ies_p2_dissector_table, e2ap_data->protocol_ie_id, tvb, pinfo, tree)) ? tvb_captured_length(tvb) : 0;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|
|
|
{
|
|
|
|
struct e2ap_private_data *e2ap_data = e2ap_get_private_data(pinfo);
|
|
|
|
|
|
|
|
return (dissector_try_uint_new(e2ap_proc_imsg_dissector_table, e2ap_data->procedure_code, tvb, pinfo, tree, TRUE, data)) ? tvb_captured_length(tvb) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|
|
|
{
|
|
|
|
struct e2ap_private_data *e2ap_data = e2ap_get_private_data(pinfo);
|
|
|
|
|
|
|
|
return (dissector_try_uint_new(e2ap_proc_sout_dissector_table, e2ap_data->procedure_code, tvb, pinfo, tree, TRUE, data)) ? tvb_captured_length(tvb) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|
|
|
{
|
|
|
|
struct e2ap_private_data *e2ap_data = e2ap_get_private_data(pinfo);
|
|
|
|
|
|
|
|
return (dissector_try_uint_new(e2ap_proc_uout_dissector_table, e2ap_data->procedure_code, tvb, pinfo, tree, TRUE, data)) ? tvb_captured_length(tvb) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
dissect_e2ap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
|
|
|
{
|
|
|
|
proto_item *e2ap_item = NULL;
|
|
|
|
proto_tree *e2ap_tree = NULL;
|
|
|
|
|
|
|
|
/* make entry in the Protocol column on summary display */
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "E2AP");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
|
|
|
|
/* create the e2ap protocol tree */
|
|
|
|
e2ap_item = proto_tree_add_item(tree, proto_e2ap, tvb, 0, -1, ENC_NA);
|
|
|
|
e2ap_tree = proto_item_add_subtree(e2ap_item, ett_e2ap);
|
|
|
|
|
|
|
|
|
|
|
|
return dissect_E2AP_PDU_PDU(tvb, pinfo, e2ap_tree, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--- proto_reg_handoff_e2ap ---------------------------------------*/
|
|
|
|
void
|
|
|
|
proto_reg_handoff_e2ap(void)
|
|
|
|
{
|
2022-08-07 13:28:32 +00:00
|
|
|
dissector_add_uint_with_preference("sctp.port", SCTP_PORT_E2AP, e2ap_handle);
|
2021-05-25 12:29:47 +00:00
|
|
|
#if 0
|
2022-08-07 13:28:32 +00:00
|
|
|
/* TODO: should one or more of these be registered? */
|
|
|
|
dissector_add_uint("sctp.ppi", E2_CP_PROTOCOL_ID, e2ap_handle);
|
|
|
|
dissector_add_uint("sctp.ppi", E2_UP_PROTOCOL_ID, e2ap_handle);
|
|
|
|
dissector_add_uint("sctp.ppi", E2_DU_PROTOCOL_ID, e2ap_handle);
|
2021-05-25 12:29:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "packet-e2ap-dis-tab.c"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--- proto_register_e2ap -------------------------------------------*/
|
|
|
|
void proto_register_e2ap(void) {
|
|
|
|
|
|
|
|
/* List of fields */
|
|
|
|
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
#include "packet-e2ap-hfarr.c"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* List of subtrees */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_e2ap,
|
|
|
|
#include "packet-e2ap-ettarr.c"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-07 13:28:32 +00:00
|
|
|
/* module_t *e2ap_module; */
|
2021-05-25 12:29:47 +00:00
|
|
|
|
|
|
|
/* Register protocol */
|
|
|
|
proto_e2ap = proto_register_protocol(PNAME, PSNAME, PFNAME);
|
|
|
|
/* Register fields and subtrees */
|
|
|
|
proto_register_field_array(proto_e2ap, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
|
|
|
|
/* Register dissector */
|
|
|
|
e2ap_handle = register_dissector("e2ap", dissect_e2ap, proto_e2ap);
|
|
|
|
|
|
|
|
/* Register dissector tables */
|
|
|
|
e2ap_ies_dissector_table = register_dissector_table("e2ap.ies", "E2AP-PROTOCOL-IES", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
// e2ap_ies_p1_dissector_table = register_dissector_table("e2ap.ies.pair.first", "E2AP-PROTOCOL-IES-PAIR FirstValue", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
// e2ap_ies_p2_dissector_table = register_dissector_table("e2ap.ies.pair.second", "E2AP-PROTOCOL-IES-PAIR SecondValue", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
e2ap_extension_dissector_table = register_dissector_table("e2ap.extension", "E2AP-PROTOCOL-EXTENSION", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
e2ap_proc_imsg_dissector_table = register_dissector_table("e2ap.proc.imsg", "E2AP-ELEMENTARY-PROCEDURE InitiatingMessage", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
e2ap_proc_sout_dissector_table = register_dissector_table("e2ap.proc.sout", "E2AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
e2ap_proc_uout_dissector_table = register_dissector_table("e2ap.proc.uout", "E2AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", proto_e2ap, FT_UINT32, BASE_DEC);
|
|
|
|
e2ap_n2_ie_type_dissector_table = register_dissector_table("e2ap.n2_ie_type", "E2AP N2 IE Type", proto_e2ap, FT_STRING, FALSE);
|
|
|
|
|
|
|
|
/* Register configuration options for ports */
|
2022-08-07 13:28:32 +00:00
|
|
|
/* e2ap_module = prefs_register_protocol(proto_e2ap, NULL); */
|
2021-05-25 12:29:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|