From 4820ee7687e9661311f868cb85501b280b6247c1 Mon Sep 17 00:00:00 2001 From: jmasterfunk84 <48972964+jmasterfunk84@users.noreply.github.com> Date: Wed, 22 May 2024 09:26:08 -0600 Subject: [PATCH] Encode DNN as Labels --- src/lib/nas/utils.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/nas/utils.cpp b/src/lib/nas/utils.cpp index 69c931a68..e677b6fa1 100644 --- a/src/lib/nas/utils.cpp +++ b/src/lib/nas/utils.cpp @@ -273,9 +273,24 @@ const char *EnumToString(EPduSessionType v) IEDnn DnnFromApn(const std::string &apn) { IEDnn dnn; + int index = 0; dnn.apn = OctetString::FromSpare(static_cast(apn.length()) + 1); - dnn.apn.data()[0] = static_cast(apn.length()); - std::memcpy(dnn.apn.data() + 1, apn.data(), apn.length()); + std::stringstream ss(apn); + + std::string token; + std::vector tokens; + char delimiter = '.'; + + while (getline(ss, token, delimiter)) { + tokens.push_back(token); + } + + for (const auto& part : tokens) { + std::cout << part; + dnn.apn.data()[index] = static_cast(part.length()); + std::memcpy(dnn.apn.data() + index + 1, part.c_str(), part.length()); + index = index + part.length() + 1; + } return dnn; }