update it

This commit is contained in:
Sukchan Lee 2017-09-12 23:07:55 +09:00
parent 42b34d0f19
commit e45d1887a5
11 changed files with 754 additions and 67 deletions

View File

@ -1464,6 +1464,16 @@ status_t mme_associate_ue_context(mme_ue_t *mme_ue, enb_ue_t *enb_ue)
return CORE_OK;
}
status_t mme_partial_associate_ue_context(mme_ue_t *mme_ue, enb_ue_t *enb_ue)
{
d_assert(mme_ue, return CORE_ERROR, "Null param");
d_assert(enb_ue, return CORE_ERROR, "Null param");
enb_ue->mme_ue = mme_ue;
return CORE_OK;
}
mme_sess_t *mme_sess_add(mme_ue_t *mme_ue, c_uint8_t pti)
{
mme_sess_t *sess = NULL;

View File

@ -121,7 +121,6 @@ typedef struct _mme_enb_t {
struct _enb_ue_t {
lnode_t node; /* A node of list_t */
index_t index; /* An index of this node */
fsm_t sm; /* A state machine */
/* UE identity */
c_uint32_t enb_ue_s1ap_id; /* eNB-UE-S1AP-ID received from eNB */
@ -352,17 +351,22 @@ typedef struct _mme_sess_t {
#define MME_HAVE_ENB_S1U_PATH(__bEARER) \
((__bEARER) && ((__bEARER)->enb_s1u_teid) && ((__bEARER)->enb_s1u_addr))
typedef struct _mme_bearer_t {
lnode_t node; /* A node of list_t */
index_t index; /* An index of this node */
fsm_t sm; /* State Machine */
lnode_t node; /* A node of list_t */
index_t index; /* An index of this node */
fsm_t sm; /* State Machine */
c_uint8_t ebi; /* EPS Bearer ID */
c_uint8_t ebi; /* EPS Bearer ID */
c_uint32_t enb_s1u_teid;
c_uint32_t enb_s1u_addr;
c_uint32_t sgw_s1u_teid;
c_uint32_t sgw_s1u_addr;
c_uint32_t enb_dl_teid;
c_uint32_t enb_dl_addr;
c_uint32_t enb_ul_teid;
c_uint32_t enb_ul_addr;
qos_t qos;
tlv_octet_t tft; /* Saved TFT */
@ -410,6 +414,8 @@ CORE_DECLARE(status_t) mme_ue_set_imsi(
mme_ue_t *mme_ue, c_int8_t *imsi_bcd);
CORE_DECLARE(status_t) mme_associate_ue_context(
mme_ue_t *mme_ue, enb_ue_t *enb_ue);
CORE_DECLARE(status_t) mme_partial_associate_ue_context(
mme_ue_t *mme_ue, enb_ue_t *enb_ue);
CORE_DECLARE(hash_index_t *) mme_ue_first();
CORE_DECLARE(hash_index_t *) mme_ue_next(hash_index_t *hi);

View File

@ -261,7 +261,7 @@ status_t s1ap_build_initial_context_setup_request(
sizeof(c_uint8_t));
ies->ueSecurityCapabilities.encryptionAlgorithms.bits_unused = 0;
ies->ueSecurityCapabilities.encryptionAlgorithms.buf[0] =
mme_ue->ue_network_capability.eea;
(mme_ue->ue_network_capability.eea << 1);
ies->ueSecurityCapabilities.integrityProtectionAlgorithms.size = 2;
ies->ueSecurityCapabilities.integrityProtectionAlgorithms.buf =
@ -674,6 +674,150 @@ status_t s1ap_build_path_switch_failure(pkbuf_t **s1apbuf,
return CORE_OK;
}
status_t s1ap_build_handover_request(
pkbuf_t **s1apbuf, mme_ue_t *mme_ue, enb_ue_t *enb_ue,
S1ap_HandoverRequiredIEs_t *required)
{
char buf[INET_ADDRSTRLEN];
int encoded;
s1ap_message_t message;
S1ap_HandoverRequestIEs_t *ies = &message.s1ap_HandoverRequestIEs;
S1ap_E_RABToBeSetupItemHOReq_t *e_rab = NULL;
struct S1ap_GBR_QosInformation *gbrQosInformation = NULL; /* OPTIONAL */
mme_sess_t *sess = NULL;
mme_bearer_t *bearer = NULL;
s6a_subscription_data_t *subscription_data = NULL;
d_assert(enb_ue, return CORE_ERROR, "Null param");
d_assert(mme_ue, return CORE_ERROR, "Null param");
d_assert(required, return CORE_ERROR, "Null param");
subscription_data = &mme_ue->subscription_data;
d_assert(subscription_data, return CORE_ERROR, "Null param");
memset(&message, 0, sizeof(s1ap_message_t));
ies->mme_ue_s1ap_id = enb_ue->mme_ue_s1ap_id;
ies->handoverType = required->handoverType;
s1ap_build_cause(&ies->cause, &required->cause);
asn_uint642INTEGER(
&ies->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL,
subscription_data->ambr.uplink);
asn_uint642INTEGER(
&ies->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL,
subscription_data->ambr.downlink);
sess = mme_sess_first(mme_ue);
while(sess)
{
bearer = mme_bearer_first(sess);
while(bearer)
{
e_rab = (S1ap_E_RABToBeSetupItemHOReq_t *)
core_calloc(1, sizeof(S1ap_E_RABToBeSetupItemHOReq_t));
e_rab->e_RAB_ID = bearer->ebi;
e_rab->e_RABlevelQosParameters.qCI = bearer->qos.qci;
e_rab->e_RABlevelQosParameters.allocationRetentionPriority.
priorityLevel = bearer->qos.arp.priority_level;
e_rab->e_RABlevelQosParameters.allocationRetentionPriority.
pre_emptionCapability =
!(bearer->qos.arp.pre_emption_capability);
e_rab->e_RABlevelQosParameters.allocationRetentionPriority.
pre_emptionVulnerability =
!(bearer->qos.arp.pre_emption_vulnerability);
if (bearer->qos.mbr.downlink || bearer->qos.mbr.uplink ||
bearer->qos.gbr.downlink || bearer->qos.gbr.uplink)
{
if (bearer->qos.mbr.downlink == 0)
bearer->qos.mbr.downlink = MAX_BIT_RATE;
if (bearer->qos.mbr.uplink == 0)
bearer->qos.mbr.uplink = MAX_BIT_RATE;
if (bearer->qos.gbr.downlink == 0)
bearer->qos.gbr.downlink = MAX_BIT_RATE;
if (bearer->qos.gbr.uplink == 0)
bearer->qos.gbr.uplink = MAX_BIT_RATE;
gbrQosInformation =
core_calloc(1, sizeof(struct S1ap_GBR_QosInformation));
asn_uint642INTEGER(&gbrQosInformation->e_RAB_MaximumBitrateDL,
bearer->qos.mbr.downlink);
asn_uint642INTEGER(&gbrQosInformation->e_RAB_MaximumBitrateUL,
bearer->qos.mbr.uplink);
asn_uint642INTEGER(&gbrQosInformation->
e_RAB_GuaranteedBitrateDL, bearer->qos.gbr.downlink);
asn_uint642INTEGER(&gbrQosInformation->
e_RAB_GuaranteedBitrateUL, bearer->qos.gbr.uplink);
e_rab->e_RABlevelQosParameters.gbrQosInformation =
gbrQosInformation;
}
e_rab->transportLayerAddress.size = 4;
e_rab->transportLayerAddress.buf = core_calloc(
e_rab->transportLayerAddress.size, sizeof(c_uint8_t));
memcpy(e_rab->transportLayerAddress.buf, &bearer->sgw_s1u_addr,
e_rab->transportLayerAddress.size);
s1ap_uint32_to_OCTET_STRING(bearer->sgw_s1u_teid, &e_rab->gTP_TEID);
ASN_SEQUENCE_ADD(&ies->e_RABToBeSetupListHOReq, e_rab);
bearer = mme_bearer_next(bearer);
}
sess = mme_sess_next(sess);
}
s1ap_buffer_to_OCTET_STRING(
required->source_ToTarget_TransparentContainer.buf,
required->source_ToTarget_TransparentContainer.size,
&ies->source_ToTarget_TransparentContainer);
ies->ueSecurityCapabilities.encryptionAlgorithms.size = 2;
ies->ueSecurityCapabilities.encryptionAlgorithms.buf =
core_calloc(ies->ueSecurityCapabilities.encryptionAlgorithms.size,
sizeof(c_uint8_t));
ies->ueSecurityCapabilities.encryptionAlgorithms.bits_unused = 0;
ies->ueSecurityCapabilities.encryptionAlgorithms.buf[0] =
(mme_ue->ue_network_capability.eea << 1);
ies->ueSecurityCapabilities.integrityProtectionAlgorithms.size = 2;
ies->ueSecurityCapabilities.integrityProtectionAlgorithms.buf =
core_calloc(ies->ueSecurityCapabilities.
integrityProtectionAlgorithms.size, sizeof(c_uint8_t));
ies->ueSecurityCapabilities.integrityProtectionAlgorithms.bits_unused = 0;
ies->ueSecurityCapabilities.integrityProtectionAlgorithms.buf[0] =
(mme_ue->ue_network_capability.eia << 1);
ies->securityContext.nextHopChainingCount = mme_ue->nhcc;
ies->securityContext.nextHopParameter.size = SHA256_DIGEST_SIZE;
ies->securityContext.nextHopParameter.buf =
core_calloc(ies->securityContext.nextHopParameter.size,
sizeof(c_uint8_t));
ies->securityContext.nextHopParameter.bits_unused = 0;
memcpy(ies->securityContext.nextHopParameter.buf,
mme_ue->nh, ies->securityContext.nextHopParameter.size);
message.procedureCode = S1ap_ProcedureCode_id_HandoverResourceAllocation;
message.direction = S1AP_PDU_PR_initiatingMessage;
encoded = s1ap_encode_pdu(s1apbuf, &message);
s1ap_free_pdu(&message);
d_assert(s1apbuf && encoded >= 0,return CORE_ERROR,);
d_trace(3, "[S1AP] Handover Request : ",
"UE[mME-UE-S1AP-ID(%d)] <-- eNB[%s:%d]\n",
enb_ue->mme_ue_s1ap_id,
INET_NTOP(&enb_ue->enb->s1ap_sock->remote.sin_addr.s_addr, buf),
enb_ue->enb->enb_id);
return CORE_OK;
}
static void s1ap_build_cause(S1ap_Cause_t *dst, S1ap_Cause_t *src)
{
d_assert(src, return, "Null param");

View File

@ -28,6 +28,10 @@ CORE_DECLARE(status_t) s1ap_build_path_switch_ack(
CORE_DECLARE(status_t) s1ap_build_path_switch_failure(pkbuf_t **s1apbuf,
c_uint32_t enb_ue_s1ap_id, c_uint32_t mme_ue_s1ap_id, S1ap_Cause_t *cause);
CORE_DECLARE(status_t) s1ap_build_handover_request(
pkbuf_t **s1apbuf, mme_ue_t *mme_ue, enb_ue_t *enb_ue,
S1ap_HandoverRequiredIEs_t *required);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -613,17 +613,13 @@ void s1ap_handle_path_switch_request(
memcpy(&eea, encryptionAlgorithms->buf, sizeof(eea));
eea = ntohs(eea);
if (eea == 0)
mme_ue->ue_network_capability.eea0 = 1;
else
mme_ue->ue_network_capability.eea0 = eea >> 9;
mme_ue->ue_network_capability.eea = eea >> 9;
mme_ue->ue_network_capability.eea0 = 1;
memcpy(&eia, integrityProtectionAlgorithms->buf, sizeof(eia));
eia = ntohs(eia);
if (eea == 0)
mme_ue->ue_network_capability.eia0 = 1;
else
mme_ue->ue_network_capability.eia0 = eia >> 9;
mme_ue->ue_network_capability.eia = eia >> 9;
mme_ue->ue_network_capability.eia0 = 0;
MODIFY_BEARER_TRANSACTION_BEGIN(mme_ue,
MODIFY_BEARER_BY_PATH_SWITCH_REQUEST);
@ -662,10 +658,137 @@ void s1ap_handle_path_switch_request(
void s1ap_handle_handover_required(mme_enb_t *enb, s1ap_message_t *message)
{
status_t rv;
char buf[INET_ADDRSTRLEN];
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
S1ap_HandoverRequiredIEs_t *ies = NULL;
d_assert(enb, return,);
ies = &message->s1ap_HandoverRequiredIEs;
d_assert(ies, return,);
enb_ue = enb_ue_find_by_enb_ue_s1ap_id(enb, ies->eNB_UE_S1AP_ID);
d_assert(enb_ue, return,
"Cannot find UE for eNB-UE-S1AP-ID[%d] and eNB[%s:%d]",
ies->eNB_UE_S1AP_ID,
INET_NTOP(&enb->s1ap_sock->remote.sin_addr.s_addr, buf),
enb->enb_id);
d_assert(enb_ue->mme_ue_s1ap_id == ies->mme_ue_s1ap_id, return,
"Conflict MME-UE-S1AP-ID : %d != %d\n",
enb_ue->mme_ue_s1ap_id, ies->mme_ue_s1ap_id);
mme_ue = enb_ue->mme_ue;
d_assert(mme_ue, return,);
if (SECURITY_CONTEXT_IS_VALID(mme_ue))
{
mme_ue->nhcc++;
mme_kdf_nh(mme_ue->kasme, mme_ue->nh, mme_ue->nh);
}
else
{
d_assert(0, return,);
}
rv = s1ap_send_handover_request(mme_ue, ies);
d_assert(rv == CORE_OK,, "s1ap send error");
d_trace(3, "[S1AP] Handover Required : "
"UE[eNB-UE-S1AP-ID(%d)] --> eNB[%s:%d]\n",
enb_ue->enb_ue_s1ap_id,
INET_NTOP(&enb->s1ap_sock->remote.sin_addr.s_addr, buf),
enb->enb_id);
}
void s1ap_handle_handover_request_ack(mme_enb_t *enb, s1ap_message_t *message)
{
//status_t rv;
char buf[INET_ADDRSTRLEN];
int i;
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
S1ap_HandoverRequestAcknowledgeIEs_t *ies = NULL;
d_assert(enb, return,);
ies = &message->s1ap_HandoverRequestAcknowledgeIEs;
d_assert(ies, return,);
enb_ue = enb_ue_find_by_mme_ue_s1ap_id(ies->mme_ue_s1ap_id);
d_assert(enb_ue, return,
"Cannot find UE for MME-UE-S1AP-ID[%d] and eNB[%s:%d]",
ies->mme_ue_s1ap_id,
INET_NTOP(&enb->s1ap_sock->remote.sin_addr.s_addr, buf),
enb->enb_id);
enb_ue->enb_ue_s1ap_id = ies->eNB_UE_S1AP_ID;
mme_ue = enb_ue->mme_ue;
d_assert(mme_ue, return,);
for (i = 0; i < ies->e_RABAdmittedList.s1ap_E_RABAdmittedItem.count; i++)
{
mme_bearer_t *bearer = NULL;
S1ap_E_RABAdmittedItem_t *e_rab = NULL;
e_rab = (S1ap_E_RABAdmittedItem_t *)ies->e_RABAdmittedList.
s1ap_E_RABAdmittedItem.array[i];
d_assert(e_rab, return, "Null param");
bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID);
d_assert(bearer, return, "Null param");
memcpy(&bearer->enb_s1u_teid, e_rab->gTP_TEID.buf,
sizeof(bearer->enb_s1u_teid));
bearer->enb_s1u_teid = ntohl(bearer->enb_s1u_teid);
memcpy(&bearer->enb_s1u_addr, e_rab->transportLayerAddress.buf,
sizeof(bearer->enb_s1u_addr));
if (e_rab->dL_transportLayerAddress && e_rab->dL_gTP_TEID)
{
d_assert(e_rab->dL_gTP_TEID->buf, return,);
d_assert(e_rab->dL_transportLayerAddress->buf, return,);
memcpy(&bearer->enb_dl_teid, e_rab->dL_gTP_TEID->buf,
sizeof(bearer->enb_dl_teid));
bearer->enb_dl_teid = ntohl(bearer->enb_dl_teid);
memcpy(&bearer->enb_dl_addr, e_rab->dL_transportLayerAddress->buf,
sizeof(bearer->enb_dl_addr));
}
if (e_rab->uL_S1ap_TransportLayerAddress && e_rab->uL_S1ap_GTP_TEID)
{
d_assert(e_rab->uL_S1ap_GTP_TEID->buf, return,);
d_assert(e_rab->uL_S1ap_TransportLayerAddress->buf, return,);
memcpy(&bearer->enb_ul_teid, e_rab->uL_S1ap_GTP_TEID->buf,
sizeof(bearer->enb_ul_teid));
bearer->enb_ul_teid = ntohl(bearer->enb_ul_teid);
memcpy(&bearer->enb_ul_addr,
e_rab->uL_S1ap_TransportLayerAddress->buf,
sizeof(bearer->enb_ul_addr));
}
#if 0
rv = mme_gtp_send_modify_bearer_request(bearer);
d_assert(rv == CORE_OK, return, "gtp send failed");
#endif
}
#if 0
rv = s1ap_send_handover_request(mme_ue, ies);
d_assert(rv == CORE_OK,, "s1ap send error");
#endif
d_trace(3, "[S1AP] Handover Request Ack : "
"UE[eNB-UE-S1AP-ID(%d)] --> eNB[%s:%d]\n",
enb_ue->enb_ue_s1ap_id,
INET_NTOP(&enb->s1ap_sock->remote.sin_addr.s_addr, buf),
enb->enb_id);
}
void s1ap_handle_handover_failure(mme_enb_t *enb, s1ap_message_t *message)

View File

@ -7,6 +7,7 @@
#include "nas_security.h"
#include "nas_path.h"
#include "s1ap_conv.h"
#include "s1ap_build.h"
#include "s1ap_path.h"
@ -423,4 +424,54 @@ status_t s1ap_send_path_switch_failure(mme_enb_t *enb,
return rv;
}
status_t s1ap_send_handover_request(
mme_ue_t *mme_ue, S1ap_HandoverRequiredIEs_t *ies)
{
status_t rv;
pkbuf_t *s1apbuf = NULL;
S1ap_TargetID_t *targetID = NULL;
c_uint32_t enb_id;
mme_enb_t *enb = NULL;
enb_ue_t *enb_ue = NULL;
d_assert(mme_ue, return CORE_ERROR,);
d_assert(ies, return CORE_ERROR,);
targetID = &ies->targetID;
d_assert(targetID, return CORE_ERROR,);
switch(targetID->present)
{
case S1ap_TargetID_PR_targeteNB_ID:
{
s1ap_ENB_ID_to_uint32(
&targetID->choice.targeteNB_ID.global_S1ap_ENB_ID.eNB_ID,
&enb_id);
break;
}
default:
{
d_error("Not implemented(%d)", targetID->present);
return CORE_ERROR;
}
}
enb = mme_enb_find_by_enb_id(enb_id);
d_assert(enb, return CORE_ERROR,
"Cannot find target eNB = %d", enb_id);
enb_ue = enb_ue_add(enb);
d_assert(enb_ue, return CORE_ERROR,);
mme_partial_associate_ue_context(mme_ue, enb_ue);
rv = s1ap_build_handover_request(&s1apbuf, mme_ue, enb_ue, ies);
d_assert(rv == CORE_OK && s1apbuf,
enb_ue_remove(enb_ue); return CORE_ERROR, "s1ap build error");
rv = s1ap_send_to_enb(enb, s1apbuf);
d_assert(rv == CORE_OK, enb_ue_remove(enb_ue), "s1ap send error");
return rv;
}

View File

@ -29,6 +29,9 @@ CORE_DECLARE(status_t) s1ap_send_path_switch_ack(mme_ue_t *mme_ue);
CORE_DECLARE(status_t) s1ap_send_path_switch_failure(mme_enb_t *enb,
c_uint32_t enb_ue_s1ap_id, c_uint32_t mme_ue_s1ap_id, S1ap_Cause_t *cause);
CORE_DECLARE(status_t) s1ap_send_handover_request(
mme_ue_t *mme_ue, S1ap_HandoverRequiredIEs_t *required);
int _s1ap_recv_cb(net_sock_t *net_sock, void *data);
#ifdef __cplusplus

View File

@ -42,7 +42,7 @@ static void attach_test1(abts_case *tc, void *data)
"fcf13a9702074202 49064000f1105ba0 00485221c1010909 08696e7465726e65"
"7405012d2d2d015e 06fefeeeee030327 2980c22304030000 0480211002000010"
"8106080808088306 04040404000d0408 080808000d040404 0404500bf600f110"
"0002010000000153 12172c5949640125 006b00051c000c00 00004900203311c6"
"0002010000000153 12172c5949640125 006b000518000c00 00004900203311c6"
"03c6a6d67f695e5a c02bb75b381b693c 3893a6d932fd9182 3544e3e79b000000"
"0000000000000000 00";
char *_emm_information =

View File

@ -321,47 +321,78 @@ static void handover_test2(abts_case *tc, void *data)
c_int64_t count = 0;
bson_error_t error;
const char *json =
"{"
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c6\" }, "
"\"imsi\" : \"405866000000972\", "
"\"pdn\" : ["
"{"
"\"apn\" : \"internet\", "
"\"_id\" : { \"$oid\" : \"597223158b8861d7605378c7\" }, "
"\"ambr\" : {"
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
"},"
"\"qos\" : { "
"\"qci\" : 9, "
"\"arp\" : { "
"\"priority_level\" : 8,"
"\"pre_emption_vulnerability\" : 1, "
"\"pre_emption_capability\" : 1"
"} "
"}, "
"\"type\" : 0"
"}"
"],"
"\"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\" : \"465B5CE8 B199B49F AA5F0A2E E238A6BC\", "
"\"op\" : \"5F1D289C 5D354D0A 140C2548 F5F3E3BA\", "
"\"amf\" : \"8000\", "
"\"sqn\" : { \"$numberLong\" : \"64\" }, "
"\"rand\" : \"E596BAB8 00000000 7AAFC796 00000000\" "
"}, "
"\"__v\" : 0 "
"}";
"{"
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2b\" },"
"\"imsi\" : \"001010123456815\","
"\"pdn\" : ["
"{ \"apn\" : \"internet.ng2.mnet\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd32\" },"
"\"qos\" : {"
"\"qci\" : 9,"
"\"arp\" : {"
"\"priority_level\" : 8,"
"\"pre_emption_vulnerability\" : 1,"
"\"pre_emption_capability\" : 1 } },"
"\"type\" : 0 },"
"{ \"apn\" : \"internet\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2c\" },"
"\"pcc_rule\" : ["
"{ \"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2d\" },"
"\"qos\" : {"
"\"qci\" : 1,"
"\"gbr\" : {"
"\"downlink\" : { \"$numberLong\" : \"976\" },"
"\"uplink\" : { \"$numberLong\" : \"976\" } },"
"\"mbr\" : {"
"\"downlink\" : { \"$numberLong\" : \"976\" },"
"\"uplink\" : { \"$numberLong\" : \"976\" } },"
"\"arp\" : {"
"\"priority_level\" : 1,"
"\"pre_emption_vulnerability\" : 0,"
"\"pre_emption_capability\" : 0 } },"
"\"flow\" : ["
"{ \"direction\" : 2,"
"\"description\" : \"permit out udp from any 1-65535 to 10.200.136.98/32 23454\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd31\" } },"
"{ \"direction\" : 1,"
"\"description\" : \"permit out udp from any 50020 to 10.200.136.98/32 1-65535\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd30\" } },"
"{ \"direction\" : 2,"
"\"description\" : \"permit out udp from any 1-65535 to 10.200.136.98/32 23455\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2f\" } },"
"{ \"direction\" : 1,"
"\"description\" : \"permit out udp from any 50021 to 10.200.136.98/32 1-65535\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2e\" } } ]"
"} ],"
"\"ambr\" : {"
"\"downlink\" : { \"$numberLong\" : \"35840\" },"
"\"uplink\" : { \"$numberLong\" : \"15360\" } },"
"\"qos\" : {"
"\"qci\" : 7,"
"\"arp\" : {"
"\"priority_level\" : 1,"
"\"pre_emption_vulnerability\" : 1,"
"\"pre_emption_capability\" : 0 } },"
"\"type\" : 0 }"
"],"
"\"ambr\" : {"
"\"downlink\" : { \"$numberLong\" : \"202400\" },"
"\"uplink\" : { \"$numberLong\" : \"202400\" } },"
"\"subscribed_rau_tau_timer\" : 12,"
"\"network_access_mode\" : 2,"
"\"subscriber_status\" : 0,"
"\"access_restriction_data\" : 32,"
"\"security\" : {"
"\"k\" : \"465B5CE8 B199B49F AA5F0A2E E238A6BC\","
"\"op\" : \"5F1D289C 5D354D0A 140C2548 F5F3E3BA\","
"\"amf\" : \"8000\","
"\"sqn\" : { \"$numberLong\" : \"161\" }, "
"\"rand\" : \"160b4726 39115e14 075f4731 50355216\" }, "
"\"__v\" : 0"
"}";
mme_self()->mme_ue_s1ap_id = 20675;
mme_self()->mme_ue_s1ap_id = 33554627;
mme_self()->m_tmsi = 0x010003e7;
/* Two eNB connects to MME */
sock1 = tests1ap_enb_connect();
@ -372,7 +403,7 @@ static void handover_test2(abts_case *tc, void *data)
/* S1-Setup Reqeust/Response for Source eNB */
rv = tests1ap_build_setup_req(
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x001f2);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock1, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -384,7 +415,7 @@ static void handover_test2(abts_case *tc, void *data)
/* S1-Setup Reqeust/Response for Target eNB */
rv = tests1ap_build_setup_req(
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f65);
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x00043);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock2, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -405,7 +436,7 @@ static void handover_test2(abts_case *tc, void *data)
MONGOC_INSERT_NONE, doc, NULL, &error));
bson_destroy(doc);
doc = BCON_NEW("imsi", BCON_UTF8("405866000000972"));
doc = BCON_NEW("imsi", BCON_UTF8("001010123456815"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
@ -422,13 +453,24 @@ static void handover_test2(abts_case *tc, void *data)
rv = tests1ap_enb_send(sock1, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Identity Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rc = tests1ap_enb_read(sock1, recvbuf);
ABTS_INT_NEQUAL(tc, 0, rc);
pkbuf_free(recvbuf);
/* Send Identity Response */
rv = tests1ap_build_identity_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock1, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Authentication Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rc = tests1ap_enb_read(sock1, recvbuf);
ABTS_INT_NEQUAL(tc, 0, rc);
pkbuf_free(recvbuf);
#if 0
/* Send Authentication Response */
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -492,10 +534,52 @@ static void handover_test2(abts_case *tc, void *data)
rc = tests1ap_enb_read(sock1, recvbuf);
ABTS_INT_NEQUAL(tc, 0, rc);
pkbuf_free(recvbuf);
#endif
/* Receive E-RAB Setup Request +
* Activate dedicated EPS bearer context request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rc = tests1ap_enb_read(sock1, recvbuf);
ABTS_INT_NEQUAL(tc, 0, rc);
pkbuf_free(recvbuf);
/* Send E-RAB Setup Response */
rv = tests1ap_build_e_rab_setup_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock1, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send Activate dedicated EPS bearer context accept */
rv = tests1ap_build_activate_dedicated_bearer_accept(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock1, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send Handover Required */
rv = tests1ap_build_handover_required(&sendbuf, 0);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock1, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Handover Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rc = tests1ap_enb_read(sock2, recvbuf);
ABTS_INT_NEQUAL(tc, 0, rc);
pkbuf_free(recvbuf);
/* Send Handover Request Ack */
rv = tests1ap_build_handover_request_ack(&sendbuf, 0);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock2, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(1000));
/********** Remove Subscriber in Database */
doc = BCON_NEW("imsi", BCON_UTF8("405866000000972"));
doc = BCON_NEW("imsi", BCON_UTF8("001010123456815"));
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_remove(collection,
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
@ -517,8 +601,9 @@ abts_suite *test_handover(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, handover_test1, NULL);
#if 0
abts_run_test(suite, handover_test1, NULL);
#else
abts_run_test(suite, handover_test2, NULL);
#endif

View File

@ -165,10 +165,12 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
"1004615380008640 0130",
"000c"
"406b000005000800 020002001a004342 0741710849506806 0000902702e06000"
"2d0201d031d12726 8080211001000010 8106000000008306 00000000000d0000"
"0300000100000c00 000a000010005c0a 00c1004300060004 9699000200644008"
"0004969904f00000 0086400130",
"4080830000060008 0002000c001a0050 4f1744b524490507 41020bf600f11000"
"0201010003e802e0 6000210204d011d1 271a808021100100 0010810600000000"
"830600000000000d 00000a005200f110 30395c0a00901103 4f18a6f15d0100e0"
"004300060000f110 3039006440080000 f110001f20a00086 400130004b000700"
"00f110000201",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
92,
@ -184,7 +186,7 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
0,
108,
111,
136,
};
char hexbuf[MAX_SDU_LEN];
@ -215,6 +217,11 @@ status_t tests1ap_build_identity_response(pkbuf_t **pkbuf, int i)
"",
"",
"",
"",
"000d"
"403e000005000000 05c0020000c40008 0002000c001a0012 1117c07eb5f50607"
"5608091010103254 8651006440080000 f110001f20a00043 40060000f1103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
@ -229,6 +236,9 @@ status_t tests1ap_build_identity_response(pkbuf_t **pkbuf, int i)
0,
0,
0,
0,
66,
};
char hexbuf[MAX_SDU_LEN];
@ -262,9 +272,15 @@ status_t tests1ap_build_authentication_response(pkbuf_t **pkbuf, int i)
"",
"",
"000d"
"4038000005000000 05c0010001da0008 00020001001a000c 0b0753084ce11ef1"
"24b1854500644008 0000f11004615380 004340060000f110 5ba0",
"000d"
"403e000005000000 05c0020000c40008 0002000c001a0012 1117deff957c0707"
"5308e3b925330735 7093006440080000 f110001f20a00043 40060000f1103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
@ -281,6 +297,7 @@ status_t tests1ap_build_authentication_response(pkbuf_t **pkbuf, int i)
0,
60,
66,
};
char hexbuf[MAX_SDU_LEN];
@ -313,10 +330,14 @@ status_t tests1ap_build_security_mode_complete(pkbuf_t **pkbuf, int i)
"",
"",
"000d"
"4035000005000000 05c0010001da0008 00020001001a0009 0847d3b0ef030007"
"5e006440080000f1 1004615380004340 060000f1105ba0",
"000d"
"4035000005000000 05c0020000c40008 0002000c001a0009 084790282df90007"
"5e006440080000f1 10001f20a0004340 060000f1103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
57,
@ -332,6 +353,7 @@ status_t tests1ap_build_security_mode_complete(pkbuf_t **pkbuf, int i)
0,
57,
57,
};
char hexbuf[MAX_SDU_LEN];
@ -369,10 +391,16 @@ status_t tests1ap_build_esm_information_response(pkbuf_t **pkbuf, int i)
"",
"",
"000d"
"4041000005000000 05c0010001da0008 00020001001a0015 14279a2476c80102"
"07da280908696e74 65726e6574006440 080000f110046153 80004340060000f1"
"105ba0",
"000d"
"4041000005000000 05c0020000c40008 0002000c001a0015 14274f280bff0102"
"04da280908696e74 65726e6574006440 080000f110001f20 a0004340060000f1"
"103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
146,
@ -388,6 +416,7 @@ status_t tests1ap_build_esm_information_response(pkbuf_t **pkbuf, int i)
0,
69,
69,
};
char hexbuf[MAX_SDU_LEN];
@ -434,6 +463,10 @@ status_t tests1ap_build_ue_capability_info_indication(pkbuf_t **pkbuf, int i)
"0016"
"4030000003000000 05c0010001da0008 00020001004a401a 1900b801014c5980"
"809c000bf06ec4d0 0140302c00000000 0000",
"0016"
"4030000003000000 05c0020000c40008 0002000c004a401a 1900b801014c5980"
"0018000bf06ec4d0 0100302c00000000 0000",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
161,
@ -449,6 +482,7 @@ status_t tests1ap_build_ue_capability_info_indication(pkbuf_t **pkbuf, int i)
0,
52,
52,
};
char hexbuf[MAX_SDU_LEN];
@ -490,6 +524,10 @@ status_t tests1ap_build_initial_context_setup_response(pkbuf_t **pkbuf, int i)
"2009"
"0025000003000040 05c0010001da0008 400200010033400f 000032400a0a1f0a"
"012d8301000008",
"2009"
"0025000003000040 05c0020000c40008 4002000c0033400f 000032400a0a1f0a"
"01237b01000808",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
41,
@ -505,6 +543,7 @@ status_t tests1ap_build_initial_context_setup_response(pkbuf_t **pkbuf, int i)
0,
41,
41,
};
char hexbuf[MAX_SDU_LEN];
@ -548,6 +587,10 @@ status_t tests1ap_build_attach_complete(pkbuf_t **pkbuf, int i)
"403a000005000000 05c0010001da0008 00020001001a000e 0d272e3456f70207"
"4300035200c20064 40080000f1100461 5380004340060000 f1105ba0",
"000d"
"403a000005000000 05c0020000c40008 0002000c001a000e 0d276a543e560207"
"4300035200c20064 40080000f110001f 20a0004340060000 f1103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
62,
@ -563,6 +606,7 @@ status_t tests1ap_build_attach_complete(pkbuf_t **pkbuf, int i)
0,
62,
62,
};
char hexbuf[MAX_SDU_LEN];
@ -709,7 +753,9 @@ status_t tests1ap_build_ue_context_release_complete(pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"2017001300000200 004005c00100009d 00084003400527",
"",
"2017"
"0012000002000040 05c00100009f0008 40020001",
@ -722,6 +768,12 @@ status_t tests1ap_build_ue_context_release_complete(pkbuf_t **pkbuf, int i)
"",
"",
"",
"2017"
"0012000002000040 05c0020000c40008 4002000c",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
23,
@ -735,6 +787,9 @@ status_t tests1ap_build_ue_context_release_complete(pkbuf_t **pkbuf, int i)
22,
0,
0,
0,
22,
};
char hexbuf[MAX_SDU_LEN];
@ -905,6 +960,10 @@ status_t tests1ap_build_e_rab_setup_response(pkbuf_t **pkbuf, int i)
"2005002600000300 004005c00200003c 0008400300010000 1c400f000027400a"
"0c1f0a012da50100 b410",
"2005"
"0025000003000040 05c0020000c40008 4002000c001c400f 000027400a0c1f0a"
"01237b01000810",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
42,
@ -920,6 +979,7 @@ status_t tests1ap_build_e_rab_setup_response(pkbuf_t **pkbuf, int i)
0,
42,
41,
};
char hexbuf[MAX_SDU_LEN];
@ -1042,6 +1102,10 @@ status_t tests1ap_build_activate_dedicated_bearer_accept(
"000d403700000500"
"000005c00200003c 0008000300010000 1a000a0927a27f49 d6036200c6006440"
"080000f1109d67aa 50004340060000f1 102b67",
"000d"
"4036000005000000 05c0020000c40008 0002000c001a000a 0927e3c77e000362"
"00c6006440080000 f110001f20a00043 40060000f1103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
59,
@ -1057,6 +1121,7 @@ status_t tests1ap_build_activate_dedicated_bearer_accept(
0,
59,
58,
};
char hexbuf[MAX_SDU_LEN];
@ -1161,3 +1226,193 @@ status_t tests1ap_build_path_switch_request(
return CORE_OK;
}
status_t tests1ap_build_handover_required(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"0000"
"0081030000060000 0005c0020000c400 080002000c000100 0100000240020220"
"0004000d0000f110 0000043000f11030 3900680080d080ce 4080ab0f1014c598"
"00018000bf06ec4d 00100302c0000000 000015a800140672 0af00348f10013d0"
"3bc58414903bc588 09401de2c2100440 13f212249010127d ad808fd50398381c"
"08fd503983805f50 37868baa010c846f b057874162d62e82 1f42f2e159f821d0"
"9c0009e28aa1a001 2d888026d0600040 8008066072003e41 5250d46210208184"
"3423c135002214d6 dfb0a0b06502c402 000004008177faab 4677235334a0e867"
"213e804030000100 4e40024500004e40 0246000000f11000 043a000000f11000"
"1f20a0000022",
"",
"",
"",
"",
"",
"",
"",
"",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
264,
0,
0,
0,
0,
0,
0,
0,
0,
};
char hexbuf[MAX_SDU_LEN];
*pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
if (!(*pkbuf)) return CORE_ERROR;
(*pkbuf)->len = len[i];
memcpy((*pkbuf)->payload, CORE_HEX(payload[i], strlen(payload[i]), hexbuf),
(*pkbuf)->len);
return CORE_OK;
}
status_t tests1ap_build_handover_request_ack(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"2001"
"0080e80000040000 4005c0020000c500 0840020008001240 47010014401f78a1"
"f00a01237c010007 080f800a01237c01 0007090f800a0123 7c0100070a001440"
"1f78c1f00a01237c 010007100f800a01 237c010007110f80 0a01237c01000712"
"007b008086808400 80810bf900d8af40 00a0339057801f47 88009e81de2c20a4"
"81de2c404a00ef16 2000010044013f21 2249008093efd243 3914cd2aa0a0142f"
"f2214d6dfb82c194 0b10080000020040 bbfd55aeab41ad80 8fd50398381c08fd"
"503983804d037868 baa016423342bc3a 18b58fa084ca833f a17970acfc10e84e"
"0004f14550d00096 c88900",
"",
"",
"",
"",
"",
"",
"",
"",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
237,
0,
0,
0,
0,
0,
0,
0,
0,
};
char hexbuf[MAX_SDU_LEN];
*pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
if (!(*pkbuf)) return CORE_ERROR;
(*pkbuf)->len = len[i];
memcpy((*pkbuf)->payload, CORE_HEX(payload[i], strlen(payload[i]), hexbuf),
(*pkbuf)->len);
return CORE_OK;
}
status_t tests1ap_build_enb_status_transfer(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"0018"
"4027000003000000 05c0020000c40008 0002000c005a0011 00000059400b0500"
"004b000000001100 00",
"",
"",
"",
"",
"",
"",
"",
"",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
43,
0,
0,
0,
0,
0,
0,
0,
0,
};
char hexbuf[MAX_SDU_LEN];
*pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
if (!(*pkbuf)) return CORE_ERROR;
(*pkbuf)->len = len[i];
memcpy((*pkbuf)->payload, CORE_HEX(payload[i], strlen(payload[i]), hexbuf),
(*pkbuf)->len);
return CORE_OK;
}
status_t tests1ap_build_handover_notify(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"0002"
"4028000004000000 05c0020000c30008 0002000800644008 0000f11000043a00"
"004340060000f110 3039",
"",
"",
"",
"",
"",
"",
"",
"",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
44,
0,
0,
0,
0,
0,
0,
0,
0,
};
char hexbuf[MAX_SDU_LEN];
*pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
if (!(*pkbuf)) return CORE_ERROR;
(*pkbuf)->len = len[i];
memcpy((*pkbuf)->payload, CORE_HEX(payload[i], strlen(payload[i]), hexbuf),
(*pkbuf)->len);
return CORE_OK;
}

View File

@ -51,6 +51,12 @@ CORE_DECLARE(status_t) tests1ap_build_deactivate_bearer_accept(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_path_switch_request(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_handover_required(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_handover_request_ack(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_enb_status_transfer(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_handover_notify(pkbuf_t **pkbuf, int i);
#ifdef __cplusplus
}