Commit defc70b9 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Handle PFCP Association Release Response from UP function

parent 0767d579
......@@ -277,6 +277,8 @@ void smf_n4::handle_receive_pfcp_msg(pfcp_msg &msg,
case PFCP_ASSOCIATION_UPDATE_RESPONSE:
case PFCP_ASSOCIATION_RELEASE_REQUEST:
case PFCP_ASSOCIATION_RELEASE_RESPONSE:
handle_receive_association_release_response(msg, remote_endpoint);
break;
case PFCP_VERSION_NOT_SUPPORTED_RESPONSE:
case PFCP_NODE_REPORT_REQUEST:
case PFCP_NODE_REPORT_RESPONSE:
......@@ -460,6 +462,8 @@ void smf_n4::handle_receive_association_update_request(
handle_receive_message_cb(msg, remote_endpoint, TASK_SMF_N4, error, trxn_id);
if (error) {
Logger::smf_n4().warn(
"Received N4 ASSOCIATION UPDATE REQUEST, error in handle_receive_message_cb!");
return;
}
......@@ -525,6 +529,53 @@ void smf_n4::handle_receive_association_update_request(
}
//------------------------------------------------------------------------------
void smf_n4::handle_receive_association_release_response(
pfcp::pfcp_msg &msg, const endpoint &remote_endpoint) {
//TODO: To be completed
Logger::smf_n4().info("Received N4 ASSOCIATION RELEASE RESPONSE from an UPF");
bool error = true;
uint64_t trxn_id = 0;
pfcp_association_release_response msg_ies_container = { };
msg.to_core_type(msg_ies_container);
handle_receive_message_cb(msg, remote_endpoint, TASK_SMF_N4, error, trxn_id);
if (error) {
Logger::smf_n4().warn(
"Received N4 ASSOCIATION RELEASE RESPONSE, error in handle_receive_message_cb!");
return;
}
if (not msg_ies_container.node_id.first) {
Logger::smf_n4().warn(
"Received N4 ASSOCIATION RELEASE RESPONSE without node id IE!, ignore message");
return;
}
pfcp::node_id_t node_id = { };
if (smf_cfg.get_pfcp_node_id(node_id) != RETURNok) {
Logger::smf_n4().warn(
"Received N4 ASSOCIATION RELEASE RESPONSE with an invalid node ID!, ignore message");
return;
}
if (not msg_ies_container.cause.first) {
Logger::smf_n4().warn(
"Received N4 ASSOCIATION RELEASE RESPONSE without cause IE!, ignore message");
} else {
if (msg_ies_container.cause.second.cause_value
== pfcp::CAUSE_VALUE_REQUEST_ACCEPTED) {
std::shared_ptr<pfcp_association> sa = std::shared_ptr < pfcp_association
> (nullptr);
if (pfcp_associations::get_instance().get_association(node_id, sa)) {
//Delete locally all the PFCP sessions related to that PFCP association
sa->del_sessions();
}
}
}
}
//------------------------------------------------------------------------------
void smf_n4::handle_receive_session_establishment_response(
pfcp::pfcp_msg &msg, const endpoint &remote_endpoint) {
......
......@@ -158,6 +158,8 @@ class smf_n4 : public pfcp::pfcp_l4_stack {
pfcp::pfcp_msg &msg, const endpoint &remote_endpoint);
void handle_receive_association_update_request(
pfcp::pfcp_msg &msg, const endpoint &remote_endpoint);
void handle_receive_association_release_response(
pfcp::pfcp_msg &msg, const endpoint &remote_endpoint);
void handle_receive_session_establishment_response(
pfcp::pfcp_msg &msg, const endpoint &r_endpoint);
void handle_receive_session_modification_response(pfcp::pfcp_msg &msg,
......
......@@ -58,16 +58,15 @@ void pfcp_association::notify_del_session(const pfcp::fseid_t &cp_fseid) {
std::unique_lock<std::mutex> l(m_sessions);
sessions.erase(cp_fseid);
}
// //------------------------------------------------------------------------------
// void pfcp_association::del_sessions()
// {
// std::unique_lock<std::mutex> l(m_sessions);
// for (std::set<pfcp::fseid_t>::iterator it=sessions.begin(); it!=sessions.end();) {
// ???->remove_pfcp_session(*it);
// sessions.erase(it++);
// }
// }
//------------------------------------------------------------------------------
void pfcp_association::del_sessions()
{
std::unique_lock<std::mutex> l(m_sessions);
sessions.clear();
}
//------------------------------------------------------------------------------
void pfcp_association::restore_n4_sessions() {
std::unique_lock<std::mutex> l(m_sessions);
if (sessions.size()) {
......
......@@ -126,7 +126,7 @@ class pfcp_association {
void notify_add_session(const pfcp::fseid_t &cp_fseid);
bool has_session(const pfcp::fseid_t &cp_fseid);
void notify_del_session(const pfcp::fseid_t &cp_fseid);
//void del_sessions();
void del_sessions();
void restore_n4_sessions();
void set(const pfcp::up_function_features_s &ff) {
function_features.first = true;
......
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