open5gs/src/pcf/context.h

180 lines
4.4 KiB
C
Raw Normal View History

2020-12-11 19:03:20 +00:00
/*
* Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
2020-12-11 19:03:20 +00:00
*
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef PCF_CONTEXT_H
#define PCF_CONTEXT_H
#include "ogs-app.h"
#include "ogs-crypt.h"
#include "ogs-sbi.h"
2021-01-01 02:07:08 +00:00
#include "ogs-dbi.h"
2020-12-11 19:03:20 +00:00
#include "pcf-sm.h"
[PCF] Add metrics support Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in PCF by using hash. The metrics are named respecting the rule: <generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552> Since slice itself is not unique, the plmnid label is exposed in addition to snssai. AM policy: fivegs_pcffunction_pa_policyamassoreq and fivegs_pcffunction_pa_policyamassosucc do not expose snssai label since it is not available at the time of exposure. plmnid is defined during AM policy processing, so not to lose the difference to ...succ, the basic metric fivegs_pcffunction_pa_policyamassoreq is preserved. SM policy: snssai is defined during SM policy processing, so not to lose the difference to ...succ, the basic metric fivegs_pcffunction_pa_policysmassoreq is preserved. Those 2 basic metrics retain their position but are exposed with empty labels. Metrics with labels are called later, when the label values are known. Exposed metrics example: -standard counters: fivegs_pcffunction_pa_policyamassoreq{plmnid=""} 3 fivegs_pcffunction_pa_policyamassoreq{plmnid="99970"} 3 fivegs_pcffunction_pa_policyamassosucc{plmnid="99970"} 3 fivegs_pcffunction_pa_policysmassoreq{plmnid="",snssai=""} 3 fivegs_pcffunction_pa_policysmassoreq{plmnid="99970",snssai="1000009"} 3 fivegs_pcffunction_pa_policysmassosucc{plmnid="99970",snssai="1000009"} 3 -nonstandard gauge (added for controlling purposes - same metric as existing metric on AMF and SMF): fivegs_pcffunction_pa_sessionnbr{plmnid="99970",snssai="1000009"} 0
2022-08-18 10:20:26 +00:00
#include "metrics.h"
2020-12-11 19:03:20 +00:00
#ifdef __cplusplus
extern "C" {
#endif
extern int __pcf_log_domain;
#undef OGS_LOG_DOMAIN
#define OGS_LOG_DOMAIN __pcf_log_domain
typedef struct pcf_context_s {
ogs_list_t pcf_ue_list;
ogs_hash_t *supi_hash;
ogs_hash_t *ipv4addr_hash;
ogs_hash_t *ipv6prefix_hash;
2020-12-11 19:03:20 +00:00
} pcf_context_t;
struct pcf_ue_s {
ogs_sbi_object_t sbi;
ogs_fsm_t sm;
char *association_id;
char *supi;
char *notification_uri;
struct {
ogs_sbi_client_t *client;
} namf;
char *gpsi;
OpenAPI_access_type_e access_type;
char *pei;
2020-12-11 19:03:20 +00:00
ogs_guami_t guami;
OpenAPI_rat_type_e rat_type;
/* SBI Features */
uint64_t am_policy_control_features;
2021-01-01 02:07:08 +00:00
OpenAPI_policy_association_request_t *policy_association_request;
OpenAPI_ambr_t *subscribed_ue_ambr;
2020-12-11 19:03:20 +00:00
ogs_list_t sess_list;
};
struct pcf_sess_s {
ogs_sbi_object_t sbi;
ogs_fsm_t sm;
char *sm_policy_id;
/* BSF sends the RESPONSE
* of [POST] /nbsf-management/v1/PcfBindings */
char *binding_id;
2020-12-11 19:03:20 +00:00
uint8_t psi; /* PDU Session Identity */
uint8_t pdu_session_type;
char *dnn;
2020-12-11 19:03:20 +00:00
char *notification_uri;
struct {
ogs_sbi_client_t *client;
} nsmf;
char *ipv4addr_string;
char *ipv6prefix_string;
uint32_t ipv4addr;
struct {
uint8_t len;
uint8_t addr6[OGS_IPV6_LEN];
} ipv6prefix;
2020-12-11 19:03:20 +00:00
ogs_s_nssai_t s_nssai;
/* SBI Features */
uint64_t smpolicycontrol_features;
uint64_t management_features;
uint64_t policyauthorization_features;
2021-01-01 02:07:08 +00:00
OpenAPI_ambr_t *subscribed_sess_ambr;
OpenAPI_subscribed_default_qos_t *subscribed_default_qos;
2021-11-14 12:07:56 +00:00
ogs_list_t app_list;
2020-12-11 19:03:20 +00:00
/* Related Context */
2021-01-01 02:07:08 +00:00
pcf_ue_t *pcf_ue;
2020-12-11 19:03:20 +00:00
};
2021-11-14 12:07:56 +00:00
typedef struct pcf_app_s {
ogs_lnode_t lnode;
char *app_session_id;
char *notif_uri;
struct {
ogs_sbi_client_t *client;
} naf;
ogs_pcc_rule_t pcc_rule[OGS_MAX_NUM_OF_PCC_RULE];
int num_of_pcc_rule;
pcf_sess_t *sess;
} pcf_app_t;
2020-12-11 19:03:20 +00:00
void pcf_context_init(void);
void pcf_context_final(void);
pcf_context_t *pcf_self(void);
int pcf_context_parse_config(void);
pcf_ue_t *pcf_ue_add(char *supi);
void pcf_ue_remove(pcf_ue_t *pcf_ue);
void pcf_ue_remove_all(void);
pcf_ue_t *pcf_ue_find_by_supi(char *supi);
pcf_ue_t *pcf_ue_find_by_association_id(char *association_id);
pcf_sess_t *pcf_sess_add(pcf_ue_t *pcf_ue, uint8_t psi);
void pcf_sess_remove(pcf_sess_t *sess);
void pcf_sess_remove_all(pcf_ue_t *pcf_ue);
bool pcf_sess_set_ipv4addr(pcf_sess_t *sess, char *ipv4addr);
bool pcf_sess_set_ipv6prefix(pcf_sess_t *sess, char *ipv6prefix);
pcf_sess_t *pcf_sess_find(uint32_t index);
pcf_sess_t *pcf_sess_find_by_sm_policy_id(char *sm_policy_id);
2020-12-11 19:03:20 +00:00
pcf_sess_t *pcf_sess_find_by_psi(pcf_ue_t *pcf_ue, uint8_t psi);
pcf_sess_t *pcf_sess_find_by_dnn(pcf_ue_t *pcf_ue, char *dnn);
pcf_sess_t *pcf_sess_find_by_ipv4addr(char *ipv4addr_string);
pcf_sess_t *pcf_sess_find_by_ipv6addr(char *ipv6addr_string);
pcf_sess_t *pcf_sess_find_by_ipv6prefix(char *ipv6prefix_string);
2021-12-02 13:03:52 +00:00
int pcf_sessions_number_by_snssai_and_dnn(
pcf_ue_t *pcf_ue, ogs_s_nssai_t *s_nssai, char *dnn);
2020-12-11 19:03:20 +00:00
pcf_ue_t *pcf_ue_cycle(pcf_ue_t *pcf_ue);
pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess);
2021-11-14 12:07:56 +00:00
pcf_app_t *pcf_app_add(pcf_sess_t *sess);
int pcf_app_remove(pcf_app_t *app);
void pcf_app_remove_all(pcf_sess_t *sess);
pcf_app_t *pcf_app_find(uint32_t index);
pcf_app_t *pcf_app_find_by_app_session_id(char *app_session_id);
2020-12-11 19:03:20 +00:00
#ifdef __cplusplus
}
#endif
#endif /* PCF_CONTEXT_H */