Remove netlink_init.c, and move remaining functionality to tun_if.c
Remove openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c, and move TUN interface creation functionality to tun_if.c. Remove SIMU_ETH target.
This commit is contained in:
+9
-14
@@ -1878,11 +1878,6 @@ set (SIMUSRC
|
||||
add_library(SIMU STATIC ${SIMUSRC} )
|
||||
target_include_directories(SIMU PUBLIC ${OPENAIR1_DIR}/SIMULATION/TOOLS ${OPENAIR1_DIR}/SIMULATION/RF)
|
||||
|
||||
add_library(SIMU_ETH STATIC
|
||||
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
|
||||
)
|
||||
target_link_libraries(SIMU_ETH PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
|
||||
|
||||
include_directories("${NFAPI_DIR}/nfapi/public_inc")
|
||||
include_directories("${NFAPI_DIR}/common/public_inc")
|
||||
include_directories("${NFAPI_DIR}/pnf/public_inc")
|
||||
@@ -1943,7 +1938,7 @@ target_link_libraries(lte-softmodem PRIVATE
|
||||
-Wl,--start-group
|
||||
lte_rrc nr_rrc s1ap m2ap x2ap m3ap GTPV1U SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB
|
||||
PHY_COMMON PHY PHY_RU L2 L2_LTE NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
|
||||
${NAS_UE_LIB} ITTI SIMU SIMU_ETH shlib_loader
|
||||
${NAS_UE_LIB} ITTI SIMU shlib_loader
|
||||
-Wl,--end-group z dl)
|
||||
|
||||
target_link_libraries(lte-softmodem PRIVATE pthread m CONFIG_LIB rt sctp)
|
||||
@@ -1997,7 +1992,7 @@ target_link_libraries(lte-uesoftmodem PRIVATE
|
||||
-Wl,--start-group
|
||||
lte_rrc nr_rrc s1ap x2ap m2ap m3ap
|
||||
SECURITY UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON
|
||||
PHY_UE PHY_RU L2_UE L2_LTE SIMU SIMU_ETH NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
|
||||
PHY_UE PHY_RU L2_UE L2_LTE SIMU NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
|
||||
${NAS_UE_LIB} ITTI shlib_loader
|
||||
-Wl,--end-group z dl)
|
||||
|
||||
@@ -2032,7 +2027,7 @@ target_link_libraries(nr-softmodem PRIVATE
|
||||
-Wl,--start-group
|
||||
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU GTPV1U SECURITY
|
||||
ITTI ${NAS_UE_LIB} lte_rrc nr_rrc
|
||||
ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU SIMU_ETH
|
||||
ngap s1ap L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB SIMU
|
||||
x2ap f1ap m2ap m3ap e1ap shlib_loader
|
||||
-Wl,--end-group z dl)
|
||||
|
||||
@@ -2071,7 +2066,7 @@ add_executable(nr-cuup
|
||||
|
||||
target_link_libraries(nr-cuup PRIVATE
|
||||
CONFIG_LIB ITTI SCTP_CLIENT
|
||||
GTPV1U e1ap f1ap SIMU_ETH
|
||||
GTPV1U e1ap f1ap
|
||||
z sctp dl pthread shlib_loader ${T_LIB})
|
||||
target_link_libraries(nr-cuup PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
|
||||
if(E2_AGENT)
|
||||
@@ -2100,7 +2095,7 @@ target_link_libraries(nr-uesoftmodem PRIVATE
|
||||
nr_rrc SECURITY UTIL HASHTABLE SCHED_RU_LIB SCHED_NR_UE_LIB
|
||||
PHY_COMMON PHY_NR_COMMON PHY_NR_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_LIB NFAPI_PNF_LIB
|
||||
NFAPI_USER_LIB MISC_NFAPI_NR_LIB
|
||||
ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU SIMU_ETH shlib_loader
|
||||
ITTI LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} SIMU shlib_loader
|
||||
-Wl,--end-group z dl)
|
||||
|
||||
target_link_libraries(nr-uesoftmodem PRIVATE pthread m CONFIG_LIB rt)
|
||||
@@ -2206,7 +2201,7 @@ add_executable(nr_psbchsim
|
||||
${PHY_INTERFACE_DIR}/queue_t.c
|
||||
)
|
||||
target_link_libraries(nr_psbchsim PRIVATE
|
||||
-Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON CONFIG_LIB L2_NR -lz -Wl,--end-group
|
||||
-Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON CONFIG_LIB L2_NR -lz -Wl,--end-group
|
||||
m pthread ${T_LIB} ITTI dl shlib_loader
|
||||
)
|
||||
target_link_libraries(nr_psbchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
|
||||
@@ -2232,7 +2227,7 @@ add_executable(nr_dlsim
|
||||
${PHY_INTERFACE_DIR}/queue_t.c
|
||||
)
|
||||
target_link_libraries(nr_dlsim PRIVATE
|
||||
-Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group
|
||||
-Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group
|
||||
m pthread ${T_LIB} ITTI dl shlib_loader
|
||||
)
|
||||
target_link_libraries(nr_dlsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
|
||||
@@ -2272,7 +2267,7 @@ if (ENABLE_LDPC_T2)
|
||||
endif()
|
||||
|
||||
target_link_libraries(nr_ulsim PRIVATE
|
||||
-Wl,--start-group UTIL SIMU SIMU_ETH PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group
|
||||
-Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group
|
||||
m pthread ${T_LIB} ITTI dl shlib_loader
|
||||
)
|
||||
target_link_libraries(nr_ulsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
|
||||
@@ -2335,7 +2330,7 @@ if (${T_TRACER})
|
||||
MISC_NFAPI_LTE_LIB MISC_NFAPI_NR_LIB
|
||||
PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX
|
||||
L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_UE_NR ngap
|
||||
CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU SIMU_ETH OPENAIR0_LIB
|
||||
CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU OPENAIR0_LIB
|
||||
ldpc_orig ldpc_optim ldpc_optim8seg ldpc_t2 ldpc_cl ldpc_cuda ldpc dfts config_internals nr_common)
|
||||
if (TARGET ${i})
|
||||
add_dependencies(${i} generate_T)
|
||||
|
||||
@@ -27,11 +27,106 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/if_tun.h>
|
||||
#include <linux/netlink.h>
|
||||
|
||||
#include "tun_if.h"
|
||||
#include "common/platform_constants.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "common/utils/system.h"
|
||||
|
||||
int nas_sock_fd[MAX_MOBILES_PER_ENB * 2]; // Allocated for both LTE UE and NR UE.
|
||||
int nas_sock_mbms_fd;
|
||||
|
||||
static int tun_alloc(char *dev)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int fd, err;
|
||||
|
||||
if ((fd = open("/dev/net/tun", O_RDWR)) < 0) {
|
||||
LOG_E(UTIL, "failed to open /dev/net/tun\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
/* Flags: IFF_TUN - TUN device (no Ethernet headers)
|
||||
* IFF_TAP - TAP device
|
||||
*
|
||||
* IFF_NO_PI - Do not provide packet information
|
||||
*/
|
||||
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
|
||||
|
||||
if (*dev)
|
||||
strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
|
||||
|
||||
if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) {
|
||||
close(fd);
|
||||
return err;
|
||||
}
|
||||
|
||||
strcpy(dev, ifr.ifr_name);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int tun_init_mbms(char *ifprefix, int id)
|
||||
{
|
||||
int ret;
|
||||
char ifname[64];
|
||||
|
||||
sprintf(ifname, "%s%d", ifprefix, id);
|
||||
nas_sock_mbms_fd = tun_alloc(ifname);
|
||||
|
||||
if (nas_sock_mbms_fd == -1) {
|
||||
LOG_E(UTIL, "Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
LOG_D(UTIL, "Opened socket %s with fd %d\n", ifname, nas_sock_mbms_fd);
|
||||
ret = fcntl(nas_sock_mbms_fd, F_SETFL, O_NONBLOCK);
|
||||
|
||||
if (ret == -1) {
|
||||
LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sockaddr_nl nas_src_addr = {0};
|
||||
nas_src_addr.nl_family = AF_NETLINK;
|
||||
nas_src_addr.nl_pid = 1;
|
||||
nas_src_addr.nl_groups = 0; /* not in mcast groups */
|
||||
ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int tun_init(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, "%s%d", ifprefix, i + 1);
|
||||
nas_sock_fd[i] = tun_alloc(ifname);
|
||||
|
||||
if (nas_sock_fd[i] == -1) {
|
||||
LOG_E(UTIL, "Error opening socket %s (%d:%s)\n", ifname, errno, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG_I(UTIL, "Opened socket %s with fd nas_sock_fd[%d]=%d\n", ifname, i, nas_sock_fd[i]);
|
||||
ret = fcntl(nas_sock_fd[i], F_SETFL, O_NONBLOCK);
|
||||
|
||||
if (ret == -1) {
|
||||
LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief set a genneric interface parameter
|
||||
* \param ifn the name of the interface to modify
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* TODO: doc */
|
||||
int tun_init(const char *ifprefix, int num_if, int id);
|
||||
|
||||
/* TODO: doc */
|
||||
int tun_init_mbms(char *ifsuffix, int id);
|
||||
|
||||
/*! \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
|
||||
|
||||
@@ -2306,8 +2306,6 @@ INPUT = \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_freq_equalization.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/proto.h \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/adc.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/dac.c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/SIMULATION/RF/rf.h \
|
||||
|
||||
@@ -85,7 +85,6 @@
|
||||
#include "executables/lte-softmodem.h"
|
||||
|
||||
#include "s1ap_eNB.h"
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
|
||||
#include "T.h"
|
||||
|
||||
|
||||
@@ -72,8 +72,6 @@ static int DEFRUTPCORES[] = {2,4,6,8};
|
||||
#include "ENB_APP/enb_paramdef.h"
|
||||
#include "common/config/config_userapi.h"
|
||||
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
|
||||
#include "T.h"
|
||||
|
||||
#include "executables/softmodem-common.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "PHY/defs_eNB.h"
|
||||
#include "PHY/defs_UE.h"
|
||||
#include "s1ap_eNB.h"
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
#include "executables/softmodem-common.h"
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@
|
||||
#include "UTIL/OPT/opt.h"
|
||||
#include "gnb_paramdef.h"
|
||||
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
#include <executables/softmodem-common.h>
|
||||
|
||||
#include "T.h"
|
||||
|
||||
@@ -65,7 +65,6 @@ static int DEFRUTPCORES[] = {-1,-1,-1,-1};
|
||||
#include "GNB_APP/gnb_paramdef.h"
|
||||
#include "common/config/config_userapi.h"
|
||||
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
#include <openair1/PHY/TOOLS/phy_scope_interface.h>
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "PHY/types.h"
|
||||
#include <threadPool/thread-pool.h>
|
||||
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
|
||||
/* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
|
||||
#define CONFIG_HLP_RFCFGF "Configuration file for front-end (e.g. LMS7002M)\n"
|
||||
#define CONFIG_HLP_ULMAXE "set the eNodeB max ULSCH erros\n"
|
||||
|
||||
@@ -140,8 +140,6 @@ uint8_t nb_antenna_rx = 1;
|
||||
|
||||
int otg_enabled;
|
||||
|
||||
#include <SIMULATION/ETH_TRANSPORT/proto.h>
|
||||
|
||||
extern void reset_opp_meas(void);
|
||||
extern void print_opp_meas(void);
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
#include <executables/nr-softmodem-common.h>
|
||||
#include <executables/softmodem-common.h>
|
||||
#include "PHY/defs_nr_UE.h"
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
|
||||
|
||||
|
||||
#define CONFIG_HLP_IF_FREQ "IF frequency for RF, if needed\n"
|
||||
#define CONFIG_HLP_IF_FREQ_OFF "UL IF frequency offset for RF, if needed\n"
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
For reliable UDP multicast, the libpgm-dev should be installed on the machines,
|
||||
otherwise the old multicast method using simply UDP will be used, resulting in
|
||||
packet loss and unexpected behaviour of oaisim.
|
||||
|
||||
To compile OAI with PGM:
|
||||
|
||||
For Ubuntu 12.04 and earliers:
|
||||
sudo apt-get install libpgm-dev
|
||||
is sufficient
|
||||
|
||||
For Ubuntu older than 12.04:
|
||||
|
||||
wget http://openpgm.googlecode.com/files/libpgm-5.1.118.tar.gz
|
||||
tar xvf libpgm-5.1.118.tar.gz
|
||||
cd libpgm-5.1.118/openpgm/pgm
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
sudo make install
|
||||
|
||||
We have to clean oaisim compilation and re-compile
|
||||
|
||||
|
||||
When running OAI, the -D should be used to provide the NIC to bind.
|
||||
Parameter can be either an interface name or an ip address (refer to this link
|
||||
for more informations: http://code.google.com/p/openpgm/wiki/OpenPgmConceptsTransport)
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file extern.h
|
||||
* \brief specifies the extern variables for phy emulation
|
||||
* \author Navid Nikaein and Raymomd Knopp and Hicham Anouar
|
||||
* \date 2011
|
||||
* \version 1.1
|
||||
* \company Eurecom
|
||||
* \email: navid.nikaein@eurecom.fr
|
||||
*/
|
||||
|
||||
#ifndef __BYPASS_SESSION_LAYER_EXTERN_H__
|
||||
# define __BYPASS_SESSION_LAYER_EXTERN_H__
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
extern unsigned char Emulation_status;
|
||||
extern unsigned char emu_tx_status;
|
||||
extern unsigned char emu_rx_status;
|
||||
//extern unsigned int Master_list;
|
||||
//extern unsigned short Master_id;
|
||||
//extern unsigned int Is_primary_master;
|
||||
|
||||
#if !defined(ENABLE_NEW_MULTICAST)
|
||||
extern pthread_mutex_t Tx_mutex;
|
||||
extern pthread_cond_t Tx_cond;
|
||||
extern char Tx_mutex_var;
|
||||
#endif
|
||||
|
||||
extern rx_handler_t rx_handler;
|
||||
extern tx_handler_t tx_handler;
|
||||
|
||||
extern eNB_transport_info_t eNB_transport_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
|
||||
extern uint16_t eNB_transport_info_TB_index[NUMBER_OF_eNB_MAX][MAX_NUM_CCs];
|
||||
|
||||
extern UE_transport_info_t UE_transport_info[NUMBER_OF_UE_MAX][MAX_NUM_CCs];
|
||||
|
||||
extern UE_cntl ue_cntl_delay[NUMBER_OF_UE_MAX][MAX_NUM_CCs][2];
|
||||
|
||||
#endif
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include <linux/netlink.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
|
||||
#include "common/platform_constants.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
int nas_sock_fd[MAX_MOBILES_PER_ENB * 2]; // Allocated for both LTE UE and NR UE.
|
||||
int nas_sock_mbms_fd;
|
||||
|
||||
static int tun_alloc(char *dev)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int fd, err;
|
||||
|
||||
if ((fd = open("/dev/net/tun", O_RDWR)) < 0) {
|
||||
LOG_E(UTIL, "failed to open /dev/net/tun\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
/* Flags: IFF_TUN - TUN device (no Ethernet headers)
|
||||
* IFF_TAP - TAP device
|
||||
*
|
||||
* IFF_NO_PI - Do not provide packet information
|
||||
*/
|
||||
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
|
||||
|
||||
if (*dev)
|
||||
strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
|
||||
|
||||
if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) {
|
||||
close(fd);
|
||||
return err;
|
||||
}
|
||||
|
||||
strcpy(dev, ifr.ifr_name);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int netlink_init_mbms_tun(char *ifprefix, int id)
|
||||
{
|
||||
int ret;
|
||||
char ifname[64];
|
||||
|
||||
sprintf(ifname, "%s%d", ifprefix, id);
|
||||
nas_sock_mbms_fd = tun_alloc(ifname);
|
||||
|
||||
if (nas_sock_mbms_fd == -1) {
|
||||
LOG_E(UTIL, "Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
LOG_D(UTIL, "Opened socket %s with fd %d\n", ifname, nas_sock_mbms_fd);
|
||||
ret = fcntl(nas_sock_mbms_fd, F_SETFL, O_NONBLOCK);
|
||||
|
||||
if (ret == -1) {
|
||||
LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sockaddr_nl nas_src_addr = {0};
|
||||
nas_src_addr.nl_family = AF_NETLINK;
|
||||
nas_src_addr.nl_pid = 1;
|
||||
nas_src_addr.nl_groups = 0; /* not in mcast groups */
|
||||
ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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, "%s%d", ifprefix, i + 1);
|
||||
nas_sock_fd[i] = tun_alloc(ifname);
|
||||
|
||||
if (nas_sock_fd[i] == -1) {
|
||||
LOG_E(UTIL, "Error opening socket %s (%d:%s)\n", ifname, errno, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG_I(UTIL, "Opened socket %s with fd nas_sock_fd[%d]=%d\n", ifname, i, nas_sock_fd[i]);
|
||||
ret = fcntl(nas_sock_fd[i], F_SETFL, O_NONBLOCK);
|
||||
|
||||
if (ret == -1) {
|
||||
LOG_E(UTIL, "Error fcntl (%d:%s)\n", errno, strerror(errno));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file proto.h
|
||||
* \brief
|
||||
* \author Navid Nikaein
|
||||
* \date 2011
|
||||
* \version 1.0
|
||||
* \company Eurecom
|
||||
* \email: navid.nikaein@eurecom.fr
|
||||
*/
|
||||
|
||||
#ifndef EMU_PROTO_H_
|
||||
#define EMU_PROTO_H_
|
||||
|
||||
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_ */
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "common/ngran_types.h"
|
||||
#include "common/openairinterface5g_limits.h"
|
||||
#include "executables/lte-softmodem.h"
|
||||
#include "SIMULATION/ETH_TRANSPORT/proto.h"
|
||||
#include "common/utils/tun_if.h"
|
||||
#include "intertask_interface.h"
|
||||
#include "openair3/S1AP/s1ap_eNB.h"
|
||||
@@ -2298,23 +2297,23 @@ 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("oaitun_ue", num_if, id);
|
||||
tun_init("oaitun_ue", num_if, id);
|
||||
if (IS_SOFTMODEM_NOS1)
|
||||
tun_config(1, "10.0.1.2", NULL, "oaitun_ue");
|
||||
netlink_init_mbms_tun("oaitun_uem", id + 1);
|
||||
tun_init_mbms("oaitun_uem", id + 1);
|
||||
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);
|
||||
tun_init("oaitun_enb", 1, 0);
|
||||
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);
|
||||
tun_init_mbms("oaitun_enm", 1);
|
||||
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);
|
||||
tun_init_mbms("oaitun_enm", 0);
|
||||
tun_config(1, "10.0.2.1", NULL, "oaitun_enm");
|
||||
LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n");
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ uint64_t nr_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(ifprefix, num_if, id);
|
||||
tun_init(ifprefix, num_if, id);
|
||||
if (IS_SOFTMODEM_NOS1) {
|
||||
const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3";
|
||||
tun_config(1, ip, NULL, ifprefix);
|
||||
@@ -625,7 +625,7 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id)
|
||||
start_pdcp_tun_ue();
|
||||
} else if (ENB_NAS_USE_TUN) {
|
||||
char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb";
|
||||
netlink_init_tun(ifprefix, 1, id);
|
||||
tun_init(ifprefix, 1, id);
|
||||
tun_config(1, "10.0.1.1", NULL, ifprefix);
|
||||
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
|
||||
start_pdcp_tun_enb();
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "intertask_interface.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"
|
||||
#include "openair3/SECU/nas_stream_eia2.h"
|
||||
#include "openair3/UTILS/conversions.h"
|
||||
|
||||
Reference in New Issue
Block a user