Commit b36adeb9 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup

parent 94376ca4
......@@ -24,7 +24,7 @@ AMF =
PID_DIRECTORY = "/var/run";
########################## NG SETUP RESPONSE IEs ###############################
AMF_NAME = "amf";
AMF_NAME = "OAI-AMF";
GUAMI:{MCC = "208"; MNC = "95"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "1"}
ServedGUAMIList = (
{MCC = "208"; MNC = "95"; RegionID = "10"; AMFSetID = "1"; AMFPointer = "0"}, #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
......
......@@ -221,13 +221,13 @@ void amf_app::handle_itti_message(itti_nas_signalling_establishment_request &itt
string ue_context_key = "app_ue_ranid_" + to_string(itti_msg.ran_ue_ngap_id) + ":amfid_" + to_string(amf_ue_ngap_id);
//if(!is_amf_ue_id_2_ue_context(amf_ue_ngap_id)){
if (!is_ran_amf_id_2_ue_context(ue_context_key)) {
Logger::amf_app().debug("No existed ue_context, create one with ran_amf_id(%s)", ue_context_key.c_str());
Logger::amf_app().debug("No existing UE Context, Create a new one with ran_amf_id %s", ue_context_key.c_str());
uc = std::shared_ptr < ue_context > (new ue_context());
//set_amf_ue_ngap_id_2_ue_context(amf_ue_ngap_id, uc);
set_ran_amf_id_2_ue_context(ue_context_key, uc);
}
if (uc.get() == nullptr) {
Logger::amf_app().error("Failed to create ue_context with ran_amf_id(%s)", ue_context_key.c_str());
Logger::amf_app().error("Failed to create ue_context with ran_amf_id %s", ue_context_key.c_str());
} else {
uc.get()->cgi = itti_msg.cgi;
uc.get()->tai = itti_msg.tai;
......@@ -245,7 +245,7 @@ void amf_app::handle_itti_message(itti_nas_signalling_establishment_request &itt
if (itti_msg.is_5g_s_tmsi_present) {
guti = itti_msg.tai.mcc + itti_msg.tai.mnc + amf_cfg.guami.regionID + itti_msg._5g_s_tmsi;
is_guti_valid = true;
Logger::amf_app().debug("Receiving guti: %s", guti.c_str());
Logger::amf_app().debug("Receiving GUTI %s", guti.c_str());
}
itti_uplink_nas_data_ind *itti_n1_msg = new itti_uplink_nas_data_ind(TASK_AMF_APP, TASK_AMF_N1);
......@@ -276,7 +276,7 @@ void amf_app::handle_post_sm_context_response_error_400() {
bool amf_app::generate_5g_guti(uint32_t ranid, long amfid, string &mcc, string &mnc, uint32_t &tmsi) {
string ue_context_key = "app_ue_ranid_" + to_string(ranid) + ":amfid_" + to_string(amfid);
if (!is_ran_amf_id_2_ue_context(ue_context_key)) {
Logger::amf_app().error("No UE context for ran_amf_id(%s), exit", ue_context_key.c_str());
Logger::amf_app().error("No UE context for ran_amf_id %s, exit", ue_context_key.c_str());
return false;
}
std::shared_ptr<ue_context> uc;
......
......@@ -242,32 +242,32 @@ int amf_config::load(const std::string &config_file) {
void amf_config::display() {
Logger::config().info("======= AMF =======");
Logger::config().info("Configuration AMF:");
Logger::config().info("- Instance .......................: %d", instance);
Logger::config().info("- PID dir ........................: %s", pid_dir.c_str());
Logger::config().info("- AMF NAME........................: %s", AMF_Name.c_str());
Logger::config().info("- GUAMI...........................: ");
Logger::config().info(" [%s] [%s] [%s] [%s] [%s]", guami.mcc.c_str(), guami.mnc.c_str(), guami.regionID.c_str(), guami.AmfSetID.c_str(), guami.AmfPointer.c_str());
Logger::config().info("- ServedGUAMIList ................: ");
Logger::config().info("- Instance ...........................................: %d", instance);
Logger::config().info("- PID dir ............................................: %s", pid_dir.c_str());
Logger::config().info("- AMF NAME............................................: %s", AMF_Name.c_str());
Logger::config().info("- GUAMI (MCC, MNC, Region ID, AMF Set ID, AMF pointer): ");
Logger::config().info(" (%s, %s, %s, %s, %s )", guami.mcc.c_str(), guami.mnc.c_str(), guami.regionID.c_str(), guami.AmfSetID.c_str(), guami.AmfPointer.c_str());
Logger::config().info("- ServedGUAMIList ....................................: ");
for (int i = 0; i < guami_list.size(); i++) {
Logger::config().info(" [%s] [%s] [%s] [%s] [%s]", guami_list[i].mcc.c_str(), guami_list[i].mnc.c_str(), guami_list[i].regionID.c_str(), guami_list[i].AmfSetID.c_str(), guami_list[i].AmfPointer.c_str());
Logger::config().info(" (%s, %s, %s , %s, %s)", guami_list[i].mcc.c_str(), guami_list[i].mnc.c_str(), guami_list[i].regionID.c_str(), guami_list[i].AmfSetID.c_str(), guami_list[i].AmfPointer.c_str());
}
Logger::config().info("- RelativeAMFCapacity ............: %d", relativeAMFCapacity);
Logger::config().info("- PLMNSupportList ................: ");
Logger::config().info("- RelativeAMFCapacity ................................: %d", relativeAMFCapacity);
Logger::config().info("- PLMNSupportList (MCC, MNC)..........................: ");
for (int i = 0; i < plmn_list.size(); i++) {
Logger::config().info(" [%s] [%s] ", plmn_list[i].mcc.c_str(), plmn_list[i].mnc.c_str());
Logger::config().info(" TAC[%d]", plmn_list[i].tac);
Logger::config().info(" - SliceSupportList ............: ");
Logger::config().info(" TAC [%d]", plmn_list[i].tac);
Logger::config().info(" - SliceSupportList (SST, SD) ....................: ");
for (int j = 0; j < plmn_list[i].slice_list.size(); j++) {
Logger::config().info(" [%s] [%s] ", plmn_list[i].slice_list[j].sST.c_str(), plmn_list[i].slice_list[j].sD.c_str());
Logger::config().info(" (%s, %s) ", plmn_list[i].slice_list[j].sST.c_str(), plmn_list[i].slice_list[j].sD.c_str());
}
}
Logger::config().info("- Emergency Support ...............: %s", is_emergency_support.c_str());
Logger::config().info("- MYSQL server ....................: %s", auth_para.mysql_server.c_str());
Logger::config().info("- MYSQL user ......................: %s", auth_para.mysql_user.c_str());
Logger::config().info("- MYSQL pass ......................: %s", auth_para.mysql_pass.c_str());
Logger::config().info("- MYSQL db ........................: %s", auth_para.mysql_db.c_str());
Logger::config().info("- operator key ....................: %s", auth_para.operator_key.c_str());
Logger::config().info("- random ..........................: %s", auth_para.random.c_str());
Logger::config().info("- Emergency Support................... ...............: %s", is_emergency_support.c_str());
Logger::config().info("- MYSQL Server Addr...................................: %s", auth_para.mysql_server.c_str());
Logger::config().info("- MYSQL user .........................................: %s", auth_para.mysql_user.c_str());
Logger::config().info("- MYSQL pass .........................................: %s", auth_para.mysql_pass.c_str());
Logger::config().info("- MYSQL db ...........................................: %s", auth_para.mysql_db.c_str());
Logger::config().info("- operator key .......................................: %s", auth_para.operator_key.c_str());
Logger::config().info("- random .............................................: %s", auth_para.random.c_str());
Logger::config().info("- Remote SMF Pool..................: ");
for (int i = 0; i < smf_pool.size(); i++) {
std::string selected;
......@@ -275,7 +275,7 @@ void amf_config::display() {
selected = "true";
else
selected = "false";
Logger::config().info(" SMF_INSTANCE_ID(%d) : (%s:%s) version(%s) is selected(%s)", smf_pool[i].id, smf_pool[i].ipv4.c_str(), smf_pool[i].port.c_str(), smf_pool[i].version.c_str(), selected.c_str());
Logger::config().info(" SMF_INSTANCE_ID %d (%s:%s, version %s) is selected: %s", smf_pool[i].id, smf_pool[i].ipv4.c_str(), smf_pool[i].port.c_str(), smf_pool[i].version.c_str(), selected.c_str());
}
}
......
......@@ -35,7 +35,7 @@ namespace config {
//------------------------------------------------------------------------------
int amf_modules::load(const std::string &config_file) {
Logger::amf_app().debug("\nLoad AMF module configuration file(%s)", config_file.c_str());
Logger::amf_app().debug("\nLoad AMF module configuration file (%s)", config_file.c_str());
Config cfg;
try {
cfg.readFile(config_file.c_str());
......@@ -80,7 +80,7 @@ int amf_modules::load(const std::string &config_file) {
void amf_modules::display() {
Logger::config().info("======= AMF Registered Modules =======");
Logger::config().info("NGAP Message Modules:");
Logger::config().info("- %s([%d,%d])\n", msgName.c_str(), procedureCode, typeOfMsg);
Logger::config().info("- %s(Procedure code %d, Type of Msg %d)\n", msgName.c_str(), procedureCode, typeOfMsg);
}
}
......@@ -154,7 +154,7 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
snn = "5G:mnc0" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc + ".3gppnetwork.org";
else
snn = "5G:mnc" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc + ".3gppnetwork.org";
Logger::amf_n1().debug("Serving network name: %s", snn.c_str());
Logger::amf_n1().debug("Serving network name %s", snn.c_str());
bstring recved_nas_msg = nas_data_ind.nas_msg;
bstring decoded_plain_msg;
......@@ -165,14 +165,14 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
if (is_guti_2_nas_context(guti))
nc = guti_2_nas_context(guti);
else {
Logger::amf_n1().error("No existed nas_context with guti(%s)", nas_data_ind.guti.c_str());
Logger::amf_n1().error("No existing nas_context with GUTI %s", nas_data_ind.guti.c_str());
return;
}
} else {
if (is_amf_ue_id_2_nas_context(amf_ue_ngap_id))
nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
else
Logger::amf_n1().warn("No existed nas_context with amf_ue_ngap_id(0x%x)", amf_ue_ngap_id);
Logger::amf_n1().warn("No existing nas_context with amf_ue_ngap_id 0x%x", amf_ue_ngap_id);
}
SecurityHeaderType type;
......@@ -250,7 +250,7 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
void amf_n1::nas_signalling_establishment_request_handle(SecurityHeaderType type, std::shared_ptr<nas_context> nc, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, std::string snn, uint8_t ulCount) {
//1. Create nas context, or update nas context
if (nc.get() == nullptr && type == PlainNasMsg) {
Logger::amf_n1().debug("No existing nas_context with amf_ue_ngap_id(0x%x) --> Create new one", amf_ue_ngap_id);
Logger::amf_n1().debug("No existing nas_context with amf_ue_ngap_id 0x%x --> Create a new one", amf_ue_ngap_id);
nc = std::shared_ptr < nas_context > (new nas_context);
if (!nc.get()) {
Logger::amf_n1().error("Cannot allocate memory for new nas_context, exit...");
......@@ -271,21 +271,21 @@ void amf_n1::nas_signalling_establishment_request_handle(SecurityHeaderType type
uint8_t *buf = (uint8_t*) bdata(plain_msg);
uint8_t message_type = *(buf + 2);
Logger::amf_n1().debug("NAS message type(0x%x)", message_type);
Logger::amf_n1().debug("NAS message type 0x%x", message_type);
switch (message_type) {
case REGISTRATION_REQUEST: { //registration request
Logger::amf_n1().debug("Received registration request message , handle ...");
Logger::amf_n1().debug("Received registration request message, handling ...");
registration_request_handle(true, nc, ran_ue_ngap_id, amf_ue_ngap_id, snn, plain_msg);
}
break;
case SERVICE_REQUEST: {
Logger::amf_n1().debug("Received service request message , handle ...");
Logger::amf_n1().debug("Received service request message, handling ...");
nc.get()->security_ctx->ul_count.seq_num = ulCount;
service_request_handle(true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
}
break;
default:
Logger::amf_n1().error("No handler for NAS message(0x%x)", message_type);
Logger::amf_n1().error("No handler for NAS message 0x%x", message_type);
}
}
......@@ -366,7 +366,6 @@ bool amf_n1::check_security_header_type(SecurityHeaderType &type, uint8_t *buffe
//------------------------------------------------------------------------------
void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context> nc, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas) {
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
Logger::amf_n1().info("nas_context pointer(%p)", nc.get());
nas_secu_ctx *secu = nc.get()->security_ctx;
ServiceRequest *serReq = new ServiceRequest();
serReq->decodefrombuffer(nullptr, (uint8_t*) bdata(nas), blength(nas));
......@@ -392,7 +391,7 @@ void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context>
supi2amfId[supi] = amf_ue_ngap_id;
supi2ranId[supi] = ran_ue_ngap_id;
Logger::amf_n1().debug("amf_ue_ngap_id %d, ran_ue_ngap_id %d", amf_ue_ngap_id, ran_ue_ngap_id);
Logger::amf_n1().debug("Key for pdu session context: supi(%s)", supi.c_str());
Logger::amf_n1().debug("Key for pdu session context: SUPI %s", supi.c_str());
std::shared_ptr<pdu_session_context> psc;
if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
psc = amf_n11_inst->supi_to_pdu_ctx(supi);
......@@ -401,7 +400,7 @@ void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context>
return;
}
} else {
Logger::amf_n1().error("Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
Logger::amf_n1().error("Cannot get pdu_session_context with SUPI %s", supi.c_str());
}
itti_initial_context_setup_request *itti_msg = new itti_initial_context_setup_request(TASK_AMF_N1, TASK_AMF_N2);
......@@ -457,16 +456,16 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
} else {
nc.get()->is_imsi_present = true;
nc.get()->imsi = imsi.mcc + imsi.mnc + imsi.msin;
Logger::amf_n1().debug("received imsi(%s)", nc.get()->imsi.c_str());
Logger::amf_n1().debug("Received IMSI %s", nc.get()->imsi.c_str());
supi2amfId[("imsi-" + nc.get()->imsi)] = amf_ue_ngap_id;
supi2ranId[("imsi-" + nc.get()->imsi)] = ran_ue_ngap_id;
imsi2nas_context[("imsi-" + nc.get()->imsi)] = nc;
Logger::amf_n1().info("Associating imsi(%s) with nas_context(%p)", ("imsi-" + nc.get()->imsi).c_str(), nc.get());
Logger::amf_n1().info("Associating IMSI (%s) with nas_context(%p)", ("imsi-" + nc.get()->imsi).c_str(), nc.get());
if (!nc.get()->is_stacs_available) {
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->amf_ue_id_2_ue_context(amf_ue_ngap_id);
Logger::amf_n1().info("Try to find ue_context in amf_app using ran_amf_id(%s)", ue_context_key.c_str());
Logger::amf_n1().info("Try to find ue_context in amf_app using ran_amf_id %s", ue_context_key.c_str());
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
ue_infos ueItem;
update_ue_information_statics(ueItem, "CM-CONNECTED", "REGISTRATION-INITIATING", ran_ue_ngap_id, amf_ue_ngap_id, nc.get()->imsi, "", uc.get()->cgi.mcc, uc.get()->cgi.mnc, uc.get()->cgi.nrCellID);
......@@ -485,9 +484,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
}
break;
}
//2.4.1 try to get supi and format imsi
//2.4.2 try to get 5g-guti
//2.4.3 try to get ...
//3. create nas context
if (nc.get() == nullptr) {
//try to get the GUTI -> nas_context
......@@ -497,12 +494,12 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
supi2amfId[("imsi-" + nc.get()->imsi)] = amf_ue_ngap_id;
supi2ranId[("imsi-" + nc.get()->imsi)] = ran_ue_ngap_id;
} else {
Logger::amf_n1().error("No nas_context with guti(%s)", guti.c_str());
Logger::amf_n1().error("No nas_context with GUTI %s", guti.c_str());
response_registration_reject_msg(_5GMM_CAUSE_ILLEGAL_UE, ran_ue_ngap_id, amf_ue_ngap_id);
return;
}
} else {
Logger::amf_n1().debug("Existing nas_context --> Update");
Logger::amf_n1().debug("Existing nas_context --> Update");
//nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
}
......@@ -754,10 +751,10 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
_5G_HE_AV_t *vector = nc.get()->_5g_he_av;
//1. access to local mysql to fetch ue-related information
if (!connect_to_mysql()) {
Logger::amf_n1().error("Cannot connect to mysql");
Logger::amf_n1().error("Cannot connect to MySQL");
return false;
}
Logger::amf_n1().debug("Connect to mysql successfully");
Logger::amf_n1().debug("Connect to MySQL successfully");
mysql_auth_info_t mysql_resp;
if (get_mysql_auth_info(nc.get()->imsi, mysql_resp)) {
if (auts) {
......@@ -769,19 +766,19 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
free(sqn);
}
if (!get_mysql_auth_info(nc.get()->imsi, mysql_resp)) {
Logger::amf_n1().error("Cannot get data from mysql");
Logger::amf_n1().error("Cannot get data from MySQL");
return false;
}
sqn = mysql_resp.sqn;
for (int i = 0; i < MAX_5GS_AUTH_VECTORS; i++) {
generate_random(vector[i].rand, RAND_LENGTH);
print_buffer("amf_n1", "generated random: rand(5G HE AV)", vector[i].rand, 16);
print_buffer("amf_n1", "Generated random rand (5G HE AV)", vector[i].rand, 16);
generate_5g_he_av_in_udm(mysql_resp.opc, nc.get()->imsi, mysql_resp.key, sqn, nc.get()->serving_network, vector[i]); //serving network name
}
mysql_push_rand_sqn(nc.get()->imsi, vector[MAX_5GS_AUTH_VECTORS - 1].rand, sqn);
} else {
Logger::amf_n1().debug("No auts ...");
Logger::amf_n1().debug("Receive information from mysql with imsi(%s)", nc.get()->imsi.c_str());
Logger::amf_n1().debug("Receive information from MySQL with IMSI %s", nc.get()->imsi.c_str());
//print_buffer("amf_n1", "Received from MYSQL: rand", mysql_resp.rand, 16);
//print_buffer("amf_n1", "Received from MYSQL: opc", mysql_resp.opc, 16);
//print_buffer("amf_n1", "Received from MYSQL: key", mysql_resp.key, 16);
......@@ -796,7 +793,7 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
}
mysql_increment_sqn(nc.get()->imsi);
} else {
Logger::amf_n1().error("Failed to fetch user data from mysql");
Logger::amf_n1().error("Failed to fetch user data from MySQL");
return false;
}
}
......@@ -936,7 +933,7 @@ void amf_n1::handle_auth_vector_successful_result(std::shared_ptr<nas_context> n
int vindex = nc.get()->security_ctx->vector_pointer;
if (!start_authentication_procedure(nc, vindex, nc.get()->ngKsi)) {
Logger::amf_n1().error("Start authentication procedure failure, reject...");
Logger::amf_n1().error("Ran_ue_ngap_id(0x%x)", nc.get()->ran_ue_ngap_id);
Logger::amf_n1().error("Ran_ue_ngap_id 0x%x", nc.get()->ran_ue_ngap_id);
response_registration_reject_msg(_5GMM_CAUSE_INVALID_MANDATORY_INFO, nc.get()->ran_ue_ngap_id, nc.get()->amf_ue_ngap_id); //cause?
} else {
//update mm state -> COMMON-PROCEDURE-INITIATED
......@@ -1056,11 +1053,11 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id, long amf_ue
}
//5. if successful, start SMC procedure; else if failure, response registration reject message with corresponding cause
if (!isAuthOk) {
Logger::amf_n1().error("Authentication Failure for UE with amf_ue_ngap_id(0x%x)", amf_ue_ngap_id);
Logger::amf_n1().error("Authentication Failure for UE with amf_ue_ngap_id 0x%x", amf_ue_ngap_id);
response_registration_reject_msg(_5GMM_CAUSE_ILLEGAL_UE, ran_ue_ngap_id, amf_ue_ngap_id); //cause?
return;
} else {
Logger::amf_n1().debug("Authenticated successfully by network!!!");
Logger::amf_n1().debug("Authenticated successfully by network!");
if (!nc.get()->is_current_security_available) {
if (!start_security_mode_control_procedure(nc)) {
Logger::amf_n1().error("Start SMC procedure failure");
......@@ -1152,7 +1149,7 @@ bool amf_n1::start_security_mode_control_procedure(std::shared_ptr<nas_context>
SecurityModeCommand *smc = new SecurityModeCommand();
smc->setHeader(PLAIN_5GS_MSG);
smc->setNAS_Security_Algorithms(amf_nea, amf_nia);
Logger::amf_n1().debug("encoded ngKSI(0x%x)", nc.get()->ngKsi);
Logger::amf_n1().debug("Encoded ngKSI 0x%x", nc.get()->ngKsi);
smc->setngKSI(NAS_KEY_SET_IDENTIFIER_NATIVE, nc.get()->ngKsi & 0x07);
smc->setUE_Security_Capability(nc.get()->ueSecurityCapEnc, nc.get()->ueSecurityCapInt);
smc->setIMEISV_Request(0xe1);
......@@ -1229,7 +1226,7 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id, long amf_ue_
regAccept->setALLOWED_NSSAI(nssai);
std::string guti = mcc + mnc + amf_cfg.guami.regionID + amf_cfg.guami.AmfSetID + amf_cfg.guami.AmfPointer + std::to_string(tmsi);
Logger::amf_n1().debug("Allocated guti %s", guti.c_str());
Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str());
regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
regAccept->setT3512_Value(0x5, 0x1e);
......@@ -1366,13 +1363,13 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc, uint8_t directio
nsc->ul_count.seq_num = stream_cipher.count;
Logger::amf_n1().debug("Uplink count in uplink: %d", nsc->ul_count.seq_num);
}
Logger::amf_n1().debug("Parameters for NIA: count(0x%x)", count);
Logger::amf_n1().debug("Parameters for NIA, count: 0x%x", count);
stream_cipher.bearer = 0x01; //33.501 section 8.1.1
Logger::amf_n1().debug("Parameters for NIA: bearer(0x%x)", 0x01);
Logger::amf_n1().debug("Parameters for NIA, bearer: 0x%x", 0x01);
stream_cipher.direction = direction; // "1" for downlink
Logger::amf_n1().debug("Parameters for NIA: direction(0x%x)", direction);
Logger::amf_n1().debug("Parameters for NIA, direction: 0x%x", direction);
stream_cipher.message = (uint8_t*) input_nas;
print_buffer("amf_n1", "parameters for NIA: message", input_nas, input_nas_len);
print_buffer("amf_n1", "parameters for NIA, message: ", input_nas, input_nas_len);
stream_cipher.blength = input_nas_len * 8;
switch (nsc->nas_algs.integrity & 0x0f) {
case IA0_5G: {
......@@ -1383,18 +1380,18 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc, uint8_t directio
case IA1_128_5G: {
Logger::amf_n1().debug("Integrity with algorithms: 128-5G-IA1");
nas_algorithms::nas_stream_encrypt_nia1(&stream_cipher, mac);
print_buffer("amf_n1", "result for NIA1: mac", mac, 4);
print_buffer("amf_n1", "Result for NIA1, mac: ", mac, 4);
mac32 = ntohl(*((uint32_t*) mac));
Logger::amf_n1().debug("Result for NIA1: mac32(0x%x)", mac32);
Logger::amf_n1().debug("Result for NIA1, mac32: 0x%x", mac32);
return true;
}
break;
case IA2_128_5G: {
Logger::amf_n1().debug("Integrity with algorithms: 128-5G-IA2");
nas_algorithms::nas_stream_encrypt_nia2(&stream_cipher, mac);
print_buffer("amf_n1", "result for NIA2: mac", mac, 4);
print_buffer("amf_n1", "result for NIA2, mac: ", mac, 4);
mac32 = ntohl(*((uint32_t*) mac));
Logger::amf_n1().debug("Result for NIA2: mac32(0x%x)", mac32);
Logger::amf_n1().debug("Result for NIA2, mac32: 0x%x", mac32);
return true;
}
break;
......@@ -1574,7 +1571,7 @@ void amf_n1::run_mobility_registration_update_procedure(std::shared_ptr<nas_cont
//std::string guti = amf_cfg.guami.mcc + amf_cfg.guami.mnc + amf_cfg.guami.regionID + amf_cfg.guami.AmfSetID + amf_cfg.guami.AmfPointer + "0001";
std::string guti = "1234567890"; //TODO: need modify
Logger::amf_n1().debug("Allocated guti %s", guti.c_str());
Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str());
regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
uint8_t buffer[1024] = { 0 };
......
......@@ -310,7 +310,7 @@ void amf_n11::handle_post_sm_context_response_error(long code, std::string cause
//------------------------------------------------------------------------------
void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std::string n1SmMsg, std::string n2SmMsg, std::string supi, uint8_t pdu_session_id) {
Logger::amf_n11().debug("Call SMF service operation: %s", remoteUri.c_str());
Logger::amf_n11().debug("Call SMF service: %s", remoteUri.c_str());
CURL *curl = curl_easy_init();
if (curl) {
CURLcode res;
......@@ -373,7 +373,7 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
bool is_response_ok = true;
Logger::amf_n11().debug("Get response with httpcode (%d)", httpCode);
if (httpCode == 0) {
Logger::amf_n11().error("Cannot get response When calling %s", remoteUri.c_str());
Logger::amf_n11().error("Cannot get response when calling %s", remoteUri.c_str());
//TODO: free curl before returning
return;
}
......
......@@ -150,7 +150,7 @@ void amf_n2::handle_itti_message(itti_new_sctp_association &new_assoc) {
// NG_SETUP_REQUEST Handler
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
Logger::amf_n2().debug("Parameters(assoc_id(%d))(stream(%d))", itti_msg.assoc_id, itti_msg.stream);
Logger::amf_n2().debug("Parameters: assoc_id %d, stream %d", itti_msg.assoc_id, itti_msg.stream);
std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
......@@ -174,7 +174,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
Logger::amf_n2().error("Missing Mandatory IE GlobalGnbID");
return;
}
Logger::amf_n2().debug("IE GlobalGNBID(0x%x)", gnb_id);
Logger::amf_n2().debug("IE GlobalGNBID: 0x%x", gnb_id);
gc->globalRanNodeId = gnb_id;
gnbItem.gnb_id = gnb_id;
......@@ -184,7 +184,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
} else {
gc->gnb_name = gnb_name;
gnbItem.gnb_name = gnb_name;
Logger::amf_n2().debug("IE RanNodeName(%s)", gnb_name.c_str());
Logger::amf_n2().debug("IE RanNodeName: %s", gnb_name.c_str());
}
int defPagingDrx = itti_msg.ngSetupReq->getDefaultPagingDRX();
......@@ -192,7 +192,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
Logger::amf_n2().error("Missing Mandatory IE DefaultPagingDRX");
return;
}
Logger::amf_n2().debug("IE DefaultPagingDRX(%d)", defPagingDrx);
Logger::amf_n2().debug("IE DefaultPagingDRX: %d", defPagingDrx);
vector<SupportedItem_t> s_ta_list;
if (!itti_msg.ngSetupReq->getSupportedTAList(s_ta_list)) { //getSupportedTAList
......@@ -213,7 +213,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
int encoded = ngSetupFailure.encode2buffer((uint8_t*) buffer, 1000);
bstring b = blk2bstr(buffer, encoded);
sctp_s_38412.sctp_send_msg(itti_msg.assoc_id, itti_msg.stream, &b);
Logger::amf_n2().error("No common plmn, encoding NG_SETUP_FAILURE with cause( Unknown PLMN )");
Logger::amf_n2().error("No common PLMN, encoding NG_SETUP_FAILURE with cause (Unknown PLMN)");
return;
} else {
gc->s_ta_list = s_ta_list;
......@@ -255,9 +255,9 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
int encoded = ngSetupResp.encode2buffer((uint8_t*) buffer, 1000);
bstring b = blk2bstr(buffer, encoded);
sctp_s_38412.sctp_send_msg(itti_msg.assoc_id, itti_msg.stream, &b);
Logger::amf_n2().debug("Sending NG_SETUP_RESPONSE ok");
Logger::amf_n2().debug("Sending NG_SETUP_RESPONSE Ok");
gc.get()->ng_state = NGAP_READY;
Logger::amf_n2().debug("gNB with [gnb_id(0x%x), assoc_id(%d)] has been attached to AMF", gc.get()->globalRanNodeId, itti_msg.assoc_id);
Logger::amf_n2().debug("gNB with gNB_id 0x%x, assoc_id %d has been attached to AMF", gc.get()->globalRanNodeId, itti_msg.assoc_id);
stacs.gNB_connected += 1;
stacs.gnbs.push_back(gnbItem);
return;
......@@ -292,14 +292,14 @@ void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg) {
}
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ne_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n2().debug("Create a new UE NGAP context with ran_ue_ngap_id(0x%x)", ran_ue_ngap_id);
Logger::amf_n2().debug("Create a new UE NGAP context with ran_ue_ngap_id 0x%x", ran_ue_ngap_id);
unc = std::shared_ptr < ue_ngap_context > (new ue_ngap_context());
set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc);
} else {
unc = ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
}
if (unc.get() == nullptr) {
Logger::amf_n2().error("Failed to get UE NGAP context for ran_ue_ngap_id(0x%x)", 21);
Logger::amf_n2().error("Failed to get UE NGAP context for ran_ue_ngap_id 0x%x", 21);
} else {
//store information into UE NGAP context
unc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
......@@ -330,7 +330,6 @@ void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg) {
itti_msg->ueCtxReq = -1;//not present
}else{
itti_msg->ueCtxReq = init_ue_msg.initUeMsg->getUeContextRequest();
Logger::amf_n2().debug("testing 12");
}
#endif
std::string _5g_s_tmsi;
......@@ -600,7 +599,7 @@ void amf_n2::set_ran_ue_ngap_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id
bool amf_n2::verifyPlmn(vector<SupportedItem_t> list) {
for (int i = 0; i < amf_cfg.plmn_list.size(); i++) {
for (int j = 0; j < list.size(); j++) {
Logger::amf_n2().debug("TAC configured(%d) -- TAC received(%d)", amf_cfg.plmn_list[i].tac, list[j].tac);
Logger::amf_n2().debug("TAC configured %d, TAC received %d", amf_cfg.plmn_list[i].tac, list[j].tac);
if (amf_cfg.plmn_list[i].tac != list[j].tac) {
continue;
}
......
......@@ -137,7 +137,7 @@ void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p, uint8_t *sqn
mysql_free_result(res);
} else {
if (mysql_field_count(db_desc->db_conn) == 0) {
Logger::amf_n1().error("%lld rows affected", mysql_affected_rows(db_desc->db_conn));
Logger::amf_n1().error("[MySQL] %lld rows affected", mysql_affected_rows(db_desc->db_conn));
} else { /* some error occurred */
Logger::amf_n1().error("Could not retrieve result set");
break;
......@@ -174,7 +174,7 @@ void amf_n1::mysql_increment_sqn(std::string imsi) {
mysql_free_result(res);
} else {
if (mysql_field_count(db_desc->db_conn) == 0) {
Logger::amf_n1().error("%lld rows affected", mysql_affected_rows(db_desc->db_conn));
Logger::amf_n1().error("[MySQL] %lld rows affected", mysql_affected_rows(db_desc->db_conn));
} else {
Logger::amf_n1().error("Could not retrieve result set");
break;
......
......@@ -93,22 +93,22 @@ int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t *buf, int len) {
uint8_t digit[4];
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[0] = octet;
tmsi |= octet;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[1] = octet;
tmsi |= octet << 8;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[2] = octet;
tmsi |= octet << 16;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[3] = octet;
tmsi |= octet << 24;
_5g_s_tmsi->_5g_tmsi = (const string) (std::to_string(tmsi));
......@@ -237,12 +237,12 @@ int _5GSMobilityIdentity::encode2buffer(uint8_t *buf, int len) {
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::suci_encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding SUCI IE iei(0x%x)", iei);
Logger::nas_mm().debug("Encoding SUCI IEI 0x%x", iei);
if (len < length)
Logger::nas_mm().debug("error: len is less than %d", length);
int encoded_size = 0;
if (iei) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity iei0x%x", typeOfIdentity);
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity IEI 0x%x", typeOfIdentity);
*(buf) = iei;
encoded_size++;
encoded_size += 2;
......@@ -271,18 +271,18 @@ int _5GSMobilityIdentity::suci_encode2buffer(uint8_t *buf, int len) {
} else {
*(uint16_t*) (buf + 1) = encoded_size - 3;
}
Logger::nas_mm().debug("encoded SUCI IE len(%d octets)", encoded_size);
Logger::nas_mm().debug("Encoded SUCI IE (len %d octets)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_guti_encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding 5G-GUTI IE iei(0x%x)", iei);
Logger::nas_mm().debug("Encoding 5G-GUTI IEI 0x%x", iei);
if (len < length)
Logger::nas_mm().debug("error: len is less than %d", length);
Logger::nas_mm().debug("Error: len is less than %d", length);
int encoded_size = 0;
if (iei) {
Logger::nas_mm().debug("encoding 5GSMobilityIdentity type: 0x%x", typeOfIdentity);
Logger::nas_mm().debug("Wncoding 5GSMobilityIdentity type 0x%x", typeOfIdentity);
*(buf) = iei;
encoded_size++;
encoded_size += 2;
......@@ -323,7 +323,7 @@ int _5GSMobilityIdentity::_5g_guti_encode2buffer(uint8_t *buf, int len) {
buf[1] = ((encoded_size - 3) & 0xff00) >> 8;
buf[2] = (encoded_size - 3) & 0x00ff;
}
Logger::nas_mm().debug("encoded 5G-GUTI IE len(%d octets)", encoded_size);
Logger::nas_mm().debug("Encoded 5G-GUTI IE (len %d octets)", encoded_size);
return encoded_size;
}
......@@ -334,24 +334,24 @@ int _5GSMobilityIdentity::encodeMssMnc2buffer(string mccstr, string mncstr, uint
int mnc = fromString<int>(mncstr);
*(buf + encoded_size) = (0x0f & (mcc / 100)) | ((0x0f & ((mcc % 100) / 10)) << 4);
encoded_size += 1;
Logger::nas_mm().debug("mnc digit 1 (%d)", mnc / 100);
Logger::nas_mm().debug("MNC digit 1: %d", mnc / 100);
if (!(mnc / 100)) {
Logger::nas_mm().debug("encoding mnc 2 digits");
Logger::nas_mm().debug("Encoding MNC 2 digits");
*(buf + encoded_size) = (0x0f & (mcc % 10)) | 0xf0;
Logger::nas_mm().debug("buffer(0x%x)", *(buf + encoded_size));
Logger::nas_mm().debug("Buffer 0x%x", *(buf + encoded_size));
encoded_size += 1;
*(buf + encoded_size) = (0x0f & ((mnc % 100) / 10)) | ((0x0f & (mnc % 10)) << 4);
encoded_size += 1;
} else {
Logger::nas_mm().debug("encoding mnc 3 digits");
Logger::nas_mm().debug("Encoding MNC 3 digits");
*(buf + encoded_size) = (0x0f & (mcc % 10)) | ((0x0f & (mnc % 10)) << 4);
Logger::nas_mm().debug("buffer(0x%x)", *(buf + encoded_size));
Logger::nas_mm().debug("Buffer 0x%x", *(buf + encoded_size));
encoded_size += 1;
*(buf + encoded_size) = ((0x0f & ((mnc % 100) / 10)) << 4) | (0x0f & (mnc / 100));
Logger::nas_mm().debug("buffer(0x%x)", *(buf + encoded_size));
Logger::nas_mm().debug("Buffer 0x%x", *(buf + encoded_size));
encoded_size += 1;
}
Logger::nas_mm().debug("mcc(%s) mnc(%s)", mccstr.c_str(), mncstr.c_str());
Logger::nas_mm().debug("MCC %s, MNC %s", mccstr.c_str(), mncstr.c_str());
return encoded_size;
}
......@@ -407,12 +407,12 @@ int _5GSMobilityIdentity::encodeMSIN2buffer(string msinstr, uint8_t *buf) {
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::imeisv_encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding IMEISV IE iei(0x%x)", iei);
Logger::nas_mm().debug("Encoding IMEISV IE IEI 0x%x", iei);
if (len < length)
Logger::nas_mm().debug("error: len is less than %d", length);
Logger::nas_mm().debug("Error: len is less than %d", length);
int encoded_size = 0;
if (iei) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity iei0x%x", typeOfIdentity);
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity IEI 0x%x", typeOfIdentity);
*(buf) = iei;
encoded_size++;
encoded_size += 2;
......@@ -426,13 +426,13 @@ int _5GSMobilityIdentity::imeisv_encode2buffer(uint8_t *buf, int len) {
} else {
*(uint16_t*) (buf + 1) = encoded_size - 3;
}
Logger::nas_mm().debug("encoded IMEISV IE len(%d octets)", encoded_size);
Logger::nas_mm().debug("Encoded IMEISV IE (len %d octets)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity");
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity");
int decoded_size = 0;
if (is_option) {
iei = *buf;
......@@ -444,12 +444,12 @@ int _5GSMobilityIdentity::decodefrombuffer(uint8_t *buf, int len, bool is_option
len2 = *(buf + decoded_size);
decoded_size++;
uint16_t length = (0x0000) | (len1 << 8) | len2;
Logger::amf_n1().debug("decoded 5GSMobilityIdentity IE length(%d)", length);
Logger::amf_n1().debug("Decoded 5GSMobilityIdentity IE length %d", length);
switch (*(buf + decoded_size) & 0x07) {
case SUCI: {
typeOfIdentity = SUCI;
decoded_size += suci_decodefrombuffer(buf + decoded_size, len - decoded_size, length);
Logger::nas_mm().debug("decoded suci(%d) octets", decoded_size);
Logger::nas_mm().debug("Decoded SUCI (%d octets)", decoded_size);
return decoded_size;
}
break;
......@@ -476,7 +476,7 @@ int _5GSMobilityIdentity::decodefrombuffer(uint8_t *buf, int len, bool is_option
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::suci_decodefrombuffer(uint8_t *buf, int len, int ie_len) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity SUCI");
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity SUCI");
int decoded_size = 0;
uint8_t octet = 0;
octet = *buf;
......@@ -492,39 +492,31 @@ int _5GSMobilityIdentity::suci_decodefrombuffer(uint8_t *buf, int len, int ie_le
octet = *(buf + decoded_size);
decoded_size++;
mcc += (octet & 0x0f);
//Logger::nas_mm().debug("mcc(%s)",std::to_string(mcc).c_str());
//Logger::nas_mm().debug("buffer(0x%x)",octet);
if ((octet & 0xf0) == 0xf0) {
octet = *(buf + decoded_size);
decoded_size++;
mnc += ((octet & 0x0f) * 10 + ((octet & 0xf0) >> 4));
//Logger::nas_mm().debug("mnc(2 digits)(%s)",std::to_string(mnc).c_str());
} else {
mnc += ((octet & 0xf0) >> 4);
octet = *(buf + decoded_size);
//Logger::nas_mm().debug("buffer(0x%x)",octet);
decoded_size++;
mnc += ((octet & 0x0f) * 100 + ((octet & 0xf0) >> 4) * 10);
//Logger::nas_mm().debug("mnc(3 digits)(%s)",std::to_string(mnc).c_str());
}
Logger::nas_mm().debug("mcc(%s) mnc(%s)", std::to_string(mcc).c_str(), std::to_string(mnc).c_str());
Logger::nas_mm().debug("MCC %s, MNC %s", std::to_string(mcc).c_str(), std::to_string(mnc).c_str());
supi_format_imsi->mcc = (const string) (std::to_string(mcc));
supi_format_imsi->mnc = (const string) (std::to_string(mnc));
int routid = 0;
uint8_t digit[4];
octet = *(buf + decoded_size);
decoded_size++;
//Logger::nas_mm().debug("octet(0x%x)",octet);
digit[0] = octet & 0x0f;
digit[1] = (octet & 0xf0) >> 4;
octet = *(buf + decoded_size);
decoded_size++;
//Logger::nas_mm().debug("octet(0x%x)",octet);
digit[2] = octet & 0x0f;
digit[3] = (octet & 0xf0) >> 4;
if (!digit[0] && digit[1] == 0x0f && digit[2] == 0x0f && digit[3] == 0x0f) {
supi_format_imsi->routingIndicator = (const string) ("none");
//Logger::nas_mm().debug("routing indicator(%s)",supi_format_imsi->routingIndicator.c_str());
} else {
string result = "";
for (int i = 0; i < 4; i++) {
......@@ -533,10 +525,10 @@ int _5GSMobilityIdentity::suci_decodefrombuffer(uint8_t *buf, int len, int ie_le
else if (digit[i] == 0x0f)
break;
else
Logger::nas_mm().error("decoded routing indicator is not BCD coding");
Logger::nas_mm().error("Decoded routing indicator is not BCD coding");
}
supi_format_imsi->routingIndicator = result;
Logger::nas_mm().debug("decoded routing indicator(%s)", supi_format_imsi->routingIndicator.c_str());
Logger::nas_mm().debug("Decoded routing indicator %s", supi_format_imsi->routingIndicator.c_str());
}
octet = *(buf + decoded_size);
decoded_size++;
......@@ -544,22 +536,18 @@ int _5GSMobilityIdentity::suci_decodefrombuffer(uint8_t *buf, int len, int ie_le
octet = *(buf + decoded_size);
decoded_size++;
supi_format_imsi->homeNetworkPKI = octet;
//Logger::nas_mm().debug("decoded homeNetworkPKI(%x)",supi_format_imsi->homeNetworkPKI);
string msin = "";
int digit_low = 0, digit_high = 0, numMsin = ie_len - decoded_size;
//Logger::nas_mm().debug("number of msin(%d)",numMsin);
for (int i = 0; i < numMsin; i++) {
octet = *(buf + decoded_size);
decoded_size++;
digit_high = (octet & 0xf0) >> 4;
digit_low = octet & 0x0f;
//Logger::amf_n1().debug("msin(%d), %d %d", i, digit_high, digit_low);
msin += ((const string) (std::to_string(digit_low)) + (const string) (std::to_string(digit_high)));
}
supi_format_imsi->msin = msin;
Logger::nas_mm().debug("decoded MSIN(%s)", supi_format_imsi->msin.c_str());
Logger::nas_mm().debug("decoded 5GSMobilityIdentity SUCI SUPI format IMSI(len(%d))", decoded_size);
Logger::nas_mm().debug("decoding 5GSMobilityIdentity SUCI SUPI format IMSI");
Logger::nas_mm().debug("Decoded MSIN %s", supi_format_imsi->msin.c_str());
Logger::nas_mm().debug("Decoded 5GSMobilityIdentity SUCI SUPI format IMSI (len %d)", decoded_size);
return decoded_size;
}
break;
......@@ -574,7 +562,7 @@ int _5GSMobilityIdentity::suci_decodefrombuffer(uint8_t *buf, int len, int ie_le
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_guti_decodefrombuffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity 5G-GUTI");
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity 5G-GUTI");
int decoded_size = 0;
uint8_t octet = 0;
octet = *buf;
......@@ -588,22 +576,22 @@ int _5GSMobilityIdentity::_5g_guti_decodefrombuffer(uint8_t *buf, int len) {
octet = *(buf + decoded_size);
decoded_size++;
mcc += (octet & 0x0f);
Logger::nas_mm().debug("mcc(%s)", std::to_string(mcc).c_str());
Logger::nas_mm().debug("buffer(0x%x)", octet);
Logger::nas_mm().debug("MCC %s", std::to_string(mcc).c_str());
Logger::nas_mm().debug("Buffer 0x%x", octet);
if ((octet & 0xf0) == 0xf0) {
octet = *(buf + decoded_size);
decoded_size++;
mnc += ((octet & 0x0f) * 10 + ((octet & 0xf0) >> 4));
Logger::nas_mm().debug("mnc(2 digits)(%s)", std::to_string(mnc).c_str());
Logger::nas_mm().debug("MNC (2 digits): %s", std::to_string(mnc).c_str());
} else {
mnc += ((octet & 0xf0) >> 4);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("buffer(0x%x)", octet);
Logger::nas_mm().debug("Buffer 0x%x", octet);
decoded_size++;
mnc += ((octet & 0x0f) * 100 + ((octet & 0xf0) >> 4) * 10);
Logger::nas_mm().debug("mnc(3 digits)(%s)", std::to_string(mnc).c_str());
Logger::nas_mm().debug("MNC (3 digits): %s", std::to_string(mnc).c_str());
}
Logger::nas_mm().debug("mcc(%s) mnc(%s)", std::to_string(mcc).c_str(), std::to_string(mnc).c_str());
Logger::nas_mm().debug("MCC %s, MNC %s", std::to_string(mcc).c_str(), std::to_string(mnc).c_str());
_5g_guti->mcc = (const string) (std::to_string(mcc));
_5g_guti->mnc = (const string) (std::to_string(mnc));
......@@ -617,22 +605,22 @@ int _5GSMobilityIdentity::_5g_guti_decodefrombuffer(uint8_t *buf, int len) {
uint8_t digit[4];
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[0] = octet;
tmsi |= octet;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[1] = octet;
tmsi |= octet << 8;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[2] = octet;
tmsi |= octet << 16;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("octet(0x%x)", octet);
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[3] = octet;
tmsi |= octet << 24;
_5g_guti->_5g_tmsi = tmsi;
......
......@@ -84,14 +84,14 @@ int _5GSRegistrationType::decodefrombuffer(uint8_t *buf, int len, bool is_option
if (is_option) {
return -1;
}
Logger::nas_mm().debug("decoding 5GSRegistrationType");
Logger::nas_mm().debug("Decoding 5GSRegistrationType");
uint8_t octet = *buf;
if (octet & 0x08)
is_for = FOLLOW_ON_REQ_PENDING;
else
is_for = NO_FOLLOW_ON_REQ_PENDING;
reg_type = 0x07 & octet;
Logger::nas_mm().debug("decoded 5GSRegistrationType len(1/2 octet)");
Logger::nas_mm().debug("Decoded 5GSRegistrationType len (1/2 octet)");
return 0;
}
......
......@@ -56,7 +56,7 @@ void Authentication_Response_Parameter::getValue(bstring &para) {
//------------------------------------------------------------------------------
int Authentication_Response_Parameter::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding Authentication_Response_Parameter iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding Authentication_Response_Parameter IEI 0x%x", _iei);
if (len < 18) {
Logger::nas_mm().error("len is less than 18");
return 0;
......@@ -74,13 +74,13 @@ int Authentication_Response_Parameter::encode2buffer(uint8_t *buf, int len) {
// *(buf + encoded_size) = length - 1; encoded_size++;
// *(buf + encoded_size) = _value; encoded_size++; encoded_size++;
}
Logger::nas_mm().debug("encoded Authentication_Response_Parameter len(%d)", encoded_size);
Logger::nas_mm().debug("Encoded Authentication_Response_Parameter (len %d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int Authentication_Response_Parameter::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding Authentication_Response_Parameter iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding Authentication_Response_Parameter IEI 0x%x", *buf);
int decoded_size = 0;
uint8_t length = 0;
if (is_option) {
......@@ -91,9 +91,9 @@ int Authentication_Response_Parameter::decodefrombuffer(uint8_t *buf, int len, b
decode_bstring(&PARA, length, (buf + decoded_size), len - decoded_size);
decoded_size += length;
for (int i = 0; i < length; i++) {
Logger::nas_mm().debug("decoded NAS_Message_Container value(0x%x)", (uint8_t*) PARA->data[i]);
Logger::nas_mm().debug("Decoded NAS_Message_Container value 0x%x", (uint8_t*) PARA->data[i]);
}
Logger::nas_mm().debug("decoded Authentication_Response_Parameter len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded Authentication_Response_Parameter (len %d)", decoded_size);
return decoded_size;
}
......@@ -65,7 +65,7 @@ void DNN::getValue(bstring &dnn) {
//------------------------------------------------------------------------------
int DNN::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding DNN iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding DNN IEI (0x%x)", _iei);
if (len < length) {
Logger::nas_mm().error("len is less than %d", length);
return 0;
......@@ -85,13 +85,13 @@ int DNN::encode2buffer(uint8_t *buf, int len) {
int size = encode_bstring(_DNN, (buf + encoded_size), len - encoded_size);
encoded_size += size;
}
Logger::nas_mm().debug("encoded DNN len(%d)", encoded_size);
Logger::nas_mm().debug("encoded DNN len: %d", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int DNN::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding DNN iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding DNN IEI (0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
decoded_size++;
......@@ -101,10 +101,9 @@ int DNN::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
decode_bstring(&_DNN, length, (buf + decoded_size), len - decoded_size);
decoded_size += length;
for (int i = 0; i < blength(_DNN); i++) {
Logger::nas_mm().debug("decoded DNN value(0x%x)", (uint8_t*) bdata(_DNN)[i]);
//print_buffer("amf_n1", "decoded dnn bitstring", (uint8_t*)bdata(_DNN), blength(_DNN));
Logger::nas_mm().debug("Decoded DNN value: 0x%x", (uint8_t*) bdata(_DNN)[i]);
}
Logger::nas_mm().debug("decoded DNN len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded DNN len: %d", decoded_size);
return decoded_size;
}
......@@ -64,7 +64,7 @@ void NAS_Message_Container::getValue(bstring &value) {
//------------------------------------------------------------------------------
int NAS_Message_Container::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding NAS_Message_Container iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding NAS_Message_Container IEI 0x%x", _iei);
if (len < length) {
Logger::nas_mm().error("len is less than %d", length);
return 0;
......@@ -84,13 +84,13 @@ int NAS_Message_Container::encode2buffer(uint8_t *buf, int len) {
// *(buf + encoded_size) = length - 1; encoded_size++;
// *(buf + encoded_size) = _value; encoded_size++; encoded_size++;
}
Logger::nas_mm().debug("encoded NAS_Message_Container len(%d)", encoded_size);
Logger::nas_mm().debug("Encoded NAS_Message_Container (len %d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int NAS_Message_Container::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding NAS_Message_Container iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding NAS_Message_Container iei(0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
decoded_size++;
......@@ -103,9 +103,9 @@ int NAS_Message_Container::decodefrombuffer(uint8_t *buf, int len, bool is_optio
decode_bstring(&_value, length, (buf + decoded_size), len - decoded_size);
decoded_size += length;
for (int i = 0; i < length; i++) {
Logger::nas_mm().debug("decoded NAS_Message_Container value(0x%x)", (uint8_t*) _value->data[i]);
Logger::nas_mm().debug("Decoded NAS_Message_Container value 0x%x", (uint8_t*) _value->data[i]);
}
Logger::nas_mm().debug("decoded NAS_Message_Container len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded NAS_Message_Container (len %d)", decoded_size);
return decoded_size;
}
......@@ -35,7 +35,7 @@ NasKeySetIdentifier::NasKeySetIdentifier(const uint8_t m_iei, uint8_t m_tsc, uin
iei = m_iei;
tsc = 0x01 & m_tsc;
key_id = 0x07 & m_key_id;
Logger::nas_mm().debug("encoding NasKeySetIdentifier ...");
Logger::nas_mm().debug("Encoding NasKeySetIdentifier ...");
}
//------------------------------------------------------------------------------
......@@ -43,7 +43,7 @@ NasKeySetIdentifier::NasKeySetIdentifier(uint8_t tsc, uint8_t key_id) {
this->iei = 0;
this->tsc = 0x01 & tsc;
this->key_id = 0x07 & key_id;
Logger::nas_mm().debug("encoding NasKeySetIdentifier???");
Logger::nas_mm().debug("Encoding NasKeySetIdentifier???");
}
//------------------------------------------------------------------------------
......@@ -57,7 +57,7 @@ NasKeySetIdentifier::~NasKeySetIdentifier() {
//------------------------------------------------------------------------------
int NasKeySetIdentifier::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding NasKeySetIdentifier IE iei(0x%x)", iei);
Logger::nas_mm().debug("Encoding NasKeySetIdentifier IE IEI 0x%x", iei);
if (len < 1) {
Logger::nas_mm().error("len is less than one");
return -1;
......@@ -66,13 +66,13 @@ int NasKeySetIdentifier::encode2buffer(uint8_t *buf, int len) {
if (!(iei & 0x0f)) {
octet = (0x0f) & ((tsc << 3) | key_id);
*buf = octet;
Logger::nas_mm().debug("encoded NasKeySetIdentifier IE tsc(0x%x),key_id(0x%x)", tsc, key_id);
Logger::nas_mm().debug("Encoded NasKeySetIdentifier IE (TSC 0x%x,Key_id 0x%x)", tsc, key_id);
return 1;
} else {
octet = (iei << 4) | (tsc << 3) | key_id;
*buf = octet;
Logger::nas_mm().debug("encoded NasKeySetIdentifier IE(len(1 octet))");
Logger::nas_mm().debug("encoded NasKeySetIdentifier IE tsc(0x%x),key_id(0x%x)", tsc, key_id);
Logger::nas_mm().debug("Encoded NasKeySetIdentifier IE (len 1 octet)");
Logger::nas_mm().debug("Encoded NasKeySetIdentifier IE (TSC 0x%x, Key_id 0x%x)", tsc, key_id);
return 1;
}
}
......@@ -80,7 +80,7 @@ int NasKeySetIdentifier::encode2buffer(uint8_t *buf, int len) {
//------------------------------------------------------------------------------
int NasKeySetIdentifier::decodefrombuffer(uint8_t *buf, int len, bool is_option, bool is_high) {
Logger::nas_mm().debug("decoding NasKeySetIdentifier IE");
Logger::nas_mm().debug("Decoding NasKeySetIdentifier IE");
if (len < 1) {
Logger::nas_mm().error("len is less than one");
return -1;
......@@ -98,7 +98,7 @@ int NasKeySetIdentifier::decodefrombuffer(uint8_t *buf, int len, bool is_option,
tsc = (octet & 0x80) >> 4;
key_id = (octet & 0x70) >> 4;
}
Logger::nas_mm().debug("decoded NasKeySetIdentifier IE tsc(0x%x),key_id(0x%x)", tsc, key_id);
Logger::nas_mm().debug("Decoded NasKeySetIdentifier IE (TSC 0x%x, Key_id 0x%x)", tsc, key_id);
if (iei)
return 1;
else
......
......@@ -74,7 +74,7 @@ uint8_t UESecurityCapability::getIASel() {
//------------------------------------------------------------------------------
int UESecurityCapability::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding UESecurityCapability iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding UESecurityCapability IEI 0x%x", _iei);
if (len < length) {
Logger::nas_mm().error("len is less than %d", length);
return 0;
......@@ -97,13 +97,13 @@ int UESecurityCapability::encode2buffer(uint8_t *buf, int len) {
*(buf + encoded_size) = _5g_IASel;
encoded_size++;
}
Logger::nas_mm().debug("encoded UESecurityCapability len(%d)", encoded_size);
Logger::nas_mm().debug("encoded UESecurityCapability (len %d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int UESecurityCapability::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding UESecurityCapability iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding UESecurityCapability IEI 0x%x", *buf);
int decoded_size = 0;
if (is_option) {
decoded_size++;
......@@ -114,8 +114,8 @@ int UESecurityCapability::decodefrombuffer(uint8_t *buf, int len, bool is_option
decoded_size++;
_5g_IASel = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("decoded UESecurityCapability EA(0x%d),IA(0x%d)", _5g_EASel, _5g_IASel);
Logger::nas_mm().debug("decoded UESecurityCapability len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded UESecurityCapability EA 0x%d,IA 0x%d", _5g_EASel, _5g_IASel);
Logger::nas_mm().debug("Decoded UESecurityCapability (len %d)", decoded_size);
return decoded_size;
}
......@@ -34,7 +34,6 @@ using namespace nas;
//------------------------------------------------------------------------------
AuthenticationRequest::AuthenticationRequest() {
Logger::nas_mm().debug("initiating class AuthenticationRequest");
plain_header = NULL;
ie_ngKSI = NULL;
ie_abba = NULL;
......@@ -80,79 +79,79 @@ void AuthenticationRequest::setEAP_Message(bstring eap) {
//------------------------------------------------------------------------------
int AuthenticationRequest::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding AuthenticationRequest message");
Logger::nas_mm().debug("Encoding AuthenticationRequest message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_ngKSI) {
Logger::nas_mm().warn("IE ie_ngKSI is not avaliable");
Logger::nas_mm().warn("IE ie_ngKSI is not available");
} else {
int size = ie_ngKSI->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != -1) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_ngKSI error");
Logger::nas_mm().error("Encoding ie_ngKSI error");
return 0;
}
}
if (!ie_abba) {
Logger::nas_mm().warn("IE ie_abba is not avaliable");
Logger::nas_mm().warn("IE ie_abba is not available");
} else {
int size = ie_abba->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
Logger::nas_mm().debug("0x%x, 0x%x, 0x%x", (buf + encoded_size)[0], (buf + encoded_size)[1], (buf + encoded_size)[2]);
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_abba error");
Logger::nas_mm().error("Encoding ie_abba error");
return 0;
}
}
if (!ie_authentication_parameter_rand) {
Logger::nas_mm().warn("IE ie_authentication_parameter_rand is not avaliable");
Logger::nas_mm().warn("IE ie_authentication_parameter_rand is not available");
} else {
int size = ie_authentication_parameter_rand->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_authentication_parameter_rand error");
Logger::nas_mm().error("Encoding ie_authentication_parameter_rand error");
return 0;
}
}
if (!ie_authentication_parameter_autn) {
Logger::nas_mm().warn("IE ie_authentication_parameter_autn is not avaliable");
Logger::nas_mm().warn("IE ie_authentication_parameter_autn is not available");
} else {
int size = ie_authentication_parameter_autn->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_authentication_parameter_autn error");
Logger::nas_mm().error("Encoding ie_authentication_parameter_autn error");
return 0;
}
}
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not avaliable");
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_eap_message error");
Logger::nas_mm().error("Encoding ie_eap_message error");
return 0;
}
}
Logger::nas_mm().debug("encoded AuthenticationRequest message len(%d)", encoded_size);
Logger::nas_mm().debug("Encoded AuthenticationRequest message (len %d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int AuthenticationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
Logger::nas_mm().debug("decoding RegistrationReject message");
Logger::nas_mm().debug("Decoding RegistrationReject message");
int decoded_size = 3;
plain_header = header;
ie_ngKSI = new NasKeySetIdentifier();
......@@ -160,37 +159,37 @@ int AuthenticationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *b
decoded_size++;
ie_abba = new ABBA();
decoded_size += ie_abba->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
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);
Logger::nas_mm().debug("First option IEI 0x%x", octet);
while ((octet != 0x0)) {
switch (octet) {
case 0x21: {
Logger::nas_mm().debug("decoding iei(0x21)");
Logger::nas_mm().debug("Decoding IEI(0x21)");
ie_authentication_parameter_rand = new Authentication_Parameter_RAND();
decoded_size += ie_authentication_parameter_rand->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x20: {
ie_authentication_parameter_autn = new Authentication_Parameter_AUTN();
decoded_size += ie_authentication_parameter_autn->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x78: {
Logger::nas_mm().debug("decoding iei(0x78)");
Logger::nas_mm().debug("Decoding IEI 0x78");
ie_eap_message = new EAP_Message();
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
}
}
Logger::nas_mm().debug("decoded AuthenticationRequest message len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded AuthenticationRequest message (len %d)", decoded_size);
}
......@@ -35,7 +35,6 @@ using namespace nas;
//------------------------------------------------------------------------------
RegistrationAccept::RegistrationAccept() {
Logger::nas_mm().debug("initiating class RegistrationAccept");
plain_header = NULL;
ie_5gs_registration_result = NULL;
ie_5g_guti = NULL;
......@@ -102,8 +101,7 @@ void RegistrationAccept::set5G_GUTI(const string mcc, const string mnc, const st
int regionId = fromString<int>(amfRegionId);
int setId = fromString<int>(amfSetId);
int pointer = fromString<int>(amfPointer);
cout << "amfRegionID string: " << amfRegionId.c_str() << endl;
cout << "amfRegionId uint8_t: " << regionId << endl;
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);
}
......
......@@ -756,7 +756,7 @@ int RegistrationRequest::encode2buffer(uint8_t *buf, int len) {
//------------------------------------------------------------------------------
int RegistrationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
Logger::nas_mm().debug("decoding RegistrationRequest message");
Logger::nas_mm().debug("Decoding RegistrationRequest message");
int decoded_size = 3;
plain_header = header;
ie_5gsregistrationtype = new _5GSRegistrationType();
......@@ -766,195 +766,195 @@ int RegistrationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf
decoded_size++;
ie_5gs_mobility_id = new _5GSMobilityIdentity();
decoded_size += ie_5gs_mobility_id->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
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);
Logger::nas_mm().debug("First option IEI 0x%x", octet);
while ((octet != 0x0)) {
switch ((octet & 0xf0) >> 4) {
case 0xC: {
Logger::nas_mm().debug("decoding iei(0xC)");
Logger::nas_mm().debug("Decoding IEI(0xC)");
ie_non_current_native_nas_ksi = new NasKeySetIdentifier();
decoded_size += ie_non_current_native_nas_ksi->decodefrombuffer(buf + decoded_size, len - decoded_size, true, false);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0xB: {
Logger::nas_mm().debug("decoding iei(0xB)");
Logger::nas_mm().debug("Decoding IEI (0xB)");
ie_MICO_indicationl = new MICO_Indication();
decoded_size += ie_MICO_indicationl->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x08: {
Logger::nas_mm().debug("decoding iei(0x8)");
Logger::nas_mm().debug("Decoding IEI (0x8)");
ie_payload_container_type = new Payload_Container_Type();
decoded_size += ie_payload_container_type->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x9: {
Logger::nas_mm().debug("decoding iei(0x9)");
Logger::nas_mm().debug("Decoding IEI(0x9)");
ie_network_slicing_indication = new Network_Slicing_Indication();
decoded_size += ie_network_slicing_indication->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
}
switch (octet) {
case 0x10: {
Logger::nas_mm().debug("decoding iei(0x10)");
Logger::nas_mm().debug("Decoding IEI(0x10)");
ie_5g_mm_capability = new _5GMMCapability();
decoded_size += ie_5g_mm_capability->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x2E: {
Logger::nas_mm().debug("decoding iei(0x2E)");
Logger::nas_mm().debug("Decoding IEI(0x2E)");
ie_ue_security_capability = new UESecurityCapability();
decoded_size += ie_ue_security_capability->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x2F: {
Logger::nas_mm().debug("decoding iei(0x2F)");
Logger::nas_mm().debug("Decoding IEI(0x2F)");
ie_requested_NSSAI = new NSSAI();
decoded_size += ie_requested_NSSAI->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x52: {
Logger::nas_mm().debug("decoding iei(0x52)");
Logger::nas_mm().debug("Decoding IEI(0x52)");
ie_last_visited_registered_TAI = new _5GS_Tracking_Area_Identity();
decoded_size += ie_last_visited_registered_TAI->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x17: {
Logger::nas_mm().debug("decoding iei(0x17)");
Logger::nas_mm().debug("Decoding IEI(0x17)");
ie_s1_ue_network_capability = new UENetworkCapability();
decoded_size += ie_s1_ue_network_capability->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x40: {
Logger::nas_mm().debug("decoding iei(0x40)");
Logger::nas_mm().debug("Decoding IEI(0x40)");
ie_uplink_data_status = new UplinkDataStatus();
decoded_size += ie_uplink_data_status->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x50: {
Logger::nas_mm().debug("decoding iei(0x50)");
Logger::nas_mm().debug("Decoding IEI(0x50)");
ie_PDU_session_status = new PDU_Session_Status();
decoded_size += ie_PDU_session_status->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x2B: {
Logger::nas_mm().debug("decoding iei(0x2B)");
Logger::nas_mm().debug("Decoding IEI(0x2B)");
ie_ue_status = new UE_Status();
decoded_size += ie_ue_status->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x77: {
Logger::nas_mm().debug("decoding iei(0x77)");
Logger::nas_mm().debug("Decoding IEI(0x77)");
ie_additional_guti = new _5GSMobilityIdentity();
decoded_size += ie_additional_guti->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x25: {
Logger::nas_mm().debug("decoding iei(0x25)");
Logger::nas_mm().debug("Decoding IEI(0x25)");
ie_allowed_PDU_session_status = new Allowed_PDU_Session_Status();
decoded_size += ie_allowed_PDU_session_status->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x18: {
Logger::nas_mm().debug("decoding iei(0x18)");
Logger::nas_mm().debug("Decoding IEI(0x18)");
ie_ues_usage_setting = new UES_Usage_Setting();
decoded_size += ie_ues_usage_setting->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x51: {
Logger::nas_mm().debug("decoding iei(0x51)");
Logger::nas_mm().debug("Decoding IEI(0x51)");
ie_5gs_drx_parameters = new _5GS_DRX_arameters();
decoded_size += ie_5gs_drx_parameters->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x70: {
Logger::nas_mm().debug("decoding iei(0x70)");
Logger::nas_mm().debug("Decoding IEI(0x70)");
ie_eps_nas_message_container = new EPS_NAS_Message_Container();
decoded_size += ie_eps_nas_message_container->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x74: {
Logger::nas_mm().debug("decoding iei(0x74)");
Logger::nas_mm().debug("Decoding IEI(0x74)");
ie_ladn_indication = new LADN_Indication();
decoded_size += ie_ladn_indication->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x7B: {
Logger::nas_mm().debug("decoding iei(0x7B)");
Logger::nas_mm().debug("Decoding IEI(0x7B)");
ie_payload_container = new Payload_Container();
decoded_size += ie_payload_container->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x53: {
Logger::nas_mm().debug("decoding iei(0x53)");
Logger::nas_mm().debug("Decoding IEI(0x53)");
ie_5gs_update_type = new _5GS_Update_Type();
decoded_size += ie_5gs_update_type->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x71: {
Logger::nas_mm().debug("decoding iei(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);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x60: {
Logger::nas_mm().debug("decoding iei(0x71)");
Logger::nas_mm().debug("Decoding IEI(0x71)");
ie_eps_bearer_context_status = new EPS_Bearer_Context_Status();
decoded_size += ie_eps_bearer_context_status->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
}
}
Logger::nas_mm().debug("decoded RegistrationRequest message len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded RegistrationRequest message (len %d)", decoded_size);
}
......@@ -34,7 +34,6 @@ using namespace nas;
//------------------------------------------------------------------------------
SecurityModeCommand::SecurityModeCommand() {
Logger::nas_mm().debug("initiating class SecurityModeCommand");
plain_header = NULL;
ie_eap_message = NULL;
ie_selected_nas_security_algorithms = NULL;
......
......@@ -71,15 +71,15 @@ void NasMmPlainHeader::setHeader(uint8_t epd_, uint8_t security_header_type, uin
//------------------------------------------------------------------------------
int NasMmPlainHeader::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding NasMmPlainHeader");
Logger::nas_mm().debug("Encoding NasMmPlainHeader");
if (len < 3) {
Logger::nas_mm().error("[encoding nas mm header error][buffer length is less than 3 octets]");
Logger::nas_mm().error("buffer length is less than 3 octets");
return 0;
} else {
*(buf++) = epd;
*(buf++) = secu_header_type;
*(buf++) = msg_type;
Logger::nas_mm().debug("encoded NasMmPlainHeader len((3 octets))");
Logger::nas_mm().debug("Encoded NasMmPlainHeader (len 3 octets)");
return 3;
}
}
......
......@@ -61,7 +61,7 @@ bool RAN_UE_NGAP_ID::encode2RAN_UE_NGAP_ID(Ngap_RAN_UE_NGAP_ID_t &ranuengapid) {
//------------------------------------------------------------------------------
bool RAN_UE_NGAP_ID::decodefromRAN_UE_NGAP_ID(Ngap_RAN_UE_NGAP_ID_t &ranuengapid) {
ranUeNgapId = ranuengapid;
cout << "in libngap, received ranuengapid " << ranUeNgapId << endl;
cout << "[LibNGAP]Received RanUeNgapId " << ranUeNgapId << endl;
return true;
}
}
......
......@@ -46,11 +46,6 @@ void TAC::setTac(uint32_t m_tac) {
//------------------------------------------------------------------------------
bool TAC::encode2octetstring(Ngap_TAC_t &m_tac) {
m_tac.size = 3; //OCTET_STRING(SIZE(3))
//uint8_t *buffer = (uint8_t*)calloc(1,sizeof(uint8_t)+sizeof(uint16_t));
//if(!buffer) return false;
//*(uint32_t *)buffer = tac & 0x00ffffff;
//printf("tac(0x%x)\n", tac);
m_tac.buf = (uint8_t*) calloc(1, sizeof(uint8_t) + sizeof(uint16_t));
m_tac.buf[2] = tac & 0x0000ff;
m_tac.buf[1] = (tac & 0x00ff00) >> 8;
......@@ -67,7 +62,7 @@ bool TAC::decodefromoctetstring(Ngap_TAC_t &m_tac) {
for (int i = 0; i < m_tac.size; i++) {
tac |= m_tac.buf[i] << ((m_tac.size - 1 - i) * 8);
}
std::cout << "received tac: " << tac << std::endl;
std::cout << "Received TAC: " << tac << std::endl;
return true;
}
......
......@@ -241,12 +241,12 @@ bool InitialUEMessageMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (initialUEMessageIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && initialUEMessageIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialUEMessage_IEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(initialUEMessageIEs->protocolIEs.list.array[i]->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
cout << "Decoded NGAP RAN_UE_NGAP_ID IE error" << endl;
return false;
}
cout << "in initialUeMessage, received ranUeNgapId " << ranUeNgapId->getRanUeNgapId() << endl;
cout << "[InitialUeMessage] Received RanUeNgapId " << ranUeNgapId->getRanUeNgapId() << endl;
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
cout << "Decoded NGAP RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}
......@@ -255,11 +255,11 @@ bool InitialUEMessageMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (initialUEMessageIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && initialUEMessageIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialUEMessage_IEs__value_PR_NAS_PDU) {
nasPdu = new NAS_PDU();
if (!nasPdu->decodefromoctetstring(initialUEMessageIEs->protocolIEs.list.array[i]->value.choice.NAS_PDU)) {
cout << "decoded ngap NAS_PDU IE error" << endl;
cout << "Decoded NGAP NAS_PDU IE error" << endl;
return false;
}
} else {
cout << "decoded ngap NAS_PDU IE error" << endl;
cout << "Decoded NGAP NAS_PDU IE error" << endl;
return false;
}
}
......@@ -268,11 +268,11 @@ bool InitialUEMessageMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (initialUEMessageIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && initialUEMessageIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialUEMessage_IEs__value_PR_UserLocationInformation) {
userLocationInformation = new UserLocationInformation();
if (!userLocationInformation->decodefromUserLocationInformation(&initialUEMessageIEs->protocolIEs.list.array[i]->value.choice.UserLocationInformation)) {
cout << "decoded ngap UserLocationInformation IE error" << endl;
cout << "Decoded NGAP UserLocationInformation IE error" << endl;
return false;
}
} else {
cout << "decoded ngap UserLocationInformation IE error" << endl;
cout << "Decoded NGAP UserLocationInformation IE error" << endl;
return false;
}
}
......@@ -281,11 +281,11 @@ bool InitialUEMessageMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (initialUEMessageIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && initialUEMessageIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialUEMessage_IEs__value_PR_RRCEstablishmentCause) {
rRCEstablishmentCause = new RRCEstablishmentCause();
if (!rRCEstablishmentCause->decodefromRRCEstablishmentCause(initialUEMessageIEs->protocolIEs.list.array[i]->value.choice.RRCEstablishmentCause)) {
cout << "decoded ngap RRCEstablishmentCause IE error" << endl;
cout << "Decoded NGAP RRCEstablishmentCause IE error" << endl;
return false;
}
} else {
cout << "decoded ngap RRCEstablishmentCause IE error" << endl;
cout << "Decoded NGAP RRCEstablishmentCause IE error" << endl;
return false;
}
}
......@@ -294,11 +294,11 @@ bool InitialUEMessageMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (initialUEMessageIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && initialUEMessageIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialUEMessage_IEs__value_PR_UEContextRequest) {
uEContextRequest = new UEContextRequest();
if (!uEContextRequest->decodefromUEContextRequest(initialUEMessageIEs->protocolIEs.list.array[i]->value.choice.UEContextRequest)) {
cout << "decoded ngap UEContextRequest IE error" << endl;
cout << "Decoded NGAP UEContextRequest IE error" << endl;
return false;
}
} else {
cout << "decoded ngap UEContextRequest IE error" << endl;
cout << "Decoded NGAP UEContextRequest IE error" << endl;
return false;
}
}
......
......@@ -215,11 +215,11 @@ bool NGSetupRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (ngSetupRequestIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && ngSetupRequestIEs->protocolIEs.list.array[i]->value.present == Ngap_NGSetupRequestIEs__value_PR_GlobalRANNodeID) {
globalRanNodeId = new GlobalRanNodeId();
if (!globalRanNodeId->decodefromGlobalRANNodeID(&ngSetupRequestIEs->protocolIEs.list.array[i]->value.choice.GlobalRANNodeID)) {
cout << "decoded ngap GlobalRanNodeId IE error!" << endl;
cout << "Decoded NGAP GlobalRanNodeId IE error!" << endl;
return false;
}
} else {
cout << "decoded ngap GlobalRanNodeId IE error" << endl;
cout << "Decoded NGAP GlobalRanNodeId IE error" << endl;
return false;
}
}
......@@ -228,11 +228,11 @@ bool NGSetupRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (ngSetupRequestIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && ngSetupRequestIEs->protocolIEs.list.array[i]->value.present == Ngap_NGSetupRequestIEs__value_PR_RANNodeName) {
ranNodeName = new RanNodeName();
if (!ranNodeName->decodefromRanNodeName(&ngSetupRequestIEs->protocolIEs.list.array[i]->value.choice.RANNodeName)) {
cout << "decoded ngap RanNodeName IE error" << endl;
cout << "Decoded NGAP RanNodeName IE error" << endl;
return false;
}
} else {
cout << "decoded ngap RanNodeName IE error" << endl;
cout << "Decoded NGAP RanNodeName IE error" << endl;
return false;
}
}
......@@ -241,11 +241,11 @@ bool NGSetupRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (ngSetupRequestIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && ngSetupRequestIEs->protocolIEs.list.array[i]->value.present == Ngap_NGSetupRequestIEs__value_PR_SupportedTAList) {
supportedTAList = new SupportedTAList();
if (!supportedTAList->decodefromSupportedTAList(&ngSetupRequestIEs->protocolIEs.list.array[i]->value.choice.SupportedTAList)) {
cout << "decoded ngap SupportedTAList IE error" << endl;
cout << "Decoded NGAP SupportedTAList IE error" << endl;
return false;
}
} else {
cout << "decoded ngap SupportedTAList IE error" << endl;
cout << "Decoded NGAP SupportedTAList IE error" << endl;
return false;
}
}
......@@ -254,17 +254,17 @@ bool NGSetupRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (ngSetupRequestIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && ngSetupRequestIEs->protocolIEs.list.array[i]->value.present == Ngap_NGSetupRequestIEs__value_PR_PagingDRX) {
defaultPagingDrx = new DefaultPagingDRX();
if (!defaultPagingDrx->decodefromDefaultPagingDRX(ngSetupRequestIEs->protocolIEs.list.array[i]->value.choice.PagingDRX)) {
cout << "decoded ngap DefaultPagingDRX IE error" << endl;
cout << "Decoded NGAP DefaultPagingDRX IE error" << endl;
return false;
}
} else {
cout << "decoded ngap DefaultPagingDRX IE error" << endl;
cout << "Decoded NGAP DefaultPagingDRX IE error" << endl;
return false;
}
}
break;
default: {
cout << "decoded ngap message pdu error" << endl;
cout << "Decoded NGAP message PDU error" << endl;
return false;
}
}
......
......@@ -47,7 +47,7 @@ ngap_app::ngap_app(const std::string &address, const uint16_t port_num)
ppid_(60),
sctp_s_38412(address.c_str(), port_num) {
sctp_s_38412.start_receive(this);
Logger::ngap().info("set n2 amf ipv4_address:port (%s:%d)", address.c_str(), port_num);
Logger::ngap().info("Set N2 AMF IPv4 Addr, port: %s, %d", address.c_str(), port_num);
}
//------------------------------------------------------------------------------
......@@ -57,10 +57,10 @@ ngap_app::~ngap_app() {
//------------------------------------------------------------------------------
// received sctp payload and decode it to NGAP message and send itti message to TASK_AMF_N2
void ngap_app::handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) {
Logger::ngap().debug("NGAP handle SCTP payload from sctp_server on assoc_id(%d), stream_id(%d), instreams(%d), outstreams(%d)", assoc_id, stream, instreams, outstreams);
Logger::ngap().debug("Handling SCTP payload from sctp_server on assoc_id (%d), stream_id (%d), instreams (%d), outstreams (%d)", assoc_id, stream, instreams, outstreams);
Ngap_NGAP_PDU_t *ngap_msg_pdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU, (void**) &ngap_msg_pdu, bdata(payload), blength(payload));
Logger::ngap().debug("Decoded NGAP message[%d,%d]", ngap_msg_pdu->choice.initiatingMessage->procedureCode, ngap_msg_pdu->present);
Logger::ngap().debug("Decoded NGAP message, procedure code %d, present %d", ngap_msg_pdu->choice.initiatingMessage->procedureCode, ngap_msg_pdu->present);
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode][ngap_msg_pdu->present - 1])(assoc_id, stream, ngap_msg_pdu);
}
......@@ -68,10 +68,10 @@ void ngap_app::handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_st
//handle new sctp association
// TNL association(clause 8.7.1.1, 3gpp ts38.413)
void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) {
Logger::ngap().debug("Ready to handle new NGAP SCTP association(id:%d) request", assoc_id);
Logger::ngap().debug("Ready to handle new NGAP SCTP association (id: %d) request", assoc_id);
std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(assoc_id)) {
Logger::ngap().debug("Create a new gNB context with assoc_id(%d)", assoc_id);
Logger::ngap().debug("Create a new gNB context with assoc_id (%d)", assoc_id);
gc = std::shared_ptr < gnb_context > (new gnb_context());
set_assoc_id_2_gnb_context(assoc_id, gc);
} else {
......
......@@ -47,12 +47,12 @@ typedef int (*ngap_message_decoded_callback)(const sctp_assoc_id_t assoc_id, con
//------------------------------------------------------------------------------
int ngap_amf_handle_ng_setup_request(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti ng setup request message to TASK_AMF_N2");
Logger::ngap().debug("Sending ITTI NG Setup Request message to TASK_AMF_N2");
//need code from yangjian and send itti message to TASK_AMF_N2
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
NGSetupRequestMsg *ngSetupReq = new NGSetupRequestMsg();
if (!ngSetupReq->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding ngsetuprequest message error");
Logger::ngap().error("Decoding NGSetupRequest message error");
return -1;
}
//after decoding, need free(message_p)
......
......@@ -66,14 +66,14 @@ int sctp_server::create_socket(const char *address, const uint16_t port_num) {
Logger::sctp().error("socket: %s:%d", strerror(errno), errno);
return -1;
}
Logger::sctp().info("Created socket(%d)", socket_);
Logger::sctp().info("Created socket (%d)", socket_);
bzero(&serverAddr_, sizeof(serverAddr_));
serverAddr_.sin_family = AF_INET;
serverAddr_.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddr_.sin_port = htons(port_num);
inet_pton(AF_INET, address, &serverAddr_.sin_addr);
if (bind(socket_, (struct sockaddr*) &serverAddr_, sizeof(serverAddr_)) != 0) {
Logger::sctp().error("socket bind: %s:%d", strerror(errno), errno);
Logger::sctp().error("Socket bind: %s:%d", strerror(errno), errno);
}
bzero(&events_, sizeof(events_));
events_.sctp_data_io_event = 1;
......@@ -162,16 +162,16 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
union sctp_notification *snp = (union sctp_notification*) buffer;
switch (snp->sn_header.sn_type) {
case SCTP_SHUTDOWN_EVENT: {
Logger::sctp().debug("SCTP_SHUTDOWN_EVENT received");
Logger::sctp().debug("SCTP Shutdown Event received");
break;
//return sctp_handle_com_down((sctp_assoc_id_t) snp->sn_shutdown_event.sse_assoc_id);
}
case SCTP_ASSOC_CHANGE: {
Logger::sctp().debug("SCTP association change event received");
Logger::sctp().debug("SCTP Association Change event received");
return handle_assoc_change(sd, ppid, &snp->sn_assoc_change);
}
default: {
Logger::sctp().error("Unhandled notification type(%d)", snp->sn_header.sn_type);
Logger::sctp().error("Unhandled notification type (%d)", snp->sn_header.sn_type);
break;
}
}
......@@ -182,10 +182,10 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
}
association->messages_recv++;
if (ntohl(sinfo.sinfo_ppid) != association->ppid) {
Logger::sctp().error("Received data from peer with unsolicited PPID(%d), expecting(%d)", ntohl(sinfo.sinfo_ppid), association->ppid);
Logger::sctp().error("Received data from peer with unsolicited PPID (%d), expecting (%d)", ntohl(sinfo.sinfo_ppid), association->ppid);
return SCTP_RC_ERROR;
}
Logger::sctp().info("[assoc_id(%d)][socket(%d)] Msg of length(%d) received from port(%d), on stream(%d), PPID(%d)", sinfo.sinfo_assoc_id, sd, n, ntohs(addr.sin6_port), sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid));
Logger::sctp().info("[Assoc_id (%d)][Socket (%d)] Received a msg (length %d) from port %d, on stream %d, PPID %d", sinfo.sinfo_assoc_id, sd, n, ntohs(addr.sin6_port), sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid));
bstring payload = blk2bstr(buffer, n);
//handle payload
app_->handle_receive(payload, (sctp_assoc_id_t) sinfo.sinfo_assoc_id, sinfo.sinfo_stream, association->instreams, association->outstreams);
......@@ -206,7 +206,7 @@ int sctp_server::handle_assoc_change(int sd, uint32_t ppid, struct sctp_assoc_ch
switch (sctp_assoc_changed->sac_state) {
case SCTP_COMM_UP: {
if (add_new_association(sd, ppid, sctp_assoc_changed) == NULL) {
Logger::sctp().error("Add new association with ppid(%d) socket(%d) error", ppid, sd);
Logger::sctp().error("Add new association with ppid (%d) socket (%d) error", ppid, sd);
rc = SCTP_RC_ERROR;
}
break;
......@@ -226,7 +226,7 @@ int sctp_server::handle_assoc_change(int sd, uint32_t ppid, struct sctp_assoc_ch
break;
}
default:
Logger::sctp().error("Logging unhandled sctp message(%d)", sctp_assoc_changed->sac_state);
Logger::sctp().error("Unhandled sctp message (%d)", sctp_assoc_changed->sac_state);
break;
}
return rc;
......@@ -241,7 +241,7 @@ sctp_association_t* sctp_server::add_new_association(int sd, uint32_t ppid, stru
new_association->instreams = sctp_assoc_changed->sac_inbound_streams;
new_association->outstreams = sctp_assoc_changed->sac_outbound_streams;
new_association->assoc_id = (sctp_assoc_id_t) sctp_assoc_changed->sac_assoc_id;
Logger::sctp().debug("Add new association with id(%d)", (sctp_assoc_id_t) sctp_assoc_changed->sac_assoc_id);
Logger::sctp().debug("Add new association with id (%d)", (sctp_assoc_id_t) sctp_assoc_changed->sac_assoc_id);
sctp_ctx.push_back(new_association);
sctp_get_localaddresses(sd, NULL, NULL);
sctp_get_peeraddresses(sd, &new_association->peer_addresses, &new_association->nb_peer_addresses);
......@@ -279,14 +279,14 @@ int sctp_server::sctp_get_peeraddresses(int sock, struct sockaddr **remote_addr,
struct sockaddr_in *addr = NULL;
addr = (struct sockaddr_in*) &temp_addr_p[j];
if (inet_ntop(AF_INET, &addr->sin_addr, address, sizeof(address)) != NULL) {
Logger::sctp().info(" - [%s]", address);
Logger::sctp().info(" - IPv4 Addr: %s\n", address);
}
} else {
struct sockaddr_in6 *addr = NULL;
char address[40] = { 0 };
addr = (struct sockaddr_in6*) &temp_addr_p[j];
if (inet_ntop(AF_INET6, &addr->sin6_addr.s6_addr, address, sizeof(address)) != NULL) {
Logger::sctp().info(" - [%s]", address);
Logger::sctp().info(" - IPv6 Addr: %s\n", address);
}
}
}
......@@ -317,20 +317,19 @@ int sctp_server::sctp_get_localaddresses(int sock, struct sockaddr **local_addr,
struct sockaddr_in *addr = NULL;
addr = (struct sockaddr_in*) &temp_addr_p[j];
if (inet_ntop(AF_INET, &addr->sin_addr, address, sizeof(address)) != NULL) {
Logger::sctp().info(" - [%s]", address);
Logger::sctp().info(" - IPv4 Addr: %s\n", address);
}
} else if (temp_addr_p[j].sa_family == AF_INET6) {
struct sockaddr_in6 *addr = NULL;
char address[40] = { 0 };
addr = (struct sockaddr_in6*) &temp_addr_p[j];
if (inet_ntop(AF_INET6, &addr->sin6_addr.s6_addr, address, sizeof(address)) != NULL) {
Logger::sctp().info(" - [%s]", address);
Logger::sctp().info(" - IPv6 Addr: %s\n", address);
}
} else {
Logger::sctp().error(" - unhandled address family %d", temp_addr_p[j].sa_family);
}
}
Logger::sctp().info("----------------------");
if (local_addr != NULL && nb_local_addresses != NULL) {
*nb_local_addresses = nb;
*local_addr = temp_addr_p;
......@@ -345,16 +344,16 @@ int sctp_server::sctp_get_localaddresses(int sock, struct sockaddr **local_addr,
int sctp_server::sctp_send_msg(sctp_assoc_id_t sctp_assoc_id, sctp_stream_id_t stream, bstring *payload) {
sctp_association_t *assoc_desc = NULL;
if ((assoc_desc = sctp_is_assoc_in_list(sctp_assoc_id)) == NULL) {
Logger::sctp().error("This assoc id(%d) has not been fount in list", sctp_assoc_id);
Logger::sctp().error("This assoc id (%d) has not been fount in list", sctp_assoc_id);
return -1;
}
if (assoc_desc->sd == -1) {
Logger::sctp().error("The socket is invalid may be closed (assoc id %d)", sctp_assoc_id);
return -1;
}
Logger::sctp().debug("[%d][%d] Sending buffer %p of %d bytes on stream %d with ppid %d", assoc_desc->sd, sctp_assoc_id, bdata(*payload), blength(*payload), stream, assoc_desc->ppid);
Logger::sctp().debug("[Socket %d, Assoc ID %d] Sending buffer %p of %d bytes on stream %d with ppid %d", assoc_desc->sd, sctp_assoc_id, bdata(*payload), blength(*payload), stream, assoc_desc->ppid);
if (sctp_sendmsg(assoc_desc->sd, (const void*) bdata(*payload), (size_t) blength(*payload), NULL, 0, htonl(assoc_desc->ppid), 0, stream, 0, 0) < 0) {
Logger::sctp().error("Send, sd:%u,stream:%u,ppid:%u, len:%u, failed: %s,%d", assoc_desc->sd, stream, htonl(assoc_desc->ppid), blength(*payload), strerror(errno), errno);
Logger::sctp().error("[Socket %d] Send stream %u, ppid %u, len %u failed (%s, %d)", assoc_desc->sd, stream, htonl(assoc_desc->ppid), blength(*payload), strerror(errno), errno);
*payload = NULL;
return -1;
}
......
......@@ -377,7 +377,7 @@ void Authentication_5gaka::derive_knas(algorithm_type_dist_t nas_alg_type, uint8
//memcpy (knas, &out[31 - 16 + 1], 16);
for (int i = 0; i < 16; i++)
knas[i] = out[16 + i];
Logger::amf_n1().debug("derive knas finished!");
Logger::amf_n1().debug("derive_knas finished!");
}
//------------------------------------------------------------------------------
......
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