Commit f92bd915 authored by Cedric Roux's avatar Cedric Roux

Merge branch 'enhancement-199-nas-multi-ue' into develop_integration_w07

 Conflicts:
	openair1/SCHED/phy_procedures_lte_ue.c
	targets/RT/USER/lte-softmodem.c
	targets/SIMU/USER/oaisim.c
	targets/SIMU/USER/oaisim_functions.c
parents bfa8a28c 6397e66c
......@@ -1759,6 +1759,7 @@ add_executable(lte-softmodem
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/utils.c
${GTPU_need_ITTI}
${HW_SOURCE}
${TRANSPORT_SOURCE}
......@@ -1889,6 +1890,7 @@ add_executable(oaisim
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR2_DIR}/RRC/NAS/rb_config.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/utils.c
${GTPU_need_ITTI}
${OPENAIR_TARGETS}/COMMON/create_tasks.c
${HW_SOURCE}
......
......@@ -88,31 +88,47 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2 -std=gnu99 -Wall -Wstrict-prototype
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -DMALLOC_CHECK_=3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb -DMALLOC_CHECK_=3 -O2")
#This is to detect nettle version changes between Ubuntu 14.04/16.04
set ( nettle_cmd "nettle-hash" )
set ( nettle_arg "-V" )
execute_process(COMMAND ${nettle_cmd} ${nettle_arg} RESULT_VARIABLE rv OUTPUT_VARIABLE ov ERROR_VARIABLE ev)
##This is to detect nettle version changes between Ubuntu 14.04/16.04
#set ( nettle_cmd "nettle-hash" )
#set ( nettle_arg "-V" )
#execute_process(COMMAND ${nettle_cmd} ${nettle_arg} RESULT_VARIABLE rv OUTPUT_VARIABLE ov ERROR_VARIABLE ev)
#
#string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${ov})
#
#message("NETTLE_VERSION = ${nv}")
#
## we need to remove decimal as floating point arithematic does not work properly with C preprocessor
#STRING(REGEX REPLACE "[.]" "" nv ${nv})
#
#if ("${nv}" STREQUAL "")
# message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" )
#endif()
#
#set (NETTLE_VERSION "${nv}")
#add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}")
include(FindPkgConfig)
string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${ov})
pkg_search_module(NETTLE nettle)
if(NOT ${NETTLE_FOUND})
message( FATAL_ERROR "PACKAGE nettle not found: some targets will fail. Run build_oai -I again!")
else()
include_directories(${NETTLE_INCLUDE_DIRS})
endif()
message("NETTLE_VERSION = ${nv}")
message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}")
# we need to remove decimal as floating point arithematic does not work properly with C preprocessor
STRING(REGEX REPLACE "[.]" "" nv ${nv})
string(REGEX REPLACE "([0-9]+).*" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION})
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION})
message ("NETTLE_VERSION_MAJOR = ${NETTLE_VERSION_MAJOR}")
message ("NETTLE_VERSION_MINOR = ${NETTLE_VERSION_MINOR}")
if ("${nv}" STREQUAL "")
if ("${NETTLE_VERSION_MAJOR}" STREQUAL "" OR "${NETTLE_VERSION_MINOR}" STREQUAL "")
message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" )
endif()
set (NETTLE_VERSION "${nv}")
add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}")
include(FindPkgConfig)
INCLUDE(FindNettle)
IF( NOT NETTLE_FOUND )
MESSAGE( SEND_ERROR "Nettle is required" )
ENDIF( NOT NETTLE_FOUND )
add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}")
add_definitions("-DNETTLE_VERSION_MINOR=${NETTLE_VERSION_MINOR}")
pkg_search_module(OPENSSL openssl REQUIRED)
......@@ -215,8 +231,8 @@ set(api_user_HDR
add_library(api_user ${api_user_SRC} ${api_user_HDR})
target_include_directories(api_user PRIVATE ${OPENAIR_NAS_DIR}/UE/API/USER
${OPENAIR_NAS_DIR}/UE
${OPENAIR_NAS_DIR}/COMMON
${OPENAIR_NAS_DIR}/UE
)
################################################################################
......@@ -397,6 +413,7 @@ target_include_directories(emm PRIVATE
${OPENAIR_DIR}/common/utils/msc
${OPENAIR_DIR}/common/utils
${OPENAIR_DIR}/openair2/COMMON
${OPENAIR_NAS_DIR}/UE
${OPENAIR_NAS_DIR}/UE/API/USIM
${OPENAIR_NAS_DIR}/UE/EMM
${OPENAIR_NAS_DIR}/COMMON/EMM/MSG
......@@ -409,7 +426,6 @@ target_include_directories(emm PRIVATE
# esm LIB
################################################################################
set(esm_SRC
${OPENAIR_NAS_DIR}/UE/ESM/esm_main.c
${OPENAIR_NAS_DIR}/UE/ESM/DedicatedEpsBearerContextActivation.c
${OPENAIR_NAS_DIR}/UE/ESM/DefaultEpsBearerContextActivation.c
${OPENAIR_NAS_DIR}/UE/ESM/EpsBearerContextDeactivation.c
......@@ -452,6 +468,7 @@ set(esm_SRC
)
set(esm_HDR
${OPENAIR_TARGETS}/COMMON/openairinterface5g_limits.h
${OPENAIR_NAS_DIR}/UE/ESM/esm_main.h
${OPENAIR_NAS_DIR}/COMMON/ESM/MSG/ActivateDedicatedEpsBearerContextAccept.h
${OPENAIR_NAS_DIR}/COMMON/ESM/MSG/ActivateDedicatedEpsBearerContextReject.h
......@@ -481,13 +498,17 @@ set(esm_HDR
${OPENAIR_NAS_DIR}/UE/ESM/SAP/esm_recv.h
${OPENAIR_NAS_DIR}/UE/ESM/SAP/esm_sap.h
${OPENAIR_NAS_DIR}/UE/ESM/SAP/esm_send.h
${OPENAIR_DIR}/common/utils/utils.h
)
add_library(esm ${esm_SRC} ${esm_HDR})
target_include_directories(esm PRIVATE
${OPENAIR_DIR}/common/utils
${OPENAIR_NAS_DIR}/UE
${OPENAIR_NAS_DIR}/UE/API/USER
${OPENAIR_NAS_DIR}/UE/ESM
${OPENAIR_TARGETS}/COMMON
${OPENAIR_NAS_DIR}/COMMON/ESM/MSG
${OPENAIR_NAS_DIR}/UE/ESM/SAP
${OPENAIR_NAS_DIR}/COMMON/IES
......@@ -670,6 +691,9 @@ target_include_directories(ies PRIVATE
# EXECUTABLE at_nas_ue
################################################################################
include_directories(
${OPENAIR_TARGETS}/COMMON
${OPENAIR_NAS_DIR}/UE
${OPENAIR_DIR}/common/utils
${OPENAIR_DIR}/common/utils/msc
${OPENAIR3_DIR}/COMMON
${OPENAIR3_DIR}/SECU
......@@ -691,6 +715,7 @@ ADD_EXECUTABLE(at_nas_ue ${OPENAIR_NAS_DIR}/UE/UEprocess.c
${OPENAIR_NAS_DIR}/UE/nas_parser.c
${OPENAIR_NAS_DIR}/UE/nas_proc.c
${OPENAIR_NAS_DIR}/UE/nas_user.c
${OPENAIR_DIR}/common/utils/utils.c
)
target_link_libraries (at_nas_ue
......
......@@ -57,17 +57,20 @@ CMAKE_BUILD_TYPE=""
UE_AUTOTEST_TRACE="False"
trap handle_ctrl_c INT
gen_nvram_path=$OPENAIR_DIR/targets/bin
conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf
function print_help() {
echo_info '
echo_info "
This program installs OpenAirInterface Software
You should have ubuntu 14.xx, updated, and the Linux kernel >= 3.14
Options
-h
This help
-c | --clean
Erase all files to make a rebuild from start"
Erase all files to make a rebuild from start
-C | --clean-all
Erase all files made by previous compilations, installations"
Erase all files made by previous compilations, installations
--clean-kernel
Erase previously installed features in kernel: iptables, drivers, ...
-I | --install-external-packages
......@@ -82,7 +85,11 @@ Options
--eNB
Makes the LTE softmodem
--UE
Makes the UE specific parts (ue_ip, usim, nvram)
Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file
--UE-conf-nvram [configuration file]
Specify conf_nvram_path (default \"$conf_nvram_path\")
--UE-gen-nvram [output path]
Specify gen_nvram_path (default \"$gen_nvram_path\")
--RRH
Makes the RRH
-a | --agent
......@@ -97,7 +104,7 @@ Options
ETHERNET , None
Adds this trasport protocol support in compilation
--oaisim
Makes the oaisim simulator. Hardware will be defaulted to "None".
Makes the oaisim simulator. Hardware will be defaulted to \"None\".
--phy_simulators
Makes the unitary tests Layer 1 simulators
--core_simulators
......@@ -140,11 +147,12 @@ Usage (first build):
Usage (Regular):
oaisim : ./build_oai --oaisim -x
Eurecom EXMIMO + OAI ENB : ./build_oai --eNB -x
NI/ETTUS B201 + OAI ENB : ./build_oai --eNB -x -w USRP'
NI/ETTUS B201 + OAI ENB : ./build_oai --eNB -x -w USRP"
}
function main() {
until [ -z "$1" ]
do
case "$1" in
......@@ -183,6 +191,12 @@ function main() {
UE=1
echo_info "Will compile UE"
shift;;
--UE-conf-nvram)
conf_nvram_path=$(readlink -f "$1")
shift 2;;
--UE-gen-nvram)
gen_nvram_path=$(readlink -f $2)
shift 2;;
--RRH)
RRH=1
echo_info "Will compile RRH"
......@@ -517,15 +531,17 @@ function main() {
compilations \
nas_sim_tools nvram \
nvram $dbin/nvram
compilations \
nas_sim_tools conf2uedata \
conf2uedata $dbin/conf2uedata
# generate USIM data
if [ -f $dbin/nvram ]; then
install_nas_tools $dbin $dconf
if [ -f $dbin/conf2uedata ]; then
install_nas_tools $conf_nvram_path $gen_nvram_path
echo_info "Copying UE specific part to $DIR/$lte_build_dir/build"
cp -Rvf $dbin/.ue_emm.nvram $DIR/$lte_build_dir/build
cp -Rvf $dbin/.ue.nvram $DIR/$lte_build_dir/build
cp -Rvf $dbin/.usim.nvram $DIR/$lte_build_dir/build
cp -Rvf $dbin/.ue_emm.nvram0 $DIR/$lte_build_dir/build
cp -Rvf $dbin/.ue.nvram0 $DIR/$lte_build_dir/build
cp -Rvf $dbin/.usim.nvram0 $DIR/$lte_build_dir/build
else
echo_warning "not generated UE NAS files: binaries not found"
fi
......@@ -647,10 +663,13 @@ function main() {
compilations \
nas_sim_tools nvram \
nvram $dbin/nvram
compilations \
nas_sim_tools conf2uedata \
conf2uedata $dbin/conf2uedata
# generate USIM data
if [ -f $dbin/nvram ]; then
install_nas_tools $dbin $dconf
if [ -f $dbin/conf2uedata ]; then
install_nas_tools $conf_nvram_path $gen_nvram_path
else
echo_warning "not generated UE NAS files: binaries not found"
fi
......
......@@ -2,70 +2,89 @@ cmake_minimum_required(VERSION 2.8)
project(NAS_SIM_TOOLS)
include(FindPkgConfig)
pkg_search_module(CONFIG libconfig REQUIRED)
include_directories(${CONFIG_INCLUDE_DIRS})
add_definitions(-std=gnu99)
ENABLE_LANGUAGE(C)
#Sends the -std=c99 flag to the gcc compiler
add_definitions(-std=c99)
add_definitions(-DNAS_UE)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -Werror -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -g")
set(OPENAIR_DIR $ENV{OPENAIR_DIR})
set(OPENAIR1_DIR $ENV{OPENAIR_DIR}/openair1)
set(OPENAIR2_DIR $ENV{OPENAIR_DIR}/openair2)
set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3)
set(OPENAIR3_DIR $ENV{OPENAIR_DIR}/openair3)
set(OPENAIR_TARGETS $ENV{OPENAIR_DIR}/targets)
#set(EXECUTABLE_OUTPUT_PATH ${OPENAIR_DIR}/targets/bin)
# Add .h files for dependancies
set(usim_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/usim_data.c
set(CONF2UEDATA_LIB_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_emm.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_user_data.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_usim.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_network.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_user_plmn.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_parser.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/fs.c
${OPENAIR_DIR}/openair3/NAS/TOOLS/display.c
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.c
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/nas_log.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/OctetString.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.c
${OPENAIR_DIR}/common/utils/utils.c
)
set(usim_HDR
${OPENAIR_DIR}/openair3/NAS/TOOLS/network.h
set(conf2uedata_HDR
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf2uedata.h
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf_emm.h
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/usim_api.h
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/nas_log.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/OctetString.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.h
${OPENAIR_DIR}/common/utils/utils.h
)
include_directories(
${OPENAIR_DIR}/common/utils
${OPENAIR_DIR}/openair3/NAS/UE
${OPENAIR_DIR}/openair3/NAS/COMMON
${OPENAIR_DIR}/openair3/NAS/UE/API/USER
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM
${OPENAIR_DIR}/openair3/NAS/UE/EMM/
${OPENAIR_DIR}/openair3/NAS/UE/ESM/
${OPENAIR_DIR}/openair3/NAS/COMMON/IES/
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL
)
ADD_EXECUTABLE(usim ${usim_SRC} ${usim_HDR})
# conf2uedata binary
set(conf2uedata_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/conf2uedata.c
${CONF2UEDATA_LIB_SRC}
)
add_executable(conf2uedata ${conf2uedata_SRC} ${conf2uedata_HDR} )
target_link_libraries(conf2uedata ${CONFIG_LIBRARIES})
set(nvram_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/ue_data.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.c
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/nas_log.c
)
# usim binary
set(nvram_HDR
${OPENAIR_DIR}/openair3/NAS/UE/EMM/emmData.h
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/memory.h
${OPENAIR_DIR}/openair3/NAS/COMMON/userDef.h
set(usim_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/usim.c
${CONF2UEDATA_LIB_SRC}
)
ADD_EXECUTABLE(nvram ${nvram_SRC} ${nvram_HDR})
#install (TARGETS usim DESTINATION ${EXECUTABLE_OUTPUT_PATH})
#install (TARGETS nvram DESTINATION ${EXECUTABLE_OUTPUT_PATH})
add_executable(usim ${usim_SRC} ${conf2uedata_HDR} )
target_link_libraries(usim ${CONFIG_LIBRARIES})
# nvram binary
set(nvram_SRC
${OPENAIR_DIR}/openair3/NAS/TOOLS/nvram.c
${CONF2UEDATA_LIB_SRC}
)
#install(CODE "EXECUTE_PROCESS (COMMAND ${OPENAIR_TARGETS}/bin/nvram --gen WORKING_DIRECTORY ${OPENAIR_TARGETS}/bin)")
#install(CODE "EXECUTE_PROCESS (COMMAND ${OPENAIR_TARGETS}/bin/usim --gen WORKING_DIRECTORY ${OPENAIR_TARGETS}/bin)")
add_executable(nvram ${nvram_SRC} ${conf2uedata_HDR} )
target_link_libraries(nvram ${CONFIG_LIBRARIES})
......@@ -450,19 +450,18 @@ install_asn1c_from_source(){
################################################
install_nas_tools() {
cd $1
if [ ! -f .ue.nvram ]; then
if [ ! -f .ue.nvram0 ]; then
echo_success "generate .ue_emm.nvram .ue.nvram"
./nvram --gen
./nvram --gen -c $1 -o $2
else
[ ./nvram -nt .ue.nvram -o ./nvram -nt .ue_emm.nvram ] && ./nvram --gen
[ ./nvram -nt .ue.nvram0 -o ./nvram -nt .ue_emm.nvram0 ] && ./nvram --gen -c $1 -o $2
fi
if [ ! -f .usim.nvram ]; then
if [ ! -f .usim.nvram0 ]; then
echo_success "generate .usim.nvram"
./usim --gen
./usim --gen -c $1 -o $2
else
[ ./usim -nt .usim.nvram ] && ./usim --gen
[ ./usim -nt .usim.nvram0 ] && ./usim --gen -c $1 -o $2
fi
}
......
......@@ -247,12 +247,6 @@ function main()
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 1 table lte
ifconfig oip1 up
ip route add default dev oip1 table lte
# the actual IP address depends on the EPC/MME config file for address pool
ip route add from 192.188.0.0/24 table lte
ip route add to 192.188.0.0/24 table lte
exe_arguments="$exe_arguments -s15 -AAWGN -y1 -b1 -u1 -Q0"
......
export KERNEL_DIR=/lib/modules/$(shell uname -r)/
CC=gcc
CCC=gcc
linux := $(shell if [ `uname` = "Linux" ] ; then echo "1" ; else echo "0" ; fi)
CFLAGS += -std=gnu99
CFLAGS += -Wall -g -ggdb -Wstrict-prototypes -fno-strict-aliasing
# Need to force this option because default kernel module builder is wrong
CFLAGS += $(call cc-option,-mpreferred-stack-boundary=4)
#For performance, if some option doesn't exist in all gcc versions, use $(call cc-option,MY_OPTION)
#CFLAGS += -O2
#CFLAGS += -funroll-loops
CFLAGS += -Wno-packed-bitfield-compat
# This is the minimum CPU faetures for OAI
CFLAGS += -mmmx -msse -msse2 -mssse3 -msse4.1
# Add CPU features from local CPU
#CFLAGS += -march=native
ifeq ($(OSTYPE),Cygwin)
cygwin=1
CFLAGS += -DCYGWIN
else
cygwin=0
endif
ifeq ($(linux),1)
CFLAGS +=
LDFLAGS +=
endif
ITTI_DIR = $(COMMON_UTILS_DIR)/itti
ITTI_OBJS = $(ITTI_DIR)/intertask_interface.o
ITTI_OBJS += $(ITTI_DIR)/intertask_interface_dump.o
ITTI_OBJS += $(ITTI_DIR)/backtrace.o
ITTI_OBJS += $(ITTI_DIR)/memory_pools.o
ITTI_OBJS += $(ITTI_DIR)/signals.o
ITTI_OBJS += $(ITTI_DIR)/timer.o
HASHTABLE_DIR = $(COMMON_UTILS_DIR)/collection/hashtable
MSC_DIR = $(COMMON_UTILS_DIR)/msc
HASHTABLE_OBJS = $(HASHTABLE_DIR)/hashtable.o
HASHTABLE_OBJS += $(HASHTABLE_DIR)/obj_hashtable.o
UTILS_OBJS = $(ITTI_OBJS) $(HASHTABLE_OBJS)
UTILS_incl = \
-I$(COMMON_UTILS_DIR) \
-I$(HASHTABLE_DIR) \
-I$(ITTI_DIR) \
-I$(MSC_DIR)
print-% : ; @echo $* = $($*)
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "utils.h"
void *calloc_or_fail(size_t size) {
void *ptr = calloc(1, size);
if (ptr == NULL) {
fprintf(stderr, "[UE] Failed to calloc %zu bytes", size);
exit(EXIT_FAILURE);
}
return ptr;
}
void *malloc_or_fail(size_t size) {
void *ptr = malloc(size);
if (ptr == NULL) {
fprintf(stderr, "[UE] Failed to malloc %zu bytes", size);
exit(EXIT_FAILURE);
}
return ptr;
}
/****************************************************************************
** **
** Name: hex_char_to_hex_value() **
** **
** Description: Converts an hexadecimal ASCII coded digit into its value. **
** **
** Inputs: c: A char holding the ASCII coded value **
** Others: None **
** **
** Outputs: None **
** Return: Converted value (-1 on error) **
** Others: None **
** **
***************************************************************************/
int hex_char_to_hex_value (char c)
{
if (!((c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F') ||
(c >= '0' && c <= '9')))
return -1;
if (c >= 'A') {
/* Remove case bit */
c &= ~('a' ^ 'A');
return (c - 'A' + 10);
} else {
return (c - '0');
}
}
/****************************************************************************
** **
** Name: hex_string_to_hex_value() **
** **
** Description: Converts an hexadecimal ASCII coded string into its value.**
** **
** Inputs: hex_value: A pointer to the location to store the **
** conversion result **
** size: The size of hex_value in bytes **
** Others: None **
** **
** Outputs: hex_value: Converted value **
** Return: 0 on success, -1 on error **
** Others: None **
** **
***************************************************************************/
int hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int size)
{
int i;
if (strlen(hex_string) != size*2) {
fprintf(stderr, "the string '%s' should be of length %d\n", hex_string, size*2);
return -1;
}
for (i=0; i < size; i++) {
int a = hex_char_to_hex_value(hex_string[2 * i]);
int b = hex_char_to_hex_value(hex_string[2 * i + 1]);
if (a == -1 || b == -1) goto error;
hex_value[i] = (a << 4) | b;
}
return 0;
error:
fprintf(stderr, "the string '%s' is not a valid hexadecimal string\n", hex_string);
for (i=0; i < size; i++)
hex_value[i] = 0;
return -1;
}
char *itoa(int i) {
char buffer[64];
int ret;
ret = snprintf(buffer, sizeof(buffer), "%d",i);
if ( ret <= 0 ) {
return NULL;
}
return strdup(buffer);
}
#ifndef _UTILS_H
#define _UTILS_H
#include <stdint.h>
#include <sys/types.h>
void *calloc_or_fail(size_t size);
void *malloc_or_fail(size_t size);
// Converts an hexadecimal ASCII coded digit into its value. **
int hex_char_to_hex_value (char c);
// Converts an hexadecimal ASCII coded string into its value.**
int hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int size);
char *itoa(int i);
#endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
/*
* 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.0 (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
*/
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
#ifdef USER_MODE
#include <string.h>
#endif
......
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*
* 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.0 (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 PHY/LTE_TRANSPORT/uespec_pilots.c
* \brief Top-level routines for generating DL ue-specific reference signals V12.5 2015-03
......
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*
* 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.0 (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 PHY/MODULATION/beamforming.c
* \brief
......
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*
* 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.0 (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
*/
/* Twiddles generated with
twa = floor(32767*exp(-sqrt(-1)*2*pi*(0:6143)/18432));
......
......@@ -284,21 +284,7 @@ typedef enum {
#define NUMBER_OF_HARQ_PID_MAX 8
#define MAX_FRAME_NUMBER 0x400
#if defined(CBMIMO1) || defined(EXMIMO) || defined(OAI_USRP)
#define NUMBER_OF_eNB_MAX 1
#define NUMBER_OF_UE_MAX 16
#define NUMBER_OF_CONNECTED_eNB_MAX 3
#else
#ifdef LARGE_SCALE
#define NUMBER_OF_eNB_MAX 2
#define NUMBER_OF_UE_MAX 120
#define NUMBER_OF_CONNECTED_eNB_MAX 1 // to save some memory
#else
#define NUMBER_OF_eNB_MAX 7
#define NUMBER_OF_UE_MAX 16
#define NUMBER_OF_CONNECTED_eNB_MAX 3
#endif
#endif
#include "openairinterface5g_limits.h"
#define NUMBER_OF_RN_MAX 3
typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t;
......
......@@ -1040,8 +1040,8 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt
int subframe_tx = proc->subframe_tx;
int frame_tx = proc->frame_tx;
int ulsch_start;
#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
int overflow=0;
#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
int k,l;
int dummy_tx_buffer[3840*4] __attribute__((aligned(16)));
#endif
......@@ -1069,7 +1069,7 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt
ulsch_start = (frame_parms->samples_per_tti*subframe_tx)-ue->N_TA_offset; //-ue->timing_advance;
#endif //else EXMIMO
#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
//#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
if (empty_subframe)
{
//#if 1
......@@ -1098,7 +1098,7 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt
#endif*/
return;
}
#endif
//#endif
if ((frame_tx%100) == 0)
LOG_D(PHY,"[UE %d] Frame %d, subframe %d: ulsch_start = %d (rxoff %d, HW TA %d, timing advance %d, TA_offset %d\n",
......
/******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*
* 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.0 (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 dlsim.c
\brief Top-level DL simulator
......
......@@ -316,15 +316,6 @@ typedef struct {
*/
#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];}
/*
* User notification callback, executed whenever a change of data with
* respect of network information (e.g. network registration and/or
* location change, new PLMN becomes available) is notified by the
* EPS Mobility Management sublayer
*/
typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t,
const char*, size_t);
typedef enum eps_protocol_discriminator_e {
/* Protocol discriminator identifier for EPS Mobility Management */
EPS_MOBILITY_MANAGEMENT_MESSAGE = 0x7,
......
......@@ -252,13 +252,6 @@ typedef struct {
network_pkf_t* pkf[NET_PACKET_FILTER_MAX];
} network_tft_t;
/*
* User notification callback, executed whenever a change of status with
* respect of PDN connection or EPS bearer context is notified by the EPS
* Session Management sublayer
*/
typedef int (*esm_indication_callback_t) (int, network_pdn_state_t);
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
......
......@@ -62,24 +62,27 @@
#endif //PHY_EMUL
#include "SCHED/defs.h"
/* TODO: this abstraction_flag here is very hackish - find a proper solution */
extern uint8_t abstraction_flag;
void dl_phy_sync_success(module_id_t module_idP,
frame_t frameP,
unsigned char eNB_index,
uint8_t first_sync) //init as MR
{
LOG_D(MAC,"[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", module_idP, frameP, eNB_index);
#if ! defined(ENABLE_USE_MME)
#if defined(ENABLE_USE_MME)
int mme_enabled=1;
#else
int mme_enabled=0;
#endif
if (first_sync==1) {
if (first_sync==1 && !(mme_enabled==1 && abstraction_flag==0)) {
layer2_init_UE(module_idP);
openair_rrc_ue_init(module_idP,eNB_index);
} else
#endif
{
rrc_in_sync_ind(module_idP,frameP,eNB_index);
}
}
void mrbch_phy_sync_failure(module_id_t module_idP, frame_t frameP, uint8_t free_eNB_index) //init as CH
......
......@@ -816,6 +816,14 @@ pdcp_data_ind(
((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id;
#if defined(OAI_EMU)
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id + oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local;
#else
# if defined(ENABLE_USE_MME)
/* for the UE compiled in S1 mode, we need 1 here
* for the UE compiled in noS1 mode, we need 0
* TODO: be sure of this
*/
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1;
# endif
#endif
} else {
((pdcp_data_ind_header_t*) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * maxDRB);
......
......@@ -167,7 +167,8 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
((pdcp_data_ind_header_t *) sdu_p->data)->data_size);
#else
#if ! defined(OAI_EMU)
((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
#endif
#endif
......@@ -571,7 +572,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/
#else // OAI_EMU
pdcp_read_header_g.inst = 0;
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// pdcp_read_header_g.inst = 0;
//#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
ctxt.frame = ctxt_cpy.frame;
ctxt.enb_flag = ctxt_cpy.enb_flag;
......
......@@ -345,7 +345,7 @@ void ue_ip_common_wireless2ip(struct nlmsghdr *nlh_pP)
ue_ip_common_class_wireless2ip(pdcph_p->data_size,
(unsigned char *)NLMSG_DATA(nlh_pP) + UE_IP_PDCPH_SIZE,
1, //pdcph_p->inst,
pdcph_p->inst,
pdcph_p->rb_id);
}
......
......@@ -19,6 +19,7 @@
* contact@openairinterface.org
*/
#include "openairinterface5g_limits.h"
#ifndef _UE_IP_CST
#define _UE_IP_CST
......@@ -51,7 +52,7 @@
#define UE_IP_NB_INSTANCES_MAX 8
#define UE_IP_NB_INSTANCES_MAX NUMBER_OF_UE_MAX
#endif
......
......@@ -4406,7 +4406,6 @@ void *rrc_ue_task( void *args_p )
/* NAS messages */
case NAS_CELL_SELECTION_REQ:
ue_mod_id = 0; /* TODO force ue_mod_id to first UE, NAS UE not virtualized yet */
LOG_D(RRC, "[UE %d] Received %s: state %d, plmnID (%d%d%d.%d%d%d), rat %x\n", ue_mod_id, msg_name, rrc_get_state(ue_mod_id),
NAS_CELL_SELECTION_REQ (msg_p).plmnID.MCCdigit1,
......@@ -4707,7 +4706,6 @@ void *rrc_ue_task( void *args_p )
break;
case RRC_RAL_CONNECTION_RELEASE_REQ:
ue_mod_id = 0; /* TODO force ue_mod_id to first UE, NAS UE not virtualized yet */
LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, msg_name);
break;
#endif
......
......@@ -31,13 +31,12 @@
#ifndef STRUCTURES_H
#define STRUCTURES_H
#include "openairinterface5g_limits.h"
#ifndef __PHY_IMPLEMENTATION_DEFS_H__
#define Maxneighbor 64
#define NUMBER_OF_UE_MAX 64
#define NUMBER_OF_eNB_MAX 3
#ifndef NB_ANTENNAS_RX
# define NB_ANTENNAS_RX 4
#endif
#define Maxneighbor NUMBER_OF_UE_MAX
#ifndef NB_ANTENNAS_RX
#define NB_ANTENNAS_RX 4
#endif
#endif
//
......
......@@ -33,12 +33,12 @@
#ifndef __OTG_DEFS_H__
# define __OTG_DEFS_H__
/* \brief To define the NUMBER_OF_eNB_MAX and NUMBER_OF_UE_MAX */
#if STANDALONE==1
# define NUMBER_OF_eNB_MAX 3
# define NUMBER_OF_UE_MAX 3
#include "openairinterface5g_limits.h"
#else
#include "PHY/impl_defs_top.h" /* \brief To define the NUMBER_OF_eNB_MAX and NUMBER_OF_UE_MAX */
// impl_defs_top.h includes openairinterface5g_limits.h
#include "PHY/impl_defs_top.h"
#endif
#include "otg_config.h"
......
......@@ -464,6 +464,9 @@ int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len)
#endif
}
if (encode_result < 0)
LOG_FUNC_RETURN (encode_result);
LOG_FUNC_RETURN (header_result + encode_result);
}
......
......@@ -103,6 +103,30 @@ char* memory_get_path(const char* dirname, const char* filename)
return data_filename;
}
char* memory_get_path_from_ueid(const char* dirname, const char* filename, int ueid)
{
/* Get non-volatile data directory */
const char* path = getenv(dirname);
char buffer[2048];
if (path == NULL) {
path = getenv(DEFAULT_NAS_PATH);
}
if (path == NULL) {
LOG_TRACE(WARNING, "MEMORY - %s and %s environment variables are not defined trying local directory", dirname, DEFAULT_NAS_PATH);
path = ".";
}
/* Append non-volatile data file name */
if ( snprintf(buffer, sizeof(buffer), "%s/%s%d", path, filename, ueid) < 0 ) {
return NULL;
}
return strdup(buffer);
}
/****************************************************************************
** **
** Name: memory_read() **
......
......@@ -58,6 +58,8 @@ Description Memory access utilities
char* memory_get_path(const char* dirname, const char* filename);
char* memory_get_path_from_ueid(const char* dirname, const char* filename, int ueid);
int memory_read(const char* datafile, void* data, size_t size);
int memory_write(const char* datafile, const void* data, size_t size);
......
......@@ -314,6 +314,7 @@ typedef struct {
*/
#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];}
#if 0
/*
* User notification callback, executed whenever a change of data with
* respect of network information (e.g. network registration and/or
......@@ -322,6 +323,7 @@ typedef struct {
*/
typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t,
const char*, size_t);
#endif
typedef enum eps_protocol_discriminator_e {
/* Protocol discriminator identifier for EPS Mobility Management */
......
......@@ -260,12 +260,14 @@ typedef struct {
network_pkf_t* pkf[NET_PACKET_FILTER_MAX];
} network_tft_t;
#if 0
/*
* User notification callback, executed whenever a change of status with
* respect of PDN connection or EPS bearer context is notified by the EPS
* Session Management sublayer
*/
typedef int (*esm_indication_callback_t) (int, network_pdn_state_t);
#endif
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
......
......@@ -18,9 +18,9 @@ EURECOM-NAS directory should contain following files:
EURECOM-NAS
|-- bin
| |-- .ue.nvram
| |-- .ue_emm.nvram
| |-- .usim.nvram
| |-- .ue.nvram0
| |-- .ue_emm.nvram0
| |-- .usim.nvram0
| |-- NetworkProcess
| |-- UEprocess
| `-- UserProcess
......@@ -57,10 +57,10 @@ UE for testing purpose.
When starting up, UEprocess reads configuration data from .nvram binary
files used as UE's non-volatile memory.
.usim.nvram contains data stored into the USIM
.ue.nvram contains data related to the UE identification (IMEI,
.usim.nvram0 contains data stored into the USIM
.ue.nvram0 contains data related to the UE identification (IMEI,
manufacturer, model, PIN code)
.ue_emm.nvram contains data related to EPS Mobility Management (IMSI, last
.ue_emm.nvram0 contains data related to EPS Mobility Management (IMSI, last
registered PLMN)
--------------------------------------------------------------------------------
......
#/*
# * 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.0 (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
# */
export PROCESS = UE
ifndef PROJDIR
PROJDIR = $(PWD)/..
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
include $(PROJDIR)/../Makefile.tools
export LD_RUN_PATH = $(LIBDIR):$(LIBPROCESS)
LIBS = -luenas.a -lrt
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(USIMAPIDIR) -I$(EMMDIR) -I$(ESMDIR) -I$(IESDIR)
#LIBSUTIL = $(LIBDIR)/$(LIBUTIL).a $(LIBDIR)/$(LIBUTIL).so
USIM_OBJ = usim_data.o
UE_OBJ = ue_data.o
USIM_TARGET = usim_data
UE_TARGET = ue_data
TARGETS = $(USIM_TARGET) $(UE_TARGET)
all: $(TARGETS)
#-DIMSI_USA_MNC_3DIGITS
%.o: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
$(USIM_TARGET): $(USIM_OBJ) $(LIBSUTIL)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lnettle -lcrypto -lm
@echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR)
$(UE_TARGET): $(UE_OBJ) $(LIBSUTIL)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lnettle -lcrypto -lm
@echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR)
clean:
$(RM) $(OBJS) *.bak *~
veryclean: clean
$(RM) $(TARGETS)
veryveryclean: veryclean
$(RM) -Rf *.o $(PROJDIR)
$(RM) -Rf *.a $(PROJDIR)
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
#include <stdio.h> // perror, printf, fprintf, snprintf
#include <stdlib.h> // exit, free
#include <string.h> // memset, strncpy
#include <getopt.h>
#include "conf2uedata.h"
#include "display.h"
#include "conf_parser.h"
int main(int argc, char**argv) {
int option;
const char* conf_file = NULL;
const char* output_dir = NULL;
const char options[]="c:o:h";
while ((option = getopt(argc, argv, options)) != -1) {
switch (option) {
case 'c':
conf_file = optarg;
break;
case 'o':
output_dir = optarg;
break;
case 'h':
_display_usage();
return true;
break;
default:
break;
}
}
if (output_dir == NULL ) {
printf("No output option found\n");
_display_usage();
exit(1);
}
if ( conf_file == NULL ) {
printf("No Configuration file is given\n");
_display_usage();
exit(1);
}
if ( parse_config_file(output_dir, conf_file, OUTPUT_ALL) == false ) {
exit(1);
}
display_data_from_directory(output_dir, DISPLAY_ALL);
exit(0);
}
/*
* Displays command line usage
*/
void _display_usage(void) {
fprintf(stderr, "usage: conf2uedata [OPTION]...\n");
fprintf(stderr, "\t[-c]\tConfig file to use\n");
fprintf(stderr, "\t[-o]\toutput file directory\n");
fprintf(stderr, "\t[-h]\tDisplay this usage\n");
}
#ifndef _CONF2UEDATA_H
#define _CONF2UEDATA_H
void _display_usage(void);
#endif // _CONF2UEDATA_H
#include <string.h>
#include "memory.h"
#include "conf_emm.h"
#include "fs.h"
void gen_emm_data(
emm_nvdata_t *emm_data,
const char *hplmn,
const char *msin,
const plmns_list *eplmn,
const networks_t networks)
{
memset(emm_data, 0, sizeof(emm_nvdata_t));
int hplmn_index = get_plmn_index(hplmn, networks);
plmn_conf_param_t *conf = &networks.items[hplmn_index].conf;
int i;
emm_data->imsi.length = 8;
emm_data->imsi.u.num.parity = get_msin_parity(msin, conf->mcc, conf->mnc);
emm_data->imsi.u.num.digit1 = conf->mcc[0];
emm_data->imsi.u.num.digit2 = conf->mcc[1];
emm_data->imsi.u.num.digit3 = conf->mcc[2];
emm_data->imsi.u.num.digit4 = conf->mnc[0];
emm_data->imsi.u.num.digit5 = conf->mnc[1];
if (strlen(conf->mnc) == 3) {
emm_data->rplmn.MNCdigit3 = conf->mnc[2];
emm_data->imsi.u.num.digit6 = conf->mnc[2];
emm_data->imsi.u.num.digit7 = msin[0];
emm_data->imsi.u.num.digit8 = msin[1];
emm_data->imsi.u.num.digit9 = msin[2];
emm_data->imsi.u.num.digit10 = msin[3];
emm_data->imsi.u.num.digit11 = msin[4];
emm_data->imsi.u.num.digit12 = msin[5];
emm_data->imsi.u.num.digit13 = msin[6];
emm_data->imsi.u.num.digit14 = msin[7];
emm_data->imsi.u.num.digit15 = msin[8];
} else {
emm_data->rplmn.MNCdigit3 = 0xf;
emm_data->imsi.u.num.digit6 = msin[0];
emm_data->imsi.u.num.digit7 = msin[1];
emm_data->imsi.u.num.digit8 = msin[2];
emm_data->imsi.u.num.digit9 = msin[3];
emm_data->imsi.u.num.digit10 = msin[4];
emm_data->imsi.u.num.digit11 = msin[5];
emm_data->imsi.u.num.digit12 = msin[6];
emm_data->imsi.u.num.digit13 = msin[7];
emm_data->imsi.u.num.digit14 = msin[8];
emm_data->imsi.u.num.digit15 = msin[9];
}
emm_data->rplmn.MCCdigit1 = conf->mcc[0];
emm_data->rplmn.MCCdigit2 = conf->mcc[1];
emm_data->rplmn.MCCdigit3 = conf->mcc[2];
emm_data->rplmn.MNCdigit1 = conf->mnc[0];
emm_data->rplmn.MNCdigit2 = conf->mnc[1];
emm_data->eplmn.n_plmns = eplmn->size;
for (i = 0; i < eplmn->size; i++) {
emm_data->eplmn.plmn[i] = networks.items[eplmn->items[i]].plmn;
}
}
bool write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data) {
int rc;
char* filename = make_filename(directory, EMM_NVRAM_FILENAME, user_id);
rc = memory_write(filename, emm_data, sizeof(emm_nvdata_t));
free(filename);
if (rc != RETURNok) {
perror("ERROR\t: memory_write() failed");
exit(false);
}
return(true);
}
int get_msin_parity(const char * msin, const char *mcc, const char *mnc) {
int imsi_size = strlen(msin) + strlen(mcc)
+ strlen(mnc);
int result = (imsi_size % 2 == 0) ? 0 : 1;
return result;
}
#ifndef _CONF_EMM_H
#define _CONF_EMM_H
#include "emmData.h"
#include "conf_network.h"
#include "conf_user_plmn.h"
void gen_emm_data(
emm_nvdata_t *emm_data,
const char *hplmn,
const char *msin,
const plmns_list *eplmn,
const networks_t networks);
bool write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data);
int get_msin_parity(const char * msin, const char *mcc, const char *mnc);
#endif
#include <stdlib.h>
#include <string.h>
#include "conf_network.h"
int get_plmn_index(const char * mccmnc, const networks_t networks) {
char mcc[4];
char mnc[strlen(mccmnc) - 2];
strncpy(mcc, mccmnc, 3);
mcc[3] = '\0';
strncpy(mnc, mccmnc + 3, 3);
mnc[strlen(mccmnc) - 3] = '\0';
for (int i = 0; i < networks.size; i++) {
if (strcmp(networks.items[i].conf.mcc, mcc) == 0) {
if (strcmp(networks.items[i].conf.mnc, mnc) == 0) {
return i;
}
}
}
return -1;
}
plmn_t make_plmn_from_conf(const plmn_conf_param_t *plmn_conf) {
plmn_t plmn;
char num[6];
memset(&plmn, 0xff, sizeof(plmn));
snprintf(num, 6, "%s%s", plmn_conf->mcc, plmn_conf->mnc);
plmn.MCCdigit2 = plmn_conf->mcc[1];
plmn.MCCdigit1 = plmn_conf->mcc[0];
plmn.MCCdigit3 = plmn_conf->mcc[2];
plmn.MNCdigit2 = plmn_conf->mnc[1];
plmn.MNCdigit1 = plmn_conf->mnc[0];
if (strlen(plmn_conf->mnc) > 2) {
plmn.MNCdigit3 = plmn_conf->mnc[2];
}
return plmn;
}
void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_t *record) {
strcpy(record->fullname, conf->fullname);
strcpy(record->shortname, conf->shortname);
char num[6];
sprintf(num, "%s%s", conf->mcc, conf->mnc);
record->num = atoi(num);
record->plmn = make_plmn_from_conf(conf);
record->tac_end = 0xfffd;
record->tac_start = 0x0001;
}
bool parse_plmn_param(config_setting_t *plmn_setting, plmn_conf_param_t *conf) {
int rc = 0;
rc = config_setting_lookup_string(plmn_setting, FULLNAME, &conf->fullname);
if (rc != 1) {
printf("Error on FULLNAME\n");
return false;
}
rc = config_setting_lookup_string(plmn_setting, SHORTNAME, &conf->shortname);
if (rc != 1) {
printf("Error on SHORTNAME\n");
return false;
}
rc = config_setting_lookup_string(plmn_setting, MNC, &conf->mnc);
if (rc != 1 || strlen(conf->mnc) > 3
|| strlen(conf->mnc) < 2) {
printf("Error ond MNC. Exiting\n");
return false;
}
rc = config_setting_lookup_string(plmn_setting, MCC, &conf->mcc);
if (rc != 1 || strlen(conf->mcc) != 3) {
printf("Error on MCC\n");
return false;
}
return true;
}
bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) {
config_setting_t *plmn_setting = NULL;
char plmn[10];
int size = 0;
size = config_setting_length(all_plmn_setting);
networks->size = size;
networks->items = malloc(sizeof(network_t) * size);
for (int i = 0; i < size; i++) {
memset(&networks->items[i].record, 0xff, sizeof(network_record_t));
}
for (int i = 0; i < networks->size; i++) {
network_t *network = &networks->items[i];
sprintf(plmn, "%s%d", PLMN, i);
plmn_setting = config_setting_get_member(all_plmn_setting, plmn);
if (plmn_setting == NULL) {
printf("PLMN%d not fouund\n", i);
return false;
}
if ( parse_plmn_param(plmn_setting, &network->conf) == false ) {
return false;
}
gen_network_record_from_conf(&network->conf, &network->record);
network->plmn = network->record.plmn;
}
return true;
}
#ifndef _CONF_NETWORK_H
#define _CONF_NETWORK_H
#include <stdbool.h>
#include <libconfig.h>
#include "usim_api.h"
#define PLMN "PLMN"
#define FULLNAME "FULLNAME"
#define SHORTNAME "SHORTNAME"
#define MNC "MNC"
#define MCC "MCC"
#define MIN_TAC 0x0000
#define MAX_TAC 0xFFFE
/*
* PLMN network operator record
*/
typedef struct {
unsigned int num;
plmn_t plmn;
char fullname[NET_FORMAT_LONG_SIZE + 1];
char shortname[NET_FORMAT_SHORT_SIZE + 1];
tac_t tac_start;
tac_t tac_end;
} network_record_t;
typedef struct {
const char *fullname;
const char *shortname;
const char *mnc;
const char *mcc;
} plmn_conf_param_t;
typedef struct {
plmn_conf_param_t conf;
network_record_t record;
plmn_t plmn;
} network_t;
typedef struct {
int size;
network_t *items;
} networks_t;
bool parse_plmn_param(config_setting_t *plmn_setting, plmn_conf_param_t *conf);
bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *plmns);
void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_t *record);
int get_plmn_index(const char * mccmnc, const networks_t networks);
#endif
#include "conf_parser.h"
#include "conf_network.h"
#include "conf_emm.h"
#include "conf_usim.h"
#include "conf_user_data.h"
#include "conf_user_plmn.h"
bool parse_config_file(const char *output_dir, const char *conf_filename, int output_flags) {
int rc = true;
int ret;
int ue_nb = 0;
config_setting_t *root_setting = NULL;
config_setting_t *ue_setting = NULL;
config_setting_t *all_plmn_setting = NULL;
char user[10];
config_t cfg;
networks_t networks;;
ret = get_config_from_file(conf_filename, &cfg);
if (ret == false) {
exit(1);
}
root_setting = config_root_setting(&cfg);
ue_nb = config_setting_length(root_setting) - 1;
all_plmn_setting = config_setting_get_member(root_setting, PLMN);
if (all_plmn_setting == NULL) {
printf("NO PLMN SECTION...EXITING...\n");
return (false);
}
if ( parse_plmns(all_plmn_setting, &networks) == false ) {
return false;
}
for (int i = 0; i < ue_nb; i++) {
emm_nvdata_t emm_data;
user_nvdata_t user_data;
user_data_conf_t user_data_conf;
usim_data_t usim_data;
usim_data_conf_t usim_data_conf;
user_plmns_t user_plmns;
sprintf(user, "%s%d", UE, i);
ue_setting = config_setting_get_member(root_setting, user);
if (ue_setting == NULL) {
printf("Check UE%d settings\n", i);
return false;
}
if ( parse_user_plmns_conf(ue_setting, i, &user_plmns, &usim_data_conf.hplmn, networks) == false ) {
return false;
}
rc = parse_ue_user_data(ue_setting, i, &user_data_conf);
if (rc != true) {
printf("Problem in USER section for UE%d. EXITING...\n", i);
return false;
}
gen_user_data(&user_data_conf, &user_data);
rc = parse_ue_sim_param(ue_setting, i, &usim_data_conf);
if (rc != true) {
printf("Problem in SIM section for UE%d. EXITING...\n", i);
return false;
}
gen_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin,
&user_plmns.equivalents_home, networks);
if ( output_flags & OUTPUT_UEDATA ) {
write_user_data(output_dir, i, &user_data);
}
if ( output_flags & OUTPUT_USIM ) {
write_usim_data(output_dir, i, &usim_data);
}
if ( output_flags & OUTPUT_EMM ) {
write_emm_data(output_dir, i, &emm_data);
}
user_plmns_free(&user_plmns);
}
free(networks.items);
networks.size=0;
config_destroy(&cfg);
return(true);
}
bool get_config_from_file(const char *filename, config_t *config) {
config_init(config);
if (filename == NULL) {
// XXX write error message ?
return(false);
}
/* Read the file. If there is an error, report it and exit. */
if (!config_read_file(config, filename)) {
fprintf(stderr, "Cant read config file '%s': %s\n", filename,
config_error_text(config));
if ( config_error_type(config) == CONFIG_ERR_PARSE ) {
fprintf(stderr, "This is line %d\n", config_error_line(config));
}
config_destroy(config);
return (false);
}
return true;
}
#ifndef _CONF_PARSER_H
#define _CONF_PARSER_H
#include <stdbool.h>
#include <libconfig.h>
#define UE "UE"
#define OUTPUT_EMM 1
#define OUTPUT_USIM 2
#define OUTPUT_UEDATA 4
#define OUTPUT_ALL 7
bool get_config_from_file(const char *filename, config_t *config);
bool parse_config_file(const char *output_dir, const char *filename, int output_flags);
#endif
#include <string.h>
#include <stdlib.h>
#include "commonDef.h"
#include "memory.h"
#include "fs.h"
#include "conf_user_data.h"
int parse_ue_user_data(config_setting_t *ue_setting, int user_id, user_data_conf_t *u) {
config_setting_t *ue_param_setting = NULL;
int rc = true;
ue_param_setting = config_setting_get_member(ue_setting, USER);
if (ue_param_setting == NULL) {
printf("Check USER section of UE%d. EXITING...\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, UE_IMEI, &u->imei);
if (rc != 1) {
printf("Check USER IMEI section for UE%d. Exiting\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, MANUFACTURER,
&u->manufacturer);
if (rc != 1) {
printf("Check USER MANUFACTURER for UE%d FULLNAME. Exiting\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, MODEL, &u->model);
if (rc != 1) {
printf("Check USER MODEL for UE%d FULLNAME. Exiting\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, PINCODE, &u->pin);
if (rc != 1) {
printf("Check USER PIN for UE%d FULLNAME. Exiting\n", user_id);
return false;
}
return true;
}
void gen_user_data(user_data_conf_t *u, user_nvdata_t *user_data) {
memset(user_data, 0, sizeof(user_nvdata_t));
snprintf(user_data->IMEI, USER_IMEI_SIZE + 1, "%s%d", u->imei, _luhn(u->imei));
/*
* Manufacturer identifier
*/
strncpy(user_data->manufacturer, u->manufacturer, USER_MANUFACTURER_SIZE);
/*
* Model identifier
*/
strncpy(user_data->model, u->model, USER_MODEL_SIZE);
/*
* SIM Personal Identification Number
*/
strncpy(user_data->PIN, u->pin, USER_PIN_SIZE);
}
bool write_user_data(const char *directory, int user_id, user_nvdata_t *data) {
int rc;
char* filename = make_filename(directory, USER_NVRAM_FILENAME, user_id);
rc = memory_write(filename, data, sizeof(user_nvdata_t));
free(filename);
if (rc != RETURNok) {
perror("ERROR\t: memory_write() failed");
return false;
}
return true;
}
/*
* Computes the check digit using Luhn algorithm
*/
int _luhn(const char* cc) {
const int m[] = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 };
int odd = 1, sum = 0;
for (int i = strlen(cc); i--; odd = !odd) {
int digit = cc[i] - '0';
sum += odd ? m[digit] : digit;
}
return 10 - (sum % 10);
}
#ifndef _CONF_USER_DATA_H
#define _CONF_USER_DATA_H
#include <stdbool.h>
#include <libconfig.h>
#include "userDef.h"
#define USER "USER"
#define MANUFACTURER "MANUFACTURER"
#define MODEL "MODEL"
#define UE_IMEI "IMEI"
#define PINCODE "PIN"
typedef struct {
const char* imei;
const char* manufacturer;
const char* model;
const char* pin;
} user_data_conf_t;
void gen_user_data(user_data_conf_t *u, user_nvdata_t *user_data);
bool write_user_data(const char *directory, int user_id, user_nvdata_t *data);
int parse_ue_user_data(config_setting_t *ue_setting, int user_id, user_data_conf_t *u);
int _luhn(const char* cc);
#endif
#include <stdlib.h>
#include <string.h>
#include "conf_user_plmn.h"
bool parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
user_plmns_t *user_plmns, const char **h,
const networks_t networks) {
int nb_errors = 0;
const char *hplmn;
if ( config_setting_lookup_string(ue_setting, HPLMN, h) != 1 ) {
printf("Check HPLMN section for UE%d. Exiting\n", user_id);
return false;
}
hplmn = *h;
if (get_plmn_index(hplmn, networks) == -1) {
printf("HPLMN for UE%d is not defined in PLMN section. Exiting\n",
user_id);
return false;
}
if ( parse_Xplmn(ue_setting, UCPLMN, user_id, &user_plmns->users_controlled, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, OPLMN, user_id, &user_plmns->operators, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, OCPLMN, user_id, &user_plmns->operators_controlled, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, FPLMN, user_id, &user_plmns->forbiddens, networks) == false )
nb_errors++;
if ( parse_Xplmn(ue_setting, EHPLMN, user_id, &user_plmns->equivalents_home, networks) == false )
nb_errors++;
if ( nb_errors > 0 )
return false;
return true;
}
bool parse_Xplmn(config_setting_t *ue_setting, const char *section,
int user_id, plmns_list *plmns, const networks_t networks) {
int rc;
int item_count;
config_setting_t *setting;
setting = config_setting_get_member(ue_setting, section);
if (setting == NULL) {
printf("Check %s section for UE%d. Exiting\n", section, user_id);
return false;
}
item_count = config_setting_length(setting);
int *datas = malloc(item_count * sizeof(int));
for (int i = 0; i < item_count; i++) {
const char *mccmnc = config_setting_get_string_elem(setting, i);
if (mccmnc == NULL) {
printf("Check %s section for UE%d. Exiting\n", section, user_id);
free(datas);
return false;
}
rc = get_plmn_index(mccmnc, networks);
if (rc == -1) {
printf("The PLMN %s is not defined in PLMN section. Exiting...\n",
mccmnc);
free(datas);
return false;
}
datas[i] = rc;
}
plmns->size = item_count;
plmns->items = datas;
return true;
}
void user_plmns_free(user_plmns_t *user_plmns) {
free(user_plmns->users_controlled.items);
free(user_plmns->operators.items);
free(user_plmns->operators_controlled.items);
free(user_plmns->forbiddens.items);
free(user_plmns->equivalents_home.items);
memset(user_plmns, 0, sizeof(user_plmns_t));
}
#ifndef _CONF_USER_H
#define _CONF_USER_H
#include <stdbool.h>
#include <libconfig.h>
#include "conf_network.h"
#define HPLMN "HPLMN"
#define UCPLMN "UCPLMN_LIST"
#define OPLMN "OPLMN_LIST"
#define OCPLMN "OCPLMN_LIST"
#define FPLMN "FPLMN_LIST"
#define EHPLMN "EHPLMN_LIST"
typedef struct {
int size;
int *items;
} plmns_list;
typedef struct {
plmns_list users_controlled;
plmns_list operators;
plmns_list operators_controlled;
plmns_list forbiddens;
plmns_list equivalents_home;
} user_plmns_t;
bool parse_user_plmns_conf(config_setting_t *ue_setting, int user_id,
user_plmns_t *user_plmns, const char **h,
const networks_t networks);
bool parse_Xplmn(config_setting_t *ue_setting, const char *section,
int user_id, plmns_list *plmns, const networks_t networks);
void user_plmns_free(user_plmns_t *user_plmns);
#endif
This diff is collapsed.
#ifndef _CONF_USIM_H
#define _CONF_USIM_H
#include <libconfig.h>
#include "usim_api.h"
#include "conf_user_plmn.h"
#define SIM "SIM"
#define MSIN "MSIN"
#define USIM_API_K "USIM_API_K"
#define OPC "OPC"
#define MSISDN "MSISDN"
#define KSI USIM_KSI_NOT_AVAILABLE
#define KSI_ASME USIM_KSI_NOT_AVAILABLE
#define OPC_SIZE 16
#define DEFAULT_TMSI 0x0000000D
#define DEFAULT_P_TMSI 0x0000000D
#define DEFAULT_M_TMSI 0x0000000D
#define DEFAULT_RAC 0x01
#define DEFAULT_TAC 0x0001
#define DEFAULT_LAC 0xFFFE
#define DEFAULT_MME_ID 0x0102
#define DEFAULT_MME_CODE 0x0F
// TODO add this setting in configuration file
#define INT_ALGO USIM_INT_EIA2
#define ENC_ALGO USIM_ENC_EEA0
#define SECURITY_ALGORITHMS (ENC_ALGO | INT_ALGO)
typedef struct {
const char *msin;
const char *usim_api_k;
const char *msisdn;
const char *opc;
const char *hplmn;
} usim_data_conf_t;
bool parse_ue_sim_param(config_setting_t *ue_setting, int user_id, usim_data_conf_t *u);
bool write_usim_data(const char *directory, int user_id, usim_data_t *usim_data);
void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data,
const user_plmns_t *user_plmns, const networks_t networks);
#endif
This diff is collapsed.
#ifndef _DISPLAY_H
#define _DISPLAY_H
#define DISPLAY_EMM 1
#define DISPLAY_USIM 2
#define DISPLAY_UEDATA 4
#define DISPLAY_ALL 7
// return number of files displayed
int display_data_from_directory(const char *directory, int flags);
void display_ue_data(const char *filename);
void display_emm_data(const char *filename);
void display_usim_data(const char *filename);
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fs.h"
#include "user_api.h"
#include "utils.h"
bool file_exist_and_is_readable(const char *filename) {
FILE *file ;
file = fopen(filename, "r");
if ( file == NULL )
return false;
fclose(file);
return true;
}
char *get_ue_filename(const char *output_dir, int user_id) {
return make_filename(output_dir, USER_NVRAM_FILENAME, user_id);
}
char *get_emm_filename(const char *output_dir, int user_id) {
return make_filename(output_dir, EMM_NVRAM_FILENAME, user_id);
}
char *get_usim_filename(const char *output_dir, int user_id) {
return make_filename(output_dir, USIM_API_NVRAM_FILENAME, user_id);
}
char *make_filename(const char *output_dir, const char *filename, int ueid) {
size_t size;
char *str_ueid, *str;
str_ueid = itoa(ueid);
if (str_ueid == NULL) {
perror("ERROR\t: itoa() failed");
exit(EXIT_FAILURE);
}
size = strlen(output_dir)+strlen(filename) + sizeof(ueid) + 1 + 1; // for \0 and for '/'
str = malloc(size);
if (str == NULL) {
perror("ERROR\t: make_filename() failed");
exit(EXIT_FAILURE);
}
snprintf(str, size, "%s/%s%s",output_dir, filename, str_ueid);
free(str_ueid);
return str;
}
#ifndef _FS_H
#define _FS_H
#include <stdbool.h>
bool file_exist_and_is_readable(const char *filename);
char *get_ue_filename(const char *output_dir, int user_id);
char *get_emm_filename(const char *output_dir, int user_id);
char *get_usim_filename(const char *output_dir, int user_id);
char *make_filename(const char *output_dir, const char *filename, int ueid);
#endif
/*
* 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.0 (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
*/
/*****************************************************************************
Source usim_data.c
Version 0.1
Date 2012/10/31
Product NVRAM data generator
Subsystem NVRAM data generator main process
Author Frederic Maurel
Description Implements the utility used to generate data stored in the
NVRAM application
*****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <getopt.h>
#include "conf_parser.h"
#include "display.h"
#define DEFAULT_NAS_PATH "PWD"
#define OUTPUT_DIR_ENV "NVRAM_DIR"
void _display_usage(const char* command);
int main (int argc, char * const argv[])
{
enum usim_command {
NVRAM_COMMAND_NONE,
NVRAM_COMMAND_PRINT,
NVRAM_COMMAND_GEN,
} command = NVRAM_COMMAND_NONE;
char *output_dir = NULL;
char *conf_file = NULL;
const char options[]="gpc:o:h";
const struct option options_long_option[] = {
{"gen", no_argument, NULL, 'g'},
{"print", no_argument, NULL, 'p'},
{"conf", required_argument, NULL, 'c'},
{"output", required_argument, NULL, 'o'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
int option_index;
char option_short;
/*
* Read command line parameters
*/
while ( true ) {
option_short = getopt_long(argc, argv, options, options_long_option, &option_index );
if ( option_short == -1 )
break;
switch (option_short) {
case 'c':
conf_file = optarg;
break;
case 'g':
command = NVRAM_COMMAND_GEN;
break;
case 'p':
command = NVRAM_COMMAND_PRINT;
break;
case 'o':
output_dir = optarg;
break;
default:
break;
}
}
if ( command == NVRAM_COMMAND_NONE ) {
_display_usage(argv[0]);
exit(EXIT_SUCCESS);
}
/* compute default data directory if no output_dir is given */
if ( output_dir == NULL ) {
output_dir = getenv(OUTPUT_DIR_ENV);
if (output_dir == NULL) {
output_dir = getenv(DEFAULT_NAS_PATH);
}
if (output_dir == NULL) {
fprintf(stderr, "%s and %s environment variables are not defined trying local directory",
OUTPUT_DIR_ENV, DEFAULT_NAS_PATH);
output_dir = ".";
}
}
if ( command == NVRAM_COMMAND_GEN ) {
if ( conf_file == NULL ) {
printf("No Configuration file is given\n");
_display_usage(argv[0]);
exit(EXIT_FAILURE);
}
if ( parse_config_file(output_dir, conf_file, OUTPUT_UEDATA|OUTPUT_EMM) == false ) {
exit(EXIT_FAILURE);
}
}
if ( display_data_from_directory(output_dir, DISPLAY_UEDATA|DISPLAY_EMM) == 0) {
fprintf(stderr, "No NVRAM files found in %s\n", output_dir);
}
exit(EXIT_SUCCESS);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/*
* Displays command line usage
*/
void _display_usage(const char* command)
{
fprintf(stderr, "usage: %s [OPTION]\n", command);
fprintf(stderr, "\t[--gen|-g]\tGenerate the NVRAM data file\n");
fprintf(stderr, "\t[--print|-p]\tDisplay the content of the NVRAM data file\n");
fprintf(stderr, "\t[-c]\tConfig file to use\n");
fprintf(stderr, "\t[-o]\toutput file directory\n");
fprintf(stderr, "\t[--help|-h]\tDisplay this usage\n");
const char* path = getenv("NVRAM_DIR");
if (path != NULL) {
fprintf(stderr, "NVRAM_DIR = %s\n", path);
} else {
fprintf(stderr, "NVRAM_DIR environment variable is not defined\n");
}
}
This diff is collapsed.
This diff is collapsed.
# List of known PLMNS
PLMN: {
PLMN0: {
FULLNAME="Test network";
SHORTNAME="OAI4G";
MNC="01";
MCC="001";
};
PLMN1: {
FULLNAME="SFR France";
SHORTNAME="SFR";
MNC="10";
MCC="208";
};
PLMN2: {
FULLNAME="SFR France";
SHORTNAME="SFR";
MNC="11";
MCC="208";
};
PLMN3: {
FULLNAME="SFR France";
SHORTNAME="SFR";
MNC="13";
MCC="208";
};
PLMN4: {
FULLNAME="OAI LTEBOX";
SHORTNAME="OAIALU";
MNC="93";
MCC="208";
};
PLMN5: {
FULLNAME="T-Mobile USA";
SHORTNAME="T-Mobile";
MNC="280";
MCC="310";
};
PLMN6: {
FULLNAME="FICTITIOUS USA";
SHORTNAME="FICTITIO";
MNC="028";
MCC="310";
};
PLMN7: {
FULLNAME="Vodafone Italia";
SHORTNAME="VODAFONE";
MNC="10";
MCC="222";
};
PLMN8: {
FULLNAME="Vodafone Spain";
SHORTNAME="VODAFONE";
MNC="01";
MCC="214";
};
PLMN9: {
FULLNAME="Vodafone Spain";
SHORTNAME="VODAFONE";
MNC="06";
MCC="214";
};
PLMN10: {
FULLNAME="Vodafone Germ";
SHORTNAME="VODAFONE";
MNC="02";
MCC="262";
};
PLMN11: {
FULLNAME="Vodafone Germ";
SHORTNAME="VODAFONE";
MNC="04";
MCC="262";
};
};
UE0:
{
USER: {
IMEI="356113022094149";
MANUFACTURER="EURECOM";
MODEL="LTE Android PC";
PIN="0000";
};
SIM: {
MSIN="0100001111";
USIM_API_K="fec86ba6eb707ed08905757b1bb44b8f";
OPC="C42449363BBAD02B66D16BC975D77CC1";
MSISDN="33611123456";
};
# Home PLMN Selector with Access Technology
HPLMN= "20893";
# User controlled PLMN Selector with Access Technology
UCPLMN_LIST = ();
# Operator PLMN List
OPLMN_LIST = ("00101", "20810", "20811", "20813", "20893", "310280", "310028");
# Operator controlled PLMN Selector with Access Technology
OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204");
# Forbidden plmns
FPLMN_LIST = ();
# List of Equivalent HPLMNs
#TODO: UE does not connect if set, to be fixed in the UE
# EHPLMN_LIST= ("20811", "20813");
EHPLMN_LIST= ();
};
/*
* 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.0 (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
*/
/*****************************************************************************
Source usim_data.c
Version 0.1
Date 2012/10/31
Product USIM data generator
Subsystem USIM data generator main process
Author Frederic Maurel
Description Implements the utility used to generate data stored in the
USIM application
*****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <getopt.h>
#include "conf_parser.h"
#include "display.h"
#define DEFAULT_NAS_PATH "PWD"
#define OUTPUT_DIR_ENV "USIM_DIR"
void _display_usage(const char* command);
int main (int argc, char * const argv[])
{
enum usim_command {
USIM_COMMAND_NONE,
USIM_COMMAND_PRINT,
USIM_COMMAND_GEN,
} command = USIM_COMMAND_NONE;
char *output_dir = NULL;
char *conf_file = NULL;
const char options[]="gpc:o:h";
const struct option options_long_option[] = {
{"gen", no_argument, NULL, 'g'},
{"print", no_argument, NULL, 'p'},
{"conf", required_argument, NULL, 'c'},
{"output", required_argument, NULL, 'o'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
int option_index;
char option_short;
/*
* Read command line parameters
*/
while ( true ) {
option_short = getopt_long(argc, argv, options, options_long_option, &option_index );
if ( option_short == -1 )
break;
switch (option_short) {
case 'c':
conf_file = optarg;
break;
case 'g':
command = USIM_COMMAND_GEN;
break;
case 'p':
command = USIM_COMMAND_PRINT;
break;
case 'o':
output_dir = optarg;
break;
default:
break;
}
}
if ( command == USIM_COMMAND_NONE ) {
_display_usage(argv[0]);
exit(EXIT_SUCCESS);
}
/* compute default data directory if no output_dir is given */
if ( output_dir == NULL ) {
output_dir = getenv(OUTPUT_DIR_ENV);
if (output_dir == NULL) {
output_dir = getenv(DEFAULT_NAS_PATH);
}
if (output_dir == NULL) {
fprintf(stderr, "%s and %s environment variables are not defined trying local directory",
OUTPUT_DIR_ENV, DEFAULT_NAS_PATH);
output_dir = ".";
}
}
if ( command == USIM_COMMAND_GEN ) {
if ( conf_file == NULL ) {
printf("No Configuration file is given\n");
_display_usage(argv[0]);
exit(EXIT_FAILURE);
}
if ( parse_config_file(output_dir, conf_file, OUTPUT_USIM) == false ) {
exit(EXIT_FAILURE);
}
}
if ( display_data_from_directory(output_dir, DISPLAY_USIM) == 0) {
fprintf(stderr, "No USIM files found in %s\n", output_dir);
}
exit(EXIT_SUCCESS);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/*
* Displays command line usage
*/
void _display_usage(const char* command)
{
fprintf(stderr, "usage: %s [OPTION]\n", command);
fprintf(stderr, "\t[--gen|-g]\tGenerate the USIM data file\n");
fprintf(stderr, "\t[--print|-p]\tDisplay the content of the USIM data file\n");
fprintf(stderr, "\t[-c]\tConfig file to use\n");
fprintf(stderr, "\t[-o]\toutput file directory\n");
fprintf(stderr, "\t[--help|-h]\tDisplay this usage\n");
const char* path = getenv("USIM_DIR");
if (path != NULL) {
fprintf(stderr, "USIM_DIR = %s\n", path);
} else {
fprintf(stderr, "USIM_DIR environment variable is not defined\n");
}
}
This diff is collapsed.
#/*
# * 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.0 (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
# */
ifndef PROJDIR
PROJDIR = $(PWD)/../../..
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR) -I$(EMMMSGDIR) -I$(ESMMSGDIR)
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
all: $(OBJS)
%.o: %.c Makefile
@echo Compiling $<
@$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) $(OBJS) *.bak *~
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
......@@ -54,6 +54,7 @@ Description Defines the ATtention (AT) command set supported by the NAS
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
// FIXME Put this in .h
extern int at_response_format_v1;
extern int at_error_code_suppression_q1;
extern at_error_format_t at_error_format;
......@@ -278,6 +279,7 @@ int at_command_decode(const char* buffer, int length, at_command_t* at_command)
char* buf = strdup(buffer+2);
char* cmd = strtok(buf, ";");
// FIXME check overflow
for (i=0; cmd && (rc != RETURNerror); i++) {
rc = ParseString(cmd, &at_command[i]);
cmd = strtok(NULL, ";");
......
......@@ -49,6 +49,7 @@ Description Defines error codes returned when execution of AT command
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
// FIXME put this in .h
extern int at_response_format_v1;
/*
......
#/*
# * 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.0 (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
# */
ifndef PROJDIR
PROJDIR = $(PWD)/../../../..
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
LIBS = -lutil -lapi -lEMMmsg -lESMmsg -lies
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(USERAPIDIR)
LIBSAPI = $(LIBDIR)/$(LIBAPI).a $(LIBDIR)/$(LIBAPI).so
TST_OBJ = at_parser.o
TST_TARGET = at_parser
TARGETS = $(TST_TARGET)
all: $(TARGETS)
%.o: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
$(TST_TARGET): $(TST_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
$(RM) $(OBJS) $(TARGETS) *.bak *~
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
at_parser.o: $(USERAPIDIR)/at_command.h
at_parser.o: $(INCDIR)/commonDef.h $(INCDIR)/userDef.h
at_parser.o: $(INCDIR)/networkDef.h $(UTILDIR)/log.h
This diff is collapsed.
......@@ -42,15 +42,14 @@ Description Implements the API used by the NAS layer running in the UE
#include "commonDef.h"
#include "networkDef.h"
#include "at_command.h"
#include "user_api_defs.h"
#include "user_defs.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
......@@ -59,20 +58,20 @@ Description Implements the API used by the NAS layer running in the UE
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int user_api_initialize(const char* host, const char* port, const char* devname, const char* devparams);
int user_api_initialize(user_api_id_t *user_api_id, const char* host, const char* port, const char* devname, const char* devparams);
int user_api_emm_callback(Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char* data, size_t size);
int user_api_esm_callback(int cid, network_pdn_state_t state);
int user_api_emm_callback(user_api_id_t *user_api_id, Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char* data, size_t size);
int user_api_esm_callback(user_api_id_t *user_api_id, int cid, network_pdn_state_t state);
int user_api_get_fd(void);
const void* user_api_get_data(int index);
int user_api_get_fd(user_api_id_t *user_api_id);
const void* user_api_get_data(user_at_commands_t *commands, int index);
int user_api_read_data(int fd);
int user_api_set_data(char *message);
int user_api_send_data(int fd, int length);
void user_api_close(int fd);
int user_api_read_data(user_api_id_t *user_api_id);
int user_api_set_data(user_api_id_t *user_api_id, char *message);
int user_api_send_data(user_api_id_t *user_api_id, int length);
void user_api_close(user_api_id_t *user_api_id);
int user_api_decode_data(int length);
int user_api_encode_data(const void* data, int add_success_code);
int user_api_decode_data(user_api_id_t *user_api_id, user_at_commands_t *commands, int length);
int user_api_encode_data(user_api_id_t *user_api_id, const void* data, int add_success_code);
#endif /* __USER_API_H__ */
#ifndef _USER_API_DEFS_H
#define _USER_API_DEFS_H
#include <sys/types.h>
#include "at_command.h"
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
#define USER_API_RECV_BUFFER_SIZE 4096
#define USER_API_SEND_BUFFER_SIZE USER_API_RECV_BUFFER_SIZE
#define USER_DATA_MAX 10
/*
* The decoded data received from the user application layer
*/
typedef struct {
int n_cmd; /* number of user data to be processed */
at_command_t cmd[USER_DATA_MAX]; /* user data to be processed */
} user_at_commands_t;
/* -------------------
* Connection endpoint
* -------------------
* The connection endpoint is used to send/receive data to/from the
* user application layer. Its definition depends on the underlaying
* mechanism chosen to communicate (network socket, I/O terminal device).
* A connection endpoint is handled using an identifier, and functions
* used to retreive the file descriptor actually allocated by the system,
* to receive data, to send data, and to perform clean up when connection
* is shut down.
* Only one single end to end connection with the user is managed at a
* time.
*/
typedef struct {
/* Connection endpoint reference */
void* endpoint;
/* Connection endpoint handlers */
void* (*open) (int, const char*, const char*);
int (*getfd)(const void*);
ssize_t (*recv) (void*, char*, size_t);
ssize_t (*send) (const void*, const char*, size_t);
void (*close)(void*);
char recv_buffer[USER_API_RECV_BUFFER_SIZE];
char send_buffer[USER_API_SEND_BUFFER_SIZE];
} user_api_id_t;
#endif
......@@ -146,7 +146,7 @@ int user_ind_deregister(user_ind_t ind)
** Others: None **
** **
***************************************************************************/
int user_ind_notify(user_ind_t ind, const void* data, size_t size)
int user_ind_notify(user_api_id_t *user_api_id, user_ind_t ind, const void* data, size_t size)
{
LOG_FUNC_IN;
......@@ -158,7 +158,7 @@ int user_ind_notify(user_ind_t ind, const void* data, size_t size)
user_ind_callback_t notify = _user_ind_handler.callback[ind];
if (notify != NULL) {
rc = (*notify)(_user_ind_handler.id, data, size);
rc = (*notify)(user_api_id, _user_ind_handler.id, data, size);
}
} else {
/* Silently discard not registered notification */
......
......@@ -43,6 +43,7 @@ Description Defines functions which allow the user application to register
#include "commonDef.h"
#include "networkDef.h"
#include "user_api_defs.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -101,7 +102,7 @@ typedef struct {
/*
* Type of procedure executed upon receiving registered notification
*/
typedef int (*user_ind_callback_t) (unsigned char, const void*, size_t);
typedef int (*user_ind_callback_t) (user_api_id_t *user_api_id, unsigned char, const void*, size_t);
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
......@@ -117,6 +118,6 @@ typedef int (*user_ind_callback_t) (unsigned char, const void*, size_t);
int user_ind_register(user_ind_t ind, unsigned char id, user_ind_callback_t cb);
int user_ind_deregister(user_ind_t ind);
int user_ind_notify(user_ind_t ind, const void* data, size_t size);
int user_ind_notify(user_api_id_t *user_api_id, user_ind_t ind, const void* data, size_t size);
#endif /* __USER_IND_H__*/
#/*
# * 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.0 (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
# */
ifndef PROJDIR
PROJDIR = $(PWD)/../../..
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR) -I$(EMMMSGDIR) -I$(ESMMSGDIR)
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
all: $(OBJS)
%.o: %.c Makefile
@echo Compiling $<
@$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) $(OBJS) *.bak *~
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
......@@ -39,26 +39,6 @@
#include "aka_functions.h"
#include "nas_log.h"
/*--------- Operator Variant Algorithm Configuration Field --------*/
/*------- Insert your value of OP here -------*/
/* PFT OP used currently in HSS (OPENAIRHSS/auc/kdf.c) */
#define OAI_LTEBOX
#ifdef OAI_LTEBOX
//1006020f0a478bf6b699f15c062e42b3
/*u8 OP[16] = {0xb3, 0x42, 0x2e, 0x06, 0x5c, 0xf1, 0x99, 0xb6,
0xf6, 0x8b, 0x47, 0x0a, 0x0f, 0x02, 0x06, 0x10
};*/
u8 OP[16] = {0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3
};
#else
u8 OP[16] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
};
#endif
/*------- Insert your value of OP here -------*/
/*-------------------------------------------------------------------
* Algorithm f1
*-------------------------------------------------------------------
......@@ -69,16 +49,14 @@ u8 OP[16] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
*
*-----------------------------------------------------------------*/
void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
u8 mac_a_pP[8] )
u8 mac_a_pP[8], const u8 op_c[16])
{
u8 op_c[16];
u8 temp[16];
u8 in1[16];
u8 out1[16];
u8 rijndaelInput[16];
u8 i;
RijndaelKeySchedule( k_pP );
ComputeOPc( op_c );
for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
......@@ -124,9 +102,8 @@ void f1 ( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
*
*-----------------------------------------------------------------*/
void f2345 ( u8 k_pP[16], u8 rand_pP[16],
u8 res_pP[8], u8 ck_pP[16], u8 ik_pP[16], u8 ak_pP[6] )
u8 res_pP[8], u8 ck_pP[16], u8 ik_pP[16], u8 ak_pP[6],const u8 op_c[16])
{
u8 op_c[16];
u8 temp[16];
u8 out[16];
u8 rijndaelInput[16];
......@@ -142,7 +119,6 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16],
rand_pP[8],rand_pP[9],rand_pP[10],rand_pP[11],rand_pP[12],rand_pP[13],rand_pP[14],rand_pP[15]);
RijndaelKeySchedule( k_pP );
ComputeOPc( op_c );
for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
......@@ -225,16 +201,14 @@ void f2345 ( u8 k_pP[16], u8 rand_pP[16],
*
*-----------------------------------------------------------------*/
void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
u8 mac_s_pP[8] )
u8 mac_s_pP[8],const u8 op_c[16])
{
u8 op_c[16];
u8 temp[16];
u8 in1[16];
u8 out1[16];
u8 rijndaelInput[16];
u8 i;
RijndaelKeySchedule( k_pP );
ComputeOPc( op_c );
for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
......@@ -280,15 +254,13 @@ void f1star( u8 k_pP[16], u8 rand_pP[16], u8 sqn_pP[6], u8 amf_pP[2],
*
*-----------------------------------------------------------------*/
void f5star( u8 k_pP[16], u8 rand_pP[16],
u8 ak_pP[6] )
u8 ak_pP[6], const u8 op_c[16])
{
u8 op_c[16];
u8 temp[16];
u8 out[16];
u8 rijndaelInput[16];
u8 i;
RijndaelKeySchedule( k_pP );
ComputeOPc( op_c );
for (i=0; i<16; i++)
rijndaelInput[i] = rand_pP[i] ^ op_c[i];
......@@ -316,22 +288,17 @@ void f5star( u8 k_pP[16], u8 rand_pP[16],
* Function to compute OPc from OP and K. Assumes key schedule has
already been performed.
*-----------------------------------------------------------------*/
void ComputeOPc( u8 op_c_pP[16] )
void ComputeOPc(const u8 op[16], u8 op_c_pP[16])
{
u8 i;
LOG_TRACE(DEBUG,
"USIM-API - ComputeOPc : OP[0..15]=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
OP[0],OP[1],OP[2], OP[3], OP[4], OP[5], OP[6], OP[7],
OP[8],OP[9],OP[10],OP[11],OP[12],OP[13],OP[14],OP[15]);
RijndaelEncrypt( OP, op_c_pP );
"USIM-API - ComputeOPc : op[0..15]=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
op[0],op[1],op[2], op[3], op[4], op[5], op[6], op[7],
op[8],op[9],op[10],op[11],op[12],op[13],op[14],op[15]);
RijndaelEncrypt( op, op_c_pP );
for (i=0; i<16; i++)
op_c_pP[i] ^= OP[i];
LOG_TRACE(DEBUG,
"USIM-API - OPc[0..15]=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
op_c_pP[0],op_c_pP[1],op_c_pP[2], op_c_pP[3], op_c_pP[4], op_c_pP[5], op_c_pP[6], op_c_pP[7],
op_c_pP[8],op_c_pP[9],op_c_pP[10],op_c_pP[11],op_c_pP[12],op_c_pP[13],op_c_pP[14],op_c_pP[15]);
op_c_pP[i] ^= op[i];
return;
} /* end of function ComputeOPc */
......@@ -489,7 +456,7 @@ void MixColumn(u8 state[4][4])
* 16-byte output (using round keys already derived from 16-byte
* key).
*-----------------------------------------------------------------*/
void RijndaelEncrypt( u8 input[16], u8 output[16] )
void RijndaelEncrypt(const u8 input[16], u8 output[16] )
{
u8 state[4][4];
int i, r;
......
......@@ -23,13 +23,13 @@ typedef unsigned char u8;
/*--------------------------- prototypes --------------------------*/
void f1 ( u8 k[16], u8 rand[16], u8 sqn[6], u8 amf[2],
u8 mac_a[8] );
u8 mac_a[8], const u8 op[16]);
void f2345 ( u8 k[16], u8 rand[16],
u8 res[8], u8 ck[16], u8 ik[16], u8 ak[6] );
u8 res[8], u8 ck[16], u8 ik[16], u8 ak[6], const u8 op[16]);
void f1star( u8 k[16], u8 rand[16], u8 sqn[6], u8 amf[2],
u8 mac_s[8] );
u8 mac_s[8], const u8 op[16]);
void f5star( u8 k[16], u8 rand[16],
u8 ak[6] );
void ComputeOPc( u8 op_c[16] );
u8 ak[6], const u8 op[16]);
void ComputeOPc(const u8 op[16], u8 op_c_pP[16] );
void RijndaelKeySchedule( u8 key[16] );
void RijndaelEncrypt( u8 input[16], u8 output[16] );
void RijndaelEncrypt(const u8 input[16], u8 output[16] );
This diff is collapsed.
......@@ -48,6 +48,23 @@ Description Implements the API used by the NAS layer to read/write
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* Subscriber authentication security key
*/
#define USIM_API_K_SIZE 16
#define USIM_API_K_VALUE "fec86ba6eb707ed08905757b1bb44b8f"
/*
* The name of the file where are stored data of the USIM application
*/
#define USIM_API_NVRAM_FILENAME ".usim.nvram"
/*
* The name of the environment variable which defines the directory
* where the USIM application file is located
*/
#define USIM_API_NVRAM_DIRNAME "USIM_DIR"
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
......@@ -106,8 +123,27 @@ typedef struct {
/* Integrity key */
#define USIM_IK_SIZE 16
Byte_t ik[USIM_IK_SIZE];
uint8_t usim_api_k[USIM_API_K_SIZE];
uint8_t opc[16];
} usim_keys_t;
/*
* List of last used Sequence Numbers SQN
*/
#define USIM_API_AK_SIZE 6
#define USIM_API_SQN_SIZE USIM_API_AK_SIZE
#define USIM_API_SQNMS_SIZE USIM_API_SQN_SIZE
typedef struct {
/* Highest sequence number the USIM has ever accepted */
uint8_t sqn_ms[USIM_API_SQNMS_SIZE];
/* List of the last used sequence numbers */
#define USIM_API_SQN_LIST_SIZE 32
uint8_t n_sqns;
uint32_t sqn[USIM_API_SQN_LIST_SIZE];
} usim_sqn_data_t;
/*
* EPS NAS Security Context
* ------------------------
......@@ -329,6 +365,7 @@ typedef struct {
usim_nasconfig_t nasconfig;
/* usim test mode */
uint8_t usimtestmode;
usim_sqn_data_t usim_sqn_data;
} usim_data_t;
/****************************************************************************/
......@@ -339,14 +376,15 @@ typedef struct {
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int usim_api_read(usim_data_t* data);
int usim_api_read(const char *filename, usim_data_t* data);
int usim_api_write(const usim_data_t* data);
int usim_api_write(const char *filename, const usim_data_t* data);
int usim_api_authenticate(const OctetString* rand, const OctetString* autn,
int usim_api_authenticate(usim_data_t *usim_data, const OctetString* rand_pP, const OctetString* autn_pP,
OctetString* auts, OctetString* res,
OctetString* ck, OctetString* ik);
int usim_api_authenticate_test(const OctetString* rand, const OctetString* autn,
int usim_api_authenticate_test(usim_data_t *usim_data,
const OctetString* rand, const OctetString* autn,
OctetString* auts, OctetString* res,
OctetString* ck, OctetString* ik);
......
This diff is collapsed.
This diff is collapsed.
#ifndef _AUTHENTICATION_H
#define _AUTHENTICATION_H
/*
* Internal data used for authentication procedure
*/
typedef struct {
uint8_t rand[AUTH_RAND_SIZE]; /* Random challenge number */
uint8_t res[AUTH_RES_SIZE]; /* Authentication response */
uint8_t ck[AUTH_CK_SIZE]; /* Ciphering key */
uint8_t ik[AUTH_IK_SIZE]; /* Integrity key */
#define AUTHENTICATION_T3410 0x01
#define AUTHENTICATION_T3417 0x02
#define AUTHENTICATION_T3421 0x04
#define AUTHENTICATION_T3430 0x08
unsigned char timers; /* Timer restart bitmap */
#define AUTHENTICATION_COUNTER_MAX 3
unsigned char mac_count:2; /* MAC failure counter (#20) */
unsigned char umts_count:2; /* UMTS challenge failure counter (#26) */
unsigned char sync_count:2; /* Sync failure counter (#21) */
} authentication_data_t;
#endif
This diff is collapsed.
......@@ -115,7 +115,7 @@ int emm_proc_status_ind(unsigned int ueid, int emm_cause)
** Others: None **
** **
***************************************************************************/
int emm_proc_status(unsigned int ueid, int emm_cause)
int emm_proc_status(nas_user_t *user, int emm_cause)
{
LOG_FUNC_IN;
......@@ -132,15 +132,15 @@ int emm_proc_status(unsigned int ueid, int emm_cause)
*/
emm_sap.primitive = EMMAS_STATUS_IND;
emm_sap.u.emm_as.u.status.emm_cause = emm_cause;
emm_sap.u.emm_as.u.status.ueid = ueid;
emm_sap.u.emm_as.u.status.ueid = user->ueid;
emm_sap.u.emm_as.u.status.guti = _emm_data.guti;
sctx = _emm_data.security;
emm_sap.u.emm_as.u.status.guti = user->emm_data->guti;
sctx = user->emm_data->security;
/* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.status.sctx, sctx,
FALSE, TRUE);
rc = emm_sap_send(&emm_sap);
rc = emm_sap_send(user, &emm_sap);
LOG_FUNC_RETURN (rc);
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef _LOWER_LAYER_DEFS_H
#define _LOWER_LAYER_DEFS_H
/*
* Type of EMM procedure callback function executed whenever data are
* successfully delivered to the network
*/
typedef int (*lowerlayer_success_callback_t)(void *);
/*
* Type of EMM procedure callback function executed when data are not
* delivered to the network because a lower layer failure occurred
*/
typedef int (*lowerlayer_failure_callback_t)(int, void *);
/*
* Type of EMM procedure callback function executed when NAS signalling
* connection is released
*/
typedef int (*lowerlayer_release_callback_t)(void *);
/*
* Data structure used to handle EMM procedures executed by the UE upon
* receiving lower layer notifications
*/
typedef struct {
lowerlayer_success_callback_t success; /* Successful data delivery */
lowerlayer_failure_callback_t failure; /* Lower layer failure */
lowerlayer_release_callback_t release; /* NAS signalling release */
void *args; /* EMM procedure argument parameters */
} lowerlayer_data_t;
#endif
This diff is collapsed.
......@@ -78,11 +78,11 @@ Description Implements the EPS Mobility Management procedures executed
** Others: emm_fsm_status **
** **
***************************************************************************/
int EmmDeregisteredNoImsi(const emm_reg_t *evt)
int EmmDeregisteredNoImsi(nas_user_t *user, const emm_reg_t *evt)
{
LOG_FUNC_IN;
assert(emm_fsm_get_status() == EMM_DEREGISTERED_NO_IMSI);
assert(emm_fsm_get_status(user) == EMM_DEREGISTERED_NO_IMSI);
LOG_TRACE(ERROR, "EMM-FSM - USIM is not present or not valid");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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