diff --git a/src/smf_app/smf_app.cpp b/src/smf_app/smf_app.cpp index 86170080814b53ccdf78bc953e79239dc9ceb8c2..8c4e178e7445f7b086d317f505939413edc7cd1a 100755 --- a/src/smf_app/smf_app.cpp +++ b/src/smf_app/smf_app.cpp @@ -924,7 +924,10 @@ void smf_app::handle_pdu_session_release_sm_context_request( } //------------------------------------------------------------------------------ -void smf_app::trigger_pdu_session_modification() { +void smf_app::trigger_pdu_session_modification(supi_t &supi, std::string &dnn, + pdu_session_id_t pdu_session_id, + snssai_t &snssai, + pfcp::qfi_t &qfi) { //SMF-requested session modification, see section 4.3.3.2@3GPP TS 23.502 //The SMF may decide to modify PDU Session. This procedure also may be //triggered based on locally configured policy or triggered from the (R)AN (see clause 4.2.6 and clause 4.9.1). @@ -936,17 +939,20 @@ void smf_app::trigger_pdu_session_modification() { std::make_shared<itti_nx_trigger_pdu_session_modification>(TASK_SMF_APP, TASK_SMF_N11); - //step 1. collect the necessary information- hardcoded - supi_t supi = { }; - std::string dnn("default"); - pdu_session_id_t pdu_session_id = { 1 }; - snssai_t snssai = { }; - pfcp::qfi_t qfi = { }; - qfi.qfi = 7; - std::string supi_str("200000000000001"); - smf_string_to_supi(&supi, supi_str.c_str()); - snssai.sST = 222; - snssai.sD = "0000D4"; + //step 1. collect the necessary information + /* + //For testing purpose + supi_t supi = { }; + std::string dnn("default"); + pdu_session_id_t pdu_session_id = { 1 }; + snssai_t snssai = { }; + pfcp::qfi_t qfi = { }; + qfi.qfi = 7; + std::string supi_str("200000000000001"); + smf_string_to_supi(&supi, supi_str.c_str()); + snssai.sST = 222; + snssai.sD = "0000D4"; + */ itti_msg->msg.set_supi(supi); itti_msg->msg.set_dnn(dnn); diff --git a/src/smf_app/smf_app.hpp b/src/smf_app/smf_app.hpp index c8fef5f9263f134b4364378749989f30a07234ca..1d6829f466384b0381aeebbfb6e9f5a84b0c810e 100644 --- a/src/smf_app/smf_app.hpp +++ b/src/smf_app/smf_app.hpp @@ -65,7 +65,6 @@ namespace smf { #define T3592_TIMER_VALUE_SEC 16 #define T3592_TIMER_MAX_RETRIES 4 - typedef enum { PDU_SESSION_ESTABLISHMENT = 1, PDU_SESSION_MODIFICATION = 2, @@ -219,10 +218,16 @@ class smf_app { /* * Trigger pdu session modification - * @param should be updated + * @param [supi_t &] supi + * @param [std::string &] dnn + * @param [pdu_session_id_t] pdu_session_id + * @param [snssai_t &] snssai + * @param [pfcp::qfi_t &] qfi * @return void */ - void trigger_pdu_session_modification(); + void trigger_pdu_session_modification(supi_t &supi, std::string &dnn, + pdu_session_id_t pdu_session_id, + snssai_t &snssai, pfcp::qfi_t &qfi); /* * Verify if SM Context is existed for this Supi @@ -300,7 +305,7 @@ class smf_app { * @return void */ void update_pdu_session_upCnx_state(const scid_t scid, - const upCnx_state_e state); + const upCnx_state_e state); 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); diff --git a/src/smf_app/smf_context.cpp b/src/smf_app/smf_context.cpp index 40d9e8817b381150637251a40c1bec27545f7bfa..76eab8f01c5b3df10839c87b0791eebbf229bbe9 100644 --- a/src/smf_app/smf_context.cpp +++ b/src/smf_app/smf_context.cpp @@ -63,7 +63,7 @@ extern smf::smf_n11 *smf_n11_inst; extern smf::smf_config smf_cfg; //------------------------------------------------------------------------------ -void smf_qos_flow::release_qos_flow() { +void smf_qos_flow::mark_as_released() { released = true; } @@ -163,7 +163,7 @@ void smf_pdu_session::get_paa(paa_t &paa) { } //------------------------------------------------------------------------------ -void smf_pdu_session::add_qos_flow(smf_qos_flow &flow) { +void smf_pdu_session::add_qos_flow(const smf_qos_flow &flow) { if ((flow.qfi.qfi >= QOS_FLOW_IDENTIFIER_FIRST ) and (flow.qfi.qfi <= QOS_FLOW_IDENTIFIER_LAST )) { qos_flows.erase(flow.qfi.qfi); @@ -248,19 +248,6 @@ bool smf_pdu_session::find_qos_flow(const pfcp::pdr_id_t &pdr_id, return false; } -//------------------------------------------------------------------------------ -bool smf_pdu_session::has_qos_flow(const pfcp::pdr_id_t &pdr_id, - pfcp::qfi_t &qfi) { - for (std::map<uint8_t, smf_qos_flow>::iterator it = qos_flows.begin(); - it != qos_flows.end(); ++it) { - if ((it->second.pdr_id_ul == pdr_id) || (it->second.pdr_id_dl == pdr_id)) { - qfi = it->second.qfi; - return true; - } - } - return false; -} - //------------------------------------------------------------------------------ void smf_pdu_session::remove_qos_flow(const pfcp::qfi_t &qfi) { smf_qos_flow &flow = qos_flows[qfi.qfi]; @@ -397,7 +384,7 @@ void smf_pdu_session::get_qos_rules_to_be_synchronised( } //------------------------------------------------------------------------------ -void smf_pdu_session::get_qos_rules(pfcp::qfi_t qfi, +void smf_pdu_session::get_qos_rules(const pfcp::qfi_t &qfi, std::vector<QOSRulesIE> &rules) const { Logger::smf_app().info("Get QoS Rules associated with Flow with QFI %d", qfi.qfi); @@ -431,7 +418,7 @@ bool smf_pdu_session::get_qos_rule(uint8_t rule_id, } //------------------------------------------------------------------------------ -void smf_pdu_session::update_qos_rule(QOSRulesIE qos_rule) { +void smf_pdu_session::update_qos_rule(const QOSRulesIE &qos_rule) { Logger::smf_app().info("Update QoS Rule with Rule Id %d", (uint8_t) qos_rule.qosruleidentifer); uint8_t rule_id = qos_rule.qosruleidentifer; @@ -482,7 +469,7 @@ void smf_pdu_session::mark_qos_rule_to_be_synchronised(uint8_t rule_id) { } //------------------------------------------------------------------------------ -void smf_pdu_session::add_qos_rule(QOSRulesIE qos_rule) { +void smf_pdu_session::add_qos_rule(const QOSRulesIE &qos_rule) { Logger::smf_app().info("Add QoS Rule with Rule Id %d", (uint8_t) qos_rule.qosruleidentifer); uint8_t rule_id = qos_rule.qosruleidentifer; @@ -1586,8 +1573,6 @@ void smf_context::handle_pdu_session_update_sm_context_request( n2_sm_info_hex_to_be_created); n11_sm_context_resp->res.set_n1_sm_message(n1_sm_msg_hex_to_be_created); - n11_sm_context_resp->res.set_n1_sm_msg_type( - "PDU_SESSION_MODIFICATION_COMMAND"); n11_sm_context_resp->res.set_n2_sm_information( n2_sm_info_hex_to_be_created); n11_sm_context_resp->res.set_n2_sm_info_type("PDU_RES_MOD_REQ"); @@ -2309,7 +2294,7 @@ void smf_context::handle_pdu_session_modification_network_requested( smf_app_inst->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex); itti_msg->msg.set_n1_sm_message(n1_sm_msg_hex); - //N2: PDU Session Resource Modify Request Transfer + //N2: PDU Session Resource Modify Response Transfer smf_n1_n2_inst.create_n2_sm_information(itti_msg->msg, 1, n2_sm_info_type_e::PDU_RES_MOD_REQ, n2_sm_info); diff --git a/src/smf_app/smf_context.hpp b/src/smf_app/smf_context.hpp index 8a565ed2673533949bd9c215687707822d7bb7e5..6d5d944f576a1b2eba35c2048a2bf0a60bc22d34 100644 --- a/src/smf_app/smf_context.hpp +++ b/src/smf_app/smf_context.hpp @@ -78,32 +78,43 @@ class smf_qos_flow { far_id_ul = { }; far_id_dl = { }; released = false; - qos_profile = {}; + qos_profile = { }; } + /* + * Release resources associated with this flow + * @param void + * @return void + */ + void deallocate_ressources(); - void release_qos_flow(); + + /* + * Mark this flow as released + * @param void + * @return void + */ + void mark_as_released(); + + /* + * Represent flow as string to be printed + * @param void + * @return void + */ std::string toString() const; pfcp::qfi_t qfi; //QoS Flow Identifier - fteid_t ul_fteid; //fteid of UPF fteid_t dl_fteid; //fteid of AN - - // PFCP - // Packet Detection Rule ID - pfcp::pdr_id_t pdr_id_ul; - pfcp::pdr_id_t pdr_id_dl; + pfcp::pdr_id_t pdr_id_ul; // Packet Detection Rule ID, UL + pfcp::pdr_id_t pdr_id_dl; // Packet Detection Rule ID, DL pfcp::precedence_t precedence; - std::pair<bool, pfcp::far_id_t> far_id_ul; - std::pair<bool, pfcp::far_id_t> far_id_dl; - + std::pair<bool, pfcp::far_id_t> far_id_ul; //FAR ID, UL + std::pair<bool, pfcp::far_id_t> far_id_dl; //FAR ID, DL bool released; // finally seems necessary, TODO try to find heuristic ? - pdu_session_id_t pdu_session_id; qos_profile_t qos_profile; //QoS profile uint8_t cause_value; //cause - }; class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { @@ -123,7 +134,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { up_fseid = { }; qos_flows.clear(); released = false; - default_qfi.qfi = NO_QOS_FLOW_IDENTIFIER_ASSIGNED ; + default_qfi.qfi = NO_QOS_FLOW_IDENTIFIER_ASSIGNED; pdu_session_status = pdu_session_status_e::PDU_SESSION_INACTIVE; timer_T3590 = ITTI_INVALID_TIMER_ID; timer_T3591 = ITTI_INVALID_TIMER_ID; @@ -132,22 +143,99 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { smf_pdu_session(smf_pdu_session &b) = delete; + /* + * Set UE Address for this session + * @param [paa_t &] paa: PAA + * @return void + */ void set(const paa_t &paa); + + /* + * Get UE Address of this session + * @param [paa_t &] paa: PAA + * @return void + */ void get_paa(paa_t &paa); - bool get_qos_flow(const pfcp::pdr_id_t &pdr_id, smf_qos_flow &q); - bool get_qos_flow(const pfcp::far_id_t &far_id, smf_qos_flow &q); - bool get_qos_flow(const pfcp::qfi_t &qfi, smf_qos_flow &q); - void add_qos_flow(smf_qos_flow &flow); + /* + * Find a QoS flow by a PDR ID + * @param [const pfcp::pdr_id_t &] pdr_id: PDR ID + * @param [const smf_qos_flow &] flow: flow to be assigned + * @return bool: Return True if found, otherwise return false + */ + bool get_qos_flow(const pfcp::pdr_id_t &pdr_id, smf_qos_flow &flow); + + /* + * Find a QoS flow by a FAR + * @param [const pfcp::far_id_t &] far_id: FAR ID + * @param [const smf_qos_flow &] flow: flow to be assigned if found + * @return bool: Return True if found, otherwise return false + */ + bool get_qos_flow(const pfcp::far_id_t &far_id, smf_qos_flow &flow); + + /* + * Find a QoS flow by its QFI + * @param [const pfcp::qfi_t &] QFI + * @param [const smf_qos_flow &] flow: flow to be assigned + * @return bool: Return True if found, otherwise return false + */ + bool get_qos_flow(const pfcp::qfi_t &qfi, smf_qos_flow &flow); + + /* + * Add a QoS flow to a PDU Session + * @param [const smf_qos_flow &] flow: Flow to be added + * @return void + */ + void add_qos_flow(const smf_qos_flow &flow); + + /* + * Get all QoS Flows associated with this PDU Session + * @param [std::vector<smf_qos_flow> &] flows: list of Flows associated with this session + * @return void + */ void get_qos_flows(std::vector<smf_qos_flow> &flows); + + /* + * Set a default flow for this PDU Session + * @param [const pfcp::qfi_t &] qfi: Default QFI + * @return void + */ void set_default_qos_flow(const pfcp::qfi_t &qfi); + /* + * Find a QoS flow by its PDR ID + * @param [const pfcp::pdr_id_t &] pdr_id: PDR ID + * @param [smf_qos_flow &] flow: Flow to be returned if found + * @return bool: return true if a flow is found, otherwise false + */ bool find_qos_flow(const pfcp::pdr_id_t &pdr_id, smf_qos_flow &flow); - bool has_qos_flow(const pfcp::pdr_id_t &pdr_id, pfcp::qfi_t &qfi); + + /* + * Remove a QoS flow identified by its QFI + * @param [const pfcp::qfi_t &] qfi: QFI of the flow to be removed + * @return void + */ void remove_qos_flow(const pfcp::qfi_t &qfi); + + /* + * Remove a QoS flow + * @param [smf_qos_flow &] flow: flow to be removed + * @return void + */ void remove_qos_flow(smf_qos_flow &flow); + /* + * Set current status of PDU Session + * @param [const pdu_session_status_e &] status: status to be set + * @return void + */ void set_pdu_session_status(const pdu_session_status_e &status); + + /* + * Get current status of PDU Session + * @param void + * @return pdu_session_status_e: status of PDU session + */ pdu_session_status_e get_pdu_session_status() const; /* @@ -170,29 +258,92 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { // when removing them from a collection, so that is why actually the deallocation of resources is not done in the destructor of objects. void deallocate_ressources(const std::string &apn); + /* + * Represent PDU Session as string to be printed + * @param void + * @return void + */ std::string toString() const; + /* + * Generate a SEID to be used to communicate with UPF + * @param void + * @return void + */ void generate_seid(); + + /* + * Set a value to SEID + * @param [const uint64_t &] seid: value to be set + * @return void + */ void set_seid(const uint64_t &seid); + + /* + * Generate a PDR ID + * @param [pfcp::pdr_id_t &]: pdr_id: PDR ID generated + * @return void + */ void generate_pdr_id(pfcp::pdr_id_t &pdr_id); + + /* + * Release a PDR ID + * @param [const pfcp::pdr_id_t &]: pdr_id: PDR ID to be released + * @return void + */ void release_pdr_id(const pfcp::pdr_id_t &pdr_id); + + /* + * Generate a FAR ID + * @param [pfcp::far_id_t &]: far_id: FAR ID generated + * @return void + */ void generate_far_id(pfcp::far_id_t &far_id); + + /* + * Release a FAR ID + * @param [const pfcp::far_id_t &]: far_id: FAR ID to be released + * @return void + */ void release_far_id(const pfcp::far_id_t &far_id); - void insert_procedure(smf_procedure *proc); + /* + * Generate a QoS Rule ID + * @param [uint8_t &]: rule_id: QoS Rule ID generated + * @return void + */ void generate_qos_rule_id(uint8_t &rule_id); + + /* + * Release a QoS Rule ID + * @param [uint8_t &]: rule_id: QoS Rule ID to be released + * @return void + */ void release_qos_rule_id(const uint8_t &rule_id); + + /* + * Mark a QoS Rule to be synchronised with UE + * @param [uint8_t ]: rule_id: QoS Rule ID to be synchronised with UE + * @return void + */ void mark_qos_rule_to_be_synchronised(uint8_t rule_id); - void get_qos_rules_to_be_synchronised(std::vector<QOSRulesIE> &qos_rules) const; + + /* + * Get all QoS Rules to be synchronised with UE + * @param [std::vector<QOSRulesIE> &]: qos_rules: List of QoS Rules to be synchronised with UE + * @return void + */ + void get_qos_rules_to_be_synchronised( + std::vector<QOSRulesIE> &qos_rules) const; /* * Get list of QoS rules associated with a given QFI - * @param [pfcp::qfi_t] qfi + * @param [pfcp::qfi_t &] qfi * @param [std::vector<QOSRulesIE> &] rules * @void */ - void get_qos_rules(pfcp::qfi_t qfi, - std::vector<QOSRulesIE> &rules) const; + void get_qos_rules(const pfcp::qfi_t &qfi, + std::vector<QOSRulesIE> &rules) const; /* * Get default QoS Rule associated with this PDU Session @@ -200,10 +351,34 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { * @void */ bool get_default_qos_rule(QOSRulesIE &qos_rule) const; + + /* + * Get QoS Rule with Rule ID + * @param [uint8_t] rule_id: Rule ID + * @param [QOSRulesIE &] qos_rule + * @return bool: Return true if Rule exist, otherwise return false + */ bool get_qos_rule(uint8_t rule_id, QOSRulesIE &qos_rule) const; - void update_qos_rule(QOSRulesIE qos_rule); - void add_qos_rule(QOSRulesIE qos_rule); + /* + * Update QoS Rule + * @param [QOSRulesIE &] qos_rule + * @void + */ + void update_qos_rule(const QOSRulesIE &qos_rule); + + /* + * Add a QoS Rule + * @param [QOSRulesIE &] qos_rule + * @void + */ + void add_qos_rule(const QOSRulesIE &qos_rule); + + /* + * Get PDN Type of this PDU session + * @param void + * @return pdn_type_t: PDN Type + */ pdn_type_t get_pdn_type() const; bool ipv4; // IP Address(es): IPv4 address and/or IPv6 prefix @@ -227,25 +402,21 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { uint32_t pdu_session_id; std::string amf_id; - // QFI <-> QoS Flow - std::map<uint8_t, smf_qos_flow> qos_flows; + std::map<uint8_t, smf_qos_flow> qos_flows; // QFI <-> QoS Flow pfcp::qfi_t default_qfi; - // QRI <-> QoS Rules - std::map<uint8_t, QOSRulesIE> qos_rules; + 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; timer_id_t timer_T3590; timer_id_t timer_T3591; timer_id_t timer_T3592; - //N3 tunnel status (ACTIVATED, DEACTIVATED, ACTIVATING) - upCnx_state_e upCnx_state; + upCnx_state_e upCnx_state; //N3 tunnel status (ACTIVATED, DEACTIVATED, ACTIVATING) //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) //TODO: Integrity protection maximum data rate (section 9.11.4.7@@3GPP TS 24.501 V16.1.0) - //number_of_supported_packet_filters - uint8_t number_of_supported_packet_filters; + uint8_t number_of_supported_packet_filters; //number_of_supported_packet_filters util::uint_generator<uint32_t> qos_rule_id_generator; }; @@ -257,14 +428,27 @@ class session_management_subscription { single_nssai(snssai), dnn_configurations() { } + + /* + * Insert a DNN configuration into the subscription + * @param [std::string] dnn + * @param [std::shared_ptr<dnn_configuration_t> &] dnn_configuration + * @return void + */ void insert_dnn_configuration( std::string dnn, std::shared_ptr<dnn_configuration_t> &dnn_configuration); + + /* + * Find a DNN configuration + * @param [std::string] dnn + * @param [std::shared_ptr<dnn_configuration_t> &] dnn_configuration + * @return void + */ void find_dnn_configuration( std::string dnn, std::shared_ptr<dnn_configuration_t> &dnn_configuration); private: snssai_t single_nssai; - //dnn <->dnn_configuration - std::map<std::string, std::shared_ptr<dnn_configuration_t>> dnn_configurations; + std::map<std::string, std::shared_ptr<dnn_configuration_t>> dnn_configurations; //dnn <->dnn_configuration }; /* @@ -292,26 +476,41 @@ class dnn_context { } dnn_context(dnn_context &b) = delete; - /* Find the PDU Session */ + /* + * Find a PDU Session by its ID + * @param [const uint32_t] pdu_session_id + * @param [std::shared_ptr<smf_pdu_session> &] pdu_session + * @return bool: return true if pdu session is found, otherwise, return false + */ bool find_pdu_session(const uint32_t pdu_session_id, std::shared_ptr<smf_pdu_session> &pdu_session); - //void create_or_update_qos_rule(QOSRulesIE &qos_rule, pfcp::qfi_t qfi, - // pdu_session_id_t pdu_id); - - /* Insert a PDU Session into the DNN context */ + /* + * Insert a PDU Session into the DNN context + * @param [std::shared_ptr<smf_pdu_session> &] sp: shared pointer to a PDU Session + * @return void + */ void insert_pdu_session(std::shared_ptr<smf_pdu_session> &sp); - /* get number of pdu sessions associated with this context (dnn and Nssai) */ + + /* + * Get number of pdu sessions associated with this context (dnn and Nssai) + * @param void + * @return size_t: number of PDU sessions + */ size_t get_number_pdu_sessions(); + /* + * Represent DNN Context as a string object + * @param void + * @return void + */ std::string toString() const; bool in_use; std::string dnn_in_use; // The APN currently used, as received from the SGW. - //ambr_t apn_ambr; // APN AMBR: The maximum aggregated uplink and downlink MBR values to be shared across all Non-GBR bearers, which are established for this APN. + //ambr_t apn_ambr; // APN AMBR: The maximum aggregated uplink and downlink MBR values to be shared across all Non-GBR bearers, which are established for this APN. snssai_t nssai; - /* Store all PDU Sessions associated with this DNN context */ - std::vector<std::shared_ptr<smf_pdu_session>> pdu_sessions; + std::vector<std::shared_ptr<smf_pdu_session>> pdu_sessions; //Store all PDU Sessions associated with this DNN context mutable std::recursive_mutex m_context; }; @@ -333,20 +532,58 @@ class smf_context : public std::enable_shared_from_this<smf_context> { smf_context(smf_context &b) = delete; + /* + * Insert a procedure to be processed + * @param [std::shared_ptr<smf_procedure> &] sproc: procedure to be processed + * @return void + */ void insert_procedure(std::shared_ptr<smf_procedure> &sproc); + + /* + * Find a with its transaction ID + * @param [const uint64_t &] trxn_id: Transaction ID + * @param [std::shared_ptr<smf_procedure> &] proc: Stored procedure if found + * @return void + */ bool find_procedure(const uint64_t &trxn_id, std::shared_ptr<smf_procedure> &proc); + + /* + * Remove a procedure from the list + * @param [smf_procedure *] sproc: procedure to be removed + * @return void + */ void remove_procedure(smf_procedure *proc); #define IS_FIND_PDN_WITH_LOCAL_TEID true #define IS_FIND_PDN_WITH_PEER_TEID false - bool find_pdu_session(const pfcp::pdr_id_t &pdr_id, - std::shared_ptr<smf_pdu_session> &pdn, ebi_t &ebi); - + /* + * Handle N4 message (session establishment response) from UPF + * @param [itti_n4_session_establishment_responset&] + * @return void + */ void handle_itti_msg(itti_n4_session_establishment_response&); + + /* + * Handle N4 message (session modification response) from UPF + * @param [itti_n4_session_modification_response&] + * @return void + */ void handle_itti_msg(itti_n4_session_modification_response&); + + /* + * Handle N4 message (session deletion response) from UPF + * @param [itti_n4_session_deletion_response&] + * @return void + */ void handle_itti_msg(itti_n4_session_deletion_response&); + + /* + * Handle N4 message (session report) from UPF + * @param [itti_n4_session_report_request&] + * @return void + */ void handle_itti_msg(std::shared_ptr<itti_n4_session_report_request>&); /* @@ -373,6 +610,11 @@ class smf_context : public std::enable_shared_from_this<smf_context> { void handle_pdu_session_release_sm_context_request( std::shared_ptr<itti_n11_release_sm_context_request> smreq); + /* + * Handle network-requested session modification (SMF, AN, AMF -requested) + * @param [std::shared_ptr<itti_nx_trigger_pdu_session_modification] msg: Request message + * @return void + */ void handle_pdu_session_modification_network_requested( std::shared_ptr<itti_nx_trigger_pdu_session_modification> msg); @@ -457,7 +699,19 @@ class smf_context : public std::enable_shared_from_this<smf_context> { * @return std::size_t: the number of contexts */ std::size_t get_number_dnn_contexts(); - void set_scid(scid_t const &id); + + /* + * Set SM Context ID + * @param [const scid_t &] id: SM Context Id + * @return void + */ + void set_scid(const scid_t &id); + + /* + * Get SM Context ID + * @param [void + * @return scid_t: SM Context Id + */ scid_t get_scid() const; /* @@ -467,13 +721,34 @@ class smf_context : public std::enable_shared_from_this<smf_context> { */ void get_default_qos_rule(QOSRulesIE &qos_rule, uint8_t pdu_session_type); + /* + * Get the default QoS Flow Description, according to PDU session type and QFI + * @param [QOSFlowDescriptionsContents &] qos_flow_description + * @param [uint8_t] pdu_session_type: PDU Session Type + * @param [const pfcp::qfi_t &] qfi + * @return void + */ void get_default_qos_flow_description( QOSFlowDescriptionsContents &qos_flow_description, - uint8_t pdu_session_type, - const pfcp::qfi_t &qfi); + uint8_t pdu_session_type, const pfcp::qfi_t &qfi); + /* + * Get the default value of Session-AMBR + * @param [SessionAMBR &] session_ambr + * @param [const snssai_t &] snssai + * @param [const std::string &] dnn + * @return void + */ void get_session_ambr(SessionAMBR &session_ambr, const snssai_t &snssai, const std::string &dnn); + + /* + * Get the default value of Session-AMBR and stored as Ngap_PDUSessionAggregateMaximumBitRate + * @param [Ngap_PDUSessionAggregateMaximumBitRate_t &] session_ambr + * @param [const snssai_t &] snssai + * @param [const std::string &] dnn + * @return void + */ void get_session_ambr(Ngap_PDUSessionAggregateMaximumBitRate_t &session_ambr, const snssai_t &snssai, const std::string &dnn); @@ -484,26 +759,13 @@ class smf_context : public std::enable_shared_from_this<smf_context> { 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. - // selected_cn_operator_id // Selected core network operator identity (to support networksharing as defined in TS 23.251 - // NOT IMPLEMENTED RAT type Current RAT (implicit) - // NOT IMPLEMENTED Trace reference // Identifies a record or a collection of records for a particular trace. - // NOT IMPLEMENTED Trace type // Indicates the type of trace - // NOT IMPLEMENTED Trigger id // Identifies the entity that initiated the trace - // NOT IMPLEMENTED OMC identity // Identifies the OMC that shall receive the trace record(s). - - //-------------------------------------------- - // internals 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; - }; } diff --git a/src/smf_app/smf_msg.cpp b/src/smf_app/smf_msg.cpp index 462a139b303a51ef3ddabf0378637046d3242d6e..b4430ca8793f216d26b024f56971af7f278721d5 100644 --- a/src/smf_app/smf_msg.cpp +++ b/src/smf_app/smf_msg.cpp @@ -228,16 +228,6 @@ std::string pdu_session_create_sm_context_request::get_dnn_selection_mode() cons return m_dnn_selection_mode; } -//----------------------------------------------------------------------------- -ipmdr_t pdu_session_create_sm_context_request::get_ipmdr() const { - return m_ipmdr; -} - -//----------------------------------------------------------------------------- -void pdu_session_create_sm_context_request::set_ipmdr(ipmdr_t const &ipmdr) { - m_ipmdr = ipmdr; -} - //----------------------------------------------------------------------------- void pdu_session_create_sm_context_response::set_cause(uint8_t cause) { m_cause = cause; @@ -326,48 +316,48 @@ std::string pdu_session_create_sm_context_response::get_amf_url() const { } //----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_request::get_n2_sm_information() const { +std::string pdu_session_update_sm_context::get_n2_sm_information() const { return m_n2_sm_information; } //----------------------------------------------------------------------------- -void pdu_session_update_sm_context_request::set_n2_sm_information( +void pdu_session_update_sm_context::set_n2_sm_information( std::string const &value) { m_n2_sm_information = value; m_n2_sm_info_is_set = true; } //----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_request::get_n2_sm_info_type() const { +std::string pdu_session_update_sm_context::get_n2_sm_info_type() const { return m_n2_sm_info_type; } //----------------------------------------------------------------------------- -void pdu_session_update_sm_context_request::set_n2_sm_info_type( +void pdu_session_update_sm_context::set_n2_sm_info_type( std::string const &value) { m_n2_sm_info_type = value; m_n2_sm_info_is_set = true; } //----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_request::get_n1_sm_message() const { +std::string pdu_session_update_sm_context::get_n1_sm_message() const { return m_n1_sm_message; } //----------------------------------------------------------------------------- -void pdu_session_update_sm_context_request::set_n1_sm_message( +void pdu_session_update_sm_context::set_n1_sm_message( std::string const &value) { m_n1_sm_message = value; m_n1_sm_msg_is_set = true; } //----------------------------------------------------------------------------- -bool pdu_session_update_sm_context_request::n1_sm_msg_is_set() const { +bool pdu_session_update_sm_context::n1_sm_msg_is_set() const { return m_n1_sm_msg_is_set; } //----------------------------------------------------------------------------- -bool pdu_session_update_sm_context_request::n2_sm_info_is_set() const { +bool pdu_session_update_sm_context::n2_sm_info_is_set() const { return m_n2_sm_info_is_set; } @@ -457,63 +447,6 @@ uint8_t pdu_session_update_sm_context_response::get_cause() { return m_cause; } -//----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_response::get_n2_sm_information() const { - return m_n2_sm_information; -} - -//----------------------------------------------------------------------------- -void pdu_session_update_sm_context_response::set_n2_sm_information( - std::string const &value) { - m_n2_sm_information = value; -} - -//----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_response::get_n2_sm_info_type() const { - return n2_sm_info_type; -} - -//----------------------------------------------------------------------------- -void pdu_session_update_sm_context_response::set_n2_sm_info_type( - std::string const &value) { - n2_sm_info_type = value; - m_n2_sm_info_is_set = true; -} - -//----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_response::get_n1_sm_message() const { - return m_n1_sm_message; -} - -//----------------------------------------------------------------------------- -void pdu_session_update_sm_context_response::set_n1_sm_message( - std::string const &value) { - m_n1_sm_message = value; - m_n1_sm_msg_is_set = true; -} - -//----------------------------------------------------------------------------- -std::string pdu_session_update_sm_context_response::get_n1_sm_msg_type() const { - return n2_sm_info_type; -} - -//----------------------------------------------------------------------------- -void pdu_session_update_sm_context_response::set_n1_sm_msg_type( - std::string const &value) { - n2_sm_info_type = value; - m_n2_sm_info_is_set = true; -} - -//----------------------------------------------------------------------------- -bool pdu_session_update_sm_context_response::n1_sm_msg_is_set() const { - return m_n1_sm_msg_is_set; -} - -//----------------------------------------------------------------------------- -bool pdu_session_update_sm_context_response::n2_sm_info_is_set() const { - return m_n2_sm_info_is_set; -} - //----------------------------------------------------------------------------- void pdu_session_update_sm_context_response::add_qos_flow_context_updated( const qos_flow_context_updated &flow) { diff --git a/src/smf_app/smf_msg.hpp b/src/smf_app/smf_msg.hpp index a6a863df3143b088cc9aa8bfc55fabc8ea6352cd..bed7bc9fe4f0742114b1f3a4fc22047f382c8d02 100644 --- a/src/smf_app/smf_msg.hpp +++ b/src/smf_app/smf_msg.hpp @@ -68,7 +68,6 @@ class qos_flow_context_updated { qfi(), ul_fteid(), dl_fteid(), - // qos_rule(), qos_profile(), to_be_removed(false) { } @@ -84,7 +83,6 @@ class qos_flow_context_updated { pfcp::qfi_t qfi; fteid_t ul_fteid; fteid_t dl_fteid; - // QOSRulesIE qos_rule; std::map<uint8_t, QOSRulesIE> qos_rules; qos_profile_t qos_profile; bool to_be_removed; @@ -127,28 +125,20 @@ class pdu_session_msg { pdu_session_msg_type_t get_msg_type() const; void set_msg_type(pdu_session_msg_type_t const &value); - supi_t get_supi() const; void set_supi(supi_t const &value); - std::string get_supi_prefix() const; void set_supi_prefix(std::string const &value); - pdu_session_id_t get_pdu_session_id() const; void set_pdu_session_id(pdu_session_id_t const value); - std::string get_dnn() const; void set_dnn(std::string const &value); - snssai_t get_snssai() const; void set_snssai(snssai_t const &value); - void set_api_root(std::string const &value); std::string get_api_root() const; - uint8_t get_pdu_session_type() const; void set_pdu_session_type(uint8_t const &pdu_session_type); - procedure_transaction_id_t get_pti() const; void set_pti(procedure_transaction_id_t const &pti); @@ -193,7 +183,6 @@ class pdu_session_create_sm_context : public pdu_session_msg { extended_protocol_discriminator_t get_epd() const; void set_epd(extended_protocol_discriminator_t const &epd); - uint8_t get_message_type() const; void set_message_type(uint8_t const &message_type); @@ -222,19 +211,13 @@ class pdu_session_create_sm_context_request : std::string get_n1_sm_message() const; void set_n1_sm_message(std::string const &value); - std::string get_serving_nf_id() const; void set_serving_nf_id(std::string const &value); - std::string get_request_type() const; void set_request_type(std::string const &value); - void set_dnn_selection_mode(std::string const &value); std::string get_dnn_selection_mode() const; - ipmdr_t get_ipmdr() const; - void set_ipmdr(ipmdr_t const &ipmdr); - private: std::string m_n1_sm_message; //N1 SM Message before decoding bool m_unauthenticated_supi; @@ -244,63 +227,6 @@ class pdu_session_create_sm_context_request : std::string m_presence_in_ladn; std::string m_an_type; std::string m_dnn_selection_mode; //SelMode - //std::string m_Pei; - //std::string m_Gpsi; - //Snssai m_HplmnSnssai; - //Guami m_Guami; - //std::string m_ServiceName; - //PlmnId m_ServingNetwork; - //RefToBinaryData m_N1SmMsg; - //std::string m_SecondAnType; - //UserLocation m_UeLocation; - //std::string m_UeTimeZone; - //UserLocation m_AddUeLocation; - //std::string m_SmContextStatusUri; - //std::string m_HSmfUri; - // std::vector<std::string> m_AdditionalHsmfUri; - // int32_t m_OldPduSessionId; - // std::vector<int32_t> m_PduSessionsActivateList; - //std::string m_UeEpsPdnConnection; - //std::string m_HoState; - //std::string m_PcfId; - //std::string m_NrfUri; - //std::string m_SupportedFeatures; - //std::vector<BackupAmfInfo> m_BackupAmfInfo; - //TraceData m_TraceData; - //std::string m_UdmGroupId; - //std::string m_RoutingIndicator; - //EpsInterworkingIndication m_EpsInterworkingInd; - //bool m_IndirectForwardingFlag; - //NgRanTargetId m_TargetId; - //std::string m_EpsBearerCtxStatus; - //bool m_CpCiotEnabled; - //bool m_InvokeNef; - // bool m_MaPduIndication; - //RefToBinaryData m_N2SmInfo; - //std::string m_SmContextRef; - - //NAS - //Extended protocol discriminator (Mandatory) - // extended_protocol_discriminator_t m_epd;//defined in pdu_session_create_sm_context - //PDU session ID (Mandatory) - //TODO: need to check with PDU_session_id from outside of NAS?? - //PTI (Mandatory) - //procedure_transaction_id_t m_pti; ////defined in pdu_session_create_sm_context - //Message type (Mandatory) (PDU SESSION ESTABLISHMENT REQUEST message identity) - // uint8_t m_message_type; //defined in pdu_session_create_sm_context - //Integrity protection maximum data rate (Mandatory) - ipmdr_t m_ipmdr; - //PDU session type (Optional) - //uint8_t m_pdu_session_type; //defined in pdu_session_create_sm_context - - //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 - }; //--------------------------------------------------------------------------------------- @@ -362,28 +288,6 @@ class pdu_session_create_sm_context_response : supi_t m_supi; std::string m_supi_prefix; std::string amf_url; - - /* PDU Session establishment accept - ExtendedProtocolDiscriminator extendedprotocoldiscriminator; - PDUSessionIdentity pdusessionidentity; - ProcedureTransactionIdentity proceduretransactionidentity; - MessageType messagetype; - _PDUSessionType _pdusessiontype; - SSCMode sscmode; - QOSRules qosrules; - SessionAMBR sessionambr; - uint16_t presence; - _5GSMCause _5gsmcause; - PDUAddress pduaddress; - GPRSTimer gprstimer; - SNSSAI snssai; - AlwaysonPDUSessionIndication alwaysonpdusessionindication; - MappedEPSBearerContexts mappedepsbearercontexts; - EAPMessage eapmessage; - QOSFlowDescriptions qosflowdescriptions; - ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions; - DNN dnn; - */ }; //--------------------------------------------------------------------------------------- @@ -393,31 +297,42 @@ class pdu_session_update_sm_context : public pdu_session_msg { pdu_session_update_sm_context() : pdu_session_msg() { + m_n1_sm_msg_is_set = false; + m_n2_sm_info_is_set = false; } ; pdu_session_update_sm_context(pdu_session_msg_type_t msg_type) : pdu_session_msg(msg_type) { + m_n1_sm_msg_is_set = false; + m_n2_sm_info_is_set = false; } ; - pdu_session_update_sm_context(pdu_session_msg_type_t msg_type, supi_t supi, - pdu_session_id_t pdi, std::string dnn, - snssai_t snssai) - : - pdu_session_msg(msg_type, supi, pdi, dnn, snssai) { - } - private: + std::string get_n2_sm_information() const; + void set_n2_sm_information(std::string const &value); + std::string get_n2_sm_info_type() const; + void set_n2_sm_info_type(std::string const &value); + std::string get_n1_sm_message() const; + void set_n1_sm_message(std::string const &value); + bool n1_sm_msg_is_set() const; + bool n2_sm_info_is_set() const; + + private: + std::string m_n1_sm_message; //N1 SM message before decoding + bool m_n1_sm_msg_is_set; + std::string m_n2_sm_information; //N2 SM before decoding + bool m_n2_sm_info_is_set; + std::string m_n2_sm_info_type; }; //see SmContextUpdateData (TS29502_Nsmf_PDUSession.yaml) -class pdu_session_update_sm_context_request : public pdu_session_msg { +class pdu_session_update_sm_context_request : + public pdu_session_update_sm_context { public: pdu_session_update_sm_context_request() : - pdu_session_msg(PDU_SESSION_UPDATE_SM_CONTEXT_REQUEST) { - m_n1_sm_msg_is_set = false; - m_n2_sm_info_is_set = false; + pdu_session_update_sm_context(PDU_SESSION_UPDATE_SM_CONTEXT_REQUEST) { m_5gMm_cause_value = 0; m_data_forwarding = false; m_upCnx_state_is_set = false; @@ -427,18 +342,9 @@ class pdu_session_update_sm_context_request : public pdu_session_msg { m_release_is_set = false; m_an_type_is_set = false; m_rat_type_is_set = false; -// m_eps_bearer_setup = {}; -// m_revoke_ebi_list = {}; } ; - std::string get_n2_sm_information() const; - void set_n2_sm_information(std::string const &value); - std::string get_n2_sm_info_type() const; - void set_n2_sm_info_type(std::string const &value); - std::string get_n1_sm_message() const; - void set_n1_sm_message(std::string const &value); - bool n1_sm_msg_is_set() const; - bool n2_sm_info_is_set() const; + void add_qfi(pfcp::qfi_t const &qfi); void add_qfi(uint8_t const &qfi); void get_qfis(std::vector<pfcp::qfi_t> &q); @@ -454,14 +360,8 @@ class pdu_session_update_sm_context_request : public pdu_session_msg { void set_release(bool const value); private: - std::vector<pfcp::qfi_t> qfis; fteid_t dl_fteid; //AN Tunnel Info - std::string m_n1_sm_message; //N1 SM message before decoding - bool m_n1_sm_msg_is_set; - std::string m_n2_sm_information; //N2 SM before decoding - bool m_n2_sm_info_is_set; - std::string m_n2_sm_info_type; std::string m_nf_instanceId; std::string m_an_type; bool m_an_type_is_set; @@ -472,78 +372,35 @@ class pdu_session_update_sm_context_request : public pdu_session_msg { std::string m_target_serving_nfId; std::string m_sm_context_status_uri; bool m_data_forwarding; -// std::vector<std::string> m_eps_bearer_setup; -// std::vector<int> m_revoke_ebi_list; uint8_t m_5gMm_cause_value; bool m_release_is_set; bool m_release; - //oai::smf_server::model::NgRanTargetId m_target_id; - //oai::smf_server::model::Guami m_guami; - //oai::smf_server::model::PlmnId m_serving_network; - //NgApCause m_ngAp_cause; - //BackupAmfInfo - //std::string m_Ppei; - - /* - SmContextUpdateData - presenceInLadn - ueLocation - ueTimeZone - addUeLocation - hoState - toBeSwitched - failedToBeSwitched - sNssai - EpsBearerId - cause - traceData - epsInterworkingInd - anTypeCanBeChanged - n2SmInfoExt1 - n2SmInfoTypeExt1 - maReleaseInd - exemptionInd - */ - }; //--------------------------------------------------------------------------------------- //for PDU session update response -class pdu_session_update_sm_context_response : public pdu_session_msg { +class pdu_session_update_sm_context_response : + public pdu_session_update_sm_context { public: pdu_session_update_sm_context_response() : - pdu_session_msg(PDU_SESSION_UPDATE_SM_CONTEXT_RESPONSE) { + pdu_session_update_sm_context(PDU_SESSION_UPDATE_SM_CONTEXT_RESPONSE) { m_cause = 0; - m_n1_sm_msg_is_set = false; - m_n2_sm_info_is_set = false; qos_flow_context_updateds = { }; } ; pdu_session_update_sm_context_response(pdu_session_msg_type_t type) : - pdu_session_msg(type) { + pdu_session_update_sm_context(type) { m_cause = 0; - m_n1_sm_msg_is_set = false; - m_n2_sm_info_is_set = false; qos_flow_context_updateds = { }; } ; void set_cause(uint8_t cause); uint8_t get_cause(); - std::string get_n2_sm_information() const; - void set_n2_sm_information(std::string const &value); - std::string get_n2_sm_info_type() const; - void set_n2_sm_info_type(std::string const &value); - std::string get_n1_sm_message() const; - void set_n1_sm_message(std::string const &value); - std::string get_n1_sm_msg_type() const; - void set_n1_sm_msg_type(std::string const &value); - bool n1_sm_msg_is_set() const; - bool n2_sm_info_is_set() const; void add_qos_flow_context_updated(const qos_flow_context_updated &qos_flow); bool get_qos_flow_context_updated(const pfcp::qfi_t &qfi, qos_flow_context_updated &qos_flow); @@ -554,12 +411,6 @@ class pdu_session_update_sm_context_response : public pdu_session_msg { private: uint8_t m_cause; - std::string m_n1_sm_message; //N1 SM after decoding - bool m_n1_sm_msg_is_set; - std::string n1_sm_msg_type; - std::string m_n2_sm_information; //N2 SM after decoding - bool m_n2_sm_info_is_set; - std::string n2_sm_info_type; std::map<uint8_t, qos_flow_context_updated> qos_flow_context_updateds; }; diff --git a/src/smf_app/smf_n10.cpp b/src/smf_app/smf_n10.cpp index baf97abce96e1def861779fb4cd228c6174ad9c3..c33658c34650b8fd6ee106eaccfe6be3367b2248 100644 --- a/src/smf_app/smf_n10.cpp +++ b/src/smf_app/smf_n10.cpp @@ -102,11 +102,6 @@ smf_n10::smf_n10() { Logger::smf_n10().startup("Started"); } -//------------------------------------------------------------------------------ -void smf_n10::handle_receive_sm_data_notification() { - //TODO: -} - //------------------------------------------------------------------------------ bool smf_n10::get_sm_data( supi64_t &supi, std::string &dnn, snssai_t &snssai, diff --git a/src/smf_app/smf_n10.hpp b/src/smf_app/smf_n10.hpp index 67a770bece886605f69e998db6daed31c716ca3b..f7aed3438976b30d3c6d123df33def9512358dd6 100644 --- a/src/smf_app/smf_n10.hpp +++ b/src/smf_app/smf_n10.hpp @@ -43,8 +43,6 @@ class smf_n10 { std::thread::id thread_id; std::thread thread; - void handle_receive_sm_data_notification(); - public: smf_n10(); smf_n10(smf_n10 const&) = delete; diff --git a/src/smf_app/smf_n11.hpp b/src/smf_app/smf_n11.hpp index c744468c382c0f354656485499a2d059f9d83ab1..753a18b30b83b3424b6068d2f2cc767e774f42a7 100644 --- a/src/smf_app/smf_n11.hpp +++ b/src/smf_app/smf_n11.hpp @@ -46,8 +46,6 @@ class smf_n11 { std::thread::id thread_id; std::thread thread; - void handle_receive_sm_data_notification(); - public: smf_n11(); smf_n11(smf_n11 const&) = delete; diff --git a/src/smf_app/smf_procedure.cpp b/src/smf_app/smf_procedure.cpp index 11bdaf3e8b70bf242879d75d12db44869f528153..ff4af745a4eed5619788dce7695a5709b95764e8 100644 --- a/src/smf_app/smf_procedure.cpp +++ b/src/smf_app/smf_procedure.cpp @@ -863,7 +863,7 @@ int session_update_sm_context_procedure::run( } //update in the PDU Session - flow.release_qos_flow(); + flow.mark_as_released(); smf_qos_flow flow2 = flow; sps->add_qos_flow(flow2); }