Commit c19bdb77 authored by Robert Schmidt's avatar Robert Schmidt

add UE Context Setup Req at CU/DU

- add message sender (CU) + handler (CU) and fill with data from ITTI message
- add PLMNID_TO_MCC_MNC and BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4 macros
- correct TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING:
  change name to TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING, make it send 4B, not 5
parent d9661177
......@@ -39,6 +39,7 @@ MESSAGE_DEF(F1AP_UL_RRC_MESSAGE , MESSAGE_PRIORITY_MED, f1ap_ul_r
/* RRC -> F1AP messages */
MESSAGE_DEF(F1AP_DL_RRC_MESSAGE , MESSAGE_PRIORITY_MED, f1ap_dl_rrc_message_t , f1ap_dl_rrc_message )
//MESSAGE_DEF(F1AP_INITIAL_CONTEXT_SETUP_REQ , MESSAGE_PRIORITY_MED, f1ap_initial_context_setup_req_t , f1ap_initial_context_setup_req )
MESSAGE_DEF(F1AP_UE_CONTEXT_SETUP_REQ, MESSAGE_PRIORITY_MED, f1ap_ue_context_setup_req_t, f1ap_ue_context_setup_req)
......
......@@ -22,6 +22,8 @@
#ifndef F1AP_MESSAGES_TYPES_H_
#define F1AP_MESSAGES_TYPES_H_
#include "rlc.h"
//-------------------------------------------------------------------------------------------//
// Defines to access message fields.
......@@ -33,6 +35,7 @@
#define F1AP_INITIAL_UL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_initial_ul_rrc_message
#define F1AP_UL_RRC_MESSAGE(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ul_rrc_message
#define F1AP_UE_CONTEXT_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_setup_req
#define F1AP_UE_CONTEXT_RELEASE_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_release_resp
#define F1AP_UE_CONTEXT_MODIFICATION_RESP(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_resp
#define F1AP_UE_CONTEXT_MODIFICATION_FAIL(mSGpTR) (mSGpTR)->ittiMsg.f1ap_ue_context_modification_fail
......@@ -249,8 +252,31 @@ typedef struct f1ap_ul_rrc_message_s {
int rrc_container_length;
} f1ap_ul_rrc_message_t;
/*typedef struct f1ap_ue_context_setup_req_s {
} f1ap_ue_context_setup_req_t;*/
typedef struct f1ap_up_tnl_s {
in_addr_t tl_address; // currently only IPv4 supported
uint32_t gtp_teid;
} f1ap_up_tnl_t;
typedef struct f1ap_drb_to_be_setup_s {
uint8_t drb_id;
f1ap_up_tnl_t up_ul_tnl[2];
uint8_t up_ul_tnl_length;
rlc_mode_t rlc_mode;
} f1ap_drb_to_be_setup_t;
typedef struct f1ap_ue_context_setup_req_s {
uint32_t gNB_CU_ue_id;
uint32_t *gNB_DU_ue_id;
// SpCell Info
uint16_t mcc;
uint16_t mnc;
uint8_t mnc_digit_length;
uint64_t nr_cellid;
uint32_t servCellId;
uint8_t *cu_to_du_rrc_information;
uint8_t cu_to_du_rrc_information_length;
f1ap_drb_to_be_setup_t *drbs_to_be_setup;
uint8_t drbs_to_be_setup_length;
} f1ap_ue_context_setup_req_t;
#endif /* F1AP_MESSAGES_TYPES_H_ */
......@@ -633,12 +633,12 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, module_id_t du_mod_
F1AP_CP_TransportLayerAddress_t transportLayerAddress;
memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t));
transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address;
TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address);
// memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t));
// transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port;
// transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t));
// TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address);
// TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address);
gnb_cu_tnl_association_to_add_item.tNLAssociationTransportLayerAddress = transportLayerAddress;
......@@ -680,12 +680,12 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, module_id_t du_mod_
F1AP_CP_TransportLayerAddress_t transportLayerAddress;
memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t));
transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address;
TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address);
// memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t));
// transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port;
// transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t));
// TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address);
// TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address);
gnb_cu_tnl_association_to_remove_item.tNLAssociationTransportLayerAddress = transportLayerAddress;
......@@ -722,12 +722,12 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, module_id_t du_mod_
F1AP_CP_TransportLayerAddress_t transportLayerAddress;
memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t));
transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address;
TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address);
// memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t));
// transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port;
// transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t));
// TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address);
// TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address);
gnb_cu_tnl_association_to_update_item.tNLAssociationTransportLayerAddress = transportLayerAddress;
......
......@@ -36,7 +36,8 @@
/*
* UE Context Setup
*/
int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance);
int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
f1ap_ue_context_setup_req_t *f1ap_ue_context_setup_req);
int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance,
uint32_t assoc_id,
......
......@@ -41,8 +41,91 @@ extern f1ap_setup_req_t *f1ap_du_data;
int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
uint32_t assoc_id,
uint32_t stream,
F1AP_F1AP_PDU_t *pdu) {
AssertFatal(1==0,"Not implemented yet\n");
F1AP_F1AP_PDU_t *pdu)
{
MessageDef *msg_p; // message to RRC
F1AP_UEContextSetupRequest_t *container;
F1AP_UEContextSetupRequestIEs_t *ie;
int i;
DevAssert(pdu);
msg_p = itti_alloc_new_message(TASK_DU_F1, F1AP_UE_CONTEXT_SETUP_REQ);
f1ap_ue_context_setup_req_t *f1ap_ue_context_setup_req;
f1ap_ue_context_setup_req = &F1AP_UE_CONTEXT_SETUP_REQ(msg_p);
container = &pdu->choice.initiatingMessage->value.choice.UEContextSetupRequest;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
f1ap_ue_context_setup_req->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, false);
if (ie) {
f1ap_ue_context_setup_req->gNB_DU_ue_id = malloc(sizeof(uint32_t));
if (f1ap_ue_context_setup_req->gNB_DU_ue_id)
*f1ap_ue_context_setup_req->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
} else {
f1ap_ue_context_setup_req->gNB_DU_ue_id = NULL;
}
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_SpCell_ID, true);
PLMNID_TO_MCC_MNC(&ie->value.choice.NRCGI.pLMN_Identity,
f1ap_ue_context_setup_req->mcc,
f1ap_ue_context_setup_req->mnc,
f1ap_ue_context_setup_req->mnc_digit_length);
BIT_STRING_TO_NR_CELL_IDENTITY(&ie->value.choice.NRCGI.nRCellIdentity, f1ap_ue_context_setup_req->nr_cellid);
/* TODO: decode candidate SpCell */
/* TODO: decode CUtoDURRCInformation */
/* TODO: Candidate_SpCell_List */
/* TODO: SCell_ToBeSetup_List */
/* TODO: SRBs_ToBeSetup_List */
/* Decode DRBs_ToBeSetup_List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true);
f1ap_ue_context_setup_req->drbs_to_be_setup_length = ie->value.choice.DRBs_ToBeSetup_List.list.count;
f1ap_ue_context_setup_req->drbs_to_be_setup = calloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length,
sizeof(f1ap_drb_to_be_setup_t));
AssertFatal(f1ap_ue_context_setup_req->drbs_to_be_setup,
"could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n");
for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) {
f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i];
F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p;
drbs_tobesetup_item_p = &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item;
drb_p->drb_id = drbs_tobesetup_item_p->dRBID;
/* TODO in the following, assume only one UP UL TNL is present.
* this matches/assumes OAI CU implementation, can be up to 2! */
drb_p->up_ul_tnl_length = 1;
AssertFatal(drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0,
"no UL UP TNL Information in DRBs to be Setup list\n");
F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0];
F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel;
BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address);
OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].gtp_teid);
switch (drbs_tobesetup_item_p->rLCMode) {
case F1AP_RLCMode_rlc_am:
drb_p->rlc_mode = RLC_MODE_AM;
break;
default:
drb_p->rlc_mode = RLC_MODE_TM;
break;
}
}
AssertFatal(0, "check configuration, send to appropriate handler\n");
return 0;
}
//void DU_send_UE_CONTEXT_SETUP_RESPONSE(F1AP_UEContextSetupResponse_t *UEContextSetupResponse) {
......@@ -153,7 +236,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance) {
// *transportLayerAddress.buf = 123;
// dLUPTNLInformation_ToBeSetup_Item.dL_GTP_Tunnel_EndPoint.transportLayerAddress = transportLayerAddress;
TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204",
strlen("1204"));
......@@ -441,7 +524,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) {
dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel;
F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t));
TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204",
strlen("1204"));
......@@ -495,7 +578,7 @@ int DU_send_UE_CONTEXT_MODIFICATION_RESPONSE(instance_t instance) {
dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.present = F1AP_UPTransportLayerInformation_PR_gTPTunnel;
F1AP_GTPTunnel_t *gTPTunnel = (F1AP_GTPTunnel_t *)calloc(1, sizeof(F1AP_GTPTunnel_t));
TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204",
strlen("1204"));
......
......@@ -196,6 +196,17 @@ do { \
(oCTETsTRING)->size = 3; \
} while(0)
#define PLMNID_TO_MCC_MNC(oCTETsTRING, mCC, mNC, mNCdIGITlENGTH) \
do { \
mCC = ((oCTETsTRING)->buf[0] & 0x0F) * 100 + \
((oCTETsTRING)->buf[0] >> 4 & 0x0F) * 10 + \
((oCTETsTRING)->buf[1] & 0x0F); \
mNCdIGITlENGTH = ((oCTETsTRING)->buf[1] >> 4 & 0x0F) == 0xF ? 2 : 3; \
mNC = (mNCdIGITlENGTH == 2 ? 0 : ((oCTETsTRING)->buf[1] >> 4 & 0x0F) * 100) + \
((oCTETsTRING)->buf[2] & 0x0F) * 10 + \
((oCTETsTRING)->buf[2] >> 4 & 0x0F); \
} while (0)
#define MCC_MNC_TO_TBCD(mCC, mNC, mNCdIGITlENGTH, tBCDsTRING) \
do { \
char _buf[3]; \
......@@ -260,7 +271,7 @@ do { \
/* TS 38.473 v15.2.1 section 9.3.1.32:
* C RNTI
* C RNTI is BIT_STRING(16)
*/
#define C_RNTI_TO_BIT_STRING(mACRO, bITsTRING) \
do { \
......@@ -272,21 +283,31 @@ do { \
} while(0)
/* TS 38.473 v15.1.1 section 9.3.2.1:
* TRANSPORT LAYER ADDRESS
/* TS 38.473 v15.1.1 section 9.3.2.3:
* TRANSPORT LAYER ADDRESS for IPv4 is 32bit (TS 38.414)
*/
#define TRANSPORT_LAYER_ADDRESS_TO_BIT_STRING(mACRO, bITsTRING) \
#define TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(mACRO, bITsTRING) \
do { \
(bITsTRING)->buf = calloc(5, sizeof(uint8_t)); \
(bITsTRING)->buf[0] = (mACRO) >> 28; \
(bITsTRING)->buf[1] = (mACRO) >> 20; \
(bITsTRING)->buf[2] = (mACRO) >> 12; \
(bITsTRING)->buf[3] = (mACRO) >> 4; \
(bITsTRING)->buf[4] = ((mACRO) & 0x0f) << 4; \
(bITsTRING)->size = 5; \
(bITsTRING)->bits_unused = 4; \
(bITsTRING)->buf = calloc(4, sizeof(uint8_t)); \
(bITsTRING)->buf[0] = (mACRO) >> 24 & 0xFF; \
(bITsTRING)->buf[1] = (mACRO) >> 16 & 0xFF; \
(bITsTRING)->buf[2] = (mACRO) >> 8 & 0xFF; \
(bITsTRING)->buf[3] = (mACRO) >> 4 & 0xFF; \
(bITsTRING)->size = 4; \
(bITsTRING)->bits_unused = 0; \
} while(0)
#define BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(bITsTRING, mACRO) \
do { \
DevCheck((bITsTRING)->size == 4, (bITsTRING)->size, 4, 0); \
DevCheck((bITsTRING)->bits_unused == 0, (bITsTRING)->bits_unused, 0, 0); \
mACRO = ((bITsTRING)->buf[0] << 24) + \
((bITsTRING)->buf[1] << 16) + \
((bITsTRING)->buf[2] << 8) + \
((bITsTRING)->buf[3]); \
} while (0)
/* TS 38.473 v15.1.1 section 9.3.1.12:
* NR CELL ID
*/
......
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