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

Fix typo

parent f3616257
......@@ -120,7 +120,7 @@ void amf_app_task(void*) {
stacs.display();
break;
default:
Logger::amf_app().info("no handler for timer(%d) with arg1_user(%d) ", to->timer_id, to->arg1_user);
Logger::amf_app().info("No handler for timer(%d) with arg1_user(%d) ", to->timer_id, to->arg1_user);
}
}
break;
......@@ -221,7 +221,7 @@ 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 existed ue_context, create 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);
......@@ -270,13 +270,13 @@ void amf_app::handle_itti_message(itti_nas_signalling_establishment_request &itt
//SMF Client response handlers
//------------------------------------------------------------------------------
void amf_app::handle_post_sm_context_response_error_400() {
Logger::amf_app().error("post sm context response error 400");
Logger::amf_app().error("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;
......
......@@ -63,7 +63,7 @@ amf_config::~amf_config() {
//------------------------------------------------------------------------------
int amf_config::load(const std::string &config_file) {
cout << endl;
Logger::amf_app().debug("Load amf system configuration file(%s)", config_file.c_str());
Logger::amf_app().debug("Load AMF system configuration file(%s)", config_file.c_str());
Config cfg;
unsigned char buf_in6_addr[sizeof(struct in6_addr)];
try {
......
......@@ -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;
......@@ -214,18 +214,18 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
uint8_t *buf = (uint8_t*) bdata(recved_nas_msg);
int buf_len = blength(recved_nas_msg);
uint32_t mac32_recv = ntohl((((uint32_t*) (buf + 2))[0]));
Logger::amf_n1().debug("received mac32(0x%x) from the message", mac32_recv);
Logger::amf_n1().debug("Received mac32(0x%x) from the message", mac32_recv);
if (mac32 == mac32_recv) {
isMatched = true;
//nc.get()->security_ctx->ul_count.seq_num ++;
}
if (!isMatched) {
Logger::amf_n1().error("received message not integrity matched");
Logger::amf_n1().error("Received message not integrity matched");
return;
} else {
bstring ciphered = blk2bstr(buf + 7, buf_len - 7);
if (!nas_message_cipher_protected(nc.get()->security_ctx, NAS_MESSAGE_UPLINK, ciphered, decoded_plain_msg)) {
Logger::amf_n1().error("decrypt NAS message failure");
Logger::amf_n1().error("Decrypt NAS message failure");
return;
}
}
......@@ -285,7 +285,7 @@ void amf_n1::nas_signalling_establishment_request_handle(SecurityHeaderType type
}
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);
}
}
......@@ -381,7 +381,7 @@ void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context>
uint8_t *kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Logger::amf_n1().debug("uplink count(%d)", secu->ul_count.seq_num);
Logger::amf_n1().debug("Uplink count(%d)", secu->ul_count.seq_num);
print_buffer("amf_n1", "kamf", kamf, 32);
Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32);
......@@ -468,7 +468,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
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);
......@@ -566,17 +566,17 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
}
break;
case MOBILITY_REGISTRATION_UPDATING: {
Logger::amf_n1().error("The network handling mobility registration ...");
Logger::amf_n1().error("Network handling mobility registration ...");
run_mobility_registration_update_procedure(nc);
}
break;
case PERIODIC_REGISTRATION_UPDATING: {
Logger::amf_n1().error("The network doesn't support periodic registration, reject ...");
Logger::amf_n1().error("Network doesn't support periodic registration, reject ...");
}
break;
case EMERGENCY_REGISTRATION: {
if (!amf_cfg.is_emergency_support.compare("false")) {
Logger::amf_n1().error("The network doesn't support emergency registration, reject ...");
Logger::amf_n1().error("Network doesn't support emergency registration, reject ...");
response_registration_reject_msg(_5GMM_CAUSE_ILLEGAL_UE, ran_ue_ngap_id, amf_ue_ngap_id); //cause?
return;
}
......@@ -782,8 +782,8 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
}
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("No auts ...");
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);
......@@ -911,7 +911,7 @@ void amf_n1::annex_a_4_33501(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uin
oldS[24 + i] = input[i];
oldS[32] = 0x00;
oldS[33] = 0x08;
print_buffer("amf_n1", "inputstring: ", S, 31 + netName.size);
print_buffer("amf_n1", "input string: ", S, 31 + netName.size);
uint8_t key[32];
memcpy(&key[0], ck, 16);
memcpy(&key[16], ik, 16); //KEY
......@@ -1128,7 +1128,7 @@ bool amf_n1::start_security_mode_control_procedure(std::shared_ptr<nas_context>
security_data_t *data = (security_data_t*) calloc(1, sizeof(security_data_t));
nas_secu_ctx *secu_ctx = nc.get()->security_ctx;
if (!data)
Logger::amf_n1().error("cannot calloc memory for security_data_t");
Logger::amf_n1().error("Cannot allocate memory for security_data_t");
if (secu_ctx->sc_type == SECURITY_CTX_TYPE_NOT_AVAILABLE && nc.get()->is_common_procedure_for_security_mode_control_running) {
Logger::amf_n1().debug("Using INTEGRITY_PROTECTED_WITH_NEW_SECU_CTX for SecurityModeControl message");
data->saved_selected_nea = secu_ctx->nas_algs.encryption; //emm_ctx->_security.selected_algorithms.encryption;
......@@ -1231,7 +1231,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);
......@@ -1317,7 +1317,7 @@ void amf_n1::encode_nas_message_protected(nas_secu_ctx *nsc, bool is_secu_ctx_ne
memcpy(protected_nas_buf, input_nas_buf, input_nas_len);
encoded_size = input_nas_len;
} else {
Logger::amf_n1().debug("Outter mac32: 0x%x", mac32);
Logger::amf_n1().debug("mac32: 0x%x", mac32);
*(uint32_t*) (protected_nas_buf + 2) = htonl(mac32);
encoded_size = 7 + input_nas_len;
}
......@@ -1336,7 +1336,7 @@ void amf_n1::encode_nas_message_protected(nas_secu_ctx *nsc, bool is_secu_ctx_ne
memcpy(protected_nas_buf, input_nas_buf, input_nas_len);
encoded_size = input_nas_len;
} else {
Logger::amf_n1().debug("Outter mac32: 0x%x", mac32);
Logger::amf_n1().debug("mac32: 0x%x", mac32);
*(uint32_t*) (protected_nas_buf + 2) = htonl(mac32);
encoded_size = 7 + input_nas_len;
}
......@@ -1368,11 +1368,11 @@ 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);
stream_cipher.blength = input_nas_len * 8;
......@@ -1387,16 +1387,16 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc, uint8_t directio
nas_algorithms::nas_stream_encrypt_nia1(&stream_cipher, mac);
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");
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);
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;
......@@ -1575,15 +1575,15 @@ void amf_n1::run_mobility_registration_update_procedure(std::shared_ptr<nas_cont
regAccept->setALLOWED_NSSAI(nssai);
//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"; //need modify
Logger::amf_n1().debug("allocated guti %s", guti.c_str());
std::string guti = "1234567890"; //TODO: need modify
Logger::amf_n1().debug("Allocated guti %s", guti.c_str());
regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
uint8_t buffer[1024] = { 0 };
int encoded_size = regAccept->encode2buffer(buffer, 1024);
print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer, encoded_size);
if (!encoded_size) {
Logger::nas_mm().error("encode Registration-Accept message error");
Logger::nas_mm().error("Encode Registration-Accept message error");
return;
} else {
delete regAccept;
......
......@@ -57,6 +57,7 @@ extern amf_app *amf_app_inst;
extern statistics stacs;
void amf_n2_task(void*);
//------------------------------------------------------------------------------
void amf_n2_task(void *args_p) {
const task_id_t task_id = TASK_AMF_N2;
......@@ -134,7 +135,7 @@ amf_n2::amf_n2(const string &address, const uint16_t port_num)
throw std::runtime_error("Cannot create task TASK_AMF_N2");
}
Logger::task_amf_n2().startup("Started");
Logger::task_amf_n2().debug("construct amf_n2 successfully");
Logger::task_amf_n2().debug("Construct amf_n2 successfully");
}
//------------------------------------------------------------------------------
......@@ -150,7 +151,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)) {
......@@ -472,7 +473,6 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request &itti_msg) {
memcpy(uecap, (uint8_t*) bdata(ueCapability), blength(ueCapability));
uecap[blength(ueCapability)] = '\0';
msg->setUERadioCapability(uecap, (size_t)blength(ueCapability));
//msg->setUERadioCapability((uint8_t*)bdata(ueCapability), (size_t)blength(ueCapability));
Logger::amf_n2().debug("Encoding parameters for service request");
std::vector<PDUSessionResourceSetupRequestItem_t> list;
PDUSessionResourceSetupRequestItem_t item;
......@@ -601,7 +601,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;
}
......
......@@ -41,7 +41,7 @@ bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { /
std::string query;
if (!db_desc->db_conn) {
Logger::amf_n1().error("Cannot connect to mysql db");
Logger::amf_n1().error("Cannot connect to MySQL DB");
return false;
}
query = "SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='" + imsi + "' ";
......@@ -54,7 +54,7 @@ bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { /
res = mysql_store_result(db_desc->db_conn);
pthread_mutex_unlock(&db_desc->db_cs_mutex);
if (!res) {
Logger::amf_n1().error("data fetched from mysql is not present");
Logger::amf_n1().error("data fetched from MySQL is not present");
return false;
}
if (row = mysql_fetch_row(res)) {
......@@ -83,7 +83,7 @@ bool amf_n1::connect_to_mysql() {
const int mysql_reconnect_val = 1;
db_desc = (database_t*) calloc(1, sizeof(database_t));
if (!db_desc) {
Logger::amf_n1().error("An error occurs when calloc");
Logger::amf_n1().error("An error occurs when allocate memory for DB_DESC");
return false;
}
pthread_mutex_init(&db_desc->db_cs_mutex, NULL);
......@@ -110,11 +110,11 @@ void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p, uint8_t *sqn
int query_length = 0;
uint64_t sqn_decimal = 0;
if (!db_desc->db_conn) {
Logger::amf_n1().error("Cannot connect to mysql");
Logger::amf_n1().error("Cannot connect to MySQL DB");
return;
}
if (!sqn || !rand_p) {
Logger::amf_n1().error("need sqn and rand");
Logger::amf_n1().error("Need sqn and rand");
return;
}
sqn_decimal = ((uint64_t) sqn[0] << 40) | ((uint64_t) sqn[1] << 32) | ((uint64_t) sqn[2] << 24) | (sqn[3] << 16) | (sqn[4] << 8) | sqn[5];
......@@ -156,7 +156,7 @@ void amf_n1::mysql_increment_sqn(std::string imsi) {
MYSQL_RES *res;
char query[1000];
if (db_desc->db_conn == NULL) {
Logger::amf_n1().error("Cannot connect to mysql");
Logger::amf_n1().error("Cannot connect to MySQL DB");
return;
}
sprintf(query, "UPDATE `users` SET `sqn` = `sqn` + 32 WHERE `users`.`imsi`='%s'", imsi.c_str());
......
......@@ -37,7 +37,7 @@ class pdu_session_context {
public:
pdu_session_context();
~pdu_session_context();
public:
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
uint8_t req_type;
......
......@@ -43,17 +43,17 @@ using namespace config;
using namespace ngap;
amf_config amf_cfg;
ngap_app * ngap_inst = NULL;
ngap_app *ngap_inst = NULL;
int main(int argc, char **argv){
int main(int argc, char **argv) {
srand (time(NULL));
if(!Options::parse(argc, argv)){
if (!Options::parse(argc, argv)) {
cout<<"Options::parse() failed"<<endl;
return 1;
}
Logger::init( "amf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::init( "AMF" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::amf_app().startup("Options parsed!");
amf_cfg.load(Options::getlibconfigConfig());
......
......@@ -32,52 +32,59 @@
#include "amf_module_from_config.hpp"
#include "ngap_message_callback.hpp"
extern "C"{
#include "Ngap_NGAP-PDU.h"
#include "Ngap_InitiatingMessage.h"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_InitiatingMessage.h"
}
using namespace sctp;
using namespace config;
using namespace ngap;
ngap_app::ngap_app(const string & address, const uint16_t port_num):ppid_(60),sctp_s_38412(address.c_str(),port_num){
//------------------------------------------------------------------------------
ngap_app::ngap_app(const 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);
}
ngap_app::~ngap_app(){}
/**************************************** received sctp paylaod and decode it to NGAP message and send itti message to TASK_AMF_N2 ***************************************/
//------------------------------------------------------------------------------
ngap_app::~ngap_app() {
}
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);
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);
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode][ngap_msg_pdu->present - 1]) (assoc_id, stream, ngap_msg_pdu);
//------------------------------------------------------------------------------
// received sctp paylaod 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);
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);
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode][ngap_msg_pdu->present - 1])(assoc_id, stream, ngap_msg_pdu);
}
/***************************************** handle new sctp association *************************************/
//------------------------------------------------------------------------------
//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);
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);
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);
gc = std::shared_ptr<gnb_context>(new gnb_context());
if (!is_assoc_id_2_gnb_context(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{
} else {
gc = assoc_id_2_gnb_context(assoc_id);
if(gc.get()->ng_state == NGAP_RESETING || gc.get()->ng_state == NGAP_SHUTDOWN){
if (gc.get()->ng_state == NGAP_RESETING || gc.get()->ng_state == NGAP_SHUTDOWN) {
Logger::ngap().warn("Received new association request on an association that is being %s, ignoring", ng_gnb_state_str[gc.get()->ng_state]);
}else{
} else {
Logger::ngap().debug("Update gNB context with assoc id (%d)", assoc_id);
}
}
if(gc.get() == nullptr){
if (gc.get() == nullptr) {
Logger::ngap().error("Failed to create gNB context for assoc_id(%d)", assoc_id);
}else{
} else {
gc.get()->sctp_assoc_id = assoc_id;
gc.get()->instreams = instreams;
gc.get()->outstreams = outstreams;
......@@ -86,26 +93,26 @@ void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream
}
}
uint32_t ngap_app::getPpid(){
//------------------------------------------------------------------------------
uint32_t ngap_app::getPpid() {
return ppid_;
}
/******************************************* gnb context management **********************************************/
bool ngap_app::is_assoc_id_2_gnb_context(const sctp_assoc_id_t & assoc_id) const{
//gnb context management
//------------------------------------------------------------------------------
bool ngap_app::is_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const {
std::shared_lock lock(m_assoc2gnbContext);
return bool{assoc2gnbContext.count(assoc_id) > 0};
return bool { assoc2gnbContext.count(assoc_id) > 0 };
}
std::shared_ptr<gnb_context> ngap_app::assoc_id_2_gnb_context(const sctp_assoc_id_t & assoc_id) const{
//------------------------------------------------------------------------------
std::shared_ptr<gnb_context> ngap_app::assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const {
std::shared_lock lock(m_assoc2gnbContext);
return assoc2gnbContext.at(assoc_id);
}
void ngap_app::set_assoc_id_2_gnb_context(const sctp_assoc_id_t& assoc_id, std::shared_ptr<gnb_context> gc){
//------------------------------------------------------------------------------
void ngap_app::set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id, std::shared_ptr<gnb_context> gc) {
std::shared_lock lock(m_assoc2gnbContext);
assoc2gnbContext[assoc_id] = gc;
}
......@@ -37,48 +37,32 @@
#include <string>
#include <thread>
using namespace sctp;
namespace ngap{
namespace ngap {
static const char * const ng_gnb_state_str [] = {"NGAP_INIT", "NGAP_RESETTING", "NGAP_READY", "NGAP_SHUTDOWN"};
static const char *const ng_gnb_state_str[] = { "NGAP_INIT", "NGAP_RESETTING", "NGAP_READY", "NGAP_SHUTDOWN" };
class ngap_app : public sctp_application{
public:
class ngap_app : public sctp_application {
public:
ngap_app(const string &address, const uint16_t port_num);
~ngap_app();
uint32_t getPpid();
protected:
protected:
sctp_server sctp_s_38412;
uint32_t ppid_;
std::map<sctp_assoc_id_t, std::shared_ptr<gnb_context>> assoc2gnbContext;
mutable std::shared_mutex m_assoc2gnbContext;
public:
public:
void 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);
void handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams);
public:
bool is_assoc_id_2_gnb_context(const sctp_assoc_id_t & assoc_id) const;
void set_assoc_id_2_gnb_context(const sctp_assoc_id_t& assoc_id, std::shared_ptr<gnb_context> gc);
std::shared_ptr<gnb_context> assoc_id_2_gnb_context(const sctp_assoc_id_t & assoc_id) const;
};
bool is_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const;
void set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id, std::shared_ptr<gnb_context> gc);
std::shared_ptr<gnb_context> assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id) const;
};
}
#endif
......@@ -34,49 +34,43 @@
#include "NGSetupRequest.hpp"
#include "PduSessionResourceSetupResponse.hpp"
#include "InitialContextSetupResponse.hpp"
//extern "C"{
// #include "Ngap_NGAP-PDU.h"
//}
using namespace sctp;
using namespace ngap;
extern itti_mw * itti_inst;
extern itti_mw *itti_inst;
typedef int (*ngap_message_decoded_callback)(
const sctp_assoc_id_t assoc_id,
const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU *message_p
);
typedef int (*ngap_message_decoded_callback)(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p);
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");
//------------------------------------------------------------------------------
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");
//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");
if (!ngSetupReq->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding ngsetuprequest message error");
return -1;
}
//after decoding, need free(message_p)
itti_ng_setup_request * itti_msg = new itti_ng_setup_request(TASK_NGAP, TASK_AMF_N2);
itti_ng_setup_request *itti_msg = new itti_ng_setup_request(TASK_NGAP, TASK_AMF_N2);
itti_msg->assoc_id = assoc_id;
itti_msg->stream = stream;
itti_msg->ngSetupReq = ngSetupReq;
std::shared_ptr<itti_ng_setup_request> i = std::shared_ptr<itti_ng_setup_request>(itti_msg);
std::shared_ptr<itti_ng_setup_request> i = std::shared_ptr < itti_ng_setup_request > (itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
}
}
int ngap_amf_handle_initial_ue_message(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti initial ue message to TASK_AMF_N2");
//------------------------------------------------------------------------------
int ngap_amf_handle_initial_ue_message(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti initial ue message to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
//decode INITIAL_UE_MESSAGE
InitialUEMessageMsg * initUeMsg = new InitialUEMessageMsg();
if(!initUeMsg->decodefrompdu(message_p)){
InitialUEMessageMsg *initUeMsg = new InitialUEMessageMsg();
if (!initUeMsg->decodefrompdu(message_p)) {
Logger::ngap().error("decoding initialuemessage message error");
return -1;
}
......@@ -84,219 +78,200 @@ int ngap_amf_handle_initial_ue_message(const sctp_assoc_id_t assoc_i
init_ue_msg->assoc_id = assoc_id;
init_ue_msg->stream = stream;
init_ue_msg->initUeMsg = initUeMsg;
std::shared_ptr<itti_initial_ue_message> i = std::shared_ptr<itti_initial_ue_message>(init_ue_msg);
std::shared_ptr<itti_initial_ue_message> i = std::shared_ptr < itti_initial_ue_message > (init_ue_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
}
}
int ngap_amf_handle_uplink_nas_transport(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti up link nas transport message to TASK_AMF_N2");
//------------------------------------------------------------------------------
int ngap_amf_handle_uplink_nas_transport(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti up link nas transport message to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
UplinkNASTransportMsg * uplinkNasT = new UplinkNASTransportMsg();
if(!uplinkNasT->decodefrompdu(message_p)){
UplinkNASTransportMsg *uplinkNasT = new UplinkNASTransportMsg();
if (!uplinkNasT->decodefrompdu(message_p)) {
Logger::ngap().error("decoding UplinkNasTransport message error");
return -1;
}
itti_ul_nas_transport * itti_ul_nas = new itti_ul_nas_transport(TASK_NGAP, TASK_AMF_N2);
itti_ul_nas_transport *itti_ul_nas = new itti_ul_nas_transport(TASK_NGAP, TASK_AMF_N2);
itti_ul_nas->assoc_id = assoc_id;
itti_ul_nas->stream = stream;
itti_ul_nas->ulNas = uplinkNasT;
std::shared_ptr<itti_ul_nas_transport> i = std::shared_ptr<itti_ul_nas_transport>(itti_ul_nas);
std::shared_ptr<itti_ul_nas_transport> i = std::shared_ptr < itti_ul_nas_transport > (itti_ul_nas);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
}
}
int ngap_amf_handle_initial_context_setup_response(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti initial context setup response to TASK_AMF_N11");
InitialContextSetupResponseMsg * initCtxResp = new InitialContextSetupResponseMsg();
if(!initCtxResp->decodefrompdu(message_p)){
Logger::ngap().error("decoding InitialContextSetupResponse message error");
//------------------------------------------------------------------------------
int ngap_amf_handle_initial_context_setup_response(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti initial context setup response to TASK_AMF_N11");
InitialContextSetupResponseMsg *initCtxResp = new InitialContextSetupResponseMsg();
if (!initCtxResp->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding InitialContextSetupResponse message error");
return -1;
}
std::vector<PDUSessionResourceSetupResponseItem_t> list;
if(!initCtxResp->getPduSessionResourceSetupResponseList(list)){
Logger::ngap().error("decoding PduSessionResourceSetupResponseMsg getPduSessionResourceSetupResponseList IE error or this IE is not avaliable");
if (!initCtxResp->getPduSessionResourceSetupResponseList(list)) {
Logger::ngap().error("Decoding PduSessionResourceSetupResponseMsg getPduSessionResourceSetupResponseList IE error or this IE is not available");
return 0;
}
uint8_t transferIe[500];
memcpy(transferIe, list[0].pduSessionResourceSetupResponseTransfer.buf, list[0].pduSessionResourceSetupResponseTransfer.size);
bstring n2sm = blk2bstr(transferIe, list[0].pduSessionResourceSetupResponseTransfer.size);
itti_nsmf_pdusession_update_sm_context * itti_msg = new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_nsmf_pdusession_update_sm_context *itti_msg = new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = list[0].pduSessionId;
itti_msg->n2sm = n2sm;
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_msg);
std::shared_ptr < itti_nsmf_pdusession_update_sm_context > i = std::shared_ptr < itti_nsmf_pdusession_update_sm_context > (itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N11", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N11", i->get_msg_name());
}
return 0;
}
int ngap_amf_handle_initial_context_setup_failure(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti initial context setup failure to TASK_AMF_N2");
//------------------------------------------------------------------------------
int ngap_amf_handle_initial_context_setup_failure(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti initial context setup failure to TASK_AMF_N2");
return 0;
}
int ngap_amf_handle_ue_radio_cap_indication(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti ue radio capability indication to TASK_AMF_N2");
//------------------------------------------------------------------------------
int ngap_amf_handle_ue_radio_cap_indication(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti ue radio capability indication to TASK_AMF_N2");
UeRadioCapabilityInfoIndicationMsg *ueRadioCap = new UeRadioCapabilityInfoIndicationMsg();
if(!ueRadioCap->decodefrompdu(message_p)){
Logger::ngap().error("decoding UEContextReleaseRequest message error");
if (!ueRadioCap->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding UEContextReleaseRequest message error");
return -1;
}
itti_ue_radio_capability_indication * itti_msg = new itti_ue_radio_capability_indication(TASK_NGAP, TASK_AMF_N2);
itti_ue_radio_capability_indication *itti_msg = new itti_ue_radio_capability_indication(TASK_NGAP, TASK_AMF_N2);
itti_msg->assoc_id = assoc_id;
itti_msg->stream = stream;
itti_msg->ueRadioCap = ueRadioCap;
std::shared_ptr<itti_ue_radio_capability_indication> i = std::shared_ptr<itti_ue_radio_capability_indication>(itti_msg);
std::shared_ptr<itti_ue_radio_capability_indication> i = std::shared_ptr < itti_ue_radio_capability_indication > (itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
}
}
int ngap_amf_handle_ue_context_release_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 ue context release request to TASK_AMF_N2");
UEContextReleaseRequestMsg * ueCtxRelReq = new UEContextReleaseRequestMsg();
if(!ueCtxRelReq->decodefrompdu(message_p)){
Logger::ngap().error("decoding UEContextReleaseRequest message error");
//------------------------------------------------------------------------------
int ngap_amf_handle_ue_context_release_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 ue context release request to TASK_AMF_N2");
UEContextReleaseRequestMsg *ueCtxRelReq = new UEContextReleaseRequestMsg();
if (!ueCtxRelReq->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding UEContextReleaseRequest message error");
return -1;
}
itti_ue_context_release_request * itti_msg = new itti_ue_context_release_request(TASK_NGAP, TASK_AMF_N2);
itti_ue_context_release_request *itti_msg = new itti_ue_context_release_request(TASK_NGAP, TASK_AMF_N2);
itti_msg->assoc_id = assoc_id;
itti_msg->stream = stream;
itti_msg->ueCtxRel = ueCtxRelReq;
std::shared_ptr<itti_ue_context_release_request> i = std::shared_ptr<itti_ue_context_release_request>(itti_msg);
std::shared_ptr<itti_ue_context_release_request> i = std::shared_ptr < itti_ue_context_release_request > (itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
}
}
int ngap_amf_handle_ue_context_release_complete(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti ue context release complete to TASK_AMF_N2");
//------------------------------------------------------------------------------
int ngap_amf_handle_ue_context_release_complete(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti ue context release complete to TASK_AMF_N2");
return 0;
}
int ngap_amf_handle_pdu_session_resource_setup_response(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("sending itti pdu_session_resource_setup_response to TASK_AMF_N11");
//------------------------------------------------------------------------------
int ngap_amf_handle_pdu_session_resource_setup_response(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti pdu_session_resource_setup_response to TASK_AMF_N11");
#if 1
PduSessionResourceSetupResponseMsg * pduresp = new PduSessionResourceSetupResponseMsg();
if(!pduresp->decodefrompdu(message_p)){
Logger::ngap().error("decoding PduSessionResourceSetupResponseMsg message error");
PduSessionResourceSetupResponseMsg *pduresp = new PduSessionResourceSetupResponseMsg();
if (!pduresp->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding PduSessionResourceSetupResponseMsg message error");
return -1;
}
std::vector<PDUSessionResourceSetupResponseItem_t> list;
if(!pduresp->getPduSessionResourceSetupResponseList(list)){
Logger::ngap().error("decoding PduSessionResourceSetupResponseMsg getPduSessionResourceSetupResponseList IE error");
if (!pduresp->getPduSessionResourceSetupResponseList(list)) {
Logger::ngap().error("Decoding PduSessionResourceSetupResponseMsg getPduSessionResourceSetupResponseList IE error");
return -1;
}
uint8_t transferIe[500];
memcpy(transferIe, list[0].pduSessionResourceSetupResponseTransfer.buf, list[0].pduSessionResourceSetupResponseTransfer.size);
bstring n2sm = blk2bstr(transferIe, list[0].pduSessionResourceSetupResponseTransfer.size);
itti_nsmf_pdusession_update_sm_context * itti_msg = new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_nsmf_pdusession_update_sm_context *itti_msg = new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = list[0].pduSessionId;
itti_msg->n2sm = n2sm;
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_msg);
std::shared_ptr < itti_nsmf_pdusession_update_sm_context > i = std::shared_ptr < itti_nsmf_pdusession_update_sm_context > (itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error( "Could not send ITTI message %s to task TASK_AMF_N11", i->get_msg_name());
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N11", i->get_msg_name());
}
#endif
return 0;
}
ngap_message_decoded_callback messages_callback[][3] = {
{0,0,0}, /*0 AMFConfigurationUpdate*/
{0,0,0}, /*1 AMFStatusIndication*/
{0,0,0}, /*2 CellTrafficTrace*/
{0,0,0}, /*3 DeactivateTrace*/
{0,0,0}, /*4 DownlinkNASTransport*/
{0,0,0}, /*5 DownlinkNonUEAssociatedNRPPaTransport*/
{0,0,0}, /*6 DownlinkRANConfigurationTransfer*/
{0,0,0}, /*7 DownlinkRANStatusTransfer*/
{0,0,0}, /*8 DownlinkUEAssociatedNRPPaTransport*/
{0,0,0},//9 {ngap_amf_handle_error_indication,0,0}, /*ErrorIndication*/
{0,0,0}, /*10 HandoverCancel*/
{0,0,0}, /*11 HandoverNotification*/
{0,0,0}, /*12 HandoverPreparation*/
{0,0,0}, /*13 HandoverResourceAllocation*/
{0,ngap_amf_handle_initial_context_setup_response,ngap_amf_handle_initial_context_setup_failure}, /*InitialContextSetup*/
{ngap_amf_handle_initial_ue_message,0,0},//15 {ngap_amf_handle_initial_ue_message,0,0}, /*InitialUEMessage*/
{0,0,0}, /*16 LocationReportingControl*/
{0,0,0}, /*17 LocationReportingFailureIndication*/
{0,0,0}, /*18 LocationReport*/
{0,0,0}, /*19 NASNonDeliveryIndication*/
{0,0,0}, /*20 NGReset*/
{ngap_amf_handle_ng_setup_request,0,0}, /*21 NGSetup*/
{0,0,0}, /*OverloadStart*/
{0,0,0}, /*OverloadStop*/
{0,0,0}, /*Paging*/
{0,0,0},//{ngap_amf_handle_path_switch_request,0,0}, /*PathSwitchRequest*
{0,0,0}, /*PDUSessionResourceModify*/
{0,0,0}, /*PDUSessionResourceModifyIndication*/
{0,0,0}, /*PDUSessionResourceRelease*/
{0,ngap_amf_handle_pdu_session_resource_setup_response,0}, /*PDUSessionResourceSetup*/
{0,0,0}, /*PDUSessionResourceNotify*/
{0,0,0}, /*PrivateMessage*/
{0,0,0}, /*PWSCancel*/
{0,0,0}, /*PWSFailureIndication*/
{0,0,0}, /*PWSRestartIndication*/
{0,0,0}, /*RANConfigurationUpdate*/
{0,0,0}, /*RerouteNASRequest*/
{0,0,0}, /*RRCInactiveTransitionReport*/
{0,0,0}, /*TraceFailureIndication*/
{0,0,0}, /*TraceStart*/
{0,0,0}, /*UEContextModification*/
{0,ngap_amf_handle_ue_context_release_complete,0}, /*UEContextRelease*/
{ngap_amf_handle_ue_context_release_request,0,0}, /*UEContextReleaseRequest*/
{0,0,0}, /*UERadioCapabilityCheck*/
{ngap_amf_handle_ue_radio_cap_indication,0,0}, /*UERadioCapabilityInfoIndication*/
{0,0,0}, /*UETNLABindingRelease*/
{ngap_amf_handle_uplink_nas_transport,0,0},//{ngap_amf_handle_uplink_nas_transport,0,0}, /*UplinkNASTransport*/
{0,0,0}, /*UplinkNonUEAssociatedNRPPaTransport*/
{0,0,0}, /*UplinkRANConfigurationTransfer*/
{0,0,0}, /*UplinkRANStatusTransfer*/
{0,0,0}, /*UplinkUEAssociatedNRPPaTransport*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0}, /*WriteReplaceWarning*/
{0,0,0} /*WriteReplaceWarning*/
//------------------------------------------------------------------------------
ngap_message_decoded_callback messages_callback[][3] = { { 0, 0, 0 }, /*0 AMFConfigurationUpdate*/
{ 0, 0, 0 }, /*1 AMFStatusIndication*/
{ 0, 0, 0 }, /*2 CellTrafficTrace*/
{ 0, 0, 0 }, /*3 DeactivateTrace*/
{ 0, 0, 0 }, /*4 DownlinkNASTransport*/
{ 0, 0, 0 }, /*5 DownlinkNonUEAssociatedNRPPaTransport*/
{ 0, 0, 0 }, /*6 DownlinkRANConfigurationTransfer*/
{ 0, 0, 0 }, /*7 DownlinkRANStatusTransfer*/
{ 0, 0, 0 }, /*8 DownlinkUEAssociatedNRPPaTransport*/
{ 0, 0, 0 }, //9 {ngap_amf_handle_error_indication,0,0}, /*ErrorIndication*/
{ 0, 0, 0 }, /*10 HandoverCancel*/
{ 0, 0, 0 }, /*11 HandoverNotification*/
{ 0, 0, 0 }, /*12 HandoverPreparation*/
{ 0, 0, 0 }, /*13 HandoverResourceAllocation*/
{ 0, ngap_amf_handle_initial_context_setup_response, ngap_amf_handle_initial_context_setup_failure }, /*InitialContextSetup*/
{ ngap_amf_handle_initial_ue_message, 0, 0 }, //15 {ngap_amf_handle_initial_ue_message,0,0}, /*InitialUEMessage*/
{ 0, 0, 0 }, /*16 LocationReportingControl*/
{ 0, 0, 0 }, /*17 LocationReportingFailureIndication*/
{ 0, 0, 0 }, /*18 LocationReport*/
{ 0, 0, 0 }, /*19 NASNonDeliveryIndication*/
{ 0, 0, 0 }, /*20 NGReset*/
{ ngap_amf_handle_ng_setup_request, 0, 0 }, /*21 NGSetup*/
{ 0, 0, 0 }, /*OverloadStart*/
{ 0, 0, 0 }, /*OverloadStop*/
{ 0, 0, 0 }, /*Paging*/
{ 0, 0, 0 }, //{ngap_amf_handle_path_switch_request,0,0}, /*PathSwitchRequest*
{ 0, 0, 0 }, /*PDUSessionResourceModify*/
{ 0, 0, 0 }, /*PDUSessionResourceModifyIndication*/
{ 0, 0, 0 }, /*PDUSessionResourceRelease*/
{ 0, ngap_amf_handle_pdu_session_resource_setup_response, 0 }, /*PDUSessionResourceSetup*/
{ 0, 0, 0 }, /*PDUSessionResourceNotify*/
{ 0, 0, 0 }, /*PrivateMessage*/
{ 0, 0, 0 }, /*PWSCancel*/
{ 0, 0, 0 }, /*PWSFailureIndication*/
{ 0, 0, 0 }, /*PWSRestartIndication*/
{ 0, 0, 0 }, /*RANConfigurationUpdate*/
{ 0, 0, 0 }, /*RerouteNASRequest*/
{ 0, 0, 0 }, /*RRCInactiveTransitionReport*/
{ 0, 0, 0 }, /*TraceFailureIndication*/
{ 0, 0, 0 }, /*TraceStart*/
{ 0, 0, 0 }, /*UEContextModification*/
{ 0, ngap_amf_handle_ue_context_release_complete, 0 }, /*UEContextRelease*/
{ ngap_amf_handle_ue_context_release_request, 0, 0 }, /*UEContextReleaseRequest*/
{ 0, 0, 0 }, /*UERadioCapabilityCheck*/
{ ngap_amf_handle_ue_radio_cap_indication, 0, 0 }, /*UERadioCapabilityInfoIndication*/
{ 0, 0, 0 }, /*UETNLABindingRelease*/
{ ngap_amf_handle_uplink_nas_transport, 0, 0 }, //{ngap_amf_handle_uplink_nas_transport,0,0}, /*UplinkNASTransport*/
{ 0, 0, 0 }, /*UplinkNonUEAssociatedNRPPaTransport*/
{ 0, 0, 0 }, /*UplinkRANConfigurationTransfer*/
{ 0, 0, 0 }, /*UplinkRANStatusTransfer*/
{ 0, 0, 0 }, /*UplinkUEAssociatedNRPPaTransport*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 }, /*WriteReplaceWarning*/
{ 0, 0, 0 } /*WriteReplaceWarning*/
};
......@@ -52,7 +52,7 @@ if (!Options::parse(argc, argv)) {
return 1;
}
Logger::init( "amf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::init( "AMF" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::amf_app().startup("Options parsed!");
amf_cfg.load(Options::getlibconfigConfig());
......@@ -67,7 +67,7 @@ if (!Options::parse(argc, argv)) {
amf_app_inst = new amf_app(amf_cfg);
amf_app_inst->allRegistredModulesInit(modules);
Logger::amf_app().debug("initiating amf server endpoints");
Logger::amf_app().debug("Initiating AMF server endpoints");
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&amf_cfg.n2.addr4))) , Pistache::Port(8282));
AMFApiServer amfApiServer(addr, amf_app_inst);
amfApiServer.init(2);
......
......@@ -29,7 +29,7 @@ bool Options::m_log_stdout;
//------------------------------------------------------------------------------
void Options::help() {
std::cout << std::endl << "Usage: smf [OPTIONS]..." << std::endl << " -h, --help Print help and exit" << std::endl << " -c, --libconfigcfg filename Read the application configuration from this file." << std::endl
std::cout << std::endl << "Usage: AMF [OPTIONS]..." << std::endl << " -h, --help Print help and exit" << std::endl << " -c, --libconfigcfg filename Read the application configuration from this file." << std::endl
<< " -o, --stdoutlog Send the application logs to STDOUT fd." << std::endl << " -r, --rotatelog Send the application logs to local file (in current working directory)." << std::endl;
}
......
......@@ -189,7 +189,7 @@ 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 unsollicited 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));
......@@ -213,7 +213,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;
......@@ -248,7 +248,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);
......@@ -383,7 +383,7 @@ int sctp_server::sctp_send_msg(sctp_assoc_id_t sctp_assoc_id, sctp_stream_id_t s
}
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);
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("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);
*payload = NULL;
return -1;
}
......
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