forked from acouzens/open5gs
[SGsAP] build LOCATION-UPDATE-REQUEST
This commit is contained in:
parent
95586eaf09
commit
c284ef7429
|
@ -128,6 +128,8 @@ int emm_handle_attach_request(
|
|||
{
|
||||
char imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
memcpy(&mme_ue->nas_mobile_identity_imsi,
|
||||
&eps_mobile_identity->imsi, sizeof(nas_mobile_identity_imsi_t));
|
||||
nas_imsi_to_bcd(
|
||||
&eps_mobile_identity->imsi, eps_mobile_identity->length,
|
||||
imsi_bcd);
|
||||
|
@ -284,6 +286,8 @@ int emm_handle_identity_response(
|
|||
{
|
||||
char imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
memcpy(&mme_ue->nas_mobile_identity_imsi,
|
||||
&mobile_identity->imsi, sizeof(nas_mobile_identity_imsi_t));
|
||||
nas_imsi_to_bcd(
|
||||
&mobile_identity->imsi, mobile_identity->length, imsi_bcd);
|
||||
mme_ue_set_imsi(mme_ue, imsi_bcd);
|
||||
|
|
|
@ -2137,7 +2137,6 @@ mme_ue_t* mme_ue_find_by_message(nas_message_t *message)
|
|||
&eps_mobile_identity->imsi, eps_mobile_identity->length,
|
||||
imsi_bcd);
|
||||
|
||||
|
||||
mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd);
|
||||
if (mme_ue) {
|
||||
ogs_trace("known UE by IMSI[%s]", imsi_bcd);
|
||||
|
|
|
@ -266,6 +266,7 @@ struct mme_ue_s {
|
|||
uint8_t imsi[MAX_IMSI_LEN];
|
||||
int imsi_len;
|
||||
char imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
nas_mobile_identity_imsi_t nas_mobile_identity_imsi;
|
||||
|
||||
mme_m_tmsi_t *m_tmsi;
|
||||
nas_guti_t guti;
|
||||
|
|
|
@ -19,29 +19,10 @@
|
|||
|
||||
#include "mme-context.h"
|
||||
|
||||
#include "sgsap-types.h"
|
||||
#include "sgsap-build.h"
|
||||
#include "sgsap-conv.h"
|
||||
|
||||
#define SGSAP_IE_IMSI_TYPE 1
|
||||
#define SGSAP_IE_IMSI_LEN MAX_IMSI_LEN
|
||||
#define SGSAP_IE_VLR_NAME_TYPE 2
|
||||
#define SGSAP_IE_VLR_NAME_LEN 256
|
||||
#define SGSAP_IE_LAI_TYPE 4
|
||||
#define SGSAP_IE_LAI_LEN 5
|
||||
#define SGSAP_IE_MME_NAME_TYPE 9
|
||||
#define SGSAP_IE_MME_NAME_LEN 55
|
||||
#define SGSAP_IE_EPS_UPDATE_TYPE 10
|
||||
#define SGSAP_IE_EPS_UPDATE_LEN 1
|
||||
#define SGSAP_IE_MOBILE_IDENTITY_TYPE 14
|
||||
#define SGSAP_IE_MOBILE_IDENTITY_LEN 5
|
||||
#define SGSAP_IE_SERVICE_INDICATOR_TYPE 32
|
||||
#define SGSAP_IE_SERVICE_INDICATOR_LEN 1
|
||||
#define SGSAP_IE_UE_EMM_MODE_TYPE 37
|
||||
#define SGSAP_IE_UE_EMM_MODE_LEN 1
|
||||
|
||||
#define SGSAP_EPS_UPDATE_IMSI_ATTACH 1
|
||||
#define SGSAP_EPS_UPDATE_NORMAL 2
|
||||
|
||||
ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue)
|
||||
{
|
||||
mme_vlr_t *vlr = NULL;
|
||||
|
@ -52,16 +33,16 @@ ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue)
|
|||
served_gummei_t *served_gummei = &mme_self()->served_gummei[0];
|
||||
char eps_update_type;
|
||||
uint32_t len;
|
||||
const char *p;
|
||||
nas_lai_t lai;
|
||||
|
||||
ogs_assert(mme_ue);
|
||||
vlr = mme_ue->vlr;
|
||||
ogs_assert(vlr);
|
||||
|
||||
root = ogs_tlv_add(NULL, SGSAP_IE_IMSI_TYPE, SGSAP_IE_IMSI_LEN, 0,
|
||||
mme_ue->imsi);
|
||||
(uint8_t *)&mme_ue->nas_mobile_identity_imsi);
|
||||
|
||||
sgsap_to_mme_name(mme_name, SGSAP_IE_MME_NAME_LEN+1,
|
||||
mme_name_build(mme_name, SGSAP_IE_MME_NAME_LEN+1,
|
||||
served_gummei->mme_code[0],
|
||||
served_gummei->mme_gid[0],
|
||||
&served_gummei->plmn_id[0]);;
|
||||
|
@ -70,23 +51,19 @@ ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue)
|
|||
eps_update_type = SGSAP_EPS_UPDATE_IMSI_ATTACH;
|
||||
ogs_tlv_add(root, SGSAP_IE_EPS_UPDATE_TYPE, SGSAP_IE_EPS_UPDATE_LEN, 0,
|
||||
(uint8_t *)&eps_update_type);
|
||||
memcpy(&lai, &vlr->lai, sizeof(nas_lai_t));
|
||||
lai.lac = htons(lai.lac);
|
||||
ogs_tlv_add(root, SGSAP_IE_LAI_TYPE, SGSAP_IE_LAI_LEN, 0,
|
||||
(uint8_t *)&vlr->lai);
|
||||
(uint8_t *)&lai);
|
||||
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, MAX_SDU_LEN);
|
||||
ogs_pkbuf_put(pkbuf, MAX_SDU_LEN);
|
||||
ogs_pkbuf_put_u8(pkbuf, SGSAP_LOCATION_UPDATE_REQUEST);
|
||||
ogs_pkbuf_put(pkbuf, MAX_SDU_LEN-1);
|
||||
len = ogs_tlv_render(root,
|
||||
pkbuf->data+1, MAX_SDU_LEN-1, OGS_TLV_MODE_T1_L1);
|
||||
p = pkbuf->data;
|
||||
|
||||
ogs_tlv_free_all(root);
|
||||
ogs_pkbuf_trim(pkbuf, len+1);
|
||||
printf("len = %d\n", len);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
const char *p = pkbuf->data;
|
||||
printf("%x\n", p[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
|
|
@ -20,22 +20,12 @@
|
|||
#ifndef SGSAP_BUILD_H
|
||||
#define SGSAP_BUILD_H
|
||||
|
||||
#include "asn1c/s1ap-message.h"
|
||||
#include "mme-context.h"
|
||||
|
||||
#include "sbc-message.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SGSAP_PAGING_REQUEST 1
|
||||
#define SGSAP_SERVICE_REQUEST 6
|
||||
#define SGSAP_LOCATION_UPDATE_REQUEST 9
|
||||
#define SGSAP_LOCATION_UPDATE_ACCEPT 10
|
||||
#define SGSAP_TMSI_REALLOCATION_COMPLETE 12
|
||||
#define SGSAP_MO_CSFB_INDICIATION 24
|
||||
|
||||
ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue);
|
||||
ogs_pkbuf_t *sgsap_build_tmsi_reallocation_complete(mme_ue_t *mme_ue);
|
||||
ogs_pkbuf_t *sgsap_build_service_request(mme_ue_t *mme_ue);
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
#include "sgsap-conv.h"
|
||||
|
||||
char *sgsap_to_mme_name(char *buf, size_t size,
|
||||
char *mme_name_build(char *buf, size_t size,
|
||||
uint32_t mme_code, uint16_t mme_gid, plmn_id_t *plmn_id)
|
||||
{
|
||||
ogs_assert(buf);
|
||||
ogs_assert(plmn_id);
|
||||
if (ogs_snprintf(buf, size,
|
||||
"mmec%02d.mmegi%04d.mme.epc.mnc%03d.mcc%03d.3gppnetwork.org",
|
||||
mme_code, mme_gid, plmn_id_mnc(plmn_id), plmn_id_mcc(plmn_id) < 0)) {
|
||||
mme_code, mme_gid, plmn_id_mnc(plmn_id), plmn_id_mcc(plmn_id)) < 0) {
|
||||
ogs_error("Cannot make MME name");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *sgsap_to_mme_name(char *buf, size_t size,
|
||||
char *mme_name_build(char *buf, size_t size,
|
||||
uint32_t mme_code, uint16_t mme_gid, plmn_id_t *plmn_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SGSAP_TYPES_H
|
||||
#define SGSAP_TYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SGSAP_PAGING_REQUEST 1
|
||||
#define SGSAP_SERVICE_REQUEST 6
|
||||
#define SGSAP_LOCATION_UPDATE_REQUEST 9
|
||||
#define SGSAP_LOCATION_UPDATE_ACCEPT 10
|
||||
#define SGSAP_TMSI_REALLOCATION_COMPLETE 12
|
||||
#define SGSAP_MO_CSFB_INDICIATION 24
|
||||
|
||||
#define SGSAP_IE_IMSI_TYPE 1
|
||||
#define SGSAP_IE_IMSI_LEN MAX_IMSI_LEN
|
||||
#define SGSAP_IE_VLR_NAME_TYPE 2
|
||||
#define SGSAP_IE_VLR_NAME_LEN 256
|
||||
#define SGSAP_IE_LAI_TYPE 4
|
||||
#define SGSAP_IE_LAI_LEN 5
|
||||
#define SGSAP_IE_MME_NAME_TYPE 9
|
||||
#define SGSAP_IE_MME_NAME_LEN 55
|
||||
#define SGSAP_IE_EPS_UPDATE_TYPE 10
|
||||
#define SGSAP_IE_EPS_UPDATE_LEN 1
|
||||
#define SGSAP_IE_MOBILE_IDENTITY_TYPE 14
|
||||
#define SGSAP_IE_MOBILE_IDENTITY_LEN 5
|
||||
#define SGSAP_IE_SERVICE_INDICATOR_TYPE 32
|
||||
#define SGSAP_IE_SERVICE_INDICATOR_LEN 1
|
||||
#define SGSAP_IE_UE_EMM_MODE_TYPE 37
|
||||
#define SGSAP_IE_UE_EMM_MODE_LEN 1
|
||||
|
||||
#define SGSAP_EPS_UPDATE_IMSI_ATTACH 1
|
||||
#define SGSAP_EPS_UPDATE_NORMAL 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SGSAP_TYPES_H */
|
|
@ -201,9 +201,11 @@ static void test1_func(abts_case *tc, void *data)
|
|||
rv = testenb_s1ap_send(s1ap, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
||||
/* Receive SGsAP-Location-Update-Request */
|
||||
recvbuf = testvlr_sgsap_read(sgsap);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
#if 0
|
||||
/* Receive Initial Context Setup Request +
|
||||
* Attach Accept +
|
||||
|
|
Loading…
Reference in New Issue