Commit 60ba82f5 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for PLMN (MNC length=2, starting with 0)

parent b598727b
......@@ -2075,14 +2075,6 @@ void amf_n1::security_mode_complete_handle(
return;
}
if (!uc.get()->isUeContextRequest) {
Logger::amf_n1().debug(
"UE Context is not requested, UE with ran_ue_ngap_id %d, "
"amf_ue_ngap_id %d attached",
ran_ue_ngap_id, amf_ue_ngap_id);
// send registration accept back
} else {
// encoding InitialContextSetupRequest(NGAP message) back
std::shared_ptr<nas_context> nc;
nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
Logger::amf_n1().info(
......@@ -2111,6 +2103,36 @@ void amf_n1::security_mode_complete_handle(
encode_nas_message_protected(
secu, false, INTEGRITY_PROTECTED_AND_CIPHERED, NAS_MESSAGE_DOWNLINK,
buffer, encoded_size, protectedNas);
if (!uc.get()->isUeContextRequest) {
Logger::amf_n1().debug(
"UE Context is not requested, UE with ran_ue_ngap_id %d, "
"amf_ue_ngap_id %d attached",
ran_ue_ngap_id, amf_ue_ngap_id);
// TODO: Use DownlinkNasTransport to convey Registration Accept
// IE: UEAggregateMaximumBitRate
// AllowedNSSAI
/* itti_dl_nas_transport* dnt =
new itti_dl_nas_transport(TASK_AMF_N1, TASK_AMF_N2);
dnt->nas = ;
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 =
std::shared_ptr<itti_dl_nas_transport>(dnt);
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 {
// use InitialContextSetupRequest (NGAP message) to convey Registration
// Accept
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);
......@@ -2119,6 +2141,7 @@ void amf_n1::security_mode_complete_handle(
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* itti_msg =
new itti_initial_context_setup_request(TASK_AMF_N1, TASK_AMF_N2);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
......
......@@ -412,4 +412,5 @@ int ULNASTransport::decodefrombuffer(
}
Logger::nas_mm().debug(
"decoded ULNASTransport message len(%d)", decoded_size);
return 0;
}
......@@ -58,13 +58,17 @@ void PlmnId::setMccMnc(const std::string mcc, const std::string mnc) {
int mncValue = fromString<int>(mnc);
mcc_digit1 = mccValue / 100;
mcc_digit2 = (uint8_t) floor((double) (mccValue % 100) / 10);
mcc_digit2 = (mccValue - mcc_digit1 * 100) /
10;
mcc_digit3 = mccValue % 10;
mnc_digit1 = (uint8_t) floor(((double) mncValue / 100));
if (!mnc_digit1) mnc_digit1 = 0xf;
mnc_digit2 = (uint8_t) floor((double) (mncValue % 100) / 10);
mnc_digit3 = mncValue % 10;
if (mncValue > 99) {
mnc_digit3 = mncValue / 100;
} else {
mnc_digit3 = 0xf;
}
mnc_digit1 = (uint8_t) floor((double) (mncValue % 100) / 10);
mnc_digit2 = mncValue % 10;
}
//------------------------------------------------------------------------------
......@@ -76,10 +80,15 @@ void PlmnId::getMcc(std::string& mcc) {
//------------------------------------------------------------------------------
void PlmnId::getMnc(std::string& mnc) {
int m_mnc = 0;
if (mnc_digit1 == 0xf)
m_mnc = mnc_digit2 * 10 + mnc_digit3;
else
m_mnc = mnc_digit1 * 100 + mnc_digit2 * 10 + mnc_digit3;
if (mnc_digit3 == 0xf) {
m_mnc = mnc_digit1 * 10 + mnc_digit2;
if (mnc_digit1 == 0) {
mnc = "0" + to_string(m_mnc);
return;
}
} else {
m_mnc = mnc_digit3 * 100 + mnc_digit1 * 10 + mnc_digit2;
}
mnc = to_string(m_mnc);
}
......@@ -89,9 +98,9 @@ bool PlmnId::encode2octetstring(Ngap_PLMNIdentity_t& plmn) {
uint8_t* buffer = (uint8_t*) calloc(1, 3 * sizeof(uint8_t));
if (!buffer) return false;
buffer[0] = (mcc_digit1 & 0x0f) | ((mcc_digit2 & 0x0f) << 4);
buffer[1] = (mcc_digit3 & 0x0f) | ((mnc_digit1 & 0x0f) << 4);
buffer[2] = (mnc_digit2 & 0x0f) | ((mnc_digit3 & 0x0f) << 4);
buffer[0] = 0x00 | ((mcc_digit2 & 0x0f) << 4) | (mcc_digit1 & 0x0f);
buffer[1] = 0x00 | ((mnc_digit3 & 0x0f) << 4) | (mcc_digit3 & 0x0f);
buffer[2] = 0x00 | ((mnc_digit2 & 0x0f) << 4) | (mnc_digit1 & 0x0f);
plmn.buf = buffer;
return true;
......@@ -102,10 +111,11 @@ bool PlmnId::decodefromoctetstring(Ngap_PLMNIdentity_t& plmn) {
if (!plmn.buf) return false;
mcc_digit1 = plmn.buf[0] & 0x0f;
mcc_digit2 = plmn.buf[0] >> 4;
mcc_digit3 = plmn.buf[1] & 0x0f;
mnc_digit1 = plmn.buf[1] >> 4;
mnc_digit2 = plmn.buf[2] & 0x0f;
mnc_digit3 = plmn.buf[2] >> 4;
mnc_digit3 = plmn.buf[1] >> 4;
mnc_digit1 = plmn.buf[2] & 0x0f;
mnc_digit2 = plmn.buf[2] >> 4;
return true;
}
......
......@@ -49,12 +49,12 @@ class PlmnId {
void getMnc(std::string& mnc);
private:
uint8_t mcc_digit1;
uint8_t mcc_digit2;
uint8_t mcc_digit1;
uint8_t mnc_digit3; // in case of 2 digit MNC, it should be 0xf
uint8_t mcc_digit3;
uint8_t mnc_digit1; // in case of 2 digit MNC, it should be 0xf
uint8_t mnc_digit2;
uint8_t mnc_digit3;
uint8_t mnc_digit1;
};
} // namespace ngap
......
......@@ -85,6 +85,7 @@ bool ResetType::decode(Ngap_ResetType_t* type) {
} else {
return false;
}
return true;
}
//------------------------------------------------------------------------------
......
......@@ -89,6 +89,7 @@ bool UEAssociationLogicalNGConnectionItem::encode(
amfUeNgapId->encode2AMF_UE_NGAP_ID(*item.aMF_UE_NGAP_ID);
item.rAN_UE_NGAP_ID = new Ngap_RAN_UE_NGAP_ID_t();
ranUeNgapId->encode2RAN_UE_NGAP_ID(*item.rAN_UE_NGAP_ID);
return true;
}
//------------------------------------------------------------------------------
......@@ -98,6 +99,7 @@ bool UEAssociationLogicalNGConnectionItem::encode(
item.amfUeNgapId = amfUeNgapId;
item.ranUeNgapId = new RAN_UE_NGAP_ID();
item.ranUeNgapId = ranUeNgapId;
return true;
}
//------------------------------------------------------------------------------
......
......@@ -108,6 +108,7 @@ bool NGResetMsg::getResetType(ResetType& resetType) {
this->resetType->getResetType() == Ngap_ResetType_PR_partOfNG_Interface) {
// TODO
}
return true;
}
//------------------------------------------------------------------------------
......
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