Commit 5acfa473 authored by Robert Schmidt's avatar Robert Schmidt

nas_config()/netlink_init_tun(): use entire interface name (prefix)

Instead of implicitly using a hardcoded prefix "oaitun_" interface
name, move that out to the callers of these functions to make it clear.
The ID still remains outside.

The "sister functions" nas_config_mbms()/netlink_init_tun_mbms() will do
the same change in the next commit.
parent 983ee279
......@@ -126,14 +126,15 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ...,
return 1;
}
int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, ...,
int netlink_init_tun(const char *ifprefix, int num_if, int id)
{
int ret;
char ifname[64];
int begx = (id == 0) ? 0 : id - 1;
int endx = (id == 0) ? num_if : id;
for (int i = begx; i < endx; i++) {
sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1);
sprintf(ifname, "%s%d", ifprefix, i + 1);
nas_sock_fd[i] = tun_alloc(ifname);
if (nas_sock_fd[i] == -1) {
......
......@@ -31,7 +31,7 @@
#ifndef EMU_PROTO_H_
#define EMU_PROTO_H_
int netlink_init_tun(char *ifsuffix, int num_if, int id);
int netlink_init_tun(const char *ifprefix, int num_if, int id);
int netlink_init_mbms_tun(char *ifsuffix, int id);
#endif /* EMU_PROTO_H_ */
......@@ -2300,15 +2300,15 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) {
if (UE_NAS_USE_TUN) {
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("oaitun_ue", num_if, id);
if (IS_SOFTMODEM_NOS1)
nas_config(1, 1, 2, "ue");
nas_config(1, 1, 2, "oaitun_ue");
netlink_init_mbms_tun("uem", id);
nas_config_mbms(1, 2, 2, "uem");
LOG_I(PDCP, "UE pdcp will use tun interface\n");
} else if (ENB_NAS_USE_TUN) {
netlink_init_tun("enb", 1, 0);
nas_config(1, 1, 1, "enb");
netlink_init_tun("oaitun_enb", 1, 0);
nas_config(1, 1, 1, "oaitun_enb");
if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) {
netlink_init_mbms_tun("enm", 0);
nas_config_mbms(1, 2, 1, "enm");
......
......@@ -613,21 +613,21 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
nas_getparams();
if (UE_NAS_USE_TUN) {
char *ifsuffix_ue = get_softmodem_params()->nsa ? "nrue" : "ue";
char *ifprefix = get_softmodem_params()->nsa ? "oaitun_nrue" : "oaitun_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);
netlink_init_tun(ifprefix, num_if, id);
if (IS_SOFTMODEM_NOS1) {
nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifsuffix_ue);
nas_config(1, 1, !get_softmodem_params()->nsa ? 2 : 3, ifprefix);
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);
char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb";
netlink_init_tun(ifprefix, 1, id);
nas_config(1, 1, 1, ifprefix);
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
start_pdcp_tun_enb();
}
......
......@@ -765,10 +765,10 @@ rrc_ue_establish_drb(
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,
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
UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet
ip_addr_offset4+ue_mod_idP+1, // fourth_octet
"oip"); // interface suffix (when using kernel module)
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
ip_addr_offset4 + ue_mod_idP + 1, // fourth_octet
"oaitun_oip");
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",
......
......@@ -5255,10 +5255,10 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n",
ctxt_pP->module_id,
ctxt_pP->module_id);
oip_ifup = nas_config(ctxt_pP->module_id, // interface index
ctxt_pP->module_id + 1, // third octet
ctxt_pP->module_id + 1, // fourth octet
"oai");
oip_ifup = nas_config(ctxt_pP->module_id, // interface index
ctxt_pP->module_id + 1, // third octet
ctxt_pP->module_id + 1, // fourth octet
"oaitun_oai");
if (oip_ifup == 0) { // interface is up --> send a config the DRB
module_id_t ue_module_id;
......
......@@ -189,7 +189,8 @@ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifn
}
// 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, const char *ifpref)
{
//char buf[5];
char ipAddress[20];
char broadcastAddress[20];
......@@ -197,8 +198,7 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname)
int returnValue;
sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet);
sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet);
sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname,
UE_NAS_USE_TUN?"ue": (ENB_NAS_USE_TUN?"enb":""),interface_id);
sprintf(interfaceName, "%s%d", ifpref, interface_id);
bringInterfaceUp(interfaceName, 0);
// sets the machine address
returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR);
......
......@@ -49,7 +49,7 @@ void nas_getparams(void);
* \note
* @ingroup _nas
*/
int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix);
int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *ifprefix);
/*! \fn int nas_config_mbms(char*, int, int)
* \brief This function initializes the nasmesh interface using the basic values,
......
......@@ -846,7 +846,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff
int third_octet = *(pdu_buffer + 41);
int fourth_octet = *(pdu_buffer + 42);
LOG_A(NAS, "Received PDU Session Establishment Accept\n");
nas_config(1,third_octet,fourth_octet,"ue");
nas_config(1, third_octet, fourth_octet, "oaitun_ue");
} else {
LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type);
}
......
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