Commit 27f5c8a3 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Update 3GPP conversion file with PLMN/Guami

parent 263d78eb
...@@ -85,7 +85,8 @@ SMF = ...@@ -85,7 +85,8 @@ SMF =
# STRING, {"yes", "no"}, # STRING, {"yes", "no"},
REGISTER_NRF = "no"; # Set to yes if SMF resgisters to an NRF REGISTER_NRF = "no"; # Set to yes if SMF resgisters to an NRF
DISCOVER_UPF = "no"; # Set to yes to enable UPF discovery and selection DISCOVER_UPF = "no"; # Set to yes to enable UPF discovery and selection
FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; # Non standard feature, normally should be set to "no",
# but you may need to set to yes for UE that do not explicitly request a PDN address through NAS signalling
USE_LOCAL_SUBSCRIPTION_INFO = "yes"; # Set to yes if SMF uses local subscription information instead of from an UDM USE_LOCAL_SUBSCRIPTION_INFO = "yes"; # Set to yes if SMF uses local subscription information instead of from an UDM
} }
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include <stdint.h> #include <stdint.h>
typedef enum extended_protocol_discriminator_e { typedef enum extended_protocol_discriminator_e {
// Protocol discriminator identifier for 5G Session Management // 5G Session Management
EPD_5GS_SESSION_MANAGEMENT_MESSAGES = 0x2e, EPD_5GS_SESSION_MANAGEMENT_MESSAGES = 0x2e,
// Protocol discriminator identifier for 5G Mobility Management // 5G Mobility Management
EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES = 0x7e, EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES = 0x7e,
} extended_protocol_discriminator_t; } extended_protocol_discriminator_t;
......
...@@ -262,7 +262,6 @@ typedef struct ip_endpoint_s { ...@@ -262,7 +262,6 @@ typedef struct ip_endpoint_s {
s.append(std::to_string(port)); s.append(std::to_string(port));
return s; return s;
} }
} ip_endpoint_t; } ip_endpoint_t;
typedef struct nf_service_s { typedef struct nf_service_s {
...@@ -324,4 +323,11 @@ typedef struct patch_item_s { ...@@ -324,4 +323,11 @@ typedef struct patch_item_s {
} }
} patch_item_t; } patch_item_t;
//TODO: move to 23.003
typedef struct guami_5g_s {
plmn_t plmn;
std::string amf_id;
} guami_5g_t;
#endif #endif
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "SmContextReleaseData.h" #include "SmContextReleaseData.h"
#include "3gpp_29.500.h" #include "3gpp_29.500.h"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include "conversions.hpp"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void xgpp_conv::paa_to_pfcp_ue_ip_address( void xgpp_conv::paa_to_pfcp_ue_ip_address(
...@@ -160,13 +161,23 @@ void xgpp_conv::sm_context_create_from_openapi( ...@@ -160,13 +161,23 @@ void xgpp_conv::sm_context_create_from_openapi(
"Convert SmContextMessage (OpenAPI) to " "Convert SmContextMessage (OpenAPI) to "
"PDUSession_CreateSMContext"); "PDUSession_CreateSMContext");
oai::smf_server::model::SmContextCreateData context_data = scd.getJsonData(); oai::smf_server::model::SmContextCreateData context_data = {};
if (scd.jsonDataIsSet()) {
context_data = scd.getJsonData();
} else {
Logger::smf_app().warn("No Json data available");
}
if (scd.binaryDataN1SmMessageIsSet()) {
std::string n1_sm_msg = scd.getBinaryDataN1SmMessage(); std::string n1_sm_msg = scd.getBinaryDataN1SmMessage();
// N1 SM Message // N1 SM Message
pcr.set_n1_sm_message(n1_sm_msg); pcr.set_n1_sm_message(n1_sm_msg);
Logger::smf_app().debug("N1 SM message: %s", n1_sm_msg.c_str()); Logger::smf_app().debug("N1 SM message: %s", n1_sm_msg.c_str());
} else {
Logger::smf_app().warn("No N1 SM Message available");
}
if (context_data.supiIsSet()) {
// supi // supi
supi_t supi = {.length = 0}; supi_t supi = {.length = 0};
std::size_t pos = context_data.getSupi().find("-"); std::size_t pos = context_data.getSupi().find("-");
...@@ -178,24 +189,40 @@ void xgpp_conv::sm_context_create_from_openapi( ...@@ -178,24 +189,40 @@ void xgpp_conv::sm_context_create_from_openapi(
Logger::smf_app().debug( Logger::smf_app().debug(
"SUPI %s, SUPI Prefix %s, IMSI %s", context_data.getSupi().c_str(), "SUPI %s, SUPI Prefix %s, IMSI %s", context_data.getSupi().c_str(),
supi_prefix.c_str(), supi_str.c_str()); supi_prefix.c_str(), supi_str.c_str());
} else {
Logger::smf_app().warn("No SUPI available");
}
// dnn // TODO: unauthenticatedSupi
// DNN
if (context_data.dnnIsSet()) {
Logger::smf_app().debug("DNN %s", context_data.getDnn().c_str()); Logger::smf_app().debug("DNN %s", context_data.getDnn().c_str());
pcr.set_dnn(context_data.getDnn().c_str()); pcr.set_dnn(context_data.getDnn().c_str());
} else {
Logger::smf_app().warn("No DNN available");
}
// S-Nssai // S-Nssai
if (context_data.sNssaiIsSet()) {
Logger::smf_app().debug( Logger::smf_app().debug(
"S-NSSAI SST %d, SD %s", context_data.getSNssai().getSst(), "S-NSSAI SST %d, SD %s", context_data.getSNssai().getSst(),
context_data.getSNssai().getSd().c_str()); context_data.getSNssai().getSd().c_str());
snssai_t snssai( snssai_t snssai(
context_data.getSNssai().getSst(), context_data.getSNssai().getSd()); context_data.getSNssai().getSst(), context_data.getSNssai().getSd());
pcr.set_snssai(snssai); pcr.set_snssai(snssai);
} else {
Logger::smf_app().warn("No SNSSAI available");
}
// PDU session ID // PDU session ID
Logger::smf_app().debug("PDU Session ID %d", context_data.getPduSessionId()); if (context_data.pduSessionIdIsSet()) {
Logger::smf_app().debug(
"PDU Session ID %d", context_data.getPduSessionId());
pcr.set_pdu_session_id(context_data.getPduSessionId()); pcr.set_pdu_session_id(context_data.getPduSessionId());
}
{ Logger::smf_app().warn("No PDU Session ID available"); }
// AMF ID (ServingNFId) // AMF ID (ServingNFId/NfInstanceId)
Logger::smf_app().debug( Logger::smf_app().debug(
"ServingNfId %s", context_data.getServingNfId().c_str()); "ServingNfId %s", context_data.getServingNfId().c_str());
pcr.set_serving_nf_id(context_data.getServingNfId() pcr.set_serving_nf_id(context_data.getServingNfId()
...@@ -203,9 +230,59 @@ void xgpp_conv::sm_context_create_from_openapi( ...@@ -203,9 +230,59 @@ void xgpp_conv::sm_context_create_from_openapi(
// is stored in GUAMI or ServingNfId // is stored in GUAMI or ServingNfId
// Request Type // Request Type
if (context_data.requestTypeIsSet()) {
Logger::smf_app().debug( Logger::smf_app().debug(
"RequestType %s", context_data.getRequestType().c_str()); "RequestType %s", context_data.getRequestType().c_str());
pcr.set_request_type(context_data.getRequestType()); pcr.set_request_type(context_data.getRequestType());
} else {
Logger::smf_app().warn("No Request Type available");
}
// SMContextStatusUri
pcr.set_sm_context_status_uri(context_data.getSmContextStatusUri());
Logger::smf_app().debug(
"SMContextStatusUri %s", context_data.getSmContextStatusUri().c_str());
// DNN Selection Mode
if (context_data.selModeIsSet()) {
Logger::smf_app().debug("SelMode %s", context_data.getSelMode().c_str());
pcr.set_dnn_selection_mode(context_data.getSelMode());
} else {
Logger::smf_app().warn("No SelMode available");
}
// ServingNetwork (PlmnId)
Logger::smf_app().debug(
"Serving Network (MCC %s, MNC %s)",
context_data.getServingNetwork().getMcc().c_str(),
context_data.getServingNetwork().getMnc().c_str());
plmn_t p = {};
if (conv::plmnFromString(
p, context_data.getServingNetwork().getMcc(),
context_data.getServingNetwork().getMnc())) {
pcr.set_plmn(p);
} else {
Logger::smf_app().warn("Error while converting MCC, MNC to PLMN");
}
// anType (AccessType)
Logger::smf_app().debug("AN Type %s", context_data.getAnType().c_str());
pcr.set_an_type(context_data.getAnType());
// Guami
if (context_data.guamiIsSet()) {
// Logger::smf_app().debug("GUAMI %s", context_data.getGuami().c_str());
guami_5g_t guami = {};
guami.amf_id = context_data.getGuami().getAmfId();
if (!conv::plmnFromString(
guami.plmn, context_data.getGuami().getPlmnId().getMcc(),
context_data.getGuami().getPlmnId().getMnc())) {
Logger::smf_app().warn("Error while converting MCC, MNC to PLMN");
}
pcr.set_guami(guami);
}
// TODO:
// PCF ID // PCF ID
// Priority Access // Priority Access
// User Location Information // User Location Information
...@@ -213,28 +290,8 @@ void xgpp_conv::sm_context_create_from_openapi( ...@@ -213,28 +290,8 @@ void xgpp_conv::sm_context_create_from_openapi(
// PEI // PEI
// GPSI // GPSI
// UE presence in LADN service area // UE presence in LADN service area
// Guami
// servingNetwork
// anType
// UETimeZone // UETimeZone
// SMContextStatusUri
pcr.set_sm_context_status_uri(context_data.getSmContextStatusUri());
// PCFId // PCFId
// DNN Selection Mode
Logger::smf_app().debug("SelMode %s", context_data.getSelMode().c_str());
pcr.set_dnn_selection_mode(context_data.getSelMode().c_str());
// Subscription for PDU Session Status Notification
// Trace requirement
// SSC mode (Optional)
// 5GSM capability (Optional)
// Maximum number of supported (Optional)
// Maximum number of supported packet filters (Optional)
// Always-on PDU session requested (Optional)
// SM PDU DN request container (Optional)
// Extended protocol configuration options (Optional) e.g, FOR DHCP
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -117,6 +117,40 @@ std::string conv::mncToString( ...@@ -117,6 +117,40 @@ std::string conv::mncToString(
return s; return s;
} }
bool conv::plmnFromString(
plmn_t& p, const std::string mcc, const std::string mnc) {
// MCC
if (isdigit(mcc[0]))
p.mcc_digit1 = mcc[0] - '0';
else
return false;
if (isdigit(mcc[1]))
p.mcc_digit2 = mcc[1] - '0';
else
return false;
if (isdigit(mcc[2]))
p.mcc_digit3 = mcc[2] - '0';
else
return false;
// MNC
if (isdigit(mnc[0]))
p.mnc_digit1 = mnc[0] - '0';
else
return false;
if (isdigit(mnc[1]))
p.mnc_digit2 = mnc[1] - '0';
else
return false;
if (mnc.length() > 2) {
if (isdigit(mnc[2]))
p.mnc_digit3 = mnc[2] - '0';
else
return false;
}
return true;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
struct in_addr conv::fromString(const std::string addr4) { struct in_addr conv::fromString(const std::string addr4) {
unsigned char buf[sizeof(struct in6_addr)] = {}; unsigned char buf[sizeof(struct in6_addr)] = {};
......
...@@ -269,6 +269,7 @@ ...@@ -269,6 +269,7 @@
pLMN.mnc_digit2 * 10 + pLMN.mnc_digit1; \ pLMN.mnc_digit2 * 10 + pLMN.mnc_digit1; \
} while (0) } while (0)
/* /*
* TS 36.413 v10.9.0 section 9.2.1.37: * TS 36.413 v10.9.0 section 9.2.1.37:
* Macro eNB ID: * Macro eNB ID:
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include <string> #include <string>
#include <netinet/in.h> #include <netinet/in.h>
#include "3gpp_23.003.h"
/* Used to format an uint32_t containing an ipv4 address */ /* Used to format an uint32_t containing an ipv4 address */
#define IN_ADDR_FMT "%u.%u.%u.%u" #define IN_ADDR_FMT "%u.%u.%u.%u"
#define PRI_IN_ADDR(aDDRESS) \ #define PRI_IN_ADDR(aDDRESS) \
...@@ -53,6 +55,7 @@ class conv { ...@@ -53,6 +55,7 @@ class conv {
static void hexa_to_ascii(uint8_t* from, char* to, size_t length); 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 int ascii_to_hex(uint8_t* dst, const char* h);
static struct in_addr fromString(const std::string addr4); static struct in_addr fromString(const std::string addr4);
static bool plmnFromString(plmn_t& p, const std::string mcc, const std::string mnc);
static std::string toString(const struct in_addr& inaddr); static std::string toString(const struct in_addr& inaddr);
static std::string toString(const struct in6_addr& in6addr); static std::string toString(const struct in6_addr& in6addr);
static std::string mccToString( static std::string mccToString(
......
...@@ -1839,6 +1839,7 @@ void smf_app::get_ee_subscriptions( ...@@ -1839,6 +1839,7 @@ void smf_app::get_ee_subscriptions(
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void smf_app::generate_smf_profile() { void smf_app::generate_smf_profile() {
// TODO: remove hardcoded values
// generate UUID // generate UUID
generate_uuid(); generate_uuid();
nf_instance_profile.set_nf_instance_id(smf_instance_id); nf_instance_profile.set_nf_instance_id(smf_instance_id);
...@@ -1864,7 +1865,7 @@ void smf_app::generate_smf_profile() { ...@@ -1864,7 +1865,7 @@ void smf_app::generate_smf_profile() {
ip_endpoint_t endpoint = {}; ip_endpoint_t endpoint = {};
std::vector<struct in_addr> addrs; std::vector<struct in_addr> addrs;
nf_instance_profile.get_nf_ipv4_addresses(addrs); nf_instance_profile.get_nf_ipv4_addresses(addrs);
endpoint.ipv4_address = addrs[0]; //TODO: use first IP ADDR for now endpoint.ipv4_address = addrs[0]; // TODO: use first IP ADDR for now
endpoint.transport = "TCP"; endpoint.transport = "TCP";
endpoint.port = smf_cfg.sbi.port; endpoint.port = smf_cfg.sbi.port;
nf_service.ip_endpoints.push_back(endpoint); nf_service.ip_endpoints.push_back(endpoint);
......
...@@ -352,6 +352,38 @@ void pdu_session_create_sm_context_request::get_epco( ...@@ -352,6 +352,38 @@ void pdu_session_create_sm_context_request::get_epco(
p = m_epco; p = m_epco;
} }
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_plmn(const plmn_t p) {
m_serving_network = p;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::get_plmn(plmn_t& p) const {
p = m_serving_network;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_an_type(
const std::string& an_type) {
m_an_type = an_type;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::get_an_type(
std::string& an_type) const {
an_type = m_an_type;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_guami(const guami_5g_t& guami) {
m_guami = guami;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::get_guami(guami_5g_t& guami) const {
guami = m_guami;
}
/* /*
* class: PDU Session Create SM Context Response * class: PDU Session Create SM Context Response
*/ */
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#define FILE_SMF_MSG_HPP_SEEN #define FILE_SMF_MSG_HPP_SEEN
#include "smf.h" #include "smf.h"
#include "3gpp_23.003.h"
#include "3gpp_24.007.h" #include "3gpp_24.007.h"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include "3gpp_29.244.h" #include "3gpp_29.244.h"
#include "3gpp_29.274.h" #include "3gpp_29.274.h"
#include "3gpp_29.508.h" #include "3gpp_29.508.h"
#include "3gpp_29.571.h" #include "3gpp_29.571.h"
#include "Guami.h"
#include "NgRanTargetId.h" #include "NgRanTargetId.h"
#include "pistache/http.h" #include "pistache/http.h"
#include "smf_profile.hpp" #include "smf_profile.hpp"
...@@ -268,6 +268,12 @@ class pdu_session_create_sm_context_request ...@@ -268,6 +268,12 @@ class pdu_session_create_sm_context_request
std::string get_sm_context_status_uri() const; std::string get_sm_context_status_uri() const;
void set_epco(const protocol_configuration_options_t& p); void set_epco(const protocol_configuration_options_t& p);
void get_epco(protocol_configuration_options_t& p) const; void get_epco(protocol_configuration_options_t& p) const;
void set_plmn(const plmn_t p);
void get_plmn(plmn_t& p) const;
void set_an_type(const std::string& an_type);
void get_an_type(std::string& an_type) const;
void set_guami(const guami_5g_t& guami);
void get_guami(guami_5g_t& guami) const;
private: private:
bool m_unauthenticated_supi; bool m_unauthenticated_supi;
...@@ -279,6 +285,8 @@ class pdu_session_create_sm_context_request ...@@ -279,6 +285,8 @@ class pdu_session_create_sm_context_request
std::string m_dnn_selection_mode; // SelMode std::string m_dnn_selection_mode; // SelMode
std::string m_sm_context_status_uri; std::string m_sm_context_status_uri;
protocol_configuration_options_t m_epco; protocol_configuration_options_t m_epco;
plmn_t m_serving_network;
guami_5g_t m_guami;
}; };
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
......
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