Commit f09468eb authored by laurent's avatar laurent

continue e1AP development

parent 76545cfb
......@@ -1707,7 +1707,7 @@ add_library(e1_if
${NR_RRC_DIR}/cucp_cuup_e1ap.c
)
target_link_libraries(e1_if PRIVATE asn1_nr_rrc asn1_lte_rrc asn1_f1ap)
target_link_libraries(e1_if PRIVATE asn1_nr_rrc asn1_lte_rrc asn1_f1ap e1ap)
add_library(e1_pdcp_if
${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_e1_api.c
......@@ -2449,7 +2449,7 @@ target_link_libraries(nr-softmodem PRIVATE
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECU_CN SECU_OSA
ITTI ${RAL_LIB} ${NAS_UE_LIB} lte_rrc nr_rrc
ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU
x2ap f1ap m2ap m3ap
x2ap f1ap m2ap m3ap e1ap
-Wl,--end-group z dl)
target_link_libraries(nr-softmodem PRIVATE ${LIBXML2_LIBRARIES})
......
......@@ -47,6 +47,8 @@ typedef enum {
ngran_gNB_CUUP = 10
} ngran_node_t;
typedef enum { CPtype = 0, UPtype } E1_t;
#define NODE_IS_MONOLITHIC(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB || (nOdE_TyPe) == ngran_ng_eNB || (nOdE_TyPe) == ngran_gNB)
#define NODE_IS_CU(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB_CU || (nOdE_TyPe) == ngran_ng_eNB_CU || (nOdE_TyPe) == ngran_gNB_CU || (nOdE_TyPe) == ngran_gNB_CUCP || (nOdE_TyPe) == ngran_gNB_CUUP)
#define NODE_IS_DU(nOdE_TyPe) ((nOdE_TyPe) == ngran_eNB_DU || (nOdE_TyPe) == ngran_gNB_DU)
......
......@@ -112,10 +112,7 @@ void fill_DRB_configList(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_contex
{
abort();
}
NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_ToAddModList_t *SRB_configList, uint8_t xid)
{
abort();
}
int main(int argc, char **argv)
{
/// static configuration for NR at the moment
......@@ -133,7 +130,7 @@ int main(int argc, char **argv)
rc = itti_create_task(TASK_CUUP_E1, E1AP_CUUP_task, NULL);
AssertFatal(rc >= 0, "Create task for CUUP E1 failed\n");
pdcp_layer_init();
MessageDef *msg = RCconfig_NR_CU_E1();
MessageDef *msg = RCconfig_NR_CU_E1(true);
if (msg)
itti_send_msg_to_task(TASK_CUUP_E1, 0, msg);
else
......
......@@ -81,6 +81,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "nfapi/oai_integration/vendor_ext.h"
#include "gnb_config.h"
#include "openair2/E1AP/e1ap_common.h"
pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
......@@ -342,14 +343,8 @@ int create_gNB_tasks(void) {
//registered_gnb = 0;
__attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);
}
if (gnb_nb > 0) {
/* Last task to create, others task must be ready before its start */
/*if (itti_create_task (TASK_GNB_APP, gNB_app_task, NULL) < 0) {
LOG_E(GNB_APP, "Create task for gNB APP failed\n");
return -1;
}*/
if(itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) {
LOG_E(SCTP, "Create task for SCTP failed\n");
return -1;
......@@ -399,17 +394,22 @@ int create_gNB_tasks(void) {
return -1;
}
LOG_I(NR_RRC,"Creating NR RRC gNB Task\n");
LOG_I(NR_RRC, "Creating NR RRC gNB Task, that will also create TASKS\n");
if (itti_create_task (TASK_RRC_GNB, rrc_gnb_task, NULL) < 0) {
LOG_E(NR_RRC, "Create task for NR RRC gNB failed\n");
return -1;
}
// If CU
if ((node_type == ngran_gNB_CU) ||
(node_type == ngran_gNB)) {
RC.nrrrc[gnb_id_start]->gtpInstN3 = RCconfig_nr_gtpu();
if (node_type == ngran_gNB_CU || node_type == ngran_gNB) {
MessageDef *msg = RCconfig_NR_CU_E1(false);
instance_t inst = 0;
createE1inst(UPtype, inst, &E1AP_SETUP_REQ(msg));
cuup_init_n3(inst);
itti_free(TASK_UNKNOWN, msg);
getCxtE1(inst)->same_process = true;
;
RC.nrrrc[gnb_id_start]->e1_inst = inst; // stupid instance !!!*/
}
//Use check on x2ap to consider the NSA scenario
......
......@@ -2036,7 +2036,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
//--------------------- Channel Compensation ---------------
//----------------------------------------------------------
start_meas(&gNB->ulsch_channel_compensation_stats);
LOG_D(PHY,"Doing channel compensations log2_maxh %d, avgs %d (%d,%d)\n",gNB->pusch_vars[ulsch_id]->log2_maxh,avgs,avg[0],avg[1]);
LOG_D(PHY, "Doing channel compensations log2_maxh %d, avgs %d (%d)\n", gNB->pusch_vars[ulsch_id]->log2_maxh, avgs, avg[0]);
nr_ulsch_channel_compensation(gNB->pusch_vars[ulsch_id]->rxdataF_ext,
gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
gNB->pusch_vars[ulsch_id]->ul_ch_mag0,
......
......@@ -1360,7 +1360,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
stop_meas(&ue->generic_stat);
if (cpumeas(CPUMEAS_GETSTATE))
LOG_D(PHY,"after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0));
LOG_D(PHY, "after LDPC until end of Rx %5.2f \n", ue->generic_stat.p_time / (cpuf * 1000.0));
#ifdef EMOS
phy_procedures_emos_UE_RX(ue,slot,gNB_id);
......
This diff is collapsed.
......@@ -26,42 +26,31 @@
#include "openair2/COMMON/e1ap_messages_types.h"
#include "e1ap_asnc.h"
#include "openair2/E1AP/e1ap_common.h"
#endif
int e1apCUCP_handle_SETUP_REQUEST(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_SETUP_REQUEST(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_SETUP_RESPONSE(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_SETUP_RESPONSE(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_SETUP_FAILURE(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_SETUP_FAILURE(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_BEARER_CONTEXT_SETUP_REQUEST(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_BEARER_CONTEXT_SETUP_REQUEST(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_BEARER_CONTEXT_SETUP_RESPONSE(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_BEARER_CONTEXT_SETUP_RESPONSE(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_BEARER_CONTEXT_SETUP_FAILURE(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_BEARER_CONTEXT_SETUP_FAILURE(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
void e1apCUUP_send_BEARER_CONTEXT_SETUP_RESPONSE(e1ap_upcp_inst_t *inst, e1ap_bearer_setup_resp_t *const resp);
void e1apCUUP_send_BEARER_CONTEXT_SETUP_RESPONSE(instance_t instance,
e1ap_bearer_setup_resp_t *const resp);
int e1apCUUP_handle_BEARER_CONTEXT_RELEASE_COMMAND(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_handle_BEARER_CONTEXT_RELEASE_COMMAND(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_BEARER_CONTEXT_RELEASE_COMPLETE(e1ap_upcp_inst_t *inst, const E1AP_E1AP_PDU_t *pdu);
int e1apCUCP_handle_BEARER_CONTEXT_RELEASE_COMPLETE(instance_t instance,
const E1AP_E1AP_PDU_t *pdu);
int e1apCUUP_send_BEARER_CONTEXT_RELEASE_COMPLETE(instance_t instance, e1ap_bearer_release_cmd_t *const cmd);
int e1apCUUP_send_BEARER_CONTEXT_RELEASE_COMPLETE(e1ap_upcp_inst_t *inst, e1ap_bearer_release_cmd_t *const cmd);
void *E1AP_CUUP_task(void *arg);
void *E1AP_CUCP_task(void *arg);
#endif
......@@ -44,41 +44,33 @@ static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, pdu_se
ie->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config;
// sdap_Config
NR_SDAP_Config_t *sdap_config = CALLOC(1, sizeof(*sdap_config));
memset(sdap_config, 0, sizeof(*sdap_config));
ie->cnAssociation->choice.sdap_Config = sdap_config;
asn1cCalloc(ie->cnAssociation->choice.sdap_Config, sdap_config);
sdap_config->pdu_Session = pdu->sessionId;
sdap_config->sdap_HeaderDL = drb->sDAP_Header_DL;
sdap_config->sdap_HeaderUL = drb->sDAP_Header_UL;
sdap_config->defaultDRB = drb->defaultDRB;
sdap_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
asn1cCalloc(sdap_config->mappedQoS_FlowsToAdd, FlowsToAdd);
for (int j=0; j < drb->numQosFlow2Setup; j++) {
NR_QFI_t *qfi = calloc(1, sizeof(NR_QFI_t));
asn1cSequenceAdd(FlowsToAdd->list, NR_QFI_t, qfi);
*qfi = drb->qosFlows[j].fiveQI;
ASN_SEQUENCE_ADD(&sdap_config->mappedQoS_FlowsToAdd->list, qfi);
}
sdap_config->mappedQoS_FlowsToRelease = NULL;
// pdcp_Config
ie->reestablishPDCP = NULL;
ie->recoverPDCP = NULL;
NR_PDCP_Config_t *pdcp_config = calloc(1, sizeof(*pdcp_config));
memset(pdcp_config, 0, sizeof(*pdcp_config));
ie->pdcp_Config = pdcp_config;
pdcp_config->drb = calloc(1,sizeof(*pdcp_config->drb));
pdcp_config->drb->discardTimer = calloc(1, sizeof(*pdcp_config->drb->discardTimer));
*pdcp_config->drb->discardTimer = drb->discardTimer;
pdcp_config->drb->pdcp_SN_SizeUL = calloc(1, sizeof(*pdcp_config->drb->pdcp_SN_SizeUL));
*pdcp_config->drb->pdcp_SN_SizeUL = drb->pDCP_SN_Size_UL;
pdcp_config->drb->pdcp_SN_SizeDL = calloc(1, sizeof(*pdcp_config->drb->pdcp_SN_SizeDL));
*pdcp_config->drb->pdcp_SN_SizeDL = drb->pDCP_SN_Size_DL;
pdcp_config->drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
pdcp_config->drb->headerCompression.choice.notUsed = 0;
pdcp_config->drb->integrityProtection = NULL;
pdcp_config->drb->statusReportRequired = NULL;
pdcp_config->drb->outOfOrderDelivery = NULL;
asn1cCalloc(ie->pdcp_Config, pdcp_config);
asn1cCalloc(pdcp_config->drb, drbCfg);
asn1cCallocOne(drbCfg->discardTimer, drb->discardTimer);
asn1cCallocOne(drbCfg->pdcp_SN_SizeUL, drb->pDCP_SN_Size_UL);
asn1cCallocOne(drbCfg->pdcp_SN_SizeDL, drb->pDCP_SN_Size_DL);
drbCfg->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
drbCfg->headerCompression.choice.notUsed = 0;
drbCfg->integrityProtection = NULL;
drbCfg->statusReportRequired = NULL;
drbCfg->outOfOrderDelivery = NULL;
pdcp_config->moreThanOneRLC = NULL;
pdcp_config->t_Reordering = calloc(1, sizeof(*pdcp_config->t_Reordering));
......@@ -87,15 +79,13 @@ static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, pdu_se
if (pdu->integrityProtectionIndication == 0 || // Required
pdu->integrityProtectionIndication == 1) { // Preferred
pdcp_config->drb->integrityProtection = calloc(1, sizeof(*pdcp_config->drb->integrityProtection));
*pdcp_config->drb->integrityProtection = NR_PDCP_Config__drb__integrityProtection_enabled;
asn1cCallocOne(drbCfg->integrityProtection, NR_PDCP_Config__drb__integrityProtection_enabled);
}
if (pdu->confidentialityProtectionIndication == 0 || // Required
pdu->confidentialityProtectionIndication == 1) { // Preferred
pdcp_config->ext1 = calloc(1, sizeof(*pdcp_config->ext1));
pdcp_config->ext1->cipheringDisabled = calloc(1, sizeof(*pdcp_config->ext1->cipheringDisabled));
*pdcp_config->ext1->cipheringDisabled = NR_PDCP_Config__ext1__cipheringDisabled_true;
asn1cCalloc(pdcp_config->ext1, ext1);
asn1cCallocOne(ext1->cipheringDisabled, NR_PDCP_Config__ext1__cipheringDisabled_true);
}
}
}
......@@ -135,13 +125,9 @@ static int drb_config_N3gtpu_create(e1ap_bearer_setup_req_t * const req,
uint8_t *kUPenc = NULL;
uint8_t *kUPint = NULL;
nr_derive_key_up_enc(req->cipheringAlgorithm,
(uint8_t *)req->encryptionKey,
&kUPenc);
nr_derive_key(UP_ENC_ALG, req->cipheringAlgorithm, (uint8_t *)req->encryptionKey, &kUPenc);
nr_derive_key_up_int(req->integrityProtectionAlgorithm,
(uint8_t *)req->integrityProtectionKey,
&kUPint);
nr_derive_key(UP_INT_ALG, req->integrityProtectionAlgorithm, (uint8_t *)req->integrityProtectionKey, &kUPint);
nr_pdcp_e1_add_drbs(true, // set this to notify PDCP that his not UE
create_tunnel_req.ue_id,
......@@ -152,35 +138,32 @@ static int drb_config_N3gtpu_create(e1ap_bearer_setup_req_t * const req,
return ret;
}
void CUUP_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *const req, instance_t instance) {
void process_e1_bearer_context_setup_req(instance_t instance, e1ap_bearer_setup_req_t *const req)
{
e1ap_upcp_inst_t *inst = getCxtE1(instance);
AssertFatal(inst, "");
gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp_N3={0};
// GTP tunnel for UL
instance_t gtpInst = getCxtE1(UPtype, instance)->gtpInstN3;
drb_config_N3gtpu_create(req, &create_tunnel_resp_N3, gtpInst);
drb_config_N3gtpu_create(req, &create_tunnel_resp_N3, inst->gtpInstN3);
e1ap_bearer_setup_resp_t resp = {0};
MessageDef *msg = itti_alloc_new_message(TASK_CUCP_E1, 0, E1AP_BEARER_CONTEXT_SETUP_RESP);
e1ap_bearer_setup_resp_t *resp = &E1AP_BEARER_CONTEXT_SETUP_RESP(msg);
int remote_port = getCxtE1(UPtype, instance)->setupReq.remoteDUPort;
int remote_port = inst->setupReq.remoteDUPort;
in_addr_t my_addr;
inet_pton(AF_INET,
getCxtE1(UPtype, instance)->setupReq.CUUP_e1_ip_address.ipv4_address,
&my_addr);
inet_pton(AF_INET, inst->setupReq.CUUP_e1_ip_address.ipv4_address, &my_addr);
gtpInst = getCxtE1(UPtype, instance)->gtpInstF1U;
fill_e1ap_bearer_setup_resp(&resp, req, gtpInst, req->gNB_cu_cp_ue_id, remote_port, my_addr);
fill_e1ap_bearer_setup_resp(resp, req, inst->gtpInstF1U, req->gNB_cu_cp_ue_id, remote_port, my_addr);
resp.gNB_cu_cp_ue_id = req->gNB_cu_cp_ue_id;
resp.numPDUSessions = req->numPDUSessions;
resp->gNB_cu_cp_ue_id = req->gNB_cu_cp_ue_id;
resp->numPDUSessions = req->numPDUSessions;
for (int i=0; i < req->numPDUSessions; i++) {
pdu_session_setup_t *pduSetup = resp.pduSession + i;
pdu_session_setup_t *pduSetup = resp->pduSession + i;
pdu_session_to_setup_t *pdu2Setup = req->pduSession + i;
pduSetup->id = pdu2Setup->sessionId;
memcpy(&pduSetup->tlAddress,
&getCxtE1(UPtype, instance)->setupReq.IPv4AddressN3,
sizeof(in_addr_t));
memcpy(&pduSetup->tlAddress, &inst->setupReq.IPv4AddressN3, sizeof(in_addr_t));
pduSetup->teId = create_tunnel_resp_N3.gnb_NGu_teid[i];
pduSetup->numDRBSetup = pdu2Setup->numDRB2Setup;
......@@ -190,21 +173,23 @@ void CUUP_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *const req
pduSetup->numDRBFailed = 0;
}
e1apCUUP_send_BEARER_CONTEXT_SETUP_RESPONSE(instance, &resp);
e1apCUUP_send_BEARER_CONTEXT_SETUP_RESPONSE(inst, resp);
}
void CUUP_process_bearer_context_mod_req(e1ap_bearer_setup_req_t *const req, instance_t instance) {
instance_t gtpInst = getCxtE1(UPtype, instance)->gtpInstF1U;
CU_update_UP_DL_tunnel(req, gtpInst, req->gNB_cu_cp_ue_id);
void CUUP_process_bearer_context_mod_req(instance_t instance, e1ap_bearer_setup_req_t *const req)
{
e1ap_upcp_inst_t *inst = getCxtE1(instance);
AssertFatal(inst, "");
// assume we receive modification of F1-U but it is wrong, we can also get modification of N3 when HO will occur
CU_update_UP_DL_tunnel(req, inst->gtpInstF1U, req->gNB_cu_cp_ue_id);
// TODO: send bearer cxt mod response
}
void CUUP_process_bearer_release_command(e1ap_bearer_release_cmd_t *const cmd, instance_t instance) {
instance_t gtpInst = getCxtE1(UPtype, instance)->gtpInstN3;
newGtpuDeleteAllTunnels(gtpInst, cmd->gNB_cu_up_ue_id);
gtpInst = getCxtE1(UPtype, instance)->gtpInstF1U;
newGtpuDeleteAllTunnels(gtpInst, cmd->gNB_cu_up_ue_id);
e1apCUUP_send_BEARER_CONTEXT_RELEASE_COMPLETE(instance, cmd);
void CUUP_process_bearer_release_command(instance_t instance, e1ap_bearer_release_cmd_t *const cmd)
{
e1ap_upcp_inst_t *inst = getCxtE1(instance);
AssertFatal(inst, "");
newGtpuDeleteAllTunnels(inst->gtpInstN3, cmd->gNB_cu_up_ue_id);
newGtpuDeleteAllTunnels(inst->gtpInstF1U, cmd->gNB_cu_up_ue_id);
e1apCUUP_send_BEARER_CONTEXT_RELEASE_COMPLETE(inst, cmd);
}
......@@ -26,10 +26,10 @@
#include "platform_types.h"
#include "openair2/COMMON/e1ap_messages_types.h"
#include "openair2/E1AP/e1ap_common.h"
void cuup_init_n3(instance_t instance);
void process_e1_bearer_context_setup_req(instance_t, e1ap_bearer_setup_req_t *const req);
void CUUP_process_bearer_context_mod_req(instance_t, e1ap_bearer_setup_req_t *const req);
void CUUP_process_e1_bearer_context_setup_req(e1ap_bearer_setup_req_t *const req, instance_t instance);
void CUUP_process_bearer_context_mod_req(e1ap_bearer_setup_req_t *const req, instance_t instance);
void CUUP_process_bearer_release_command(e1ap_bearer_release_cmd_t *const cmd, instance_t instance);
void CUUP_process_bearer_release_command(instance_t, e1ap_bearer_release_cmd_t *const cmd);
#endif
......@@ -29,40 +29,28 @@
#include "common/openairinterface5g_limits.h"
#include "common/utils/ocp_itti/intertask_interface.h"
static e1ap_upcp_inst_t *e1ap_cp_inst[NUMBER_OF_gNB_MAX] = {0};
static e1ap_upcp_inst_t *e1ap_up_inst[NUMBER_OF_gNB_MAX] = {0};
static e1ap_upcp_inst_t *e1ap_inst[NUMBER_OF_gNB_MAX] = {0};
e1ap_upcp_inst_t *getCxtE1(E1_t type, instance_t instance) {
AssertFatal( instance < sizeofArray(e1ap_cp_inst), "instance exceeds limit\n");
return type == UPtype ? e1ap_up_inst[instance] : e1ap_cp_inst[instance];
e1ap_upcp_inst_t *getCxtE1(instance_t instance)
{
AssertFatal(instance < sizeofArray(e1ap_inst), "instance exceeds limit\n");
return e1ap_inst[instance];
}
int e1ap_assoc_id(E1_t type, instance_t instance) {
if (type == CPtype) {
AssertFatal(e1ap_cp_inst[instance] != NULL, "Trying to access uninitiated instance of CUCP\n");
return e1ap_cp_inst[instance]->setupReq.assoc_id;
} else if (type == UPtype) {
AssertFatal(e1ap_up_inst[instance] != NULL, "Trying to access uninitiated instance of CUUP\n");
return e1ap_up_inst[instance]->setupReq.assoc_id;
} else {
AssertFatal(false, "Unknown CU type\n");
}
return -1;
AssertFatal(e1ap_inst[instance] != NULL, "Trying to access uninitiated instance of CUCP\n");
return e1ap_inst[instance]->setupReq.assoc_id;
}
void createE1inst(E1_t type, instance_t instance, e1ap_setup_req_t *req) {
if (type == CPtype) {
AssertFatal(e1ap_cp_inst[instance] == NULL, "Double call to E1 CP instance %d\n", (int)instance);
e1ap_cp_inst[instance] = (e1ap_upcp_inst_t *) calloc(1, sizeof(e1ap_upcp_inst_t));
} else if (type == UPtype) {
AssertFatal(e1ap_up_inst[instance] == NULL, "Double call to E1 UP instance %d\n", (int)instance);
e1ap_up_inst[instance] = (e1ap_upcp_inst_t *) calloc(1, sizeof(e1ap_upcp_inst_t));
memcpy(&e1ap_up_inst[instance]->setupReq, req, sizeof(e1ap_setup_req_t));
e1ap_up_inst[instance]->gtpInstN3 = -1;
e1ap_up_inst[instance]->gtpInstF1U = -1;
} else {
AssertFatal(false, "Unknown CU type\n");
}
AssertFatal(e1ap_inst[instance] == NULL, "Double call to E1 instance %d\n", (int)instance);
e1ap_inst[instance] = calloc(1, sizeof(e1ap_upcp_inst_t));
e1ap_inst[instance]->type = type;
e1ap_inst[instance]->instance = instance;
if (req)
memcpy(&e1ap_inst[instance]->setupReq, req, sizeof(*req));
e1ap_inst[instance]->gtpInstN3 = -1;
e1ap_inst[instance]->gtpInstF1U = -1;
}
E1AP_TransactionID_t transacID[E1AP_MAX_NUM_TRANSAC_IDS] = {0};
......@@ -207,7 +195,8 @@ int e1ap_decode_pdu(E1AP_E1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t
return -1;
}
int e1ap_encode_send(E1_t type, instance_t instance, E1AP_E1AP_PDU_t *pdu, uint16_t stream, const char *func) {
int e1ap_encode_send(E1_t type, e1ap_setup_req_t *setupReq, E1AP_E1AP_PDU_t *pdu, uint16_t stream, const char *func)
{
DevAssert(pdu != NULL);
if (asn1_xer_print) {
......@@ -234,14 +223,13 @@ int e1ap_encode_send(E1_t type, instance_t instance, E1AP_E1AP_PDU_t *pdu, uint1
} else {
MessageDef *message = itti_alloc_new_message((type==CPtype)?TASK_CUCP_E1:TASK_CUUP_E1, 0, SCTP_DATA_REQ);
sctp_data_req_t *s = &message->ittiMsg.sctp_data_req;
s->assoc_id = e1ap_assoc_id(type, instance);
s->assoc_id = setupReq->assoc_id;
s->buffer = buffer;
s->buffer_length = encoded;
s->stream = stream;
LOG_I(E1AP, "%s: Sending ITTI message to SCTP Task\n", func);
itti_send_msg_to_task(TASK_SCTP, instance, message);
itti_send_msg_to_task(TASK_SCTP, 0 /*unused by callee*/, message);
}
return encoded;
}
......@@ -26,8 +26,13 @@
#include "openair2/COMMON/e1ap_messages_types.h"
#include "e1ap_asnc.h"
#include "openair2/COMMON/sctp_messages_types.h"
#include "common/ngran_types.h"
typedef struct e1ap_upcp_inst_s {
bool incoming_sock;
instance_t instance;
bool same_process;
E1_t type;
enum sctp_state_e sockState;
uint32_t assoc_id;
instance_t gtpInstN3;
......@@ -37,13 +42,11 @@ typedef struct e1ap_upcp_inst_s {
e1ap_bearer_setup_resp_t bearerSetupResp;
} e1ap_upcp_inst_t;
typedef enum { CPtype = 0, UPtype } E1_t;
extern int asn1_xer_print;
int e1ap_decode_pdu(E1AP_E1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t length);
e1ap_upcp_inst_t *getCxtE1(E1_t type, instance_t instance);
e1ap_upcp_inst_t *getCxtE1(instance_t instance);
E1AP_TransactionID_t E1AP_get_next_transaction_identifier();
......@@ -53,7 +56,7 @@ bool check_transac_id(E1AP_TransactionID_t id, int *freeIdx);
int e1ap_assoc_id(E1_t type, instance_t instance);
int e1ap_encode_send(E1_t type, instance_t instance, E1AP_E1AP_PDU_t *pdu, uint16_t stream, const char *func);
int e1ap_encode_send(E1_t type, e1ap_setup_req_t *setupReq, E1AP_E1AP_PDU_t *pdu, uint16_t stream, const char *func);
void e1ap_common_init();
......
......@@ -30,7 +30,7 @@
#include "openair2/GNB_APP/gnb_paramdef.h"
#include "openair3/ocp-gtpu/gtp_itf.h"
MessageDef *RCconfig_NR_CU_E1(void)
MessageDef *RCconfig_NR_CU_E1(bool separate_CUUP_process)
{
MessageDef *msgConfig = itti_alloc_new_message(TASK_GNB_APP, 0, E1AP_SETUP_REQ);
if (!msgConfig)
......@@ -73,21 +73,23 @@ MessageDef *RCconfig_NR_CU_E1(void)
e1Setup->plmns[I].mnc = *PLMNParamList.paramarray[I][GNB_MNC_DIGIT_LENGTH].u8ptr;
}
strcpy(e1Setup->CUCP_e1_ip_address.ipv4_address, *(GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_IPV4_ADDRESS_CUCP].strptr));
e1Setup->CUCP_e1_ip_address.ipv4 = 1;
e1Setup->port_cucp = *GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_PORT_CUCP].uptr;
strcpy(e1Setup->CUUP_e1_ip_address.ipv4_address, *(GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_IPV4_ADDRESS_CUUP].strptr));
e1Setup->CUUP_e1_ip_address.ipv4 = 1;
e1Setup->port_cuup = *GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_PORT_CUUP].uptr;
e1Setup->remoteDUPort = e1Setup->port_cuup; // set same as local port for now TODO: get from F1 config
if (separate_CUUP_process) {
strcpy(e1Setup->CUCP_e1_ip_address.ipv4_address, *(GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_IPV4_ADDRESS_CUCP].strptr));
e1Setup->CUCP_e1_ip_address.ipv4 = 1;
e1Setup->port_cucp = *GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_PORT_CUCP].uptr;
strcpy(e1Setup->CUUP_e1_ip_address.ipv4_address, *(GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_IPV4_ADDRESS_CUUP].strptr));
e1Setup->CUUP_e1_ip_address.ipv4 = 1;
e1Setup->port_cuup = *GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_PORT_CUUP].uptr;
e1Setup->remoteDUPort = e1Setup->port_cuup; // set same as local port for now TODO: get from F1 config
e1Setup->cn_support = *GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_CN_SUPPORT].uptr;
}
char N3Addr[64];
int N3Port;
if (!get_NGU_S1U_addr(N3Addr, &N3Port)) {
;
inet_pton(AF_INET, N3Addr, &e1Setup->IPv4AddressN3);
e1Setup->portN3 = N3Port;
}
e1Setup->cn_support = *GNBE1ParamList.paramarray[0][GNB_CONFIG_E1_CN_SUPPORT].uptr;
}
return msgConfig;
}
......@@ -110,15 +110,15 @@ void *F1AP_DU_task(void *arg) {
LOG_I(F1AP, "DU Task Received %s for instance %ld\n",
ITTI_MSG_NAME(msg),myInstance);
switch (ITTI_MSG_ID(msg)) {
case F1AP_SETUP_REQ:
case F1AP_SETUP_REQ: {
// this is not a true F1 message, but rather an ITTI message sent by enb_app
// 1. save the itti msg so that you can use it to sen f1ap_setup_req, fill the f1ap_setup_req message,
// 2. store the message in f1ap context, that is also stored in RC
// 2. send a sctp_association req
f1ap_setup_req_t *msgSetup=&F1AP_SETUP_REQ(msg);
f1ap_setup_req_t *msgSetup = &F1AP_SETUP_REQ(msg);
createF1inst(false, myInstance, msgSetup);
du_task_send_sctp_association_req(myInstance,msgSetup);
break;
du_task_send_sctp_association_req(myInstance, msgSetup);
} break;
case F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE:
DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_ORIGIN_INSTANCE(msg),
......@@ -144,14 +144,10 @@ void *F1AP_DU_task(void *arg) {
break;
case F1AP_INITIAL_UL_RRC_MESSAGE: // from rrc
{
f1ap_initial_ul_rrc_message_t *msgRrc = &F1AP_INITIAL_UL_RRC_MESSAGE(msg);
DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(0,0,0,msgRrc->crnti,
msgRrc->rrc_container,
msgRrc->rrc_container_length,
msgRrc->du2cu_rrc_container,
msgRrc->du2cu_rrc_container_length
);
break;
DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(0, 0, 0, msgRrc->crnti, msgRrc->rrc_container, msgRrc->rrc_container_length, msgRrc->du2cu_rrc_container, msgRrc->du2cu_rrc_container_length);
} break;
case F1AP_UL_RRC_MESSAGE: // to rrc
if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) {
......
......@@ -1061,35 +1061,30 @@ void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid)
drb_ToAddMod->reestablishPDCP = NULL;
drb_ToAddMod->recoverPDCP = NULL;
drb_ToAddMod->pdcp_Config = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config));
drb_ToAddMod->pdcp_Config->drb = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb));
drb_ToAddMod->pdcp_Config->drb->discardTimer = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->discardTimer));
*drb_ToAddMod->pdcp_Config->drb->discardTimer=NR_PDCP_Config__drb__discardTimer_infinity;
drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL));
*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits;
drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL));
*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits;
drb_ToAddMod->pdcp_Config->drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
drb_ToAddMod->pdcp_Config->drb->headerCompression.choice.notUsed = 0;
drb_ToAddMod->pdcp_Config->drb->integrityProtection=NULL;
drb_ToAddMod->pdcp_Config->drb->statusReportRequired=NULL;
drb_ToAddMod->pdcp_Config->drb->outOfOrderDelivery=NULL;
asn1cCalloc(drb_ToAddMod->pdcp_Config->drb, drb);
asn1cCallocOne(drb->discardTimer, NR_PDCP_Config__drb__discardTimer_infinity);
asn1cCallocOne(drb->pdcp_SN_SizeUL, NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits);
asn1cCallocOne(drb->pdcp_SN_SizeDL, NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits);
drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
drb->headerCompression.choice.notUsed = 0;
drb->integrityProtection = NULL;
drb->statusReportRequired = NULL;
drb->outOfOrderDelivery = NULL;
drb_ToAddMod->pdcp_Config->moreThanOneRLC = NULL;
drb_ToAddMod->pdcp_Config->t_Reordering = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->t_Reordering));
*drb_ToAddMod->pdcp_Config->t_Reordering = NR_PDCP_Config__t_Reordering_ms0;
asn1cCallocOne(drb_ToAddMod->pdcp_Config->t_Reordering, NR_PDCP_Config__t_Reordering_ms0);
drb_ToAddMod->pdcp_Config->ext1 = NULL;
asn1cSeqAdd(&rbconfig->drb_ToAddModList->list,drb_ToAddMod);
rbconfig->drb_ToReleaseList = NULL;
rbconfig->securityConfig = calloc(1,sizeof(*rbconfig->securityConfig));
rbconfig->securityConfig->securityAlgorithmConfig = calloc(1,sizeof(*rbconfig->securityConfig->securityAlgorithmConfig));
rbconfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm = NR_CipheringAlgorithm_nea0;
rbconfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm=NULL;
rbconfig->securityConfig->keyToUse = calloc(1,sizeof(*rbconfig->securityConfig->keyToUse));
*rbconfig->securityConfig->keyToUse = NR_SecurityConfig__keyToUse_master;
asn1cCalloc(rbconfig->securityConfig, secConf);
asn1cCalloc(secConf->securityAlgorithmConfig, secConfAlgo);
secConfAlgo->cipheringAlgorithm = NR_CipheringAlgorithm_nea0;
secConfAlgo->integrityProtAlgorithm = NULL;
asn1cCallocOne(secConf->keyToUse, NR_SecurityConfig__keyToUse_master);
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)rbconfig);
......
......@@ -37,7 +37,7 @@
#include "rrc_gNB_GTPV1U.h"
#include "common/ran_context.h"
#include "openair2/F1AP/f1ap_common.h"
#include "openair2/E1AP/e1ap_common.h"
extern RAN_CONTEXT_t RC;
void fill_e1ap_bearer_setup_resp(e1ap_bearer_setup_resp_t *resp,
......@@ -122,9 +122,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
create_tunnel_req.num_tunnels = ue_context_p->ue_context.nb_of_pdusessions;
create_tunnel_req.ue_id = ue_context_p->ue_context.rnti;
int ret = gtpv1u_create_ngu_tunnel(instance,
&create_tunnel_req,
&create_tunnel_resp);
int ret = gtpv1u_create_ngu_tunnel(getCxtE1(instance)->gtpInstN3, &create_tunnel_req, &create_tunnel_resp);
if (ret != 0) {
LOG_E(NR_RRC,"rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ : gtpv1u_create_ngu_tunnel failed,start to release UE rnti %ld\n",
......@@ -177,6 +175,21 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
return ret;
}
static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_ToAddModList_t *SRB_configList, uint8_t xid)
{
NR_SRB_ToAddModList_t **SRB_configList2 = NULL;
SRB_configList2 = &ue->SRB_configList2[xid];
if (*SRB_configList2 == NULL) {
*SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
NR_SRB_ToAddMod_t *SRB2_config = CALLOC(1, sizeof(*SRB2_config));
SRB2_config->srb_Identity = 2;
asn1cSeqAdd(&(*SRB_configList2)->list, SRB2_config);
asn1cSeqAdd(&SRB_configList->list, SRB2_config);
}
return SRB_configList2;
}
static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)], req->rnti);
protocol_ctxt_t ctxt = {0};
......@@ -187,12 +200,7 @@ static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const
gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id];
NR_SRB_ToAddModList_t **SRB_configList2 = generateSRB2_confList(&ue_context_p->ue_context, ue_context_p->ue_context.SRB_configList, 1);
// GTP tunnel for UL
int ret = drb_config_gtpu_create(&ctxt,
ue_context_p,
req,
ue_context_p->ue_context.DRB_configList,
*SRB_configList2,
rrc->gtpInstN3);
int ret = drb_config_gtpu_create(&ctxt, ue_context_p, req, ue_context_p->ue_context.DRB_configList, *SRB_configList2, rrc->e1_inst);
if (ret < 0) AssertFatal(false, "Unable to configure DRB or to create GTP Tunnel\n");
if(!NODE_IS_CU(RC.nrrrc[ctxt.module_id]->node_type)) {
......
......@@ -417,7 +417,7 @@ typedef struct rrc_gNB_ue_context_s {
// 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 S1AP */
/* UE id for initial connection to NGAP */
struct gNB_RRC_UE_s ue_context;
} rrc_gNB_ue_context_t;
......@@ -506,7 +506,7 @@ typedef struct gNB_RRC_INST_s {
gNB_RrcConfigurationReq configuration;
// gNB N3 GTPU instance
instance_t gtpInstN3;
instance_t e1_inst;
// other PLMN parameters
/// Mobile country code
......
......@@ -247,8 +247,6 @@ static void openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_Rrc
rrc->ngap_id2_ngap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
rrc->configuration = *configuration;
rrc->carrier.servingcellconfigcommon = configuration->scc;
extern instance_t *N3GTPUInst;
N3GTPUInst = &rrc->gtpInstN3;
rrc->carrier.servingcellconfig = configuration->scd;
nr_rrc_config_ul_tda(configuration->scc,configuration->minRXTXTIME);
/// System Information INIT
......
......@@ -22,32 +22,6 @@
#include "rrc_gNB_radio_bearers.h"
#include "oai_asn1.h"
NR_SRB_ToAddMod_t *generateSRB2() {
NR_SRB_ToAddMod_t *SRB2_config = NULL;
SRB2_config = CALLOC(1, sizeof(*SRB2_config));
SRB2_config->srb_Identity = 2;
return SRB2_config;
}
NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue,
NR_SRB_ToAddModList_t *SRB_configList,
uint8_t xid) {
NR_SRB_ToAddModList_t **SRB_configList2 = NULL;
SRB_configList2 = &ue->SRB_configList2[xid];
if (*SRB_configList2 == NULL) {
*SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
memset(*SRB_configList2, 0, sizeof(**SRB_configList2));
NR_SRB_ToAddMod_t *SRB2_config = generateSRB2();
asn1cSeqAdd(&(*SRB_configList2)->list, SRB2_config);
asn1cSeqAdd(&SRB_configList->list, SRB2_config);
}
return SRB_configList2;
}
NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *ue,
uint8_t drb_id,
const pdu_session_param_t *pduSession,
......
......@@ -35,10 +35,6 @@
#define GBR_FLOW (1)
#define NONGBR_FLOW (0)
NR_SRB_ToAddMod_t *generateSRB2(void);
NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue,
NR_SRB_ToAddModList_t *SRB_configList,
uint8_t xid);
NR_DRB_ToAddMod_t *generateDRB(gNB_RRC_UE_t *rrc_ue,
uint8_t drb_id,
const pdu_session_param_t *pduSession,
......
......@@ -219,6 +219,7 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
req->ue_id = ue_id;
req->bearer_id = pdusession_id;
LOG_D(SDAP, "%s() sending message to gtp size %d\n", __func__, size-offset);
// very very dirty hack gloabl var N3GTPUInst
itti_send_msg_to_task(TASK_GTPV1_U, *N3GTPUInst, message_p);
} else { //nrUE
/*
......
......@@ -1046,14 +1046,14 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
break;
default:
NGAP_ERROR("could not found protocolIEs id %ld\n", pdusessionTransfer_ies->id);
NGAP_ERROR("Not found protocolIEs id %ld\n", pdusessionTransfer_ies->id);
return -1;
}
}
} /* for i... */
} else {/* ie != NULL */
NGAP_ERROR("could not found NGAP_ProtocolIE_ID_id_PDUSessionResourceSetupListCxtReq\n");
NGAP_ERROR("Not found NGAP_ProtocolIE_ID_id_PDUSessionResourceSetupListCxtReq\n");
}
/* id-AllowedNSSAI */
......
......@@ -617,10 +617,7 @@ sctp_handle_new_association_req(
}
//------------------------------------------------------------------------------
static void sctp_send_data(
instance_t instance,
task_id_t task_id,
sctp_data_req_t *sctp_data_req_p)
static void sctp_send_data(sctp_data_req_t *sctp_data_req_p)
{
struct sctp_cnx_list_elm_s *sctp_cnx = NULL;
......@@ -660,10 +657,7 @@ static void sctp_send_data(
}
//------------------------------------------------------------------------------
static int sctp_close_association(
const instance_t instance,
const task_id_t requestor,
sctp_close_association_t *close_association_p)
static int sctp_close_association(sctp_close_association_t *close_association_p)
{
struct sctp_cnx_list_elm_s *sctp_cnx = NULL;
......@@ -1152,10 +1146,8 @@ static void sctp_eNB_process_itti_msg()
break;
case SCTP_CLOSE_ASSOCIATION:
sctp_close_association(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
ITTI_MSG_ORIGIN_ID(received_msg),
&received_msg->ittiMsg.sctp_close_association);
break;
sctp_close_association(&received_msg->ittiMsg.sctp_close_association);
break;
case TERMINATE_MESSAGE:
SCTP_WARN("*** Exiting SCTP thread\n");
......@@ -1163,9 +1155,7 @@ static void sctp_eNB_process_itti_msg()
break;
case SCTP_DATA_REQ: {
sctp_send_data(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
ITTI_MSG_ORIGIN_ID(received_msg),
&received_msg->ittiMsg.sctp_data_req);
sctp_send_data(&received_msg->ittiMsg.sctp_data_req);
}
break;
......
......@@ -94,7 +94,6 @@ typedef struct Gtpv1uExtHeader {
#define GTP_END_MARKER (254)
#define GTP_GPDU (255)
typedef struct gtpv1u_bearer_s {
/* TEID used in dl and ul */
teid_t teid_incoming; ///< eNB TEID
......@@ -127,8 +126,7 @@ class gtpEndPoint {
uint8_t foundAddr[20];
int foundAddrLen;
int ipVersion;
map<uint64_t,teidData_t> ue2te_mapping;
map<uint64_t,ueidData_t> te2ue_mapping;
map<uint64_t, teidData_t> ue2te_mapping;
// we use the same port number for source and destination address
// this allow using non standard gtp port number (different from 2152)
// and so, for example tu run 4G and 5G cores on one system
......@@ -142,7 +140,7 @@ class gtpEndPoints {
pthread_mutex_t gtp_lock=PTHREAD_MUTEX_INITIALIZER;
// the instance id will be the Linux socket handler, as this is uniq
map<uint64_t, gtpEndPoint> instances;
map<uint64_t, ueidData_t> te2ue_mapping;
gtpEndPoints() {
unsigned int seed;
fill_random(&seed, sizeof(seed));
......@@ -593,22 +591,17 @@ teid_t newGtpuCreateTunnel(instance_t instance,
teid_t incoming_teid=gtpv1uNewTeid();
while ( inst->te2ue_mapping.find(incoming_teid) != inst->te2ue_mapping.end() ) {
while (globGtp.te2ue_mapping.find(incoming_teid) != globGtp.te2ue_mapping.end()) {
LOG_W(GTPU, "[%ld] generated a random Teid that exists, re-generating (%x)\n", instance, incoming_teid);
incoming_teid=gtpv1uNewTeid();
};
inst->te2ue_mapping[incoming_teid].ue_id=ue_id;
inst->te2ue_mapping[incoming_teid].incoming_rb_id= incoming_bearer_id;
inst->te2ue_mapping[incoming_teid].outgoing_teid= outgoing_teid;
inst->te2ue_mapping[incoming_teid].callBack=callBack;
inst->te2ue_mapping[incoming_teid].callBackSDAP = callBackSDAP;
inst->te2ue_mapping[incoming_teid].pdusession_id = (uint8_t)outgoing_bearer_id;
globGtp.te2ue_mapping[incoming_teid].ue_id = ue_id;
globGtp.te2ue_mapping[incoming_teid].incoming_rb_id = incoming_bearer_id;
globGtp.te2ue_mapping[incoming_teid].outgoing_teid = outgoing_teid;
globGtp.te2ue_mapping[incoming_teid].callBack = callBack;
globGtp.te2ue_mapping[incoming_teid].callBackSDAP = callBackSDAP;
globGtp.te2ue_mapping[incoming_teid].pdusession_id = (uint8_t)outgoing_bearer_id;
gtpv1u_bearer_t *tmp=&inst->ue2te_mapping[ue_id].bearers[outgoing_bearer_id];
......@@ -641,13 +634,14 @@ teid_t newGtpuCreateTunnel(instance_t instance,
pthread_mutex_unlock(&globGtp.gtp_lock);
char ip4[INET_ADDRSTRLEN];
char ip6[INET6_ADDRSTRLEN];
LOG_I(GTPU, "[%ld] Created tunnel for UE ID %lu, teid for DL: %x, teid for UL %x to remote IPv4: %s, IPv6 %s\n",
LOG_I(GTPU,
"[%ld] Created tunnel for UE ID %lu, teid for incoming: %x, teid for outgoing %x to remote IPv4: %s, IPv6 %s\n",
instance,
ue_id,
tmp->teid_incoming,
tmp->teid_outgoing,
inet_ntop(AF_INET,(void *)&tmp->outgoing_ip_addr, ip4,INET_ADDRSTRLEN ),
inet_ntop(AF_INET6,(void *)&tmp->outgoing_ip6_addr.s6_addr, ip6, INET6_ADDRSTRLEN));
inet_ntop(AF_INET, (void *)&tmp->outgoing_ip_addr, ip4, INET_ADDRSTRLEN),
inet_ntop(AF_INET6, (void *)&tmp->outgoing_ip6_addr.s6_addr, ip6, INET6_ADDRSTRLEN));
return incoming_teid;
}
......@@ -795,7 +789,7 @@ int newGtpuDeleteAllTunnels(instance_t instance, ue_id_t ue_id) {
for (auto j=ptrUe->second.bearers.begin();
j!=ptrUe->second.bearers.end();
++j) {
inst->te2ue_mapping.erase(j->second.teid_incoming);
globGtp.te2ue_mapping.erase(j->second.teid_incoming);
nb++;
}
......@@ -826,7 +820,7 @@ int newGtpuDeleteTunnels(instance_t instance, ue_id_t ue_id, int nbTunnels, pdus
if ( ptr2 == ptrUe->second.bearers.end() ) {
LOG_E(GTPU,"[%ld] GTP-U instance: delete of not existing tunnel UE ID:RAB: %ld/%x\n", instance, ue_id, pdusession_id[i]);
} else {
inst->te2ue_mapping.erase(ptr2->second.teid_incoming);
globGtp.te2ue_mapping.erase(ptr2->second.teid_incoming);
nb++;
}
}
......@@ -913,9 +907,9 @@ static int Gtpv1uHandleEndMarker(int h,
// the socket Linux file handler is the instance id
getInstRetInt(h);
auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid));
auto tunnel = globGtp.te2ue_mapping.find(ntohl(msgHdr->teid));
if ( tunnel == inst->te2ue_mapping.end() ) {
if (tunnel == globGtp.te2ue_mapping.end()) {
LOG_E(GTPU,"[%d] Received a incoming packet on unknown teid (%x) Dropping!\n", h, msgHdr->teid);
pthread_mutex_unlock(&globGtp.gtp_lock);
return GTPNOK;
......@@ -973,10 +967,9 @@ static int Gtpv1uHandleGpdu(int h,
pthread_mutex_lock(&globGtp.gtp_lock);
// the socket Linux file handler is the instance id
getInstRetInt(h);
auto tunnel = globGtp.te2ue_mapping.find(ntohl(msgHdr->teid));
auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid));
if ( tunnel == inst->te2ue_mapping.end() ) {
if (tunnel == globGtp.te2ue_mapping.end()) {
LOG_E(GTPU,"[%d] Received a incoming packet on unknown teid (%x) Dropping!\n", h, ntohl(msgHdr->teid));
pthread_mutex_unlock(&globGtp.gtp_lock);
return GTPNOK;
......@@ -1143,10 +1136,7 @@ static int Gtpv1uHandleGpdu(int h,
* according to TS 38.425: Fig. 5.5.2.2-1 and section 5.5.3.24*/
extensionHeader->length = 1+sizeof(DlDataDeliveryStatus_flagsT)+3+1+1;
gtpv1uCreateAndSendMsg(
h, peerIp, peerPort, GTP_GPDU,
inst->te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid,
NULL, 0, false, false, 0, 0, NR_RAN_CONTAINER,
extensionHeader->buffer, extensionHeader->length);
h, peerIp, peerPort, GTP_GPDU, globGtp.te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid, NULL, 0, false, false, 0, 0, NR_RAN_CONTAINER, extensionHeader->buffer, extensionHeader->length);
}
LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", 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