|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "context.h" |
|
|
#include "n4-build.h" |
|
|
|
|
|
ogs_pkbuf_t *upf_n4_build_session_establishment_response(uint8_t type, |
|
|
upf_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr) |
|
|
{ |
|
|
ogs_pfcp_message_t *pfcp_message = NULL; |
|
|
ogs_pfcp_session_establishment_response_t *rsp = NULL; |
|
|
ogs_pkbuf_t *pkbuf = NULL; |
|
|
|
|
|
int i = 0, j = 0; |
|
|
|
|
|
ogs_pfcp_node_id_t node_id; |
|
|
ogs_pfcp_f_seid_t f_seid; |
|
|
int len = 0; |
|
|
|
|
|
ogs_debug("Session Establishment Response"); |
|
|
|
|
|
pfcp_message = ogs_calloc(1, sizeof(*pfcp_message)); |
|
|
if (!pfcp_message) { |
|
|
ogs_error("ogs_calloc() failed"); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
rsp = &pfcp_message->pfcp_session_establishment_response; |
|
|
|
|
|
|
|
|
ogs_pfcp_sockaddr_to_node_id(&node_id, &len); |
|
|
rsp->node_id.presence = 1; |
|
|
rsp->node_id.data = &node_id; |
|
|
rsp->node_id.len = len; |
|
|
|
|
|
|
|
|
rsp->cause.presence = 1; |
|
|
rsp->cause.u8 = OGS_PFCP_CAUSE_REQUEST_ACCEPTED; |
|
|
|
|
|
|
|
|
ogs_pfcp_sockaddr_to_f_seid(&f_seid, &len); |
|
|
f_seid.seid = htobe64(sess->upf_n4_seid); |
|
|
rsp->up_f_seid.presence = 1; |
|
|
rsp->up_f_seid.data = &f_seid; |
|
|
rsp->up_f_seid.len = len; |
|
|
|
|
|
ogs_pfcp_pdrbuf_init(); |
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < num_of_created_pdr; i++) { |
|
|
bool pdr_presence = ogs_pfcp_build_created_pdr( |
|
|
&rsp->created_pdr[j], i, created_pdr[i]); |
|
|
if (pdr_presence == true) j++; |
|
|
} |
|
|
|
|
|
pfcp_message->h.type = type; |
|
|
pkbuf = ogs_pfcp_build_msg(pfcp_message); |
|
|
ogs_expect(pkbuf); |
|
|
|
|
|
ogs_pfcp_pdrbuf_clear(); |
|
|
ogs_free(pfcp_message); |
|
|
|
|
|
return pkbuf; |
|
|
} |
|
|
|
|
|
ogs_pkbuf_t *upf_n4_build_session_modification_response(uint8_t type, |
|
|
upf_sess_t *sess, ogs_pfcp_pdr_t *created_pdr[], int num_of_created_pdr) |
|
|
{ |
|
|
ogs_pfcp_message_t *pfcp_message = NULL; |
|
|
ogs_pfcp_session_modification_response_t *rsp = NULL; |
|
|
ogs_pkbuf_t *pkbuf = NULL; |
|
|
|
|
|
int i = 0, j = 0; |
|
|
|
|
|
ogs_debug("Session Modification Response"); |
|
|
|
|
|
pfcp_message = ogs_calloc(1, sizeof(*pfcp_message)); |
|
|
if (!pfcp_message) { |
|
|
ogs_error("ogs_calloc() failed"); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
rsp = &pfcp_message->pfcp_session_modification_response; |
|
|
|
|
|
|
|
|
rsp->cause.presence = 1; |
|
|
rsp->cause.u8 = OGS_PFCP_CAUSE_REQUEST_ACCEPTED; |
|
|
|
|
|
ogs_pfcp_pdrbuf_init(); |
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < num_of_created_pdr; i++) { |
|
|
bool pdr_presence = ogs_pfcp_build_created_pdr( |
|
|
&rsp->created_pdr[j], i, created_pdr[i]); |
|
|
if (pdr_presence == true) j++; |
|
|
} |
|
|
|
|
|
pfcp_message->h.type = type; |
|
|
pkbuf = ogs_pfcp_build_msg(pfcp_message); |
|
|
ogs_expect(pkbuf); |
|
|
|
|
|
ogs_pfcp_pdrbuf_clear(); |
|
|
ogs_free(pfcp_message); |
|
|
|
|
|
return pkbuf; |
|
|
} |
|
|
|
|
|
ogs_pkbuf_t *upf_n4_build_session_deletion_response(uint8_t type, |
|
|
upf_sess_t *sess) |
|
|
{ |
|
|
ogs_pfcp_urr_t *urr = NULL; |
|
|
ogs_pfcp_user_plane_report_t report; |
|
|
size_t num_of_reports = 0; |
|
|
ogs_debug("Session Deletion Response"); |
|
|
|
|
|
memset(&report, 0, sizeof(report)); |
|
|
ogs_list_for_each(&sess->pfcp.urr_list, urr) { |
|
|
ogs_assert(num_of_reports < OGS_ARRAY_SIZE(report.usage_report)); |
|
|
upf_sess_urr_acc_fill_usage_report(sess, urr, &report, num_of_reports); |
|
|
report.usage_report[num_of_reports].rep_trigger.termination_report = 1; |
|
|
num_of_reports++; |
|
|
upf_sess_urr_acc_snapshot(sess, urr); |
|
|
} |
|
|
report.num_of_usage_report = num_of_reports; |
|
|
|
|
|
return ogs_pfcp_build_session_deletion_response(type, OGS_PFCP_CAUSE_REQUEST_ACCEPTED, |
|
|
&report); |
|
|
} |
|
|
|