Skip to content

Commit

Permalink
adding pfcp session-set-delete message
Browse files Browse the repository at this point in the history
  • Loading branch information
spencersevilla committed Sep 23, 2022
1 parent 53d75e7 commit b033d97
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 0 deletions.
57 changes: 57 additions & 0 deletions lib/pfcp/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,63 @@ ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_response(uint8_t type,
return ogs_pfcp_build_msg(&pfcp_message);
}

ogs_pkbuf_t *ogs_pfcp_cp_build_session_set_deletion_request(uint8_t type)
{
ogs_pfcp_message_t pfcp_message;
ogs_pfcp_session_set_deletion_request_t *req = NULL;

ogs_pfcp_node_id_t node_id;
int node_id_len = 0, rv;

ogs_debug("Session Set Deletion Request");

req = &pfcp_message.pfcp_session_set_deletion_request;
memset(&pfcp_message, 0, sizeof(ogs_pfcp_message_t));

rv = ogs_pfcp_sockaddr_to_node_id(
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
ogs_app()->parameter.prefer_ipv4,
&node_id, &node_id_len);
ogs_expect_or_return_val(rv == OGS_OK, NULL);
req->node_id.presence = 1;
req->node_id.data = &node_id;
req->node_id.len = node_id_len;

pfcp_message.h.type = type;
return ogs_pfcp_build_msg(&pfcp_message);
}

ogs_pkbuf_t *ogs_pfcp_up_build_session_set_deletion_response(uint8_t type, uint8_t cause)
{
ogs_pfcp_message_t pfcp_message;
ogs_pfcp_session_set_deletion_response_t *rsp = NULL;

ogs_pfcp_node_id_t node_id;
int node_id_len = 0, rv;

ogs_debug("Session Set Deletion Response");

rsp = &pfcp_message.pfcp_session_set_deletion_response;
memset(&pfcp_message, 0, sizeof(ogs_pfcp_message_t));

// node id
rv = ogs_pfcp_sockaddr_to_node_id(
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
ogs_app()->parameter.prefer_ipv4,
&node_id, &node_id_len);
ogs_expect_or_return_val(rv == OGS_OK, NULL);
rsp->node_id.presence = 1;
rsp->node_id.data = &node_id;
rsp->node_id.len = node_id_len;

// cause
rsp->cause.presence = 1;
rsp->cause.u8 = cause;

pfcp_message.h.type = type;
return ogs_pfcp_build_msg(&pfcp_message);
}

static struct {
ogs_pfcp_f_teid_t f_teid;
char dnn[OGS_MAX_DNN_LEN+1];
Expand Down
4 changes: 4 additions & 0 deletions lib/pfcp/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_request(uint8_t type);
ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_response(uint8_t type,
uint8_t cause);

ogs_pkbuf_t *ogs_pfcp_cp_build_session_set_deletion_request(uint8_t type);
ogs_pkbuf_t *ogs_pfcp_up_build_session_set_deletion_response(uint8_t type,
uint8_t cause);

void ogs_pfcp_pdrbuf_init(void);
void ogs_pfcp_pdrbuf_clear(void);

Expand Down
54 changes: 54 additions & 0 deletions lib/pfcp/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,60 @@ int ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
return rv;
}

int ogs_pfcp_cp_send_session_set_deletion_request(ogs_pfcp_node_t *node,
void (*cb)(ogs_pfcp_xact_t *xact, void *data))
{
int rv;
ogs_pkbuf_t *pkbuf = NULL;
ogs_pfcp_header_t h;
ogs_pfcp_xact_t *xact = NULL;

ogs_assert(node);

memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_SET_DELETION_REQUEST_TYPE;
h.seid = 0;

xact = ogs_pfcp_xact_local_create(node, cb, node);
ogs_expect_or_return_val(xact, OGS_ERROR);

pkbuf = ogs_pfcp_cp_build_session_set_deletion_request(h.type);
ogs_expect_or_return_val(pkbuf, OGS_ERROR);

rv = ogs_pfcp_xact_update_tx(xact, &h, pkbuf);
ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR);

rv = ogs_pfcp_xact_commit(xact);
ogs_expect(rv == OGS_OK);

return rv;
}

int ogs_pfcp_up_send_session_set_deletion_response(ogs_pfcp_xact_t *xact,
uint8_t cause)
{
int rv;
ogs_pkbuf_t *pkbuf = NULL;
ogs_pfcp_header_t h;

ogs_assert(xact);

memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_SET_DELETION_RESPONSE_TYPE;
h.seid = 0;

pkbuf = ogs_pfcp_up_build_session_set_deletion_response(h.type, cause);
ogs_expect_or_return_val(pkbuf, OGS_ERROR);

rv = ogs_pfcp_xact_update_tx(xact, &h, pkbuf);
ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR);

rv = ogs_pfcp_xact_commit(xact);
ogs_expect(rv == OGS_OK);

