Commit 3bae76aa authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue with DNN with a dotted str

parent c1f65bf8
...@@ -145,8 +145,55 @@ void util::string_to_bstring(const std::string& str, bstring bstr) { ...@@ -145,8 +145,55 @@ void util::string_to_bstring(const std::string& str, bstring bstr) {
memcpy((void*) bstr->data, (void*) str.c_str(), str.length()); memcpy((void*) bstr->data, (void*) str.c_str(), str.length());
} }
bool util::string_to_dotted(const std::string& str, std::string& dotted) {
uint8_t offset = 0;
uint8_t* last_size;
uint8_t word_length = 0;
uint8_t value[str.length() + 1];
dotted = {};
last_size = &value[0];
while (str[offset]) {
// We replace the . by the length of the word
if (str[offset] == '.') {
*last_size = word_length;
word_length = 0;
last_size = &value[offset + 1];
} else {
word_length++;
value[offset + 1] = str[offset];
}
offset++;
}
*last_size = word_length;
dotted.assign((const char*) value, str.length() + 1);
return true;
};
void util::string_to_dnn(const std::string& str, bstring bstr) { void util::string_to_dnn(const std::string& str, bstring bstr) {
std::string tmp = std::to_string(str.length()) + str; std::string tmp = std::to_string(str.length()) + str;
bstr->slen = tmp.length(); bstr->slen = tmp.length();
memcpy((void*) bstr->data, (void*) tmp.c_str(), tmp.length()); memcpy((void*) bstr->data, (void*) tmp.c_str(), tmp.length());
/*
uint8_t tmp[str.length() + 1];
tmp[0] = str.length();
memcpy((void*) &tmp[1], (void*) str.c_str(), tmp.length());
bstr->slen = tmp.length() + 1;
memcpy((void*) bstr->data, (void*) tmp, tmp.length()+1);
*/
/*
// 19 05 63 74 6e 65
uint8_t strB[6] = {0};
strB[0] = str.length();
memcpy(strB + 1, str.c_str(), str.length());
bstr->slen = str.length() + 20;
uint8_t dnn[19] = {0x06, 0x6d, 0x6e, 0x63, 0x30, 0x31, 0x31, 0x06, 0x6d, 0x63,
0x63, 0x34, 0x36, 0x30, 0x04, 0x67, 0x70, 0x72, 0x73};
memcpy((void*) (bstr->data), (void*) strB, str.length() + 1);
memcpy((void*) (bstr->data + str.length() + 1), (void*) dnn, 19);*/
} }
...@@ -61,6 +61,7 @@ void ipv4v6_to_pdu_address_information( ...@@ -61,6 +61,7 @@ void ipv4v6_to_pdu_address_information(
struct in_addr ipv4_address, struct in6_addr ipv6_address, bstring str); struct in_addr ipv4_address, struct in6_addr ipv6_address, bstring str);
void string_to_bstring(const std::string& str, bstring bstr); void string_to_bstring(const std::string& str, bstring bstr);
bool string_to_dotted(const std::string& str, std::string& dotted);
void string_to_dnn(const std::string& str, bstring bstr); void string_to_dnn(const std::string& str, bstring bstr);
} // namespace util } // namespace util
#endif #endif
...@@ -256,13 +256,25 @@ bool smf_n1::create_n1_pdu_session_establishment_accept( ...@@ -256,13 +256,25 @@ 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() + sm_context_res.get_dnn() + dotted; //".mnc011.mcc110.gprs";
gprs; //".mnc011.mcc110.gprs"; Logger::smf_n1().debug("Full DNN %s", full_dnn.c_str());
sm_msg->pdu_session_establishment_accept.dnn = sm_msg->pdu_session_establishment_accept.dnn =
bfromcstralloc(full_dnn.length() + 1, "\0"); bfromcstralloc(full_dnn.length() + 1, "\0");
util::string_to_dnn(full_dnn, sm_msg->pdu_session_establishment_accept.dnn); util::string_to_dnn(full_dnn, sm_msg->pdu_session_establishment_accept.dnn);
Logger::smf_n1().debug("Full DNN %s", full_dnn.c_str());
/*
sm_msg->pdu_session_establishment_accept.dnn = bfromcstralloc(
sm_context_res.get_dnn().length() + 1 + 2 + sizeof(".mnc011.mcc110.gprs"),
"\0");
util::string_to_dnn(
sm_context_res.get_dnn(), sm_msg->pdu_session_establishment_accept.dnn);
Logger::smf_n1().debug("DNN %s", sm_context_res.get_dnn().c_str());
*/
Logger::smf_n1().info("Encode PDU Session Establishment Accept"); Logger::smf_n1().info("Encode PDU Session Establishment Accept");
// Encode NAS message // Encode NAS message
......
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