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

Fix issue for dnn with dot

parent 7c5fbe3a
...@@ -173,6 +173,30 @@ bool util::string_to_dotted(const std::string& str, std::string& dotted) { ...@@ -173,6 +173,30 @@ bool util::string_to_dotted(const std::string& str, std::string& dotted) {
return true; return true;
}; };
bool util::dotted_to_string(const std::string& dot, std::string& no_dot) {
// uint8_t should be enough, but uint16 if length > 255.
uint16_t offset = 0;
bool result = true;
no_dot = {};
while (offset < dot.length()) {
if (dot[offset] < 64) {
if ((offset + dot[offset]) <= dot.length()) {
if (offset) {
no_dot.push_back('.');
}
no_dot.append(&dot[offset + 1], dot[offset]);
}
offset = offset + 1 + dot[offset];
} else {
// should not happen, consume bytes
no_dot.push_back(dot[offset++]);
result = false;
}
}
return result;
};
void util::string_to_dnn(const std::string& str, bstring bstr) { void util::string_to_dnn(const std::string& str, bstring bstr) {
bstr->slen = str.length(); bstr->slen = str.length();
memcpy((void*) bstr->data, (void*) str.c_str(), str.length()); memcpy((void*) bstr->data, (void*) str.c_str(), str.length());
......
...@@ -62,6 +62,7 @@ void ipv4v6_to_pdu_address_information( ...@@ -62,6 +62,7 @@ void ipv4v6_to_pdu_address_information(
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); bool string_to_dotted(const std::string& str, std::string& dotted);
bool dotted_to_string(const std::string& dot, std::string& no_dot);
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
...@@ -868,6 +868,9 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -868,6 +868,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// authorization by the external DN // authorization by the external DN
// Step 3. check if the DNN requested is valid // Step 3. check if the DNN requested is valid
std::string nd_dnn;
util::dotted_to_string(dnn, nd_dnn);
dnn = nd_dnn;
if (not smf_cfg.is_dotted_dnn_handled(dnn, pdu_session_type)) { if (not smf_cfg.is_dotted_dnn_handled(dnn, pdu_session_type)) {
// Not a valid request... // Not a valid request...
Logger::smf_app().warn( Logger::smf_app().warn(
......
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