Update URR contribution (#1190)

This commit is contained in:
Sukchan Lee 2021-10-04 22:28:32 +09:00
parent 13f1b390ae
commit 5e016937c7
13 changed files with 793 additions and 39 deletions

View File

@ -550,6 +550,86 @@ void ogs_pfcp_build_update_far_activate(
}
}
static struct {
ogs_pfcp_volume_threshold_t vol_threshold;
ogs_pfcp_volume_quota_t vol_quota;
ogs_pfcp_dropped_dl_traffic_threshold_t dropped_dl_traffic_threshold;
} urrbuf[OGS_MAX_NUM_OF_URR];
void ogs_pfcp_build_create_urr(
ogs_pfcp_tlv_create_urr_t *message, int i, ogs_pfcp_urr_t *urr)
{
ogs_assert(message);
ogs_assert(urr);
message->presence = 1;
message->urr_id.presence = 1;
message->urr_id.u32 = urr->id;
message->measurement_method.presence = 1;
message->measurement_method.u8 = urr->meas_method;
message->reporting_triggers.presence = 1;
message->reporting_triggers.u24 = (urr->rep_triggers.reptri_5 << 16)
| (urr->rep_triggers.reptri_6 << 8)
| (urr->rep_triggers.reptri_7);
if (urr->meas_period) {
message->measurement_period.presence = 1;
message->measurement_period.u32 = htobe32(urr->meas_period);
}
if (urr->vol_threshold.flags) {
message->volume_threshold.presence = 1;
ogs_pfcp_build_volume(
&message->volume_threshold, &urr->vol_threshold,
&urrbuf[i].vol_threshold, sizeof(urrbuf[i].vol_threshold));
}
if (urr->vol_quota.flags) {
message->volume_quota.presence = 1;
ogs_pfcp_build_volume(
&message->volume_quota, &urr->vol_quota,
&urrbuf[i].vol_quota, sizeof(urrbuf[i].vol_quota));
}
if (urr->event_threshold) {
message->event_threshold.presence = 1;
message->event_threshold.u32 = htobe32(urr->event_threshold);
}
if (urr->event_quota) {
message->event_quota.presence = 1;
message->event_quota.u32 = htobe32(urr->event_quota);
}
if (urr->time_threshold) {
message->time_threshold.presence = 1;
message->time_threshold.u32 = htobe32(urr->time_threshold);
}
if (urr->time_quota) {
message->time_quota.presence = 1;
message->time_quota.u32 = htobe32(urr->time_quota);
}
if (urr->quota_holding_time) {
message->quota_holding_time.presence = 1;
message->quota_holding_time.u32 = htobe32(urr->quota_holding_time);
}
if (urr->dropped_dl_traffic_threshold.flags) {
message->dropped_dl_traffic_threshold.presence = 1;
ogs_pfcp_build_dropped_dl_traffic_threshold(
&message->dropped_dl_traffic_threshold,
&urr->dropped_dl_traffic_threshold,
&urrbuf[i].dropped_dl_traffic_threshold,
sizeof(urrbuf[i].dropped_dl_traffic_threshold));
}
if (urr->quota_validity_time) {
message->quota_validity_time.presence = 1;
message->quota_validity_time.u32 = htobe32(urr->quota_validity_time);
}
}
static struct {
char mbr[OGS_PFCP_BITRATE_LEN];
char gbr[OGS_PFCP_BITRATE_LEN];
@ -611,17 +691,6 @@ void ogs_pfcp_build_update_qer(
}
}
void ogs_pfcp_build_create_urr(
ogs_pfcp_tlv_create_urr_t *message, int i, ogs_pfcp_urr_t *urr)
{
ogs_assert(message);
ogs_assert(urr);
message->presence = 1;
message->urr_id.presence = 1;
message->urr_id.u32 = urr->id;
}
void ogs_pfcp_build_create_bar(
ogs_pfcp_tlv_create_bar_t *message, ogs_pfcp_bar_t *bar)
{

View File

@ -229,6 +229,26 @@ typedef struct ogs_pfcp_urr_s {
uint8_t *id_node; /* Pool-Node for ID */
ogs_pfcp_urr_id_t id;
ogs_pfcp_measurement_method_t meas_method;
ogs_pfcp_reporting_triggers_t rep_triggers;
ogs_pfcp_measurement_period_t meas_period;
ogs_pfcp_volume_threshold_t vol_threshold;
ogs_pfcp_volume_quota_t vol_quota;
ogs_pfcp_event_threshold_t event_threshold;
ogs_pfcp_event_quota_t event_quota;
ogs_pfcp_time_threshold_t time_threshold;
ogs_pfcp_time_quota_t time_quota;
ogs_pfcp_quota_holding_time_t quota_holding_time;
ogs_pfcp_dropped_dl_traffic_threshold_t dropped_dl_traffic_threshold;
ogs_pfcp_quota_validity_time_t quota_validity_time;
ogs_pfcp_sess_t *sess;
} ogs_pfcp_urr_t;

View File

@ -270,6 +270,7 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
{
ogs_pfcp_pdr_t *pdr = NULL;
ogs_pfcp_far_t *far = NULL;
ogs_pfcp_urr_t *urr = NULL;
ogs_pfcp_qer_t *qer = NULL;
int i, len;
int rv;
@ -470,6 +471,14 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
ogs_pfcp_pdr_associate_far(pdr, far);
}
pdr->urr = NULL;
if(message->urr_id.presence) {
urr = ogs_pfcp_urr_find_or_add(sess, message->urr_id.u32);
ogs_assert(urr);
ogs_pfcp_pdr_associate_urr(pdr,urr);
}
pdr->qer = NULL;
if (message->qer_id.presence) {
@ -1072,3 +1081,228 @@ bool ogs_pfcp_handle_remove_bar(ogs_pfcp_sess_t *sess,
*cause_value = OGS_PFCP_CAUSE_SESSION_CONTEXT_NOT_FOUND;
return false;
}
ogs_pfcp_urr_t *ogs_pfcp_handle_create_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_create_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value)
{
ogs_pfcp_urr_t *urr = NULL;
ogs_assert(message);
ogs_assert(sess);
if (message->presence == 0)
return NULL;
if (message->urr_id.presence == 0) {
ogs_error("No URR-ID");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_URR_ID_TYPE;
return NULL;
}
urr = ogs_pfcp_urr_find(sess, message->urr_id.u32);
if (!urr) {
ogs_error("Cannot find URR-ID[%d] in PDR", message->urr_id.u32);
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_INCORRECT;
*offending_ie_value = OGS_PFCP_URR_ID_TYPE;
return NULL;
}
if (message->measurement_method.presence == 0) {
ogs_error("No Measurement Method");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_MEASUREMENT_METHOD_TYPE;
return NULL;
}
if (message->reporting_triggers.presence == 0) {
ogs_error("No Reporting Triggers");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_REPORTING_TRIGGERS_TYPE;
return NULL;
}
urr->meas_method = message->measurement_method.u8;
urr->rep_triggers.reptri_5 = (message->reporting_triggers.u24 >> 16) & 0xFF;
urr->rep_triggers.reptri_6 = (message->reporting_triggers.u24 >> 8) & 0xFF;
urr->rep_triggers.reptri_7 = message->reporting_triggers.u24 & 0xFF;
if (message->measurement_period.presence) {
urr->meas_period = be32toh(message->measurement_period.u32);
}
if (message->volume_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_threshold, &message->volume_threshold);
}
if (message->volume_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_quota, &message->volume_quota);
}
if (message->event_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_EVENT)) {
urr->event_threshold = be32toh(message->event_threshold.u32);
}
if (message->event_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_EVENT)) {
urr->event_quota = be32toh(message->event_quota.u32);
}
if (message->time_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_DURATION)) {
urr->time_threshold = be32toh(message->time_threshold.u32);
}
if (message->time_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_DURATION)) {
urr->time_quota = be32toh(message->time_quota.u32);
}
if (message->quota_holding_time.presence) {
urr->quota_holding_time = be32toh(message->quota_holding_time.u32);
}
if (message->dropped_dl_traffic_threshold.presence) {
ogs_pfcp_parse_dropped_dl_traffic_threshold(
&urr->dropped_dl_traffic_threshold,
&message->dropped_dl_traffic_threshold);
}
if (message->quota_validity_time.presence) {
urr->quota_validity_time = be32toh(message->quota_validity_time.u32);
}
return urr;
}
ogs_pfcp_urr_t *ogs_pfcp_handle_update_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_update_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value)
{
ogs_pfcp_urr_t *urr = NULL;
ogs_assert(message);
ogs_assert(sess);
if (message->presence == 0)
return NULL;
if (message->urr_id.presence == 0) {
ogs_error("No URR-ID");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_URR_ID_TYPE;
return NULL;
}
urr = ogs_pfcp_urr_find(sess, message->urr_id.u32);
if (!urr) {
ogs_error("Cannot find URR-ID[%d] in PDR", message->urr_id.u32);
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_INCORRECT;
*offending_ie_value = OGS_PFCP_URR_ID_TYPE;
return NULL;
}
if (message->measurement_method.presence == 0) {
ogs_error("No Measurement Method");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_MEASUREMENT_METHOD_TYPE;
return NULL;
}
if (message->reporting_triggers.presence == 0) {
ogs_error("No Reporting Triggers");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_REPORTING_TRIGGERS_TYPE;
return NULL;
}
urr->meas_method = message->measurement_method.u8;
urr->rep_triggers.reptri_5 = message->reporting_triggers.u24 & 0xFF;
urr->rep_triggers.reptri_6 = (message->reporting_triggers.u24 >> 8) & 0xFF;
urr->rep_triggers.reptri_7 = (message->reporting_triggers.u24 >> 16) & 0xFF;
if (message->measurement_period.presence) {
urr->meas_period = be32toh(message->measurement_period.u32);
}
if (message->volume_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_threshold, &message->volume_threshold);
}
if (message->volume_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_VOLUME)) {
ogs_pfcp_parse_volume(&urr->vol_quota, &message->volume_quota);
}
if (message->event_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_EVENT)) {
urr->event_threshold = be32toh(message->event_threshold.u32);
}
if (message->event_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_EVENT)) {
urr->event_quota = be32toh(message->event_quota.u32);
}
if (message->time_threshold.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_DURATION)) {
urr->time_threshold = be32toh(message->time_threshold.u32);
}
if (message->time_quota.presence &&
(urr->meas_method & OGS_PFCP_MEASUREMENT_METHOD_DURATION)) {
urr->time_quota = be32toh(message->time_quota.u32);
}
if (message->quota_holding_time.presence) {
urr->quota_holding_time = be32toh(message->quota_holding_time.u32);
}
if (message->dropped_dl_traffic_threshold.presence) {
ogs_pfcp_parse_dropped_dl_traffic_threshold(
&urr->dropped_dl_traffic_threshold,
&message->dropped_dl_traffic_threshold);
}
if (message->quota_validity_time.presence) {
urr->quota_validity_time = be32toh(message->quota_validity_time.u32);
}
return urr;
}
bool ogs_pfcp_handle_remove_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_remove_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value)
{
ogs_pfcp_urr_t *urr = NULL;
ogs_assert(sess);
ogs_assert(message);
if (message->presence == 0)
return false;
if (message->urr_id.presence == 0) {
ogs_error("No URR-ID");
*cause_value = OGS_PFCP_CAUSE_MANDATORY_IE_MISSING;
*offending_ie_value = OGS_PFCP_URR_ID_TYPE;
return false;
}
urr = ogs_pfcp_urr_find(sess, message->urr_id.u32);
if (!urr) {
ogs_error("Unknown URR-ID[%d]", message->urr_id.u32);
*cause_value = OGS_PFCP_CAUSE_SESSION_CONTEXT_NOT_FOUND;
return false;
}
ogs_pfcp_urr_remove(urr);
return true;
}