return rv;
}

int ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
void (*cb)(ogs_pfcp_xact_t *xact, void *data))
{
Expand Down
5 changes: 5 additions & 0 deletions lib/pfcp/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ int ogs_pfcp_cp_send_association_setup_request(ogs_pfcp_node_t *node,
int ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
uint8_t cause);

int ogs_pfcp_cp_send_session_set_deletion_request(ogs_pfcp_node_t *node,
void (*cb)(ogs_pfcp_xact_t *xact, void *data));
int ogs_pfcp_up_send_session_set_deletion_response(ogs_pfcp_xact_t *xact,
uint8_t cause);

int ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
void (*cb)(ogs_pfcp_xact_t *xact, void *data));
int ogs_pfcp_up_send_association_setup_response(ogs_pfcp_xact_t *xact,
Expand Down
2 changes: 2 additions & 0 deletions lib/pfcp/xact.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ static ogs_pfcp_xact_stage_t ogs_pfcp_xact_get_stage(uint8_t type, uint32_t xid)
case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
case OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE:
case OGS_PFCP_SESSION_DELETION_REQUEST_TYPE:
case OGS_PFCP_SESSION_SET_DELETION_REQUEST_TYPE:
case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
stage = PFCP_XACT_INITIAL_STAGE;
break;
Expand All @@ -739,6 +740,7 @@ static ogs_pfcp_xact_stage_t ogs_pfcp_xact_get_stage(uint8_t type, uint32_t xid)
case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
case OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE:
case OGS_PFCP_SESSION_DELETION_RESPONSE_TYPE:
case OGS_PFCP_SESSION_SET_DELETION_RESPONSE_TYPE:
case OGS_PFCP_SESSION_REPORT_RESPONSE_TYPE:
stage = PFCP_XACT_FINAL_STAGE;
break;
Expand Down
5 changes: 5 additions & 0 deletions src/sgwc/pfcp-sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ void sgwc_pfcp_state_associated(ogs_fsm_t *s, sgwc_event_t *e)
&message->pfcp_session_deletion_response);
break;

case OGS_PFCP_SESSION_SET_DELETION_RESPONSE_TYPE:
sgwc_sxa_handle_session_set_deletion_response(
xact, &message->pfcp_session_set_deletion_response);
break;

case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
if (!message->h.seid_presence) ogs_error("No SEID");

Expand Down
14 changes: 14 additions & 0 deletions src/sgwc/sxa-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,20 @@ void sgwc_sxa_handle_session_deletion_response(
sgwc_sess_remove(sess);
}

void sgwc_sxa_handle_session_set_deletion_response(
ogs_pfcp_xact_t *pfcp_xact,
ogs_pfcp_session_set_deletion_response_t *pfcp_rsp)
{
ogs_debug("Session Set Deletion Response");

ogs_assert(pfcp_xact);
ogs_assert(pfcp_rsp);

ogs_pfcp_xact_commit(pfcp_xact);

return;
}

void sgwc_sxa_handle_session_report_request(
sgwc_sess_t *sess, ogs_pfcp_xact_t *pfcp_xact,
ogs_pfcp_session_report_request_t *pfcp_req)
Expand Down
3 changes: 3 additions & 0 deletions src/sgwc/sxa-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ void sgwc_sxa_handle_session_deletion_response(
sgwc_sess_t *sess, ogs_pfcp_xact_t *pfcp_xact,
ogs_gtp2_message_t *gtp_message,
ogs_pfcp_session_deletion_response_t *pfcp_rsp);
void sgwc_sxa_handle_session_set_deletion_response(
ogs_pfcp_xact_t *pfcp_xact,
ogs_pfcp_session_set_deletion_response_t *pfcp_rsp);
void sgwc_sxa_handle_session_report_request(
sgwc_sess_t *sess, ogs_pfcp_xact_t *pfcp_xact,
ogs_pfcp_session_report_request_t *pfcp_req);
Expand Down
4 changes: 4 additions & 0 deletions src/sgwu/pfcp-sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ void sgwu_pfcp_state_associated(ogs_fsm_t *s, sgwu_event_t *e)
sgwu_sxa_handle_session_report_response(
sess, xact, &message->pfcp_session_report_response);
break;
case OGS_PFCP_SESSION_SET_DELETION_REQUEST_TYPE:
sgwu_sxa_handle_session_set_deletion_request(
node, xact, &message->pfcp_session_set_deletion_request);
break;
default:
ogs_error("Not implemented PFCP message type[%d]",
message->h.type);
Expand Down
20 changes: 20 additions & 0 deletions src/sgwu/sxa-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,26 @@ void sgwu_sxa_handle_session_deletion_request(
sgwu_sess_remove(sess);
}

