Commit 89d89a75 authored by Robert Schmidt's avatar Robert Schmidt

Create tun_if module for TUN interface handling

Move openair3/RRC/NAS/nas_config.c to common/utils/tun_if.c, and remove
the former from all targets.
parent 39e7839f
......@@ -1931,7 +1931,6 @@ add_executable(lte-softmodem
${OPENAIR_DIR}/executables/create_tasks_mbms.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${PHY_INTERFACE_DIR}/queue_t.c
${OPENAIR_DIR}/common/utils/lte/ue_power.c
......@@ -1988,7 +1987,6 @@ add_executable(lte-uesoftmodem
${OPENAIR_DIR}/executables/create_tasks_ue.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/lte/ue_power.c
${OPENAIR_DIR}/common/utils/lte/prach_utils.c
......@@ -2024,7 +2022,6 @@ add_executable(nr-softmodem
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR_DIR}/common/utils/lte/ue_power.c
${OPENAIR_DIR}/common/utils/lte/prach_utils.c
${PHY_INTERFACE_DIR}/queue_t.c
......@@ -2066,7 +2063,6 @@ target_link_libraries(nr-softmodem PRIVATE
add_executable(nr-cuup
executables/nr-cuup.c
executables/softmodem-common.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${NR_RRC_DIR}/rrc_gNB_UE_context.c
${OPENAIR2_DIR}/E1AP/e1ap_setup.c
${NR_PDCP_SRC}
......@@ -2094,7 +2090,6 @@ add_executable(nr-uesoftmodem
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c
......@@ -2205,7 +2200,6 @@ add_executable(nr_psbchsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/psbchsim.c
${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${NR_UE_RRC_DIR}/rrc_nsa.c
${NFAPI_USER_DIR}/nfapi.c
${NFAPI_USER_DIR}/gnb_ind_vars.c
......@@ -2232,7 +2226,6 @@ add_executable(nr_dlsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${NR_UE_RRC_DIR}/rrc_nsa.c
${NFAPI_USER_DIR}/nfapi.c
${NFAPI_USER_DIR}/gnb_ind_vars.c
......@@ -2268,7 +2261,6 @@ add_executable(nr_ulsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c
${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${NR_UE_RRC_DIR}/rrc_nsa.c
${NFAPI_USER_DIR}/nfapi.c
${NFAPI_USER_DIR}/gnb_ind_vars.c
......
......@@ -13,6 +13,6 @@ add_subdirectory(T)
add_subdirectory(nr)
add_subdirectory(LOG)
add_subdirectory(threadPool)
add_library(utils utils.c system.c time_meas.c time_stat.c)
add_library(utils utils.c system.c time_meas.c time_stat.c tun_if.c)
target_include_directories(utils PUBLIC .)
target_link_libraries(utils PRIVATE ${T_LIB})
......@@ -28,7 +28,7 @@
#include <arpa/inet.h>
#include <linux/ipv6.h>
#include "nas_config.h"
#include "tun_if.h"
#include "common/utils/LOG/log.h"
#include "common/utils/system.h"
......@@ -115,7 +115,7 @@ fail_interface_state:
}
// non blocking full configuration of the interface (address, and the two lest octets of the address)
bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifpref)
bool tun_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifpref)
{
char interfaceName[IFNAMSIZ];
snprintf(interfaceName, sizeof(interfaceName), "%s%d", ifpref, interface_id);
......
......@@ -19,12 +19,12 @@
* contact@openairinterface.org
*/
#ifndef NAS_CONFIG_H_
#define NAS_CONFIG_H_
#ifndef TUN_IF_H_
#define TUN_IF_H_
#include <stdbool.h>
/*! \fn int nas_config(char*, int, int)
/*! \fn int tun_config(char*, int, int)
* \brief This function initializes the nasmesh interface using the basic values,
* basic address, network mask and broadcast address, as the default configured
* ones
......@@ -38,7 +38,7 @@
* \note
* @ingroup _nas
*/
bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifprefix);
bool tun_config(int interface_id, const char *ipv4, const char *ipv6, const char *ifprefix);
/*!
* \brief Setup a IPv4 rule in table (interface_id - 1 + 10000) and route to
......@@ -54,4 +54,4 @@ bool nas_config(int interface_id, const char *ipv4, const char *ipv6, const char
*/
void setup_ue_ipv4_route(int interface_id, const char *ipv4, const char *ifpref);
#endif /*NAS_CONFIG_H_*/
#endif /*TUN_IF_H_*/
......@@ -866,6 +866,8 @@ INPUT = \
@CMAKE_CURRENT_SOURCE_DIR@/../common/config/config_cmdline.c \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/time_meas.c \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/time_meas.h \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/tun_if.h \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/tun_if.c \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/utils.c \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/oai_asn1.h \
@CMAKE_CURRENT_SOURCE_DIR@/../common/utils/system.h \
......@@ -1874,8 +1876,6 @@ INPUT = \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_defs.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/L2_interface_ue.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/nas_config.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NAS/nas_config.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_internode.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_defs.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/cucp_cuup_if.h \
......
......@@ -50,7 +50,7 @@
#include "common/openairinterface5g_limits.h"
#include "executables/lte-softmodem.h"
#include "SIMULATION/ETH_TRANSPORT/proto.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
#include "intertask_interface.h"
#include "openair3/S1AP/s1ap_eNB.h"
#include <pthread.h>
......@@ -2300,22 +2300,22 @@ 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;
netlink_init_tun("oaitun_ue", num_if, id);
if (IS_SOFTMODEM_NOS1)
nas_config(1, "10.0.1.2", NULL, "oaitun_ue");
tun_config(1, "10.0.1.2", NULL, "oaitun_ue");
netlink_init_mbms_tun("oaitun_uem", id + 1);
nas_config(1, "10.0.2.2", NULL, "oaitun_uem");
tun_config(1, "10.0.2.2", NULL, "oaitun_uem");
LOG_I(PDCP, "UE pdcp will use tun interface\n");
} else if (ENB_NAS_USE_TUN) {
netlink_init_tun("oaitun_enb", 1, 0);
nas_config(1, "10.0.1.1", NULL, "oaitun_enb");
tun_config(1, "10.0.1.1", NULL, "oaitun_enb");
if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) {
netlink_init_mbms_tun("oaitun_enm", 1);
nas_config(1, "10.0.2.1", NULL, "oaitun_enm");
tun_config(1, "10.0.2.1", NULL, "oaitun_enm");
LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n");
}
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
} else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) {
netlink_init_mbms_tun("oaitun_enm", 0);
nas_config(1, "10.0.2.1", NULL, "oaitun_enm");
tun_config(1, "10.0.2.1", NULL, "oaitun_enm");
LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n");
}
......
......@@ -594,7 +594,7 @@ void nr_pdcp_layer_init(bool uses_e1)
#include "nfapi/oai_integration/vendor_ext.h"
#include "executables/lte-softmodem.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
{
......@@ -618,7 +618,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
netlink_init_tun(ifprefix, num_if, id);
if (IS_SOFTMODEM_NOS1) {
const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3";
nas_config(1, ip, NULL, ifprefix);
tun_config(1, ip, NULL, ifprefix);
set_qfi_pduid(7, 10);
}
LOG_I(PDCP, "UE pdcp will use tun interface\n");
......@@ -626,7 +626,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
} else if (ENB_NAS_USE_TUN) {
char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb";
netlink_init_tun(ifprefix, 1, id);
nas_config(1, "10.0.1.1", NULL, ifprefix);
tun_config(1, "10.0.1.1", NULL, ifprefix);
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
start_pdcp_tun_enb();
}
......
......@@ -67,7 +67,7 @@
#include "NR_RAT-Type.h"
#include "NR_UE-CapabilityRAT-Container.h"
#include "RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
#if ENABLE_RAL
#include "rrc_UE_ral.h"
#endif
......@@ -771,7 +771,7 @@ rrc_ue_establish_drb(
"10.0.%d.%d",
UE_NAS_USE_TUN ? 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, ip, NULL, "oaitun_oip");
oip_ifup = tun_config(ip_addr_offset3 + ue_mod_idP + 1, ip, NULL, "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",
......
......@@ -78,7 +78,7 @@
#include "T.h"
#include "LTE_MeasResults.h"
#include "RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
#include "rrc_eNB_S1AP.h"
#include "rrc_eNB_GTPV1U.h"
......@@ -5257,7 +5257,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
ctxt_pP->module_id);
char ip[20];
snprintf(ip, sizeof(ip), "10.0.%d.%d", ctxt_pP->module_id + 1, ctxt_pP->module_id + 1);
oip_ifup = nas_config(ctxt_pP->module_id, ip, NULL, "oaitun_oai");
oip_ifup = tun_config(ctxt_pP->module_id, ip, NULL, "oaitun_oai");
if (oip_ifup == 0) { // interface is up --> send a config the DRB
module_id_t ue_module_id;
......
......@@ -22,7 +22,7 @@
#include "PduSessionEstablishmentAccept.h"
#include "common/utils/LOG/log.h"
#include "nr_nas_msg_sim.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
#include "openair2/SDAP/nr_sdap/nr_sdap.h"
static uint16_t getShort(uint8_t *input)
......@@ -132,14 +132,14 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
addr[i] = *curPtr++;
char ip[20];
capture_ipv4_addr(&addr[0], ip, sizeof(ip));
nas_config(1, ip, NULL, "oaitun_ue");
tun_config(1, ip, NULL, "oaitun_ue");
setup_ue_ipv4_route(1, ip, "oaitun_ue");
} else if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV6) {
for (int i = 0; i < 8; ++i)
addr[i] = *curPtr++;
char ipv6[40];
capture_ipv6_addr(addr, ipv6, sizeof(ipv6));
nas_config(1, NULL, ipv6, "oaitun_ue");
tun_config(1, NULL, ipv6, "oaitun_ue");
} else if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4V6) {
// 24.501 Sec 9.11.4.10: "If the PDU session type value indicates
// IPv4v6, the PDU address information in octet 4 to octet 11
......@@ -151,7 +151,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
capture_ipv6_addr(addr, ipv6, sizeof(ipv6));
char ipv4[20];
capture_ipv4_addr(&addr[8], ipv4, sizeof(ipv4));
nas_config(1, ipv4, ipv6, "oaitun_ue");
tun_config(1, ipv4, ipv6, "oaitun_ue");
setup_ue_ipv4_route(1, ipv4, "oaitun_ue");
} else {
LOG_E(NAS, "unknown/unhandled PDU session establishment accept PDU type %d\n", psea_msg.pdu_addr_ie.pdu_type);
......
......@@ -46,7 +46,7 @@
#include "RegistrationAccept.h"
#include "FGSDeregistrationRequestUEOriginating.h"
#include "intertask_interface.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
#include <openair3/NAS/COMMON/NR_NAS_defs.h>
#include <openair1/SIMULATION/ETH_TRANSPORT/proto.h>
#include "openair2/SDAP/nr_sdap/nr_sdap.h"
......@@ -845,7 +845,7 @@ void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buff
char ip[20];
sprintf(ip, "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3));
LOG_A(NAS, "Received PDU Session Establishment Accept\n");
nas_config(1, ip, NULL, "oaitun_ue");
tun_config(1, ip, NULL, "oaitun_ue");
setup_ue_ipv4_route(1, ip, "oaitun_ue");
} else {
LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type);
......@@ -1432,7 +1432,7 @@ void *nas_nrue(void *args_p)
char ip[20];
snprintf(ip, sizeof(ip), "%d.%d.%d.%d", *(ip_p), *(ip_p + 1), *(ip_p + 2), *(ip_p + 3));
LOG_I(NAS, "Received PDU Session Establishment Accept, UE IP: %s\n", ip);
nas_config(1, ip, NULL, "oaitun_ue");
tun_config(1, ip, NULL, "oaitun_ue");
setup_ue_ipv4_route(1, ip, "oaitun_ue");
break;
}
......
......@@ -45,7 +45,7 @@ Description Defines functions used to handle EPS bearer contexts.
#include "esm_ebr.h"
#include "esm_ebr_context.h"
#include "openair2/RRC/NAS/nas_config.h"
#include "common/utils/tun_if.h"
#include "emm_sap.h"
#include "system.h"
......@@ -207,7 +207,7 @@ int esm_ebr_context_create(
char *ip_addr = pdn->ip_addr;
snprintf(ip, sizeof(ip), "%d.%d.%d.%d", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]);
const char *ifn = get_softmodem_params()->nsa ? "oaitun_nru" : "oaitun_ue";
nas_config(1, ip, NULL, ifn);
tun_config(1, ip, NULL, ifn);
setup_ue_ipv4_route(1, ip, ifn);
} break;
......
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