open5gs/lib/app/ogs-context.h

192 lines
4.2 KiB
C
Raw Normal View History

/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* 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/>.
*/
2019-09-13 12:07:47 +00:00
#if !defined(OGS_APP_INSIDE) && !defined(OGS_APP_COMPILATION)
#error "This header cannot be included directly."
#endif
2019-04-27 14:54:30 +00:00
#ifndef OGS_APP_CONTEXT_H
#define OGS_APP_CONTEXT_H
2019-09-13 12:07:47 +00:00
2019-04-27 14:54:30 +00:00
#ifdef __cplusplus
extern "C" {
2019-09-13 12:07:47 +00:00
#endif
2019-04-27 14:54:30 +00:00
#define OGS_APP_DB_JSON_MAX_APNS 16
typedef struct ogs_app_context_s {
const char *version;
const char *file;
2019-04-27 14:54:30 +00:00
void *document;
const char *db_uri;
struct {
const char *apn;
const char *filepath;
} db_json[OGS_APP_DB_JSON_MAX_APNS];
2019-04-27 14:54:30 +00:00
struct {
const char *file;
const char *level;
const char *domain;
} logger;
ogs_queue_t *queue;
ogs_timer_mgr_t *timer_mgr;
ogs_pollset_t *pollset;
2019-04-27 14:54:30 +00:00
struct {
/* Element */
2020-08-13 00:31:22 +00:00
int no_mme;
2019-04-27 14:54:30 +00:00
int no_hss;
int no_sgw;
2020-08-13 00:31:22 +00:00
int no_sgwc;
int no_sgwu;
2019-04-27 14:54:30 +00:00
int no_pgw;
int no_pcrf;
2020-05-25 16:15:22 +00:00
int no_amf;
int no_smf;
int no_upf;
2020-06-04 18:12:05 +00:00
int no_ausf;
int no_udm;
2020-12-11 19:03:20 +00:00
int no_pcf;
int no_nssf;
int no_bsf;
2020-06-04 18:12:05 +00:00
int no_udr;
int no_scp;
2020-05-25 16:15:22 +00:00
int no_nrf;
2019-04-27 14:54:30 +00:00
/* Network */
int no_ipv4;
int no_ipv6;
int prefer_ipv4;
int multicast;
int use_openair;
int no_ipv4v6_local_addr_in_packet_filter;
int no_pfcp_rr_select;
2019-04-27 14:54:30 +00:00
} parameter;
struct {
int no_delay;
int l_onoff;
int l_linger;
} sockopt;
2019-06-01 12:30:13 +00:00
struct {
int udp_port;
} usrsctp;
2019-05-31 07:33:09 +00:00
struct {
uint64_t ue;
uint64_t peer;
uint64_t gtp_peer;
} max;
2019-04-27 14:54:30 +00:00
struct {
ogs_pkbuf_config_t defconfig;
uint64_t packet;
uint64_t sess;
uint64_t bearer;
uint64_t tunnel;
uint64_t nf_service;
uint64_t timer;
uint64_t message;
uint64_t event;
uint64_t socket;
uint64_t subscription;
uint64_t xact;
2022-08-10 02:03:10 +00:00
uint64_t stream;
uint64_t nf;
uint64_t gtp_node;
uint64_t csmap;
2021-04-05 08:09:39 +00:00
uint64_t impi;
uint64_t impu;
} pool;
2020-05-18 21:00:37 +00:00
struct {
struct {
2020-07-27 01:02:40 +00:00
int heartbeat_interval;
int no_heartbeat_margin;
int validity_duration;
2020-05-18 21:00:37 +00:00
} nf_instance;
struct {
2020-07-27 01:02:40 +00:00
int validity_duration;
2020-05-18 21:00:37 +00:00
} subscription;
2020-07-27 01:02:40 +00:00
struct {
ogs_time_t duration;
struct {
ogs_time_t client_wait_duration;
ogs_time_t connection_deadline;
2020-07-27 01:02:40 +00:00
ogs_time_t nf_register_interval;
ogs_time_t nf_register_interval_in_exception;
} sbi;
struct {
ogs_time_t t3_response_duration;
int n3_response_rcount;
ogs_time_t t3_holding_duration;
int n3_holding_rcount;
} gtp;
struct {
ogs_time_t t1_response_duration;
int n1_response_rcount;
ogs_time_t t1_holding_duration;
int n1_holding_rcount;
ogs_time_t association_interval;
ogs_time_t no_heartbeat_duration;
} pfcp;
} message;
struct {
ogs_time_t duration;
ogs_time_t complete_delay;
} handover;
2020-05-18 21:00:37 +00:00
} time;
Initial metrics support based on Prometheus (#1571) * Initial metrics support based on Prometheus This commit introduces initial support for metrics in open5gs. The metrics code is added as libogsmetrics (lib/metrics/), with a well defined opaque API to manage different types of metrics, allowing for different implementations for different technologies to scrap the metrics (placed as lib/metrics/<impl>/. The implementation is right now selected at build time, in order to be able to opt-out the related dependencies for users not interested in the features. 2 implementations are already provided in this commit to start with: * void: Default implementation. Empty stubs, acts as a NOOP. * prometheus: open5gs processes become Prometheus servers, offering states through an http server to the Prometheus scrappers. Relies on libprom (prometheus-client-ci [1] project) to track the metrics and format them during export, and libmicrohttpd to make the export possible through HTTP. [1] https://github.com/digitalocean/prometheus-client-c The prometheus-client-c is not well maintained nowadays in upstream, and furthermore it uses a quite peculiar mixture of build systems (autolib on the main dir, cmake for libprom in a subdir). This makes it difficult to have it widely available in distros, and difficult to find it if it is installed in the system. Hence, the best is to include it as a meson subproject like we already do for freeDiameter. An open5gs fork is requried in order to have an extra patch adding a top-level CMakeList.txt in order to be able to includ eit from open5gs's meson build. Furthermore, this allows adding bugfixes to the subproject if any are found in the future. * [SMF] Initial metrics support * [SMF] Add metrics at gtp_node level * docs: Add tutorial documenting metrics with Prometheus
2022-06-07 20:51:02 +00:00
struct metrics {
uint64_t max_specs;
} metrics;
} ogs_app_context_t;
int ogs_app_context_init(void);
void ogs_app_context_final(void);
ogs_app_context_t *ogs_app(void);
2019-04-27 14:54:30 +00:00
int ogs_app_context_parse_config(void);
2019-04-27 14:54:30 +00:00
#ifdef __cplusplus
}
2019-09-13 12:07:47 +00:00
#endif
2019-04-27 14:54:30 +00:00
#endif /* OGS_APP_CONTEXT_H */