void sgwu_sxa_handle_session_set_deletion_request(
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_set_deletion_request_t *req)
{
sgwu_sess_t *sess = NULL, *next = NULL;;
ogs_assert(node);
ogs_assert(xact);
ogs_assert(req);

ogs_debug("Session Set Deletion Request");

ogs_list_for_each_safe(&sgwu_self()->sess_list, next, sess) {
if (sess->pfcp_node == node) {
sgwu_sess_remove(sess);
}
}

ogs_pfcp_up_send_session_set_deletion_response(xact, OGS_PFCP_CAUSE_REQUEST_ACCEPTED);
}

void sgwu_sxa_handle_session_report_response(
sgwu_sess_t *sess, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_report_response_t *rsp)
Expand Down
3 changes: 3 additions & 0 deletions src/sgwu/sxa-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void sgwu_sxa_handle_session_modification_request(
void sgwu_sxa_handle_session_deletion_request(
sgwu_sess_t *sess, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_deletion_request_t *req);
void sgwu_sxa_handle_session_set_deletion_request(
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_set_deletion_request_t *req);

void sgwu_sxa_handle_session_report_response(
sgwu_sess_t *sess, ogs_pfcp_xact_t *xact,
Expand Down
13 changes: 13 additions & 0 deletions src/smf/n4-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,19 @@ uint8_t smf_epc_n4_handle_session_deletion_response(
return OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
}

void smf_epc_n4_handle_session_set_deletion_response(
ogs_pfcp_xact_t *xact, ogs_pfcp_session_set_deletion_response_t *rsp)
{
ogs_debug("Session Set Deletion Response");

ogs_assert(xact);
ogs_assert(rsp);

ogs_pfcp_xact_commit(xact);

return;
}

void smf_n4_handle_session_report_request(
smf_sess_t *sess, ogs_pfcp_xact_t *pfcp_xact,
ogs_pfcp_session_report_request_t *pfcp_req)
Expand Down
2 changes: 2 additions & 0 deletions src/smf/n4-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void smf_epc_n4_handle_session_modification_response(
uint8_t smf_epc_n4_handle_session_deletion_response(
smf_sess_t *sess, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_deletion_response_t *rsp);
void smf_epc_n4_handle_session_set_deletion_response(
ogs_pfcp_xact_t *xact, ogs_pfcp_session_set_deletion_response_t *rsp);

void smf_n4_handle_session_report_request(
smf_sess_t *sess, ogs_pfcp_xact_t *pfcp_xact,
Expand Down
5 changes: 5 additions & 0 deletions src/smf/pfcp-sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
ogs_fsm_dispatch(&sess->sm, e);
break;

case OGS_PFCP_SESSION_SET_DELETION_RESPONSE_TYPE:
smf_epc_n4_handle_session_set_deletion_response(
xact, &message->pfcp_session_set_deletion_response);
break;

case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
if (!message->h.seid_presence) ogs_error("No SEID");

Expand Down
20 changes: 20 additions & 0 deletions src/upf/n4-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,26 @@ void upf_n4_handle_session_deletion_request(
upf_sess_remove(sess);
}

void upf_n4_handle_session_set_deletion_request(
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_set_deletion_request_t *req)
{
upf_sess_t *sess = NULL, *next = NULL;;
ogs_assert(node);
ogs_assert(xact);
ogs_assert(req);

ogs_debug("Session Set Deletion Request");

ogs_list_for_each_safe(&upf_self()->sess_list, next, sess) {
if (sess->pfcp_node == node) {
upf_sess_remove(sess);
}
}

ogs_pfcp_up_send_session_set_deletion_response(xact, OGS_PFCP_CAUSE_REQUEST_ACCEPTED);
}

void upf_n4_handle_session_report_response(
upf_sess_t *sess, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_report_response_t *rsp)
Expand Down
3 changes: 3 additions & 0 deletions src/upf/n4-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void upf_n4_handle_session_modification_request(
void upf_n4_handle_session_deletion_request(
upf_sess_t *sess, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_deletion_request_t *req);
void upf_n4_handle_session_set_deletion_request(
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
ogs_pfcp_session_set_deletion_request_t *req);

void upf_n4_handle_session_report_response(
upf_sess_t *sess, ogs_pfcp_xact_t *xact,
Expand Down
4 changes: 4 additions & 0 deletions src/upf/pfcp-sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ void upf_pfcp_state_associated(ogs_fsm_t *s, upf_event_t *e)
upf_n4_handle_session_deletion_request(
sess, xact, &message->pfcp_session_deletion_request);
break;
case OGS_PFCP_SESSION_SET_DELETION_REQUEST_TYPE:
upf_n4_handle_session_set_deletion_request(
node, xact, &message->pfcp_session_set_deletion_request);
break;
case OGS_PFCP_SESSION_REPORT_RESPONSE_TYPE:
upf_n4_handle_session_report_response(
sess, xact, &message->pfcp_session_report_response);
Expand Down

0 comments on commit b033d97

Please sign in to comment.