Commit 07852f13 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue with APN Operator Identifier

parent 3bae76aa
...@@ -133,6 +133,7 @@ bool conv::plmnFromString( ...@@ -133,6 +133,7 @@ bool conv::plmnFromString(
p.mcc_digit3 = mcc[2] - '0'; p.mcc_digit3 = mcc[2] - '0';
else else
return false; return false;
// MNC // MNC
if (isdigit(mnc[0])) if (isdigit(mnc[0]))
p.mnc_digit1 = mnc[0] - '0'; p.mnc_digit1 = mnc[0] - '0';
...@@ -147,6 +148,8 @@ bool conv::plmnFromString( ...@@ -147,6 +148,8 @@ bool conv::plmnFromString(
p.mnc_digit3 = mnc[2] - '0'; p.mnc_digit3 = mnc[2] - '0';
else else
return false; return false;
} else {
p.mnc_digit3 = 0x0;
} }
return true; return true;
} }
......
...@@ -51,13 +51,17 @@ std::string Utility::home_network_gprs(const char* mnc, const char* mcc) { ...@@ -51,13 +51,17 @@ std::string Utility::home_network_gprs(const char* mnc, const char* mcc) {
} }
std::string Utility::home_network_gprs(const plmn_t& plmn) { std::string Utility::home_network_gprs(const plmn_t& plmn) {
// '.mnc(\d{3})\.mcc(\d{3})\.gprs'
std::string s; std::string s;
uint16_t mcc = 0; uint16_t mcc = 0;
uint16_t mnc = 0; uint16_t mnc = 0;
uint16_t mnc_len = 0; uint16_t mnc_len = 0;
PLMN_T_TO_MCC_MNC(plmn, mcc, mnc, mnc_len); mcc = plmn.mcc_digit1 * 100 + plmn.mcc_digit2 * 10 + plmn.mcc_digit3;
mnc_len = (plmn.mnc_digit3 == 0x0 ? 2 : 3);
mnc = plmn.mnc_digit1 * 10 + plmn.mnc_digit2;
mnc = (mnc_len == 2 ? mnc : mnc * 10 + plmn.mnc_digit3);
s.append(".mnc"); s.append(".mnc");
if (mnc_len == 2) s.append("0"); if (mnc_len == 2) s.append("0");
......
...@@ -174,12 +174,18 @@ bool util::string_to_dotted(const std::string& str, std::string& dotted) { ...@@ -174,12 +174,18 @@ bool util::string_to_dotted(const std::string& str, std::string& dotted) {
}; };
void util::string_to_dnn(const std::string& str, bstring bstr) { void util::string_to_dnn(const std::string& str, bstring bstr) {
uint8_t tmp[str.length() + 1];
std::string tmp = std::to_string(str.length()) + str; tmp[0] = str.length();
bstr->slen = tmp.length(); memcpy((void*) &tmp[1], (void*) str.c_str(), str.length());
memcpy((void*) bstr->data, (void*) tmp.c_str(), tmp.length()); bstr->slen = str.length() + 1;
memcpy((void*) bstr->data, (void*) tmp, str.length() + 1);
/* /*
printf("\n");
for (int i = 0; i < str.length() + 1; i++) {
printf(" %02x", tmp[i]);
}
uint8_t tmp[str.length() + 1]; uint8_t tmp[str.length() + 1];
tmp[0] = str.length(); tmp[0] = str.length();
memcpy((void*) &tmp[1], (void*) str.c_str(), tmp.length()); memcpy((void*) &tmp[1], (void*) str.c_str(), tmp.length());
......
...@@ -256,16 +256,15 @@ bool smf_n1::create_n1_pdu_session_establishment_accept( ...@@ -256,16 +256,15 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
plmn_t plmn = {}; plmn_t plmn = {};
sc.get()->get_plmn(plmn); sc.get()->get_plmn(plmn);
std::string gprs = EPC::Utility::home_network_gprs(plmn); std::string gprs = EPC::Utility::home_network_gprs(plmn);
std::string dotted;
util::string_to_dotted(gprs, dotted);
std::string full_dnn = std::string full_dnn =
sm_context_res.get_dnn() + dotted; //".mnc011.mcc110.gprs"; sm_context_res.get_dnn() + gprs; //".mnc011.mcc110.gprs";
Logger::smf_n1().debug("Full DNN %s", full_dnn.c_str()); std::string dotted;
util::string_to_dotted(full_dnn, dotted);
Logger::smf_n1().debug(
"Full DNN %s, dotted DNN %s", full_dnn.c_str(), dotted.c_str());
sm_msg->pdu_session_establishment_accept.dnn = sm_msg->pdu_session_establishment_accept.dnn =
bfromcstralloc(full_dnn.length() + 1, "\0"); bfromcstralloc(dotted.length() + 1, "\0");
util::string_to_dnn(full_dnn, sm_msg->pdu_session_establishment_accept.dnn); util::string_to_dnn(dotted, sm_msg->pdu_session_establishment_accept.dnn);
/* /*
sm_msg->pdu_session_establishment_accept.dnn = bfromcstralloc( sm_msg->pdu_session_establishment_accept.dnn = bfromcstralloc(
......
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