[SGsAP] update it

This commit is contained in:
Sukchan Lee 2019-06-21 18:23:29 +09:00
parent c284ef7429
commit bbc594330b
20 changed files with 70 additions and 82 deletions

View File

@ -64,19 +64,15 @@ void *plmn_id_build(plmn_id_t *plmn_id,
return plmn_id;
}
int apn_build(char *dst, char *src, int length)
int fqdn_build(char *dst, char *src, int length)
{
int i = 0, j = 0;
for (i = 0, j = 0; i < length; i++, j++)
{
if (src[i] == '.')
{
for (i = 0, j = 0; i < length; i++, j++) {
if (src[i] == '.') {
dst[i-j] = j;
j = -1;
}
else
{
} else {
dst[i+1] = src[i];
}
}
@ -85,13 +81,12 @@ int apn_build(char *dst, char *src, int length)
return length+1;
}
int apn_parse(char *dst, char *src, int length)
int fqdn_parse(char *dst, char *src, int length)
{
int i = 0, j = 0;
uint8_t len = 0;
do
{
do {
len = src[i++];
memcpy(&dst[j], &src[i], len);
@ -125,8 +120,7 @@ int pco_parse(pco_t *pco, void *data, int data_len)
pco->configuration_protocol = source->configuration_protocol;
size++;
while(size < data_len && i < MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID)
{
while(size < data_len && i < MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID) {
pco_id_t *id = &pco->ids[i];
ogs_assert(size + sizeof(id->id) <= data_len);
memcpy(&id->id, data + size, sizeof(id->id));
@ -164,8 +158,7 @@ int pco_build(void *data, int data_len, pco_t *pco)
size += 1;
ogs_assert(target.num_of_id <= MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID);
for (i = 0; i < target.num_of_id; i++)
{
for (i = 0; i < target.num_of_id; i++) {
pco_id_t *id = &target.ids[i];
ogs_assert(size + sizeof(id->id) <= data_len);
@ -184,4 +177,3 @@ int pco_build(void *data, int data_len, pco_t *pco)
return size;
}

View File

@ -285,8 +285,8 @@ typedef struct pdn_s {
ip_t pgw_ip;
} pdn_t;
int apn_build(char *dst, char *src, int len);
int apn_parse(char *dst, char *src, int len);
int fqdn_build(char *dst, char *src, int len);
int fqdn_parse(char *dst, char *src, int len);
/**************************************************
* Protocol Configuration Options Structure

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by nas-message.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2019-06-11 17:27:29.685234 by acetcom
* Created on: 2019-06-21 14:10:51.931135 by acetcom
* from 24301-d80.docx
******************************************************************************/

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by nas-message.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2019-06-11 17:27:29.711227 by acetcom
* Created on: 2019-06-21 14:10:51.957409 by acetcom
* from 24301-d80.docx
******************************************************************************/

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by nas-message.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2019-06-11 17:27:29.648106 by acetcom
* Created on: 2019-06-21 14:10:51.889878 by acetcom
* from 24301-d80.docx
******************************************************************************/
@ -2123,7 +2123,7 @@ int nas_decode_access_point_name(nas_access_point_name_t *access_point_name, ogs
{
char apn[MAX_APN_LEN];
access_point_name->length = apn_parse(apn, access_point_name->apn, access_point_name->length);
access_point_name->length = fqdn_parse(apn, access_point_name->apn, access_point_name->length);
ogs_cpystrn(access_point_name->apn, apn, ogs_min(access_point_name->length, MAX_APN_LEN) + 1);
}
@ -2139,7 +2139,7 @@ int nas_encode_access_point_name(ogs_pkbuf_t *pkbuf, nas_access_point_name_t *ac
nas_access_point_name_t target;
memcpy(&target, access_point_name, sizeof(nas_access_point_name_t));
target.length = apn_build(target.apn, access_point_name->apn, access_point_name->length);
target.length = fqdn_build(target.apn, access_point_name->apn, access_point_name->length);
size = target.length + sizeof(target.length);
ogs_assert(ogs_pkbuf_pull(pkbuf, size));

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by nas-message.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2019-06-11 17:27:29.642367 by acetcom
* Created on: 2019-06-21 14:10:51.884139 by acetcom
* from 24301-d80.docx
******************************************************************************/

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by nas-message.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2019-06-11 17:27:29.664161 by acetcom
* Created on: 2019-06-21 14:10:51.908774 by acetcom
* from 24301-d80.docx
******************************************************************************/

View File

@ -79,10 +79,10 @@ type_list["Short MAC"]["encode"] = \
type_list["Access point name"]["decode"] = \
" {\n" \
" char apn[MAX_APN_LEN];\n" \
" access_point_name->length = apn_parse(apn, access_point_name->apn, access_point_name->length);\n" \
" access_point_name->length = fqdn_parse(apn, access_point_name->apn, access_point_name->length);\n" \
" ogs_cpystrn(access_point_name->apn, apn, ogs_min(access_point_name->length, MAX_APN_LEN) + 1);\n" \
" }\n\n"
type_list["Access point name"]["encode"] = \
" target.length = apn_build(target.apn, access_point_name->apn, access_point_name->length);\n" \
" target.length = fqdn_build(target.apn, access_point_name->apn, access_point_name->length);\n" \
" size = target.length + sizeof(target.length);\n\n"

View File

@ -126,7 +126,7 @@ int mme_s11_build_create_session_request(
}
req->access_point_name.presence = 1;
req->access_point_name.len = apn_build(apn, pdn->apn, strlen(pdn->apn));
req->access_point_name.len = fqdn_build(apn, pdn->apn, strlen(pdn->apn));
req->access_point_name.data = apn;
req->selection_mode.presence = 1;

View File

@ -30,9 +30,9 @@ ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue)
ogs_pkbuf_t *pkbuf = NULL;
char mme_name[SGSAP_IE_MME_NAME_LEN+1];
int mme_name_len = 0;
served_gummei_t *served_gummei = &mme_self()->served_gummei[0];
char eps_update_type;
uint32_t len;
nas_lai_t lai;
ogs_assert(mme_ue);
@ -42,11 +42,11 @@ ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue)
root = ogs_tlv_add(NULL, SGSAP_IE_IMSI_TYPE, SGSAP_IE_IMSI_LEN, 0,
(uint8_t *)&mme_ue->nas_mobile_identity_imsi);
mme_name_build(mme_name, SGSAP_IE_MME_NAME_LEN+1,
mme_name_len = mme_name_build(mme_name,
served_gummei->mme_code[0],
served_gummei->mme_gid[0],
&served_gummei->plmn_id[0]);;
ogs_tlv_add(root, SGSAP_IE_MME_NAME_TYPE, strlen(mme_name), 0,
&served_gummei->plmn_id[0]);
ogs_tlv_add(root, SGSAP_IE_MME_NAME_TYPE, mme_name_len, 0,
(uint8_t *)mme_name);
eps_update_type = SGSAP_EPS_UPDATE_IMSI_ATTACH;
ogs_tlv_add(root, SGSAP_IE_EPS_UPDATE_TYPE, SGSAP_IE_EPS_UPDATE_LEN, 0,
@ -59,11 +59,11 @@ ogs_pkbuf_t *sgsap_build_location_update_request(mme_ue_t *mme_ue)
pkbuf = ogs_pkbuf_alloc(NULL, 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);
ogs_pkbuf_trim(pkbuf, 1+ogs_tlv_render(root,
pkbuf->data+1, MAX_SDU_LEN-1, OGS_TLV_MODE_T1_L1));
ogs_tlv_free_all(root);
ogs_pkbuf_trim(pkbuf, len+1);
return pkbuf;
}

View File

@ -17,19 +17,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "sgsap-types.h"
#include "sgsap-conv.h"
char *mme_name_build(char *buf, size_t size,
int mme_name_build(char *buf,
uint32_t mme_code, uint16_t mme_gid, plmn_id_t *plmn_id)
{
int len;
char temp[SGSAP_IE_MME_NAME_LEN];
ogs_assert(buf);
ogs_assert(plmn_id);
if (ogs_snprintf(buf, size,
len = ogs_snprintf(temp, SGSAP_IE_MME_NAME_LEN,
"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) {
ogs_error("Cannot make MME name");
return NULL;
mme_code, mme_gid, plmn_id_mnc(plmn_id), plmn_id_mcc(plmn_id));
if (len < 0) {
ogs_assert_if_reached();
}
return buf;
return fqdn_build(buf, temp, len);
}

View File

@ -26,7 +26,7 @@
extern "C" {
#endif
char *mme_name_build(char *buf, size_t size,
int mme_name_build(char *buf,
uint32_t mme_code, uint16_t mme_gid, plmn_id_t *plmn_id);
#ifdef __cplusplus

View File

@ -894,7 +894,7 @@ pgw_sess_t *pgw_sess_add_by_message(gtp_message_t *message)
return NULL;
}
apn_parse(apn, req->access_point_name.data, req->access_point_name.len);
fqdn_parse(apn, req->access_point_name.data, req->access_point_name.len);
ogs_trace("pgw_sess_add_by_message() [APN:%s, PDN:%d, EDI:%d]",
apn, req->pdn_type.u8,

View File

@ -58,7 +58,8 @@ void sgw_s11_handle_create_session_request(
return;
}
apn_parse(apn, req->access_point_name.data, req->access_point_name.len);
fqdn_parse(apn,
req->access_point_name.data, req->access_point_name.len);
sess = sgw_sess_add(sgw_ue, apn,
req->bearer_contexts_to_be_created.eps_bearer_id.u8);
ogs_assert(sess);

View File

@ -132,8 +132,7 @@ static void attach_test1(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -574,8 +573,7 @@ static void attach_test2(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456826"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -590,8 +588,7 @@ static void attach_test2(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010000000003"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -897,8 +894,7 @@ static void attach_test3(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456797"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -1194,8 +1190,7 @@ static void attach_test4(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -1368,8 +1363,7 @@ static void attach_test5(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456937"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -1706,8 +1700,7 @@ static void attach_test6(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);

View File

@ -152,8 +152,7 @@ static void handover_test1(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456801"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -458,8 +457,7 @@ static void handover_test2(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456815"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);

View File

@ -16,14 +16,12 @@ static void s1setup_test1(abts_case *tc, void *data)
s1ap_message_t message;
int i;
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
{
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++) {
node[i] = testenb_s1ap_client("127.0.0.1");
ABTS_PTR_NOTNULL(tc, node[i]);
}
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
{
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++) {
rv = tests1ap_build_setup_req(
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x54f64, 12345, 1, 1, 2);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
@ -41,8 +39,7 @@ static void s1setup_test1(abts_case *tc, void *data)
ogs_pkbuf_free(recvbuf);
}
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
{
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++) {
testenb_s1ap_close(node[i]);
}
@ -60,14 +57,12 @@ static void s1setup_test2(abts_case *tc, void *data)
s1ap_message_t message;
int i;
for (i = 0; i < NUM_OF_TEST_ENB; i++)
{
for (i = 0; i < NUM_OF_TEST_ENB; i++) {
node[i] = testenb_s1ap_client("127.0.0.1");
ABTS_PTR_NOTNULL(tc, node[i]);
}
for (i = 0; i < NUM_OF_TEST_ENB; i++)
{
for (i = 0; i < NUM_OF_TEST_ENB; i++) {
rv = tests1ap_build_setup_req(
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x54f64+i, 12345, 1, 1, 2);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
@ -85,8 +80,7 @@ static void s1setup_test2(abts_case *tc, void *data)
ogs_pkbuf_free(recvbuf);
}
for (i = 0; i < NUM_OF_TEST_ENB; i++)
{
for (i = 0; i < NUM_OF_TEST_ENB; i++) {
testenb_s1ap_close(node[i]);
}

View File

@ -126,8 +126,7 @@ static void volte_test1(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -423,8 +422,7 @@ static void volte_test2(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);

View File

@ -38,6 +38,10 @@ static void test1_func(abts_case *tc, void *data)
char *_esm_information_request =
"000b401d00000300 0000020001000800 020001001a000a09 27d1237969010234"
"d9";
char *_sgsap_location_update_request =
"0901082926240000 1118930937066d6d 65633031096d6d65 676930303032036d"
"6d6503657063066d 6e63303730066d63 633930310b336770 706e6574776f726b"
"036f72670a010104 0509f1070926";
char *_initial_context_setup_request =
"00090080c8000006 0000000200010008 000200010042000a 183d090000603d09"
"00000018007a0000 340075450009230f 807f000002000000 01662775a81d1902"
@ -132,8 +136,7 @@ static void test1_func(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("262420000118139"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
@ -204,8 +207,14 @@ static void test1_func(abts_case *tc, void *data)
/* Receive SGsAP-Location-Update-Request */
recvbuf = testvlr_sgsap_read(sgsap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ABTS_TRUE(tc, memcmp(recvbuf->data,
OGS_HEX(_sgsap_location_update_request,
strlen(_sgsap_location_update_request), tmp),
recvbuf->len) == 0);
ogs_pkbuf_free(recvbuf);
/* Send SGsAP-Location-Update-Accept */
#if 0
/* Receive Initial Context Setup Request +
* Attach Accept +

View File

@ -129,8 +129,7 @@ static void test1_func(abts_case *tc, void *data)
doc = BCON_NEW("imsi", BCON_UTF8("310014987654004"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
do {
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);