Commit 3e5fee86 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_nssai_mismatch' into 'develop'

Fix nssai mismatch

See merge request oai/cn5g/oai-cn5g-amf!76
parents 710fa651 9caf610b
......@@ -85,7 +85,7 @@ amf_app::amf_app(const amf_config& amf_cfg)
throw;
}
// Register to NRF
// Register to NRF if needed
if (amf_cfg.support_features.enable_nf_registration) register_to_nrf();
timer_id_t tid = itti_inst->timer_setup(
......@@ -146,7 +146,7 @@ void amf_app_task(void*) {
}
} break;
default:
Logger::amf_app().info("no handler for msg type %d", msg->msg_type);
Logger::amf_app().info("No handler for msg type %d", msg->msg_type);
}
} while (true);
}
......@@ -191,6 +191,7 @@ std::shared_ptr<ue_context> amf_app::ran_amf_id_2_ue_context(
return ue_ctx_key.at(ue_context_key);
}
//------------------------------------------------------------------------------
bool amf_app::ran_amf_id_2_ue_context(
const std::string& ue_context_key, std::shared_ptr<ue_context>& uc) const {
std::shared_lock lock(m_ue_ctx_key);
......@@ -201,6 +202,7 @@ bool amf_app::ran_amf_id_2_ue_context(
} else
return false;
}
//------------------------------------------------------------------------------
void amf_app::set_ran_amf_id_2_ue_context(
const string& ue_context_key, std::shared_ptr<ue_context> uc) {
......
......@@ -154,6 +154,20 @@ typedef struct guami_s {
typedef struct slice_s {
std::string sST;
std::string sD;
bool operator==(const struct slice_s& s) const {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
return true;
} else {
return false;
}
}
bool operator>(const struct slice_s& s) const {
if (this->sST.compare(s.sST) > 0) return true;
if (this->sST.compare(s.sST) == 0) {
if (this->sD.compare(s.sD) > 0) return true;
if (this->sD.compare(s.sD) < 0) return false;
}
}
} slice_t;
typedef struct plmn_support_item_s {
......
This diff is collapsed.
......@@ -182,6 +182,10 @@ class amf_n1 {
void initialize_registration_accept(
std::unique_ptr<nas::RegistrationAccept>& registration_accept);
void initialize_registration_accept(
std::unique_ptr<nas::RegistrationAccept>& registration_accept,
std::shared_ptr<nas_context>& nc);
bool find_ue_context(
const std::shared_ptr<nas_context>& nc, std::shared_ptr<ue_context>& uc);
......@@ -209,7 +213,7 @@ class amf_n1 {
void ue_initiate_de_registration_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas);
void registration_request_handle(
bool isNasSig, std::shared_ptr<nas_context> nc, uint32_t ran_ue_ngap_id,
bool isNasSig, std::shared_ptr<nas_context>& nc, uint32_t ran_ue_ngap_id,
long amf_ue_ngap_id, std::string snn, bstring reg);
void authentication_response_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg);
......@@ -219,8 +223,6 @@ class amf_n1 {
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas_msg);
void security_mode_reject_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas_msg);
void ul_nas_transport_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas);
void ul_nas_transport_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas, plmn_t plmn);
void registration_complete_handle(
......
......@@ -288,13 +288,13 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
}
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
if (!uc.get()) {
Logger::amf_n11().error(
"No UE context for %s exit", ue_context_key.c_str());
return;
}
// Create PDU Session Context if not available
std::shared_ptr<pdu_session_context> psc = {};
if (!uc.get()->find_pdu_session_context(smf.pdu_sess_id, psc)) {
psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
......@@ -307,6 +307,7 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
return;
}
// Store corresponding info in PDU Session Context
psc.get()->amf_ue_ngap_id = nc.get()->amf_ue_ngap_id;
psc.get()->ran_ue_ngap_id = nc.get()->ran_ue_ngap_id;
psc.get()->req_type = smf.req_type;
......@@ -316,6 +317,10 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
psc.get()->plmn.mcc = smf.plmn.mcc;
psc.get()->plmn.mnc = smf.plmn.mnc;
Logger::amf_n1().debug(
"PDU Session Context, NSSAI SST (0x%x) SD %s", psc.get()->snssai.sST,
psc.get()->snssai.sD.c_str());
// parse binary dnn and store
std::string dnn = "default"; // If DNN doesn't available, use "default"
if ((smf.dnn != nullptr) && (blength(smf.dnn) > 0)) {
......@@ -444,15 +449,16 @@ void amf_n11::handle_pdu_session_initial_request(
pdu_session_establishment_request["gpsi"] = "msisdn-200000000001";
pdu_session_establishment_request["dnn"] = dnn.c_str();
pdu_session_establishment_request["sNssai"]["sst"] = psc.get()->snssai.sST;
pdu_session_establishment_request["sNssai"]["sd"] = psc.get()->snssai.sD;
pdu_session_establishment_request["sNssai"]["sd"] =
psc.get()->snssai.sD.c_str();
pdu_session_establishment_request["pduSessionId"] = psc.get()->pdu_session_id;
pdu_session_establishment_request["requestType"] =
"INITIAL_REQUEST"; // TODO: from SM_MSG
pdu_session_establishment_request["servingNfId"] = "servingNfId";
pdu_session_establishment_request["servingNetwork"]["mcc"] =
psc.get()->plmn.mcc;
psc.get()->plmn.mcc.c_str();
pdu_session_establishment_request["servingNetwork"]["mnc"] =
psc.get()->plmn.mnc;
psc.get()->plmn.mnc.c_str();
pdu_session_establishment_request["anType"] = "3GPP_ACCESS"; // TODO
pdu_session_establishment_request["smContextStatusUri"] =
"http://" +
......@@ -466,7 +472,10 @@ void amf_n11::handle_pdu_session_initial_request(
["contentId"] = "n1SmMsg";
std::string json_part = pdu_session_establishment_request.dump();
std::string n1SmMsg = {};
Logger::amf_n11().debug("Message body %s", json_part.c_str());
std::string n1SmMsg = {};
octet_stream_2_hex_stream((uint8_t*) bdata(sm_msg), blength(sm_msg), n1SmMsg);
uint8_t http_version = 1;
......
......@@ -350,7 +350,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
std::string gnb_name = {};
if (!itti_msg.ngSetupReq->getRanNodeName(gnb_name)) {
Logger::amf_n2().warn("IE RanNodeName not existed");
Logger::amf_n2().warn("Missing IE RanNodeName");
} else {
gc->gnb_name = gnb_name;
gnbItem.gnb_name = gnb_name;
......@@ -427,7 +427,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
tmp.mcc = amf_cfg.plmn_list[i].mcc;
tmp.mnc = amf_cfg.plmn_list[i].mnc;
for (int j = 0; j < amf_cfg.plmn_list[i].slice_list.size(); j++) {
SliceSupportItem_t s_tmp;
S_Nssai s_tmp;
s_tmp.sst = amf_cfg.plmn_list[i].slice_list[j].sST;
s_tmp.sd = amf_cfg.plmn_list[i].slice_list[j].sD;
tmp.slice_list.push_back(s_tmp);
......@@ -861,14 +861,26 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
0xe000); // TODO: remove hardcoded value
msg->setSecurityKey((uint8_t*) bdata(itti_msg.kgnb));
msg->setNasPdu((uint8_t*) bdata(itti_msg.nas), blength(itti_msg.nas));
// Allowed NSSAI
// Get the list allowed NSSAI from the common PLMN between gNB and AMF
std::vector<S_Nssai> list;
for (auto p : amf_cfg.plmn_list) {
for (auto s : p.slice_list) {
S_Nssai item;
item.sst = s.sST;
item.sd = s.sD;
list.push_back(item);
/* for (auto p : amf_cfg.plmn_list) {
for (auto s : p.slice_list) {
S_Nssai item;
item.sst = s.sST;
item.sd = s.sD;
list.push_back(item);
}
}
*/
for (auto s : gc.get()->s_ta_list) {
for (auto p : s.b_plmn_list) {
for (auto s : p.slice_list) {
S_Nssai item;
item.sst = s.sst;
item.sd = s.sd;
list.push_back(item);
}
}
}
msg->setAllowedNssai(list);
......@@ -910,6 +922,8 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
}
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n2().debug("SUPI (%s)", supi.c_str());
// Get S_NSSAI from PDU Session Context
std::shared_ptr<pdu_session_context> psc = {};
if (!amf_app_inst->find_pdu_session_context(
......@@ -917,7 +931,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
Logger::amf_n2().warn(
"Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
item.s_nssai.sst = "01";
item.s_nssai.sd = "None";
item.s_nssai.sd = "none";
} else {
item.s_nssai.sst = std::to_string(psc.get()->snssai.sST);
item.s_nssai.sd = psc.get()->snssai.sD;
......@@ -1016,8 +1030,9 @@ void amf_n2::handle_itti_message(
}
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n2().debug("SUPI (%s)", supi.c_str());
std::shared_ptr<pdu_session_context> psc = {};
// Get SNSSAI info from PDU Session Context
std::shared_ptr<pdu_session_context> psc = {};
if (!amf_app_inst->find_pdu_session_context(
supi, itti_msg.pdu_session_id, psc)) {
Logger::amf_n2().warn(
......@@ -1029,8 +1044,9 @@ void amf_n2::handle_itti_message(
item.s_nssai.sd = psc.get()->snssai.sD;
}
// item.s_nssai.sst = std::to_string(psc.get()->snssai.sST);
// item.s_nssai.sd = psc.get()->snssai.sD;
Logger::amf_n2().debug(
"S_NSSAI (SST, SD) %s, %s", item.s_nssai.sst.c_str(),
item.s_nssai.sd.c_str());
item.pduSessionResourceSetupRequestTransfer.buf =
(uint8_t*) bdata(itti_msg.n2sm);
......@@ -1443,7 +1459,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
std::vector<S_NSSAI> Allowed_Nssai;
for (int i = 0; i < amf_cfg.plmn_list.size(); i++) {
for (int j = 0; j < amf_cfg.plmn_list[i].slice_list.size(); j++) {
SliceSupportItem_t s_tmp;
S_Nssai s_tmp;
S_NSSAI s_nssai = {};
s_nssai.setSst(amf_cfg.plmn_list[i].slice_list[j].sST);
s_nssai.setSd(amf_cfg.plmn_list[i].slice_list[j].sD);
......@@ -2102,6 +2118,7 @@ std::vector<SupportedItem_t> amf_n2::get_common_plmn(
for (int k = 0; k < list[j].b_plmn_list.size(); k++) {
if (!(list[j].b_plmn_list[k].mcc.compare(amf_cfg.plmn_list[i].mcc)) &&
!(list[j].b_plmn_list[k].mnc.compare(amf_cfg.plmn_list[i].mnc))) {
// TODO: compare NSSAI
plmn_list.push_back(list[j]);
}
}
......
......@@ -30,24 +30,24 @@
//------------------------------------------------------------------------------
nas_context::nas_context() : _vector(), _5g_he_av(), _5g_av(), kamf() {
security_ctx = nullptr;
is_imsi_present = false;
is_stacs_available = false;
is_auth_vectors_present = false;
auts = nullptr;
ctx_avaliability_ind = false;
amf_ue_ngap_id = 0;
ran_ue_ngap_id = 0;
_5gmm_state = {};
registration_type = 0;
follow_on_req_pending_ind = false;
ngKsi = 0;
mmCapability = 0;
ueSecurityCapEnc = 0;
ueSecurityCapInt = 0;
ueSecurityCapEEA = 0;
ueSecurityCapEIA = 0;
requestedNssai = {};
security_ctx = nullptr;
is_imsi_present = false;
is_stacs_available = false;
is_auth_vectors_present = false;
auts = nullptr;
ctx_avaliability_ind = false;
amf_ue_ngap_id = 0;
ran_ue_ngap_id = 0;
_5gmm_state = {};
registration_type = 0;
follow_on_req_pending_ind = false;
ngKsi = 0;
mmCapability = 0;
ueSecurityCapEnc = 0;
ueSecurityCapInt = 0;
ueSecurityCapEEA = 0;
ueSecurityCapEIA = 0;
// requestedNssai = {};
is_specific_procedure_for_registration_running = false;
is_specific_procedure_for_deregistration_running = false;
is_specific_procedure_for_eCell_inactivity_running = false;
......
......@@ -497,8 +497,9 @@ int _5GSMobilityIdentity::decodefrombuffer(
decoded_size++;
len2 = *(buf + decoded_size);
decoded_size++;
uint16_t length = (0x0000) | (len1 << 8) | len2;
length = (0x0000) | (len1 << 8) | len2;
Logger::amf_n1().debug("Decoded 5GSMobilityIdentity IE length %d", length);
switch (*(buf + decoded_size) & 0x07) {
case SUCI: {
typeOfIdentity = SUCI;
......@@ -515,8 +516,7 @@ int _5GSMobilityIdentity::decodefrombuffer(
} break;
case IMEISVI: {
typeOfIdentity = IMEISVI;
decoded_size +=
imeisv_decodefrombuffer(buf + decoded_size, len - decoded_size);
decoded_size += imeisv_decodefrombuffer(buf + decoded_size, length);
return decoded_size;
} break;
case _5G_S_TMSI: {
......@@ -707,14 +707,14 @@ int _5GSMobilityIdentity::imeisv_decodefrombuffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity IMEISV");
int decoded_size = 0;
decode_bstring(
&(_IMEISV.identity), length, (buf + decoded_size), len - decoded_size);
decoded_size += length;
for (int i = 0; i < length; i++) {
&(_IMEISV.identity), len, (buf + decoded_size), len - decoded_size);
decoded_size += len;
for (int i = 0; i < len; i++) {
Logger::nas_mm().debug(
"decoded 5GSMobilityIdentity IMEISV value(0x%x)",
(uint8_t) _IMEISV.identity->data[i]);
}
Logger::nas_mm().debug(
"decoded 5GSMobilityIdentity IMEISV len(%d)", decoded_size);
"decoded 5GSMobilityIdentity IMEISV len (%d)", decoded_size);
return decoded_size;
}
......@@ -94,13 +94,14 @@ int NAS_Message_Container::decodefrombuffer(
Logger::nas_mm().debug("Decoding NAS_Message_Container iei (0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
decoded_size++;
decoded_size++; // for IE
}
length = 0;
length |= (*(buf + decoded_size)) << 8;
decoded_size++;
length |= *(buf + decoded_size);
decoded_size++;
decode_bstring(&_value, length, (buf + decoded_size), len - decoded_size);
decoded_size += length;
for (int i = 0; i < length; i++) {
......
......@@ -145,9 +145,9 @@ int NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
a.sst = *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd = -1;
a.mHplmnSst = -1;
a.mHplmnSd = -1;
a.sd = 0;
a.mHplmnSst = 0;
a.mHplmnSd = 0;
} break;
case 4: {
decoded_size++;
......@@ -158,16 +158,16 @@ int NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd << 8;
a.sd <<= 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd << 8;
a.sd <<= 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.mHplmnSst = -1;
a.mHplmnSd = -1;
a.mHplmnSst = 0;
a.mHplmnSd = 0;
} break;
case 5: {
decoded_size++;
......@@ -178,18 +178,18 @@ int NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd << 8;
a.sd <<= 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd << 8;
a.sd <<= 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.mHplmnSst = *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.mHplmnSd = -1;
a.mHplmnSd = 0;
} break;
case 8: {
decoded_size++;
......@@ -200,11 +200,11 @@ int NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd << 8;
a.sd <<= 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.sd << 8;
a.sd <<= 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
......@@ -214,11 +214,11 @@ int NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
a.mHplmnSd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.mHplmnSd << 16;
a.mHplmnSd <<= 8;
a.mHplmnSd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
a.mHplmnSd << 8;
a.mHplmnSd <<= 8;
a.mHplmnSd |= *(buf + decoded_size);
decoded_size++;
length_tmp--;
......
......@@ -131,9 +131,9 @@ int S_NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
case 1: {
a.sst = *(buf + decoded_size);
decoded_size++;
a.sd = -1;
a.mHplmnSst = -1;
a.mHplmnSd = -1;
a.sd = 0;
a.mHplmnSst = 0;
a.mHplmnSd = 0;
} break;
case 4: {
a.sst = *(buf + decoded_size);
......@@ -147,8 +147,8 @@ int S_NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
a.sd |= *(buf + decoded_size);
a.sd &= 0x00ffffff;
decoded_size++;
a.mHplmnSst = -1;
a.mHplmnSd = -1;
a.mHplmnSst = 0;
a.mHplmnSd = 0;
} break;
case 5: {
a.sst = *(buf + decoded_size);
......@@ -164,7 +164,7 @@ int S_NSSAI::decodefrombuffer(uint8_t* buf, int len, bool is_option) {
decoded_size++;
a.mHplmnSst = *(buf + decoded_size);
decoded_size++;
a.mHplmnSd = -1;
a.mHplmnSd = 0;
} break;
case 8: {
a.sst = *(buf + decoded_size);
......
......@@ -45,6 +45,13 @@ typedef struct SNSSAI_s {
int32_t sd;
int32_t mHplmnSst;
int32_t mHplmnSd;
SNSSAI_s& operator=(const struct SNSSAI_s& s) {
sst = s.sst;
sd = s.sd;
mHplmnSst = s.mHplmnSst;
mHplmnSd = s.mHplmnSd;
return *this;
}
} SNSSAI_t;
typedef struct {
uint8_t ie_type;
......
......@@ -82,12 +82,14 @@ void DeregistrationRequest::getDeregistrationType(
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getngKSI(uint8_t& ng_ksi) {
bool DeregistrationRequest::getngKSI(uint8_t& ng_ksi) {
if (ie_ngKSI) {
ng_ksi =
(ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
return true;
} else {
ng_ksi = 0;
// ng_ksi = 0;
return false;
}
}
......
......@@ -58,7 +58,7 @@ class DeregistrationRequest {
void getDeregistrationType(uint8_t& dereg_type);
void getDeregistrationType(_5gs_deregistration_type_t& type);
void getngKSI(uint8_t& ng_ksi);
bool getngKSI(uint8_t& ng_ksi);
void getMobilityIdentityType(uint8_t& type);
std::string get_5g_guti();
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi);
......
......@@ -113,7 +113,6 @@ void RegistrationAccept::set5G_GUTI(
int regionId = fromString<int>(amfRegionId);
int setId = fromString<int>(amfSetId);
int pointer = fromString<int>(amfPointer);
cout << "amfRegionID: " << amfRegionId.c_str() << endl;
ie_5g_guti->set5GGUTI(
mcc, mnc, (uint8_t) regionId, (uint16_t) setId, (uint8_t) pointer, tmsi);
ie_5g_guti->setIEI(0x77);
......
......@@ -92,13 +92,14 @@ void RegistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
}
//------------------------------------------------------------------------------
uint8_t RegistrationRequest::getngKSI() {
bool RegistrationRequest::getngKSI(uint8_t& ng_ksi) {
if (ie_ngKSI) {
return (
(ie_ngKSI->getTypeOfSecurityContext()) |
ie_ngKSI->getasKeyIdentifier());
ng_ksi =
(ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
return true;
} else {
return 0;
// ng_ksi = 0;
return false;
}
}
......
......@@ -93,7 +93,7 @@ class RegistrationRequest {
void setEPS_Bearer_Context_Status(uint16_t value);
bool get5GSRegistrationType(bool& is_for, uint8_t& reg_type /*3bits*/);
uint8_t getngKSI();
bool getngKSI(uint8_t& ng_ksi);
uint8_t getMobilityIdentityType();
std::string get_5g_guti(); //"error" for missing IE GUTI
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi);
......
......@@ -36,10 +36,10 @@ using namespace nas;
//------------------------------------------------------------------------------
SecurityModeComplete::SecurityModeComplete() {
Logger::nas_mm().debug("initiating class SecurityModeComplete");
plain_header = NULL;
ie_imeisv = NULL;
ie_nas_message_container = NULL;
ie_non_imeisvpei = NULL;
plain_header = nullptr;
ie_imeisv = nullptr;
ie_nas_message_container = nullptr;
ie_non_imeisvpei = nullptr;
};
//------------------------------------------------------------------------------
......@@ -75,9 +75,9 @@ void SecurityModeComplete::setNON_IMEISV(IMEISV_t imeisv) {
bool SecurityModeComplete::getIMEISV(IMEISV_t& imeisv) {
if (ie_imeisv) {
ie_imeisv->getIMEISV(imeisv);
return 0;
return true;
} else {
return -1;
return false;
}
}
......@@ -85,9 +85,9 @@ bool SecurityModeComplete::getIMEISV(IMEISV_t& imeisv) {
bool SecurityModeComplete::getNasMessageContainer(bstring& nas) {
if (ie_nas_message_container) {
ie_nas_message_container->getValue(nas);
return 0;
return true;
} else {
return -1;
return false;
}
}
......@@ -95,9 +95,9 @@ bool SecurityModeComplete::getNasMessageContainer(bstring& nas) {
bool SecurityModeComplete::getNON_IMEISV(IMEISV_t& imeisv) {
if (ie_non_imeisvpei) {
ie_non_imeisvpei->getIMEISV(imeisv);
return 0;
return true;
} else {
return -1;
return false;
}
}
......@@ -153,40 +153,40 @@ int SecurityModeComplete::encode2buffer(uint8_t* buf, int len) {
int SecurityModeComplete::decodefrombuffer(
NasMmPlainHeader* header, uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoding SecurityModeComplete message");
int decoded_size = 3;
int decoded_size = 3; // For the header
plain_header = header;
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("First option IEI (0x%x)", octet);
while ((octet != 0x0)) {
Logger::nas_mm().debug("Decoded_size (%d)", decoded_size);
// while ((octet != 0x0)) {
while (len - decoded_size > 0) {
uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("Optional IEI (0x%x)", octet);
switch (octet) {
case 0x77: {
Logger::nas_mm().debug("Decoding IEI (0x77)");
ie_imeisv = new _5GSMobilityIdentity();
decoded_size += ie_imeisv->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
} break;
case 0x71: {
Logger::nas_mm().debug("Decoding IEI (0x71)");
ie_nas_message_container = new NAS_Message_Container();
decoded_size += ie_nas_message_container->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
} break;
case 0x78: {
Logger::nas_mm().debug("Decoding IEI (0x78)");
ie_non_imeisvpei = new _5GSMobilityIdentity();
decoded_size += ie_non_imeisvpei->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
} break;
default: {
Logger::nas_mm().debug("Unexpected IEI (0x%x)", octet);
return TLV_UNEXPECTED_IEI;
}
}
}
Logger::nas_mm().debug(
"Decoded SecurityModeComplete message len (%d)", decoded_size);
return 1;
return TLV_ERROR_OK;
}
......@@ -246,13 +246,13 @@ int ServiceRequest::decodefrombuffer(
}
//------------------------------------------------------------------------------
uint8_t ServiceRequest::getngKSI() {
bool ServiceRequest::getngKSI(uint8_t& ng_ksi) {
if (ie_ngKSI) {
uint8_t a = 0;
a = (ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
return a;
ng_ksi =
(ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
return true;
} else {
return 0;
return false;
}
}
......
......@@ -56,7 +56,7 @@ class ServiceRequest {
public:
int decodefrombuffer(NasMmPlainHeader* header, uint8_t* buf, int len);
uint8_t getngKSI();
bool getngKSI(uint8_t& ng_ksi);
uint8_t getServiceType();
bool get5G_S_TMSI(uint16_t& amfSetId, uint8_t& amfPointer, string& tmsi);
uint16_t getUplinkDataStatus();
......
......@@ -45,14 +45,29 @@ extern "C" {
namespace ngap {
typedef struct SliceSupportItem_s {
typedef struct S_Nssai_s {
std::string sst;
std::string sd;
} SliceSupportItem_t;
bool operator==(const struct S_Nssai_s& s) const {
if ((s.sst == this->sst) && (s.sd.compare(this->sd) == 0)) {
return true;
} else {
return false;
}
}
bool operator>(const struct S_Nssai_s& s) const {
if (this->sst.compare(s.sst) > 0) return true;
if (this->sst.compare(s.sst) == 0) {
if (this->sd.compare(s.sd) > 0) return true;
if (this->sd.compare(s.sd) < 0) return false;
}
}
} S_Nssai;
typedef struct PlmnSliceSupport_s {
std::string mcc;
std::string mnc;
std::vector<SliceSupportItem_t> slice_list;
std::vector<S_Nssai> slice_list;
} PlmnSliceSupport_t;
typedef struct SupportedItem_s {
......@@ -89,11 +104,6 @@ typedef struct Guami_s {
std::string AmfPointer;
} Guami_t;
typedef struct {
std::string sst;
std::string sd;
} S_Nssai;
typedef struct {
uint8_t pduSessionId;
uint8_t* pduSessionNAS_PDU;
......
......@@ -375,7 +375,7 @@ bool NGSetupRequestMsg::getSupportedTAList(
plmnId_decode->getMcc(broadcastplmn_data.mcc);
plmnId_decode->getMnc(broadcastplmn_data.mnc);
for (int k = 0; k < numofsnssai; k++) {
SliceSupportItem_t slicesupport_data;
S_Nssai slicesupport_data;
snssai_decode[k].getSst(slicesupport_data.sst);
snssai_decode[k].getSd(slicesupport_data.sd);
broadcastplmn_data.slice_list.push_back(slicesupport_data);
......
......@@ -379,7 +379,7 @@ bool NGSetupResponseMsg::getPlmnSupportList(
plmn->getMcc(plmnSupportItem_data.mcc);
plmn->getMnc(plmnSupportItem_data.mnc);
for (int j = 0; j < numofsnssai; j++) {
SliceSupportItem_t sliceSupportItem_data;
S_Nssai sliceSupportItem_data;
snssai[j].getSst(sliceSupportItem_data.sst);
snssai[j].getSd(sliceSupportItem_data.sd);
plmnSupportItem_data.slice_list.push_back(sliceSupportItem_data);
......
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