Commit 35936fd5 authored by Sakthivel Velumani's avatar Sakthivel Velumani

Harmonize UE IP interface creation

NAS thread creates TUN interface & socket, configures IP and starts SDAP thread to read from socket.
noS1 mode: RRC sends itti msg to NAS thread
SA mode: NAS receives configuration from core network

Move TUN read thread to SDAP in gNB.
parent c599e172
...@@ -370,19 +370,14 @@ void init_openair0(void) { ...@@ -370,19 +370,14 @@ void init_openair0(void) {
static void init_pdcp(int ue_id) static void init_pdcp(int ue_id)
{ {
uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1) ? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT);
/*if (IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF)) {
pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT;
}*/
if (IS_SOFTMODEM_NOKRNMOD) {
pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT;
}
if (get_softmodem_params()->nsa && rlc_module_init(0) != 0) { if (get_softmodem_params()->nsa && rlc_module_init(0) != 0) {
LOG_I(RLC, "Problem at RLC initiation \n"); LOG_I(RLC, "Problem at RLC initiation \n");
} }
nr_pdcp_layer_init(false); nr_pdcp_layer_init(false);
uint64_t pdcp_initmask = 0;
/* TUN is created for nos1 and SA modes */
pdcp_initmask |= UE_NAS_USE_TUN_BIT;
nr_pdcp_module_init(pdcp_initmask, ue_id); nr_pdcp_module_init(pdcp_initmask, ue_id);
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind);
...@@ -511,6 +506,11 @@ int main(int argc, char **argv) ...@@ -511,6 +506,11 @@ int main(int argc, char **argv)
memset(PHY_vars_UE_g[0][CC_id], 0, sizeof(*PHY_vars_UE_g[0][CC_id])); memset(PHY_vars_UE_g[0][CC_id], 0, sizeof(*PHY_vars_UE_g[0][CC_id]));
} }
if (create_tasks_nrue(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode
}
int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
uint16_t node_number = get_softmodem_params()->node_number; uint16_t node_number = get_softmodem_params()->node_number;
ue_id_g = (node_number == 0) ? 0 : node_number - 2; ue_id_g = (node_number == 0) ? 0 : node_number - 2;
...@@ -591,11 +591,6 @@ int main(int argc, char **argv) ...@@ -591,11 +591,6 @@ int main(int argc, char **argv)
// wait for end of program // wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n"); printf("TYPE <CTRL-C> TO TERMINATE\n");
if (create_tasks_nrue(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode
}
// Sleep a while before checking all parameters have been used // Sleep a while before checking all parameters have been used
// Some are used directly in external threads, asynchronously // Some are used directly in external threads, asynchronously
sleep(2); sleep(2);
......
...@@ -132,6 +132,26 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., ...@@ -132,6 +132,26 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ...,
return 1; return 1;
} }
int init_single_tun(char *ifname)
{
int sock = tun_alloc(ifname);
if (sock == -1) {
LOG_E(OIP, "TUN: Error opening socket %s (%d:%s)\n", ifname, errno, strerror(errno));
exit(1);
}
LOG_I(OIP, "TUN: Opened interface %s with fd = %d\n", ifname, sock);
int ret = fcntl(sock, F_SETFL);
if (ret == -1) {
LOG_E(OIP, "TUN: Error fcntl (%d:%s)\n", errno, strerror(errno));
return ret;
}
return sock;
}
int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, ..., int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, ...,
int ret; int ret;
char ifname[64]; char ifname[64];
...@@ -139,13 +159,8 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, . ...@@ -139,13 +159,8 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, .
int begx = (id == 0) ? 0 : id - 1; int begx = (id == 0) ? 0 : id - 1;
int endx = (id == 0) ? num_if : id; int endx = (id == 0) ? num_if : id;
for (int i = begx; i < endx; i++) { for (int i = begx; i < endx; i++) {
sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1); sprintf(ifname, "oaitun_%.3s%d", ifprefix, i + 1);
nas_sock_fd[i] = tun_alloc(ifname); nas_sock_fd[i] = init_single_tun(ifname);
if (nas_sock_fd[i] == -1) {
LOG_E(PDCP, "TUN: Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno));
exit(1);
}
LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n", LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n",
ifname, i, nas_sock_fd[i]); ifname, i, nas_sock_fd[i]);
...@@ -163,7 +178,6 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, . ...@@ -163,7 +178,6 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, .
return 1; return 1;
} }
int netlink_init(void) { int netlink_init(void) {
int ret; int ret;
nas_sock_fd[0] = socket(PF_NETLINK, SOCK_RAW,GRAAL_NETLINK_ID); nas_sock_fd[0] = socket(PF_NETLINK, SOCK_RAW,GRAAL_NETLINK_ID);
......
...@@ -64,6 +64,7 @@ void clear_UE_transport_info(uint8_t); ...@@ -64,6 +64,7 @@ void clear_UE_transport_info(uint8_t);
int netlink_init(void); int netlink_init(void);
int netlink_init_tun(char *ifsuffix, int num_if, int id); int netlink_init_tun(char *ifsuffix, int num_if, int id);
int netlink_init_mbms_tun(char *ifsuffix, int id); int netlink_init_mbms_tun(char *ifsuffix, int id);
int init_single_tun(const char *ifname);
void netlink_cleanup(void); void netlink_cleanup(void);
#endif /* EMU_PROTO_H_ */ #endif /* EMU_PROTO_H_ */
...@@ -43,6 +43,7 @@ Description Defines the messages supported by the Access Stratum sublayer ...@@ -43,6 +43,7 @@ Description Defines the messages supported by the Access Stratum sublayer
#include "commonDef.h" #include "commonDef.h"
#include "networkDef.h" #include "networkDef.h"
#include "common/platform_types.h"
/****************************************************************************/ /****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/ /********************* G L O B A L C O N S T A N T S *******************/
...@@ -470,6 +471,10 @@ typedef struct nas_pdu_session_req_s { ...@@ -470,6 +471,10 @@ typedef struct nas_pdu_session_req_s {
int sd; int sd;
} nas_pdu_session_req_t; } nas_pdu_session_req_t;
typedef struct nas_nos1_msg_s {
rnti_t rnti;
} nas_nos1_msg_t;
/* /*
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Radio Access Bearer establishment * Radio Access Bearer establishment
......
...@@ -85,3 +85,5 @@ MESSAGE_DEF(NRRRC_FRAME_PROCESS, MESSAGE_PRIORITY_MED, NRRrcFramePr ...@@ -85,3 +85,5 @@ MESSAGE_DEF(NRRRC_FRAME_PROCESS, MESSAGE_PRIORITY_MED, NRRrcFramePr
// eNB: RLC -> RRC messages // eNB: RLC -> RRC messages
MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication) MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication)
MESSAGE_DEF(NAS_PDU_SESSION_REQ, MESSAGE_PRIORITY_MED, nas_pdu_session_req_t, nas_pdu_session_req) MESSAGE_DEF(NAS_PDU_SESSION_REQ, MESSAGE_PRIORITY_MED, nas_pdu_session_req_t, nas_pdu_session_req)
MESSAGE_DEF(NAS_INIT_NOS1_IF, MESSAGE_PRIORITY_MED, nas_nos1_msg_t, nas_init_nos1_if)
MESSAGE_DEF(NAS_PDU_SESSION_REL, MESSAGE_PRIORITY_MED, nas_pdu_session_req_t, nas_pdu_session_rel)
...@@ -47,19 +47,19 @@ ...@@ -47,19 +47,19 @@
//-------------------------------------------------------------------------------------------// //-------------------------------------------------------------------------------------------//
// Messages for RRC logging // Messages for RRC logging
#if defined(DISABLE_ITTI_XER_PRINT) #if defined(DISABLE_ITTI_XER_PRINT)
#include "LTE_BCCH-DL-SCH-Message.h" #include "LTE_BCCH-DL-SCH-Message.h"
#include "LTE_DL-CCCH-Message.h" #include "LTE_DL-CCCH-Message.h"
#include "LTE_DL-DCCH-Message.h" #include "LTE_DL-DCCH-Message.h"
#include "LTE_UE-EUTRA-Capability.h" #include "LTE_UE-EUTRA-Capability.h"
#include "LTE_UL-CCCH-Message.h" #include "LTE_UL-CCCH-Message.h"
#include "LTE_UL-DCCH-Message.h" #include "LTE_UL-DCCH-Message.h"
typedef LTE_BCCH_DL_SCH_Message_t RrcDlBcchMessage; typedef LTE_BCCH_DL_SCH_Message_t RrcDlBcchMessage;
typedef LTE_DL_CCCH_Message_t RrcDlCcchMessage; typedef LTE_DL_CCCH_Message_t RrcDlCcchMessage;
typedef LTE_DL_DCCH_Message_t RrcDlDcchMessage; typedef LTE_DL_DCCH_Message_t RrcDlDcchMessage;
typedef LTE_UE_EUTRA_Capability_t RrcUeEutraCapability; typedef LTE_UE_EUTRA_Capability_t RrcUeEutraCapability;
typedef LTE_UL_CCCH_Message_t RrcUlCcchMessage; typedef LTE_UL_CCCH_Message_t RrcUlCcchMessage;
typedef LTE_UL_DCCH_Message_t RrcUlDcchMessage; typedef LTE_UL_DCCH_Message_t RrcUlDcchMessage;
#endif #endif
//-------------------------------------------------------------------------------------------// //-------------------------------------------------------------------------------------------//
...@@ -96,10 +96,12 @@ ...@@ -96,10 +96,12 @@
#define NAS_OAI_TUN_NSA(mSGpTR) (mSGpTR)->ittiMsg.nas_oai_tun_nsa #define NAS_OAI_TUN_NSA(mSGpTR) (mSGpTR)->ittiMsg.nas_oai_tun_nsa
#define NAS_PDU_SESSION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_pdu_session_req #define NAS_PDU_SESSION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_pdu_session_req
#define NAS_INIT_NOS1_IF(mSGpTR) (mSGpTR)->ittiMsg.nas_init_nos1_if
#define NAS_PDU_SESSION_REL(mSGpTR) (mSGpTR)->ittiMsg.nas_pdu_session_rel
//-------------------------------------------------------------------------------------------// //-------------------------------------------------------------------------------------------//
typedef struct RrcStateInd_s { typedef struct RrcStateInd_s {
Rrc_State_t state; Rrc_State_t state;
Rrc_Sub_State_t sub_state; Rrc_Sub_State_t sub_state;
} RrcStateInd; } RrcStateInd;
......
...@@ -2306,13 +2306,13 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { ...@@ -2306,13 +2306,13 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) {
int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1;
netlink_init_tun("ue",num_if, id); netlink_init_tun("ue",num_if, id);
if (IS_SOFTMODEM_NOS1) if (IS_SOFTMODEM_NOS1)
nas_config(1, 1, 2, "ue"); nas_config(1, 1, 2, "ue", 10);
netlink_init_mbms_tun("uem", id); netlink_init_mbms_tun("uem", id);
nas_config_mbms(1, 2, 2, "uem"); nas_config_mbms(1, 2, 2, "uem");
LOG_I(PDCP, "UE pdcp will use tun interface\n"); LOG_I(PDCP, "UE pdcp will use tun interface\n");
} else if(ENB_NAS_USE_TUN) { } else if(ENB_NAS_USE_TUN) {
netlink_init_tun("enb", 1, 0); netlink_init_tun("enb", 1, 0);
nas_config(1, 1, 1, "enb"); nas_config(1, 1, 1, "enb", 10);
if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){ if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){
netlink_init_mbms_tun("enm", 0); netlink_init_mbms_tun("enm", 0);
nas_config_mbms(1, 2, 1, "enm"); nas_config_mbms(1, 2, 1, "enm");
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "gnb_config.h" #include "gnb_config.h"
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
#include "cuup_cucp_if.h" #include "cuup_cucp_if.h"
#include "openair2/RRC/NAS/nas_config.h"
#define TODO do { \ #define TODO do { \
printf("%s:%d:%s: todo\n", __FILE__, __LINE__, __FUNCTION__); \ printf("%s:%d:%s: todo\n", __FILE__, __LINE__, __FUNCTION__); \
...@@ -388,173 +389,19 @@ bool pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, ...@@ -388,173 +389,19 @@ bool pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP,
return true; return true;
} }
/****************************************************************************/ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
/* pdcp_data_ind thread - end */
/****************************************************************************/
/****************************************************************************/
/* hacks to be cleaned up at some point - begin */
/****************************************************************************/
#include "LAYER2/MAC/mac_extern.h"
static void reblock_tun_socket(void)
{
extern int nas_sock_fd[];
int f;
f = fcntl(nas_sock_fd[0], F_GETFL, 0);
f &= ~(O_NONBLOCK);
if (fcntl(nas_sock_fd[0], F_SETFL, f) == -1) {
LOG_E(PDCP, "reblock_tun_socket failed\n");
exit(1);
}
}
static void *enb_tun_read_thread(void *_)
{
extern int nas_sock_fd[];
char rx_buf[NL_MAX_PAYLOAD];
int len;
protocol_ctxt_t ctxt;
ue_id_t UEid;
int rb_id = 1;
pthread_setname_np( pthread_self(),"enb_tun_read");
while (1) {
len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD);
if (len == -1) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len);
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
const bool has_ue = nr_pdcp_get_first_ue_id(nr_pdcp_ue_manager, &UEid);
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
if (!has_ue) continue;
ctxt.module_id = 0;
ctxt.enb_flag = 1;
ctxt.instance = 0;
ctxt.frame = 0;
ctxt.subframe = 0;
ctxt.eNB_index = 0;
ctxt.brOption = 0;
ctxt.rntiMaybeUEid = UEid;
uint8_t qfi = 7;
bool rqi = 0;
int pdusession_id = 10;
sdap_data_req(&ctxt,
UEid,
SRB_FLAG_NO,
rb_id,
RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO,
len,
(unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA,
NULL,
NULL,
qfi,
rqi,
pdusession_id);
}
return NULL;
}
static void *ue_tun_read_thread(void *_)
{
extern int nas_sock_fd[];
char rx_buf[NL_MAX_PAYLOAD];
int len;
protocol_ctxt_t ctxt;
ue_id_t UEid;
int has_ue;
int rb_id = 1;
pthread_setname_np( pthread_self(),"ue_tun_read");
while (1) {
len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD);
if (len == -1) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len);
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
has_ue = nr_pdcp_get_first_ue_id(nr_pdcp_ue_manager, &UEid);
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
if (!has_ue) continue;
ctxt.module_id = 0;
ctxt.enb_flag = 0;
ctxt.instance = 0;
ctxt.frame = 0;
ctxt.subframe = 0;
ctxt.eNB_index = 0;
ctxt.brOption = 0;
ctxt.rntiMaybeUEid = UEid;
bool dc = SDAP_HDR_UL_DATA_PDU;
extern uint8_t nas_qfi;
extern uint8_t nas_pduid;
sdap_data_req(&ctxt,
UEid,
SRB_FLAG_NO,
rb_id,
RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO,
len,
(unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA,
NULL,
NULL,
nas_qfi,
dc,
nas_pduid);
}
return NULL;
}
static void start_pdcp_tun_enb(void)
{ {
pthread_t t; pdcp_optmask = pdcp_optmask | _pdcp_optmask;
reblock_tun_socket();
if (pthread_create(&t, NULL, enb_tun_read_thread, NULL) != 0) { if (ENB_NAS_USE_TUN) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); nas_getparams();
exit(1); start_sdap_tun_gnb(id);
} }
} /* UE's tun interface in NOS1 is created from SDAP entity of default DRB in nr_sdap_entity.c */
static void start_pdcp_tun_ue(void) return pdcp_optmask;
{
pthread_t t;
reblock_tun_socket();
if (pthread_create(&t, NULL, ue_tun_read_thread, NULL) != 0) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
} }
/****************************************************************************/
/* hacks to be cleaned up at some point - end */
/****************************************************************************/
int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP)
{ {
return 0; return 0;
...@@ -570,6 +417,7 @@ void pdcp_layer_init(void) ...@@ -570,6 +417,7 @@ void pdcp_layer_init(void)
abort(); abort();
} }
#include "LAYER2/MAC/mac_extern.h"
void nr_pdcp_layer_init(bool uses_e1) void nr_pdcp_layer_init(bool uses_e1)
{ {
/* hack: be sure to initialize only once */ /* hack: be sure to initialize only once */
...@@ -600,63 +448,6 @@ void nr_pdcp_layer_init(bool uses_e1) ...@@ -600,63 +448,6 @@ void nr_pdcp_layer_init(bool uses_e1)
#include "executables/lte-softmodem.h" #include "executables/lte-softmodem.h"
#include "openair2/RRC/NAS/nas_config.h" #include "openair2/RRC/NAS/nas_config.h"
uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
{
/* hack: be sure to initialize only once */
static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
static int initialized = 0;
if (pthread_mutex_lock(&m) != 0) abort();
if (initialized) {
abort();
}
initialized = 1;
if (pthread_mutex_unlock(&m) != 0) abort();
#if 0
pdcp_optmask = _pdcp_optmask;
return pdcp_optmask;
#endif
/* temporary enforce netlink when UE_NAS_USE_TUN is set,
this is while switching from noS1 as build option
to noS1 as config option */
if ( _pdcp_optmask & UE_NAS_USE_TUN_BIT) {
pdcp_optmask = pdcp_optmask | PDCP_USE_NETLINK_BIT ;
}
pdcp_optmask = pdcp_optmask | _pdcp_optmask ;
LOG_I(PDCP, "pdcp init,%s %s\n",
((LINK_ENB_PDCP_TO_GTPV1U)?"usegtp":""),
((PDCP_USE_NETLINK)?"usenetlink":""));
if (PDCP_USE_NETLINK) {
nas_getparams();
if(UE_NAS_USE_TUN) {
char *ifsuffix_ue = get_softmodem_params()->nsa ? "nrue" : "ue";
int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1;
netlink_init_tun(ifsuffix_ue, num_if, id);
//Add --nr-ip-over-lte option check for next line
if (IS_SOFTMODEM_NOS1){
nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue);
set_qfi_pduid(7, 10);
}
LOG_I(PDCP, "UE pdcp will use tun interface\n");
start_pdcp_tun_ue();
} else if(ENB_NAS_USE_TUN) {
char *ifsuffix_base_s = get_softmodem_params()->nsa ? "gnb" : "enb";
netlink_init_tun(ifsuffix_base_s, 1, id);
nas_config(1, 1, 1, ifsuffix_base_s);
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
start_pdcp_tun_enb();
} else {
LOG_I(PDCP, "pdcp will use kernel modules\n");
abort();
netlink_init();
}
}
return pdcp_optmask ;
}
static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
char *buf, int size) char *buf, int size)
{ {
......
...@@ -766,10 +766,11 @@ rrc_ue_establish_drb( ...@@ -766,10 +766,11 @@ rrc_ue_establish_drb(
ip_addr_offset4 = 1; ip_addr_offset4 = 1;
LOG_I(OIP,"[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, LOG_I(OIP,"[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP,
ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1);
oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id oip_ifup = nas_config(ip_addr_offset3 + ue_mod_idP + 1, // interface_id
UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet UE_NAS_USE_TUN ? 1 : (ip_addr_offset3 + ue_mod_idP + 1), // third_octet
ip_addr_offset4+ue_mod_idP+1, // fourth_octet ip_addr_offset4 + ue_mod_idP + 1, // fourth_octet
"oip"); // interface suffix (when using kernel module) "oip", // interface suffix (when using kernel module)
10); // pdu id (for multi pdu)
if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB
LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n",
......
...@@ -5257,10 +5257,11 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ...@@ -5257,10 +5257,11 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n",
ctxt_pP->module_id, ctxt_pP->module_id,
ctxt_pP->module_id); ctxt_pP->module_id);
oip_ifup = nas_config(ctxt_pP->module_id, // interface index oip_ifup = nas_config(ctxt_pP->module_id, // interface index
ctxt_pP->module_id + 1, // third octet ctxt_pP->module_id + 1, // third octet
ctxt_pP->module_id + 1, // fourth octet ctxt_pP->module_id + 1, // fourth octet
"oai"); "oai",
10); // not used in eNB
if (oip_ifup == 0) { // interface is up --> send a config the DRB if (oip_ifup == 0) { // interface is up --> send a config the DRB
module_id_t ue_module_id; module_id_t ue_module_id;
......
...@@ -235,6 +235,27 @@ int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *br ...@@ -235,6 +235,27 @@ int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *br
return returnValue; return returnValue;
} }
int doesInterfaceExist(const char *interfaceName)
{
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd == -1) {
exit(1);
}
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, interfaceName, IFNAMSIZ - 1);
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) == -1) {
close(sockfd);
return 1;
}
close(sockfd);
return 0;
}
int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifname) {
//char buf[5]; //char buf[5];
char ipAddress[20]; char ipAddress[20];
...@@ -315,18 +336,31 @@ int nas_config_mbms_s1(int interface_id, int thirdOctet, int fourthOctet, char * ...@@ -315,18 +336,31 @@ int nas_config_mbms_s1(int interface_id, int thirdOctet, int fourthOctet, char *
return returnValue; return returnValue;
} }
void nas_config_interface_name(int if_id, int if_suffix, const char *ifname, char *ret)
{
char prefixName[20];
sprintf(prefixName,
"%s%s%d",
(UE_NAS_USE_TUN || ENB_NAS_USE_TUN) ? "oaitun_" : ifname,
UE_NAS_USE_TUN ? "ue" : (ENB_NAS_USE_TUN ? "enb" : ""),
if_id);
if (UE_NAS_USE_TUN) {
sprintf(ret, "%s%s%d", prefixName, "p", if_suffix);
} else {
strcpy(ret, prefixName);
}
}
// non blocking full configuration of the interface (address, and the two lest octets of the address) // non blocking full configuration of the interface (address, and the two lest octets of the address)
int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname, int interface_suffix)
//char buf[5]; {
char ipAddress[20]; char ipAddress[20];
char broadcastAddress[20]; char broadcastAddress[20];
char interfaceName[20]; char interfaceName[20];
int returnValue; int returnValue;
sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet); sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet);
sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet);
sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname, nas_config_interface_name(interface_id, interface_suffix, ifname, interfaceName);
UE_NAS_USE_TUN?"ue": (ENB_NAS_USE_TUN?"enb":""),interface_id);
bringInterfaceUp(interfaceName, 0); bringInterfaceUp(interfaceName, 0);
// sets the machine address // sets the machine address
returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR);
...@@ -350,15 +384,21 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) ...@@ -350,15 +384,21 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname)
interfaceName, ipAddress, netMask, broadcastAddress); interfaceName, ipAddress, netMask, broadcastAddress);
int res; int res;
char pdu_suffix[10];
sprintf(pdu_suffix, "p%d", interface_suffix);
char command_line[500]; char command_line[500];
res = sprintf(command_line, res = sprintf(command_line,
"ip rule add from %s/32 table %d && " "ip rule add from %s/32 table %d && "
"ip rule add to %s/32 table %d && " "ip rule add to %s/32 table %d && "
"ip route add default dev %s%d table %d", "ip route add default dev %s%d%s table %d",
ipAddress, interface_id - 1 + 10000, ipAddress,
ipAddress, interface_id - 1 + 10000, interface_id - 1 + 10000,
UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ipAddress,
interface_id, interface_id - 1 + 10000); interface_id - 1 + 10000,
UE_NAS_USE_TUN ? "oaitun_ue" : "oip",
interface_id,
UE_NAS_USE_TUN ? pdu_suffix : "",
interface_id - 1 + 10000);
if (res < 0) { if (res < 0) {
LOG_E(OIP,"Could not create ip rule/route commands string\n"); LOG_E(OIP,"Could not create ip rule/route commands string\n");
......
...@@ -61,7 +61,7 @@ int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *br ...@@ -61,7 +61,7 @@ int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *br
* \note * \note
* @ingroup _nas * @ingroup _nas
*/ */
int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix, int interface_suffix);
/*! \fn int nas_config_mbms(char*, int, int) /*! \fn int nas_config_mbms(char*, int, int)
* \brief This function initializes the nasmesh interface using the basic values, * \brief This function initializes the nasmesh interface using the basic values,
...@@ -181,4 +181,6 @@ void rb_ioctl_init(int inst); ...@@ -181,4 +181,6 @@ void rb_ioctl_init(int inst);
int rb_stats_req(int inst); int rb_stats_req(int inst);
void init_socket(void); void init_socket(void);
in_addr_t ipv4_address(int thirdOctet, int fourthOctet); in_addr_t ipv4_address(int thirdOctet, int fourthOctet);
int doesInterfaceExist(const char *interfaceName);
void nas_config_interface_name(int if_id, int if_suffix, const char *ifname, char *ret);
#endif /*NAS_CONFIG_H_*/ #endif /*NAS_CONFIG_H_*/
...@@ -62,6 +62,8 @@ void init_nsa_message(NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig ...@@ -62,6 +62,8 @@ void init_nsa_message(NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig
msg_len = fread(buffer, 1, 1024, fd); msg_len = fread(buffer, 1, 1024, fd);
fclose(fd); fclose(fd);
process_nsa_message(rrc, nr_RadioBearerConfigX_r15, buffer,msg_len); process_nsa_message(rrc, nr_RadioBearerConfigX_r15, buffer,msg_len);
MessageDef* ittiMsg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_INIT_NOS1_IF);
itti_send_msg_to_task(TASK_NAS_NRUE, 0, ittiMsg);
} }
else else
LOG_D(NR_RRC, "In NSA mode \n"); LOG_D(NR_RRC, "In NSA mode \n");
......
...@@ -19,10 +19,161 @@ ...@@ -19,10 +19,161 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
#define _GNU_SOURCE
#include "nr_sdap.h" #include "nr_sdap.h"
#include "openair2/LAYER2/RLC/rlc.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "openair1/SIMULATION/ETH_TRANSPORT/proto.h"
#include <pthread.h>
uint8_t nas_qfi; struct thread_args {
uint8_t nas_pduid; int sock_fd;
};
static void *gnb_tun_read_thread(void *arg)
{
int sock_fd = ((struct thread_args *)arg)->sock_fd;
char rx_buf[NL_MAX_PAYLOAD];
int len;
protocol_ctxt_t ctxt;
ue_id_t UEid;
int rb_id = 1;
pthread_setname_np(pthread_self(), "gnb_tun_read");
while (1) {
len = read(sock_fd, &rx_buf, NL_MAX_PAYLOAD);
if (len == -1) {
LOG_E(SDAP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
LOG_D(SDAP, "%s read data of size %d\n", __func__, len);
const bool has_ue = nr_sdap_get_first_ue_id(&UEid);
if (!has_ue)
continue;
ctxt.module_id = 0;
ctxt.enb_flag = 1;
ctxt.instance = 0;
ctxt.frame = 0;
ctxt.subframe = 0;
ctxt.eNB_index = 0;
ctxt.brOption = 0;
ctxt.rntiMaybeUEid = UEid;
uint8_t qfi = 7;
bool rqi = 0;
int pdusession_id = 10;
sdap_data_req(&ctxt,
UEid,
SRB_FLAG_NO,
rb_id,
RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO,
len,
(unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA,
NULL,
NULL,
qfi,
rqi,
pdusession_id);
}
free(arg);
return NULL;
}
void start_sdap_tun_gnb(int id)
{
pthread_t t;
struct thread_args *arg = malloc(sizeof(struct thread_args));
char ifname[20];
nas_config_interface_name(id + 1, 1, "oaitun_", ifname);
arg->sock_fd = init_single_tun(ifname);
nas_config(id + 1, 1, 1, ifname, 1);
{
// default ue id & pdu session id in nos1 mode
nr_sdap_entity_t *entity = nr_sdap_get_entity(1, 10);
DevAssert(entity != NULL);
entity->pdusession_sock = arg->sock_fd;
}
if (pthread_create(&t, NULL, gnb_tun_read_thread, (void *)arg) != 0) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
}
static void *ue_tun_read_thread(void *arg)
{
nr_sdap_entity_t *entity = (nr_sdap_entity_t *)arg;
char rx_buf[NL_MAX_PAYLOAD];
int len;
protocol_ctxt_t ctxt;
int rb_id = 1;
char thread_name[64];
sprintf(thread_name, "ue_tun_read_%d\n", entity->pdusession_id);
pthread_setname_np(pthread_self(), thread_name);
while (1) {
len = read(entity->pdusession_sock, &rx_buf, NL_MAX_PAYLOAD);
if (entity->stop_thread)
break;
if (len == -1) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
LOG_D(PDCP, "%s(): pdusession_sock read returns len %d\n", __func__, len);
ctxt.module_id = 0;
ctxt.enb_flag = 0;
ctxt.instance = 0;
ctxt.frame = 0;
ctxt.subframe = 0;
ctxt.eNB_index = 0;
ctxt.brOption = 0;
ctxt.rntiMaybeUEid = entity->ue_id;
bool dc = SDAP_HDR_UL_DATA_PDU;
entity->tx_entity(entity,
&ctxt,
SRB_FLAG_NO,
rb_id,
RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO,
len,
(unsigned char *)rx_buf,
PDCP_TRANSMISSION_MODE_DATA,
NULL,
NULL,
entity->qfi,
dc);
}
return NULL;
}
void start_sdap_tun_ue(ue_id_t ue_id, int pdu_session_id, int sock)
{
nr_sdap_entity_t *entity = nr_sdap_get_entity(ue_id, pdu_session_id);
DevAssert(entity != NULL);
entity->pdusession_sock = sock;
entity->stop_thread = false;
if (pthread_create(&entity->pdusession_thread, NULL, ue_tun_read_thread, (void *)entity) != 0) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
}
bool sdap_data_req(protocol_ctxt_t *ctxt_p, bool sdap_data_req(protocol_ctxt_t *ctxt_p,
const ue_id_t ue_id, const ue_id_t ue_id,
...@@ -86,9 +237,3 @@ void sdap_data_ind(rb_id_t pdcp_entity, ...@@ -86,9 +237,3 @@ void sdap_data_ind(rb_id_t pdcp_entity,
buf, buf,
size); size);
} }
void set_qfi_pduid(uint8_t qfi, uint8_t pduid){
nas_qfi = qfi;
nas_pduid = pduid;
return;
}
...@@ -61,6 +61,7 @@ void sdap_data_ind(rb_id_t pdcp_entity, ...@@ -61,6 +61,7 @@ void sdap_data_ind(rb_id_t pdcp_entity,
char *buf, char *buf,
int size); int size);
void set_qfi_pduid(uint8_t qfi, uint8_t pduid); void start_sdap_tun_ue(ue_id_t ue_id, int pdu_session_id, int sock);
void start_sdap_tun_gnb(int id);
#endif #endif
...@@ -20,7 +20,12 @@ ...@@ -20,7 +20,12 @@
*/ */
#include "nr_sdap_entity.h" #include "nr_sdap_entity.h"
#include "nr_sdap.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "executables/softmodem-common.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "openair2/COMMON/as_message.h"
#include "openair1/SIMULATION/ETH_TRANSPORT/proto.h"
#include <openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h> #include <openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h>
#include <openair3/ocp-gtpu/gtp_itf.h> #include <openair3/ocp-gtpu/gtp_itf.h>
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h" #include "openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h"
...@@ -299,8 +304,7 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity, ...@@ -299,8 +304,7 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
* 5.2.2 Downlink * 5.2.2 Downlink
* deliver the retrieved SDAP SDU to the upper layer. * deliver the retrieved SDAP SDU to the upper layer.
*/ */
extern int nas_sock_fd[]; int len = write(entity->pdusession_sock, &buf[offset], size - offset);
int len = write(nas_sock_fd[0], &buf[offset], size-offset);
LOG_D(SDAP, "RX Entity len : %d\n", len); LOG_D(SDAP, "RX Entity len : %d\n", len);
LOG_D(SDAP, "RX Entity size : %d\n", size); LOG_D(SDAP, "RX Entity size : %d\n", size);
LOG_D(SDAP, "RX Entity offset : %d\n", offset); LOG_D(SDAP, "RX Entity offset : %d\n", offset);
...@@ -458,6 +462,16 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, ...@@ -458,6 +462,16 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb,
return sdap_entity; return sdap_entity;
} }
/* TODO: modify data in sdap_info with mutex lock */
bool nr_sdap_get_first_ue_id(ue_id_t *ret)
{
if (sdap_info.sdap_entity_llist == NULL) {
return false;
}
*ret = sdap_info.sdap_entity_llist->ue_id;
return true;
}
nr_sdap_entity_t *nr_sdap_get_entity(ue_id_t ue_id, int pdusession_id) nr_sdap_entity_t *nr_sdap_get_entity(ue_id_t ue_id, int pdusession_id)
{ {
nr_sdap_entity_t *sdap_entity; nr_sdap_entity_t *sdap_entity;
...@@ -491,6 +505,26 @@ void nr_sdap_release_drb(ue_id_t ue_id, int drb_id, int pdusession_id) ...@@ -491,6 +505,26 @@ void nr_sdap_release_drb(ue_id_t ue_id, int drb_id, int pdusession_id)
pdusession_id); pdusession_id);
} }
void remove_ue_ip_if(ue_id_t ue_id, int pdusession_id)
{
nr_sdap_entity_t *entity = nr_sdap_get_entity(ue_id, pdusession_id);
DevAssert(entity != NULL);
// Stop the read thread
entity->stop_thread = true;
// Bring down the IP interface
char ifnameFull[20];
nas_config_interface_name(entity->ue_id, entity->pdusession_id, "oaitun_", ifnameFull);
if (bringInterfaceUp(ifnameFull, 0) == 0) {
// Close the socket associated with the interface
close(entity->pdusession_sock);
LOG_I(SDAP, "Interface %s is now down.\n", ifnameFull);
} else {
LOG_E(SDAP, "Could not bring interface %s down.\n", ifnameFull);
exit(1);
}
nr_sdap_delete_entity(ue_id, pdusession_id);
}
bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id) bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id)
{ {
nr_sdap_entity_t *entityPtr = sdap_info.sdap_entity_llist; nr_sdap_entity_t *entityPtr = sdap_info.sdap_entity_llist;
...@@ -562,3 +596,11 @@ bool nr_sdap_delete_ue_entities(ue_id_t ue_id) ...@@ -562,3 +596,11 @@ bool nr_sdap_delete_ue_entities(ue_id_t ue_id)
} }
return ret; return ret;
} }
void set_qfi(uint8_t qfi, uint8_t pduid, ue_id_t ue_id)
{
nr_sdap_entity_t *entity = nr_sdap_get_entity(ue_id, pduid);
DevAssert(entity != NULL);
entity->qfi = qfi;
return;
}
...@@ -80,6 +80,11 @@ typedef struct nr_sdap_entity_s { ...@@ -80,6 +80,11 @@ typedef struct nr_sdap_entity_s {
ue_id_t ue_id; ue_id_t ue_id;
rb_id_t default_drb; rb_id_t default_drb;
int pdusession_id; int pdusession_id;
int pdusession_sock;
pthread_t pdusession_thread;
bool stop_thread;
int qfi;
qfi2drb_t qfi2drb_table[SDAP_MAX_QFI]; qfi2drb_t qfi2drb_table[SDAP_MAX_QFI];
void (*qfi2drb_map_update)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t drb, bool has_sdap_rx, bool has_sdap_tx); void (*qfi2drb_map_update)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t drb, bool has_sdap_rx, bool has_sdap_tx);
...@@ -188,4 +193,7 @@ bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id); ...@@ -188,4 +193,7 @@ bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id);
* @return True, it deleted at least one entity, false otherwise. * @return True, it deleted at least one entity, false otherwise.
*/ */
bool nr_sdap_delete_ue_entities(ue_id_t ue_id); bool nr_sdap_delete_ue_entities(ue_id_t ue_id);
void set_qfi(uint8_t qfi, uint8_t pduid, ue_id_t ue_id);
bool nr_sdap_get_first_ue_id(ue_id_t *ret);
void remove_ue_ip_if(ue_id_t ue_id, int pdusession_id);
#endif #endif
...@@ -112,7 +112,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ ...@@ -112,7 +112,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
psea_msg.pdu_addr_ie.pdu_addr_oct4 = *curPtr++; psea_msg.pdu_addr_ie.pdu_addr_oct4 = *curPtr++;
nas_getparams(); nas_getparams();
sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2); sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2);
nas_config(1, psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); nr_ue_create_ip_if("", 0, psea_msg.pdu_id, psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4);
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n", LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received UE IP: %d.%d.%d.%d\n",
psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct1,
psea_msg.pdu_addr_ie.pdu_addr_oct2, psea_msg.pdu_addr_ie.pdu_addr_oct2,
...@@ -185,6 +185,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ ...@@ -185,6 +185,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
} }
} }
set_qfi_pduid(qos_rule.qfi, psea_msg.pdu_id); const int ue_id = 0;
set_qfi(qos_rule.qfi, psea_msg.pdu_id, ue_id);
return; return;
} }
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "openair2/SDAP/nr_sdap/nr_sdap.h" #include "openair2/SDAP/nr_sdap/nr_sdap.h"
#include "openair3/SECU/nas_stream_eia2.h" #include "openair3/SECU/nas_stream_eia2.h"
#include "openair3/UTILS/conversions.h" #include "openair3/UTILS/conversions.h"
#include "softmodem-common.h"
uint8_t *registration_request_buf; uint8_t *registration_request_buf;
uint32_t registration_request_len; uint32_t registration_request_len;
...@@ -719,14 +720,28 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -719,14 +720,28 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
} }
} }
void nr_ue_create_ip_if(char *ifname, int ue_id, int pdu_session_id, int third_octet, int fourth_octet)
{
char ifname_full[20];
nas_config_interface_name(ue_id, pdu_session_id, ifname, ifname_full);
if (doesInterfaceExist(ifname_full) == 0) {
LOG_W(NAS, "Interface %s already exists. Do nothing.\n", ifname_full);
return;
}
const int sock = init_single_tun(ifname_full);
nas_config(ue_id, third_octet, fourth_octet, ifname, pdu_session_id);
start_sdap_tun_ue(ue_id, pdu_session_id, sock);
}
void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buffer){ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buffer){
uint8_t msg_type = *(pdu_buffer + 16); uint8_t msg_type = *(pdu_buffer + 16);
if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){
sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40)); sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40));
int third_octet = *(pdu_buffer + 41); int third_octet = *(pdu_buffer + 41);
int fourth_octet = *(pdu_buffer + 42); int fourth_octet = *(pdu_buffer + 42);
int pdu_session_id = *(pdu_buffer + 14);
LOG_A(NAS, "Received PDU Session Establishment Accept\n"); LOG_A(NAS, "Received PDU Session Establishment Accept\n");
nas_config(1,third_octet,fourth_octet,"ue"); nr_ue_create_ip_if("oaitun_", 0, pdu_session_id, third_octet, fourth_octet);
} else { } else {
LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type);
} }
...@@ -1241,6 +1256,7 @@ void *nas_nrue(void *args_p) ...@@ -1241,6 +1256,7 @@ void *nas_nrue(void *args_p)
if (offset < NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length) if (offset < NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length)
payload_container = pdu_buffer + offset; payload_container = pdu_buffer + offset;
int pdu_session_id = ((dl_nas_transport_t *)(pdu_buffer + offset))->sm_nas_msg_header.pdu_session_id;
while (offset < payload_container_length) { while (offset < payload_container_length) {
if (*(payload_container + offset) == 0x29) { // PDU address IEI if (*(payload_container + offset) == 0x29) { // PDU address IEI
if ((*(payload_container + offset + 1) == 0x05) && (*(payload_container + offset + 2) == 0x01)) { // IPV4 if ((*(payload_container + offset + 1) == 0x05) && (*(payload_container + offset + 2) == 0x01)) { // IPV4
...@@ -1254,7 +1270,7 @@ void *nas_nrue(void *args_p) ...@@ -1254,7 +1270,7 @@ void *nas_nrue(void *args_p)
*(payload_container + offset + 4), *(payload_container + offset + 4),
*(payload_container + offset + 5), *(payload_container + offset + 5),
*(payload_container + offset + 6)); *(payload_container + offset + 6));
nas_config(1, third_octet, fourth_octet, "oaitun_ue"); nr_ue_create_ip_if("oaitun_", 0, pdu_session_id, third_octet, fourth_octet);
break; break;
} }
} }
...@@ -1270,6 +1286,25 @@ void *nas_nrue(void *args_p) ...@@ -1270,6 +1286,25 @@ void *nas_nrue(void *args_p)
send_nas_uplink_data_req(instance, &initialNasMsg); send_nas_uplink_data_req(instance, &initialNasMsg);
} break; } break;
case NAS_INIT_NOS1_IF: {
const int ue_id = instance;
const int pdu_session_id = 10;
const int qfi = 7;
const int third_octet = 1;
const int fourth_octet = !get_softmodem_params()->nsa ? 2 : 3;
nas_getparams();
nr_ue_create_ip_if("oaitun_", ue_id, pdu_session_id, third_octet, fourth_octet);
set_qfi(qfi, pdu_session_id, ue_id);
break;
}
case NAS_PDU_SESSION_REL: {
// TODO: Initiate PDU session release request & send NAS signal to network
nas_pdu_session_req_t *pdu_rel = &NAS_PDU_SESSION_REL(msg_p);
remove_ue_ip_if(instance, pdu_rel->pdusession_id);
break;
}
default: default:
LOG_E(NAS, "[UE %ld] Received unexpected message %s\n", instance, ITTI_MSG_NAME(msg_p)); LOG_E(NAS, "[UE %ld] Received unexpected message %s\n", instance, ITTI_MSG_NAME(msg_p));
break; break;
......
...@@ -184,6 +184,7 @@ nr_ue_nas_t *get_ue_nas_info(module_id_t module_id); ...@@ -184,6 +184,7 @@ nr_ue_nas_t *get_ue_nas_info(module_id_t module_id);
void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas); void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas);
void *nas_nrue_task(void *args_p); void *nas_nrue_task(void *args_p);
void *nas_nrue(void *args_p); void *nas_nrue(void *args_p);
void nr_ue_create_ip_if(char *ifname, int ue_id, int pdu_session_id, int third_octet, int fourth_octet);
#endif /* __NR_NAS_MSG_SIM_H__*/ #endif /* __NR_NAS_MSG_SIM_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