Commit 5f3e2652 authored by Lionel Gauthier's avatar Lionel Gauthier

Merged with trunk

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6501 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 57d7c10f
......@@ -37,7 +37,7 @@ export PROJDIR = $(CURDIR)
all:
ifeq ($(PROCESS), UE)
@$(CD) $(SECUDIR) && $(MAKE)
@$(CD) $(SECUDIR) && $(MAKE) -f Makefile.NAS
endif
@$(CD) $(UTILDIR) && $(MAKE)
@$(CD) $(APIDIR) && $(MAKE)
......
......@@ -34,13 +34,14 @@ endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
include $(PROJDIR)/../Makefile.tools
export LD_RUN_PATH = $(LIBDIR):$(LIBPROCESS)
LIBS = -lapi -lutil -lEMMmsg -lESMmsg -lies -lrt
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
#LIBSUTIL = $(LIBDIR)/$(LIBUTIL).a $(LIBDIR)/$(LIBUTIL).so
USIM_OBJ = usim_data.o
UE_OBJ = ue_data.o
......@@ -57,13 +58,13 @@ all: $(TARGETS)
$(CC) $(CFLAGS) -c $< -o $@
$(USIM_TARGET): $(USIM_OBJ) $(LIBSUTIL)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SECUDIR)/*.o -lnettle -lcrypto -lm
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lnettle -lcrypto -lm
@echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR)
$(UE_TARGET): $(UE_OBJ) $(LIBSUTIL)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SECUDIR)/*.o -lnettle -lcrypto -lm
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -lnettle -lcrypto -lm
@echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR)
......@@ -74,6 +75,10 @@ clean:
veryclean: clean
$(RM) $(TARGETS)
veryveryclean: veryclean
$(RM) -Rf *.o $(PROJDIR)
$(RM) -Rf *.a $(PROJDIR)
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
......
......@@ -53,8 +53,7 @@ Description Implements the utility used to generate data stored in the
#include <stdlib.h> // exit, free
#include <string.h> // memset, strncpy
//#define SELECTED_PLMN SFR1
#define SELECTED_PLMN FCT1
#define SELECTED_PLMN SFR1
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
......@@ -290,7 +289,7 @@ static void _gen_user_data(user_nvdata_t* data)
static void _gen_emm_data(emm_nvdata_t* data)
{
//#if (SELECTED_PLMN == FCT1)
#if 1
#if 0
/*
* International Mobile Subscriber Identity
* IMSI = MCC + MNC + MSIN = 310 (USA) + 028 (UNKNOWN) + 90832150
......
......@@ -27,22 +27,22 @@
*******************************************************************************/
/*****************************************************************************
Source usim_data.c
Source usim_data.c
Version 0.1
Version 0.1
Date 2012/10/31
Date 2012/10/31
Product USIM data generator
Product USIM data generator
Subsystem USIM data generator main process
Subsystem USIM data generator main process
Author Frederic Maurel
Author Frederic Maurel
Description Implements the utility used to generate data stored in the
Description Implements the utility used to generate data stored in the
USIM application
*****************************************************************************/
*****************************************************************************/
#include "network.h"
......@@ -53,8 +53,7 @@ Description Implements the utility used to generate data stored in the
#include <stdlib.h> // exit
#include <string.h> // memset, memcpy, strncpy
//#define SELECTED_PLMN SFR1
#define SELECTED_PLMN FCT1
#define SELECTED_PLMN SFR1
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
......@@ -105,6 +104,7 @@ int main (int argc, const char* argv[])
{
int rc;
usim_data_t usim_data;
int i;
unsigned char gen_data;
......@@ -115,32 +115,28 @@ int main (int argc, const char* argv[])
fprintf(stderr, "Invalid parameter\n");
_display_usage(argv[0]);
exit(EXIT_FAILURE);
}
else if ( (strcmp(argv[1], "--gen") == 0) ||
(strcmp(argv[1], "-g") == 0) ) {
} else if ((strcmp(argv[1], "--gen") == 0)
|| (strcmp(argv[1], "-g") == 0)) {
/* Generate USIM data files */
gen_data = TRUE;
}
else if ( (strcmp(argv[1], "--print") == 0) ||
(strcmp(argv[1], "-p") == 0) ) {
} else if ((strcmp(argv[1], "--print") == 0)
|| (strcmp(argv[1], "-p") == 0)) {
/* Display content of USIM data files */
gen_data = FALSE;
}
else {
} else {
/* Display usage */
_display_usage(argv[0]);
exit(EXIT_SUCCESS);
}
if (gen_data)
{
if (gen_data) {
/*
* Initialize USIM data
*/
memset(&usim_data, 0, sizeof(usim_data_t));
//#if (SELECTED_PLMN == FCT1)
#if 1
//#if (SELECTED_PLMN == FCT1)
#if 0
/*
* International Mobile Subscriber Identity
* IMSI = MCC + MNC + MSIN = 310 (USA) + 028 (UNKNOWN) + 90832150
......@@ -169,7 +165,7 @@ int main (int argc, const char* argv[])
* IMSI = MCC + MNC + MSIN = 208 (France) + 10 (SFR) + 00001234
*/
#warning "IMSI 208.10.00001234"
/* usim_data.imsi.length = 8;
/* usim_data.imsi.length = 8;
usim_data.imsi.u.num.parity = EVEN_PARITY; // Parity: even
usim_data.imsi.u.num.digit1 = 2; // MCC digit 1
usim_data.imsi.u.num.digit2 = 0; // MCC digit 2
......@@ -188,11 +184,11 @@ int main (int argc, const char* argv[])
usim_data.imsi.u.num.digit15 = 0b1111;*/
usim_data.imsi.length = 8;
usim_data.imsi.u.num.parity = 0x0; // Type of identity = IMSI, even
usim_data.imsi.u.num.digit1 = 2; // MCC digit 1
usim_data.imsi.u.num.digit2 = 0; // MCC digit 2
usim_data.imsi.u.num.digit3 = 8; // MCC digit 3
usim_data.imsi.u.num.digit4 = 1; // MNC digit 1
usim_data.imsi.u.num.digit5 = 0; // MNC digit 2
usim_data.imsi.u.num.digit1 = 2;// MCC digit 1
usim_data.imsi.u.num.digit2 = 0;// MCC digit 2
usim_data.imsi.u.num.digit3 = 8;// MCC digit 3
usim_data.imsi.u.num.digit4 = 1;// MNC digit 1
usim_data.imsi.u.num.digit5 = 0;// MNC digit 2
usim_data.imsi.u.num.digit6 = 0;
usim_data.imsi.u.num.digit7 = 0;
usim_data.imsi.u.num.digit8 = 0;
......@@ -218,7 +214,7 @@ int main (int argc, const char* argv[])
/*
* List of Forbidden PLMNs
*/
for (int i = 0; i < USIM_FPLMN_MAX; i++) {
for (i = 0; i < USIM_FPLMN_MAX; i++) {
memset(&usim_data.fplmn[i], 0xff, sizeof(plmn_t));
}
/*
......@@ -299,22 +295,22 @@ int main (int argc, const char* argv[])
/*
* PLMN Network Name and Operator PLMN List
*/
for (int i = SFR1; i < VDF2; i++) {
for (i = SFR1; i < VDF2; i++) {
network_record_t record = network_records[i];
usim_data.pnn[i].fullname.type = USIM_PNN_FULLNAME_TAG;
usim_data.pnn[i].fullname.length = strlen(record.fullname);
strncpy((char*)usim_data.pnn[i].fullname.value, record.fullname,
strncpy((char*) usim_data.pnn[i].fullname.value, record.fullname,
usim_data.pnn[i].fullname.length);
usim_data.pnn[i].shortname.type = USIM_PNN_SHORTNAME_TAG;
usim_data.pnn[i].shortname.length = strlen(record.shortname);
strncpy((char*)usim_data.pnn[i].shortname.value, record.shortname,
strncpy((char*) usim_data.pnn[i].shortname.value, record.shortname,
usim_data.pnn[i].shortname.length);
usim_data.opl[i].plmn = record.plmn;
usim_data.opl[i].start = record.tac_start;
usim_data.opl[i].end = record.tac_end;
usim_data.opl[i].record_id = i;
}
for (int i = VDF2; i < USIM_OPL_MAX; i++) {
for (i = VDF2; i < USIM_OPL_MAX; i++) {
memset(&usim_data.opl[i].plmn, 0xff, sizeof(plmn_t));
}
......@@ -331,29 +327,35 @@ int main (int argc, const char* argv[])
/*
* List of user controlled PLMN selector with Access Technology
*/
for (int i = 0; i < USIM_PLMN_MAX; i++) {
for (i = 0; i < USIM_PLMN_MAX; i++) {
memset(&usim_data.plmn[i], 0xff, sizeof(plmn_t));
}
/*
* List of operator controlled PLMN selector with Access Technology
*/
usim_data.oplmn[0].plmn = network_records[VDF1].plmn;
usim_data.oplmn[0].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN);
usim_data.oplmn[0].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN
| USIM_ACT_EUTRAN);
usim_data.oplmn[1].plmn = network_records[VDF2].plmn;
usim_data.oplmn[1].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN);
usim_data.oplmn[1].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN
| USIM_ACT_EUTRAN);
usim_data.oplmn[2].plmn = network_records[VDF3].plmn;
usim_data.oplmn[2].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN);
usim_data.oplmn[2].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN
| USIM_ACT_EUTRAN);
usim_data.oplmn[3].plmn = network_records[VDF4].plmn;
usim_data.oplmn[3].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN);
usim_data.oplmn[3].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN
| USIM_ACT_EUTRAN);
usim_data.oplmn[4].plmn = network_records[VDF5].plmn;
usim_data.oplmn[4].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN);
for (int i = 5; i < USIM_OPLMN_MAX; i++) {
usim_data.oplmn[4].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN
| USIM_ACT_EUTRAN);
for (i = 5; i < USIM_OPLMN_MAX; i++) {
memset(&usim_data.oplmn[i], 0xff, sizeof(plmn_t));
}
/*
* EPS Location Information
*/
usim_data.epsloci.guti.gummei.plmn = network_records[SELECTED_PLMN].plmn;
usim_data.epsloci.guti.gummei.plmn =
network_records[SELECTED_PLMN].plmn;
usim_data.epsloci.guti.gummei.MMEgid = DEFAULT_MME_ID;
usim_data.epsloci.guti.gummei.MMEcode = DEFAULT_MME_CODE;
usim_data.epsloci.guti.m_tmsi = DEFAULT_M_TMSI;
......@@ -363,7 +365,8 @@ int main (int argc, const char* argv[])
/*
* Non-Access Stratum configuration
*/
usim_data.nasconfig.NAS_SignallingPriority.type = USIM_NAS_SIGNALLING_PRIORITY_TAG;
usim_data.nasconfig.NAS_SignallingPriority.type =
USIM_NAS_SIGNALLING_PRIORITY_TAG;
usim_data.nasconfig.NAS_SignallingPriority.length = 1;
usim_data.nasconfig.NAS_SignallingPriority.value[0] = 0x00;
usim_data.nasconfig.NMO_I_Behaviour.type = USIM_NMO_I_BEHAVIOUR_TAG;
......@@ -376,13 +379,16 @@ int main (int argc, const char* argv[])
#else
usim_data.nasconfig.AttachWithImsi.value[0] = 0x01;
#endif
usim_data.nasconfig.MinimumPeriodicSearchTimer.type = USIM_MINIMUM_PERIODIC_SEARCH_TIMER_TAG;
usim_data.nasconfig.MinimumPeriodicSearchTimer.type =
USIM_MINIMUM_PERIODIC_SEARCH_TIMER_TAG;
usim_data.nasconfig.MinimumPeriodicSearchTimer.length = 1;
usim_data.nasconfig.MinimumPeriodicSearchTimer.value[0] = 0x00;
usim_data.nasconfig.ExtendedAccessBarring.type = USIM_EXTENDED_ACCESS_BARRING_TAG;
usim_data.nasconfig.ExtendedAccessBarring.type =
USIM_EXTENDED_ACCESS_BARRING_TAG;
usim_data.nasconfig.ExtendedAccessBarring.length = 1;
usim_data.nasconfig.ExtendedAccessBarring.value[0] = 0x00;
usim_data.nasconfig.Timer_T3245_Behaviour.type = USIM_TIMER_T3245_BEHAVIOUR_TAG;
usim_data.nasconfig.Timer_T3245_Behaviour.type =
USIM_TIMER_T3245_BEHAVIOUR_TAG;
usim_data.nasconfig.Timer_T3245_Behaviour.length = 1;
usim_data.nasconfig.Timer_T3245_Behaviour.value[0] = 0x00;
......@@ -429,17 +435,16 @@ int main (int argc, const char* argv[])
/*
* Displays command line usage
*/
static void _display_usage(const char* command)
{
static 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[--print|-p]\tDisplay the content of the USIM data file\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 {
} else {
fprintf(stderr, "USIM_DIR environment variable is not defined\n");
}
}
......@@ -447,9 +452,9 @@ static void _display_usage(const char* command)
/*
* Displays USIM application data
*/
static void _display_usim_data(const usim_data_t* data)
{
static void _display_usim_data(const usim_data_t* data) {
int digits;
int i;
printf("Administrative Data:\n");
printf("\tUE_Operation_Mode\t= 0x%.2x\n", data->ad.UE_Operation_Mode);
......@@ -458,8 +463,10 @@ static void _display_usim_data(const usim_data_t* data)
printf("IMSI:\n");
printf("\tlength\t= %d\n", data->imsi.length);
printf("\tparity\t= %s\n", data->imsi.u.num.parity == EVEN_PARITY ? "Even" : "Odd");
digits = (data->imsi.length * 2) - 1 - (data->imsi.u.num.parity == EVEN_PARITY ? 1 : 0);
printf("\tparity\t= %s\n",
data->imsi.u.num.parity == EVEN_PARITY ? "Even" : "Odd");
digits = (data->imsi.length * 2) - 1
- (data->imsi.u.num.parity == EVEN_PARITY ? 1 : 0);
printf("\tdigits\t= %d\n", digits);
printf("\tdigits\t= %u%u%u%u%u%x%u%u%u%u",
data->imsi.u.num.digit1, // MCC digit 1
......@@ -468,10 +475,8 @@ static void _display_usim_data(const usim_data_t* data)
data->imsi.u.num.digit4, // MNC digit 1
data->imsi.u.num.digit5, // MNC digit 2
data->imsi.u.num.digit6, // MNC digit 3
data->imsi.u.num.digit7,
data->imsi.u.num.digit8,
data->imsi.u.num.digit9,
data->imsi.u.num.digit10);
data->imsi.u.num.digit7, data->imsi.u.num.digit8,
data->imsi.u.num.digit9, data->imsi.u.num.digit10);
if (digits >= 11)
printf("%x", data->imsi.u.num.digit11);
if (digits >= 12)
......@@ -486,7 +491,7 @@ static void _display_usim_data(const usim_data_t* data)
printf("Ciphering and Integrity Keys:\n");
printf("\tKSI\t: 0x%.2x\n", data->keys.ksi);
char key[USIM_CK_SIZE+1];
char key[USIM_CK_SIZE + 1];
key[USIM_CK_SIZE] = '\0';
memcpy(key, data->keys.ck, USIM_CK_SIZE);
printf("\tCK\t: \"%s\"\n", key);
......@@ -495,67 +500,68 @@ static void _display_usim_data(const usim_data_t* data)
printf("EPS NAS security context:\n");
printf("\tKSIasme\t: 0x%.2x\n", data->securityctx.KSIasme.value[0]);
char kasme[USIM_K_ASME_SIZE+1];
char kasme[USIM_K_ASME_SIZE + 1];
kasme[USIM_K_ASME_SIZE] = '\0';
memcpy(kasme, data->securityctx.Kasme.value, USIM_K_ASME_SIZE);
printf("\tKasme\t: \"%s\"\n", kasme);
printf("\tulNAScount\t: 0x%.8x\n",
*(UInt32_t*)data->securityctx.ulNAScount.value);
*(UInt32_t*) data->securityctx.ulNAScount.value);
printf("\tdlNAScount\t: 0x%.8x\n",
*(UInt32_t*)data->securityctx.dlNAScount.value);
*(UInt32_t*) data->securityctx.dlNAScount.value);
printf("\talgorithmID\t: 0x%.2x\n\n",
data->securityctx.algorithmID.value[0]);
printf("MSISDN\t= %u%u%u %u%u%u%u %u%u%u%u\n\n",
data->msisdn.number.digit[0].msb,
data->msisdn.number.digit[0].lsb,
data->msisdn.number.digit[1].msb,
data->msisdn.number.digit[1].lsb,
data->msisdn.number.digit[2].msb,
data->msisdn.number.digit[2].lsb,
data->msisdn.number.digit[3].msb,
data->msisdn.number.digit[3].lsb,
data->msisdn.number.digit[4].msb,
data->msisdn.number.digit[4].lsb,
data->msisdn.number.digit[0].msb, data->msisdn.number.digit[0].lsb,
data->msisdn.number.digit[1].msb, data->msisdn.number.digit[1].lsb,
data->msisdn.number.digit[2].msb, data->msisdn.number.digit[2].lsb,
data->msisdn.number.digit[3].msb, data->msisdn.number.digit[3].lsb,
data->msisdn.number.digit[4].msb, data->msisdn.number.digit[4].lsb,
data->msisdn.number.digit[5].msb);
for (int i = 0; i < USIM_PNN_MAX; i++) {
printf("PNN[%d]\t= {%s, %s}\n", i,
data->pnn[i].fullname.value, data->pnn[i].shortname.value);
for (i = 0; i < USIM_PNN_MAX; i++) {
printf("PNN[%d]\t= {%s, %s}\n", i, data->pnn[i].fullname.value,
data->pnn[i].shortname.value);
}
printf("\n");
for (int i = 0; i < USIM_OPL_MAX; i++) {
printf("OPL[%d]\t= ", i); PRINT_PLMN(data->opl[i].plmn);
printf(", TAC = [%.4x - %.4x], record_id = %d\n",
data->opl[i].start, data->opl[i].end, data->opl[i].record_id);
for (i = 0; i < USIM_OPL_MAX; i++) {
printf("OPL[%d]\t= ", i);
PRINT_PLMN(data->opl[i].plmn);
printf(", TAC = [%.4x - %.4x], record_id = %d\n", data->opl[i].start,
data->opl[i].end, data->opl[i].record_id);
}
printf("\n");
printf("HPLMN\t\t= "); PRINT_PLMN(data->hplmn.plmn);
printf("HPLMN\t\t= ");
PRINT_PLMN(data->hplmn.plmn);
printf(", AcT = 0x%x\n\n", data->hplmn.AcT);
for (int i = 0; i < USIM_FPLMN_MAX; i++) {
printf("FPLMN[%d]\t= ", i); PRINT_PLMN(data->fplmn[i]);
for (i = 0; i < USIM_FPLMN_MAX; i++) {
printf("FPLMN[%d]\t= ", i);
PRINT_PLMN(data->fplmn[i]);
printf("\n");
}
printf("\n");
for (int i = 0; i < USIM_EHPLMN_MAX; i++) {
printf("EHPLMN[%d]\t= ", i); PRINT_PLMN(data->ehplmn[i]);
for (i = 0; i < USIM_EHPLMN_MAX; i++) {
printf("EHPLMN[%d]\t= ", i);
PRINT_PLMN(data->ehplmn[i]);
printf("\n");
}
printf("\n");
for (int i = 0; i < USIM_PLMN_MAX; i++) {
printf("PLMN[%d]\t\t= ", i); PRINT_PLMN(data->plmn[i].plmn);
for (i = 0; i < USIM_PLMN_MAX; i++) {
printf("PLMN[%d]\t\t= ", i);
PRINT_PLMN(data->plmn[i].plmn);
printf(", AcTPLMN = 0x%x", data->plmn[i].AcT);
printf("\n");
}
printf("\n");
for (int i = 0; i < USIM_OPLMN_MAX; i++) {
printf("OPLMN[%d]\t= ", i); PRINT_PLMN(data->oplmn[i].plmn);
for (i = 0; i < USIM_OPLMN_MAX; i++) {
printf("OPLMN[%d]\t= ", i);
PRINT_PLMN(data->oplmn[i].plmn);
printf(", AcTPLMN = 0x%x", data->oplmn[i].AcT);
printf("\n");
}
......@@ -565,19 +571,19 @@ static void _display_usim_data(const usim_data_t* data)
printf("LOCI:\n");
printf("\tTMSI = 0x%.4x\n", data->loci.tmsi);
printf("\tLAI\t: PLMN = "); PRINT_PLMN(data->loci.lai.plmn);
printf("\tLAI\t: PLMN = ");
PRINT_PLMN(data->loci.lai.plmn);
printf(", LAC = 0x%.2x\n", data->loci.lai.lac);
printf("\tstatus\t= %d\n\n", data->loci.status);
printf("PSLOCI:\n");
printf("\tP-TMSI = 0x%.4x\n", data->psloci.p_tmsi);
printf("\tsignature = 0x%x 0x%x 0x%x\n",
data->psloci.signature[0],
data->psloci.signature[1],
data->psloci.signature[2]);
printf("\tRAI\t: PLMN = "); PRINT_PLMN(data->psloci.rai.plmn);
printf(", LAC = 0x%.2x, RAC = 0x%.1x\n",
data->psloci.rai.lac, data->psloci.rai.rac);
printf("\tsignature = 0x%x 0x%x 0x%x\n", data->psloci.signature[0],
data->psloci.signature[1], data->psloci.signature[2]);
printf("\tRAI\t: PLMN = ");
PRINT_PLMN(data->psloci.rai.plmn);
printf(", LAC = 0x%.2x, RAC = 0x%.1x\n", data->psloci.rai.lac,
data->psloci.rai.rac);
printf("\tstatus\t= %d\n\n", data->psloci.status);
printf("EPSLOCI:\n");
......@@ -589,8 +595,7 @@ static void _display_usim_data(const usim_data_t* data)
printf(", M-TMSI = 0x%.4x\n", data->epsloci.guti.m_tmsi);
printf("\tTAI\t: PLMN = ");
PRINT_PLMN(data->epsloci.tai.plmn);
printf(", TAC = 0x%.2x\n",
data->epsloci.tai.tac);
printf(", TAC = 0x%.2x\n", data->epsloci.tai.tac);
printf("\tstatus\t= %d\n\n", data->epsloci.status);
printf("NASCONFIG:\n");
......
......@@ -28,6 +28,7 @@
*******************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <gmp.h>
#ifndef AUC_H_
......
......@@ -70,11 +70,21 @@
#define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE
#define MAX_NUM_RE (14*1200)
#if !defined(SI_RNTI)
#define SI_RNTI (rnti_t)0xffff
#endif
#if !defined(M_RNTI)
#define M_RNTI (rnti_t)0xfffd
#endif
#if !defined(P_RNTI)
#define P_RNTI (rnti_t)0xfffe
#endif
#if !defined(CBA_RNTI)
#define CBA_RNTI (rnti_t)0xfff4
#endif
#if !defined(C_RNTI)
#define C_RNTI (rnti_t)0x1234
#endif
#define PMI_2A_11 0
#define PMI_2A_1m1 1
......
......@@ -159,7 +159,6 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg,
int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
void fill_ue_band_info(void);
#ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE
......@@ -250,6 +249,7 @@ static uint32_t downlink_frequency[MAX_NUM_CCs][4];/* = {{19
{1907600000,1907600000,1907600000,1907600000}};*/
static int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; /*= {{0,0,0,0},{0,0,0,0}};
*/
openair0_rf_map rf_map[MAX_NUM_CCs];
static char *conf_config_file_name = NULL;
......@@ -464,7 +464,6 @@ static const eutra_band_t eutra_bands[] =
{43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD},
{44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD},
};
unsigned int build_rflocal(int txi, int txq, int rxi, int rxq)
{
return (txi + (txq<<6) + (rxi<<12) + (rxq<<18));
......@@ -1023,13 +1022,13 @@ static void * eNB_thread_tx(void *param) {
if (task==NULL) {
LOG_E(PHY,"[SCHED][eNB] Problem starting eNB_proc_TX thread_index %d (%s)!!!!\n",proc->subframe,task_name);
return 0;
}
}
else {
LOG_I(PHY,"[SCHED][eNB] eNB TX thread CC %d SF %d started with id %p\n",
proc->CC_id,
proc->subframe,
task);
}
}
#else
#ifdef LOWLATENCY
attr.size = sizeof(attr);
......@@ -1046,7 +1045,7 @@ static void * eNB_thread_tx(void *param) {
if (sched_setattr(0, &attr, flags) < 0 ){
perror("[SCHED] eNB tx thread: sched_setattr failed\n");
exit(-1);
}
}
LOG_I(HW,"[SCHED] eNB TX deadline thread %d(id %ld) started on CPU %d\n",
proc->subframe, gettid(),sched_getcpu());
#else
......@@ -1103,30 +1102,30 @@ static void * eNB_thread_tx(void *param) {
phy_procedures_eNB_TX(proc->subframe,PHY_vars_eNB_g[0][proc->CC_id],0,no_relay,NULL);
}
}
if ((subframe_select(&PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms,proc->subframe_tx)==SF_S)) {
phy_procedures_eNB_TX(proc->subframe,PHY_vars_eNB_g[0][proc->CC_id],0,no_relay,NULL);
}
}
do_OFDM_mod_rt(proc->subframe_tx,PHY_vars_eNB_g[0][proc->CC_id]);
if (pthread_mutex_lock(&proc->mutex_tx) != 0) {
printf("[openair][SCHED][eNB] error locking mutex for eNB TX proc %d\n",proc->subframe);
}
}
else {
proc->instance_cnt_tx--;
if (pthread_mutex_unlock(&proc->mutex_tx) != 0) {
printf("[openair][SCHED][eNB] error unlocking mutex for eNB TX proc %d\n",proc->subframe);
}
}
}
}
proc->frame_tx++;
if (proc->frame_tx==1024)
proc->frame_tx=0;
}
}
stop_meas(&softmodem_stats_tx_sf[proc->subframe]);
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),0);
#ifdef HARD_RT
......@@ -1149,8 +1148,8 @@ static void * eNB_thread_tx(void *param) {
#endif
}
int eNB_thread_rx_status[10];
static void * eNB_thread_rx(void *param) {
int eNB_thread_rx_status[10];
static void * eNB_thread_rx(void *param) {
//unsigned long cpuid;
eNB_proc_t *proc = (eNB_proc_t*)param;
......@@ -1177,7 +1176,7 @@ static void * eNB_thread_rx(void *param) {
if (task==NULL) {
LOG_E(PHY,"[SCHED][eNB] Problem starting eNB_proc_RX thread_index %d (%s)!!!!\n",proc->subframe,task_name);
return 0;
}
}
else {
LOG_I(PHY,"[SCHED][eNB] eNB RX thread CC_id %d SF %d started with id %p\n", /* on CPU %d*/
proc->CC_id,
......@@ -1476,6 +1475,7 @@ static void *eNB_thread(void *arg)
attr.sched_deadline = 0.5 * 1000000;
attr.sched_period = 1.0 * 1000000;
/* pin the eNB main thread to CPU0*/
/* if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) {
perror("[MAIN_ENB_THREAD] pthread_setaffinity_np failed\n");
......@@ -1875,7 +1875,6 @@ static void *UE_thread_synch(void *arg) {
LOG_D(PHY,"[SCHED][UE] Check absolute frequency %u\n",downlink_frequency[0][0]);
sync_mode=pbch;
}
while (!oai_exit) {
if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
......@@ -1892,7 +1891,6 @@ static void *UE_thread_synch(void *arg) {
}
} // mutex_lock
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,1);
switch (sync_mode) {
......@@ -1995,11 +1993,12 @@ static void *UE_thread_synch(void *arg) {
// rt_sleep_ns(FRAME_PERIOD);
} // freq_offset
} // initial_sync=0
break;
case si:
default:
break;
}
break;
}
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0);
printf("Finished synch : Locking synch mutex (thread_sync)\n");
if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
......@@ -2012,6 +2011,7 @@ static void *UE_thread_synch(void *arg) {
printf("[openair][SCHED][eNB] error unlocking mutex for UE synch\n");
}
}
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0);
} // while !oai_exit
return(0);
......@@ -2302,11 +2302,11 @@ static void *UE_thread(void *arg) {
void *rxp[2],*txp[2];
/*
#ifdef LOWLATENCY
#ifdef LOWLATENCY
struct sched_attr attr;
unsigned int flags = 0;
unsigned long mask = 1; // processor 0
#endif
#endif
*/
printf("waiting for sync (UE_thread)\n");
......@@ -2323,7 +2323,7 @@ static void *UE_thread(void *arg) {
printf("starting UE thread\n");
/*
#ifdef LOWLATENCY
#ifdef LOWLATENCY
attr.size = sizeof(attr);
attr.sched_flags = 0;
attr.sched_nice = 0;
......@@ -2347,7 +2347,7 @@ static void *UE_thread(void *arg) {
LOG_I(HW,"[SCHED][eNB] eNB main deadline thread %ld started on CPU %d\n",
gettid(),sched_getcpu());
}
#endif
#endif
*/
mlockall(MCL_CURRENT | MCL_FUTURE);
......@@ -2497,7 +2497,6 @@ static void *UE_thread(void *arg) {
//LOG_D(PHY,"HW RESYNC: hw_frame %d: Resynchronizing sample stream\n");
frame=0;
// dump ahead in time to start of frame
#ifndef USRP_DEBUG
rxs = openair0.trx_read_func(&openair0,
&timestamp,
......@@ -2941,7 +2940,6 @@ void init_UE_threads(void) {
}
void fill_ue_band_info() {
UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability;
......@@ -2969,7 +2967,6 @@ void fill_ue_band_info() {
}
}
}
static void get_options (int argc, char **argv) {
int c;
// char line[1000];
......@@ -2988,7 +2985,6 @@ static void get_options (int argc, char **argv) {
const Enb_properties_array_t *enb_properties;
enum long_option_e {
......@@ -3309,7 +3305,7 @@ int main(int argc, char **argv) {
// int *eNB_thread_status_rx[10],*eNB_thread_status_tx[10];
#endif
int i,aa,card;
#if defined (XFORMS) || defined (EMOS) || defined(EXMIMO)
#if defined (XFORMS) || defined (EMOS) || defined (EXMIMO)
void *status;
#endif
......@@ -3334,7 +3330,6 @@ int main(int argc, char **argv) {
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
set_latency_target();
mode = normal_txrx;
......@@ -3799,7 +3794,6 @@ int main(int argc, char **argv) {
}
printf("ITTI tasks created\n");
#endif
printf("Filling UE band info\n");
if (UE_flag==1)
fill_ue_band_info();
......
......@@ -846,6 +846,29 @@ compile_unisim() {
return 1
fi
}
compile_nas_tools() {
export NVRAM_DIR=$OPENAIR_TARGETS/bin
cd $NVRAM_DIR
if [ ! -f /tmp/nas_cleaned ]; then
echo_success "make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS/tools veryveryclean"
make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS/tools veryveryclean
fi
echo_success "make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS/tools all"
make --directory=$OPENAIRCN_DIR/NAS/EURECOM-NAS/tools all
rm .ue.nvram
rm .usim.nvram
touch /tmp/nas_cleaned
}
compile_ue_ip_nw_driver() {
cd $OPENAIR2_DIR && make ue_ip.ko
}
################################################
# 1. check if the executable functions exist
###############################################
......@@ -935,10 +958,20 @@ check_for_mbmssim_executable() {
fi
}
check_for_nas_ue_executable() {
if [ ! -f $OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/UserProcess ]; then
echo_error "Cannot find UserProcess executable object in directory $OPENAIRCN_DIR/NAS/EURECOM-NAS/bin"
echo_fatal "Check the compilation logs in bin/install_log.txt"
fi
}
################################################
# 1. check if the executable functions exist
###############################################
# arg1 is RT
# arg2 is HW
# arg3 is ENB_S1
install_ltesoftmodem() {
# RT
if [ $1 = "RTAI" ]; then
......@@ -986,12 +1019,32 @@ install_ltesoftmodem() {
}
# arg1 is ENB_S1 'boolean'
install_oaisim() {
if [ $1 = 0 ]; then
cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1
cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make # || exit 1
else
compile_ue_ip_nw_driver
install_nas_tools
fi
}
install_nas_tools() {
cd $OPENAIR_TARGETS/bin
if [ ! -f .ue.nvram ]; then
echo_success "generate .ue_emm.nvram .ue.nvram"
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data --gen
fi
if [ ! -f .usim.nvram ]; then
echo_success "generate .usim.nvram"
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data --gen
fi
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data --print
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data --print
}
##################################
......
......@@ -473,6 +473,12 @@ build_enb(){
check_for_oaisim_executable
echo_info "7.2 finished oaisim target: check the installation log file bin/install_log.txt"
if [ $ENB_S1 -eq 1 ]; then
compile_nas_tools 2>&1
nas_tools_compiled=$?
check_for_nas_tools_executable
echo_info "7.2.1 finished nas ue target: check the installation log file bin/install_log.txt"
fi
fi
if [ $TARGET = "UNISIM" ]; then
echo "################## compile_unisim ##################" >> bin/install_log.txt
......@@ -800,6 +806,39 @@ if [ $RUN -ne 0 ]; then
$SUDO echo "run" >> ~/.gdb_lte_softmodem
$SUDO gdb -nh -x ~/.gdb_lte_softmodem 2>&1
fi
elif [ $TARGET == "OAISIM" ]; then
if [ $ENB_S1 -eq 0 ]; then
echo_error "TODO: LOAD NASMESH IP DRIVER FOR UE AND eNB"
else
# prepare NAS for UE
if [ ! -f .ue.nvram ]; then
echo_success "generate .ue_emm.nvram .ue.nvram"
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data --gen
fi
if [ ! -f .usim.nvram ]; then
echo_success "generate .usim.nvram"
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data --gen
fi
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/ue_data --print
$OPENAIRCN_DIR/NAS/EURECOM-NAS/bin/usim_data --print
insmod $OPENAIR2_DIR/NETWORK_DRIVER/UE_IP/ue_ip.ko
fi
if [ $RUN_GDB -eq 0 ]; then
$SUDO exec $OPENAIR_TARGETS/bin/oaisim `echo $EXE_ARGUMENTS`
else
$SUDO setenv MALLOC_CHECK_ 2
$SUDO touch ~/.gdb_oaisim
$SUDO echo "file $OPENAIR_TARGETS/bin/lte-oaisim" > ~/.gdb_oaisim
$SUDO echo "set args $EXE_ARGUMENTS" >> ~/.gdb_oaisim
$SUDO echo "run" >> ~/.gdb_oaisim
$SUDO gdb -nh -x ~/.gdb_oaisim 2>&1
fi
fi
;;
......
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