[SGsAP] Location Update process is done

This commit is contained in:
Sukchan Lee 2019-06-22 11:16:22 +09:00
parent 058ebc747d
commit 693afa922f
11 changed files with 144 additions and 88 deletions

View File

@ -65,7 +65,7 @@ void *nas_from_plmn_id(nas_plmn_id_t *nas_plmn_id, plmn_id_t *plmn_id);
void *nas_to_plmn_id(plmn_id_t *plmn_id, nas_plmn_id_t *nas_plmn_id);
typedef struct nas_guti_s {
nas_plmn_id_t plmn_id;
nas_plmn_id_t nas_plmn_id;
uint16_t mme_gid;
uint8_t mme_code;
uint32_t m_tmsi;
@ -114,7 +114,7 @@ ED8(uint8_t ebi15:1;,
* See subclause 10.5.1.3 in 3GPP TS 24.008 [13]
* O TV 6 */
typedef struct nas_location_area_identification_s {
nas_plmn_id_t plmn_id;
nas_plmn_id_t nas_plmn_id;
uint16_t lac;
} __attribute__ ((packed)) nas_location_area_identification_t;
@ -164,7 +164,7 @@ ED5(uint8_t spare:2;,
uint8_t odd_even:1;,
uint8_t type:3;)
uint8_t mbms_servicec_id[3];
nas_plmn_id_t plmn_id;
nas_plmn_id_t nas_plmn_id;
uint8_t mbms_session_identity;
} __attribute__ ((packed)) nas_mobile_identity_tmgi_t;
@ -230,7 +230,7 @@ typedef struct nas_mobile_station_classmark_3_s {
#define NAS_MAX_PLMN 15
typedef struct nas_plmn_list_s {
uint8_t length;
nas_plmn_id_t plmn_id[NAS_MAX_PLMN];
nas_plmn_id_t nas_plmn_id[NAS_MAX_PLMN];
} __attribute__ ((packed)) nas_plmn_list_t;
/* 9.9.2.10 Supported codec list
@ -458,7 +458,7 @@ typedef struct nas_eps_mobile_identity_guti_s {
ED3(uint8_t spare:4;,
uint8_t odd_even:1;,
uint8_t type:3;)
nas_plmn_id_t plmn_id;
nas_plmn_id_t nas_plmn_id;
uint16_t mme_gid;
uint8_t mme_code;
uint32_t m_tmsi;
@ -778,7 +778,7 @@ ED3(uint8_t type:4;,
/* 9.9.3.32 Tracking area identity
* O TV 6 */
typedef struct nas_tracking_area_identity_s {
nas_plmn_id_t plmn_id;
nas_plmn_id_t nas_plmn_id;
uint16_t tac;
} __attribute__ ((packed)) nas_tracking_area_identity_t;

View File

@ -20,6 +20,10 @@ int emm_build_attach_accept(
nas_eps_mobile_identity_t *nas_guti = &attach_accept->guti;
nas_eps_network_feature_support_t *eps_network_feature_support =
&attach_accept->eps_network_feature_support;
nas_location_area_identification_t *lai =
&attach_accept->location_area_identification;
nas_mobile_identity_t *ms_identity = &attach_accept->ms_identity;
nas_mobile_identity_tmsi_t *tmsi = &ms_identity->tmsi;;
ogs_assert(mme_ue);
ogs_assert(esmbuf);
@ -66,7 +70,7 @@ int emm_build_attach_accept(
nas_guti->length = sizeof(nas_eps_mobile_identity_guti_t);
nas_guti->guti.odd_even = NAS_EPS_MOBILE_IDENTITY_EVEN;
nas_guti->guti.type = NAS_EPS_MOBILE_IDENTITY_GUTI;
nas_guti->guti.plmn_id = mme_ue->guti.plmn_id;
nas_guti->guti.nas_plmn_id = mme_ue->guti.nas_plmn_id;
nas_guti->guti.mme_gid = mme_ue->guti.mme_gid;
nas_guti->guti.mme_code = mme_ue->guti.mme_code;
nas_guti->guti.m_tmsi = mme_ue->guti.m_tmsi;
@ -89,6 +93,40 @@ int emm_build_attach_accept(
eps_network_feature_support->length = 1;
eps_network_feature_support->ims_vops = 1;
if (mme_ue->vlr) {
attach_accept->presencemask |=
NAS_ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT;
lai->nas_plmn_id = mme_ue->vlr->lai.nas_plmn_id;
lai->lac = mme_ue->vlr->lai.lac;
if (lai->nas_plmn_id.mnc3 == 0xf)
ogs_debug(" LAI[MCC:%d%d%d,MNC:%d%d,LAC:%d]",
lai->nas_plmn_id.mcc1,
lai->nas_plmn_id.mcc2,
lai->nas_plmn_id.mcc3,
lai->nas_plmn_id.mnc1,
lai->nas_plmn_id.mnc2,
lai->lac);
else
ogs_debug(" LAI[MCC:%d%d%d,MNC:%d%d%d,LAC:%d]",
lai->nas_plmn_id.mcc1,
lai->nas_plmn_id.mcc2,
lai->nas_plmn_id.mcc3,
lai->nas_plmn_id.mnc1,
lai->nas_plmn_id.mnc2,
lai->nas_plmn_id.mnc3,
lai->lac);
}
if (mme_ue->p_tmsi) {
attach_accept->presencemask |= NAS_ATTACH_ACCEPT_MS_IDENTITY_PRESENT;
ms_identity->length = 5;
tmsi->spare = 0xf;
tmsi->odd_even = 0;
tmsi->type = NAS_MOBILE_IDENTITY_TMSI;
tmsi->tmsi = mme_ue->p_tmsi;
ogs_debug(" P-TMSI: 0x%08x", tmsi->tmsi);
}
rv = nas_security_encode(emmbuf, mme_ue, &message);
ogs_assert(rv == OGS_OK && *emmbuf);
ogs_pkbuf_free(esmbuf);

View File

@ -100,8 +100,8 @@ int emm_handle_attach_request(
nas_tracking_area_identity_t *last_visited_registered_tai =
&attach_request->last_visited_registered_tai;
nas_to_plmn_id(
&mme_ue->visited_plmn_id, &last_visited_registered_tai->plmn_id);
nas_to_plmn_id(&mme_ue->visited_plmn_id,
&last_visited_registered_tai->nas_plmn_id);
ogs_debug(" Visited_PLMN_ID:%06x",
plmn_id_hexdump(&mme_ue->visited_plmn_id));
}
@ -141,19 +141,19 @@ int emm_handle_attach_request(
}
case NAS_EPS_MOBILE_IDENTITY_GUTI:
{
nas_eps_mobile_identity_guti_t *nas_guti = NULL;
nas_guti = &eps_mobile_identity->guti;
nas_guti_t guti;
nas_eps_mobile_identity_guti_t *nas_eps_mobile_identity_guti =
&eps_mobile_identity->guti;
nas_guti_t nas_guti;
guti.plmn_id = nas_guti->plmn_id;
guti.mme_gid = nas_guti->mme_gid;
guti.mme_code = nas_guti->mme_code;
guti.m_tmsi = nas_guti->m_tmsi;
nas_guti.nas_plmn_id = nas_eps_mobile_identity_guti->nas_plmn_id;
nas_guti.mme_gid = nas_eps_mobile_identity_guti->mme_gid;
nas_guti.mme_code = nas_eps_mobile_identity_guti->mme_code;
nas_guti.m_tmsi = nas_eps_mobile_identity_guti->m_tmsi;
ogs_debug(" GUTI[G:%d,C:%d,M_TMSI:0x%x] IMSI[%s]",
guti.mme_gid,
guti.mme_code,
guti.m_tmsi,
nas_guti.mme_gid,
nas_guti.mme_code,
nas_guti.m_tmsi,
MME_UE_HAVE_IMSI(mme_ue)
? mme_ue->imsi_bcd : "Unknown");
break;
@ -472,8 +472,8 @@ int emm_handle_tau_request(
nas_tracking_area_identity_t *last_visited_registered_tai =
&tau_request->last_visited_registered_tai;
nas_to_plmn_id(
&mme_ue->visited_plmn_id, &last_visited_registered_tai->plmn_id);
nas_to_plmn_id(&mme_ue->visited_plmn_id,
&last_visited_registered_tai->nas_plmn_id);
ogs_debug(" Visited_PLMN_ID:%06x",
plmn_id_hexdump(&mme_ue->visited_plmn_id));
}
@ -506,19 +506,19 @@ int emm_handle_tau_request(
{
case NAS_EPS_MOBILE_IDENTITY_GUTI:
{
nas_eps_mobile_identity_guti_t *nas_guti = NULL;
nas_guti = &eps_mobile_identity->guti;
nas_guti_t guti;
nas_eps_mobile_identity_guti_t *nas_eps_mobile_identity_guti =
&eps_mobile_identity->guti;
nas_guti_t nas_guti;
guti.plmn_id = nas_guti->plmn_id;
guti.mme_gid = nas_guti->mme_gid;
guti.mme_code = nas_guti->mme_code;
guti.m_tmsi = nas_guti->m_tmsi;
nas_guti.nas_plmn_id = nas_eps_mobile_identity_guti->nas_plmn_id;
nas_guti.mme_gid = nas_eps_mobile_identity_guti->mme_gid;
nas_guti.mme_code = nas_eps_mobile_identity_guti->mme_code;
nas_guti.m_tmsi = nas_eps_mobile_identity_guti->m_tmsi;
ogs_debug(" GUTI[G:%d,C:%d,M_TMSI:0x%x] IMSI:[%s]",
guti.mme_gid,
guti.mme_code,
guti.m_tmsi,
nas_guti.mme_gid,
nas_guti.mme_code,
nas_guti.m_tmsi,
MME_UE_HAVE_IMSI(mme_ue)
? mme_ue->imsi_bcd : "Unknown");
break;

View File

@ -2,6 +2,7 @@
#include "mme-context.h"
#include "nas-path.h"
#include "sgsap-path.h"
#include "mme-gtp-path.h"
#include "esm-build.h"
@ -130,8 +131,13 @@ int esm_handle_information_response(mme_sess_t *sess,
ogs_debug(" APN[%s]", sess->pdn->apn);
if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue))
{
rv = nas_send_attach_accept(mme_ue);
ogs_assert(rv == OGS_OK);
mme_vlr_t *vlr = mme_vlr_find_by_tai(&mme_ue->tai);
mme_ue->vlr = vlr;
if (vlr)
sgsap_send_location_update_request(mme_ue);
else
nas_send_attach_accept(mme_ue);
}
else
{

View File

@ -1176,9 +1176,9 @@ int mme_context_parse_config()
plmn_id_build(&plmn_id,
atoi(mcc), atoi(mnc), strlen(mnc));
nas_from_plmn_id(&vlr->tai.plmn_id, &plmn_id);
nas_from_plmn_id(&vlr->tai.nas_plmn_id, &plmn_id);
vlr->tai.tac = atoi(tac);
nas_from_plmn_id(&vlr->lai.plmn_id, &plmn_id);
nas_from_plmn_id(&vlr->lai.nas_plmn_id, &plmn_id);
vlr->lai.lac = atoi(lac);
} while (ogs_yaml_iter_type(&sgsap_array) ==
YAML_SEQUENCE_NODE);
@ -1601,7 +1601,7 @@ mme_vlr_t *mme_vlr_find_by_tai(tai_t *tai)
ogs_list_for_each(&self.vlr_list, vlr) {
nas_tai_t nas_tai;
nas_from_plmn_id(&nas_tai.plmn_id, &tai->plmn_id);
nas_from_plmn_id(&nas_tai.nas_plmn_id, &tai->plmn_id);
nas_tai.tac = tai->tac;
if (memcmp(&vlr->tai, &nas_tai, sizeof(nas_tai_t)) == 0)
return vlr;
@ -1913,7 +1913,7 @@ static int mme_ue_new_guti(mme_ue_t *mme_ue)
memset(&mme_ue->guti, 0, sizeof(nas_guti_t));
/* Use the first configured plmn_id and mme group id */
nas_from_plmn_id(&mme_ue->guti.plmn_id, &served_gummei->plmn_id[0]);
nas_from_plmn_id(&mme_ue->guti.nas_plmn_id, &served_gummei->plmn_id[0]);
mme_ue->guti.mme_gid = served_gummei->mme_gid[0];
mme_ue->guti.mme_code = served_gummei->mme_code[0];
@ -2147,26 +2147,26 @@ mme_ue_t* mme_ue_find_by_message(nas_message_t *message)
}
case NAS_EPS_MOBILE_IDENTITY_GUTI:
{
nas_eps_mobile_identity_guti_t *nas_guti = NULL;
nas_guti = &eps_mobile_identity->guti;
nas_guti_t guti;
nas_eps_mobile_identity_guti_t *nas_eps_mobile_identity_guti =
&eps_mobile_identity->guti;
nas_guti_t nas_guti;
guti.plmn_id = nas_guti->plmn_id;
guti.mme_gid = nas_guti->mme_gid;
guti.mme_code = nas_guti->mme_code;
guti.m_tmsi = nas_guti->m_tmsi;
nas_guti.nas_plmn_id = nas_eps_mobile_identity_guti->nas_plmn_id;
nas_guti.mme_gid = nas_eps_mobile_identity_guti->mme_gid;
nas_guti.mme_code = nas_eps_mobile_identity_guti->mme_code;
nas_guti.m_tmsi = nas_eps_mobile_identity_guti->m_tmsi;
mme_ue = mme_ue_find_by_guti(&guti);
mme_ue = mme_ue_find_by_guti(&nas_guti);
if (mme_ue) {
ogs_trace("Known UE by GUTI[G:%d,C:%d,M_TMSI:0x%x]",
guti.mme_gid,
guti.mme_code,
guti.m_tmsi);
nas_guti.mme_gid,
nas_guti.mme_code,
nas_guti.m_tmsi);
} else {
ogs_warn("Unknown UE by GUTI[G:%d,C:%d,M_TMSI:0x%x]",
guti.mme_gid,
guti.mme_code,
guti.m_tmsi);
nas_guti.mme_gid,
nas_guti.mme_code,
nas_guti.m_tmsi);
}
break;
}
@ -2193,26 +2193,26 @@ mme_ue_t* mme_ue_find_by_message(nas_message_t *message)
switch(eps_mobile_identity->imsi.type) {
case NAS_EPS_MOBILE_IDENTITY_GUTI:
{
nas_eps_mobile_identity_guti_t *nas_guti = NULL;
nas_guti = &eps_mobile_identity->guti;
nas_guti_t guti;
nas_eps_mobile_identity_guti_t *nas_eps_mobile_identity_guti =
&eps_mobile_identity->guti;
nas_guti_t nas_guti;
guti.plmn_id = nas_guti->plmn_id;
guti.mme_gid = nas_guti->mme_gid;
guti.mme_code = nas_guti->mme_code;
guti.m_tmsi = nas_guti->m_tmsi;
nas_guti.nas_plmn_id = nas_eps_mobile_identity_guti->nas_plmn_id;
nas_guti.mme_gid = nas_eps_mobile_identity_guti->mme_gid;
nas_guti.mme_code = nas_eps_mobile_identity_guti->mme_code;
nas_guti.m_tmsi = nas_eps_mobile_identity_guti->m_tmsi;
mme_ue = mme_ue_find_by_guti(&guti);
mme_ue = mme_ue_find_by_guti(&nas_guti);
if (mme_ue) {
ogs_trace("Known UE by GUTI[G:%d,C:%d,M_TMSI:0x%x]",
guti.mme_gid,
guti.mme_code,
guti.m_tmsi);
nas_guti.mme_gid,
nas_guti.mme_code,
nas_guti.m_tmsi);
} else {
ogs_warn("Unknown UE by GUTI[G:%d,C:%d,M_TMSI:0x%x]",
guti.mme_gid,
guti.mme_code,
guti.m_tmsi);
nas_guti.mme_gid,
nas_guti.mme_code,
nas_guti.m_tmsi);
}
break;
}

View File

@ -112,11 +112,12 @@ void mme_s11_handle_create_session_response(
if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_initial_context_setup)) {
mme_vlr_t *vlr = mme_vlr_find_by_tai(&mme_ue->tai);
mme_ue->vlr = vlr;
if (mme_ue->vlr) {
if (vlr)
sgsap_send_location_update_request(mme_ue);
} else {
else
nas_send_attach_accept(mme_ue);
}
} else if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_registered)) {
nas_send_activate_default_bearer_context_request(bearer);
} else

View File

@ -239,7 +239,7 @@ void s1ap_handle_initial_ue_message(mme_enb_t *enb, s1ap_message_t *message)
memset(&nas_guti, 0, sizeof(nas_guti_t));
/* Use the first configured plmn_id and mme group id */
nas_from_plmn_id(&nas_guti.plmn_id, &served_gummei->plmn_id[0]);
nas_from_plmn_id(&nas_guti.nas_plmn_id, &served_gummei->plmn_id[0]);
nas_guti.mme_gid = served_gummei->mme_gid[0];
/* size must be 1 */

View File

@ -95,5 +95,8 @@ error:
enb_ue = mme_ue->enb_ue;
ogs_assert(enb_ue);
nas_send_attach_reject(mme_ue,
EMM_CAUSE_EPS_SERVICES_AND_NON_EPS_SERVICES_NOT_ALLOWED,
ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
mme_send_delete_session_or_ue_context_release(mme_ue, enb_ue);
}

View File

@ -88,14 +88,22 @@ int sgsap_send_to_vlr_with_sid(
ogs_assert(sock);
ogs_debug(" IP[%s] TAI[MCC:%d%d%d,MNC:%d%d%d,TAC:%d]",
OGS_ADDR(node->addr, buf),
vlr->tai.plmn_id.mcc1, vlr->tai.plmn_id.mcc2, vlr->tai.plmn_id.mcc3,
vlr->tai.plmn_id.mnc1, vlr->tai.plmn_id.mnc2, vlr->tai.plmn_id.mnc3,
vlr->tai.tac);
OGS_ADDR(node->addr, buf),
vlr->tai.nas_plmn_id.mcc1,
vlr->tai.nas_plmn_id.mcc2,
vlr->tai.nas_plmn_id.mcc3,
vlr->tai.nas_plmn_id.mnc1,
vlr->tai.nas_plmn_id.mnc2,
vlr->tai.nas_plmn_id.mnc3,
vlr->tai.tac);
ogs_debug(" LAI[MCC:%d%d%d,MNC:%d%d%d,TAC:%d]",
vlr->lai.plmn_id.mcc1, vlr->lai.plmn_id.mcc2, vlr->lai.plmn_id.mcc3,
vlr->lai.plmn_id.mnc1, vlr->lai.plmn_id.mnc2, vlr->lai.plmn_id.mnc3,
vlr->lai.lac);
vlr->lai.nas_plmn_id.mcc1,
vlr->lai.nas_plmn_id.mcc2,
vlr->lai.nas_plmn_id.mcc3,
vlr->lai.nas_plmn_id.mnc1,
vlr->lai.nas_plmn_id.mnc2,
vlr->lai.nas_plmn_id.mnc3,
vlr->lai.lac);
rv = sgsap_send(sock, pkbuf, node->addr, stream_no);
if (rv != OGS_OK) {

View File

@ -43,13 +43,13 @@ static void test1_func(abts_case *tc, void *data)
"6d6503657063066d 6e63303730066d63 633930310b336770 706e6574776f726b"
"036f72670a010104 0509f1070926";
char *_initial_context_setup_request =
"00090080c8000006 0000000200010008 000200010042000a 183d090000603d09"
"00000018007a0000 340075450009230f 807f000002000000 01662775a81d1902"
"07420249062009f1 07000700415234c1 01090908696e7465 726e657405012d2d"
"00025e06fefee2e2 0303272280802110 0200001081060808 0808830608080404"
"000d040808080800 0d0408080404500b f609f107000201de 0008885949640101"
"006b00051c000e00 0000490020f9f4f8 0b206c33ae286c6d aff4c253585174c3"
"a0a12a661967f5e1 ba0a686c8c";
"00090080d7000006 0000000200010008 000200010042000a 183d090000603d09"
"0000001800808800 0034008082450009 230f807f00000200 0000017327283f4c"
"6102074202490620 09f1070007004152 34c101090908696e 7465726e65740501"
"2d2d00025e06fefe e2e2030327228080 2110020000108106 0808080883060808"
"0404000d04080808 08000d0408080404 500bf609f1070002 01d20064c31309f1"
"0709262305f49ee8 8e64594964010100 6b00051c000e0000 00490020f9f4f80b"
"206c33ae286c6daf f4c253585174c3a0 a12a661967f5e1ba 0a686c8c";
char *_emm_information =
"000b403800000300 0000020001000800 020001001a002524 2751034124030761"
"430f10004e006500 7800740045005000 4347916051216124 63490100";
@ -226,9 +226,9 @@ static void test1_func(abts_case *tc, void *data)
ABTS_PTR_NOTNULL(tc, recvbuf);
OGS_HEX(_initial_context_setup_request,
strlen(_initial_context_setup_request), tmp);
ABTS_TRUE(tc, memcmp(recvbuf->data, tmp, 59) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data+63, tmp+63, 88) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data+155, tmp+155, 50) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data, tmp, 61) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data+65, tmp+65, 88) == 0);
ABTS_TRUE(tc, memcmp(recvbuf->data+157, tmp+157, 63) == 0);
ogs_pkbuf_free(recvbuf);
/* Send Initial Context Setup Response */

View File

@ -81,7 +81,7 @@ static void nas_message_test2(abts_case *tc, void *data)
attach_accept->presencemask |= NAS_ATTACH_ACCEPT_GUTI_PRESENT;
attach_accept->guti.length = 11;
attach_accept->guti.guti.type = NAS_EPS_MOBILE_IDENTITY_GUTI;
nas_from_plmn_id(&attach_accept->guti.guti.plmn_id,
nas_from_plmn_id(&attach_accept->guti.guti.nas_plmn_id,
plmn_id_build(&plmn_id, 417, 99, 2));
attach_accept->guti.guti.mme_gid = 9029;
attach_accept->guti.guti.mme_code = 225;
@ -89,7 +89,7 @@ static void nas_message_test2(abts_case *tc, void *data)
attach_accept->presencemask |=
NAS_ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT;
nas_from_plmn_id(&attach_accept->location_area_identification.plmn_id,
nas_from_plmn_id(&attach_accept->location_area_identification.nas_plmn_id,
plmn_id_build(&plmn_id, 1, 2, 2));
attach_accept->location_area_identification.lac = 0xfffd;