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) ...@@ -37,7 +37,7 @@ export PROJDIR = $(CURDIR)
all: all:
ifeq ($(PROCESS), UE) ifeq ($(PROCESS), UE)
@$(CD) $(SECUDIR) && $(MAKE) @$(CD) $(SECUDIR) && $(MAKE) -f Makefile.NAS
endif endif
@$(CD) $(UTILDIR) && $(MAKE) @$(CD) $(UTILDIR) && $(MAKE)
@$(CD) $(APIDIR) && $(MAKE) @$(CD) $(APIDIR) && $(MAKE)
......
...@@ -34,13 +34,14 @@ endif ...@@ -34,13 +34,14 @@ endif
include $(PROJDIR)/Makerules include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc include $(PROJDIR)/Makefile.inc
include $(PROJDIR)/../Makefile.tools
export LD_RUN_PATH = $(LIBDIR):$(LIBPROCESS) 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) 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 USIM_OBJ = usim_data.o
UE_OBJ = ue_data.o UE_OBJ = ue_data.o
...@@ -57,13 +58,13 @@ all: $(TARGETS) ...@@ -57,13 +58,13 @@ all: $(TARGETS)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
$(USIM_TARGET): $(USIM_OBJ) $(LIBSUTIL) $(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) @echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@ @$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR) @$(CP) $@ $(BINDIR)
$(UE_TARGET): $(UE_OBJ) $(LIBSUTIL) $(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) @echo Replacing $@ to $(BINDIR)
@$(RM) $(BINDIR)/$@ @$(RM) $(BINDIR)/$@
@$(CP) $@ $(BINDIR) @$(CP) $@ $(BINDIR)
...@@ -74,6 +75,10 @@ clean: ...@@ -74,6 +75,10 @@ clean:
veryclean: clean veryclean: clean
$(RM) $(TARGETS) $(RM) $(TARGETS)
veryveryclean: veryclean
$(RM) -Rf *.o $(PROJDIR)
$(RM) -Rf *.a $(PROJDIR)
depend: depend:
makedepend -- ${CFLAGS} -- ${SRCS} makedepend -- ${CFLAGS} -- ${SRCS}
......
...@@ -53,8 +53,7 @@ Description Implements the utility used to generate data stored in the ...@@ -53,8 +53,7 @@ Description Implements the utility used to generate data stored in the
#include <stdlib.h> // exit, free #include <stdlib.h> // exit, free
#include <string.h> // memset, strncpy #include <string.h> // memset, strncpy
//#define SELECTED_PLMN SFR1 #define SELECTED_PLMN SFR1
#define SELECTED_PLMN FCT1
/****************************************************************************/ /****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/ /**************** 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) ...@@ -290,7 +289,7 @@ static void _gen_user_data(user_nvdata_t* data)
static void _gen_emm_data(emm_nvdata_t* data) static void _gen_emm_data(emm_nvdata_t* data)
{ {
//#if (SELECTED_PLMN == FCT1) //#if (SELECTED_PLMN == FCT1)
#if 1 #if 0
/* /*
* International Mobile Subscriber Identity * International Mobile Subscriber Identity
* IMSI = MCC + MNC + MSIN = 310 (USA) + 028 (UNKNOWN) + 90832150 * IMSI = MCC + MNC + MSIN = 310 (USA) + 028 (UNKNOWN) + 90832150
......
/******************************************************************************* /*******************************************************************************
OpenAirInterface OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful, OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not, included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>. see <http://www.gnu.org/licenses/>.
Contact Information Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
*******************************************************************************/ *******************************************************************************/
/***************************************************************************** /*****************************************************************************
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 USIM application
*****************************************************************************/ *****************************************************************************/
#include "network.h" #include "network.h"
...@@ -53,8 +53,7 @@ Description Implements the utility used to generate data stored in the ...@@ -53,8 +53,7 @@ Description Implements the utility used to generate data stored in the
#include <stdlib.h> // exit #include <stdlib.h> // exit
#include <string.h> // memset, memcpy, strncpy #include <string.h> // memset, memcpy, strncpy
//#define SELECTED_PLMN SFR1 #define SELECTED_PLMN SFR1
#define SELECTED_PLMN FCT1
/****************************************************************************/ /****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/
...@@ -82,12 +81,12 @@ Description Implements the utility used to generate data stored in the ...@@ -82,12 +81,12 @@ Description Implements the utility used to generate data stored in the
#define PRINT_PLMN_DIGIT(d) if ((d) != 0xf) printf("%u", (d)) #define PRINT_PLMN_DIGIT(d) if ((d) != 0xf) printf("%u", (d))
#define PRINT_PLMN(plmn) \ #define PRINT_PLMN(plmn) \
PRINT_PLMN_DIGIT((plmn).MCCdigit1); \ PRINT_PLMN_DIGIT((plmn).MCCdigit1); \
PRINT_PLMN_DIGIT((plmn).MCCdigit2); \ PRINT_PLMN_DIGIT((plmn).MCCdigit2); \
PRINT_PLMN_DIGIT((plmn).MCCdigit3); \ PRINT_PLMN_DIGIT((plmn).MCCdigit3); \
PRINT_PLMN_DIGIT((plmn).MNCdigit1); \ PRINT_PLMN_DIGIT((plmn).MNCdigit1); \
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \ PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3) PRINT_PLMN_DIGIT((plmn).MNCdigit3)
/****************************************************************************/ /****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/ /******************* L O C A L D E F I N I T I O N S *******************/
...@@ -103,323 +102,330 @@ static void _display_usim_data(const usim_data_t* data); ...@@ -103,323 +102,330 @@ static void _display_usim_data(const usim_data_t* data);
int main (int argc, const char* argv[]) int main (int argc, const char* argv[])
{ {
int rc; int rc;
usim_data_t usim_data; usim_data_t usim_data;
int i;
unsigned char gen_data;
unsigned char gen_data;
/*
* Read command line parameters
*/
if (argc != 2) {
fprintf(stderr, "Invalid parameter\n");
_display_usage(argv[0]);
exit(EXIT_FAILURE);
}
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) ) {
/* Display content of USIM data files */
gen_data = FALSE;
}
else {
/* Display usage */
_display_usage(argv[0]);
exit(EXIT_SUCCESS);
}
if (gen_data)
{
/* /*
* Initialize USIM data * Read command line parameters
*/ */
memset(&usim_data, 0, sizeof(usim_data_t)); if (argc != 2) {
fprintf(stderr, "Invalid parameter\n");
_display_usage(argv[0]);
exit(EXIT_FAILURE);
} 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)) {
/* Display content of USIM data files */
gen_data = FALSE;
} else {
/* Display usage */
_display_usage(argv[0]);
exit(EXIT_SUCCESS);
}
//#if (SELECTED_PLMN == FCT1) if (gen_data) {
#if 1 /*
/* * Initialize USIM data
* International Mobile Subscriber Identity */
* IMSI = MCC + MNC + MSIN = 310 (USA) + 028 (UNKNOWN) + 90832150 memset(&usim_data, 0, sizeof(usim_data_t));
*/
//#if (SELECTED_PLMN == FCT1)
#if 0
/*
* International Mobile Subscriber Identity
* IMSI = MCC + MNC + MSIN = 310 (USA) + 028 (UNKNOWN) + 90832150
*/
#warning "IMSI 310.028.90832150" #warning "IMSI 310.028.90832150"
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.parity = EVEN_PARITY; // Parity: even
usim_data.imsi.u.num.digit1 = 3; // MCC digit 1 usim_data.imsi.u.num.digit1 = 3; // MCC digit 1
usim_data.imsi.u.num.digit2 = 1; // MCC digit 2 usim_data.imsi.u.num.digit2 = 1; // MCC digit 2
usim_data.imsi.u.num.digit3 = 0; // MCC digit 3 usim_data.imsi.u.num.digit3 = 0; // MCC digit 3
usim_data.imsi.u.num.digit4 = 0; // MNC digit 1 usim_data.imsi.u.num.digit4 = 0; // MNC digit 1
usim_data.imsi.u.num.digit5 = 2; // MNC digit 2 usim_data.imsi.u.num.digit5 = 2; // MNC digit 2
usim_data.imsi.u.num.digit6 = 8; // MNC digit 3 usim_data.imsi.u.num.digit6 = 8; // MNC digit 3
usim_data.imsi.u.num.digit7 = 9; usim_data.imsi.u.num.digit7 = 9;
usim_data.imsi.u.num.digit8 = 0; usim_data.imsi.u.num.digit8 = 0;
usim_data.imsi.u.num.digit9 = 8; usim_data.imsi.u.num.digit9 = 8;
usim_data.imsi.u.num.digit10 = 3; usim_data.imsi.u.num.digit10 = 3;
usim_data.imsi.u.num.digit11 = 2; usim_data.imsi.u.num.digit11 = 2;
usim_data.imsi.u.num.digit12 = 1; usim_data.imsi.u.num.digit12 = 1;
usim_data.imsi.u.num.digit13 = 5; usim_data.imsi.u.num.digit13 = 5;
usim_data.imsi.u.num.digit14 = 0; usim_data.imsi.u.num.digit14 = 0;
usim_data.imsi.u.num.digit15 = 0b1111; usim_data.imsi.u.num.digit15 = 0b1111;
#else #else
/* /*
* International Mobile Subscriber Identity * International Mobile Subscriber Identity
* IMSI = MCC + MNC + MSIN = 208 (France) + 10 (SFR) + 00001234 * IMSI = MCC + MNC + MSIN = 208 (France) + 10 (SFR) + 00001234
*/ */
#warning "IMSI 208.10.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.parity = EVEN_PARITY; // Parity: even
usim_data.imsi.u.num.digit1 = 2; // MCC digit 1 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.digit2 = 0; // MCC digit 2
usim_data.imsi.u.num.digit3 = 8; // MCC digit 3 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.digit4 = 1; // MNC digit 1
usim_data.imsi.u.num.digit5 = 0; // MNC digit 2 usim_data.imsi.u.num.digit5 = 0; // MNC digit 2
usim_data.imsi.u.num.digit6 = 0b1111; // MNC digit 3 usim_data.imsi.u.num.digit6 = 0b1111; // MNC digit 3
usim_data.imsi.u.num.digit7 = 0; usim_data.imsi.u.num.digit7 = 0;
usim_data.imsi.u.num.digit8 = 0; usim_data.imsi.u.num.digit8 = 0;
usim_data.imsi.u.num.digit9 = 0; usim_data.imsi.u.num.digit9 = 0;
usim_data.imsi.u.num.digit10 = 0; usim_data.imsi.u.num.digit10 = 0;
usim_data.imsi.u.num.digit11 = 1; usim_data.imsi.u.num.digit11 = 1;
usim_data.imsi.u.num.digit12 = 2; usim_data.imsi.u.num.digit12 = 2;
usim_data.imsi.u.num.digit13 = 3; usim_data.imsi.u.num.digit13 = 3;
usim_data.imsi.u.num.digit14 = 4; usim_data.imsi.u.num.digit14 = 4;
usim_data.imsi.u.num.digit15 = 0b1111;*/ usim_data.imsi.u.num.digit15 = 0b1111;*/
usim_data.imsi.length = 8; usim_data.imsi.length = 8;
usim_data.imsi.u.num.parity = 0x0; // Type of identity = IMSI, even 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.digit1 = 2;// MCC digit 1
usim_data.imsi.u.num.digit2 = 0; // MCC digit 2 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.digit3 = 8;// MCC digit 3
usim_data.imsi.u.num.digit4 = 1; // MNC digit 1 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.digit5 = 0;// MNC digit 2
usim_data.imsi.u.num.digit6 = 0; usim_data.imsi.u.num.digit6 = 0;
usim_data.imsi.u.num.digit7 = 0; usim_data.imsi.u.num.digit7 = 0;
usim_data.imsi.u.num.digit8 = 0; usim_data.imsi.u.num.digit8 = 0;
usim_data.imsi.u.num.digit9 = 0; usim_data.imsi.u.num.digit9 = 0;
usim_data.imsi.u.num.digit10 = 0; usim_data.imsi.u.num.digit10 = 0;
usim_data.imsi.u.num.digit11 = 1; usim_data.imsi.u.num.digit11 = 1;
usim_data.imsi.u.num.digit12 = 2; usim_data.imsi.u.num.digit12 = 2;
usim_data.imsi.u.num.digit13 = 3; usim_data.imsi.u.num.digit13 = 3;
usim_data.imsi.u.num.digit14 = 4; usim_data.imsi.u.num.digit14 = 4;
usim_data.imsi.u.num.digit15 = 0xF; usim_data.imsi.u.num.digit15 = 0xF;
#endif #endif
/* /*
* Ciphering and Integrity Keys * Ciphering and Integrity Keys
*/ */
usim_data.keys.ksi = KSI; usim_data.keys.ksi = KSI;
memset(&usim_data.keys.ck, 0, USIM_CK_SIZE); memset(&usim_data.keys.ck, 0, USIM_CK_SIZE);
memset(&usim_data.keys.ik, 0, USIM_IK_SIZE); memset(&usim_data.keys.ik, 0, USIM_IK_SIZE);
/* /*
* Higher Priority PLMN search period * Higher Priority PLMN search period
*/ */
usim_data.hpplmn = 0x00; /* Disable timer */ usim_data.hpplmn = 0x00; /* Disable timer */
/* /*
* List of Forbidden PLMNs * 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)); memset(&usim_data.fplmn[i], 0xff, sizeof(plmn_t));
} }
/* /*
* Location Information * Location Information
*/ */
usim_data.loci.tmsi = DEFAULT_TMSI; usim_data.loci.tmsi = DEFAULT_TMSI;
usim_data.loci.lai.plmn = network_records[SELECTED_PLMN].plmn; usim_data.loci.lai.plmn = network_records[SELECTED_PLMN].plmn;
usim_data.loci.lai.lac = DEFAULT_LAC; usim_data.loci.lai.lac = DEFAULT_LAC;
usim_data.loci.status = USIM_LOCI_NOT_UPDATED; usim_data.loci.status = USIM_LOCI_NOT_UPDATED;
/* /*
* Packet Switched Location Information * Packet Switched Location Information
*/ */
usim_data.psloci.p_tmsi = DEFAULT_P_TMSI; usim_data.psloci.p_tmsi = DEFAULT_P_TMSI;
usim_data.psloci.signature[0] = 0x01; usim_data.psloci.signature[0] = 0x01;
usim_data.psloci.signature[1] = 0x02; usim_data.psloci.signature[1] = 0x02;
usim_data.psloci.signature[2] = 0x03; usim_data.psloci.signature[2] = 0x03;
usim_data.psloci.rai.plmn = network_records[SELECTED_PLMN].plmn; usim_data.psloci.rai.plmn = network_records[SELECTED_PLMN].plmn;
usim_data.psloci.rai.lac = DEFAULT_LAC; usim_data.psloci.rai.lac = DEFAULT_LAC;
usim_data.psloci.rai.rac = DEFAULT_RAC; usim_data.psloci.rai.rac = DEFAULT_RAC;
usim_data.psloci.status = USIM_PSLOCI_NOT_UPDATED; usim_data.psloci.status = USIM_PSLOCI_NOT_UPDATED;
/* /*
* Administrative Data * Administrative Data
*/ */
usim_data.ad.UE_Operation_Mode = USIM_NORMAL_MODE; usim_data.ad.UE_Operation_Mode = USIM_NORMAL_MODE;
usim_data.ad.Additional_Info = 0xffff; usim_data.ad.Additional_Info = 0xffff;
usim_data.ad.MNC_Length = 2; usim_data.ad.MNC_Length = 2;
/* /*
* EPS NAS security context * EPS NAS security context
*/ */
usim_data.securityctx.length = 52; usim_data.securityctx.length = 52;
usim_data.securityctx.KSIasme.type = USIM_KSI_ASME_TAG; usim_data.securityctx.KSIasme.type = USIM_KSI_ASME_TAG;
usim_data.securityctx.KSIasme.length = 1; usim_data.securityctx.KSIasme.length = 1;
usim_data.securityctx.KSIasme.value[0] = KSI_ASME; usim_data.securityctx.KSIasme.value[0] = KSI_ASME;
usim_data.securityctx.Kasme.type = USIM_K_ASME_TAG; usim_data.securityctx.Kasme.type = USIM_K_ASME_TAG;
usim_data.securityctx.Kasme.length = USIM_K_ASME_SIZE; usim_data.securityctx.Kasme.length = USIM_K_ASME_SIZE;
memset(usim_data.securityctx.Kasme.value, 0, memset(usim_data.securityctx.Kasme.value, 0,
usim_data.securityctx.Kasme.length); usim_data.securityctx.Kasme.length);
usim_data.securityctx.ulNAScount.type = USIM_UL_NAS_COUNT_TAG; usim_data.securityctx.ulNAScount.type = USIM_UL_NAS_COUNT_TAG;
usim_data.securityctx.ulNAScount.length = USIM_UL_NAS_COUNT_SIZE; usim_data.securityctx.ulNAScount.length = USIM_UL_NAS_COUNT_SIZE;
memset(usim_data.securityctx.ulNAScount.value, 0, memset(usim_data.securityctx.ulNAScount.value, 0,
usim_data.securityctx.ulNAScount.length); usim_data.securityctx.ulNAScount.length);
usim_data.securityctx.dlNAScount.type = USIM_DL_NAS_COUNT_TAG; usim_data.securityctx.dlNAScount.type = USIM_DL_NAS_COUNT_TAG;
usim_data.securityctx.dlNAScount.length = USIM_DL_NAS_COUNT_SIZE; usim_data.securityctx.dlNAScount.length = USIM_DL_NAS_COUNT_SIZE;
memset(usim_data.securityctx.dlNAScount.value, 0, memset(usim_data.securityctx.dlNAScount.value, 0,
usim_data.securityctx.dlNAScount.length); usim_data.securityctx.dlNAScount.length);
usim_data.securityctx.algorithmID.type = USIM_INT_ENC_ALGORITHMS_TAG; usim_data.securityctx.algorithmID.type = USIM_INT_ENC_ALGORITHMS_TAG;
usim_data.securityctx.algorithmID.length = 1; usim_data.securityctx.algorithmID.length = 1;
usim_data.securityctx.algorithmID.value[0] = SECURITY_ALGORITHMS; usim_data.securityctx.algorithmID.value[0] = SECURITY_ALGORITHMS;
/* /*
* Subcriber's Number * Subcriber's Number
*/ */
usim_data.msisdn.length = 7; usim_data.msisdn.length = 7;
usim_data.msisdn.number.ext = 1; usim_data.msisdn.number.ext = 1;
usim_data.msisdn.number.ton = MSISDN_TON_UNKNOWKN; usim_data.msisdn.number.ton = MSISDN_TON_UNKNOWKN;
usim_data.msisdn.number.npi = MSISDN_NPI_ISDN_TELEPHONY; usim_data.msisdn.number.npi = MSISDN_NPI_ISDN_TELEPHONY;
usim_data.msisdn.number.digit[0].msb = 3; usim_data.msisdn.number.digit[0].msb = 3;
usim_data.msisdn.number.digit[0].lsb = 3; usim_data.msisdn.number.digit[0].lsb = 3;
usim_data.msisdn.number.digit[1].msb = 6; usim_data.msisdn.number.digit[1].msb = 6;
usim_data.msisdn.number.digit[1].lsb = 1; usim_data.msisdn.number.digit[1].lsb = 1;
usim_data.msisdn.number.digit[2].msb = 1; usim_data.msisdn.number.digit[2].msb = 1;
usim_data.msisdn.number.digit[2].lsb = 1; usim_data.msisdn.number.digit[2].lsb = 1;
usim_data.msisdn.number.digit[3].msb = 2; usim_data.msisdn.number.digit[3].msb = 2;
usim_data.msisdn.number.digit[3].lsb = 3; usim_data.msisdn.number.digit[3].lsb = 3;
usim_data.msisdn.number.digit[4].msb = 4; usim_data.msisdn.number.digit[4].msb = 4;
usim_data.msisdn.number.digit[4].lsb = 5; usim_data.msisdn.number.digit[4].lsb = 5;
usim_data.msisdn.number.digit[5].msb = 6; usim_data.msisdn.number.digit[5].msb = 6;
usim_data.msisdn.number.digit[5].lsb = 0xf; usim_data.msisdn.number.digit[5].lsb = 0xf;
usim_data.msisdn.number.digit[6].msb = 0xf; usim_data.msisdn.number.digit[6].msb = 0xf;
usim_data.msisdn.number.digit[6].lsb = 0xf; usim_data.msisdn.number.digit[6].lsb = 0xf;
usim_data.msisdn.number.digit[7].msb = 0xf; usim_data.msisdn.number.digit[7].msb = 0xf;
usim_data.msisdn.number.digit[7].lsb = 0xf; usim_data.msisdn.number.digit[7].lsb = 0xf;
usim_data.msisdn.number.digit[8].msb = 0xf; usim_data.msisdn.number.digit[8].msb = 0xf;
usim_data.msisdn.number.digit[8].lsb = 0xf; usim_data.msisdn.number.digit[8].lsb = 0xf;
usim_data.msisdn.number.digit[9].msb = 0xf; usim_data.msisdn.number.digit[9].msb = 0xf;
usim_data.msisdn.number.digit[9].lsb = 0xf; usim_data.msisdn.number.digit[9].lsb = 0xf;
usim_data.msisdn.conf1_record_id = 0xff; /* Not used */ usim_data.msisdn.conf1_record_id = 0xff; /* Not used */
usim_data.msisdn.ext1_record_id = 0xff; /* Not used */ usim_data.msisdn.ext1_record_id = 0xff; /* Not used */
/* /*
* PLMN Network Name and Operator PLMN List * 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]; network_record_t record = network_records[i];
usim_data.pnn[i].fullname.type = USIM_PNN_FULLNAME_TAG; usim_data.pnn[i].fullname.type = USIM_PNN_FULLNAME_TAG;
usim_data.pnn[i].fullname.length = strlen(record.fullname); 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].fullname.length);
usim_data.pnn[i].shortname.type = USIM_PNN_SHORTNAME_TAG; usim_data.pnn[i].shortname.type = USIM_PNN_SHORTNAME_TAG;
usim_data.pnn[i].shortname.length = strlen(record.shortname); 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.pnn[i].shortname.length);
usim_data.opl[i].plmn = record.plmn; usim_data.opl[i].plmn = record.plmn;
usim_data.opl[i].start = record.tac_start; usim_data.opl[i].start = record.tac_start;
usim_data.opl[i].end = record.tac_end; usim_data.opl[i].end = record.tac_end;
usim_data.opl[i].record_id = i; 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)); memset(&usim_data.opl[i].plmn, 0xff, sizeof(plmn_t));
}
/*
* List of Equivalent HPLMNs
*/
usim_data.ehplmn[0] = network_records[SFR2].plmn;
usim_data.ehplmn[1] = network_records[SFR3].plmn;
/*
* Home PLMN Selector with Access Technology
*/
usim_data.hplmn.plmn = network_records[SELECTED_PLMN].plmn;
usim_data.hplmn.AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN);
/*
* List of user controlled PLMN selector with Access Technology
*/
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[1].plmn = network_records[VDF2].plmn;
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[3].plmn = network_records[VDF4].plmn;
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 (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.MMEgid = DEFAULT_MME_ID;
usim_data.epsloci.guti.gummei.MMEcode = DEFAULT_MME_CODE;
usim_data.epsloci.guti.m_tmsi = DEFAULT_M_TMSI;
usim_data.epsloci.tai.plmn = usim_data.epsloci.guti.gummei.plmn;
usim_data.epsloci.tai.tac = DEFAULT_TAC;
usim_data.epsloci.status = USIM_EPSLOCI_UPDATED;
/*
* Non-Access Stratum configuration
*/
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;
usim_data.nasconfig.NMO_I_Behaviour.length = 1;
usim_data.nasconfig.NMO_I_Behaviour.value[0] = 0x00;
usim_data.nasconfig.AttachWithImsi.type = USIM_ATTACH_WITH_IMSI_TAG;
usim_data.nasconfig.AttachWithImsi.length = 1;
#if defined(START_WITH_GUTI)
usim_data.nasconfig.AttachWithImsi.value[0] = 0x00;
#else
usim_data.nasconfig.AttachWithImsi.value[0] = 0x01;
#endif
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.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.length = 1;
usim_data.nasconfig.Timer_T3245_Behaviour.value[0] = 0x00;
/*
* Write USIM application data
*/
rc = usim_api_write(&usim_data);
if (rc != RETURNok) {
perror("ERROR\t: usim_api_write() failed");
exit(EXIT_FAILURE);
}
} }
/* /*
* List of Equivalent HPLMNs * Read USIM application data
*/
usim_data.ehplmn[0] = network_records[SFR2].plmn;
usim_data.ehplmn[1] = network_records[SFR3].plmn;
/*
* Home PLMN Selector with Access Technology
*/ */
usim_data.hplmn.plmn = network_records[SELECTED_PLMN].plmn; memset(&usim_data, 0, sizeof(usim_data_t));
usim_data.hplmn.AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN | USIM_ACT_EUTRAN); rc = usim_api_read(&usim_data);
/* if (rc != RETURNok) {
* List of user controlled PLMN selector with Access Technology perror("ERROR\t: usim_api_read() failed");
*/ exit(EXIT_FAILURE);
for (int 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[1].plmn = network_records[VDF2].plmn;
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[3].plmn = network_records[VDF4].plmn;
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++) {
memset(&usim_data.oplmn[i], 0xff, sizeof(plmn_t));
} }
/* /*
* EPS Location Information * Display USIM application data
*/
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;
usim_data.epsloci.tai.plmn = usim_data.epsloci.guti.gummei.plmn;
usim_data.epsloci.tai.tac = DEFAULT_TAC;
usim_data.epsloci.status = USIM_EPSLOCI_UPDATED;
/*
* Non-Access Stratum configuration
*/ */
usim_data.nasconfig.NAS_SignallingPriority.type = USIM_NAS_SIGNALLING_PRIORITY_TAG; printf("\nUSIM data:\n\n");
usim_data.nasconfig.NAS_SignallingPriority.length = 1; _display_usim_data(&usim_data);
usim_data.nasconfig.NAS_SignallingPriority.value[0] = 0x00;
usim_data.nasconfig.NMO_I_Behaviour.type = USIM_NMO_I_BEHAVIOUR_TAG;
usim_data.nasconfig.NMO_I_Behaviour.length = 1;
usim_data.nasconfig.NMO_I_Behaviour.value[0] = 0x00;
usim_data.nasconfig.AttachWithImsi.type = USIM_ATTACH_WITH_IMSI_TAG;
usim_data.nasconfig.AttachWithImsi.length = 1;
#if defined(START_WITH_GUTI)
usim_data.nasconfig.AttachWithImsi.value[0] = 0x00;
#else
usim_data.nasconfig.AttachWithImsi.value[0] = 0x01;
#endif
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.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.length = 1;
usim_data.nasconfig.Timer_T3245_Behaviour.value[0] = 0x00;
/* /*
* Write USIM application data * Display USIM file location
*/ */
rc = usim_api_write(&usim_data); char* path = memory_get_path("USIM_DIR", ".usim.nvram");
if (rc != RETURNok) { printf("\nUSIM data file: %s\n", path);
perror("ERROR\t: usim_api_write() failed"); free(path);
exit(EXIT_FAILURE);
} exit(EXIT_SUCCESS);
}
/*
* Read USIM application data
*/
memset(&usim_data, 0, sizeof(usim_data_t));
rc = usim_api_read(&usim_data);
if (rc != RETURNok) {
perror("ERROR\t: usim_api_read() failed");
exit(EXIT_FAILURE);
}
/*
* Display USIM application data
*/
printf("\nUSIM data:\n\n");
_display_usim_data(&usim_data);
/*
* Display USIM file location
*/
char* path = memory_get_path("USIM_DIR", ".usim.nvram");
printf("\nUSIM data file: %s\n", path);
free(path);
exit(EXIT_SUCCESS);
} }
/****************************************************************************/ /****************************************************************************/
...@@ -429,182 +435,181 @@ int main (int argc, const char* argv[]) ...@@ -429,182 +435,181 @@ int main (int argc, const char* argv[])
/* /*
* Displays command line usage * 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, "usage: %s [OPTION]\n", command); fprintf(stderr, "\t[--gen|-g]\tGenerate the USIM data file\n");
fprintf(stderr, "\t[--gen|-g]\tGenerate the USIM data file\n"); fprintf(stderr,
fprintf(stderr, "\t[--print|-p]\tDisplay the content of the USIM data file\n"); "\t[--print|-p]\tDisplay the content of the USIM data file\n");
fprintf(stderr, "\t[--help|-h]\tDisplay this usage\n"); fprintf(stderr, "\t[--help|-h]\tDisplay this usage\n");
const char* path = getenv("USIM_DIR"); const char* path = getenv("USIM_DIR");
if (path != NULL) { if (path != NULL) {
fprintf(stderr, "USIM_DIR = %s\n", path); fprintf(stderr, "USIM_DIR = %s\n", path);
} } else {
else { fprintf(stderr, "USIM_DIR environment variable is not defined\n");
fprintf(stderr, "USIM_DIR environment variable is not defined\n"); }
}
} }
/* /*
* Displays USIM application data * 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 digits; int i;
printf("Administrative Data:\n"); printf("Administrative Data:\n");
printf("\tUE_Operation_Mode\t= 0x%.2x\n", data->ad.UE_Operation_Mode); printf("\tUE_Operation_Mode\t= 0x%.2x\n", data->ad.UE_Operation_Mode);
printf("\tAdditional_Info\t\t= 0x%.4x\n", data->ad.Additional_Info); printf("\tAdditional_Info\t\t= 0x%.4x\n", data->ad.Additional_Info);
printf("\tMNC_Length\t\t= %d\n\n", data->ad.MNC_Length); printf("\tMNC_Length\t\t= %d\n\n", data->ad.MNC_Length);
printf("IMSI:\n"); printf("IMSI:\n");
printf("\tlength\t= %d\n", data->imsi.length); printf("\tlength\t= %d\n", data->imsi.length);
printf("\tparity\t= %s\n", data->imsi.u.num.parity == EVEN_PARITY ? "Even" : "Odd"); printf("\tparity\t= %s\n",
digits = (data->imsi.length * 2) - 1 - (data->imsi.u.num.parity == EVEN_PARITY ? 1 : 0); data->imsi.u.num.parity == EVEN_PARITY ? "Even" : "Odd");
printf("\tdigits\t= %d\n", digits); digits = (data->imsi.length * 2) - 1
printf("\tdigits\t= %u%u%u%u%u%x%u%u%u%u", - (data->imsi.u.num.parity == EVEN_PARITY ? 1 : 0);
data->imsi.u.num.digit1, // MCC digit 1 printf("\tdigits\t= %d\n", digits);
data->imsi.u.num.digit2, // MCC digit 2 printf("\tdigits\t= %u%u%u%u%u%x%u%u%u%u",
data->imsi.u.num.digit3, // MCC digit 3 data->imsi.u.num.digit1, // MCC digit 1
data->imsi.u.num.digit4, // MNC digit 1 data->imsi.u.num.digit2, // MCC digit 2
data->imsi.u.num.digit5, // MNC digit 2 data->imsi.u.num.digit3, // MCC digit 3
data->imsi.u.num.digit6, // MNC digit 3 data->imsi.u.num.digit4, // MNC digit 1
data->imsi.u.num.digit7, data->imsi.u.num.digit5, // MNC digit 2
data->imsi.u.num.digit8, data->imsi.u.num.digit6, // MNC digit 3
data->imsi.u.num.digit9, data->imsi.u.num.digit7, data->imsi.u.num.digit8,
data->imsi.u.num.digit10); data->imsi.u.num.digit9, data->imsi.u.num.digit10);
if (digits >= 11) if (digits >= 11)
printf("%x", data->imsi.u.num.digit11); printf("%x", data->imsi.u.num.digit11);
if (digits >= 12) if (digits >= 12)
printf("%x", data->imsi.u.num.digit12); printf("%x", data->imsi.u.num.digit12);
if (digits >= 13) if (digits >= 13)
printf("%x", data->imsi.u.num.digit13); printf("%x", data->imsi.u.num.digit13);
if (digits >= 14) if (digits >= 14)
printf("%x", data->imsi.u.num.digit14); printf("%x", data->imsi.u.num.digit14);
if (digits >= 15) if (digits >= 15)
printf("%x", data->imsi.u.num.digit15); printf("%x", data->imsi.u.num.digit15);
printf("\n\n"); printf("\n\n");
printf("Ciphering and Integrity Keys:\n"); printf("Ciphering and Integrity Keys:\n");
printf("\tKSI\t: 0x%.2x\n", data->keys.ksi); 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'; key[USIM_CK_SIZE] = '\0';
memcpy(key, data->keys.ck, USIM_CK_SIZE); memcpy(key, data->keys.ck, USIM_CK_SIZE);
printf("\tCK\t: \"%s\"\n", key); printf("\tCK\t: \"%s\"\n", key);
memcpy(key, data->keys.ik, USIM_IK_SIZE); memcpy(key, data->keys.ik, USIM_IK_SIZE);
printf("\tIK\t: \"%s\"\n", key); printf("\tIK\t: \"%s\"\n", key);
printf("EPS NAS security context:\n"); printf("EPS NAS security context:\n");
printf("\tKSIasme\t: 0x%.2x\n", data->securityctx.KSIasme.value[0]); 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'; kasme[USIM_K_ASME_SIZE] = '\0';
memcpy(kasme, data->securityctx.Kasme.value, USIM_K_ASME_SIZE); memcpy(kasme, data->securityctx.Kasme.value, USIM_K_ASME_SIZE);
printf("\tKasme\t: \"%s\"\n", kasme); printf("\tKasme\t: \"%s\"\n", kasme);
printf("\tulNAScount\t: 0x%.8x\n", printf("\tulNAScount\t: 0x%.8x\n",
*(UInt32_t*)data->securityctx.ulNAScount.value); *(UInt32_t*) data->securityctx.ulNAScount.value);
printf("\tdlNAScount\t: 0x%.8x\n", 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", printf("\talgorithmID\t: 0x%.2x\n\n",
data->securityctx.algorithmID.value[0]); data->securityctx.algorithmID.value[0]);
printf("MSISDN\t= %u%u%u %u%u%u%u %u%u%u%u\n\n", 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].msb, data->msisdn.number.digit[0].lsb,
data->msisdn.number.digit[0].lsb, data->msisdn.number.digit[1].msb, data->msisdn.number.digit[1].lsb,
data->msisdn.number.digit[1].msb, data->msisdn.number.digit[2].msb, data->msisdn.number.digit[2].lsb,
data->msisdn.number.digit[1].lsb, data->msisdn.number.digit[3].msb, data->msisdn.number.digit[3].lsb,
data->msisdn.number.digit[2].msb, data->msisdn.number.digit[4].msb, data->msisdn.number.digit[4].lsb,
data->msisdn.number.digit[2].lsb, data->msisdn.number.digit[5].msb);
data->msisdn.number.digit[3].msb,
data->msisdn.number.digit[3].lsb, for (i = 0; i < USIM_PNN_MAX; i++) {
data->msisdn.number.digit[4].msb, printf("PNN[%d]\t= {%s, %s}\n", i, data->pnn[i].fullname.value,
data->msisdn.number.digit[4].lsb, data->pnn[i].shortname.value);
data->msisdn.number.digit[5].msb); }
printf("\n");
for (int i = 0; i < USIM_PNN_MAX; i++) {
printf("PNN[%d]\t= {%s, %s}\n", i, for (i = 0; i < USIM_OPL_MAX; i++) {
data->pnn[i].fullname.value, data->pnn[i].shortname.value); printf("OPL[%d]\t= ", i);
} PRINT_PLMN(data->opl[i].plmn);
printf("\n"); printf(", TAC = [%.4x - %.4x], record_id = %d\n", data->opl[i].start,
data->opl[i].end, data->opl[i].record_id);
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);
}
printf("\n");
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]);
printf("\n"); printf("\n");
}
printf("\n");
for (int i = 0; i < USIM_EHPLMN_MAX; i++) { printf("HPLMN\t\t= ");
printf("EHPLMN[%d]\t= ", i); PRINT_PLMN(data->ehplmn[i]); PRINT_PLMN(data->hplmn.plmn);
printf(", AcT = 0x%x\n\n", data->hplmn.AcT);
for (i = 0; i < USIM_FPLMN_MAX; i++) {
printf("FPLMN[%d]\t= ", i);
PRINT_PLMN(data->fplmn[i]);
printf("\n");
}
printf("\n");
for (i = 0; i < USIM_EHPLMN_MAX; i++) {
printf("EHPLMN[%d]\t= ", i);
PRINT_PLMN(data->ehplmn[i]);
printf("\n");
}
printf("\n"); printf("\n");
}
printf("\n");
for (int i = 0; i < USIM_PLMN_MAX; i++) { for (i = 0; i < USIM_PLMN_MAX; i++) {
printf("PLMN[%d]\t\t= ", i); PRINT_PLMN(data->plmn[i].plmn); printf("PLMN[%d]\t\t= ", i);
printf(", AcTPLMN = 0x%x", data->plmn[i].AcT); PRINT_PLMN(data->plmn[i].plmn);
printf(", AcTPLMN = 0x%x", data->plmn[i].AcT);
printf("\n");
}
printf("\n"); printf("\n");
}
printf("\n");
for (int i = 0; i < USIM_OPLMN_MAX; i++) { for (i = 0; i < USIM_OPLMN_MAX; i++) {
printf("OPLMN[%d]\t= ", i); PRINT_PLMN(data->oplmn[i].plmn); printf("OPLMN[%d]\t= ", i);
printf(", AcTPLMN = 0x%x", data->oplmn[i].AcT); PRINT_PLMN(data->oplmn[i].plmn);
printf(", AcTPLMN = 0x%x", data->oplmn[i].AcT);
printf("\n");
}
printf("\n"); printf("\n");
}
printf("\n"); printf("HPPLMN\t\t= 0x%.2x (%d minutes)\n\n", data->hpplmn, data->hpplmn);
printf("HPPLMN\t\t= 0x%.2x (%d minutes)\n\n", data->hpplmn, data->hpplmn); printf("LOCI:\n");
printf("\tTMSI = 0x%.4x\n", data->loci.tmsi);
printf("LOCI:\n"); printf("\tLAI\t: PLMN = ");
printf("\tTMSI = 0x%.4x\n", data->loci.tmsi); 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(", LAC = 0x%.2x\n", data->loci.lai.lac); printf("\tstatus\t= %d\n\n", data->loci.status);
printf("\tstatus\t= %d\n\n", data->loci.status);
printf("PSLOCI:\n");
printf("PSLOCI:\n"); printf("\tP-TMSI = 0x%.4x\n", data->psloci.p_tmsi);
printf("\tP-TMSI = 0x%.4x\n", data->psloci.p_tmsi); printf("\tsignature = 0x%x 0x%x 0x%x\n", data->psloci.signature[0],
printf("\tsignature = 0x%x 0x%x 0x%x\n", data->psloci.signature[1], data->psloci.signature[2]);
data->psloci.signature[0], printf("\tRAI\t: PLMN = ");
data->psloci.signature[1], PRINT_PLMN(data->psloci.rai.plmn);
data->psloci.signature[2]); printf(", LAC = 0x%.2x, RAC = 0x%.1x\n", data->psloci.rai.lac,
printf("\tRAI\t: PLMN = "); PRINT_PLMN(data->psloci.rai.plmn); data->psloci.rai.rac);
printf(", LAC = 0x%.2x, RAC = 0x%.1x\n", printf("\tstatus\t= %d\n\n", data->psloci.status);
data->psloci.rai.lac, data->psloci.rai.rac);
printf("\tstatus\t= %d\n\n", data->psloci.status); printf("EPSLOCI:\n");
printf("\tGUTI\t: GUMMEI\t: (PLMN = ");
printf("EPSLOCI:\n"); PRINT_PLMN(data->epsloci.guti.gummei.plmn);
printf("\tGUTI\t: GUMMEI\t: (PLMN = "); printf(", MMEgid = 0x%.2x, MMEcode = 0x%.1x)",
PRINT_PLMN(data->epsloci.guti.gummei.plmn); data->epsloci.guti.gummei.MMEgid,
printf(", MMEgid = 0x%.2x, MMEcode = 0x%.1x)", data->epsloci.guti.gummei.MMEcode);
data->epsloci.guti.gummei.MMEgid, printf(", M-TMSI = 0x%.4x\n", data->epsloci.guti.m_tmsi);
data->epsloci.guti.gummei.MMEcode); printf("\tTAI\t: PLMN = ");
printf(", M-TMSI = 0x%.4x\n", data->epsloci.guti.m_tmsi); PRINT_PLMN(data->epsloci.tai.plmn);
printf("\tTAI\t: PLMN = "); printf(", TAC = 0x%.2x\n", data->epsloci.tai.tac);
PRINT_PLMN(data->epsloci.tai.plmn); printf("\tstatus\t= %d\n\n", data->epsloci.status);
printf(", TAC = 0x%.2x\n",
data->epsloci.tai.tac); printf("NASCONFIG:\n");
printf("\tstatus\t= %d\n\n", data->epsloci.status); printf("\tNAS_SignallingPriority\t\t: 0x%.2x\n",
data->nasconfig.NAS_SignallingPriority.value[0]);
printf("NASCONFIG:\n"); printf("\tNMO_I_Behaviour\t\t\t: 0x%.2x\n",
printf("\tNAS_SignallingPriority\t\t: 0x%.2x\n", data->nasconfig.NMO_I_Behaviour.value[0]);
data->nasconfig.NAS_SignallingPriority.value[0]); printf("\tAttachWithImsi\t\t\t: 0x%.2x\n",
printf("\tNMO_I_Behaviour\t\t\t: 0x%.2x\n", data->nasconfig.AttachWithImsi.value[0]);
data->nasconfig.NMO_I_Behaviour.value[0]); printf("\tMinimumPeriodicSearchTimer\t: 0x%.2x\n",
printf("\tAttachWithImsi\t\t\t: 0x%.2x\n", data->nasconfig.MinimumPeriodicSearchTimer.value[0]);
data->nasconfig.AttachWithImsi.value[0]); printf("\tExtendedAccessBarring\t\t: 0x%.2x\n",
printf("\tMinimumPeriodicSearchTimer\t: 0x%.2x\n", data->nasconfig.ExtendedAccessBarring.value[0]);
data->nasconfig.MinimumPeriodicSearchTimer.value[0]); printf("\tTimer_T3245_Behaviour\t\t: 0x%.2x\n",
printf("\tExtendedAccessBarring\t\t: 0x%.2x\n", data->nasconfig.Timer_T3245_Behaviour.value[0]);
data->nasconfig.ExtendedAccessBarring.value[0]);
printf("\tTimer_T3245_Behaviour\t\t: 0x%.2x\n",
data->nasconfig.Timer_T3245_Behaviour.value[0]);
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
*******************************************************************************/ *******************************************************************************/
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include <gmp.h> #include <gmp.h>
#ifndef AUC_H_ #ifndef AUC_H_
......
...@@ -70,11 +70,21 @@ ...@@ -70,11 +70,21 @@
#define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE #define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE
#define MAX_NUM_RE (14*1200) #define MAX_NUM_RE (14*1200)
#if !defined(SI_RNTI)
#define SI_RNTI (rnti_t)0xffff #define SI_RNTI (rnti_t)0xffff
#endif
#if !defined(M_RNTI)
#define M_RNTI (rnti_t)0xfffd #define M_RNTI (rnti_t)0xfffd
#endif
#if !defined(P_RNTI)
#define P_RNTI (rnti_t)0xfffe #define P_RNTI (rnti_t)0xfffe
#endif
#if !defined(CBA_RNTI)
#define CBA_RNTI (rnti_t)0xfff4 #define CBA_RNTI (rnti_t)0xfff4
#endif
#if !defined(C_RNTI)
#define C_RNTI (rnti_t)0x1234 #define C_RNTI (rnti_t)0x1234
#endif
#define PMI_2A_11 0 #define PMI_2A_11 0
#define PMI_2A_1m1 1 #define PMI_2A_1m1 1
......
...@@ -159,7 +159,6 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg, ...@@ -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]); 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); void fill_ue_band_info(void);
#ifdef XFORMS #ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) // 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 // at eNB 0, an UL scope for every UE
...@@ -250,6 +249,7 @@ static uint32_t downlink_frequency[MAX_NUM_CCs][4];/* = {{19 ...@@ -250,6 +249,7 @@ static uint32_t downlink_frequency[MAX_NUM_CCs][4];/* = {{19
{1907600000,1907600000,1907600000,1907600000}};*/ {1907600000,1907600000,1907600000,1907600000}};*/
static int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; /*= {{0,0,0,0},{0,0,0,0}}; 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]; openair0_rf_map rf_map[MAX_NUM_CCs];
static char *conf_config_file_name = NULL; static char *conf_config_file_name = NULL;
...@@ -464,7 +464,6 @@ static const eutra_band_t eutra_bands[] = ...@@ -464,7 +464,6 @@ static const eutra_band_t eutra_bands[] =
{43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD}, {43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD},
{44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD}, {44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD},
}; };
unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) unsigned int build_rflocal(int txi, int txq, int rxi, int rxq)
{ {
return (txi + (txq<<6) + (rxi<<12) + (rxq<<18)); return (txi + (txq<<6) + (rxi<<12) + (rxq<<18));
...@@ -980,13 +979,13 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) { ...@@ -980,13 +979,13 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) {
#ifdef EXMIMO #ifdef EXMIMO
((short*)dummy_tx_b)[2*i]<<4; ((short*)dummy_tx_b)[2*i]<<4;
#else #else
((short*)dummy_tx_b)[2*i]<<5; ((short*)dummy_tx_b)[2*i]<<5;
#endif #endif
((short*)&phy_vars_eNB->lte_eNB_common_vars.txdata[0][aa][tx_offset])[1]= ((short*)&phy_vars_eNB->lte_eNB_common_vars.txdata[0][aa][tx_offset])[1]=
#ifdef EXMIMO #ifdef EXMIMO
((short*)dummy_tx_b)[2*i+1]<<4; ((short*)dummy_tx_b)[2*i+1]<<4;
#else #else
((short*)dummy_tx_b)[2*i+1]<<5; ((short*)dummy_tx_b)[2*i+1]<<5;
#endif #endif
} }
} }
...@@ -1021,15 +1020,15 @@ static void * eNB_thread_tx(void *param) { ...@@ -1021,15 +1020,15 @@ static void * eNB_thread_tx(void *param) {
task = rt_task_init_schmod(nam2num(task_name), 0, 0, 0, SCHED_FIFO, 0xF); task = rt_task_init_schmod(nam2num(task_name), 0, 0, 0, SCHED_FIFO, 0xF);
if (task==NULL) { if (task==NULL) {
LOG_E(PHY,"[SCHED][eNB] Problem starting eNB_proc_TX thread_index %d (%s)!!!!\n",proc->subframe,task_name); LOG_E(PHY,"[SCHED][eNB] Problem starting eNB_proc_TX thread_index %d (%s)!!!!\n",proc->subframe,task_name);
return 0; return 0;
} }
else { else {
LOG_I(PHY,"[SCHED][eNB] eNB TX thread CC %d SF %d started with id %p\n", LOG_I(PHY,"[SCHED][eNB] eNB TX thread CC %d SF %d started with id %p\n",
proc->CC_id, proc->CC_id,
proc->subframe, proc->subframe,
task); task);
} }
#else #else
#ifdef LOWLATENCY #ifdef LOWLATENCY
attr.size = sizeof(attr); attr.size = sizeof(attr);
...@@ -1044,14 +1043,14 @@ static void * eNB_thread_tx(void *param) { ...@@ -1044,14 +1043,14 @@ static void * eNB_thread_tx(void *param) {
attr.sched_period = 1 * 10000000; // each tx thread has a period of 10ms from the starting point attr.sched_period = 1 * 10000000; // each tx thread has a period of 10ms from the starting point
if (sched_setattr(0, &attr, flags) < 0 ){ if (sched_setattr(0, &attr, flags) < 0 ){
perror("[SCHED] eNB tx thread: sched_setattr failed\n"); perror("[SCHED] eNB tx thread: sched_setattr failed\n");
exit(-1); exit(-1);
} }
LOG_I(HW,"[SCHED] eNB TX deadline thread %d(id %ld) started on CPU %d\n", LOG_I(HW,"[SCHED] eNB TX deadline thread %d(id %ld) started on CPU %d\n",
proc->subframe, gettid(),sched_getcpu()); proc->subframe, gettid(),sched_getcpu());
#else #else
LOG_I(HW,"[SCHED] eNB TX thread %d started on CPU %d\n", LOG_I(HW,"[SCHED] eNB TX thread %d started on CPU %d\n",
proc->subframe,sched_getcpu()); proc->subframe,sched_getcpu());
#endif #endif
#endif #endif
...@@ -1067,10 +1066,10 @@ static void * eNB_thread_tx(void *param) { ...@@ -1067,10 +1066,10 @@ static void * eNB_thread_tx(void *param) {
while (!oai_exit){ while (!oai_exit){
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),0);
//LOG_I(PHY,"Locking mutex for eNB proc %d (IC %d,mutex %p)\n",proc->subframe,proc->instance_cnt,&proc->mutex); //LOG_I(PHY,"Locking mutex for eNB proc %d (IC %d,mutex %p)\n",proc->subframe,proc->instance_cnt,&proc->mutex);
// printf("Locking mutex for eNB proc %d (subframe_tx %d))\n",proc->subframe,proc->instance_cnt_tx); // printf("Locking mutex for eNB proc %d (subframe_tx %d))\n",proc->subframe,proc->instance_cnt_tx);
if (pthread_mutex_lock(&proc->mutex_tx) != 0) { if (pthread_mutex_lock(&proc->mutex_tx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error locking mutex for eNB TX proc %d\n",proc->subframe); LOG_E(PHY,"[SCHED][eNB] error locking mutex for eNB TX proc %d\n",proc->subframe);
...@@ -1078,9 +1077,9 @@ static void * eNB_thread_tx(void *param) { ...@@ -1078,9 +1077,9 @@ static void * eNB_thread_tx(void *param) {
} }
else { else {
while (proc->instance_cnt_tx < 0) { while (proc->instance_cnt_tx < 0) {
// LOG_I(PHY,"Waiting and unlocking mutex for eNB proc %d (IC %d,lock %d)\n",proc->subframe,proc->instance_cnt,pthread_mutex_trylock(&proc->mutex)); // LOG_I(PHY,"Waiting and unlocking mutex for eNB proc %d (IC %d,lock %d)\n",proc->subframe,proc->instance_cnt,pthread_mutex_trylock(&proc->mutex));
//printf("Waiting and unlocking mutex for eNB proc %d (subframe_tx %d)\n",proc->subframe,proc->instance_cnt_tx); //printf("Waiting and unlocking mutex for eNB proc %d (subframe_tx %d)\n",proc->subframe,proc->instance_cnt_tx);
pthread_cond_wait(&proc->cond_tx,&proc->mutex_tx); pthread_cond_wait(&proc->cond_tx,&proc->mutex_tx);
} }
...@@ -1094,39 +1093,39 @@ static void * eNB_thread_tx(void *param) { ...@@ -1094,39 +1093,39 @@ static void * eNB_thread_tx(void *param) {
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX_ENB, proc->frame_tx); vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX_ENB, proc->frame_tx);
start_meas(&softmodem_stats_tx_sf[proc->subframe]); start_meas(&softmodem_stats_tx_sf[proc->subframe]);
if (oai_exit) break; if (oai_exit) break;
if ((((PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms.frame_type == TDD)&& if ((((PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms.frame_type == TDD)&&
(subframe_select(&PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms,proc->subframe_tx)==SF_DL))|| (subframe_select(&PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms,proc->subframe_tx)==SF_DL))||
(PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms.frame_type == FDD))) { (PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms.frame_type == FDD))) {
phy_procedures_eNB_TX(proc->subframe,PHY_vars_eNB_g[0][proc->CC_id],0,no_relay,NULL); 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)) { 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); 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]); do_OFDM_mod_rt(proc->subframe_tx,PHY_vars_eNB_g[0][proc->CC_id]);
if (pthread_mutex_lock(&proc->mutex_tx) != 0) { if (pthread_mutex_lock(&proc->mutex_tx) != 0) {
printf("[openair][SCHED][eNB] error locking mutex for eNB TX proc %d\n",proc->subframe); printf("[openair][SCHED][eNB] error locking mutex for eNB TX proc %d\n",proc->subframe);
} }
else { else {
proc->instance_cnt_tx--; proc->instance_cnt_tx--;
if (pthread_mutex_unlock(&proc->mutex_tx) != 0) { if (pthread_mutex_unlock(&proc->mutex_tx) != 0) {
printf("[openair][SCHED][eNB] error unlocking mutex for eNB TX proc %d\n",proc->subframe); printf("[openair][SCHED][eNB] error unlocking mutex for eNB TX proc %d\n",proc->subframe);
} }
} }
proc->frame_tx++; proc->frame_tx++;
if (proc->frame_tx==1024) if (proc->frame_tx==1024)
proc->frame_tx=0; proc->frame_tx=0;
} }
stop_meas(&softmodem_stats_tx_sf[proc->subframe]); 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); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),0);
#ifdef HARD_RT #ifdef HARD_RT
...@@ -1149,8 +1148,8 @@ static void * eNB_thread_tx(void *param) { ...@@ -1149,8 +1148,8 @@ static void * eNB_thread_tx(void *param) {
#endif #endif
} }
int eNB_thread_rx_status[10]; int eNB_thread_rx_status[10];
static void * eNB_thread_rx(void *param) { static void * eNB_thread_rx(void *param) {
//unsigned long cpuid; //unsigned long cpuid;
eNB_proc_t *proc = (eNB_proc_t*)param; eNB_proc_t *proc = (eNB_proc_t*)param;
...@@ -1175,9 +1174,9 @@ static void * eNB_thread_rx(void *param) { ...@@ -1175,9 +1174,9 @@ static void * eNB_thread_rx(void *param) {
task = rt_task_init_schmod(nam2num(task_name), 0, 0, 0, SCHED_FIFO, 0xF); task = rt_task_init_schmod(nam2num(task_name), 0, 0, 0, SCHED_FIFO, 0xF);
if (task==NULL) { if (task==NULL) {
LOG_E(PHY,"[SCHED][eNB] Problem starting eNB_proc_RX thread_index %d (%s)!!!!\n",proc->subframe,task_name); LOG_E(PHY,"[SCHED][eNB] Problem starting eNB_proc_RX thread_index %d (%s)!!!!\n",proc->subframe,task_name);
return 0; return 0;
} }
else { else {
LOG_I(PHY,"[SCHED][eNB] eNB RX thread CC_id %d SF %d started with id %p\n", /* on CPU %d*/ LOG_I(PHY,"[SCHED][eNB] eNB RX thread CC_id %d SF %d started with id %p\n", /* on CPU %d*/
proc->CC_id, proc->CC_id,
...@@ -1475,6 +1474,7 @@ static void *eNB_thread(void *arg) ...@@ -1475,6 +1474,7 @@ static void *eNB_thread(void *arg)
attr.sched_runtime = 0.1 * 1000000; attr.sched_runtime = 0.1 * 1000000;
attr.sched_deadline = 0.5 * 1000000; attr.sched_deadline = 0.5 * 1000000;
attr.sched_period = 1.0 * 1000000; attr.sched_period = 1.0 * 1000000;
/* pin the eNB main thread to CPU0*/ /* pin the eNB main thread to CPU0*/
/* if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) { /* if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) {
...@@ -1648,7 +1648,7 @@ static void *eNB_thread(void *arg) ...@@ -1648,7 +1648,7 @@ static void *eNB_thread(void *arg)
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE,0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE,0);
/* /*
if (trace_cnt++<10) if (trace_cnt++<10)
printf("TRX: t1 %llu (trx_read), t2 %llu (trx_write)\n",(long long unsigned int)(trx_time1.tv_nsec - trx_time0.tv_nsec), (long long unsigned int)(trx_time2.tv_nsec - trx_time1.tv_nsec)); printf("TRX: t1 %llu (trx_read), t2 %llu (trx_write)\n",(long long unsigned int)(trx_time1.tv_nsec - trx_time0.tv_nsec), (long long unsigned int)(trx_time2.tv_nsec - trx_time1.tv_nsec));
*/ */
#else #else
...@@ -1851,7 +1851,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -1851,7 +1851,7 @@ static void *UE_thread_synch(void *arg) {
printf("unlocked sync_mutex (UE_sync_thread)\n"); printf("unlocked sync_mutex (UE_sync_thread)\n");
#endif #endif
printf("starting UE synch thread\n"); printf("starting UE synch thread\n");
if (UE_scan == 1) { if (UE_scan == 1) {
for (card=0;card<MAX_CARDS;card++) { for (card=0;card<MAX_CARDS;card++) {
for (i=0; i<openair0_cfg[card].rx_num_channels; i++) { for (i=0; i<openair0_cfg[card].rx_num_channels; i++) {
...@@ -1875,7 +1875,6 @@ static void *UE_thread_synch(void *arg) { ...@@ -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]); LOG_D(PHY,"[SCHED][UE] Check absolute frequency %u\n",downlink_frequency[0][0]);
sync_mode=pbch; sync_mode=pbch;
} }
while (!oai_exit) { while (!oai_exit) {
if (pthread_mutex_lock(&UE->mutex_synch) != 0) { if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
...@@ -1890,9 +1889,8 @@ static void *UE_thread_synch(void *arg) { ...@@ -1890,9 +1889,8 @@ static void *UE_thread_synch(void *arg) {
LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for UE Initial Synch thread\n"); LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for UE Initial Synch thread\n");
exit_fun("nothing to add"); exit_fun("nothing to add");
} }
} // mutex_lock } // mutex_lock
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,1); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,1);
switch (sync_mode) { switch (sync_mode) {
...@@ -1930,7 +1928,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -1930,7 +1928,7 @@ static void *UE_thread_synch(void *arg) {
break; break;
case pbch: case pbch:
if (initial_sync(UE,mode)==0) { if (initial_sync(UE,mode)==0) {
/* /*
lte_adjust_synch(&PHY_vars_UE_g[0]->lte_frame_parms, lte_adjust_synch(&PHY_vars_UE_g[0]->lte_frame_parms,
...@@ -1966,14 +1964,14 @@ static void *UE_thread_synch(void *arg) { ...@@ -1966,14 +1964,14 @@ static void *UE_thread_synch(void *arg) {
openair_daq_vars.freq_offset += 100; openair_daq_vars.freq_offset += 100;
openair_daq_vars.freq_offset *= -1; openair_daq_vars.freq_offset *= -1;
} }
else { else {
openair_daq_vars.freq_offset *= -1; openair_daq_vars.freq_offset *= -1;
} }
if (abs(openair_daq_vars.freq_offset) > 7500) { if (abs(openair_daq_vars.freq_offset) > 7500) {
LOG_I(PHY,"[initial_sync] No cell synchronization found, abandoning\n"); LOG_I(PHY,"[initial_sync] No cell synchronization found, abandoning\n");
mac_xface->macphy_exit("No cell synchronization found, abandoning"); mac_xface->macphy_exit("No cell synchronization found, abandoning");
} }
else { else {
LOG_I(PHY,"[initial_sync] trying carrier off %d Hz, rxgain %d\n",openair_daq_vars.freq_offset, LOG_I(PHY,"[initial_sync] trying carrier off %d Hz, rxgain %d\n",openair_daq_vars.freq_offset,
UE->rx_total_gain_dB); UE->rx_total_gain_dB);
for (card=0;card<MAX_CARDS;card++) { for (card=0;card<MAX_CARDS;card++) {
...@@ -1991,15 +1989,16 @@ static void *UE_thread_synch(void *arg) { ...@@ -1991,15 +1989,16 @@ static void *UE_thread_synch(void *arg) {
} }
// openair0_dump_config(&openair0_cfg[0],UE_flag); // openair0_dump_config(&openair0_cfg[0],UE_flag);
// rt_sleep_ns(FRAME_PERIOD); // rt_sleep_ns(FRAME_PERIOD);
} // freq_offset } // freq_offset
} // initial_sync=0 } // initial_sync=0
break;
case si: break;
default: case si:
break; default:
} break;
}
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0);
printf("Finished synch : Locking synch mutex (thread_sync)\n"); printf("Finished synch : Locking synch mutex (thread_sync)\n");
if (pthread_mutex_lock(&UE->mutex_synch) != 0) { if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
...@@ -2012,6 +2011,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -2012,6 +2011,7 @@ static void *UE_thread_synch(void *arg) {
printf("[openair][SCHED][eNB] error unlocking mutex for UE synch\n"); 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); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0);
} // while !oai_exit } // while !oai_exit
return(0); return(0);
...@@ -2156,7 +2156,7 @@ static void *UE_thread_rx(void *arg) { ...@@ -2156,7 +2156,7 @@ static void *UE_thread_rx(void *arg) {
#endif #endif
UE->instance_cnt_rx=-1; UE->instance_cnt_rx=-1;
#ifdef LOWLATENCY #ifdef LOWLATENCY
attr.size = sizeof(attr); attr.size = sizeof(attr);
attr.sched_flags = 0; attr.sched_flags = 0;
...@@ -2174,7 +2174,7 @@ static void *UE_thread_rx(void *arg) { ...@@ -2174,7 +2174,7 @@ static void *UE_thread_rx(void *arg) {
exit(-1); exit(-1);
} }
#endif #endif
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
#ifndef EXMIMO #ifndef EXMIMO
...@@ -2302,11 +2302,11 @@ static void *UE_thread(void *arg) { ...@@ -2302,11 +2302,11 @@ static void *UE_thread(void *arg) {
void *rxp[2],*txp[2]; void *rxp[2],*txp[2];
/* /*
#ifdef LOWLATENCY #ifdef LOWLATENCY
struct sched_attr attr; struct sched_attr attr;
unsigned int flags = 0; unsigned int flags = 0;
unsigned long mask = 1; // processor 0 unsigned long mask = 1; // processor 0
#endif #endif
*/ */
printf("waiting for sync (UE_thread)\n"); printf("waiting for sync (UE_thread)\n");
...@@ -2323,31 +2323,31 @@ static void *UE_thread(void *arg) { ...@@ -2323,31 +2323,31 @@ static void *UE_thread(void *arg) {
printf("starting UE thread\n"); printf("starting UE thread\n");
/* /*
#ifdef LOWLATENCY #ifdef LOWLATENCY
attr.size = sizeof(attr); attr.size = sizeof(attr);
attr.sched_flags = 0; attr.sched_flags = 0;
attr.sched_nice = 0; attr.sched_nice = 0;
attr.sched_priority = 0; attr.sched_priority = 0;
// This creates a .5 ms reservation // This creates a .5 ms reservation
attr.sched_policy = SCHED_DEADLINE; attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = 0.5 * 1000000; attr.sched_runtime = 0.5 * 1000000;
attr.sched_deadline = 0.5 * 1000000; attr.sched_deadline = 0.5 * 1000000;
attr.sched_period = 1 * 1000000; attr.sched_period = 1 * 1000000;
// pin the UE main thread to CPU0 // pin the UE main thread to CPU0
// if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) { // if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) {
// perror("[MAIN_ENB_THREAD] pthread_setaffinity_np failed\n"); // perror("[MAIN_ENB_THREAD] pthread_setaffinity_np failed\n");
// } // }
if (sched_setattr(0, &attr, flags) < 0 ){ if (sched_setattr(0, &attr, flags) < 0 ){
perror("[SCHED] main eNB thread: sched_setattr failed\n"); perror("[SCHED] main eNB thread: sched_setattr failed\n");
exit_fun("Nothing to add"); exit_fun("Nothing to add");
} else { } else {
LOG_I(HW,"[SCHED][eNB] eNB main deadline thread %ld started on CPU %d\n", LOG_I(HW,"[SCHED][eNB] eNB main deadline thread %ld started on CPU %d\n",
gettid(),sched_getcpu()); gettid(),sched_getcpu());
} }
#endif #endif
*/ */
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
...@@ -2497,7 +2497,6 @@ static void *UE_thread(void *arg) { ...@@ -2497,7 +2497,6 @@ static void *UE_thread(void *arg) {
//LOG_D(PHY,"HW RESYNC: hw_frame %d: Resynchronizing sample stream\n"); //LOG_D(PHY,"HW RESYNC: hw_frame %d: Resynchronizing sample stream\n");
frame=0; frame=0;
// dump ahead in time to start of frame // dump ahead in time to start of frame
#ifndef USRP_DEBUG #ifndef USRP_DEBUG
rxs = openair0.trx_read_func(&openair0, rxs = openair0.trx_read_func(&openair0,
&timestamp, &timestamp,
...@@ -2941,7 +2940,6 @@ void init_UE_threads(void) { ...@@ -2941,7 +2940,6 @@ void init_UE_threads(void) {
} }
void fill_ue_band_info() { void fill_ue_band_info() {
UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability; UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability;
...@@ -2969,7 +2967,6 @@ void fill_ue_band_info() { ...@@ -2969,7 +2967,6 @@ void fill_ue_band_info() {
} }
} }
} }
static void get_options (int argc, char **argv) { static void get_options (int argc, char **argv) {
int c; int c;
// char line[1000]; // char line[1000];
...@@ -2986,7 +2983,6 @@ static void get_options (int argc, char **argv) { ...@@ -2986,7 +2983,6 @@ static void get_options (int argc, char **argv) {
#endif #endif
const Enb_properties_array_t *enb_properties; const Enb_properties_array_t *enb_properties;
...@@ -3309,7 +3305,7 @@ int main(int argc, char **argv) { ...@@ -3309,7 +3305,7 @@ int main(int argc, char **argv) {
// int *eNB_thread_status_rx[10],*eNB_thread_status_tx[10]; // int *eNB_thread_status_rx[10],*eNB_thread_status_tx[10];
#endif #endif
int i,aa,card; int i,aa,card;
#if defined (XFORMS) || defined (EMOS) || defined(EXMIMO) #if defined (XFORMS) || defined (EMOS) || defined (EXMIMO)
void *status; void *status;
#endif #endif
...@@ -3334,7 +3330,6 @@ int main(int argc, char **argv) { ...@@ -3334,7 +3330,6 @@ int main(int argc, char **argv) {
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs); memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
set_latency_target(); set_latency_target();
mode = normal_txrx; mode = normal_txrx;
...@@ -3799,7 +3794,6 @@ int main(int argc, char **argv) { ...@@ -3799,7 +3794,6 @@ int main(int argc, char **argv) {
} }
printf("ITTI tasks created\n"); printf("ITTI tasks created\n");
#endif #endif
printf("Filling UE band info\n"); printf("Filling UE band info\n");
if (UE_flag==1) if (UE_flag==1)
fill_ue_band_info(); fill_ue_band_info();
......
...@@ -846,6 +846,29 @@ compile_unisim() { ...@@ -846,6 +846,29 @@ compile_unisim() {
return 1 return 1
fi 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 # 1. check if the executable functions exist
############################################### ###############################################
...@@ -935,14 +958,24 @@ check_for_mbmssim_executable() { ...@@ -935,14 +958,24 @@ check_for_mbmssim_executable() {
fi 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 # 1. check if the executable functions exist
############################################### ###############################################
# arg1 is RT
# arg2 is HW
# arg3 is ENB_S1
install_ltesoftmodem() { install_ltesoftmodem() {
# RT # RT
if [ $1 = "RTAI" ]; then if [ $1 = "RTAI" ]; then
if [ ! -f /tmp/init_rt_done.tmp ]; then if [ ! -f /tmp/init_rt_done.tmp ]; then
echo_info " 8.1 Insert RTAI modules" echo_info " 8.1 Insert RTAI modules"
$SUDO insmod /usr/realtime/modules/rtai_hal.ko > /dev/null 2>&1 $SUDO insmod /usr/realtime/modules/rtai_hal.ko > /dev/null 2>&1
$SUDO insmod /usr/realtime/modules/rtai_sched.ko > /dev/null 2>&1 $SUDO insmod /usr/realtime/modules/rtai_sched.ko > /dev/null 2>&1
...@@ -980,20 +1013,40 @@ install_ltesoftmodem() { ...@@ -980,20 +1013,40 @@ install_ltesoftmodem() {
# ENB_S1 # ENB_S1
if [ $3 = 0 ]; then if [ $3 = 0 ]; then
cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1 cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1
cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make # || exit 1 cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make # || exit 1
fi fi
} }
# arg1 is ENB_S1 'boolean'
install_oaisim() { install_oaisim() {
if [ $1 = 0 ]; then if [ $1 = 0 ]; then
cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1 cd $OPENAIR2_DIR && make clean && make nasmesh_netlink.ko #|| exit 1
cd $OPENAIR2_DIR/NAS/DRIVER/MESH/RB_TOOL && make clean && make # || 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 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
}
################################## ##################################
# create HSS DB # create HSS DB
################################ ################################
......
...@@ -472,7 +472,13 @@ build_enb(){ ...@@ -472,7 +472,13 @@ build_enb(){
oaisim_compiled=$? oaisim_compiled=$?
check_for_oaisim_executable check_for_oaisim_executable
echo_info "7.2 finished oaisim target: check the installation log file bin/install_log.txt" 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 fi
if [ $TARGET = "UNISIM" ]; then if [ $TARGET = "UNISIM" ]; then
echo "################## compile_unisim ##################" >> bin/install_log.txt echo "################## compile_unisim ##################" >> bin/install_log.txt
...@@ -800,6 +806,39 @@ if [ $RUN -ne 0 ]; then ...@@ -800,6 +806,39 @@ if [ $RUN -ne 0 ]; then
$SUDO echo "run" >> ~/.gdb_lte_softmodem $SUDO echo "run" >> ~/.gdb_lte_softmodem
$SUDO gdb -nh -x ~/.gdb_lte_softmodem 2>&1 $SUDO gdb -nh -x ~/.gdb_lte_softmodem 2>&1
fi 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 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