Commit 968c5aba authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/xn-encdec-setup-messages' into integration_2026_w11 (!3923)

XNAP: Add encode/decode and unit tests for Xn Setup Request/Response/Failure

This MR adds complete support for the following in accordance with
3GPP TS 38.423 v16.2.0
- Add Xn Setup Request, Response, and Failure message type definitions
- Implement ASN.1 encode/decode for all Xn Setup messages
- Add equality checks and memory management helpers
- Create XNAP unit test infrastructure

Co-author: @venkatareddy

Acknowledgement
  This work was carried out as part of research and development at Indian
  Institute of Science (IISc), Bengaluru.
parents 8556a148 e34cb240
...@@ -517,6 +517,17 @@ add_library(x2ap ...@@ -517,6 +517,17 @@ add_library(x2ap
target_link_libraries(x2ap PUBLIC asn1_x2ap) target_link_libraries(x2ap PUBLIC asn1_x2ap)
target_link_libraries(x2ap PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) target_link_libraries(x2ap PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
#XNAP
##############
set(XNAP_DIR ${OPENAIR2_DIR}/XNAP)
add_library(xnap
${XNAP_DIR}/xnap_common.c
)
target_include_directories(xnap PUBLIC XNAP_DIR)
target_link_libraries(xnap PUBLIC asn1_xnap)
target_link_libraries(xnap PRIVATE nr_rrc xnap_lib)
target_include_directories(xnap PRIVATE ${XNAP_DIR}/lib)
# F1AP # F1AP
############## ##############
set(F1AP_DIR ${OPENAIR2_DIR}/F1AP) set(F1AP_DIR ${OPENAIR2_DIR}/F1AP)
......
...@@ -162,6 +162,7 @@ static const char *const flag_name[] = {FOREACH_FLAG(FLAG_TEXT) ""}; ...@@ -162,6 +162,7 @@ static const char *const flag_name[] = {FOREACH_FLAG(FLAG_TEXT) ""};
COMP_DEF(USIM, log) \ COMP_DEF(USIM, log) \
COMP_DEF(F1U, ) \ COMP_DEF(F1U, ) \
COMP_DEF(X2AP, ) \ COMP_DEF(X2AP, ) \
COMP_DEF(XNAP, ) \
COMP_DEF(M2AP, ) \ COMP_DEF(M2AP, ) \
COMP_DEF(M3AP, ) \ COMP_DEF(M3AP, ) \
COMP_DEF(NGAP, ) \ COMP_DEF(NGAP, ) \
......
...@@ -628,6 +628,27 @@ ID = LEGACY_X2AP_TRACE ...@@ -628,6 +628,27 @@ ID = LEGACY_X2AP_TRACE
GROUP = ALL:LEGACY_X2AP:LEGACY_GROUP_TRACE:LEGACY GROUP = ALL:LEGACY_X2AP:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log FORMAT = string,log
ID = LEGACY_XNAP_INFO
DESC = XNAP legacy logs - info level
GROUP = ALL:LEGACY_XNAP:LEGACY_GROUP_INFO:LEGACY
FORMAT = string,log
ID = LEGACY_XNAP_ERROR
DESC = XNAP legacy logs - error level
GROUP = ALL:LEGACY_XNAP:LEGACY_GROUP_ERROR:LEGACY
FORMAT = string,log
ID = LEGACY_XNAP_WARNING
DESC = XNAP legacy logs - warning level
GROUP = ALL:LEGACY_XNAP:LEGACY_GROUP_WARNING:LEGACY
FORMAT = string,log
ID = LEGACY_XNAP_DEBUG
DESC = XNAP legacy logs - debug level
GROUP = ALL:LEGACY_XNAP:LEGACY_GROUP_DEBUG:LEGACY
FORMAT = string,log
ID = LEGACY_XNAP_TRACE
DESC = XNAP legacy logs - trace level
GROUP = ALL:LEGACY_XNAP:LEGACY_GROUP_TRACE:LEGACY
FORMAT = string,log
ID = LEGACY_M2AP_INFO ID = LEGACY_M2AP_INFO
DESC = M2AP legacy logs - info level DESC = M2AP legacy logs - info level
GROUP = ALL:LEGACY_M2AP:LEGACY_GROUP_INFO:LEGACY GROUP = ALL:LEGACY_M2AP:LEGACY_GROUP_INFO:LEGACY
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef XNAP_MESSAGES_TYPES_H_
#define XNAP_MESSAGES_TYPES_H_
#include "common/5g_platform_types.h"
typedef struct {
// PLMN Identity
plmn_id_t plmn;
// Number of supported S-NSSAIs
uint16_t num_nssai;
// List of supported S-NSSAIs
nssai_t *nssai;
} xnap_plmn_support_t;
typedef struct {
// Tracking Area Code
uint32_t tac;
// Number of supported PLMNs
uint8_t num_plmn;
// List of supported PLMNs
xnap_plmn_support_t *plmn_support;
} xnap_tai_support_t;
typedef struct {
// PLMN Identity
plmn_id_t plmn;
// AMF Region Identifier
uint8_t amf_region_id;
} xnap_amf_region_info_t;
/* 3GPP TS 38.423 9.1.3.1 – Xn Setup Request */
typedef struct {
// Global NG-RAN Node ID (gNB_id+plmn) (M)
uint32_t gNB_id;
plmn_id_t plmn;
// TAI Support List (M)
uint16_t num_tai;
xnap_tai_support_t *tai_support;
// AMF Region Information (M)
uint8_t num_amf_regions;
xnap_amf_region_info_t *amf_region_info;
} xnap_setup_req_t;
/* 3GPP TS 38.423 9.1.3.2 – Xn Setup Response */
typedef struct {
// Global NG-RAN Node ID (gNB_id+plmn) (M)
uint32_t gNB_id;
plmn_id_t plmn;
// TAI Support List (M)
uint16_t num_tai;
xnap_tai_support_t *tai_support;
} xnap_setup_resp_t;
typedef enum xnap_cause_radio_network_e {
XNAP_CAUSE_RADIO_NETWORK_LAYER_CELL_NOT_AVAILABLE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_HANDOVER_DESIRABLE_FOR_RADIO_REASONS,
XNAP_CAUSE_RADIO_NETWORK_LAYER_HANDOVER_TARGET_NOT_ALLOWED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_INVALID_AMF_SET_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_NO_RADIO_RESOURCES_AVAILABLE_IN_TARGET_CELL,
XNAP_CAUSE_RADIO_NETWORK_LAYER_PARTIAL_HANDOVER,
XNAP_CAUSE_RADIO_NETWORK_LAYER_REDUCE_LOAD_IN_SERVING_CELL,
XNAP_CAUSE_RADIO_NETWORK_LAYER_RESOURCE_OPTIMISATION_HANDOVER,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TIME_CRITICAL_HANDOVER,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TXN_RELOCOVERALL_EXPIRY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TXN_RELOCPREP_EXPIRY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UNKNOWN_GUAMI_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UNKNOWN_LOCAL_NG_RAN_NODE_UE_XNAP_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_INCONSISTENT_REMOTE_NG_RAN_NODE_UE_XNAP_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_ENCRYPTION_AND_OR_INTEGRITY_PROTECTION_ALGORITHMS_NOT_SUPPORTED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_PROTECTION_ALGORITHMS_NOT_SUPPORTED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_MULTIPLE_PDU_SESSION_ID_INSTANCES,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UNKNOWN_PDU_SESSION_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UNKNOWN_QOS_FLOW_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_MULTIPLE_QOS_FLOW_ID_INSTANCES,
XNAP_CAUSE_RADIO_NETWORK_LAYER_SWITCH_OFF_ONGOING,
XNAP_CAUSE_RADIO_NETWORK_LAYER_NOT_SUPPORTED_5QI_VALUE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TXN_DCOVERALL_EXPIRY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TXN_DCPREP_EXPIRY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_ACTION_DESIRABLE_FOR_RADIO_REASONS,
XNAP_CAUSE_RADIO_NETWORK_LAYER_REDUCE_LOAD,
XNAP_CAUSE_RADIO_NETWORK_LAYER_RESOURCE_OPTIMISATION,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TIME_CRITICAL_ACTION,
XNAP_CAUSE_RADIO_NETWORK_LAYER_TARGET_NOT_ALLOWED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_NO_RADIO_RESOURCES_AVAILABLE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_INVALID_QOS_COMBINATION,
XNAP_CAUSE_RADIO_NETWORK_LAYER_ENCRYPTION_ALGORITHMS_NOT_SUPPORTED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_PROCEDURE_CANCELLED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_RRM_PURPOSE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_IMPROVE_USER_BIT_RATE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_USER_INACTIVITY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_RADIO_CONNECTION_WITH_UE_LOST,
XNAP_CAUSE_RADIO_NETWORK_LAYER_FAILURE_IN_THE_RADIO_INTERFACE_PROCEDURE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_BEARER_OPTION_NOT_SUPPORTED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UP_INTEGRITY_PROTECTION_NOT_POSSIBLE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UP_CONFIDENTIALITY_PROTECTION_NOT_POSSIBLE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_RESOURCES_NOT_AVAILABLE_FOR_THE_SLICE_S,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UE_MAX_IP_DATA_RATE_REASON,
XNAP_CAUSE_RADIO_NETWORK_LAYER_CP_INTEGRITY_PROTECTION_FAILURE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UP_INTEGRITY_PROTECTION_FAILURE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_SLICE_NOT_SUPPORTED_BY_NG_RAN,
XNAP_CAUSE_RADIO_NETWORK_LAYER_MN_MOBILITY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_SN_MOBILITY,
XNAP_CAUSE_RADIO_NETWORK_LAYER_COUNT_REACHES_MAX_VALUE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UNKNOWN_OLD_NG_RAN_NODE_UE_XNAP_ID,
XNAP_CAUSE_RADIO_NETWORK_LAYER_PDCP_OVERLOAD,
XNAP_CAUSE_RADIO_NETWORK_LAYER_DRB_ID_NOT_AVAILABLE,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UNSPECIFIED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_UE_CONTEXT_ID_NOT_KNOWN,
XNAP_CAUSE_RADIO_NETWORK_LAYER_NON_RELOCATION_OF_CONTEXT,
XNAP_CAUSE_RADIO_NETWORK_LAYER_CHO_CPC_RESOURCES_TOBECHANGED,
XNAP_CAUSE_RADIO_NETWORK_LAYER_RSN_NOT_AVAILABLE_FOR_THE_UP,
XNAP_CAUSE_RADIO_NETWORK_LAYER_NPN_ACCESS_DENIED
} xnap_cause_radio_network_t;
typedef enum xnap_cause_transport_layer_e {
XNAP_CAUSE_TRANSPORT_LAYER_TRANSPORT_RESOURCE_UNAVAILABLE,
XNAP_CAUSE_TRANSPORT_LAYER_UNSPECIFIED
} xnap_cause_transport_layer_t;
typedef enum xnap_cause_protocol_e {
XNAP_CAUSE_PROTOCOL_TRANSFER_SYNTAX_ERROR,
XNAP_CAUSE_PROTOCOL_ABSTRACT_SYNTAX_ERROR_REJECT,
XNAP_CAUSE_PROTOCOL_ABSTRACT_SYNTAX_ERROR_IGNORE_AND_NOTIFY,
XNAP_CAUSE_PROTOCOL_MESSAGE_NOT_COMPATIBLE_WITH_RECEIVER_STATE,
XNAP_CAUSE_PROTOCOL_SEMANTIC_ERROR,
XNAP_CAUSE_PROTOCOL_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED,
XNAP_CAUSE_PROTOCOL_UNSPECIFIED
} xnap_cause_protocol_t;
typedef enum xnap_cause_misc_e {
XNAP_CAUSE_MISC_CONTROL_PROCESSING_OVERLOAD,
XNAP_CAUSE_MISC_HARDWARE_FAILURE,
XNAP_CAUSE_MISC_O_AND_M_INTERVENTION,
XNAP_CAUSE_MISC_NOT_ENOUGH_USER_PLANE_PROCESSING_RESOURCES,
XNAP_CAUSE_MISC_UNSPECIFIED
} xnap_cause_misc_t;
typedef enum xnap_cause_group_e {
XNAP_CAUSE_NOTHING,
XNAP_CAUSE_RADIO_NETWORK,
XNAP_CAUSE_TRANSPORT,
XNAP_CAUSE_PROTOCOL,
XNAP_CAUSE_MISC,
} xnap_cause_group_t;
typedef struct xnap_cause_s {
/* Cause group (e.g. radioNetwork, transport, protocol, misc) */
xnap_cause_group_t type;
/* Specific cause value within the selected cause group */
uint8_t value;
} xnap_cause_t;
/* 3GPP TS 38.423 9.1.3.3 – Xn Setup Failure */
typedef struct {
// Cause (M)
xnap_cause_t cause;
} xnap_setup_failure_t;
#endif /* XNAP_MESSAGES_TYPES_H_ */
add_subdirectory(lib)
add_subdirectory(MESSAGES) add_subdirectory(MESSAGES)
add_library(xnap xnap_common.c)
target_link_libraries(xnap if(ENABLE_TESTS)
PUBLIC asn1_xnap add_subdirectory(tests)
PRIVATE nr_rrc) endif()
target_include_directories(xnap PUBLIC ${CMAKE_CURRENT_DIR})
set( XNAP_GRAMMAR ASN1/xnap_R16.2.0.asn) set(XNAP_GRAMMAR ASN1/xnap_R16.2.0.asn)
set(xnap_source set(xnap_source
ANY.c ANY.c
...@@ -9,6 +9,7 @@ set(xnap_source ...@@ -9,6 +9,7 @@ set(xnap_source
asn_application.c asn_application.c
asn_bit_data.c asn_bit_data.c
asn_codecs_prim.c asn_codecs_prim.c
asn_codecs_prim_xer.c
asn_internal.c asn_internal.c
asn_random_fill.c asn_random_fill.c
asn_SEQUENCE_OF.c asn_SEQUENCE_OF.c
...@@ -16,20 +17,73 @@ set(xnap_source ...@@ -16,20 +17,73 @@ set(xnap_source
ber_tlv_length.c ber_tlv_length.c
ber_tlv_tag.c ber_tlv_tag.c
BIT_STRING.c BIT_STRING.c
BIT_STRING_print.c
BIT_STRING_rfill.c
BIT_STRING_uper.c
BIT_STRING_xer.c
constraints.c constraints.c
constr_CHOICE.c constr_CHOICE.c
constr_CHOICE_aper.c
constr_CHOICE_rfill.c
constr_CHOICE_print.c
constr_CHOICE_uper.c
constr_CHOICE_xer.c
constr_SEQUENCE.c constr_SEQUENCE.c
constr_SEQUENCE_aper.c
constr_SEQUENCE_OF.c constr_SEQUENCE_OF.c
constr_SEQUENCE_OF_aper.c
constr_SEQUENCE_OF_uper.c
constr_SEQUENCE_OF_xer.c
constr_SEQUENCE_print.c
constr_SEQUENCE_rfill.c
constr_SEQUENCE_uper.c
constr_SEQUENCE_xer.c
constr_SET_OF.c constr_SET_OF.c
constr_SET_OF_aper.c
constr_SET_OF_print.c
constr_SET_OF_rfill.c
constr_SET_OF_uper.c
constr_SET_OF_xer.c
constr_TYPE.c constr_TYPE.c
INTEGER.c INTEGER.c
INTEGER_aper.c
INTEGER_print.c
INTEGER_rfill.c
INTEGER_uper.c
INTEGER_xer.c
Makefile.am.libasncodec Makefile.am.libasncodec
NativeEnumerated.c NativeEnumerated.c
NativeEnumerated_aper.c
NativeEnumerated_uper.c
NativeEnumerated_xer.c
NativeInteger.c NativeInteger.c
NativeInteger_aper.c
NativeInteger_print.c
NativeInteger_rfill.c
NativeInteger_uper.c
NativeInteger_xer.c
NULL.c NULL.c
NULL_aper.c
NULL_print.c
NULL_rfill.c
NULL_uper.c
NULL_xer.c
OBJECT_IDENTIFIER.c OBJECT_IDENTIFIER.c
OBJECT_IDENTIFIER_print.c
OBJECT_IDENTIFIER_rfill.c
OBJECT_IDENTIFIER_xer.c
OCTET_STRING.c OCTET_STRING.c
OCTET_STRING_aper.c
OCTET_STRING_print.c
OCTET_STRING_rfill.c
OCTET_STRING_uper.c
OCTET_STRING_xer.c
OPEN_TYPE.c OPEN_TYPE.c
OPEN_TYPE_aper.c
OPEN_TYPE_uper.c
OPEN_TYPE_xer.c
per_opentype.c
per_encoder.c
VisibleString.c VisibleString.c
xer_decoder.c xer_decoder.c
xer_encoder.c xer_encoder.c
...@@ -819,14 +873,22 @@ set(xnap_source ...@@ -819,14 +873,22 @@ set(xnap_source
XNAP_XnUAddressIndication.c XNAP_XnUAddressIndication.c
XNAP_XnUAddressInfoperPDUSession-Item.c XNAP_XnUAddressInfoperPDUSession-Item.c
XNAP_XnUAddressInfoperPDUSession-List.c XNAP_XnUAddressInfoperPDUSession-List.c
uper_encoder.c
uper_opentype.c
uper_support.c
) )
set(xnap_headers set(xnap_headers
ANY.h ANY.h
aper_decoder.h
aper_encoder.h
aper_opentype.h
aper_support.h
asn_application.h asn_application.h
asn_bit_data.h asn_bit_data.h
asn_codecs.h asn_codecs.h
asn_codecs_prim.h asn_codecs_prim.h
asn_codecs_prim_xer.h
asn_internal.h asn_internal.h
asn_ioc.h asn_ioc.h
asn_random_fill.h asn_random_fill.h
...@@ -836,23 +898,72 @@ set(xnap_headers ...@@ -836,23 +898,72 @@ set(xnap_headers
ber_tlv_length.h ber_tlv_length.h
ber_tlv_tag.h ber_tlv_tag.h
BIT_STRING.h BIT_STRING.h
BIT_STRING_print.h
BIT_STRING_rfill.h
BIT_STRING_uper.h
BIT_STRING_xer.h
constraints.h constraints.h
constr_CHOICE.h constr_CHOICE.h
constr_CHOICE_aper.h
constr_CHOICE_print.h
constr_CHOICE_rfill.h
constr_CHOICE_uper.h
constr_CHOICE_xer.h
constr_SEQUENCE.h constr_SEQUENCE.h
constr_SEQUENCE_aper.h
constr_SEQUENCE_OF.h constr_SEQUENCE_OF.h
constr_SEQUENCE_OF_aper.h
constr_SEQUENCE_OF_uper.h
constr_SEQUENCE_OF_xer.h
constr_SEQUENCE_print.h
constr_SEQUENCE_rfill.h
constr_SEQUENCE_uper.h
constr_SEQUENCE_xer.h
constr_SET_OF.h constr_SET_OF.h
constr_SET_OF_aper.h
constr_SET_OF_print.h
constr_SET_OF_rfill.h
constr_SET_OF_uper.h
constr_SET_OF_xer.h
constr_TYPE.h constr_TYPE.h
INTEGER.h INTEGER.h
INTEGER_aper.h
INTEGER_print.h
INTEGER_rfill.h
INTEGER_uper.h
INTEGER_xer.h
NativeEnumerated.h NativeEnumerated.h
NativeEnumerated_aper.h
NativeEnumerated_uper.h
NativeEnumerated_xer.h
NativeInteger.h NativeInteger.h
NativeInteger_aper.h
NativeInteger_print.h
NativeInteger_rfill.h
NativeInteger_xer.h
NativeInteger_uper.h
NULL.h NULL.h
NULL_aper.h
NULL_print.h
NULL_rfill.h
NULL_uper.h
NULL_xer.h
OBJECT_IDENTIFIER.h OBJECT_IDENTIFIER.h
OBJECT_IDENTIFIER_print.h
OBJECT_IDENTIFIER_rfill.h
OBJECT_IDENTIFIER_xer.h
OCTET_STRING.h OCTET_STRING.h
OCTET_STRING_aper.h
OCTET_STRING_print.h
OCTET_STRING_rfill.h
OCTET_STRING_uper.h
OCTET_STRING_xer.h
OPEN_TYPE.h OPEN_TYPE.h
aper_decoder.h OPEN_TYPE_aper.h
aper_encoder.h OPEN_TYPE_uper.h
aper_opentype.h OPEN_TYPE_xer.h
aper_support.h per_encoder.h
per_opentype.h
VisibleString.h VisibleString.h
xer_decoder.h xer_decoder.h
xer_encoder.h xer_encoder.h
...@@ -1643,5 +1754,8 @@ set(xnap_headers ...@@ -1643,5 +1754,8 @@ set(xnap_headers
XNAP_XnUAddressIndication.h XNAP_XnUAddressIndication.h
XNAP_XnUAddressInfoperPDUSession-Item.h XNAP_XnUAddressInfoperPDUSession-Item.h
XNAP_XnUAddressInfoperPDUSession-List.h XNAP_XnUAddressInfoperPDUSession-List.h
uper_encoder.h
uper_opentype.h
uper_support.h
) )
add_library(xnap_lib OBJECT
xnap_lib_common.c
xnap_gNB_interface_management.c
)
target_link_libraries(xnap_lib PRIVATE asn1_xnap ds)
if(ENABLE_TESTS)
target_compile_definitions(xnap_lib PRIVATE ENABLE_TESTS)
endif()
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef XNAP_GNB_INTERFACE_MANAGEMENT_H_
#define XNAP_GNB_INTERFACE_MANAGEMENT_H_
#include <stdbool.h>
#include "xnap_messages_types.h"
typedef struct XNAP_XnAP_PDU XNAP_XnAP_PDU_t;
XNAP_XnAP_PDU_t *encode_xn_setup_request(const xnap_setup_req_t *req);
XNAP_XnAP_PDU_t *encode_xn_setup_response(const xnap_setup_resp_t *resp);
XNAP_XnAP_PDU_t *encode_xn_setup_failure(const xnap_setup_failure_t *fail);
bool decode_xn_setup_request(xnap_setup_req_t *req, const XNAP_XnAP_PDU_t *pdu);
bool decode_xn_setup_response(xnap_setup_resp_t *out, const XNAP_XnAP_PDU_t *pdu);
bool decode_xn_setup_failure(xnap_setup_failure_t *out, const XNAP_XnAP_PDU_t *pdu);
bool eq_xnap_setup_request(const xnap_setup_req_t *a, const xnap_setup_req_t *b);
bool eq_xnap_setup_response(const xnap_setup_resp_t *a, const xnap_setup_resp_t *b);
bool eq_xnap_setup_failure(const xnap_setup_failure_t *a, const xnap_setup_failure_t *b);
void free_xnap_setup_request(const xnap_setup_req_t *msg);
void free_xnap_setup_response(const xnap_setup_resp_t *msg);
void free_xnap_setup_failure(xnap_setup_failure_t *msg);
#endif /* XNAP_GNB_INTERFACE_MANAGEMENT_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "xnap_lib_common.h"
#include "common/utils/assertions.h"
#include "common/utils/utils.h"
int xnap_gNB_set_cause(XNAP_Cause_t *cause_p,const xnap_cause_t *in)
{
DevAssert(cause_p != NULL);
switch (in->type) {
case XNAP_CAUSE_RADIO_NETWORK:
cause_p->present = XNAP_Cause_PR_radioNetwork;
cause_p->choice.radioNetwork = in->value;
break;
case XNAP_CAUSE_TRANSPORT:
cause_p->present = XNAP_Cause_PR_transport;
cause_p->choice.transport = in->value;
break;
case XNAP_CAUSE_PROTOCOL:
cause_p->present = XNAP_Cause_PR_protocol;
cause_p->choice.protocol = in->value;
break;
case XNAP_CAUSE_MISC:
cause_p->present = XNAP_Cause_PR_misc;
cause_p->choice.misc = in->value;
break;
case XNAP_CAUSE_NOTHING:
default:
AssertFatal(false, "unknown cause value %d\n", in->type);
break;
}
return 0;
}
xnap_cause_t decode_xnap_cause(const XNAP_Cause_t *in)
{
xnap_cause_t out = {0};
switch (in->present) {
case XNAP_Cause_PR_radioNetwork:
out.type = XNAP_CAUSE_RADIO_NETWORK;
out.value = in->choice.radioNetwork;
break;
case XNAP_Cause_PR_transport:
out.type = XNAP_CAUSE_TRANSPORT;
out.value = in->choice.transport;
break;
case XNAP_Cause_PR_protocol:
out.type = XNAP_CAUSE_PROTOCOL;
out.value = in->choice.protocol;
break;
case XNAP_Cause_PR_misc:
out.type = XNAP_CAUSE_MISC;
out.value = in->choice.misc;
break;
case XNAP_Cause_PR_NOTHING:
default:
PRINT_ERROR("received illegal XNAP cause %d\n", in->present);
break;
}
return out;
}
bool eq_xnap_cause(const xnap_cause_t *a, const xnap_cause_t *b)
{
_EQ_CHECK_INT(a->type, b->type);
_EQ_CHECK_INT(a->value, b->value);
return true;
}
bool eq_xnap_plmn(const plmn_id_t *a, const plmn_id_t *b)
{
_EQ_CHECK_INT(a->mcc, b->mcc);
_EQ_CHECK_INT(a->mnc, b->mnc);
_EQ_CHECK_INT(a->mnc_digit_length, b->mnc_digit_length);
return true;
}
bool eq_xnap_snssai(const nssai_t *a, const nssai_t *b)
{
_EQ_CHECK_INT(a->sst, b->sst);
_EQ_CHECK_UINT32(a->sd, b->sd);
return true;
}
bool eq_xnap_plmn_support(const xnap_plmn_support_t *a, const xnap_plmn_support_t *b)
{
if (!eq_xnap_plmn(&a->plmn, &b->plmn)) return false;
_EQ_CHECK_INT(a->num_nssai, b->num_nssai);
for (int i = 0; i < a->num_nssai; i++) {
if (!eq_xnap_snssai(&a->nssai[i], &b->nssai[i]))
return false;
}
return true;
}
bool eq_xnap_tai_support(const xnap_tai_support_t *a, const xnap_tai_support_t *b)
{
_EQ_CHECK_UINT32(a->tac, b->tac);
_EQ_CHECK_INT(a->num_plmn, b->num_plmn);
for (int i = 0; i < a->num_plmn; i++) {
if (!eq_xnap_plmn_support(&a->plmn_support[i], &b->plmn_support[i]))
return false;
}
return true;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef XNAP_LIB_COMMON_H_
#define XNAP_LIB_COMMON_H_
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "openair3/UTILS/conversions.h"
#include "common/utils/oai_asn1.h"
#include "common/utils/utils.h"
#include "common/utils/eq_check.h"
#include "xnap_messages_types.h"
#include "xnap_lib_includes.h"
/* macro to look up XnAP IE. If mandatory and not found, macro will print
* descriptive debug message to stderr and force exit in calling function */
#define XNAP_LIB_FIND_IE(IE_TYPE, ie, IE_LIST, IE_ID, mandatory) \
do { \
ie = NULL; \
for (IE_TYPE **ptr = (IE_LIST)->array; ptr < &(IE_LIST)->array[(IE_LIST)->count]; ptr++) { \
if ((*ptr)->id == IE_ID) { \
ie = *ptr; \
break; \
} \
} \
if ((mandatory) && (ie == NULL)) { \
fprintf(stderr, "%s(): could not find XnAP IE " #IE_ID " of type " #IE_TYPE "\n", __func__); \
return false; \
} \
} while (0)
/* Function Prototypes */
bool eq_xnap_plmn(const plmn_id_t *a, const plmn_id_t *b);
bool eq_xnap_snssai(const nssai_t *a, const nssai_t *b);
bool eq_xnap_tai_support(const xnap_tai_support_t *a, const xnap_tai_support_t *b);
bool eq_xnap_plmn_support(const xnap_plmn_support_t *a, const xnap_plmn_support_t *b);
bool eq_xnap_cause(const xnap_cause_t *a, const xnap_cause_t *b);
int xnap_gNB_set_cause(XNAP_Cause_t *cause_p,const xnap_cause_t *in);
xnap_cause_t decode_xnap_cause(const XNAP_Cause_t *in);
#endif /* XNAP_LIB_COMMON_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
* \brief XnAP ASN.1 message definitions generated from specifications
*/
#ifndef XNAP_LIB_INCLUDES_H
#define XNAP_LIB_INCLUDES_H
#include "XNAP_XnAP-PDU.h"
#include "XNAP_ProtocolIE-Field.h"
#include "XNAP_InitiatingMessage.h"
#include "XNAP_SuccessfulOutcome.h"
#include "XNAP_UnsuccessfulOutcome.h"
#include "XNAP_GlobalgNB-ID.h"
#include "XNAP_GlobalNG-RANNode-ID.h"
#include "XNAP_GlobalAMF-Region-Information.h"
#include "XNAP_TAISupport-Item.h"
#include "XNAP_S-NSSAI.h"
#include "XNAP_BroadcastPLMNinTAISupport-Item.h"
#include "XNAP_Cause.h"
#endif // XNAP_LIB_INCLUDES_H
add_executable(xnap_lib_test xnap_lib_test.c)
add_dependencies(tests xnap_lib_test)
add_test(NAME xnap_lib_test COMMAND xnap_lib_test)
target_link_libraries(xnap_lib_test PRIVATE xnap_lib ds LOG)
target_link_libraries(xnap_lib_test PRIVATE asn1_xnap)
target_include_directories(xnap_lib_test PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
This diff is collapsed.
...@@ -497,6 +497,16 @@ do { \ ...@@ -497,6 +497,16 @@ do { \
(bITsTRING)->bits_unused = 4; \ (bITsTRING)->bits_unused = 4; \
} while(0) } while(0)
#define MACRO_BIT_STRING_TO_GNB_ID(bITsTRING, oUT) \
do { \
uint8_t *_buf = (bITsTRING)->buf; \
(oUT) = \
((uint32_t)_buf[0] << 20) | \
((uint32_t)_buf[1] << 12) | \
((uint32_t)_buf[2] << 4) | \
(((uint32_t)_buf[3] & 0xF0) >> 4); \
} while (0)
/* TS 36.413 v10.9.0 section 9.2.1.38: /* TS 36.413 v10.9.0 section 9.2.1.38:
* E-UTRAN CGI/Cell Identity * E-UTRAN CGI/Cell Identity
* The leftmost bits of the Cell * The leftmost bits of the Cell
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment