Commit 431d72de authored by SreeshmaShiv's avatar SreeshmaShiv

codechanges-squashed- jan18

parent 9f092d00
...@@ -411,9 +411,9 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf ...@@ -411,9 +411,9 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf
// If CU // If CU
if (node_type == ngran_gNB_CU || node_type == ngran_gNB) { if (node_type == ngran_gNB_CU || node_type == ngran_gNB) {
MessageDef *msg = RCconfig_NR_CU_E1(NULL); MessageDef *msg = RCconfig_NR_CU_E1(false);
instance_t inst = 0; instance_t inst = 0;
createE1inst(UPtype, inst, E1AP_REGISTER_REQ(msg).gnb_id, &E1AP_REGISTER_REQ(msg).net_config, NULL); createE1inst(UPtype, inst, &E1AP_REGISTER_REQ(msg).net_config, NULL);
cuup_init_n3(inst); cuup_init_n3(inst);
RC.nrrrc[gnb_id_start]->e1_inst = inst; // stupid instance !!!*/ RC.nrrrc[gnb_id_start]->e1_inst = inst; // stupid instance !!!*/
...@@ -580,53 +580,6 @@ void init_pdcp(void) { ...@@ -580,53 +580,6 @@ void init_pdcp(void) {
} }
} }
#ifdef E2_AGENT
#include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h" // need to get info from MAC
static void initialize_agent(ngran_node_t node_type, e2_agent_args_t oai_args)
{
AssertFatal(oai_args.sm_dir != NULL , "Please, specify the directory where the SMs are located in the config file, i.e., add in config file the next line: e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\");} ");
AssertFatal(oai_args.ip != NULL , "Please, specify the IP address of the nearRT-RIC in the config file, i.e., e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\"");
printf("After RCconfig_NR_E2agent %s %s \n",oai_args.sm_dir, oai_args.ip );
fr_args_t args = { .ip = oai_args.ip }; // init_fr_args(0, NULL);
memcpy(args.libs_dir, oai_args.sm_dir, 128);
sleep(1);
const gNB_RRC_INST* rrc = RC.nrrrc[0];
assert(rrc != NULL && "rrc cannot be NULL");
const int mcc = rrc->configuration.mcc[0];
const int mnc = rrc->configuration.mnc[0];
const int mnc_digit_len = rrc->configuration.mnc_digit_length[0];
// const ngran_node_t node_type = rrc->node_type;
int nb_id = 0;
int cu_du_id = 0;
if (node_type == ngran_gNB) {
nb_id = rrc->node_id;
} else if (node_type == ngran_gNB_DU) {
const gNB_MAC_INST* mac = RC.nrmac[0];
AssertFatal(mac != NULL, "MAC not initialized\n");
cu_du_id = mac->f1_config.gnb_id;
nb_id = mac->f1_config.setup_req->gNB_DU_id;
} else if (node_type == ngran_gNB_CU) {
// agent buggy: the CU has no second ID, it is the CU-UP ID
// however, that is not a problem her for us, so put the same ID twice
nb_id = rrc->node_id;
cu_du_id = rrc->node_id;
} else {
LOG_E(NR_RRC, "not supported ran type detect\n");
}
printf("[E2 NODE]: mcc = %d mnc = %d mnc_digit = %d nb_id = %d \n", mcc, mnc, mnc_digit_len, nb_id);
printf("[E2 NODE]: Args %s %s \n", args.ip, args.libs_dir);
sm_io_ag_ran_t io = init_ran_func_ag();
init_agent_api(mcc, mnc, mnc_digit_len, nb_id, cu_du_id, node_type, io, &args);
}
#endif
configmodule_interface_t *uniqCfg = NULL; configmodule_interface_t *uniqCfg = NULL;
int main( int argc, char **argv ) { int main( int argc, char **argv ) {
int ru_id, CC_id = 0; int ru_id, CC_id = 0;
...@@ -745,18 +698,54 @@ int main( int argc, char **argv ) { ...@@ -745,18 +698,54 @@ int main( int argc, char **argv ) {
config_sync_var=0; config_sync_var=0;
#ifdef E2_AGENT #ifdef E2_AGENT
////////////////////////////////// //////////////////////////////////
////////////////////////////////// //////////////////////////////////
//// Init the E2 Agent //// Init the E2 Agent
sm_io_ag_ran_t io = init_ran_func_ag();
// OAI Wrapper // OAI Wrapper
e2_agent_args_t oai_args = RCconfig_NR_E2agent(); e2_agent_args_t oai_args = RCconfig_NR_E2agent();
AssertFatal(oai_args.sm_dir != NULL , "Please, specify the directory where the SMs are located in the config file, i.e., add in config file the next line: e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\");} ");
AssertFatal(oai_args.ip != NULL , "Please, specify the IP address of the nearRT-RIC in the config file, i.e., e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\"");
if (oai_args.enabled) { printf("After RCconfig_NR_E2agent %s %s \n",oai_args.sm_dir, oai_args.ip );
initialize_agent(node_type, oai_args);
fr_args_t args = { .ip = oai_args.ip }; // init_fr_args(0, NULL);
memcpy(args.libs_dir, oai_args.sm_dir, 128);
sleep(1);
const gNB_RRC_INST* rrc = RC.nrrrc[0];
assert(rrc != NULL && "rrc cannot be NULL");
const int mcc = rrc->configuration.mcc[0];
const int mnc = rrc->configuration.mnc[0];
const int mnc_digit_len = rrc->configuration.mnc_digit_length[0];
// const ngran_node_t node_type = rrc->node_type;
int nb_id = 0;
int cu_du_id = 0;
if (node_type == ngran_gNB) {
nb_id = rrc->configuration.cell_identity;
} else if (node_type == ngran_gNB_DU) {
cu_du_id = rrc->node_id + 1; // Hack to avoid been 0
nb_id = rrc->configuration.cell_identity;
} else if (node_type == ngran_gNB_CU) {
cu_du_id = rrc->node_id + 1;
nb_id = rrc->configuration.cell_identity;
} else {
LOG_E(NR_RRC, "not supported ran type detect\n");
} }
printf("[E2 NODE]: mcc = %d mnc = %d mnc_digit = %d nb_id = %d \n", mcc, mnc, mnc_digit_len, nb_id);
printf("[E2 NODE]: Args %s %s \n", args.ip, args.libs_dir);
init_agent_api(mcc, mnc, mnc_digit_len, nb_id, cu_du_id, node_type, io, &args);
// }
#endif // E2_AGENT #endif // E2_AGENT
......
...@@ -174,6 +174,7 @@ typedef struct ngap_security_capabilities_s { ...@@ -174,6 +174,7 @@ typedef struct ngap_security_capabilities_s {
uint16_t nRintegrity_algorithms; uint16_t nRintegrity_algorithms;
uint16_t eUTRAencryption_algorithms; uint16_t eUTRAencryption_algorithms;
uint16_t eUTRAintegrity_algorithms; uint16_t eUTRAintegrity_algorithms;
uint16_t encryption_algorithms;
} ngap_security_capabilities_t; } ngap_security_capabilities_t;
/* Provides the establishment cause for the RRC connection request as provided /* Provides the establishment cause for the RRC connection request as provided
......
...@@ -33,3 +33,4 @@ MESSAGE_DEF(XNAP_REGISTER_GNB_REQ, MESSAGE_PRIORITY_MED, xnap_register_gnb_req_t ...@@ -33,3 +33,4 @@ MESSAGE_DEF(XNAP_REGISTER_GNB_REQ, MESSAGE_PRIORITY_MED, xnap_register_gnb_req_t
MESSAGE_DEF(XNAP_SETUP_REQ, MESSAGE_PRIORITY_MED, xnap_setup_req_t, xnap_setup_req) MESSAGE_DEF(XNAP_SETUP_REQ, MESSAGE_PRIORITY_MED, xnap_setup_req_t, xnap_setup_req)
MESSAGE_DEF(XNAP_SETUP_RESP, MESSAGE_PRIORITY_MED, xnap_setup_resp_t, xnap_setup_resp) MESSAGE_DEF(XNAP_SETUP_RESP, MESSAGE_PRIORITY_MED, xnap_setup_resp_t, xnap_setup_resp)
MESSAGE_DEF(XNAP_SETUP_FAILURE, MESSAGE_PRIORITY_MED, xnap_setup_failure_t, xnap_setup_failure) MESSAGE_DEF(XNAP_SETUP_FAILURE, MESSAGE_PRIORITY_MED, xnap_setup_failure_t, xnap_setup_failure)
MESSAGE_DEF(XNAP_HANDOVER_REQ, MESSAGE_PRIORITY_MED, xnap_handover_req_t, xnap_handover_req)
...@@ -27,12 +27,14 @@ ...@@ -27,12 +27,14 @@
#ifndef XNAP_MESSAGES_TYPES_H_ #ifndef XNAP_MESSAGES_TYPES_H_
#define XNAP_MESSAGES_TYPES_H_ #define XNAP_MESSAGES_TYPES_H_
// Defines to access message fields. #include "s1ap_messages_types.h"
#include "f1ap_messages_types.h"
#define XNAP_REGISTER_GNB_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_register_gnb_req #define XNAP_REGISTER_GNB_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_register_gnb_req
#define XNAP_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_req #define XNAP_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_req
#define XNAP_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_resp #define XNAP_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_resp
#define XNAP_SETUP_FAILURE(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_failure #define XNAP_SETUP_FAILURE(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_failure
#define XNAP_HANDOVER_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_handover_req
#define XNAP_MAX_NB_GNB_IP_ADDRESS 4 #define XNAP_MAX_NB_GNB_IP_ADDRESS 4
...@@ -146,7 +148,7 @@ typedef struct xnap_setup_resp_s { ...@@ -146,7 +148,7 @@ typedef struct xnap_setup_resp_s {
xnap_served_cell_info_t info; xnap_served_cell_info_t info;
} xnap_setup_resp_t; } xnap_setup_resp_t;
typedef struct xnap_register_gnb_req_s { ypedef struct xnap_register_gnb_req_s {
xnap_setup_req_t setup_req; xnap_setup_req_t setup_req;
xnap_net_config_t net_config; xnap_net_config_t net_config;
char *gNB_name; char *gNB_name;
...@@ -166,4 +168,113 @@ typedef struct xnap_setup_failure_s { ...@@ -166,4 +168,113 @@ typedef struct xnap_setup_failure_s {
uint16_t time_to_wait; uint16_t time_to_wait;
uint16_t criticality_diagnostics; uint16_t criticality_diagnostics;
} xnap_setup_failure_t; } xnap_setup_failure_t;
typedef struct xnap_guami_s {
xnap_plmn_t plmn_id;
uint8_t amf_region_id;
uint8_t amf_set_id;
uint8_t amf_pointer;
} xnap_guami_t;
typedef struct xnap_allocation_retention_priority_s {
uint16_t priority_level;
preemption_capability_t preemption_capability;
preemption_vulnerability_t preemption_vulnerability;
} xnap_allocation_retention_priority_t;
typedef struct xnap_qos_characteristics_s {
union {
struct {
long fiveqi;
long qos_priority_level;
} non_dynamic;
struct {
long fiveqi; // -1 -> optional
long qos_priority_level;
long packet_delay_budget;
struct {
long per_scalar;
long per_exponent;
} packet_error_rate;
} dynamic;
};
fiveQI_type_t qos_type;
} xnap_qos_characteristics_t;
typedef struct xnap_qos_tobe_setup_item_s {
uint8_t qfi;
xnap_qos_characteristics_t qos_params;
xnap_allocation_retention_priority_t allocation_retention_priority;
} xnap_qos_tobe_setup_item_t;
typedef struct xnap_qos_tobe_setup_list_s {
uint8_t num_qos;
xnap_qos_tobe_setup_item_t qos[2]; //QOSFLOW_MAX_VALUE= 64 Put this?
} xnap_qos_tobe_setup_list_t;
typedef struct xnap_pdusession_tobe_setup_item_s {
uint8_t pdusession_id;
xnap_snssai_t snssai;
xnap_net_ip_address_t up_ngu_tnl_ip_upf;
teid_t up_ngu_tnl_teid_upf;
uint32_t pdu_session_type; //enumerated-pdu_session_type_t- ngap_messages_types.h
xnap_qos_tobe_setup_list_t qos_list;
} xnap_pdusession_tobe_setup_item_t;
typedef struct xnap_pdusession_tobe_setup_list_s {
uint8_t num_pdu;
xnap_pdusession_tobe_setup_item_t pdu[NGAP_MAX_PDUSESSION]; //Is the limit ok?
} xnap_pdusession_tobe_setup_list_t;
typedef struct xnap_ngran_cgi_t {
xnap_plmn_t plmn_id;
uint32_t cgi;
} xnap_ngran_cgi_t;
typedef struct xnap_security_capabilities_s {
uint16_t encryption_algorithms;
uint16_t integrity_algorithms;
} xnap_security_capabilities_t;
typedef struct xnap_ambr_s {
uint64_t br_ul;
uint64_t br_dl;
} xnap_ambr_t;
typedef struct xnap_uehistory_info_s {
xnap_ngran_cgi_t last_visited_cgi;
cell_type_t cell_type; //enumerated -s1ap_messages_types.h
uint64_t time_UE_StayedInCell;
} xnap_uehistory_info_t; //38.413- 9.3.1.97
typedef struct xnap_ue_context_info_s {
uint64_t ngc_ue_sig_ref;// 0-2^40-1
xnap_net_ip_address_t tnl_ip_source;
uint32_t tnl_port_source;
xnap_security_capabilities_t security_capabilities;
uint8_t as_security_key_ranstar[32];//bitstring 256, why array?
uint32_t as_security_ncc;
xnap_ambr_t ue_ambr;
uint8_t rrc_buffer[8192 /* arbitrary, big enough */];
xnap_uehistory_info_t uehistory_info;//most recent info added at top(upto 16). how many needed?
int rrc_buffer_size;//rrc msg type needed?
} xnap_ue_context_info_t;
typedef struct xnap_handover_req_s {
uint32_t ng_node_ue_xnap_id;
xnap_Cause_t cause_type;
xnap_ngran_cgi_t target_cgi;
xnap_guami_t guami;
xnap_ue_context_info_t ue_context;
} xnap_handover_req_t;
typedef struct xnap_handover_req_ack_s {
uint32_t ng_node_ue_xnap_id;
xnap_Cause_t cause_type;
xnap_ngran_cgi_t target_cgi;
xnap_guami_t guami;
xnap_ue_context_info_t ue_context;
} xnap_handover_req_ack_t;
#endif /* XNAP_MESSAGES_TYPES_H_ */ #endif /* XNAP_MESSAGES_TYPES_H_ */
...@@ -68,7 +68,7 @@ static void get_NGU_S1U_addr(char **addr, uint16_t *port) ...@@ -68,7 +68,7 @@ static void get_NGU_S1U_addr(char **addr, uint16_t *port)
return; return;
} }
MessageDef *RCconfig_NR_CU_E1(const E1_t *entity) MessageDef *RCconfig_NR_CU_E1(bool separate_CUUP_process)
{ {
MessageDef *msgConfig = itti_alloc_new_message(TASK_GNB_APP, 0, E1AP_REGISTER_REQ); MessageDef *msgConfig = itti_alloc_new_message(TASK_GNB_APP, 0, E1AP_REGISTER_REQ);
if (!msgConfig) if (!msgConfig)
...@@ -82,12 +82,14 @@ MessageDef *RCconfig_NR_CU_E1(const E1_t *entity) ...@@ -82,12 +82,14 @@ MessageDef *RCconfig_NR_CU_E1(const E1_t *entity)
sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, 0); sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, 0);
int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;
AssertFatal(num_gnbs == 1, "Support only one gNB per process\n"); AssertFatal(num_gnbs == 1, "Support only one gNB per process\n");
config_getlist(config_get_if(), &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL);
paramdef_t *gnbParms = GNBParamList.paramarray[0];
e1ap_setup_req_t *e1Setup = &E1AP_REGISTER_REQ(msgConfig).setup_req;
if (num_gnbs > 0) { if (num_gnbs > 0) {
config_getlist(config_get_if(), &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL);
paramdef_t *gnbParms = GNBParamList.paramarray[0];
AssertFatal(gnbParms[GNB_GNB_ID_IDX].uptr != NULL, "gNB id %d is not defined in configuration file\n", 0);
e1ap_setup_req_t *e1Setup = &E1AP_REGISTER_REQ(msgConfig).setup_req;
msgConfig->ittiMsgHeader.destinationInstance = 0; msgConfig->ittiMsgHeader.destinationInstance = 0;
e1Setup->gNB_cu_up_id = *(gnbParms[GNB_GNB_ID_IDX].uptr);
if (*gnbParms[GNB_GNB_NAME_IDX].strptr) if (*gnbParms[GNB_GNB_NAME_IDX].strptr)
e1Setup->gNB_cu_up_name = *(gnbParms[GNB_GNB_NAME_IDX].strptr); e1Setup->gNB_cu_up_name = *(gnbParms[GNB_GNB_NAME_IDX].strptr);
...@@ -130,11 +132,7 @@ MessageDef *RCconfig_NR_CU_E1(const E1_t *entity) ...@@ -130,11 +132,7 @@ MessageDef *RCconfig_NR_CU_E1(const E1_t *entity)
get_NGU_S1U_addr(&e1ap_nc->localAddressN3, &e1ap_nc->localPortN3); get_NGU_S1U_addr(&e1ap_nc->localAddressN3, &e1ap_nc->localPortN3);
e1ap_nc->remotePortN3 = e1ap_nc->localPortN3 ; e1ap_nc->remotePortN3 = e1ap_nc->localPortN3 ;
AssertFatal(config_isparamset(gnbParms, GNB_GNB_ID_IDX), "%s is not defined in configuration file\n", GNB_CONFIG_STRING_GNB_ID); if (separate_CUUP_process) {
uint32_t gnb_id = *gnbParms[GNB_GNB_ID_IDX].uptr;
E1AP_REGISTER_REQ(msgConfig).gnb_id = gnb_id;
if (entity != NULL) {
paramlist_def_t GNBE1ParamList = {GNB_CONFIG_STRING_E1_PARAMETERS, NULL, 0}; paramlist_def_t GNBE1ParamList = {GNB_CONFIG_STRING_E1_PARAMETERS, NULL, 0};
paramdef_t GNBE1Params[] = GNBE1PARAMS_DESC; paramdef_t GNBE1Params[] = GNBE1PARAMS_DESC;
config_getlist(config_get_if(), &GNBE1ParamList, GNBE1Params, sizeofArray(GNBE1Params), aprefix); config_getlist(config_get_if(), &GNBE1ParamList, GNBE1Params, sizeofArray(GNBE1Params), aprefix);
...@@ -143,24 +141,6 @@ MessageDef *RCconfig_NR_CU_E1(const E1_t *entity) ...@@ -143,24 +141,6 @@ MessageDef *RCconfig_NR_CU_E1(const E1_t *entity)
e1ap_nc->CUCP_e1_ip_address.ipv4 = 1; e1ap_nc->CUCP_e1_ip_address.ipv4 = 1;
strcpy(e1ap_nc->CUUP_e1_ip_address.ipv4_address, *(e1Parms[GNB_CONFIG_E1_IPV4_ADDRESS_CUUP].strptr)); strcpy(e1ap_nc->CUUP_e1_ip_address.ipv4_address, *(e1Parms[GNB_CONFIG_E1_IPV4_ADDRESS_CUUP].strptr));
e1ap_nc->CUUP_e1_ip_address.ipv4 = 1; e1ap_nc->CUUP_e1_ip_address.ipv4 = 1;
if (*entity == CPtype) {
// CP needs gNB_ID (although not used, but other parts check it as
// well), and gNB-CU-UP ID should NOT be present as it comes through E1!
AssertFatal(!config_isparamset(gnbParms, GNB_GNB_CU_UP_ID_IDX), "%s must not be defined in configuration file\n", GNB_CONFIG_STRING_GNB_CU_UP_ID);
} else { // UPtype
AssertFatal(config_isparamset(gnbParms, GNB_GNB_CU_UP_ID_IDX), "%s is not be defined in configuration file\n", GNB_CONFIG_STRING_GNB_CU_UP_ID);
e1Setup->gNB_cu_up_id = *gnbParms[GNB_GNB_CU_UP_ID_IDX].u64ptr;
}
} else {
// integrated CU-CP/UP. We don't care about the gNB-CU-UP ID that much,
// but if it's there, check it's the same as gNB ID
uint64_t *gnb_cu_up_id = gnbParms[GNB_GNB_CU_UP_ID_IDX].u64ptr;
AssertFatal(!config_isparamset(gnbParms, GNB_GNB_CU_UP_ID_IDX) || *gnb_cu_up_id == gnb_id,
"%s is different of %s: they need to match or remove %s from config\n",
GNB_CONFIG_STRING_GNB_CU_UP_ID,
GNB_CONFIG_STRING_GNB_ID,
GNB_CONFIG_STRING_GNB_CU_UP_ID);
e1Setup->gNB_cu_up_id = gnb_id;
} }
} }
return msgConfig; return msgConfig;
......
...@@ -168,8 +168,7 @@ void *gNB_app_task(void *args_p) ...@@ -168,8 +168,7 @@ void *gNB_app_task(void *args_p)
if (node_type == ngran_gNB_CUCP) { if (node_type == ngran_gNB_CUCP) {
if (itti_create_task(TASK_CUCP_E1, E1AP_CUCP_task, NULL) < 0) if (itti_create_task(TASK_CUCP_E1, E1AP_CUCP_task, NULL) < 0)
AssertFatal(false, "Create task for E1AP CP failed\n"); AssertFatal(false, "Create task for E1AP CP failed\n");
E1_t e1type = CPtype; MessageDef *msg = RCconfig_NR_CU_E1(true);
MessageDef *msg = RCconfig_NR_CU_E1(&e1type);
AssertFatal(msg != NULL, "Send inti to task for E1AP CP failed\n"); AssertFatal(msg != NULL, "Send inti to task for E1AP CP failed\n");
// this sends the E1AP_REGISTER_REQ to CU-CP so it sets up the socket // this sends the E1AP_REGISTER_REQ to CU-CP so it sets up the socket
// it does NOT use the E1AP part // it does NOT use the E1AP part
...@@ -276,6 +275,22 @@ void *gNB_app_task(void *args_p) ...@@ -276,6 +275,22 @@ void *gNB_app_task(void *args_p)
/* TODO handle recovering of registration */ /* TODO handle recovering of registration */
break; break;
case XNAP_DEREGISTERED_GNB_IND:
LOG_W(GNB_APP,
"[gNB %ld] Received %s: associated gNB %d\n",
instance,
ITTI_MSG_NAME(msg_p),
XNAP_DEREGISTERED_GNB_IND(msg_p).nb_xn);
break;
case XNAP_REGISTER_GNB_CNF:
LOG_I(GNB_APP,
"[gNB %ld] Received %s: associated gNB %d\n",
instance,
ITTI_MSG_NAME(msg_p),
XNAP_REGISTER_GNB_CNF(msg_p).nb_xn);
break;
case TIMER_HAS_EXPIRED: case TIMER_HAS_EXPIRED:
LOG_I(GNB_APP, " Received %s: timer_id %ld\n", msg_name, TIMER_HAS_EXPIRED(msg_p).timer_id); LOG_I(GNB_APP, " Received %s: timer_id %ld\n", msg_name, TIMER_HAS_EXPIRED(msg_p).timer_id);
......
This diff is collapsed.
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "rrc_messages_types.h" #include "rrc_messages_types.h"
#include "intertask_interface.h" #include "intertask_interface.h"
#include "RRC/NR/nr_rrc_defs.h" #include "RRC/NR/nr_rrc_defs.h"
#include "openair2/COMMON/xnap_messages_types.h"
#define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\ #define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\
struct in_addr inp;\ struct in_addr inp;\
......
...@@ -142,7 +142,6 @@ typedef enum { ...@@ -142,7 +142,6 @@ typedef enum {
/* cell configuration parameters */ /* cell configuration parameters */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------*/
// clang-format off
#define GNBPARAMS_DESC {\ #define GNBPARAMS_DESC {\
{GNB_CONFIG_STRING_GNB_ID, NULL, 0, .uptr=NULL, .defintval=0, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_GNB_ID, NULL, 0, .uptr=NULL, .defintval=0, TYPE_UINT, 0}, \
{GNB_CONFIG_STRING_CELL_TYPE, NULL, 0, .strptr=NULL, .defstrval="CELL_MACRO_GNB", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_CELL_TYPE, NULL, 0, .strptr=NULL, .defstrval="CELL_MACRO_GNB", TYPE_STRING, 0}, \
...@@ -172,11 +171,7 @@ typedef enum { ...@@ -172,11 +171,7 @@ typedef enum {
{GNB_CONFIG_STRING_FORCE256QAMOFF, GNB_CONFIG_HLP_FORCE256QAMOFF, PARAMFLAG_BOOL, .iptr=NULL, .defintval=0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_FORCE256QAMOFF, GNB_CONFIG_HLP_FORCE256QAMOFF, PARAMFLAG_BOOL, .iptr=NULL, .defintval=0, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_ENABLE_SDAP, GNB_CONFIG_HLP_STRING_ENABLE_SDAP, PARAMFLAG_BOOL,.iptr=NULL, .defintval=0, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_ENABLE_SDAP, GNB_CONFIG_HLP_STRING_ENABLE_SDAP, PARAMFLAG_BOOL,.iptr=NULL, .defintval=0, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_DRBS, GNB_CONFIG_HLP_STRING_DRBS, 0, .iptr=NULL, .defintval=1, TYPE_INT, 0}, \ {GNB_CONFIG_STRING_DRBS, GNB_CONFIG_HLP_STRING_DRBS, 0, .iptr=NULL, .defintval=1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_GNB_DU_ID, GNB_CONFIG_HLP_GNB_DU_ID, 0, .u64ptr=NULL, .defint64val=1, TYPE_UINT64, 0}, \
{GNB_CONFIG_STRING_GNB_CU_UP_ID, GNB_CONFIG_HLP_GNB_CU_UP_ID, 0, .u64ptr=NULL, .defint64val=1, TYPE_UINT64, 0}, \
} }
// clang-format on
#define GNB_GNB_ID_IDX 0 #define GNB_GNB_ID_IDX 0
#define GNB_CELL_TYPE_IDX 1 #define GNB_CELL_TYPE_IDX 1
...@@ -206,8 +201,6 @@ typedef enum { ...@@ -206,8 +201,6 @@ typedef enum {
#define GNB_FORCE256QAMOFF_IDX 25 #define GNB_FORCE256QAMOFF_IDX 25
#define GNB_ENABLE_SDAP_IDX 26 #define GNB_ENABLE_SDAP_IDX 26
#define GNB_DRBS 27 #define GNB_DRBS 27
#define GNB_GNB_DU_ID_IDX 28
#define GNB_GNB_CU_UP_ID_IDX 29
#define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD}
#define GNBPARAMS_CHECK { \ #define GNBPARAMS_CHECK { \
......
...@@ -159,6 +159,8 @@ typedef struct HANDOVER_INFO_NR_s { ...@@ -159,6 +159,8 @@ typedef struct HANDOVER_INFO_NR_s {
uint8_t buf[RRC_BUF_SIZE]; /* ASN.1 encoded handoverCommandMessage */ uint8_t buf[RRC_BUF_SIZE]; /* ASN.1 encoded handoverCommandMessage */
int size; /* size of above message in bytes */ int size; /* size of above message in bytes */
sctp_assoc_t assoc_id;
int x2_id;
} NR_HANDOVER_INFO; } NR_HANDOVER_INFO;
#define NR_RRC_BUFFER_SIZE sizeof(RRC_BUFFER_NR) #define NR_RRC_BUFFER_SIZE sizeof(RRC_BUFFER_NR)
...@@ -323,6 +325,15 @@ typedef struct gNB_RRC_UE_s { ...@@ -323,6 +325,15 @@ typedef struct gNB_RRC_UE_s {
typedef struct rrc_gNB_ue_context_s { typedef struct rrc_gNB_ue_context_s {
/* Tree related data */ /* Tree related data */
RB_ENTRY(rrc_gNB_ue_context_s) entries; RB_ENTRY(rrc_gNB_ue_context_s) entries;
/* Uniquely identifies the UE between MME and eNB within the eNB.
* This id is encoded on 24bits.
*/
rnti_t ue_id_rnti;
// another key for protocol layers but should not be used as a key for RB tree
uid_t local_uid;
/* UE id for initial connection to NGAP */ /* UE id for initial connection to NGAP */
struct gNB_RRC_UE_s ue_context; struct gNB_RRC_UE_s ue_context;
} rrc_gNB_ue_context_t; } rrc_gNB_ue_context_t;
...@@ -422,6 +433,11 @@ typedef struct gNB_RRC_INST_s { ...@@ -422,6 +433,11 @@ typedef struct gNB_RRC_INST_s {
RB_HEAD(rrc_cuup_tree, nr_rrc_cuup_container_t) cuups; // CU-UPs, indexed by assoc_id RB_HEAD(rrc_cuup_tree, nr_rrc_cuup_container_t) cuups; // CU-UPs, indexed by assoc_id
size_t num_cuups; size_t num_cuups;
/* KgNB as computed from parameters within USIM card */
uint8_t kgnb[32];
uint8_t nh[32];
int8_t nh_ncc;
} gNB_RRC_INST; } gNB_RRC_INST;
#include "nr_rrc_proto.h" //should be put here otherwise compilation error #include "nr_rrc_proto.h" //should be put here otherwise compilation error
......
...@@ -135,6 +135,22 @@ void bearer_context_setup_direct(e1ap_bearer_setup_req_t *req, ...@@ -135,6 +135,22 @@ void bearer_context_setup_direct(e1ap_bearer_setup_req_t *req,
void bearer_context_setup_e1ap(e1ap_bearer_setup_req_t *req, void bearer_context_setup_e1ap(e1ap_bearer_setup_req_t *req,
instance_t instance); instance_t instance);
void
rrc_gNB_process_MeasurementReport(
const protocol_ctxt_t *const ctxt_pP,
// rrc_gNB_ue_context_t *ue_context_pP,
const NR_MeasResults_t *const measResults2
);
void
rrc_gNB_generate_HandoverPreparationInformation(
//const protocol_ctxt_t* const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *buffer,
int *_size
//LTE_PhysCellId_t targetPhyId
);
void ue_cxt_mod_send_e1ap(MessageDef *msg, void ue_cxt_mod_send_e1ap(MessageDef *msg,
instance_t instance); instance_t instance);
......
This diff is collapsed.
...@@ -6,7 +6,8 @@ add_library(xnap ...@@ -6,7 +6,8 @@ add_library(xnap
xnap_gNB_itti_messaging.c xnap_gNB_itti_messaging.c
xnap_gNB_handler.c xnap_gNB_handler.c
xnap_gNB_interface_management.c xnap_gNB_interface_management.c
xnap_gNB_generate_messages) xnap_timers.c
xnap_gNB_generate_messages.c)
target_link_libraries(xnap target_link_libraries(xnap
PUBLIC asn1_xnap PUBLIC asn1_xnap
PRIVATE nr_rrc) PRIVATE nr_rrc)
......
...@@ -71,3 +71,4 @@ int xnap_gNB_decode_pdu(XNAP_XnAP_PDU_t *pdu, const uint8_t *const buffer, uint3 ...@@ -71,3 +71,4 @@ int xnap_gNB_decode_pdu(XNAP_XnAP_PDU_t *pdu, const uint8_t *const buffer, uint3
} }
return 0; return 0;
} }
/*
* 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
*/
/*! \file xnap_gNB_decoder.c
* \date July 2023
* \version 1.0
*/
#include <stdio.h>
#include "assertions.h"
#include "intertask_interface.h"
#include "xnap_common.h"
#include "xnap_gNB_decoder.h"
int xnap_gNB_decode_pdu(XNAP_XnAP_PDU_t *pdu, const uint8_t *const buffer, uint32_t length)
{
asn_dec_rval_t dec_ret;
DevAssert(buffer != NULL);
dec_ret = aper_decode(NULL, &asn_DEF_XNAP_XnAP_PDU, (void **)&pdu, buffer, length, 0, 0);
xer_fprint(stdout, &asn_DEF_XNAP_XnAP_PDU, pdu);
if (dec_ret.code != RC_OK) {
LOG_E(XNAP, "Failed to decode PDU\n");
return -1;
}
switch (pdu->present) {
case XNAP_XnAP_PDU_PR_initiatingMessage:
LOG_I(XNAP, "xnap_gNB_decode_initiating_message!\n");
break;
case XNAP_XnAP_PDU_PR_successfulOutcome:
LOG_I(XNAP, "xnap_gNB_decode_successfuloutcome_message!\n");
break;
case XNAP_XnAP_PDU_PR_unsuccessfulOutcome:
LOG_I(XNAP, "xnap_gNB_decode_unsuccessfuloutcome_message!\n");
break;
case XNAP_ProcedureCode_id_handoverPreparation:
//asn_encode_to_new_buffer(NULL, ATS_CANONICAL_XER, &asn_DEF_XNAP_XNAP_PDU, pdu);
XNAP_INFO("xnap_eNB_decode_initiating_message!\n");
break;
default:
LOG_D(XNAP, "Unknown presence (%d) or not implemented\n", (int)pdu->present);
break;
}
return 0;
}
/*
* 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
*/
/*! \file xnap_gNB_decoder.h
* \date July 2023
* \version 1.0
*/
#ifndef XNAP_GNB_DECODER_H_
#define XNAP_GNB_DECODER_H_
int xnap_gNB_decode_pdu(XNAP_XnAP_PDU_t *pdu, const uint8_t *const buffer, uint32_t length) __attribute__((warn_unused_result));
#endif /* XNAP_GNB_DECODER_H_ */
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "tree.h" #include "tree.h"
#include "sctp_eNB_defs.h" #include "sctp_eNB_defs.h"
#include "xnap_messages_types.h" #include "xnap_messages_types.h"
#include "xnap_ids.h"
#include "xnap_timers.h"
#ifndef XNAP_GNB_DEFS_H_ #ifndef XNAP_GNB_DEFS_H_
#define XNAP_GNB_DEFS_H_ #define XNAP_GNB_DEFS_H_
...@@ -90,6 +92,8 @@ typedef struct xnap_gNB_instance_s { ...@@ -90,6 +92,8 @@ typedef struct xnap_gNB_instance_s {
/* SCTP information */ /* SCTP information */
xnap_sctp_t sctp_streams; xnap_sctp_t sctp_streams;
char *gNB_name; char *gNB_name;
xnap_id_manager id_manager;
xnap_timers_t timers;
} xnap_gNB_instance_t; } xnap_gNB_instance_t;
#endif /* XNAP_GNB_DEFS_H_ */ #endif /* XNAP_GNB_DEFS_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
*/
/*! \file xnap_gNB_encoder.c
* \brief xnap encoder procedures for gNB
* \author Sreeshma Shiv <sreeshmau@iisc.ac.in>
* \date August 2023
* \version 1.0
*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "assertions.h"
#include "conversions.h"
#include "intertask_interface.h"
#include "xnap_common.h"
#include "xnap_gNB_encoder.h"
int xnap_gNB_encode_pdu(XNAP_XnAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
{
ssize_t encoded;
DevAssert(pdu != NULL);
DevAssert(buffer != NULL);
DevAssert(len != NULL);
xer_fprint(stdout, &asn_DEF_XNAP_XnAP_PDU, (void *)pdu);
encoded = aper_encode_to_new_buffer(&asn_DEF_XNAP_XnAP_PDU, 0, pdu, (void **)buffer);
if (encoded < 0) {
return -1;
}
*len = encoded;
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_XNAP_XnAP_PDU, pdu);
return encoded;
}
/*
* 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
*/
/*! \file xnap_gNB_encoder.h
* \brief xnap encoder procedures for gNB
* \date July 2023
* \version 1.0
*/
#ifndef XNAP_GNB_ENCODER_H_
#define XNAP_GNB_ENCODER_H_
int xnap_gNB_encode_pdu(XNAP_XnAP_PDU_t *pdu, uint8_t **buffer, uint32_t *len) __attribute__((warn_unused_result));
#endif /* XNAP_GNB_ENCODER_H_ */
This diff is collapsed.
...@@ -39,4 +39,6 @@ int xnap_gNB_generate_xn_setup_failure(sctp_assoc_t assoc_id, xnap_setup_failure ...@@ -39,4 +39,6 @@ int xnap_gNB_generate_xn_setup_failure(sctp_assoc_t assoc_id, xnap_setup_failure
int xnap_gNB_set_cause(XNAP_Cause_t *cause_p, XNAP_Cause_PR cause_type, long cause_value); int xnap_gNB_set_cause(XNAP_Cause_t *cause_p, XNAP_Cause_PR cause_type, long cause_value);
int xnap_gNB_generate_xn_handover_request(instance_t *instance_p, xnap_handover_req_t *xnap_handover_req, int ue_id);
#endif /* XNAP_GNB_GENERATE_MESSAGES_H_ */ #endif /* XNAP_GNB_GENERATE_MESSAGES_H_ */
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "intertask_interface.h" #include "intertask_interface.h"
#include "xnap_gNB_itti_messaging.h" #include "xnap_gNB_itti_messaging.h"
<<<<<<< HEAD
void xnap_gNB_itti_send_sctp_data_req(sctp_assoc_t assoc_id, uint8_t *buffer, uint32_t buffer_length, uint16_t stream) void xnap_gNB_itti_send_sctp_data_req(sctp_assoc_t assoc_id, uint8_t *buffer, uint32_t buffer_length, uint16_t stream)
{ {
MessageDef *message_p; MessageDef *message_p;
......
...@@ -30,5 +30,4 @@ ...@@ -30,5 +30,4 @@
void xnap_gNB_itti_send_sctp_data_req(sctp_assoc_t assoc_id, uint8_t *buffer, uint32_t buffer_length, uint16_t stream); void xnap_gNB_itti_send_sctp_data_req(sctp_assoc_t assoc_id, uint8_t *buffer, uint32_t buffer_length, uint16_t stream);
#endif /* XNAP_GNB_ITTI_MESSAGING_H_ */ #endif /* XNAP_GNB_ITTI_MESSAGING_H_ */
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "xnap_gNB_defs.h" #include "xnap_gNB_defs.h"
#include "xnap_gNB_task.h" #include "xnap_gNB_task.h"
<<<<<<< HEAD
// xnap_gNB_internal_data_t xnap_gNB_internal_data; // xnap_gNB_internal_data_t xnap_gNB_internal_data;
static xnap_gNB_instance_t *xn_inst[NUMBER_OF_gNB_MAX] = {0}; static xnap_gNB_instance_t *xn_inst[NUMBER_OF_gNB_MAX] = {0};
...@@ -64,6 +65,7 @@ RB_GENERATE(xnap_gnb_tree, xnap_gNB_data_t, entry, xnap_gNB_compare_assoc_id); ...@@ -64,6 +65,7 @@ RB_GENERATE(xnap_gnb_tree, xnap_gNB_data_t, entry, xnap_gNB_compare_assoc_id);
return 0; return 0;
}*/ }*/
<<<<<<< HEAD
static pthread_mutex_t xn_inst_mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t xn_inst_mtx = PTHREAD_MUTEX_INITIALIZER;
void createXninst(instance_t instanceP, xnap_setup_req_t *req, xnap_net_config_t *nc) void createXninst(instance_t instanceP, xnap_setup_req_t *req, xnap_net_config_t *nc)
{ {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <openair3/ocp-gtpu/gtp_itf.h> #include <openair3/ocp-gtpu/gtp_itf.h>
#include "xnap_gNB_task.h" #include "xnap_gNB_task.h"
#include "xnap_gNB_defs.h" #include "xnap_gNB_defs.h"
#include "xnap_ids.h"
#include "xnap_gNB_management_procedures.h" #include "xnap_gNB_management_procedures.h"
#include "xnap_gNB_handler.h" #include "xnap_gNB_handler.h"
#include "xnap_gNB_generate_messages.h" #include "xnap_gNB_generate_messages.h"
...@@ -198,14 +199,48 @@ static void xnap_gNB_handle_sctp_association_ind(instance_t instance, sctp_new_a ...@@ -198,14 +199,48 @@ static void xnap_gNB_handle_sctp_association_ind(instance_t instance, sctp_new_a
//xnap_dump_trees(instance); //xnap_dump_trees(instance);
xnap_insert_gnb(instance, xnap_gnb_data_p); xnap_insert_gnb(instance, xnap_gnb_data_p);
xnap_dump_trees(instance); xnap_dump_trees(instance);
} else {
xnap_gnb_data_p->in_streams = sctp_new_association_ind->in_streams;
xnap_gnb_data_p->out_streams = sctp_new_association_ind->out_streams; xnap_gnb_data_p->out_streams = sctp_new_association_ind->out_streams;
LOG_W(XNAP, "Updated streams for assoc id: %d \n", sctp_new_association_ind->assoc_id); LOG_W(XNAP, "Updated streams for assoc id: %d \n", sctp_new_association_ind->assoc_id);
} }
xnap_dump_trees(instance); xnap_dump_trees(instance);
} }
static
void xnap_gNB_handle_handover_req(instance_t instance,
xnap_handover_req_t *xnap_handover_req)
{
xnap_gNB_instance_t *instance_p;
xnap_gNB_data_t *target;
xnap_id_manager *id_manager;
int ue_id;
int target_pci = xnap_handover_req->target_physCellId;
instance_p = xnap_gNB_get_instance(instance);
DevAssert(instance_p != NULL);
target = xnap_is_gNB_pci_in_list(target_pci);
DevAssert(target != NULL);
/* allocate xnap ID */
id_manager = &instance_p->id_manager;
ue_id = xnap_allocate_new_id(id_manager);
if (ue_id == -1) {
XNAP_ERROR("could not allocate a new XNAP UE ID\n");
/* TODO: cancel handover: send (to be defined) message to RRC */
exit(1);
}
/* id_source is ue_id, id_target is unknown yet */
xnap_set_ids(id_manager, ue_id, xnap_handover_req->rnti, ue_id, -1);
xnap_id_set_state(id_manager, ue_id, XNID_STATE_SOURCE_PREPARE);
xnap_set_reloc_prep_timer(id_manager, ue_id,
xnap_timer_get_tti(&instance_p->timers));
xnap_id_set_target(id_manager, ue_id, target);
// xnap_gNB_generate_xn_handover_request(instance_p, target, xnap_handover_req, ue_id); //Review removed target here but needs it
xnap_gNB_generate_xn_handover_request(instance_p, xnap_handover_req, ue_id);
}
void *xnap_task(void *arg) void *xnap_task(void *arg)
{ {
MessageDef *received_msg = NULL; MessageDef *received_msg = NULL;
...@@ -237,6 +272,11 @@ void *xnap_task(void *arg) ...@@ -237,6 +272,11 @@ void *xnap_task(void *arg)
xnap_gNB_generate_xn_setup_response(ITTI_MSG_ORIGIN_INSTANCE(received_msg), &XNAP_SETUP_RESP(received_msg)); xnap_gNB_generate_xn_setup_response(ITTI_MSG_ORIGIN_INSTANCE(received_msg), &XNAP_SETUP_RESP(received_msg));
break; break;
case XNAP_HANDOVER_REQ: // from rrc
xnap_gNB_handle_handover_req(ITTI_MSG_ORIGIN_INSTANCE(received_msg),
&XNAP_HANDOVER_REQ(received_msg));
break;
case SCTP_INIT_MSG_MULTI_CNF: case SCTP_INIT_MSG_MULTI_CNF:
xnap_gNB_handle_sctp_init_msg_multi_cnf(ITTI_MSG_DESTINATION_INSTANCE(received_msg), xnap_gNB_handle_sctp_init_msg_multi_cnf(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
&received_msg->ittiMsg.sctp_init_msg_multi_cnf); &received_msg->ittiMsg.sctp_init_msg_multi_cnf);
......
/*
* 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
*/
/* Poornima */
#include "xnap_ids.h"
#include <string.h>
void xnap_id_manager_init(xnap_id_manager *m)
{
int i;
memset(m, 0, sizeof(xnap_id_manager));
for (i = 0; i < XNAP_MAX_IDS; i++)
m->ids[i].rnti = -1;
}
int xnap_allocate_new_id(xnap_id_manager *m)
{
int i;
for (i = 0; i < XNAP_MAX_IDS; i++)
if (m->ids[i].rnti == -1) {
m->ids[i].rnti = 0;
m->ids[i].id_source = -1;
m->ids[i].id_target = -1;
return i;
}
return -1;
}
void xnap_release_id(xnap_id_manager *m, int id)
{
m->ids[id].rnti = -1;
}
int xnap_find_id(xnap_id_manager *m, int id_source, int id_target)
{
int i;
for (i = 0; i < XNAP_MAX_IDS; i++)
if (m->ids[i].rnti != -1 &&
m->ids[i].id_source == id_source &&
m->ids[i].id_target == id_target)
return i;
return -1;
}
int xnap_find_id_from_id_source(xnap_id_manager *m, int id_source)
{
int i;
for (i = 0; i < XNAP_MAX_IDS; i++)
if (m->ids[i].rnti != -1 &&
m->ids[i].id_source == id_source)
return i;
return -1;
}
int xnap_find_id_from_id_target(xnap_id_manager *m, int id_target)
{
int i;
for (i = 0; i < XNAP_MAX_IDS; i++)
if (m->ids[i].rnti != -1 &&
m->ids[i].id_target == id_target)
return i;
return -1;
}
int xnap_find_id_from_rnti(xnap_id_manager *m, int rnti)
{
int i;
for (i = 0; i < XNAP_MAX_IDS; i++)
if (m->ids[i].rnti == rnti)
return i;
return -1;
}
void xnap_set_ids(xnap_id_manager *m, int ue_id, int rnti, int id_source, int id_target)
{
m->ids[ue_id].rnti = rnti;
m->ids[ue_id].id_source = id_source;
m->ids[ue_id].id_target = id_target;
}
/* real type of target is xnap_gNB_data_t * */
void xnap_id_set_target(xnap_id_manager *m, int ue_id, void *target)
{
m->ids[ue_id].target = target;
}
void xnap_id_set_state(xnap_id_manager *m, int ue_id, xnid_state_t state)
{
m->ids[ue_id].state = state;
}
void xnap_set_reloc_prep_timer(xnap_id_manager *m, int ue_id, uint64_t time)
{
m->ids[ue_id].t_reloc_prep_start = time;
}
void xnap_set_reloc_overall_timer(xnap_id_manager *m, int ue_id, uint64_t time)
{
m->ids[ue_id].tx2_reloc_overall_start = time;
}
void xnap_set_dc_prep_timer(xnap_id_manager *m, int ue_id, uint64_t time)
{
m->ids[ue_id].t_dc_prep_start = time;
}
void xnap_set_dc_overall_timer(xnap_id_manager *m, int ue_id, uint64_t time)
{
m->ids[ue_id].t_dc_overall_start = time;
}
int xnap_id_get_id_source(xnap_id_manager *m, int ue_id)
{
return m->ids[ue_id].id_source;
}
int xnap_id_get_id_target(xnap_id_manager *m, int ue_id)
{
return m->ids[ue_id].id_target;
}
int xnap_id_get_rnti(xnap_id_manager *m, int ue_id)
{
return m->ids[ue_id].rnti;
}
void *xnap_id_get_target(xnap_id_manager *m, int ue_id)
{
return m->ids[ue_id].target;
}
/*
* 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
*/
/* Poornima */
#ifndef XNAP_IDS_H_
#define XNAP_IDS_H_
#include <stdint.h>
/* maximum number of simultaneous handovers, do not set too high */
#define XNAP_MAX_IDS 16
/*
* state:
* - when starting handover in source, UE is in state XNID_STATE_SOURCE_PREPARE
* - after receiving HO_ack in source, UE is in state XNID_STATE_SOURCE_OVERALL
* - in target, UE is in state XNID_STATE_TARGET
* The state is used to check timers.
*/
typedef enum {
XNID_STATE_SOURCE_PREPARE,
XNID_STATE_SOURCE_OVERALL,
XNID_STATE_TARGET,
XNID_STATE_NSA_GNB_PREPARE,
XNID_STATE_NSA_GNB_OVERALL,
} xnid_state_t;
typedef struct {
int rnti; /* -1 when free */
int id_source;
int id_target;
/* the target eNB. Real type is x2ap_eNB_data_t * */
void *target;
/* state: needed to check timers */
xnid_state_t state;
/* timers */
uint64_t t_reloc_prep_start;
uint64_t tx2_reloc_overall_start;
uint64_t t_dc_prep_start;
uint64_t t_dc_overall_start;
} xnap_id;
typedef struct {
xnap_id ids[XNAP_MAX_IDS];
} xnap_id_manager;
void xnap_id_manager_init(xnap_id_manager *m);
int xnap_allocate_new_id(xnap_id_manager *m);
void xnap_release_id(xnap_id_manager *m, int id);
int xnap_find_id(xnap_id_manager *, int id_source, int id_target);
int xnap_find_id_from_id_source(xnap_id_manager *, int id_source);
int xnap_find_id_from_id_target(xnap_id_manager *, int id_source);
int xnap_find_id_from_rnti(xnap_id_manager *, int rnti);
void xnap_set_ids(xnap_id_manager *m, int ue_id, int rnti, int id_source, int id_target);
void xnap_id_set_state(xnap_id_manager *m, int ue_id, xnid_state_t state);
/* real type of target is x2ap_eNB_data_t * */
void xnap_id_set_target(xnap_id_manager *m, int ue_id, void *target);
void xnap_set_reloc_prep_timer(xnap_id_manager *m, int ue_id, uint64_t time);
void xnap_set_reloc_overall_timer(xnap_id_manager *m, int ue_id, uint64_t time);
void xnap_set_dc_prep_timer(xnap_id_manager *m, int ue_id, uint64_t time);
void xnap_set_dc_overall_timer(xnap_id_manager *m, int ue_id, uint64_t time);
int xnap_id_get_id_source(xnap_id_manager *m, int ue_id);
int xnap_id_get_id_target(xnap_id_manager *m, int ue_id);
int xnap_id_get_rnti(xnap_id_manager *m, int ue_id);
void *xnap_id_get_target(xnap_id_manager *m, int ue_id);
#endif /* X2AP_IDS_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_timers.h"
#include "assertions.h"
#include "PHY/defs_common.h" /* TODO: try to not include this */
#include "xnap_messages_types.h"
#include "xnap_gNB_defs.h"
#include "xnap_ids.h"
#include "xnap_gNB_management_procedures.h"
#include "xnap_gNB_generate_messages.h"
void xnap_timers_init(xnap_timers_t *t,
int t_reloc_prep,
int tx2_reloc_overall,
int t_dc_prep,
int t_dc_overall)
{
t->tti = 0;
t->t_reloc_prep = t_reloc_prep;
t->tx2_reloc_overall = tx2_reloc_overall;
t->t_dc_prep = t_dc_prep;
t->t_dc_overall = t_dc_overall;
}
/*
void xnap_check_timers(instance_t instance)
{
xnap_gNB_instance_t *instance_p;
xnap_timers_t *t;
xnap_id_manager *m;
int i;
xnap_handover_cancel_cause_t cause;
void *target;
MessageDef *msg;
int xnap_ongoing;
instance_p = xnap_gNB_get_instance(instance);
DevAssert(instance_p != NULL);
t = &instance_p->timers;
m = &instance_p->id_manager;
// increment subframe count
t->tti++;
xnap_ongoing = 0;
for (i = 0; i < XNAP_MAX_IDS; i++) {
if (m->ids[i].rnti == -1) continue;
if (m->ids[i].state == XNAPID_STATE_SOURCE_PREPARE ||
m->ids[i].state == XNAPID_STATE_SOURCE_OVERALL)
xnap_ongoing++;
if (m->ids[i].state == XNAPID_STATE_SOURCE_PREPARE &&
t->tti > m->ids[i].t_reloc_prep_start + t->t_reloc_prep) {
LOG_I(XNAP, "XNAP timeout reloc prep\n");
// t_reloc_prep timed out
cause = XNAP_T_RELOC_PREP_TIMEOUT;
goto xnap_handover_timeout;
}
if (m->ids[i].state == XNAPID_STATE_SOURCE_OVERALL &&
t->tti > m->ids[i].tx2_reloc_overall_start + t->tx2_reloc_overall) {
LOG_I(XNAP, "XNAP timeout reloc overall\n");
// tx2_reloc_overall timed out
cause = XNAP_TX2_RELOC_OVERALL_TIMEOUT;
goto xnap_handover_timeout;
}
if (m->ids[i].state == XNAPID_STATE_NSA_GNB_PREPARE &&
t->tti > m->ids[i].t_dc_prep_start + t->t_dc_prep) {
int id_source;
int id_target;
LOG_I(XNAP, "XNAP timeout DC prep\n");
// t_dc_prep timed out
target = xnap_id_get_target(m, i);
id_source = xnap_id_get_id_source(m, i);
id_target = xnap_id_get_id_target(m, i);
xnap_gNB_generate_ENDC_xnap_SgNB_release_request(instance_p, target,
id_source, id_target,
XNAP_CAUSE_T_DC_PREP_TIMEOUT);
// inform RRC of timeout
msg = itti_alloc_new_message(TASK_XNAP, 0, XNAP_ENDC_DC_PREP_TIMEOUT);
XNAP_ENDC_DC_PREP_TIMEOUT(msg).rnti = xnap_id_get_rnti(m, i);
itti_send_msg_to_task(TASK_RRC_GNB, instance_p->instance, msg);
// remove UE from XNAP
xnap_release_id(m, i);
continue;
}
if (m->ids[i].state == XNAPID_STATE_NSA_GNB_OVERALL &&
t->tti > m->ids[i].t_dc_overall_start + t->t_dc_overall) {
int id_source;
int id_target;
LOG_I(XNAP, "XNAP timeout DC overall\n");
// t_dc_overall timed out
target = xnap_id_get_target(m, i);
id_source = xnap_id_get_id_source(m, i);
id_target = xnap_id_get_id_target(m, i);
xnap_gNB_generate_ENDC_xnap_SgNB_release_required(instance_p, target,
id_source, id_target, XNAP_CAUSE_T_DC_OVERALL_TIMEOUT);
// inform RRC of timeout
msg = itti_alloc_new_message(TASK_XNAP, 0, XNAP_ENDC_DC_OVERALL_TIMEOUT);
XNAP_ENDC_DC_OVERALL_TIMEOUT(msg).rnti = xnap_id_get_rnti(m, i);
itti_send_msg_to_task(TASK_RRC_GNB, instance_p->instance, msg);
// remove UE from X2AP
xnap_release_id(m, i);
continue;
}
// no timeout -> check next UE
continue;
xnap_handover_timeout:
// inform target about timeout
target = xnap_id_get_target(m, i);
xnap_gNB_generate_xnap_handover_cancel(instance_p, target, i, cause);
// inform RRC of cancellation
msg = itti_alloc_new_message(TASK_XNAP, 0, XNAP_HANDOVER_CANCEL);
XNAP_HANDOVER_CANCEL(msg).rnti = xnap_id_get_rnti(m, i);
XNAP_HANDOVER_CANCEL(msg).cause = cause;
itti_send_msg_to_task(TASK_RRC_GNB, instance_p->instance, msg);
// remove UE from XNAP
xnap_release_id(m, i);
}
if (xnap_ongoing && t->tti % 1000 == 0)
LOG_I(XNAP, "XNAP has %d process ongoing\n", xnap_ongoing);
}
uint64_t xnap_timer_get_tti(xnap_timers_t *t)
{
return t->tti;
} **/
/*
* 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_TIMERS_H_
#define XNAP_TIMERS_H_
#include <stdint.h>
#include "platform_types.h"
typedef struct {
/* incremented every TTI (every millisecond when in realtime).
* Used to check timers.
* 64 bits gives us more than 500 million years of (realtime) processing.
* It should be enough.
*/
uint64_t tti;
/* timer values (unit: TTI, ie. millisecond when in realtime) */
int t_reloc_prep;
int tx2_reloc_overall;
int t_dc_prep;
int t_dc_overall;
} xnap_timers_t;
void xnap_timers_init(xnap_timers_t *t,
int t_reloc_prep,
int tx2_reloc_overall,
int t_dc_prep,
int t_dc_overall);
void xnap_check_timers(instance_t instance);
uint64_t xnap_timer_get_tti(xnap_timers_t *t);
#endif /* X2AP_TIMERS_H_ */
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