From 669ef9816fdae1374ba3e4bfcab65eaa0571cffe Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 26 Feb 2018 10:39:40 +0000 Subject: [PATCH] Added packing of TMSI to mobile station identity IE. --- lib/include/srslte/asn1/liblte_mme.h | 1 + lib/src/asn1/liblte_mme.cc | 64 +++++++++++++++++++--------- srsepc/src/mme/s1ap_nas_transport.cc | 24 ++++++++--- 3 files changed, 62 insertions(+), 27 deletions(-) diff --git a/lib/include/srslte/asn1/liblte_mme.h b/lib/include/srslte/asn1/liblte_mme.h index 78e2cae69..85b8b2241 100644 --- a/lib/include/srslte/asn1/liblte_mme.h +++ b/lib/include/srslte/asn1/liblte_mme.h @@ -175,6 +175,7 @@ typedef struct{ uint8 imsi[15]; uint8 imei[15]; uint8 imeisv[16]; + uint32 tmsi; }LIBLTE_MME_MOBILE_ID_STRUCT; // Functions LIBLTE_ERROR_ENUM liblte_mme_pack_mobile_id_ie(LIBLTE_MME_MOBILE_ID_STRUCT *mobile_id, diff --git a/lib/src/asn1/liblte_mme.cc b/lib/src/asn1/liblte_mme.cc index ea7729519..da79fb791 100644 --- a/lib/src/asn1/liblte_mme.cc +++ b/lib/src/asn1/liblte_mme.cc @@ -297,6 +297,7 @@ LIBLTE_ERROR_ENUM liblte_mme_pack_mobile_id_ie(LIBLTE_MME_MOBILE_ID_STRUCT *mob { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; uint8 *id; + uint32 id32; uint32 i; uint8 length; bool odd = false; @@ -317,6 +318,11 @@ LIBLTE_ERROR_ENUM liblte_mme_pack_mobile_id_ie(LIBLTE_MME_MOBILE_ID_STRUCT *mob id = mobile_id->imeisv; length = 9; odd = false; + }else if(LIBLTE_MME_MOBILE_ID_TYPE_TMSI == mobile_id->type_of_id){ + id32 = mobile_id->tmsi; + length = 4; + odd = false; + } }else{ // FIXME: Not handling these IDs return(err); @@ -325,30 +331,48 @@ LIBLTE_ERROR_ENUM liblte_mme_pack_mobile_id_ie(LIBLTE_MME_MOBILE_ID_STRUCT *mob // Length **ie_ptr = length; *ie_ptr += 1; - - // | Identity digit 1 | odd/even | Id type | - if(odd) + if(LIBLTE_MME_MOBILE_ID_TYPE_TMSI != mobile_id->type_of_id) { - **ie_ptr = (id[0] << 4) | (1 << 3) | mobile_id->type_of_id; - }else{ - **ie_ptr = (id[0] << 4) | (0 << 3) | mobile_id->type_of_id; - } - *ie_ptr += 1; + // | Identity digit 1 | odd/even | Id type | + if(odd) + { + **ie_ptr = (id[0] << 4) | (1 << 3) | mobile_id->type_of_id; + }else{ + **ie_ptr = (id[0] << 4) | (0 << 3) | mobile_id->type_of_id; + } + *ie_ptr += 1; - // | Identity digit p+1 | Identity digit p | - for(i=0; i<7; i++) - { - (*ie_ptr)[i] = (id[i*2+2] << 4) | id[i*2+1]; - } - *ie_ptr += 7; - if(!odd) - { - **ie_ptr = 0xF0 | id[15]; - *ie_ptr += 1; + + // | Identity digit p+1 | Identity digit p | + for(i=0; i<7; i++) + { + (*ie_ptr)[i] = (id[i*2+2] << 4) | id[i*2+1]; + } + *ie_ptr += 7; + if(!odd) + { + **ie_ptr = 0xF0 | id[15]; + *ie_ptr += 1; + } + + err = LIBLTE_SUCCESS; } + else{ - err = LIBLTE_SUCCESS; - } + **ie_ptr = (0xFF << 4) | (0 << 3) | mobile_id->type_of_id; + *ie_ptr += 1; + //4-Byte based ids + **ie_ptr = (id32 >> 24) & 0xFF; + *ie_ptr += 1; + **ie_ptr = (id32 >> 16) & 0xFF; + *ie_ptr += 1; + **ie_ptr = (id32 >> 8) & 0xFF; + *ie_ptr += 1; + **ie_ptr = id32 & 0xFF; + *ie_ptr += 1; + + err = LIBLTE_SUCCESS; + } return(err); } diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index b5c2b8531..736eb4d3d 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -1542,8 +1542,9 @@ s1ap_nas_transport::pack_attach_accept(ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *u } //Attach accept - attach_accept.eps_attach_result = LIBLTE_MME_EPS_ATTACH_RESULT_EPS_ONLY; - //attach_accept.eps_attach_result = LIBLTE_MME_EPS_ATTACH_RESULT_COMBINED_EPS_IMSI_ATTACH; + //attach_accept.eps_attach_result = LIBLTE_MME_EPS_ATTACH_RESULT_EPS_ONLY; + attach_accept.eps_attach_result = LIBLTE_MME_EPS_ATTACH_RESULT_COMBINED_EPS_IMSI_ATTACH; + //Mandatory //FIXME: Set t3412 from config attach_accept.t3412.unit = LIBLTE_MME_GPRS_TIMER_UNIT_1_MINUTE; // GPRS 1 minute unit @@ -1570,13 +1571,22 @@ s1ap_nas_transport::pack_attach_accept(ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *u attach_accept.guti.guti.m_tmsi); //Set EMM cause to no CS available - //attach_accept.emm_cause_present=false; - attach_accept.emm_cause_present=true; - attach_accept.emm_cause=18; + attach_accept.emm_cause_present=false; + //attach_accept.emm_cause_present=true; + //attach_accept.emm_cause=18; + + //Set up LAI for combined EPS/IMSI attach + //attach_accept.lai_present=false; + attach_accept.lai_present=true; + attach_accept.lai.mcc = mcc; + attach_accept.lai.mnc = mnc; + attach_accept.lai.lac = 001; + + attach_accept.ms_id_present=true; + attach_accept.ms_id.type_of_id = LIBLTE_MME_MOBILE_ID_TYPE_TMSI; + attach_accept.ms_id.tmsi = attach_accept.guti.guti.m_tmsi; //Make sure all unused options are set to false - attach_accept.lai_present=false; - attach_accept.ms_id_present=false; attach_accept.t3402_present=false; attach_accept.t3423_present=false; attach_accept.equivalent_plmns_present=false;