forked from acouzens/open5gs
Default APN is added
This commit is contained in:
parent
0557be8ffd
commit
a864b36f44
|
@ -41,6 +41,7 @@ typedef struct _s6a_subscription_data_t {
|
|||
bitrate_t ambr; /* UE-AMBR */
|
||||
c_uint32_t subscribed_rau_tau_timer; /* unit : minutes */
|
||||
|
||||
c_uint32_t context_identifier; /* default APN */
|
||||
pdn_t pdn[MAX_NUM_OF_SESS];
|
||||
int num_of_pdn;
|
||||
} s6a_subscription_data_t;
|
||||
|
|
|
@ -49,6 +49,15 @@ status_t esm_handle_pdn_connectivity_request(mme_bearer_t *bearer,
|
|||
{
|
||||
sess->pdn = mme_pdn_find_by_apn(mme_ue,
|
||||
pdn_connectivity_request->access_point_name.apn);
|
||||
if (!sess->pdn)
|
||||
{
|
||||
/* Invalid APN */
|
||||
rv = nas_send_pdn_connectivity_reject(
|
||||
sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN);
|
||||
d_assert(rv == CORE_OK,, "nas send failed");
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (pdn_connectivity_request->presencemask &
|
||||
|
@ -64,22 +73,28 @@ status_t esm_handle_pdn_connectivity_request(mme_bearer_t *bearer,
|
|||
{
|
||||
rv = nas_send_esm_information_request(bearer);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR, "nas send failed");
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
if (!sess->pdn)
|
||||
{
|
||||
/* Default APN */
|
||||
sess->pdn = mme_default_pdn(mme_ue);
|
||||
}
|
||||
|
||||
if (sess->pdn)
|
||||
{
|
||||
rv = mme_gtp_send_create_session_request(sess);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR, "gtp send failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sess->pdn)
|
||||
{
|
||||
rv = mme_gtp_send_create_session_request(sess);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR, "gtp send failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = nas_send_pdn_connectivity_reject(
|
||||
sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN);
|
||||
d_assert(rv == CORE_OK,, "nas send failed");
|
||||
rv = nas_send_pdn_connectivity_reject(
|
||||
sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN);
|
||||
d_assert(rv == CORE_OK,, "nas send failed");
|
||||
|
||||
return CORE_ERROR;
|
||||
}
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
|
|
|
@ -2424,6 +2424,26 @@ pdn_t* mme_pdn_find_by_apn(mme_ue_t *mme_ue, c_int8_t *apn)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pdn_t* mme_default_pdn(mme_ue_t *mme_ue)
|
||||
{
|
||||
s6a_subscription_data_t *subscription_data = NULL;
|
||||
pdn_t *pdn = NULL;
|
||||
int i = 0;
|
||||
|
||||
d_assert(mme_ue, return NULL, "Null param");
|
||||
subscription_data = &mme_ue->subscription_data;
|
||||
d_assert(subscription_data, return NULL, "Null param");
|
||||
|
||||
for (i = 0; i < subscription_data->num_of_pdn; i++)
|
||||
{
|
||||
pdn = &subscription_data->pdn[i];
|
||||
if (pdn->context_identifier == subscription_data->context_identifier)
|
||||
return pdn;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mme_find_served_tai(tai_t *tai)
|
||||
{
|
||||
int i = 0, j = 0, k = 0;
|
||||
|
|
|
@ -513,6 +513,7 @@ CORE_DECLARE(pdn_t*) mme_pdn_add(mme_ue_t *mme_ue, c_int8_t *apn);
|
|||
CORE_DECLARE(status_t) mme_pdn_remove_all(mme_ue_t *mme_ue);
|
||||
CORE_DECLARE(pdn_t*) mme_pdn_find_by_apn(
|
||||
mme_ue_t *mme_ue, c_int8_t *apn);
|
||||
CORE_DECLARE(pdn_t*) mme_default_pdn(mme_ue_t *mme_ue);
|
||||
|
||||
CORE_DECLARE(int) mme_find_served_tai(tai_t *tai);
|
||||
|
||||
|
|
|
@ -647,7 +647,11 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg)
|
|||
switch(hdr->avp_code)
|
||||
{
|
||||
case S6A_AVP_CODE_CONTEXT_IDENTIFIER:
|
||||
{
|
||||
subscription_data->context_identifier =
|
||||
hdr->avp_value->i32;
|
||||
break;
|
||||
}
|
||||
case S6A_AVP_CODE_ALL_APN_CONFIG_INC_IND:
|
||||
break;
|
||||
case S6A_AVP_CODE_APN_CONFIGURATION:
|
||||
|
|
|
@ -463,7 +463,7 @@ static void attach_test2(abts_case *tc, void *data)
|
|||
const char *json2 =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c7\" }, "
|
||||
"\"imsi\" : \"001010000000002\", "
|
||||
"\"imsi\" : \"001010000000003\", "
|
||||
"\"pdn\" : ["
|
||||
"{"
|
||||
"\"apn\" : \"internet\", "
|
||||
|
@ -554,7 +554,7 @@ static void attach_test2(abts_case *tc, void *data)
|
|||
MONGOC_INSERT_NONE, doc, NULL, &error));
|
||||
bson_destroy(doc);
|
||||
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010000000003"));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
do
|
||||
{
|
||||
|
@ -717,7 +717,7 @@ static void attach_test2(abts_case *tc, void *data)
|
|||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
bson_destroy(doc);
|
||||
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010000000003"));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_TRUE(tc, mongoc_collection_remove(collection,
|
||||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
|
@ -1030,6 +1030,186 @@ static void attach_test3(abts_case *tc, void *data)
|
|||
core_sleep(time_from_msec(300));
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* eNB : MACRO
|
||||
* UE : IMSI
|
||||
* Protocol Configuration Options without default APN */
|
||||
static void attach_test4(abts_case *tc, void *data)
|
||||
{
|
||||
status_t rv;
|
||||
sock_id sock;
|
||||
sock_id gtpu;
|
||||
pkbuf_t *sendbuf;
|
||||
pkbuf_t *recvbuf;
|
||||
s1ap_message_t message;
|
||||
int i;
|
||||
int msgindex = 8;
|
||||
|
||||
c_uint8_t tmp[MAX_SDU_LEN];
|
||||
|
||||
mongoc_collection_t *collection = NULL;
|
||||
bson_t *doc = NULL;
|
||||
c_int64_t count = 0;
|
||||
bson_error_t error;
|
||||
const char *json =
|
||||
"{"
|
||||
"\"_id\" : { \"$oid\" : \"597223258b8861d7605378c7\" }, "
|
||||
"\"imsi\" : \"001010000000002\", "
|
||||
"\"pdn\" : ["
|
||||
"{"
|
||||
"\"apn\" : \"internet\", "
|
||||
"\"_id\" : { \"$oid\" : \"598223158b8861d7605378c8\" }, "
|
||||
"\"ambr\" : {"
|
||||
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
|
||||
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
|
||||
"},"
|
||||
"\"qos\" : { "
|
||||
"\"qci\" : 9, "
|
||||
"\"arp\" : { "
|
||||
"\"priority_level\" : 8,"
|
||||
"\"pre_emption_vulnerability\" : 1, "
|
||||
"\"pre_emption_capability\" : 1"
|
||||
"} "
|
||||
"}, "
|
||||
"\"type\" : 2"
|
||||
"}"
|
||||
"],"
|
||||
"\"ambr\" : { "
|
||||
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
|
||||
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
|
||||
"},"
|
||||
"\"subscribed_rau_tau_timer\" : 12,"
|
||||
"\"network_access_mode\" : 2, "
|
||||
"\"subscriber_status\" : 0, "
|
||||
"\"access_restriction_data\" : 32, "
|
||||
"\"security\" : { "
|
||||
"\"k\" : \"00112233 44556677 8899AABB CCDDEEFF\", "
|
||||
"\"opc\" : \"00010203 04050607 08090A0B 0C0D0E0F\", "
|
||||
"\"amf\" : \"9001\", "
|
||||
"\"sqn\" : { \"$numberLong\" : \"96\" }, "
|
||||
"\"rand\" : \"9bdbfb93 16be4d52 80153094 38326671\" "
|
||||
"}, "
|
||||
"\"__v\" : 0 "
|
||||
"}";
|
||||
|
||||
core_sleep(time_from_msec(300));
|
||||
|
||||
/* eNB connects to MME */
|
||||
rv = tests1ap_enb_connect(&sock);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* eNB connects to SGW */
|
||||
rv = testgtpu_enb_connect(>pu);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Send S1-Setup Reqeust */
|
||||
rv = tests1ap_build_setup_req(
|
||||
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive S1-Setup Response */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rv = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = s1ap_decode_pdu(&message, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
s1ap_free_pdu(&message);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
collection = mongoc_client_get_collection(
|
||||
context_self()->db_client,
|
||||
context_self()->db_name, "subscribers");
|
||||
ABTS_PTR_NOTNULL(tc, collection);
|
||||
|
||||
/********** Insert Subscriber in Database */
|
||||
doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_TRUE(tc, mongoc_collection_insert(collection,
|
||||
MONGOC_INSERT_NONE, doc, NULL, &error));
|
||||
bson_destroy(doc);
|
||||
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
do
|
||||
{
|
||||
count = mongoc_collection_count (
|
||||
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
|
||||
} while (count == 0);
|
||||
bson_destroy(doc);
|
||||
|
||||
/***********************************************************************
|
||||
* Attach Request : Known IMSI, Integrity Protected, No Security Context
|
||||
* Send Initial-UE Message + Attach Request + PDN Connectivity */
|
||||
core_sleep(time_from_msec(300));
|
||||
|
||||
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive Authentication Request */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rv = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send Authentication Response */
|
||||
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive Security mode Command */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rv = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
/* Send Security mode Complete */
|
||||
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = tests1ap_enb_send(sock, sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* Receive Initial Context Setup Request */
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rv = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
core_sleep(time_from_msec(300));
|
||||
|
||||
#if 0
|
||||
rv = testgtpu_build_slacc_rs(&sendbuf, 0);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
rv = testgtpu_enb_send(sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
rv = testgtpu_enb_read(gtpu, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
pkbuf_free(recvbuf);
|
||||
#endif
|
||||
|
||||
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
|
||||
ABTS_PTR_NOTNULL(tc, doc);
|
||||
ABTS_TRUE(tc, mongoc_collection_remove(collection,
|
||||
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
|
||||
bson_destroy(doc);
|
||||
|
||||
mongoc_collection_destroy(collection);
|
||||
|
||||
/* eNB disonncect from MME */
|
||||
rv = tests1ap_enb_close(sock);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
/* eNB disonncect from SGW */
|
||||
rv = testgtpu_enb_close(gtpu);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
}
|
||||
|
||||
abts_suite *test_attach(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
@ -1037,6 +1217,7 @@ abts_suite *test_attach(abts_suite *suite)
|
|||
abts_run_test(suite, attach_test1, NULL);
|
||||
abts_run_test(suite, attach_test2, NULL);
|
||||
abts_run_test(suite, attach_test3, NULL);
|
||||
abts_run_test(suite, attach_test4, NULL);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
"0000f11030390064 40080000f1109d67 aa500086400130",
|
||||
|
||||
"000c405300000500 080003002100001a 002a2917bcba67c4 8207410108091010"
|
||||
"000000002005f0f0 000000000e023cd0 11d1270780000a00 000d00c100430006"
|
||||
"000000003005f0f0 000000000e023cd0 11d1270780000a00 000d00c100430006"
|
||||
"0000f11030390064 40080000f1109d67 aa500086400130",
|
||||
|
||||
|
||||
|
@ -185,8 +185,11 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
"0000000e0201d011 d1270780000a0000 0d00c10043000600 00f1103039006440"
|
||||
"080000f11054f640 100086400130",
|
||||
"",
|
||||
"",
|
||||
|
||||
"000c"
|
||||
"4070000005000800 020001001a004847 0741720809101000 0000002004f07000"
|
||||
"000023020ed03127 1d80802110010000 1081060000000083 0600000000000d00"
|
||||
"000300000a005c0a 003103e5e0349011 035758a65d010000 4300060000f11030"
|
||||
"39006440080000f1 100019b010008640 0130",
|
||||
|
||||
"000c"
|
||||
"4068000005000800 020001001a00403f 0741720809101010 3254861002e06000"
|
||||
|
@ -201,6 +204,9 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
"004300060000f110 3039006440080000 f110001f20a00086 400130004b000700"
|
||||
"00f110000201",
|
||||
|
||||
"",
|
||||
|
||||
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
92,
|
||||
|
@ -213,10 +219,12 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
|
||||
80,
|
||||
0,
|
||||
0,
|
||||
116,
|
||||
|
||||
108,
|
||||
136,
|
||||
0,
|
||||
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
|
@ -300,7 +308,9 @@ status_t tests1ap_build_authentication_response(pkbuf_t **pkbuf, int i)
|
|||
"4038000005000000 05c0020000c80008 00020002001a000c 0b0753087dc78e7c"
|
||||
"421f9eb900644008 0000f11054f64010 004340060000f110 2b67",
|
||||
"",
|
||||
"",
|
||||
"000d"
|
||||
"4035000005000000 0200010008000200 01001a000c0b0753 08d8b388ddacaa1f"
|
||||
"36006440080000f1 100019b010004340 060000f1100001",
|
||||
|
||||
|
||||
"000d"
|
||||
|
@ -324,7 +334,7 @@ status_t tests1ap_build_authentication_response(pkbuf_t **pkbuf, int i)
|
|||
|
||||
60,
|
||||
0,
|
||||
0,
|
||||
57,
|
||||
|
||||
60,
|
||||
66,
|
||||
|
@ -411,7 +421,9 @@ status_t tests1ap_build_security_mode_complete(pkbuf_t **pkbuf, int i)
|
|||
"4035000005000000 05c0020000c80008 00020002001a0009 0847c0eb1eb80007"
|
||||
"5e006440080000f1 1054f64010004340 060000f1102b67",
|
||||
"",
|
||||
"",
|
||||
"000d"
|
||||
"4032000005000000 0200010008000200 01001a00090847c8 38f8d700075e0064"
|
||||
"40080000f1100019 b010004340060000 f1100001",
|
||||
|
||||
|
||||
"000d"
|
||||
|
@ -433,7 +445,7 @@ status_t tests1ap_build_security_mode_complete(pkbuf_t **pkbuf, int i)
|
|||
|
||||
57,
|
||||
0,
|
||||
0,
|
||||
54,
|
||||
|
||||
57,
|
||||
57,
|
||||
|
|
Loading…
Reference in New Issue