View File

@ -94,6 +94,16 @@ bool ogs_pfcp_handle_remove_bar(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_remove_bar_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value);
ogs_pfcp_urr_t *ogs_pfcp_handle_create_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_create_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value);
ogs_pfcp_urr_t *ogs_pfcp_handle_update_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_update_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value);
bool ogs_pfcp_handle_remove_urr(ogs_pfcp_sess_t *sess,
ogs_pfcp_tlv_remove_urr_t *message,
uint8_t *cause_value, uint8_t *offending_ie_value);
#ifdef __cplusplus
}
#endif

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by pfcp-tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2021-07-27 20:23:21.045510 by acetcom
* Created on: 2021-10-04 22:09:12.905975 by acetcom
* from 29244-g10.docx
******************************************************************************/
@ -171,10 +171,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_volume_threshold =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_time_threshold =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Time Threshold",
OGS_PFCP_TIME_THRESHOLD_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_time_threshold_t),
{ NULL }
@ -226,10 +226,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_inactivity_detection_time =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_reporting_triggers =
{
OGS_TLV_UINT8,
OGS_TLV_UINT24,
"Reporting Triggers",
OGS_PFCP_REPORTING_TRIGGERS_TYPE,
1,
3,
0,
sizeof(ogs_pfcp_tlv_reporting_triggers_t),
{ NULL }
@ -479,10 +479,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_usage_report_trigger =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_measurement_period =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Measurement Period",
OGS_PFCP_MEASUREMENT_PERIOD_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_measurement_period_t),
{ NULL }
@ -545,10 +545,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_time_of_last_packet =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_quota_holding_time =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Quota Holding Time",
OGS_PFCP_QUOTA_HOLDING_TIME_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_quota_holding_time_t),
{ NULL }
@ -578,10 +578,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_volume_quota =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_time_quota =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Time Quota",
OGS_PFCP_TIME_QUOTA_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_time_quota_t),
{ NULL }
@ -1216,10 +1216,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_additional_monitoring_time =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_event_quota =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Event Quota",
OGS_PFCP_EVENT_QUOTA_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_event_quota_t),
{ NULL }
@ -1227,10 +1227,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_event_quota =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_event_threshold =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Event Threshold",
OGS_PFCP_EVENT_THRESHOLD_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_event_threshold_t),
{ NULL }
@ -1502,10 +1502,10 @@ ogs_tlv_desc_t ogs_pfcp_tlv_desc_smf_set_id =
ogs_tlv_desc_t ogs_pfcp_tlv_desc_quota_validity_time =
{
OGS_TLV_VAR_STR,
OGS_TLV_UINT32,
"Quota Validity Time",
OGS_PFCP_QUOTA_VALIDITY_TIME_TYPE,
0,
4,
0,
sizeof(ogs_pfcp_tlv_quota_validity_time_t),
{ NULL }

View File

@ -20,7 +20,7 @@
/*******************************************************************************
* This file had been created by pfcp-tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2021-07-27 20:23:21.038999 by acetcom
* Created on: 2021-10-04 22:09:12.899719 by acetcom
* from 29244-g10.docx
******************************************************************************/
@ -494,12 +494,12 @@ typedef ogs_tlv_uint32_t ogs_pfcp_tlv_qer_correlation_id_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_precedence_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_transport_level_marking_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_volume_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_time_threshold_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_time_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_monitoring_time_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_subsequent_volume_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_subsequent_time_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_inactivity_detection_time_t;
typedef ogs_tlv_uint8_t ogs_pfcp_tlv_reporting_triggers_t;
typedef ogs_tlv_uint24_t ogs_pfcp_tlv_reporting_triggers_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_redirect_information_t;
typedef ogs_tlv_uint8_t ogs_pfcp_tlv_report_type_t;
typedef ogs_tlv_uint16_t ogs_pfcp_tlv_offending_ie_t;
@ -522,16 +522,16 @@ typedef ogs_tlv_octet_t ogs_pfcp_tlv_node_id_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_pfd_contents_t;
typedef ogs_tlv_uint8_t ogs_pfcp_tlv_measurement_method_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_usage_report_trigger_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_measurement_period_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_measurement_period_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_fq_csid_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_volume_measurement_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_duration_measurement_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_time_of_first_packet_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_time_of_last_packet_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_quota_holding_time_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_quota_holding_time_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_dropped_dl_traffic_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_volume_quota_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_time_quota_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_time_quota_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_start_time_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_end_time_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_urr_id_t;
@ -589,8 +589,8 @@ typedef ogs_tlv_octet_t ogs_pfcp_tlv_mac_addresses_detected_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_mac_addresses_removed_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_ethernet_inactivity_timer_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_additional_monitoring_time_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_event_quota_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_event_threshold_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_event_quota_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_event_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_subsequent_event_quota_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_subsequent_event_threshold_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_trace_information_t;
@ -615,7 +615,7 @@ typedef ogs_tlv_octet_t ogs_pfcp_tlv_ue_ip_address_pool_identity_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_alternative_smf_ip_address_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_packet_replication_and_detection_carry_on_information_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_smf_set_id_t;
typedef ogs_tlv_octet_t ogs_pfcp_tlv_quota_validity_time_t;
typedef ogs_tlv_uint32_t ogs_pfcp_tlv_quota_validity_time_t;
/* Structure for Group Infomration Element */
typedef struct ogs_pfcp_tlv_ethernet_packet_filter_s {

View File

@ -32,7 +32,7 @@
#define OGS_MAX_NUM_OF_PDR 16
#define OGS_MAX_NUM_OF_FAR 16
#define OGS_MAX_NUM_OF_URR 2
#define OGS_MAX_NUM_OF_URR 16
#define OGS_MAX_NUM_OF_QER 4
#define OGS_MAX_NUM_OF_BAR 1

View File

@ -407,7 +407,8 @@ type_list["Source Interface"]["size"] = 1 # Type 20
type_list["Gate Status"]["size"] = 1 # Type 25
type_list["QER Correlation ID"]["size"] = 4 # Type 28
type_list["Precedence"]["size"] = 4 # Type 29
type_list["Reporting Triggers"]["size"] = 1 # Type 37
type_list["Time Threshold"]["size"] = 4 # Type 32
type_list["Reporting Triggers"]["size"] = 3 # Type 37
type_list["Report Type"]["size"] = 1 # Type 39
type_list["Offending IE"]["size"] = 2 # Type 40
type_list["Destination Interface"]["size"] = 1 # Type 42
@ -416,6 +417,9 @@ type_list["PFCPSMReq-Flags"]["size"] = 1 # Type 49
type_list["PFCPSRRsp-Flags"]["size"] = 1 # Type 50
type_list["PDR ID"]["size"] = 2 # Type 56
type_list["Measurement Method"]["size"] = 1 # Type 62
type_list["Measurement Period"]["size"] = 4 # Type 64
type_list["Quota Holding Time"]["size"] = 4 # Type 71
type_list["Time Quota"]["size"] = 4 # Type 74
type_list["URR ID"]["size"] = 4 # Type 81
type_list["BAR ID"]["size"] = 1 # Type 88
type_list["CP Function Features"]["size"] = 1 # Type 89
@ -425,10 +429,13 @@ type_list["QER ID"]["size"] = 4 # Type 109
type_list["PDN Type"]["size"] = 1 # Type 113
type_list["RQI"]["size"] = 1 # Type 123
type_list["QFI"]["size"] = 1 # Type 124
type_list["Event Quota"]["size"] = 4 # Type 148
type_list["Event Threshold"]["size"] = 4 # Type 149
type_list["Averaging Window"]["size"] = 4 # Type 157
type_list["Paging Policy Indicator"]["size"] = 1 # Type 158
type_list["PFCPSRReq-Flags"]["size"] = 1 # Type 161
type_list["PFCPAUReq-Flags"]["size"] = 1 # Type 162
type_list["Quota Validity Time"]["size"] = 4 # Type 181
f = open(outdir + 'message.h', 'w')
output_header_to_file(f)

View File

@ -405,3 +405,159 @@ int16_t ogs_pfcp_parse_bitrate(
return size;
}
int16_t ogs_pfcp_build_volume(ogs_tlv_octet_t *octet,
ogs_pfcp_volume_threshold_t *volume, void *data, int data_len)
{
ogs_pfcp_volume_threshold_t target;
int16_t size = 0;
ogs_assert(volume);
ogs_assert(octet);
ogs_assert(data);
ogs_assert(data_len >= sizeof(ogs_pfcp_volume_threshold_t));
ogs_assert(volume->flags);
octet->data = data;
memcpy(&target, volume, sizeof(ogs_pfcp_volume_threshold_t));
((unsigned char *)octet->data)[size] = target.flags;
size += sizeof(target.flags);
if (target.tovol) {
target.total_volume = htobe64(target.total_volume);
memcpy((unsigned char *)octet->data + size,
&target.total_volume, sizeof(target.total_volume));
size += sizeof(target.total_volume);
}
if (target.ulvol) {
target.uplink_volume = htobe64(target.uplink_volume);
memcpy((unsigned char *)octet->data + size,
&target.uplink_volume, sizeof(target.uplink_volume));
size += sizeof(target.uplink_volume);
}
if (target.dlvol) {
target.downlink_volume = htobe64(target.downlink_volume);
memcpy((unsigned char *)octet->data + size,
&target.downlink_volume, sizeof(target.downlink_volume));
size += sizeof(target.downlink_volume);
}
octet->len = size;
return octet->len;
}
int16_t ogs_pfcp_parse_volume(
ogs_pfcp_volume_threshold_t *volume, ogs_tlv_octet_t *octet)
{
int16_t size = 0;
ogs_assert(volume);
ogs_assert(octet);
memset(volume, 0, sizeof(ogs_pfcp_volume_threshold_t));
volume->flags = ((unsigned char *)octet->data)[size];
size += sizeof(volume->flags);
if (volume->tovol) {
memcpy(&volume->total_volume, (unsigned char *)octet->data + size,
sizeof(volume->total_volume));
volume->total_volume = be64toh(volume->total_volume);
size += sizeof(volume->total_volume);
}
if (volume->ulvol) {
memcpy(&volume->uplink_volume, (unsigned char *)octet->data + size,
sizeof(volume->uplink_volume));
volume->uplink_volume = be64toh(volume->uplink_volume);
size += sizeof(volume->uplink_volume);
}
if (volume->dlvol) {
memcpy(&volume->downlink_volume, (unsigned char *)octet->data + size,
sizeof(volume->downlink_volume));
volume->downlink_volume = be64toh(volume->downlink_volume);
size += sizeof(volume->downlink_volume);
}
ogs_assert(size == octet->len);
return size;
}
int16_t ogs_pfcp_build_dropped_dl_traffic_threshold(
ogs_tlv_octet_t *octet,
ogs_pfcp_dropped_dl_traffic_threshold_t *threshold,
void *data, int data_len)
{
ogs_pfcp_dropped_dl_traffic_threshold_t target;
int16_t size = 0;
ogs_assert(threshold);
ogs_assert(octet);
ogs_assert(data);
ogs_assert(data_len >= sizeof(ogs_pfcp_dropped_dl_traffic_threshold_t));
ogs_assert(threshold->flags);
octet->data = data;
memcpy(&target, threshold, sizeof(ogs_pfcp_dropped_dl_traffic_threshold_t));
((unsigned char *)octet->data)[size] = target.flags;
size += sizeof(target.flags);
if (target.dlpa) {
target.downlink_packets = htobe64(target.downlink_packets);
memcpy((unsigned char *)octet->data + size,
&target.downlink_packets, sizeof(target.downlink_packets));
size += sizeof(target.downlink_packets);
}
if (target.dlby) {
target.number_of_bytes_of_downlink_data =
htobe64(target.number_of_bytes_of_downlink_data);
memcpy((unsigned char *)octet->data + size,
&target.number_of_bytes_of_downlink_data,
sizeof(target.number_of_bytes_of_downlink_data));
size += sizeof(target.number_of_bytes_of_downlink_data);
}
octet->len = size;
return octet->len;
}
int16_t ogs_pfcp_parse_dropped_dl_traffic_threshold(
ogs_pfcp_dropped_dl_traffic_threshold_t *threshold,
ogs_tlv_octet_t *octet)
{
int16_t size = 0;
ogs_assert(threshold);
ogs_assert(octet);
memset(threshold, 0, sizeof(ogs_pfcp_dropped_dl_traffic_threshold_t));
threshold->flags = ((unsigned char *)octet->data)[size];
size += sizeof(threshold->flags);
if (threshold->dlpa) {
memcpy(&threshold->downlink_packets,
(unsigned char *)octet->data + size,
sizeof(threshold->downlink_packets));
threshold->downlink_packets = be64toh(threshold->downlink_packets);
size += sizeof(threshold->downlink_packets);
}
if (threshold->dlby) {
memcpy(&threshold->number_of_bytes_of_downlink_data,
(unsigned char *)octet->data + size,
sizeof(threshold->number_of_bytes_of_downlink_data));
threshold->number_of_bytes_of_downlink_data =
be64toh(threshold->number_of_bytes_of_downlink_data);
size += sizeof(threshold->number_of_bytes_of_downlink_data);
}
ogs_assert(size == octet->len);
return size;
}

View File

@ -933,6 +933,211 @@ typedef struct ogs_pfcp_user_plane_report_s {
} error_indication;
} ogs_pfcp_user_plane_report_t;
/*
* 8.2.40 Measurement Method
*
* Octet 5 shall be encoded as follows:
* - Bit 1 DURAT (Duration): when set to "1",
* this indicates a request for measuring the duration of the traffic.
* - Bit 2 VOLUM (Volume): when set to "1",
* this indicates a request for measuring the volume of the traffic.
* - Bit 3 EVENT (Event): when set to "1",
* this indicates a request for measuring the events.
* - Bit 4 to 8: Spare, for future use and set to "0".
*
* At least one bit shall be set to "1". Several bits may be set to "1".
*/
#define OGS_PFCP_MEASUREMENT_METHOD_DURATION 1
#define OGS_PFCP_MEASUREMENT_METHOD_VOLUME 2
#define OGS_PFCP_MEASUREMENT_METHOD_EVENT 4
typedef uint8_t ogs_pfcp_measurement_method_t;
/*
* 8.2.41 Usage Report Trigger
*
* The Usage Report Trigger IE shall be encoded as shown in Figure 8.2.41-1.
* It indicates the trigger of the usage report.
*/
typedef struct ogs_pfcp_reporting_triggers_s {
union {
struct {
ED8(uint8_t linked_usage_reporting:1;,
uint8_t dropped_dl_traffic_threshold:1;,
uint8_t stop_of_traffic:1;,
uint8_t start_of_traffic:1;,
uint8_t quota_holding_time:1;,
uint8_t time_threshold:1;,
uint8_t volume_threshold:1;,
uint8_t periodic_reporting:1;)
};
uint8_t reptri_5;
};
union {
struct {
ED8(uint8_t quota_validity_time:1;,
uint8_t ip_multicast_join_leave:1;,
uint8_t event_quota:1;,
uint8_t event_threshold:1;,
uint8_t mac_addresses_reporting:1;,
uint8_t envelope_closure:1;,
uint8_t time_quota:1;,
uint8_t volume_quota:1;)
};
uint8_t reptri_6;
};
union {
struct {
ED2(uint8_t spare:7;,
uint8_t report_the_end_marker_reception:1;)
};
uint8_t reptri_7;
};
} __attribute__ ((packed)) ogs_pfcp_reporting_triggers_t;
/*
* 8.2.42 Measurement Period
*
* The Measurement Period IE contains the period, in seconds,
* for generating periodic usage reports or the periodic QoS monitoring reports.
* It shall be encoded as shown in Figure 8.2.42-1.
*
* The Measurement Period field shall be encoded
* as an Unsigned32 binary integer value.
*/
typedef uint32_t ogs_pfcp_measurement_period_t;
/*
* 8.2.13 Volume Threshold
*/
typedef struct ogs_pfcp_volume_threshold_s {
union {
struct {
ED4(uint8_t spare:5;,
uint8_t dlvol:1;,
uint8_t ulvol:1;,
uint8_t tovol:1;)
};
uint8_t flags;
};
uint64_t total_volume;
uint64_t uplink_volume;
uint64_t downlink_volume;
} __attribute__ ((packed)) ogs_pfcp_volume_threshold_t;
int16_t ogs_pfcp_build_volume(ogs_tlv_octet_t *octet,
ogs_pfcp_volume_threshold_t *volume, void *data, int data_len);
int16_t ogs_pfcp_parse_volume(
ogs_pfcp_volume_threshold_t *volume, ogs_tlv_octet_t *octet);
/*
* 8.2.50 Volume Quota
*/
typedef ogs_pfcp_volume_threshold_t ogs_pfcp_volume_quota_t;
/*
* 8.2.113 Event Threshold
*
* The Event Threshold IE contains the Number of events after
* which the measurement report is to be generated by the UP function.
*
* It shall be encoded as shown in Figure 8.2.113-1.
*/
typedef uint32_t ogs_pfcp_event_threshold_t;
/*
* 8.2.112 Event Quota
*
* The Event Quota IE type shall be encoded as shown in Figure 8.2.112-1.
* It contains the event quota to be monitored by the UP function.
*/
typedef uint32_t ogs_pfcp_event_quota_t;
/*
* 8.2.14 Time Threshold
*
* The Time Threshold IE contains the traffic duration threshold
* to be monitored by the UP function. It shall be encoded as shown
* in Figure 8.2.14-1.
*/
typedef uint32_t ogs_pfcp_time_threshold_t;
/*
* 8.2.51 Time Quota
*
* The Time Quota IE type shall be encoded as shown in Figure 8.2.51-1.
* It contains the time quota to be monitored by the UP function.
*/
typedef uint32_t ogs_pfcp_time_quota_t;
/*
* 8.2.48 Quota Holding Time
*
* The Quota Holding Time IE type shall be encoded as shown in Figure 8.2.48-1.
* It contains the quota holding time in seconds.
*
* The Quota Holding Time value shall be encoded as
* an Unsigned32 binary integer value.
*/
typedef uint32_t ogs_pfcp_quota_holding_time_t;
/*
* 8.2.132 Quota Validity Time
*
* The Quota Validity Time IE type shall be encoded as shown
* in Figure 8.2.132-1. It contains the quota validity time in seconds.
*
* The Quota Validity Time value shall be encoded as
* an Unsigned32 binary integer value.
*/
typedef uint32_t ogs_pfcp_quota_validity_time_t;
/*
* 8.2.49 Dropped DL Traffic Threshold
*
* The Dropped DL Traffic Threshold IE type shall be encoded as shown
* in Figure 8.2.49-1. It contains the dropped DL traffic volume thresholds
* to be monitored by the UP function.
*
* The following flags are coded within Octet 5:
* - Bit 1 DLPA: If this bit is set to "1",
* then the Downlink Packets field shall be present,
* otherwise the Downlink Packets field shall not be present.
* - Bit 2 DLBY: If this bit is set to "1",
* then the Number of Bytes of Downlink Data field shall be present,
* otherwise the Number of Bytes of Downlink Data field shall not be present.
* - Bit 3 to 8: Spare, for future use and set to "0".
*
*
* The Downlink Packets fields shall be encoded as an Unsigned64 binary
* integer value. It shall contain a number of downlink packets.
*
* The Number of Bytes of Downlink Data fields shall be encoded
* as an Unsigned64 binary integer value. It shall contain the number
* of bytes of the downlink data.
*/
typedef struct ogs_pfcp_dropped_dl_traffic_threshold_s {
union {
struct {
ED3(uint8_t spare:6;,
uint8_t dlpa:1;,
uint8_t dlby:1;)
};
uint8_t flags;
};
uint64_t downlink_packets;
uint64_t number_of_bytes_of_downlink_data;
} __attribute__ ((packed)) ogs_pfcp_dropped_dl_traffic_threshold_t;
int16_t ogs_pfcp_build_dropped_dl_traffic_threshold(
ogs_tlv_octet_t *octet,
ogs_pfcp_dropped_dl_traffic_threshold_t *threshold,
void *data, int data_len);
int16_t ogs_pfcp_parse_dropped_dl_traffic_threshold(
ogs_pfcp_dropped_dl_traffic_threshold_t *threshold,
ogs_tlv_octet_t *octet);
#ifdef __cplusplus
}
#endif

View File

@ -1592,6 +1592,7 @@ smf_bearer_t *smf_qos_flow_add(smf_sess_t *sess)
ogs_pfcp_pdr_t *ul_pdr = NULL;
ogs_pfcp_far_t *dl_far = NULL;
ogs_pfcp_far_t *ul_far = NULL;
ogs_pfcp_urr_t *urr = NULL;
ogs_pfcp_qer_t *qer = NULL;
ogs_assert(sess);
@ -1608,6 +1609,7 @@ smf_bearer_t *smf_qos_flow_add(smf_sess_t *sess)
ogs_list_init(&qos_flow->pf_list);
/* PDR */
dl_pdr = ogs_pfcp_pdr_add(&sess->pfcp);
ogs_assert(dl_pdr);
qos_flow->dl_pdr = dl_pdr;
@ -1645,6 +1647,7 @@ smf_bearer_t *smf_qos_flow_add(smf_sess_t *sess)
ul_pdr->outer_header_removal.gtpu_extheader_deletion =
OGS_PFCP_PDU_SESSION_CONTAINER_TO_BE_DELETED;
/* FAR */
dl_far = ogs_pfcp_far_add(&sess->pfcp);
ogs_assert(dl_far);
qos_flow->dl_far = dl_far;
@ -1665,6 +1668,19 @@ smf_bearer_t *smf_qos_flow_add(smf_sess_t *sess)
ul_far->apply_action = OGS_PFCP_APPLY_ACTION_FORW;
/* URR */
urr = ogs_pfcp_urr_add(&sess->pfcp);
ogs_assert(urr);
qos_flow->urr = urr;
urr->meas_method = OGS_PFCP_MEASUREMENT_METHOD_VOLUME;
urr->rep_triggers.volume_threshold = 1;
urr->vol_threshold.tovol = 1;
urr->vol_threshold.total_volume = 1024*1024*100;
ogs_pfcp_pdr_associate_urr(dl_pdr, urr);
/* QER */
qer = ogs_pfcp_qer_add(&sess->pfcp);
ogs_assert(qer);
qos_flow->qer = qer;
@ -1943,6 +1959,7 @@ smf_bearer_t *smf_bearer_add(smf_sess_t *sess)
ogs_list_init(&bearer->pf_list);
/* PDR */
dl_pdr = ogs_pfcp_pdr_add(&sess->pfcp);
ogs_assert(dl_pdr);
bearer->dl_pdr = dl_pdr;
@ -1976,6 +1993,7 @@ smf_bearer_t *smf_bearer_add(smf_sess_t *sess)
} else
ogs_assert_if_reached();
/* FAR */
dl_far = ogs_pfcp_far_add(&sess->pfcp);
ogs_assert(dl_far);
bearer->dl_far = dl_far;
@ -2018,6 +2036,8 @@ int smf_bearer_remove(smf_bearer_t *bearer)
ogs_pfcp_far_remove(bearer->dl_far);
ogs_assert(bearer->ul_far);
ogs_pfcp_far_remove(bearer->ul_far);
if (bearer->urr)
ogs_pfcp_urr_remove(bearer->urr);
if (bearer->qer)
ogs_pfcp_qer_remove(bearer->qer);

View File

@ -156,6 +156,7 @@ typedef struct smf_bearer_s {
ogs_pfcp_pdr_t *ul_pdr;
ogs_pfcp_far_t *dl_far;
ogs_pfcp_far_t *ul_far;
ogs_pfcp_urr_t *urr;
ogs_pfcp_qer_t *qer;
uint8_t *qfi_node; /* Pool-Node for 5GC-QFI */

View File

@ -67,6 +67,14 @@ void upf_n4_handle_session_establishment_request(
if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
goto cleanup;
for (i = 0; i < OGS_MAX_NUM_OF_URR; i++) {
if (ogs_pfcp_handle_create_urr(&sess->pfcp, &req->create_urr[i],
&cause_value, &offending_ie_value) == NULL)
break;
}
if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
goto cleanup;
for (i = 0; i < OGS_MAX_NUM_OF_QER; i++) {
if (ogs_pfcp_handle_create_qer(&sess->pfcp, &req->create_qer[i],
&cause_value, &offending_ie_value) == NULL)
@ -264,6 +272,30 @@ void upf_n4_handle_session_modification_request(
if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
goto cleanup;
for (i = 0; i < OGS_MAX_NUM_OF_URR; i++) {
if (ogs_pfcp_handle_create_urr(&sess->pfcp, &req->create_urr[i],
&cause_value, &offending_ie_value) == NULL)
break;
}
if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
goto cleanup;
for (i = 0; i < OGS_MAX_NUM_OF_URR; i++) {
if (ogs_pfcp_handle_update_urr(&sess->pfcp, &req->update_urr[i],
&cause_value, &offending_ie_value) == NULL)
break;
}
if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
goto cleanup;
for (i = 0; i < OGS_MAX_NUM_OF_URR; i++) {
if (ogs_pfcp_handle_remove_urr(&sess->pfcp, &req->remove_urr[i],
&cause_value, &offending_ie_value) == false)
break;
}
if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
goto cleanup;
for (i = 0; i < OGS_MAX_NUM_OF_QER; i++) {
if (ogs_pfcp_handle_create_qer(&sess->pfcp, &req->create_qer[i],
&cause_value, &offending_ie_value) == NULL)