Commit 59964b0f authored by Laurent's avatar Laurent

Identity response encoding

parent 5729f153
......@@ -2269,6 +2269,7 @@ set (SHLIB_LOADER_SOURCES
add_library(LIB_5GNAS_GNB
${NAS_SRC}/gNB/network_process_nas.c
${NAS_SRC}/NR_UE/ue_process_nas.c
${OPENAIR3_DIR}//UICC/usim_interface.c
)
# Make lfds as a own source code (even if it is a outside library)
......@@ -2782,6 +2783,7 @@ add_executable(ocp-gnb
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
${XFORMSINTERFACE_SOURCE}
)
target_link_libraries (ocp-gnb
......@@ -2796,7 +2798,7 @@ target_link_libraries (ocp-gnb ${LIBXML2_LIBRARIES})
target_link_libraries (ocp-gnb pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (ocp-gnb ${LIB_LMS_LIBRARIES})
target_link_libraries (ocp-gnb ${T_LIB})
add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif rfsimulator)
add_dependencies(ocp-gnb ldpc_orig ldpc_optim ldpc_optim8seg ldpc params_libconfig rfsimulator oai_usrpdevif rfsimulator nrscope)
# nr-uesoftmodem is UE implementation
......@@ -2833,7 +2835,7 @@ target_link_libraries (nr-uesoftmodem
RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB S1AP_LIB S1AP_ENB
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB
-Wl,--end-group z dl)
target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES})
......
......@@ -78,11 +78,14 @@ unsigned short config_frames[4] = {2,9,11,13};
/* Callbacks, globals and object handlers */
//#include "stats.h"
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
#include "PHY/TOOLS/phy_scope_interface.h"
#include "PHY/TOOLS/nr_phy_scope.h"
#include <executables/nr-uesoftmodem.h>
#include "executables/softmodem-common.h"
#include "executables/thread-common.h"
#include <openair1/PHY/TOOLS/phy_scope_interface.h>
#include <openair3/NAS/NR_UE/nr_user_def.h>
// Raphael : missing
pthread_cond_t nfapi_sync_cond;
......@@ -757,6 +760,10 @@ int main( int argc, char **argv ) {
configure_linux();
mlockall(MCL_CURRENT | MCL_FUTURE);
char * resp;
nr_user_nas_t UErrc={0};
int size=identityResponse(&resp, &UErrc);
if(IS_SOFTMODEM_DOFORMS) {
load_softscope("nr",PHY_vars_UE_g[0][0]);
}
......
......@@ -1005,11 +1005,12 @@ int main( int argc, char **argv ) {
(void *)NULL, "time_meas", -1, OAI_PRIORITY_RT_LOW);
}
if (do_forms==1) {
if(IS_SOFTMODEM_DOFORMS) {
scopeParms_t tmp= {&argc, argv, &ru, RC.gNB[0]};
gNBinitScope(&tmp);
load_softscope("nr",&tmp);
}
while(!oai_exit)
sleep(1);
......
......@@ -66,7 +66,7 @@ typedef enum {
} Security_header_t;
typedef enum {
SUCI=0,
SUCI=1,
SGGUTI,
IMEI,
SGSTMSI,
......@@ -221,13 +221,32 @@ typedef struct {
} Identityrequest_t;
// the message continues with the identity value, depending on identity type, see TS 14.501, 9.11.3.4
typedef struct {
typedef struct __attribute__((packed)) {
Extendedprotocoldiscriminator_t epd:8;
Security_header_t sh:8;
SGSmobilitymanagementmessages_t mt:8;
identitytype_t mi:8;
uint16_t len;
} Identityresponse_t;
typedef struct __attribute__((packed)) {
Identityresponse_t common;
identitytype_t mi:8;
int supiFormat:4;
int identityType:4;
int mcc1:4;
int mcc2:4;
int mcc3:4;
int mnc3:4;
int mnc2:4;
int mnc1:4;
int routing1:4;
int routing2:4;
int routing3:4;
int routing4:4;
int protectScheme:4;
int spare:4;
uint8_t hplmnId;
} IdentityresponseIMSI_t;
typedef struct {
Extendedprotocoldiscriminator_t epd:8;
......@@ -244,4 +263,5 @@ typedef struct {
SGSmobilitymanagementmessages_t mt:8;
} authenticationresponseHeader_t;
//AUTHENTICATION RESULT
typedef struct {
#include <openair3/UICC/usim_interface.h>
typedef struct {
uicc_t * uicc;
} nr_user_nas_t;
int identityResponse(void **msg, nr_user_nas_t *UE);
#include <openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h>
#include <openair3/NAS/NR_UE/nr_user_def.h>
void SGSabortNet(void *msg, nr_user_nas_t *UE) {
}
void nas_schedule(void) {
}
/*
*Message reception
*/
void SGSauthenticationReq(void *msg, nr_user_nas_t *UE) {
Identityrequest_t *idmsg=(Identityrequest_t *) msg;
if (idmsg->it == SUCI ) {
LOG_I(NAS,"Received Identity request, scheduling answer\n");
nas_schedule();
} else
LOG_E(NAS,"Not developped: identity request for %d\n", idmsg->it);
}
void SGSidentityReq(void *msg, nr_user_nas_t *UE) {
......@@ -28,16 +36,17 @@ void UEprocessNAS(void *msg,nr_user_nas_t *UE) {
SGSabortNet(msg, UE);
else {
switch (header->epd) {
SGSmobilitymanagementmessages:
case SGSmobilitymanagementmessages:
switch (header->mt) {
Authenticationrequest:
case Authenticationrequest:
SGSauthenticationReq(msg, UE);
break;
Identityrequest:
case Identityrequest:
SGSidentityReq(msg, UE);
break;
Securitymodecommand:
case Securitymodecommand:
SGSsecurityModeCommand(msg, UE);
break;
......@@ -46,7 +55,8 @@ Securitymodecommand:
}
break;
SGSsessionmanagementmessages:
case SGSsessionmanagementmessages:
SGSabortNet(msg, UE);
break;
......@@ -60,14 +70,53 @@ SGSsessionmanagementmessages:
* Messages emission
*/
void identityResponse(void *msg, nr_user_nas_t *UE) {
int identityResponse(void **msg, nr_user_nas_t *UE) {
if (UE->uicc == NULL)
// config file section hardcoded as "uicc", nevertheless it opens to manage several UEs or a multi SIM UE
UE->uicc=init_uicc("uicc");
// TS 24.501 9.11.3.4
int imsiL=strlen(UE->uicc->imsi);
int msinL=imsiL-3-UE->uicc->nmc_size;
int respSize=sizeof(IdentityresponseIMSI_t) + (msinL+1)/2;
IdentityresponseIMSI_t *resp=(IdentityresponseIMSI_t *) calloc(respSize,1);
resp->common.epd=SGSmobilitymanagementmessages;
resp->common.sh=0;
resp->common.mt=Identityresponse;
resp->common.len=htons(respSize-sizeof(Identityresponse_t));
resp->mi=SUCI;
resp->mcc1=UE->uicc->imsi[0]-'0';
resp->mcc2=UE->uicc->imsi[1]-'0';
resp->mcc3=UE->uicc->imsi[2]-'0';
resp->mnc1=UE->uicc->imsi[3]-'0';
resp->mnc2=UE->uicc->imsi[4]-'0';
resp->mnc3=UE->uicc->nmc_size==2? 0xF : UE->uicc->imsi[3]-'0';
// TBD: routing to fill (FF ?)
char *out=(char *)(resp+1);
char *ptr=UE->uicc->imsi + 3 + UE->uicc->nmc_size;
while ( ptr < UE->uicc->imsi+strlen(UE->uicc->imsi) ) {
*out=((*(ptr+1)-'0')<<4) | (*(ptr) -'0');
out++;
ptr+=2;
}
if (msinL%2 == 1)
*out=((*(ptr-1)-'0')) | 0xF0;
*msg=resp;
log_dump(NAS, resp, respSize, LOG_DUMP_CHAR, "\n");
return respSize;
}
void authenticationResponse(void *msg,nr_user_nas_t *UE) {
int authenticationResponse(void **msg,nr_user_nas_t *UE) {
return -1;
}
void securityModeComplete(void *msg, nr_user_nas_t *UE) {
int securityModeComplete(void **msg, nr_user_nas_t *UE) {
return -1;
}
void registrationComplete(void *msg, nr_user_nas_t *UE) {
int registrationComplete(void **msg, nr_user_nas_t *UE) {
return -1;
}
......@@ -74,11 +74,11 @@ SGSsessionmanagementmessages:
* Messages emission
*/
void identityRequest(void *msg, NRUEcontext_t *UE) {
int identityRequest(void **msg, NRUEcontext_t *UE) {
}
void authenticationRequest(void *msg, NRUEcontext_t *UE) {
int authenticationRequest(void **msg, NRUEcontext_t *UE) {
}
void securityModeCommand(void *msg, NRUEcontext_t *UE) {
int securityModeCommand(void **msg, NRUEcontext_t *UE) {
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <openair3/UICC/usim_interface.h>
#define UICC_SECTION "uicc"
#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"
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* configuration parameters for the rfsimulator device */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define UICC_PARAMS_DESC {\
{"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsi), defstrval:"", TYPE_STRING, 0 },\
{"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\
{"key", "USIM Ki\n", 0, strptr:&(uicc->key), defstrval:"", TYPE_STRING, 0 },\
{"opc", "USIM OPc\n", 0, strptr:&(uicc->opc), defstrval:"", TYPE_STRING, 0 },\
};
uicc_t *init_uicc(char *sectionName) {
uicc_t *uicc=(uicc_t *)calloc(sizeof(uicc_t),1);
paramdef_t uicc_params[] = UICC_PARAMS_DESC;
int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName);
AssertFatal(ret >= 0, "configuration couldn't be performed");
LOG_I(HW, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsi, uicc->key, uicc->opc);
return uicc;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.comopenair3/UICC/usim_interface.h
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <errno.h>
#include <common/utils/assertions.h>
#include <common/utils/LOG/log.h>
#include <common/utils/load_module_shlib.h>
#include <common/config/config_userapi.h>
#include "common_lib.h"
typedef struct {
char *imsi;
char *key;
char *opc;
int nmc_size;
} uicc_t;
/*
* Read the configuration file, section name variable to be able to manage several UICC
*/
uicc_t *init_uicc(char *sectionName);
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