Commit 058c666e authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Apply Google style format

parent 7b5b106a
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -44,24 +44,34 @@ class amf_n11 {
~amf_n11();
void handle_itti_message(itti_smf_services_consumer&);
void handle_pdu_session_initial_request(std::string supi, std::shared_ptr<pdu_session_context> psc, std::string smf_addr, bstring sm_msg, std::string dnn);
void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg);
void send_pdu_session_update_sm_context_request(std::string supi, std::shared_ptr<pdu_session_context> psc, std::string smf_addr, bstring sm_msg, std::string dnn);
void send_pdu_session_update_sm_context_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
std::map<std::string, std::shared_ptr<pdu_session_context>> supi2pdu; // amf ue ngap id
mutable std::shared_mutex m_supi2pdu;
bool is_supi_to_pdu_ctx(const std::string &supi) const;
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(const std::string &supi) const;
void set_supi_to_pdu_ctx(const std::string &supi, std::shared_ptr<pdu_session_context> psc);
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(
const std::string &supi) const;
void set_supi_to_pdu_ctx(const std::string &supi,
std::shared_ptr<pdu_session_context> psc);
std::map<uint8_t, std::string> pduid2supi;
bool smf_selection_from_configuration(std::string &smf_addr);
bool smf_selection_from_context(std::string &smf_addr);
void handle_post_sm_context_response_error_400();
void handle_post_sm_context_response_error(long code, std::string cause, bstring n1sm, std::string supi, uint8_t pdu_session_id);
void handle_post_sm_context_response_error(long code, std::string cause,
bstring n1sm, std::string supi,
uint8_t pdu_session_id);
void curl_http_client(std::string remoteUri, std::string jsonData, std::string n1SmMsg, std::string n2SmMsg, std::string supi, uint8_t pdu_session_id);
void curl_http_client(std::string remoteUri, std::string jsonData,
std::string n1SmMsg, std::string n2SmMsg,
std::string supi, uint8_t pdu_session_id);
};
}
......
......@@ -40,30 +40,47 @@ void statistics::display() {
//Logger::amf_app().info("--------------------------------------------------");
//Logger::amf_app().info("| %d | %d | %d |",gNB_connected,UE_connected,UE_registred);
//Logger::amf_app().info("--------------------------------------------------");
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("|----------------------------------------------------gNBs' information-------------------------------------------|");
Logger::amf_app().info("| Index | Status | Global ID | gNB Name | Tracking Area (PLMN, TAC) |");
if (gnbs.size() ==0 ) {
Logger::amf_app().info("| - | - | - | - | - |");
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info(
"|----------------------------------------------------gNBs' information-------------------------------------------|");
Logger::amf_app().info(
"| Index | Status | Global ID | gNB Name | Tracking Area (PLMN, TAC) |");
if (gnbs.size() == 0) {
Logger::amf_app().info(
"| - | - | - | - | - |");
}
//TODO: Show the list of common PLMNs
for (int i = 0; i < gnbs.size(); i++) {
Logger::amf_app().info("| %d | Connected | 0x%x | %s | %s, %d | ", i + 1, gnbs[i].gnb_id, gnbs[i].gnb_name.c_str(), (gnbs[i].mcc + gnbs[i].mnc).c_str(), gnbs[i].tac);
Logger::amf_app().info(
"| %d | Connected | 0x%x | %s | %s, %d | ",
i + 1, gnbs[i].gnb_id, gnbs[i].gnb_name.c_str(),
(gnbs[i].mcc + gnbs[i].mnc).c_str(), gnbs[i].tac);
}
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("");
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("|----------------------------------------------------UEs' information--------------------------------------------|");
Logger::amf_app().info("| Index | 5GMM state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID | PLMN |Cell ID|");
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info(
"|----------------------------------------------------UEs' information--------------------------------------------|");
Logger::amf_app().info(
"| Index | 5GMM state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID | PLMN |Cell ID|");
int i = 0;
for (auto const &ue : ue_infos) {
Logger::amf_app().info("|%7d|%22s|%18s|%15s|%16d|%11d|%9s|%7d|", i + 1, ue.second.registerStatus.c_str(), ue.second.imsi.c_str(), ue.second.guti.c_str(), ue.second.ranid, ue.second.amfid, (ue.second.mcc + ue.second.mnc).c_str(), ue.second.cellId);
Logger::amf_app().info("|%7d|%22s|%18s|%15s|%16d|%11d|%9s|%7d|", i + 1,
ue.second.registerStatus.c_str(),
ue.second.imsi.c_str(), ue.second.guti.c_str(),
ue.second.ranid, ue.second.amfid,
(ue.second.mcc + ue.second.mnc).c_str(),
ue.second.cellId);
i++;
}
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("");
}
......@@ -75,7 +92,7 @@ statistics::statistics() {
}
//------------------------------------------------------------------------------
void statistics::update_ue_info(const ue_info_t& ue_info) {
void statistics::update_ue_info(const ue_info_t &ue_info) {
if (!(ue_info.imsi.size() > 0)) {
Logger::amf_app().warn("Update UE Info with invalid IMSI");
}
......@@ -83,23 +100,28 @@ void statistics::update_ue_info(const ue_info_t& ue_info) {
if (ue_infos.count(ue_info.imsi) > 0) {
ue_infos.erase(ue_info.imsi);
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
Logger::amf_app().debug("Update UE Info (IMSI %s) success", ue_info.imsi.c_str());
Logger::amf_app().debug("Update UE Info (IMSI %s) success",
ue_info.imsi.c_str());
} else {
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
Logger::amf_app().debug("Add UE Info (IMSI %s) success", ue_info.imsi.c_str());
Logger::amf_app().debug("Add UE Info (IMSI %s) success",
ue_info.imsi.c_str());
}
}
//------------------------------------------------------------------------------
void statistics::update_5gmm_state(const std::string& imsi, const std::string& state) {
void statistics::update_5gmm_state(const std::string &imsi,
const std::string &state) {
if (ue_infos.count(imsi) > 0) {
ue_info_t ue_info = ue_infos.at(imsi);
ue_info.registerStatus = state;
ue_infos.erase(ue_info.imsi);
ue_infos.insert(std::pair<std::string, ue_info_t>(imsi, ue_info));
Logger::amf_app().debug("Update UE State (IMSI %s, State %s) success", imsi.c_str(), state.c_str());
Logger::amf_app().debug("Update UE State (IMSI %s, State %s) success",
imsi.c_str(), state.c_str());
} else {
Logger::amf_app().warn("Update UE State (IMSI %s), UE does not exist!", imsi.c_str());
Logger::amf_app().warn("Update UE State (IMSI %s), UE does not exist!",
imsi.c_str());
}
}
......
......@@ -61,14 +61,13 @@ typedef struct ue_info_s {
uint32_t cellId;
} ue_info_t;
class statistics {
public:
void display();
statistics();
~statistics();
void update_ue_info(const ue_info_t& ue_info);
void update_5gmm_state(const std::string& imsi, const std::string& state);
void update_ue_info(const ue_info_t &ue_info);
void update_5gmm_state(const std::string &imsi, const std::string &state);
public:
uint32_t gNB_connected;
uint32_t UE_connected;
......
......@@ -42,7 +42,8 @@ _5GSDeregistrationType::_5GSDeregistrationType(uint8_t type) {
u1.b = type;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType(_5gs_deregistration_type_t type) {
_5GSDeregistrationType::_5GSDeregistrationType(
_5gs_deregistration_type_t type) {
u1.b = 0;
u1.bf.switch_off = type.switch_off;
u1.bf.dereg_required = type.dereg_required;
......@@ -64,7 +65,7 @@ void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) {
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::get(_5gs_deregistration_type_t& type) {
void _5GSDeregistrationType::get(_5gs_deregistration_type_t &type) {
type.switch_off = u1.bf.switch_off;
type.dereg_required = u1.bf.dereg_required;
type.access_type = u1.bf.access_type;
......@@ -77,7 +78,7 @@ void _5GSDeregistrationType::set(uint8_t type) {
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::get(uint8_t& type) {
void _5GSDeregistrationType::get(uint8_t &type) {
type = u1.b;
}
......@@ -85,7 +86,8 @@ void _5GSDeregistrationType::get(uint8_t& type) {
int _5GSDeregistrationType::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().error("Encoding 5GSDeregistrationType IE");
if (len < 1) {
Logger::nas_mm().error("encoding 5GSDeregistrationType error(len is less than one)");
Logger::nas_mm().error(
"encoding 5GSDeregistrationType error(len is less than one)");
return -1;
}
*buf = u1.b;
......
......@@ -34,7 +34,7 @@
namespace nas {
typedef struct _5gs_deregistration_type_s {
uint8_t iei :4;
uint8_t switch_off:1;
uint8_t switch_off :1;
uint8_t dereg_required :1;
uint8_t access_type :2;
} _5gs_deregistration_type_t;
......@@ -49,22 +49,21 @@ class _5GSDeregistrationType {
int encode2buffer(uint8_t *buf, int len);
void set(_5gs_deregistration_type_t type);
void get(_5gs_deregistration_type_t& type);
void get(_5gs_deregistration_type_t &type);
void set(uint8_t type);
void get(uint8_t& type);
void get(uint8_t &type);
public:
union {
struct {
uint8_t iei :4;
uint8_t switch_off:1;
uint8_t switch_off :1;
uint8_t dereg_required :1;
uint8_t access_type :2;
} bf;
uint8_t b;
} u1;
};
}
......
......@@ -48,7 +48,8 @@ DeregistrationRequest::~DeregistrationRequest() {
//------------------------------------------------------------------------------
void DeregistrationRequest::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, DEREGISTRATION_REQUEST_UE_ORIGINATING);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
DEREGISTRATION_REQUEST_UE_ORIGINATING);
}
//------------------------------------------------------------------------------
......@@ -57,7 +58,8 @@ void DeregistrationRequest::setDeregistrationType(uint8_t dereg_type) {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setDeregistrationType(_5gs_deregistration_type_t type) {
void DeregistrationRequest::setDeregistrationType(
_5gs_deregistration_type_t type) {
ie_deregistrationtype = new _5GSDeregistrationType(type);
}
......@@ -68,35 +70,43 @@ void DeregistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
//------------------------------------------------------------------------------
void DeregistrationRequest::getDeregistrationType(uint8_t &dereg_type) {
ie_deregistrationtype->get(dereg_type );
ie_deregistrationtype->get(dereg_type);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getDeregistrationType(_5gs_deregistration_type_t& type) {
void DeregistrationRequest::getDeregistrationType(
_5gs_deregistration_type_t &type) {
ie_deregistrationtype->get(type);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getngKSI(uint8_t& ng_ksi) {
void DeregistrationRequest::getngKSI(uint8_t &ng_ksi) {
if (ie_ngKSI) {
ng_ksi = (ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
ng_ksi = (ie_ngKSI->getTypeOfSecurityContext())
| ie_ngKSI->getasKeyIdentifier();
} else {
ng_ksi = 0;
}
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin) {
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(const string mcc,
const string mnc,
const string routingInd,
uint8_t protection_sch_id,
const string msin) {
if (protection_sch_id != NULL_SCHEME) {
Logger::nas_mm().error("encoding suci and supi format for imsi error, please choose right interface");
Logger::nas_mm().error(
"encoding suci and supi format for imsi error, please choose right interface");
return;
} else {
ie_5gs_mobility_id = new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
ie_5gs_mobility_id = new _5GSMobilityIdentity(mcc, mnc, routingInd,
protection_sch_id, msin);
}
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getMobilityIdentityType(uint8_t& type) {
void DeregistrationRequest::getMobilityIdentityType(uint8_t &type) {
if (ie_5gs_mobility_id) {
type = ie_5gs_mobility_id->gettypeOfIdentity();
} else {
......@@ -119,7 +129,7 @@ std::string DeregistrationRequest::get_5g_guti() {
if (ie_5gs_mobility_id) {
nas::_5G_GUTI_t guti;
ie_5gs_mobility_id->get5GGUTI(guti);
std::string str ;//= guti.toString();
std::string str; //= guti.toString();
return str;
} else {
return "error";
......@@ -127,7 +137,12 @@ std::string DeregistrationRequest::get_5g_guti() {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin) {
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(const string mcc,
const string mnc,
const string routingInd,
uint8_t protection_sch_id,
uint8_t hnpki,
const string msin) {
}
//------------------------------------------------------------------------------
......@@ -165,7 +180,8 @@ int DeregistrationRequest::encode2buffer(uint8_t *buf, int len) {
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!(ie_deregistrationtype->encode2buffer(buf + encoded_size, len - encoded_size))) {
if (!(ie_deregistrationtype->encode2buffer(buf + encoded_size,
len - encoded_size))) {
if (!(ie_ngKSI->encode2buffer(buf + encoded_size, len - encoded_size))) {
encoded_size += 1;
} else {
......@@ -176,30 +192,37 @@ int DeregistrationRequest::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().error("Encoding IE Deregistrationt Type error");
return 0;
}
if (int size = ie_5gs_mobility_id->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_5gs_mobility_id->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding IE ie_5gs_mobility_id error");
return 0;
}
Logger::nas_mm().debug("Encoded DeregistrationRequest message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded DeregistrationRequest message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int DeregistrationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int DeregistrationRequest::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("****Decoding DeregistrationRequest message****");
int decoded_size = 3;
plain_header = header;
ie_deregistrationtype = new _5GSDeregistrationType();
decoded_size += ie_deregistrationtype->decodefrombuffer(buf + decoded_size, len - decoded_size);
decoded_size += ie_deregistrationtype->decodefrombuffer(buf + decoded_size,
len - decoded_size);
ie_ngKSI = new NasKeySetIdentifier();
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size, len - decoded_size, false, true);
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size,
len - decoded_size, false, true);
decoded_size++;
ie_5gs_mobility_id = new _5GSMobilityIdentity();
decoded_size += ie_5gs_mobility_id->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("****Decoded DeregistrationRequest message (len %d)****", decoded_size);
decoded_size += ie_5gs_mobility_id->decodefrombuffer(buf + decoded_size,
len - decoded_size,
false);
Logger::nas_mm().debug(
"****Decoded DeregistrationRequest message (len %d)****", decoded_size);
}
......@@ -46,16 +46,21 @@ class DeregistrationRequest {
void setngKSI(uint8_t tsc, uint8_t key_set_id);
void setMobilityIdentityType(uint8_t type);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki,
const string msin);
void set5G_GUTI();
void setIMEI_IMEISV();
void set5G_S_TMSI();
void getDeregistrationType(uint8_t &dereg_type);
void getDeregistrationType(_5gs_deregistration_type_t& type);
void getngKSI(uint8_t& ng_ksi);
void getMobilityIdentityType(uint8_t& type);
void getDeregistrationType(_5gs_deregistration_type_t &type);
void getngKSI(uint8_t &ng_ksi);
void getMobilityIdentityType(uint8_t &type);
std::string get_5g_guti();
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t &imsi);
......
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