2019-04-27 14:54:30 +00:00
|
|
|
/*
|
|
|
|
* 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_GTP_INSIDE) && !defined(OGS_GTP_COMPILATION)
|
|
|
|
#error "This header cannot be included directly."
|
|
|
|
#endif
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2021-03-15 01:01:55 +00:00
|
|
|
#ifndef OGS_GTP_CONTEXT_H
|
|
|
|
#define OGS_GTP_CONTEXT_H
|
2017-12-01 15:44:07 +00:00
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2019-06-11 09:28:25 +00:00
|
|
|
#endif
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2021-03-15 01:01:55 +00:00
|
|
|
typedef struct ogs_gtp_context_s {
|
|
|
|
uint32_t gtpc_port; /* GTPC local port */
|
|
|
|
uint32_t gtpu_port; /* GTPU local port */
|
|
|
|
|
|
|
|
ogs_list_t gtpc_list; /* GTPC IPv4 Server List */
|
|
|
|
ogs_list_t gtpc_list6; /* GTPC IPv6 Server List */
|
|
|
|
ogs_sock_t *gtpc_sock; /* GTPC IPv4 Socket */
|
|
|
|
ogs_sock_t *gtpc_sock6; /* GTPC IPv6 Socket */
|
|
|
|
ogs_sockaddr_t *gtpc_addr; /* GTPC IPv4 Address */
|
|
|
|
ogs_sockaddr_t *gtpc_addr6; /* GTPC IPv6 Address */
|
|
|
|
|
|
|
|
ogs_list_t gtpu_list; /* GTPU IPv4/IPv6 Server List */
|
|
|
|
ogs_sock_t *gtpu_sock; /* GTPU IPv4 Socket */
|
|
|
|
ogs_sock_t *gtpu_sock6; /* GTPU IPv6 Socket */
|
|
|
|
ogs_sockaddr_t *gtpu_addr; /* GTPU IPv4 Address */
|
|
|
|
ogs_sockaddr_t *gtpu_addr6; /* GTPU IPv6 Address */
|
|
|
|
|
|
|
|
ogs_ip_t gtpu_ip; /* GTPU IP */;
|
|
|
|
|
|
|
|
ogs_list_t gtpu_peer_list; /* GTPU Node List */
|
|
|
|
ogs_list_t gtpu_resource_list; /* UP IP Resource List */
|
2021-12-17 02:33:54 +00:00
|
|
|
|
|
|
|
ogs_sockaddr_t *link_local_addr;
|
2021-03-15 01:01:55 +00:00
|
|
|
} ogs_gtp_context_t;
|
|
|
|
|
2019-09-13 12:07:47 +00:00
|
|
|
#define OGS_SETUP_GTP_NODE(__cTX, __gNODE) \
|
2017-12-06 08:58:38 +00:00
|
|
|
do { \
|
2019-04-27 14:54:30 +00:00
|
|
|
ogs_assert((__cTX)); \
|
|
|
|
ogs_assert((__gNODE)); \
|
2017-12-06 08:58:38 +00:00
|
|
|
(__cTX)->gnode = __gNODE; \
|
|
|
|
} while(0)
|
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
/**
|
|
|
|
* This structure represents the commonalities of GTP node such as MME, SGW,
|
|
|
|
* PGW gateway. Some of members may not be used by the specific type of node */
|
2019-09-13 12:07:47 +00:00
|
|
|
typedef struct ogs_gtp_node_s {
|
2019-04-27 14:54:30 +00:00
|
|
|
ogs_lnode_t node; /* A node of list_t */
|
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
|
|
|
void *data_ptr; /* Can be used by app */
|
2017-12-04 10:45:02 +00:00
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_sockaddr_t *sa_list; /* Socket Address List Candidate */
|
2017-12-04 10:45:02 +00:00
|
|
|
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_sock_t *sock; /* Socket Instance */
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_sockaddr_t addr; /* Remote Address */
|
|
|
|
|
|
|
|
ogs_ip_t ip; /* F-TEID IP Address Duplicate Check */
|
2017-12-04 10:45:02 +00:00
|
|
|
|
2022-01-18 02:23:40 +00:00
|
|
|
ogs_list_t local_list;
|
|
|
|
ogs_list_t remote_list;
|
2019-09-13 12:07:47 +00:00
|
|
|
} ogs_gtp_node_t;
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2021-03-15 01:01:55 +00:00
|
|
|
typedef struct ogs_gtpu_resource_s {
|
|
|
|
ogs_lnode_t lnode;
|
|
|
|
|
|
|
|
ogs_user_plane_ip_resource_info_t info;
|
|
|
|
} ogs_gtpu_resource_t;
|
|
|
|
|
|
|
|
void ogs_gtp_context_init(int num_of_gtpu_resource);
|
|
|
|
void ogs_gtp_context_final(void);
|
|
|
|
ogs_gtp_context_t *ogs_gtp_self(void);
|
|
|
|
int ogs_gtp_context_parse_config(const char *local, const char *remote);
|
2017-12-02 05:17:32 +00:00
|
|
|
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_new(ogs_sockaddr_t *sa_list);
|
2019-09-13 12:07:47 +00:00
|
|
|
void ogs_gtp_node_free(ogs_gtp_node_t *node);
|
2018-09-23 04:16:40 +00:00
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_add_by_f_teid(
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_list_t *list, ogs_gtp2_f_teid_t *f_teid, uint16_t port);
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_add_by_addr(
|
|
|
|
ogs_list_t *list, ogs_sockaddr_t *addr);
|
2019-09-13 12:07:47 +00:00
|
|
|
void ogs_gtp_node_remove(ogs_list_t *list, ogs_gtp_node_t *node);
|
|
|
|
void ogs_gtp_node_remove_all(ogs_list_t *list);
|
2017-12-06 11:52:32 +00:00
|
|
|
|
2019-11-07 14:07:29 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_find_by_addr(
|
|
|
|
ogs_list_t *list, ogs_sockaddr_t *addr);
|
|
|
|
ogs_gtp_node_t *ogs_gtp_node_find_by_f_teid(
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_list_t *list, ogs_gtp2_f_teid_t *f_teid);
|
2017-12-02 05:17:32 +00:00
|
|
|
|
2021-03-15 01:01:55 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_add_by_ip(
|
|
|
|
ogs_list_t *list, ogs_ip_t *ip, uint16_t port);
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_gtp_node_t *ogs_gtp_node_find_by_ip(ogs_list_t *list, ogs_ip_t *ip);
|
|
|
|
|
2021-03-15 01:01:55 +00:00
|
|
|
ogs_gtpu_resource_t *ogs_gtpu_resource_add(ogs_list_t *list,
|
|
|
|
ogs_user_plane_ip_resource_info_t *info);
|
|
|
|
void ogs_gtpu_resource_remove(ogs_list_t *list,
|
|
|
|
ogs_gtpu_resource_t *resource);
|
|
|
|
void ogs_gtpu_resource_remove_all(ogs_list_t *list);
|
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2019-06-11 09:28:25 +00:00
|
|
|
#endif
|
2017-11-30 11:13:15 +00:00
|
|
|
|
2021-03-15 01:01:55 +00:00
|
|
|
#endif /* OGS_GTP_CONTEXT_H */
|