Commit 908e56da authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Continue to work with documentation

parent 44a7737f
......@@ -189,5 +189,7 @@ static const std::vector<std::string> multipart_related_content_part_e2str = {
//for CURL
#define AMF_CURL_TIMEOUT_MS 100L
#define UDM_CURL_TIMEOUT_MS 100L
#define UDM_NUMBER_RETRIES 3
#endif
......@@ -1018,6 +1018,16 @@ bool smf_app::is_scid_2_smf_context(const scid_t &scid) const {
return bool { scid2smf_context.count(scid) > 0 };
}
//------------------------------------------------------------------------------
bool smf_app::scid_2_smf_context(const scid_t &scid, std::shared_ptr<smf_context_ref> & scf) const {
std::shared_lock lock(m_scid2smf_context);
if ( scid2smf_context.count(scid) > 0 ) {
scf = scid2smf_context.at(scid);
return true;
}
return false;
}
//------------------------------------------------------------------------------
bool smf_app::use_local_configuration_subscription_data(
const std::string &dnn_selection_mode) {
......@@ -1069,7 +1079,7 @@ void smf_app::convert_string_2_hex(std::string &input_str,
}
//---------------------------------------------------------------------------------------------
unsigned char* smf_app::format_string_as_hex(std::string str) {
unsigned char* smf_app::format_string_as_hex(std::string &str) {
unsigned int str_len = str.length();
char *data = (char*) malloc(str_len + 1);
memset(data, 0, str_len + 1);
......@@ -1094,8 +1104,8 @@ unsigned char* smf_app::format_string_as_hex(std::string str) {
}
//---------------------------------------------------------------------------------------------
void smf_app::update_pdu_session_status(const scid_t scid,
const pdu_session_status_e status) {
void smf_app::update_pdu_session_status(const scid_t &scid,
const pdu_session_status_e &status) {
Logger::smf_app().info("Update PDU Session Status");
//get the smf context
......@@ -1150,8 +1160,8 @@ void smf_app::update_pdu_session_status(const scid_t scid,
}
//---------------------------------------------------------------------------------------------
void smf_app::update_pdu_session_upCnx_state(const scid_t scid,
const upCnx_state_e state) {
void smf_app::update_pdu_session_upCnx_state(const scid_t &scid,
const upCnx_state_e &state) {
Logger::smf_app().info("Update UpCnx_State");
//get the smf context
......@@ -1209,7 +1219,7 @@ void smf_app::timer_t3591_timeout(timer_id_t timer_id, uint64_t arg2_user) {
}
//---------------------------------------------------------------------------------------------
n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(std::string n2_info_type) {
n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(std::string &n2_info_type) {
std::size_t number_of_types = n2_sm_info_type_e2str.size();
for (auto i = 0; i < number_of_types; ++i) {
if (n2_info_type.compare(n2_sm_info_type_e2str[i]) == 0) {
......
......@@ -87,13 +87,10 @@ class smf_context_ref {
pdu_session_id = 0;
}
// std::string toString() const;
supi_t supi;
std::string dnn;
pdu_session_id_t pdu_session_id;
snssai_t nssai;
};
class smf_app {
......@@ -117,17 +114,49 @@ class smf_app {
std::map<scid_t, std::shared_ptr<smf_context_ref>> scid2smf_context;
mutable std::shared_mutex m_scid2smf_context;
/*
* Apply the config from the configuration file for APN pools
* @param [const smf_config &cfg] cfg
* @return
*/
int apply_config(const smf_config &cfg);
/*
* pco_push_protocol_or_container_id
* @param [protocol_configuration_options_t &] pco
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int pco_push_protocol_or_container_id(
protocol_configuration_options_t &pco,
pco_protocol_or_container_id_t *const poc_id /* STOLEN_REF poc_id->contents*/);
/*
* process_pco_request_ipcp
* @param [protocol_configuration_options_t &] pco_resp
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int process_pco_request_ipcp(
protocol_configuration_options_t &pco_resp,
const pco_protocol_or_container_id_t *const poc_id);
/*
* process_pco_dns_server_request
* @param [protocol_configuration_options_t &] pco_resp
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int process_pco_dns_server_request(
protocol_configuration_options_t &pco_resp,
const pco_protocol_or_container_id_t *const poc_id);
/*
* process_pco_link_mtu_request
* @param [protocol_configuration_options_t &] pco_resp
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int process_pco_link_mtu_request(
protocol_configuration_options_t &pco_resp,
const pco_protocol_or_container_id_t *const poc_id);
......@@ -137,61 +166,205 @@ class smf_app {
smf_app(smf_app const&) = delete;
void operator=(smf_app const&) = delete;
/*
* Set the association between Seid and SM Context
* @param [const seid_t &] seid: SessionID
* @param [std::shared_ptr<smf_context> &] pc : Shared_ptr to a SMF context
* @return
*/
void set_seid_2_smf_context(const seid_t &seid,
std::shared_ptr<smf_context> &pc);
/*
* Find SMF context associated with a Session ID
* @param [const seid_t &] seid: SessionID
* @param [std::shared_ptr<smf_context> &] pc : Shared_ptr to a SMF context
* @return bool: True if SMF context found, otherwise return false
*/
bool seid_2_smf_context(const seid_t &seid,
std::shared_ptr<smf_context> &pc) const;
/*
* Delete the SMF Context
* @param [std::shared_ptr<smf_context> &] pc : Shared_ptr to the SMF context to be deleted
* @return void
*/
void delete_smf_context(std::shared_ptr<smf_context> spc);
int static_paa_get_free_paa(const std::string &apn, paa_t &paa);
int static_paa_release_address(const std::string &apn, struct in_addr &addr);
/*
* static_paa_get_free_paa
* @param [const std::string &] dnn
* @param [paa_t &] paa
* @return void
*/
int static_paa_get_free_paa(const std::string &dnn, paa_t &paa);
/*
* static_paa_get_free_paa
* @param [const std::string &] dnn
* @param [struct in_addr &] addr
* @return void
*/
int static_paa_release_address(const std::string &dnn, struct in_addr &addr);
/*
* static_paa_get_num_ipv4_pool
* @param void
* @return void
*/
int static_paa_get_num_ipv4_pool(void);
/*
* Get paa pool
* @param
* @return pool index
*/
int static_paa_get_ipv4_pool(
const int pool_id, struct in_addr *const range_low,
struct in_addr *const range_high, struct in_addr *const netaddr,
struct in_addr *const netmask,
std::vector<struct in_addr>::iterator &it_out_of_nw);
/*
* Get pool ID corresponding to an address
* @param [const struct in_addr &] ue_addr
* @return pool index
*/
int static_paa_get_pool_id(const struct in_addr &ue_addr);
/*
* process_pco_request
* @param [const protocol_configuration_options_t &] pco_req
* @param [const protocol_configuration_options_t &] pco_resp
* @param [const protocol_configuration_options_ids_t &] pco_ids
* @return pool index
*/
int process_pco_request(const protocol_configuration_options_t &pco_req,
protocol_configuration_options_t &pco_resp,
protocol_configuration_options_ids_t &pco_ids);
void handle_itti_msg(itti_n4_session_establishment_response &m);
void handle_itti_msg(itti_n4_session_modification_response &m);
void handle_itti_msg(itti_n4_session_deletion_response &m);
/*
* Handle ITTI message (N4 Session Establishment Response)
* @param [itti_n4_session_modification_response&] sne
* @return void
*/
void handle_itti_msg(itti_n4_session_establishment_response &sne);
/*
* Handle ITTI message (N4 Session Modification Response)
* @param [itti_n4_session_modification_response&] snm
* @return void
*/
void handle_itti_msg(itti_n4_session_modification_response &snm);
/*
* Handle ITTI message (N4 Session Report Request)
* @param [itti_n4_association_setup_request&] snd
* @return void
*/
void handle_itti_msg(itti_n4_session_deletion_response &snd);
/*
* Handle ITTI message (N4 Session Report Request)
* @param [itti_n4_association_setup_request&] snr
* @return void
*/
void handle_itti_msg(std::shared_ptr<itti_n4_session_report_request> snr);
void handle_itti_msg(itti_n4_association_setup_request &m);
/*
* Handle ITTI message (N4 Association Setup Request)
* @param [itti_n4_association_setup_request&] sna
* @return void
*/
void handle_itti_msg(itti_n4_association_setup_request &sna);
/*
* Handle ITTI message from N11 to update PDU session status
* @param [itti_n11_update_pdu_session_status&] itti_n11_update_pdu_session_status
* @param [itti_n11_update_pdu_session_status&] snu
* @return void
*/
void handle_itti_msg(itti_n11_update_pdu_session_status &m);
void handle_itti_msg(itti_n11_update_pdu_session_status &snu);
/*
* Handle ITTI message from N11 (N1N2MessageTransfer Response)
* @param [itti_n11_n1n2_message_transfer_response_status&] itti_n11_n1n2_message_transfer_response_status
* @param [itti_n11_n1n2_message_transfer_response_status&] snm
* @return void
*/
void handle_itti_msg(itti_n11_n1n2_message_transfer_response_status &m);
void handle_itti_msg(itti_n11_n1n2_message_transfer_response_status &snm);
/*
* Restore a N4 Session
* @param [const seid_t &] seid: Session ID to be restored
* @return void
*/
void restore_n4_sessions(const seid_t &seid) const;
/*
* Generate a Session ID
* @param [void]
* @return uint64_t: Return Seid generated
*/
uint64_t generate_seid();
/*
* Verify whether a session with a given ID exist
* @param [const uint64_t &] s: Seid ID
* @return bool: True if exist, otherwise false
*/
bool is_seid_n4_exist(const uint64_t &s) const;
/*
* Free a Seid by its ID
* @param [const uint64_t &] s: Seid ID
* @return void
*/
void free_seid_n4(const uint64_t &seid);
/*
* Generate a SMF Context Reference in a form of string
* @param [std::string &] smf_ref: Store the generated reference
* @return void
*/
void generate_smf_context_ref(std::string &smf_ref);
/*
* Generate a SMF Context Reference
* @param [void]
* @return the generated reference
*/
scid_t generate_smf_context_ref();
/*
* Set the association betwen a SMF Context Reference and a SMF Context
* @param [const scid_t &] id: SMF Context Reference Id
* @param [std::shared_ptr<smf_context_ref>] scf: SMF Context
* @return the generated reference
*/
void set_scid_2_smf_context(const scid_t &id,
std::shared_ptr<smf_context_ref> scf);
/*
* Find SMF Context Reference by its ID
* @param [const scid_t &] scid: SM Context Reference ID
* @return Shared_ptr to a SMF Context Reference if found, otherwise return false
*/
std::shared_ptr<smf_context_ref> scid_2_smf_context(const scid_t &scid) const;
/*
* Verify whether a SMF Context Reference with a given ID exist
* @param [const scid_t &] scid: SM Context Reference ID
* @return bool: True if a SMF Context Reference exist, otherwise return false
*/
bool is_scid_2_smf_context(const scid_t &scid) const;
/*
* Find SMF Context Reference by its ID
* @param [const scid_t &] scid: SM Context Reference ID
* @param [std::shared_ptr<smf_context_ref> &] scf : Shared_ptr to a SMF Context Reference
* @return bool: True if SMF Context Reference found, otherwise return false
*/
bool scid_2_smf_context(const scid_t &scid, std::shared_ptr<smf_context_ref> & scf) const;
/*
* Handle PDUSession_CreateSMContextRequest from AMF
* @param [std::shared_ptr<itti_n11_create_sm_context_request>&] Request message
......@@ -285,18 +458,29 @@ class smf_app {
*/
void convert_string_2_hex(std::string &input_str, std::string &output_str);
unsigned char* format_string_as_hex(std::string str);
void start_upf_association(const pfcp::node_id_t &node_id);
/*
* Represent a string as hex
* @param [std::string&] str: input string
* @param [std::string&] output_str String represents string in hex format
* @return void
*/
unsigned char* format_string_as_hex(std::string &str);
/*
* Update PDU session status
* @param [const scid_t] id SM Context ID
* @param [const pdu_session_status_e] status PDU Session Status
* @param [const scid_t &] id SM Context ID
* @param [const pdu_session_status_e &] status PDU Session Status
* @return void
*/
void update_pdu_session_status(const scid_t id,
const pdu_session_status_e status);
void update_pdu_session_status(const scid_t &id,
const pdu_session_status_e &status);
/*
* Convert N2 Info type representing by a string to n2_sm_info_type_e
* @param [std::string] n2_info_type
* @return representing of N2 info type in a form of emum
*/
n2_sm_info_type_e n2_sm_info_type_str2e(std::string &n2_info_type);
/*
* Update PDU session UpCnxState
......@@ -304,11 +488,23 @@ class smf_app {
* @param [const upCnx_state_e] status PDU Session UpCnxState
* @return void
*/
void update_pdu_session_upCnx_state(const scid_t scid,
const upCnx_state_e state);
void update_pdu_session_upCnx_state(const scid_t &scid,
const upCnx_state_e &state);
/*
* will be executed when timer T3591 expires
* @param [timer_id_t] timer_id
* @param [uint64_t] arg2_user
* @return void
*/
void timer_t3591_timeout(timer_id_t timer_id, uint64_t arg2_user);
n2_sm_info_type_e n2_sm_info_type_str2e(std::string n2_info_type);
/*
* To start an association with a UPF (SMF-initiated association)
* @param [const pfcp::node_id_t] node_id: UPF Node ID
* @return void
*/
void start_upf_association(const pfcp::node_id_t &node_id);
};
}
......
......@@ -86,7 +86,6 @@ class smf_qos_flow {
* @param void
* @return void
*/
void deallocate_ressources();
/*
......@@ -129,7 +128,6 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
ipv4_address.s_addr = INADDR_ANY;
ipv6_address = in6addr_any;
pdn_type = { };
default_bearer.ebi = EPS_BEARER_IDENTITY_UNASSIGNED;
seid = 0;
up_fseid = { };
qos_flows.clear();
......@@ -386,7 +384,6 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
struct in_addr ipv4_address; // IP Address(es): IPv4 address and/or IPv6 prefix
struct in6_addr ipv6_address; // IP Address(es): IPv4 address and/or IPv6 prefix
pdn_type_t pdn_type; // IPv4, IPv6, IPv4v6 or Non-IP
ebi_t default_bearer; //Default Bearer: Identifies the default bearer within the PDN connection by its EPS Bearer Id.
bool released; //(release access bearers request)
......@@ -402,16 +399,17 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
uint32_t pdu_session_id;
std::string amf_id;
std::map<uint8_t, smf_qos_flow> qos_flows; // QFI <-> QoS Flow
pfcp::qfi_t default_qfi;
std::map<uint8_t, QOSRulesIE> qos_rules; // QRI <-> QoS Rules
std::vector<uint8_t> qos_rules_to_be_synchronised;
std::vector<uint8_t> qos_rules_to_be_removed;
pdu_session_status_e pdu_session_status;
upCnx_state_e upCnx_state; //N3 tunnel status (ACTIVATED, DEACTIVATED, ACTIVATING)
timer_id_t timer_T3590;
timer_id_t timer_T3591;
timer_id_t timer_T3592;
upCnx_state_e upCnx_state; //N3 tunnel status (ACTIVATED, DEACTIVATED, ACTIVATING)
pfcp::qfi_t default_qfi; //Default QFI for this session
std::map<uint8_t, smf_qos_flow> qos_flows; // QFI <-> QoS Flow
std::map<uint8_t, QOSRulesIE> qos_rules; // QRI <-> QoS Rules
std::vector<uint8_t> qos_rules_to_be_synchronised;
std::vector<uint8_t> qos_rules_to_be_removed;
//5GSM parameters and capabilities
uint8_t maximum_number_of_supported_packet_filters;
//TODO: 5GSM Capability (section 9.11.4.1@3GPP TS 24.501 V16.1.0)
......@@ -446,6 +444,7 @@ class session_management_subscription {
*/
void find_dnn_configuration(
std::string dnn, std::shared_ptr<dnn_configuration_t> &dnn_configuration);
private:
snssai_t single_nssai;
std::map<std::string, std::shared_ptr<dnn_configuration_t>> dnn_configurations; //dnn <->dnn_configuration
......@@ -753,19 +752,19 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
const snssai_t &snssai, const std::string &dnn);
private:
std::vector<std::shared_ptr<dnn_context>> dnns;
imsi_t imsi; // IMSI (International Mobile Subscriber Identity) is the subscriber permanent identity.
bool imsi_unauthenticated_indicator; // This is an IMSI indicator to show the IMSI is unauthenticated.
// TO BE CHECKED me_identity_t me_identity; // Mobile Equipment Identity (e.g. IMEI/IMEISV).
msisdn_t msisdn; // The basic MSISDN of the UE. The presence is dictated by its storage in the HSS.
std::vector<std::shared_ptr<smf_procedure>> pending_procedures;
// Big recursive lock
mutable std::recursive_mutex m_context;
// snssai-sst <-> session management subscription
std::map<uint8_t, std::shared_ptr<session_management_subscription>> dnn_subscriptions;
supi_t supi;
scid_t scid;
scid_t scid; //SM Context ID
// Big recursive lock
mutable std::recursive_mutex m_context;
};
}
......
......@@ -39,9 +39,6 @@
#include "logger.hpp"
#include "smf_config.hpp"
#define UDM_CURL_TIMEOUT_MS 100L
#define UDM_NUMBER_RETRIES 3
using namespace smf;
using namespace std;
using json = nlohmann::json;
......
......@@ -47,9 +47,26 @@ class smf_n10 {
smf_n10();
smf_n10(smf_n10 const&) = delete;
void operator=(smf_n10 const&) = delete;
/*
* Get SM subscription data from UDM
* @param [supi64_t &] supi
* @param [std::string &] dnn
* @param [snssai_t &] snssai
* @param [std::shared_ptr<session_management_subscription>] subscription
* @return bool: True if successful, otherwise false
*
*/
bool get_sm_data(
supi64_t &supi, std::string &dnn, snssai_t &snssai,
std::shared_ptr<session_management_subscription> subscription);
/*
* Subscribe to be notify from UDM
* @param []
* @return void
*
*/
void subscribe_sm_data();
};
......
......@@ -54,7 +54,7 @@ class smf_n11 {
/*
* Send N1N2 Message Transfer Request to AMF
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res: Content of message to be sent
*
* @return void
*/
void send_n1n2_message_transfer_request(
std::shared_ptr<itti_n11_create_sm_context_response> sm_context_res);
......@@ -62,7 +62,7 @@ class smf_n11 {
/*
* Send N1N2 Message Transfer Request to AMF
* @param [std::shared_ptr<itti_nx_trigger_pdu_session_modification>] sm_context_res: Content of message to be sent
*
* @return void
*/
void send_n1n2_message_transfer_request(
std::shared_ptr<itti_nx_trigger_pdu_session_modification> sm_context_res);
......@@ -70,16 +70,15 @@ class smf_n11 {
/*
* Send update session response to AMF
* @param [std::shared_ptr<itti_n11_update_sm_context_response> sm_context_res] sm_context_res
*
* @return void
*/
void send_pdu_session_update_sm_context_response(
std::shared_ptr<itti_n11_update_sm_context_response> sm_context_res);
/*
* Send N1N2 Message Transfer Request to AMF
* @param [std::shared_ptr<itti_n11_modify_session_request_smf_requested>] sm_context_mod: Content of message to be sent
*
* @return void
*/
void send_n1n2_message_transfer_request(
std::shared_ptr<itti_n11_modify_session_request_smf_requested> sm_context_mod);
......@@ -89,7 +88,7 @@ class smf_n11 {
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextUpdateError] SmContextUpdateError
* @param [Pistache::Http::Code] code, response code
*
* @return void
*/
void send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -101,7 +100,7 @@ class smf_n11 {
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextUpdatedData] smContextUpdatedData
* @param [Pistache::Http::Code] code, response code
*
* @return void
*/
void send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -113,7 +112,7 @@ class smf_n11 {
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextCreateError] smContextCreateError
* @param [Pistache::Http::Code] code, response code
*
* @return void
*/
void send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -126,7 +125,7 @@ class smf_n11 {
* @param [ oai::smf_server::model::SmContextCreateError] smContextCreateError
* @param [Pistache::Http::Code] code, response code
* @param [std::string] n1_sm_msg, N1 SM message content
*
* @return void
*/
void send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -139,7 +138,7 @@ class smf_n11 {
* @param [ oai::smf_server::model::SmContextUpdateError] smContextUpdateError
* @param [Pistache::Http::Code] code, response code
* @param [std::string] n1_sm_msg, N1 SM message content
*
* @return void
*/
void send_pdu_session_update_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -151,7 +150,7 @@ class smf_n11 {
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [ oai::smf_server::model::SmContextCreatedData] smContextCreatedData
* @param [Pistache::Http::Code] code, response code
*
* @return void
*/
void send_pdu_session_create_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -162,7 +161,7 @@ class smf_n11 {
* Send release session response to AMF
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [Pistache::Http::Code] code, response code
*
* @return void
*/
void send_pdu_session_release_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse, Pistache::Http::Code code);
......@@ -172,7 +171,7 @@ class smf_n11 {
* @param [Pistache::Http::ResponseWriter] httpResponse
* @param [oai::smf_server::model::ProblemDetails] problem
* @param [Pistache::Http::Code] code, response code
*
* @return void
*/
void send_pdu_session_release_sm_context_response(
Pistache::Http::ResponseWriter &httpResponse,
......@@ -186,7 +185,7 @@ class smf_n11 {
* @param [std::string] boundary: Boundary of multipart/related msg
* @param [std::string] n1_message: N1 (NAS) part
* @param [std::string] n2_message: N2 (NGAP) part
*
* @return void
*/
void create_multipart_related_content(std::string &body,
std::string &json_part,
......@@ -201,7 +200,7 @@ class smf_n11 {
* @param [std::string] boundary: Boundary of multipart/related msg
* @param [std::string] message: N1 (NAS) or N2 (NGAP) part