Commit 1def2e1f authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

update dnn/apn context

parent 05817c02
......@@ -96,7 +96,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//User Location Information
//Access Type
// PEI
//GPSI
// GPSI
// UE presence in LADN service area
// DNN Selection Mode
sm_context_req_msg.set_dnn_selection_mode(smContextCreateData.getSelMode());
......@@ -115,7 +115,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//sm_context_req_msg->set_message_type(decoded_nas_msg.plain.sm.pdu_session_establishment_request.messagetype);
//Logger::smf_api_server().debug("nas decode messaget type %d\n",
// decoded_nas_msg.plain.sm.pdu_session_establishment_request.messagetype);
sm_context_req_msg.set_message_type (PDU_SESSION_ESTABLISHMENT_REQUEST); //Temporary - should be removed
sm_context_req_msg.set_message_type (PDU_SESSION_ESTABLISHMENT_REQUEST); //Temporary - should be removed (get from NAS)
//Integrity protection maximum data rate (Mandatory)
//PDU session type (Optional)
sm_context_req_msg.set_pdu_session_type(PDN_TYPE_E_IPV4);//TODO: should get from NAS msg
......
......@@ -313,7 +313,7 @@ void pgw_app::handle_itti_msg (itti_n4_session_deletion_response& smresp)
if (seid_2_pgw_context(smresp.seid, pc)) {
pc.get()->handle_itti_msg(smresp);
if (pc->apns.size() == 0) {
if (pc->dnns.size() == 0) {
delete_pgw_context(pc);
}
} else {
......@@ -336,12 +336,7 @@ void pgw_app::handle_itti_msg (std::shared_ptr<itti_n4_session_report_request> s
//------------------------------------------------------------------------------
void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request> smreq)
{
//handle PDU Session Create SM Context Request as specified in section 4.3.2 3GPP TS 23.502
pdu_session_create_sm_context_request sm_context_req_msg = smreq->req;
oai::smf::model::SmContextCreateError smContextCreateError;
oai::smf::model::ProblemDetails problem_details;
......@@ -363,6 +358,7 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
Logger::pgwc_app().warn(" Invalid PTI value (pti = %d)\n", pti.procedure_transaction_id);
problem_details.setCause(pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR]);
smContextCreateError.setError(problem_details);
//TODO: to be completed when finishing NAS implementation
//create a PDU Session Establishment Response by relying on NAS and assign to smContextCeateError.m_N1SmMsg
//TODO: (24.501 (section 7.3.1)) NAS N1 SM message: response with a 5GSM STATUS message including cause "#81 Invalid PTI value"
//Send response to AMF
......@@ -382,6 +378,7 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
//TODO:
problem_details.setCause(pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR]);
smContextCreateError.setError(problem_details);
//TODO: to be completed when finishing NAS implementation
//create a PDU Session Establishment Response by relying on NAS and assign to smContextCeateError.m_N1SmMsg
//TODO: (24.501 (section 7.4)) implementation dependent->do similar to UE: response with a 5GSM STATUS message including cause "#98 message type not compatible with protocol state."
//Send response to AMF
......@@ -392,15 +389,16 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
if ((request_type & 0x07) != INITIAL_REQUEST){
Logger::pgwc_app().warn("Invalid request type (request type = %s)\n", request_type_e2str[request_type & 0x07]);
//TODO:
//return
}
//Step 2. check if the DNN requested is valid
if (not smf_cfg.is_dotted_dnn_handled(dnn, pdu_session_type)) {
// Not a valid request...
Logger::pgwc_app().warn("Received PDU_SESSION_CREATESMCONTEXT_REQUEST unknown requested APN %s, ignore message!", dnn.c_str());
problem_details.setCause(pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_DNN_DENIED]);
smContextCreateError.setError(problem_details);
//TODO: to be completed when finishing NAS implementation
//create a PDU Session Establishment Response by relying on NAS and assign to smContextCeateError.m_N1SmMsg
//Send response to AMF
send_create_session_response(smreq->http_response, smContextCreateError, Pistache::Http::Code::Forbidden);
......@@ -410,10 +408,10 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
//Step 3. create a context for this supi if not existed, otherwise update
std::shared_ptr<pgw_context> sc;
if (is_supi_2_smf_context(supi64)) {
Logger::pgwc_app().debug("Update PGW context\n");
Logger::pgwc_app().debug("Update SMF context with SUPI " SUPI_64_FMT "", supi64);
sc = supi_2_smf_context(supi64);
} else {
Logger::pgwc_app().debug("Create a new PGW context\n");
Logger::pgwc_app().debug("Create a new SMF context with SUPI " SUPI_64_FMT "", supi64);
sc = std::shared_ptr<pgw_context>(new pgw_context());
set_supi_2_smf_context(supi64, sc);
}
......@@ -424,7 +422,7 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
if (!sc.get()->find_dnn_context(dnn, sd)) {
if (nullptr == sd.get()){
//create a new one and insert to the list
Logger::pgwc_app().debug("Create a DNN context and add to the PGW context\n");
Logger::pgwc_app().debug("Create a DNN context and add to the SMF context\n");
sd = std::shared_ptr<dnn_context>(new dnn_context(dnn));
//sd.get()->in_use = true;
sc.get()->insert_dnn(sd);
......@@ -433,7 +431,7 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
// step 4. retrieve Session Management Subscription data from UDM if not available (step 4, section 4.3.2 3GPP TS 23.502)
std::string dnn_selection_mode = smreq->req.get_dnn_selection_mode();
if (not is_use_local_configuration_subscription_data(dnn_selection_mode) && not is_supi_dnn_snssai_subscription_data(supi, dnn, snssai))
if (not use_local_configuration_subscription_data(dnn_selection_mode) && not is_supi_dnn_snssai_subscription_data(supi, dnn, snssai))
{
//uses a dummy UDM to test this part
Logger::pgwc_app().debug("Retrieve Session Management Subscription data from UDM");
......@@ -441,25 +439,19 @@ void pgw_app::handle_amf_msg (std::shared_ptr<itti_n11_create_sm_context_request
if (smf_n10_inst->get_sm_data(supi64, dnn, snssai, subscription)) {
//update dnn_context with subscription info
sc.get()->insert_dnn_subscription(snssai, subscription);
//debug
//dnn_configuration_t dnn_configuration = subscription.get()->get_dnn_configuration(dnn);
//Logger::pgwc_app().debug("Retrieve Session Management Subscription data from UDM %s, %s, %s, %s", pdu_session_type_e2str[dnn_configuration.pdu_session_types.default_session_type.pdu_session_type].c_str(), ssc_mode_e2str[dnn_configuration.ssc_modes.default_ssc_mode.ssc_mode].c_str(), dnn_configuration.session_ambr.uplink.c_str(), dnn_configuration.session_ambr.downlink.c_str());
} else {
// Not accept to establish a PDU session
Logger::pgwc_app().warn("Received PDU_SESSION_CREATESMCONTEXT_REQUEST, couldn't retrieve the Session Management Subscription from UDM, ignore message!");
problem_details.setCause(pdu_session_application_error_e2str[PDU_SESSION_APPLICATION_ERROR_SUBSCRIPTION_DENIED]);
smContextCreateError.setError(problem_details);
//TODO: to be completed when finishing NAS implementation
//create a PDU Session Establishment Response by relying on NAS and assign to smContextCeateError.m_N1SmMsg
//Send response to AMF
send_create_session_response(smreq->http_response, smContextCreateError, Pistache::Http::Code::Forbidden);
return;
}
}
//Step 4. check the validity of the UE request, if valid send PDU Session Accept, otherwise send PDU Session Reject to AMF
//Step 5. let the context handle the message
//in this step, SMF will send N4 Session Establishment/Modification to UPF (step 10a, section 4.3.2 3GPP 23.502)
//SMF, then, sends response to AMF
......@@ -490,7 +482,7 @@ void pgw_app::set_supi_2_smf_context(const supi64_t& supi, std::shared_ptr<pgw_c
}
//------------------------------------------------------------------------------
bool pgw_app::is_use_local_configuration_subscription_data(const std::string& dnn_selection_mode)
bool pgw_app::use_local_configuration_subscription_data(const std::string& dnn_selection_mode)
{
//TODO: should be implemented
return false; //get Session Management Subscription from UDM
......
......@@ -166,7 +166,7 @@ public:
* @param [std::string] dnn_selection_mode
* @return True if SMF uses the local configuration to check the validity of the UE request, False otherwise
*/
bool is_use_local_configuration_subscription_data(const std::string& dnn_selection_mode);
bool use_local_configuration_subscription_data(const std::string& dnn_selection_mode);
/*
* Verify whether the Session Management Data is existed
......
This diff is collapsed.
......@@ -245,40 +245,6 @@ public:
};
class apn_context {
public:
apn_context() : m_context(), in_use(false), pdn_connections() {
apn_ambr = {0};
}
apn_context(apn_context& b) = delete;
void insert_pdn_connection(std::shared_ptr<pgw_pdn_connection>& sp);
bool find_pdn_connection(const teid_t xgw_s5s8c_teid, const bool is_local_teid, std::shared_ptr<pgw_pdn_connection>& pdn);
bool find_pdn_connection(const pfcp::pdr_id_t& pdr_id, std::shared_ptr<pgw_pdn_connection>& pdn, ebi_t& ebi);
void delete_pdn_connection(std::shared_ptr<pgw_pdn_connection>& pdn_connection);
int get_num_pdn_connections() const {return pdn_connections.size();};
// deallocate_ressources is for releasing LTE resources prior to the deletion of objects
// since shared_ptr is actually heavy used for handling objects, deletion of object instances cannot be always guaranteed
// 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();
std::string toString() const;
bool in_use;
std::string apn_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.
// APN Rate Control: The APN-Rate-Control limits the maximum number of uplink/downlink packets and the maximum number of
// additional exception report packets per a specific time unit (e.g. minute, hour, day, week) for this APN. It includes an
// indication as to whether or not Exception reports may still be sent when the limit has been met.
// key is local s5s8 teid
//map<teid_t, shared_ptr<pgw_pdn_connection>> pdn_connections;
std::vector<std::shared_ptr<pgw_pdn_connection>> pdn_connections; // was list
mutable std::recursive_mutex m_context;
};
class session_management_subscription {
public:
session_management_subscription(snssai_t snssai): single_nssai(snssai), dnn_configurations() {}
......@@ -309,6 +275,8 @@ public:
/* Insert a PDN connection into the DNN context */
void insert_pdn_connection(std::shared_ptr<pgw_pdn_connection>& sp);
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.
......@@ -323,14 +291,10 @@ public:
class pgw_context;
typedef std::pair<std::shared_ptr<apn_context>, std::shared_ptr<pgw_pdn_connection>> pdn_duo_t;
typedef std::pair<std::shared_ptr<dnn_context>, std::shared_ptr<pgw_pdn_connection>> dnn_pdn_t;
class pgw_context : public std::enable_shared_from_this<pgw_context> {
public:
pgw_context() : m_context(), imsi(), imsi_unauthenticated_indicator(false), apns(), pending_procedures(), msisdn() {}
pgw_context() : m_context(), imsi(), imsi_unauthenticated_indicator(false), pending_procedures(), msisdn() {}
pgw_context(pgw_context& b) = delete;
......@@ -341,15 +305,7 @@ public:
#define IS_FIND_PDN_WITH_LOCAL_TEID true
#define IS_FIND_PDN_WITH_PEER_TEID false
bool find_pdn_connection(const std::string& apn, const teid_t xgw_s5s8c_teid, const bool is_local_teid, pdn_duo_t& pdn_connection);
bool find_pdn_connection(const teid_t xgw_s5s8c_teid, const bool is_local_teid, pdn_duo_t& pdn_connection);
bool find_pdn_connection(const pfcp::pdr_id_t& pdr_id, std::shared_ptr<pgw_pdn_connection>& pdn, ebi_t& ebi);
void insert_apn(std::shared_ptr<apn_context>& sa);
bool find_apn_context(const std::string& apn, std::shared_ptr<apn_context>& apn_context);
int get_num_apn_contexts() {return apns.size();};
void delete_apn_context(std::shared_ptr<apn_context>& sa);
void delete_pdn_connection(std::shared_ptr<apn_context>& sa , std::shared_ptr<pgw_pdn_connection>& sp);
void handle_itti_msg (itti_n4_session_establishment_response& );
void handle_itti_msg (itti_n4_session_modification_response& );
......@@ -387,17 +343,6 @@ public:
*/
void send_create_session_response_error(oai::smf::model::SmContextCreateError& smContextCreateError, Pistache::Http::Code code, Pistache::Http::ResponseWriter& httpResponse);
/*
* Find DNN connection with APN name and PDU session ID
* @param [const std::string&] dnn
* @param [const uint32_t ] pdu_session_id PDU session ID
* @param [dnn_pdn_t&] pdn_connection pdn connection to be found
* @return void
*/
bool find_pdn_connection(const std::string& dnn, const uint32_t pdu_session_id, dnn_pdn_t& pdn_connection);
bool verify_sm_context_request(std::shared_ptr<itti_n11_create_sm_context_request> smreq);
std::vector<std::shared_ptr<dnn_context>> dnns;
......@@ -417,8 +362,6 @@ public:
// 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).
std::vector<std::shared_ptr<apn_context>> apns; // was list
//--------------------------------------------
// internals
std::vector<std::shared_ptr<smf_procedure>> pending_procedures;
......
......@@ -599,13 +599,11 @@ smf_config::~smf_config()
//------------------------------------------------------------------------------
bool smf_config::is_dotted_dnn_handled(const std::string& dnn, const pdu_session_type_t& pdn_session_type)
{
return true; //test
Logger::pgwc_app().debug( "DNN: %s", dnn.c_str());
Logger::pgwc_app().debug( "requested dnn: %s", dnn.c_str());
for (int i = 0; i < smf_cfg.num_apn; i++) {
Logger::pgwc_app().debug( "apn_label: %s", smf_cfg.apn[i].apn_label.c_str());
if (0 == dnn.compare(smf_cfg.apn[i].apn_label)) {
//if (0 == dnn.compare(smf_cfg.apn[i].apn_label)) {
if (0 == dnn.compare(smf_cfg.apn[i].apn)) {
if (pdn_session_type.pdu_session_type == smf_cfg.apn[i].pdn_type.pdn_type) {
return true;
}
......
......@@ -44,7 +44,6 @@
namespace pgwc {
class apn_context;
class pgw_context;
class pgw_pdn_connection;
......
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