Commit 1d292816 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Use InitialUEContextSetup to convey PDUSessionResourceSetupTransfer

parent c84fd646
......@@ -171,9 +171,25 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
i->get_msg_name());
}
} else {
string ue_context_key = "app_ue_ranid_" + to_string(ran_ue_ngap_id) +
":amfid_" + to_string(amf_ue_ngap_id);
std::shared_ptr<ue_context> uc;
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
if (uc.get() == nullptr) {
// TODO:
Logger::amf_n1().error(
"ue_context in amf_app using ran_amf_id (%s) does not existed!",
ue_context_key.c_str());
}
Logger::amf_n1().info(
"Found ue_context (%p) in amf_app using ran_amf_id (%s)", uc.get(),
ue_context_key.c_str());
if (uc.get()->isUeContextRequest) {
// PDU SESSION RESOURCE SETUP_REQUEST
itti_pdu_session_resource_setup_request* psrsr =
new itti_pdu_session_resource_setup_request(TASK_AMF_N1, TASK_AMF_N2);
new itti_pdu_session_resource_setup_request(
TASK_AMF_N1, TASK_AMF_N2);
psrsr->nas = protected_nas;
psrsr->n2sm = itti_msg.n2sm;
psrsr->amf_ue_ngap_id = amf_ue_ngap_id;
......@@ -187,6 +203,37 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
} else {
// send using InitialContextSetupRequest
uint8_t* kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32];
uint32_t ulcount =
secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb);
ncc = 1;
print_buffer("amf_n1", "kamf", kamf, 32);
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32);
itti_initial_context_setup_request* csr =
new itti_initial_context_setup_request(TASK_AMF_N1, TASK_AMF_N2);
csr->ran_ue_ngap_id = ran_ue_ngap_id;
csr->amf_ue_ngap_id = amf_ue_ngap_id;
csr->kgnb = kgnb_bs;
csr->nas = protected_nas;
csr->pdu_session_id = itti_msg.pdu_session_id;
csr->is_pdu_exist = true;
csr->n2sm = itti_msg.n2sm;
csr->is_sr = false; // TODO: for Service Request procedure
std::shared_ptr<itti_initial_context_setup_request> i =
std::shared_ptr<itti_initial_context_setup_request>(csr);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
}
}
} else {
itti_dl_nas_transport* dnt =
......@@ -734,7 +781,7 @@ void amf_n1::service_request_handle(
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->nas = protectedNas;
itti_msg->kgnb = kgnb_bs;
itti_msg->is_sr = true; // service request indicator
itti_msg->is_sr = true; // Service Request indicator
itti_msg->is_pdu_exist = false;
std::shared_ptr<itti_initial_context_setup_request> i =
std::shared_ptr<itti_initial_context_setup_request>(itti_msg);
......@@ -782,7 +829,7 @@ void amf_n1::service_request_handle(
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->nas = protectedNas;
itti_msg->kgnb = kgnb_bs;
itti_msg->is_sr = true; // service request indicator
itti_msg->is_sr = true; // Service Request indicator
itti_msg->pdu_session_id = pdu_session_id;
itti_msg->is_pdu_exist = true;
if (psc.get()->isn2sm_avaliable) {
......@@ -2114,9 +2161,9 @@ void amf_n1::security_mode_complete_handle(
// IE: UEAggregateMaximumBitRate
// AllowedNSSAI
/* itti_dl_nas_transport* dnt =
itti_dl_nas_transport* dnt =
new itti_dl_nas_transport(TASK_AMF_N1, TASK_AMF_N2);
dnt->nas = ;
dnt->nas = protectedNas;
dnt->amf_ue_ngap_id = amf_ue_ngap_id;
dnt->ran_ue_ngap_id = ran_ue_ngap_id;
std::shared_ptr<itti_dl_nas_transport> i =
......@@ -2127,7 +2174,6 @@ void amf_n1::security_mode_complete_handle(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
*/
} else {
// use InitialContextSetupRequest (NGAP message) to convey Registration
......@@ -2148,7 +2194,7 @@ void amf_n1::security_mode_complete_handle(
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->kgnb = kgnb_bs;
itti_msg->nas = protectedNas;
itti_msg->is_sr = false; // TODO: for Setup Request procedure
itti_msg->is_sr = false; // TODO: for Service Request procedure
std::shared_ptr<itti_initial_context_setup_request> i =
std::shared_ptr<itti_initial_context_setup_request>(itti_msg);
int ret = itti_inst->send_msg(i);
......
......@@ -728,14 +728,19 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
msg->setAllowedNssai(list);
bdestroy(itti_msg.nas);
bdestroy(itti_msg.kgnb);
if (itti_msg.is_sr) {
if (itti_msg.is_sr or itti_msg.is_pdu_exist) {
// TODO: to add UEAggregateMaximumBitRate
bstring ueCapability = gc.get()->ue_radio_cap_ind;
uint8_t* uecap = (uint8_t*) calloc(1, blength(ueCapability) + 1);
memcpy(uecap, (uint8_t*) bdata(ueCapability), blength(ueCapability));
uecap[blength(ueCapability)] = '\0';
msg->setUERadioCapability(uecap, (size_t) blength(ueCapability));
free(uecap);
if (itti_msg.is_sr)
Logger::amf_n2().debug("Encoding parameters for Service Request");
else
Logger::amf_n2().debug(
"Encoding parameters for Initial Context Setup Request");
if (itti_msg.is_pdu_exist) {
std::vector<PDUSessionResourceSetupRequestItem_t> list;
......
......@@ -540,7 +540,7 @@ uint8_t* Authentication_5gaka::sqn_ms_derive(
uint8_t* mac_s = NULL;
uint8_t mac_s_computed[MAC_S_LENGTH] = {0};
uint8_t* sqn_ms = NULL;
uint8_t amf[2] = {0x80, 0x00};
uint8_t amf[2] = {0x00, 0x00}; // TODO: To be verified
int i = 0;
conc_sqn_ms = auts;
......@@ -570,7 +570,9 @@ uint8_t* Authentication_5gaka::sqn_ms_derive(
// print_buffer ("MAC_S +: ", mac_s_computed, 8);
if (memcmp(mac_s_computed, mac_s, 8) != 0) {
// FPRINTF_ERROR ( "Failed to verify computed SQN_MS\n");
Logger::amf_n1().debug(
"sqn_ms_derive, failed to verify computed SQN_MS (MAC does not "
"matched!)");
free(sqn_ms);
return NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment