Commit 6fbbee52 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add plmn to customize data

parent c945ecaa
......@@ -102,6 +102,7 @@ std::string conv::mccToString(
s.append(std::to_string(mcc16));
return s;
}
//------------------------------------------------------------------------------
std::string conv::mncToString(
const uint8_t digit1, const uint8_t digit2, const uint8_t digit3) {
......@@ -117,6 +118,7 @@ std::string conv::mncToString(
return s;
}
//------------------------------------------------------------------------------
bool conv::plmnFromString(
plmn_t& p, const std::string mcc, const std::string mnc) {
// MCC
......@@ -154,6 +156,23 @@ bool conv::plmnFromString(
return true;
}
//------------------------------------------------------------------------------
void conv::plmnToMccMnc(
const plmn_t& plmn, std::string& mcc, std::string& mnc) {
uint16_t mcc_dec = 0;
uint16_t mnc_dec = 0;
uint16_t mnc_len = 0;
mcc_dec = plmn.mcc_digit1 * 100 + plmn.mcc_digit2 * 10 + plmn.mcc_digit3;
mnc_len = (plmn.mnc_digit3 == 0x0 ? 2 : 3);
mnc_dec = plmn.mnc_digit1 * 10 + plmn.mnc_digit2;
mnc_dec = (mnc_len == 2 ? mnc_dec : mnc_dec * 10 + plmn.mnc_digit3);
mcc = std::to_string(mcc_dec);
mnc = std::to_string(mnc_dec);
return;
}
//------------------------------------------------------------------------------
struct in_addr conv::fromString(const std::string addr4) {
unsigned char buf[sizeof(struct in6_addr)] = {};
......
......@@ -55,7 +55,10 @@ class conv {
static void hexa_to_ascii(uint8_t* from, char* to, size_t length);
static int ascii_to_hex(uint8_t* dst, const char* h);
static struct in_addr fromString(const std::string addr4);
static bool plmnFromString(plmn_t& p, const std::string mcc, const std::string mnc);
static bool plmnFromString(
plmn_t& p, const std::string mcc, const std::string mnc);
static void plmnToMccMnc(
const plmn_t& plmn, std::string& mcc, std::string& mnc);
static std::string toString(const struct in_addr& inaddr);
static std::string toString(const struct in6_addr& in6addr);
static std::string mccToString(
......
......@@ -3289,6 +3289,13 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) {
ev_notif.set_notif_id(i.get()->notif_id);
// custom json e.g., for FlexCN
nlohmann::json cj = {};
// PLMN
plmn_t plmn = {};
std::string mcc, mnc;
sc->get_plmn(plmn);
conv::plmnToMccMnc(plmn, mcc, mnc);
cj["plmn"]["mcc"] = mcc;
cj["plmn"]["mnc"] = mnc;
// UE IPv4
if (sp->ipv4) {
cj["ue_ipv4_addr"] = conv::toString(sp->ipv4_address);
......
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