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);
}
}
This diff is collapsed.
......@@ -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;
......
This diff is collapsed.
......@@ -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);
}
......
This diff is collapsed.
......@@ -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