Commit ca37e0c1 authored by Laurent THOMAS's avatar Laurent THOMAS Committed by Robert Schmidt

Clean up NAS code, remove unused compile options

parent d68a8b51
......@@ -260,7 +260,6 @@ endif()
# Debug related options
#########################################
add_boolean_option(DEBUG_ASN1 False "Enable ASN1 debug logs" OFF)
# asn1c skeletons have hardcoded this flag to make customized debug logs
# OAI uses this feature to re-use OAI LOG_I(ASN1, ...)
# see common/utils/config.h
......@@ -505,7 +504,7 @@ add_boolean_option(ENABLE_VCD_FIFO False "time measurements of proc cal
##########################
# PHY options
##########################
add_integer_option(MAX_NUM_CCs 1 "????" ON)
add_integer_option(MAX_NUM_CCs 1 "Carrier component data arrays size (oai doesn't support carrier aggreagtion for now)" ON)
add_boolean_option(SMBV False "Rohde&Schwarz SMBV100A vector signal generator" ON)
add_boolean_option(DEBUG_PHY False "Enable PHY layer debugging options" ON)
add_boolean_option(DEBUG_PHY_PROC False "Enable debugging of PHY layer procedures" ON)
......@@ -513,10 +512,7 @@ add_boolean_option(DEBUG_PHY_PROC False "Enable debugging of PHY layer
##########################
# NAS LAYER OPTIONS
##########################
add_boolean_option(ENABLE_NAS_UE_LOGGING True "????" ON)
add_boolean_option(NAS_BUILT_IN_UE True "UE NAS layer present in this executable" ON)
add_boolean_option(NAS_UE True "NAS UE INSTANCE (<> NAS_MME)" ON)
##########################
# RRC LAYER OPTIONS
......
......@@ -105,11 +105,7 @@ add_definitions("-DFIRMWARE_VERSION=\"${FIRMWARE_VERSION}\"")
##########################
# NAS LAYER OPTIONS
##########################
add_boolean_option(ENABLE_NAS_UE_LOGGING True "????")
add_boolean_option(NAS_BUILT_IN_EPC False "MME NAS layer not present in this executable")
add_boolean_option(NAS_BUILT_IN_UE False "UE NAS layer present in this executable")
add_boolean_option(NAS_UE True "NAS UE INSTANCE (<> NAS_MME)")
add_boolean_option(NAS_MME False "NAS_UE and NAS_MME are incompatible options")
################################################################################
# SECU LIB
......
......@@ -1726,7 +1726,8 @@ void *UE_thread(void *arg) {
pthread_mutex_unlock(&sync_mutex);
*/
wait_sync("UE thread");
#ifdef NAS_UE
#ifdef NAS_BUILT_IN_UE
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, 0, INITIALIZE_MESSAGE);
itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p);
......@@ -2089,7 +2090,7 @@ void init_UE_single_thread_stub(int nb_inst) {
AssertFatal(PHY_vars_UE_g[i][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n");
if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) {
#ifdef NAS_UE
#ifdef NAS_BUILT_IN_UE
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, 0, INITIALIZE_MESSAGE);
itti_send_msg_to_task (TASK_NAS_UE, i + NB_eNB_INST, message_p);
......
......@@ -42,11 +42,7 @@ Description Defines the layer 3 messages supported by the NAS sublayer
#include "commonDef.h"
#include "emm_msg.h"
#if defined(NAS_BUILT_IN_EPC)
#include "emmData.h"
#endif
#include "esm_msg.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
......
......@@ -129,13 +129,7 @@ int network_api_initialize(const char* host, const char* port)
_network_api_id.send = socket_send;
_network_api_id.close = socket_close;
/* Initialize UDP communication channel with the network layer */
#ifdef NAS_UE
_network_api_id.endpoint = NETWORK_API_OPEN(SOCKET_CLIENT, host, port);
#endif
#ifdef NAS_MME
_network_api_id.endpoint = NETWORK_API_OPEN(SOCKET_SERVER, NULL, port);
#endif
if (_network_api_id.endpoint == NULL) {
LOG_TRACE(ERROR, "NET-API - Failed to open connection endpoint, %s",
((errno < 0) ? gai_strerror(errno) : strerror(errno)));
......
......@@ -86,14 +86,6 @@ int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len) {
LOG_FUNC_IN;
int header_result;
int decode_result;
uint8_t *buffer_log = buffer;
uint32_t len_log = len;
int down_link;
# if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)))
down_link = 0;
# else
down_link = 1;
# endif
/* First decode the EMM message header */
header_result = _emm_msg_decode_header(&msg->header, buffer, len);
......@@ -247,14 +239,13 @@ int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len) {
if (decode_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to decode L3 EMM message 0x%x "
"(%d)", msg->header.message_type, decode_result);
LOG_FUNC_RETURN (decode_result);
LOG_FUNC_RETURN(decode_result);
} else {
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
/* Message has been decoded and security header removed, handle it has a plain message */
nas_itti_plain_msg((char *) buffer_log, (nas_message_t *) msg, len_log, down_link);
#if defined(NAS_BUILT_IN_EPC)
nas_itti_plain_msg((char *)buffer_log, (nas_message_t *)msg, len_log, 0);
#endif
}
LOG_FUNC_RETURN (header_result + decode_result);
}
......@@ -279,13 +270,6 @@ int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len) {
LOG_FUNC_IN;
int header_result;
int encode_result;
uint8_t *buffer_log = buffer;
int down_link;
# if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)))
down_link = 1;
# else
down_link = 0;
# endif
/* First encode the EMM message header */
header_result = _emm_msg_encode_header(&msg->header, buffer, len);
......@@ -443,8 +427,8 @@ int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to encode L3 EMM message 0x%x "
"(%d)", msg->header.message_type, encode_result);
} else {
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
nas_itti_plain_msg((char *) buffer_log, (nas_message_t *) msg, header_result + encode_result, down_link);
#if defined(NAS_BUILT_IN_EPC)
nas_itti_plain_msg((char *)buffer_log, (nas_message_t *)msg, header_result + encode_result, 1);
#endif
}
......
......@@ -43,10 +43,6 @@ Description Defines EPS Session Management messages
#include "TLVDecoder.h"
#include "TLVEncoder.h"
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
# include "nas_itti_messaging.h"
#endif
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
......@@ -84,19 +80,6 @@ int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
{
int header_result;
int decode_result;
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
uint8_t *buffer_log = buffer;
uint32_t len_log = len;
int down_link;
# if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)))
down_link = 0;
# else
down_link = 1;
# endif
#endif
LOG_FUNC_IN;
/* First decode the ESM message header */
......@@ -210,14 +193,12 @@ int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
if (decode_result < 0) {
LOG_TRACE(ERROR, "ESM-MSG - Failed to decode L3 ESM message 0x%x "
"(%u)", msg->header.message_type, decode_result);
LOG_FUNC_RETURN (decode_result);
LOG_FUNC_RETURN(decode_result);
} else {
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
/* Message has been decoded and security header removed, handle it has a plain message */
nas_itti_plain_msg((char *) buffer_log, (nas_message_t *) msg, len_log, down_link);
#if defined(NAS_BUILT_IN_EPC)
nas_itti_plain_msg((char *)buffer_log, (nas_message_t *)msg, len_log, 0);
#endif
}
LOG_FUNC_RETURN (header_result + decode_result);
}
......@@ -245,17 +226,6 @@ int esm_msg_encode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
int header_result;
int encode_result;
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
uint8_t *buffer_log = buffer;
int down_link;
# if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)))
down_link = 1;
# else
down_link = 0;
# endif
#endif
/* First encode the ESM message header */
header_result = _esm_msg_encode_header(&msg->header, buffer, len);
......@@ -371,11 +341,10 @@ int esm_msg_encode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
LOG_TRACE(ERROR, "ESM-MSG - Failed to encode L3 ESM message 0x%x "
"(%d)", msg->header.message_type, encode_result);
} else {
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
nas_itti_plain_msg((char *) buffer_log, (nas_message_t *) msg, header_result + encode_result, down_link);
#if defined(NAS_BUILT_IN_EPC)
nas_itti_plain_msg((char *)buffer_log, (nas_message_t *)msg, header_result + encode_result, 1);
#endif
}
LOG_FUNC_RETURN (header_result + encode_result);
}
......
......@@ -38,7 +38,7 @@ Description Usefull logging functions
#ifndef __NAS_LOG_H__
#define __NAS_LOG_H__
#if defined(NAS_BUILT_IN_UE) && defined(NAS_UE)
#if defined(NAS_BUILT_IN_UE)
# include "common/utils/LOG/log.h"
# undef LOG_TRACE
#endif
......
......@@ -216,11 +216,7 @@ int nas_timer_start(long sec, nas_timer_callback_t cb, void *args)
/* Insert the new entry into the timer queue */
_nas_timer_db_insert_entry(id, te);
# if defined(NAS_MME)
ret = timer_setup(sec, 0, TASK_NAS_MME, INSTANCE_DEFAULT, TIMER_PERIODIC, args, &timer_id);
# else
ret = timer_setup(sec, 0, TASK_NAS_UE, INSTANCE_DEFAULT, TIMER_PERIODIC, args, &timer_id);
# endif
if (ret == -1) {
return NAS_TIMER_INACTIVE_ID;
......@@ -295,39 +291,6 @@ int nas_timer_restart(int id)
return (NAS_TIMER_INACTIVE_ID);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/****************************************************************************
** **
** Name: _nas_timer_handler() **
** **
** Description: The timer handler is executed whenever the system deli- **
** vers signal SIGALARM. It starts execution of the callback **
** function of the first entry within the queue of active **
** timer entries. The entry is not removed from the queue of **
** active timer entries and shall be explicitly removed when **
** the timer expires. **
** **
** Inputs: None **
** Others: None **
** **
** Outputs: None **
** Return: None **
** Others: _nas_timer_db **
** **
***************************************************************************/
void nas_timer_handle_signal_expiry(long timer_id, void *arg_p)
{
/* Get the timer entry for which the system timer expired */
nas_timer_entry_t *te = _nas_timer_db.head->entry;
te->cb(te->args);
}
/*
* -----------------------------------------------------------------------------
* Functions used to manage the timer database
......
......@@ -74,8 +74,4 @@ int nas_timer_start(long sec, nas_timer_callback_t cb, void *args);
int nas_timer_stop(int id);
int nas_timer_restart(int id);
#if defined(NAS_BUILT_IN_EPC)
void nas_timer_handle_signal_expiry(long timer_id, void *arg_p);
#endif
#endif /* __NAS_TIMER_H__ */
......@@ -27,8 +27,7 @@
# define TASK_ORIGIN TASK_NAS_UE
#if (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) )
#if defined(NAS_BUILT_IN_UE)
__attribute__ ((unused)) static const uint8_t emm_message_ids[] = {
ATTACH_REQUEST,
ATTACH_ACCEPT,
......
......@@ -30,22 +30,13 @@
#ifndef NAS_ITTI_MESSAGING_H_
#define NAS_ITTI_MESSAGING_H_
# if (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE))
int nas_itti_plain_msg(
const char *buffer,
const nas_message_t *msg,
const int lengthP,
const int instance);
int nas_itti_protected_msg(
const char *buffer,
const nas_message_t *msg,
const int lengthP,
const int instance);
# endif
# if defined(NAS_BUILT_IN_UE)
int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const int lengthP, const int instance);
int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id);
......@@ -56,5 +47,4 @@ int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t
int nas_itti_ul_data_req(const uint32_t ue_idP, void *const data_pP, const uint32_t lengthP, int user_id);
int nas_itti_rab_establish_rsp(const as_stmsi_t s_tmsi, const as_rab_id_t rabID, const nas_error_code_t errCode, int user_id);
# endif
#endif /* NAS_ITTI_MESSAGING_H_ */
......@@ -34,8 +34,6 @@
#include "nas_user.h"
#include "common/ran_context.h"
// FIXME make command line option for NAS_UE_AUTOSTART
# define NAS_UE_AUTOSTART 1
// FIXME review these externs
extern uint16_t NB_UE_INST;
......@@ -203,15 +201,12 @@ void *nas_ue_task(void *args_p)
switch (ITTI_MSG_ID(msg_p)) {
case INITIALIZE_MESSAGE:
LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME (msg_p));
#if (NAS_UE_AUTOSTART != 0)
LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, ITTI_MSG_NAME(msg_p));
{
/* Send an activate modem command to NAS like UserProcess should do it */
char *user_data = "at+cfun=1\r";
nas_user_receive_and_process (user, user_data);
}
#endif
break;
case TERMINATE_MESSAGE:
......
......@@ -139,7 +139,6 @@ void nr_derive_key(algorithm_type_dist_t alg_type, uint8_t alg_id, const uint8_t
* NOTE: knas is dynamically allocated by the KDF function
*/
#ifndef NAS_UE
void derive_keNB(const uint8_t kasme[32], const uint32_t nas_count, uint8_t *keNB)
{
uint8_t s[7] = {0};
......@@ -159,7 +158,6 @@ void derive_keNB(const uint8_t kasme[32], const uint32_t nas_count, uint8_t *keN
byte_array_t data = {.buf = s, .len = 7};
kdf(kasme, data, 32, keNB);
}
#endif
void derive_keNB_star(const uint8_t *kenb_32,
const uint16_t pci,
......
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