Commit eca08df8 authored by Dorovskikh's avatar Dorovskikh

5G UE IMEISV 16 digits

reading 5G UE IMEISV from config file
Signed-off-by: default avatarDorovskikh <vladimir.dorovskikh@capgemini.com>
parent f984f493
......@@ -235,10 +235,23 @@ static int encode_suci_5gs_mobile_identity(Suci5GSMobileIdentity_t *suci, uint8_
static int encode_imeisv_5gs_mobile_identity(Imeisv5GSMobileIdentity_t *imeisv, uint8_t *buffer)
{
uint32_t encoded = 0;
*(buffer + encoded) = 0x00 | (imeisv->digit1 << 4) | (imeisv->oddeven << 3) | (imeisv->typeofidentity);
*(buffer + encoded) = 0x00 | (imeisv->digittac01 << 4) | (imeisv->oddeven << 3) | (imeisv->typeofidentity);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digitp1 << 4) | (imeisv->digitp);
*(buffer + encoded) = 0x00 | (imeisv->digittac03 << 4) | (imeisv->digittac02);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digittac05 << 4) | (imeisv->digittac04);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digittac07 << 4) | (imeisv->digittac06);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digit09 << 4) | (imeisv->digittac08);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digit11 << 4) | (imeisv->digit10);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digit13 << 4) | (imeisv->digit12);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->digitsv1 << 4) | (imeisv->digit14);
encoded++;
*(buffer + encoded) = 0x00 | (imeisv->spare << 4) | (imeisv->digitsv2);
encoded++;
return encoded;
......
......@@ -92,7 +92,27 @@ typedef struct {
uint8_t digitp:4;
} Imei5GSMobileIdentity_t;
typedef Imei5GSMobileIdentity_t Imeisv5GSMobileIdentity_t;
typedef struct {
uint8_t digittac01:4;
uint8_t oddeven:1;
uint8_t typeofidentity:3;
uint8_t digittac02:4;
uint8_t digittac03:4;
uint8_t digittac04:4;
uint8_t digittac05:4;
uint8_t digittac06:4;
uint8_t digittac07:4;
uint8_t digittac08:4;
uint8_t digit09:4;
uint8_t digit10:4;
uint8_t digit11:4;
uint8_t digit12:4;
uint8_t digit13:4;
uint8_t digit14:4;
uint8_t digitsv1:4;
uint8_t digitsv2:4;
uint8_t spare:4;
} Imeisv5GSMobileIdentity_t;
typedef struct {
......
......@@ -25,6 +25,8 @@
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
* \date 2020
* \version 0.1
*
* 2023.01.27 Vladimir Dorovskikh 16 digits IMEISV
*/
......@@ -523,6 +525,31 @@ int nas_itti_kgnb_refresh_req(const uint8_t kgnb[32], int instance) {
return itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p);
}
static int addImeisv(int Mod_id,MM_msg *mm_msg)
{
int i=0;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.typeofidentity = FGS_MOBILE_IDENTITY_IMEISV;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac01 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac02 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac03 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac04 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac05 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac06 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac07 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digittac08 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit09 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit10 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit11 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit12 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit13 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit14 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digitsv1 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digitsv2 = getImeisvDigit(Mod_id,i++);
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.spare = 0x0f;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.oddeven = 1;
return 19;
}
static void generateSecurityModeComplete(int Mod_id,as_nas_info_t *initialNasMsg)
{
int size = sizeof(mm_msg_header_t);
......@@ -552,12 +579,7 @@ static void generateSecurityModeComplete(int Mod_id,as_nas_info_t *initialNasMsg
mm_msg->fgs_security_mode_complete.messagetype = FGS_SECURITY_MODE_COMPLETE;
size += 1;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.typeofidentity = FGS_MOBILE_IDENTITY_IMEISV;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digit1 = 1;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digitp1 = 1;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.digitp = 1;
mm_msg->fgs_security_mode_complete.fgsmobileidentity.imeisv.oddeven = 0;
size += 5;
size += addImeisv(Mod_id, mm_msg);
mm_msg->fgs_security_mode_complete.fgsnasmessagecontainer.nasmessagecontainercontents.value = registration_request_buf;
mm_msg->fgs_security_mode_complete.fgsnasmessagecontainer.nasmessagecontainercontents.length = registration_request_len;
......
......@@ -27,10 +27,12 @@
extern uint16_t NB_UE_INST;
#define UICC_SECTION "uicc"
#define IMEISV_STR_MAX_LENGTH 16
#define UICC_CONFIG_HELP_OPTIONS " list of comma separated options to interface a simulated (real UICC to be developped). Available options: \n"\
" imsi: user imsi\n"\
" key: cyphering key\n"\
" opc: cyphering OPc\n"
" opc: cyphering OPc\n"\
" imiesv: string with IMEISV value\n"
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* configuration parameters for the rfsimulator device */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
......@@ -45,6 +47,7 @@ extern uint16_t NB_UE_INST;
{"dnn", "UE dnn (apn)\n", 0, strptr:&uicc->dnnStr, defstrval:"oai", TYPE_STRING, 0 }, \
{"nssai_sst", "UE nssai\n", 0, iptr:&uicc->nssai_sst, defintval:1, TYPE_INT, 0 }, \
{"nssai_sd", "UE nssai\n", 0, iptr:&uicc->nssai_sd, defintval:0xffffff, TYPE_INT, 0 }, \
{"imeisv", "IMEISV\n", 0, strptr:&uicc->imeisvStr, defstrval:"6754567890123413", TYPE_STRING, 0 }, \
};
static uicc_t** uiccArray=NULL;
......@@ -74,8 +77,8 @@ uicc_t *init_uicc(char *sectionName) {
int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName);
AssertFatal(ret >= 0, "configuration couldn't be performed for uicc name: %s", sectionName);
LOG_I(SIM,
"UICC simulation: IMSI=%s, Ki=%s, OPc=%s, DNN=%s, SST=0x%02x, SD=0x%06x\n",
uicc->imsiStr, uicc->keyStr, uicc->opcStr,
"UICC simulation: IMSI=%s, IMEISV=%s, Ki=%s, OPc=%s, DNN=%s, SST=0x%02x, SD=0x%06x\n",
uicc->imsiStr, uicc->imeisvStr, uicc->keyStr, uicc->opcStr,
uicc->dnnStr, uicc->nssai_sst, uicc->nssai_sd);
to_hex(uicc->keyStr,uicc->key, sizeof(uicc->key) );
to_hex(uicc->opcStr,uicc->opc, sizeof(uicc->opc) );
......@@ -112,3 +115,22 @@ uicc_t * checkUicc(int Mod_id) {
}
return (uicc_t*) uiccArray[Mod_id];
}
uint8_t getImeisvDigit(int Mod_id,uint8_t i)
{
uicc_t * uicc=checkUicc(Mod_id);
uint8_t r = 0;
uint8_t l = strlen(uicc->imeisvStr);
if (l > IMEISV_STR_MAX_LENGTH) {
l=IMEISV_STR_MAX_LENGTH;
}
if((uicc->imeisvStr!=NULL) && (i<l))
{
char c = uicc->imeisvStr[i];
if (isdigit(c))
{
r=c-'0';
}
}
return (0x0f & r);
}
\ No newline at end of file
......@@ -45,6 +45,7 @@ So, RES can be either milenage res, or received response, so hash of milenage re
typedef struct {
char *imsiStr;
char *imeisvStr;
char *keyStr;
char *opcStr;
char *amfStr;
......@@ -73,4 +74,5 @@ uicc_t *checkUicc(int Mod_id);
uicc_t *init_uicc(char *sectionName);
void uicc_milenage_generate(uint8_t * autn, uicc_t *uicc);
uicc_t * checkUicc(int Mod_id);
uint8_t getImeisvDigit(int Mod_id,uint8_t i);
#endif
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