2020-04-26 19:36:05 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SMF_EVENT_H
|
|
|
|
#define SMF_EVENT_H
|
|
|
|
|
|
|
|
#include "ogs-core.h"
|
2022-04-14 01:30:58 +00:00
|
|
|
#include "ogs-gtp.h"
|
2020-04-26 19:36:05 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct ogs_gtp_node_s ogs_gtp_node_t;
|
|
|
|
typedef struct ogs_gtp_xact_s ogs_gtp_xact_t;
|
|
|
|
typedef struct ogs_pfcp_node_s ogs_pfcp_node_t;
|
|
|
|
typedef struct ogs_pfcp_xact_s ogs_pfcp_xact_t;
|
|
|
|
typedef struct ogs_pfcp_message_s ogs_pfcp_message_t;
|
2022-02-19 00:47:44 +00:00
|
|
|
typedef struct ogs_diam_gx_message_s ogs_diam_gx_message_t;
|
2022-04-08 23:26:28 +00:00
|
|
|
typedef struct ogs_diam_gy_message_s ogs_diam_gy_message_t;
|
2022-04-20 12:42:18 +00:00
|
|
|
typedef struct ogs_diam_s6b_message_s ogs_diam_s6b_message_t;
|
2020-04-26 19:36:05 +00:00
|
|
|
typedef struct smf_sess_s smf_sess_t;
|
|
|
|
typedef struct smf_upf_s smf_upf_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
|
|
|
typedef struct smf_gtp_node_s smf_gtp_node_t;
|
2020-05-18 21:00:37 +00:00
|
|
|
typedef struct ogs_sbi_request_s ogs_sbi_request_t;
|
|
|
|
typedef struct ogs_sbi_response_s ogs_sbi_response_t;
|
|
|
|
typedef struct ogs_sbi_message_s ogs_sbi_message_t;
|
|
|
|
typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t;
|
2020-06-17 05:22:28 +00:00
|
|
|
typedef struct ogs_nas_5gs_message_s ogs_nas_5gs_message_t;
|
|
|
|
typedef struct NGAP_NGAP_PDU ogs_ngap_message_t;
|
|
|
|
typedef long NGAP_ProcedureCode_t;
|
2020-04-26 19:36:05 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SMF_EVT_BASE = OGS_FSM_USER_SIG,
|
|
|
|
|
|
|
|
SMF_EVT_S5C_MESSAGE,
|
2022-04-20 12:42:18 +00:00
|
|
|
SMF_EVT_S6B_MESSAGE,
|
Introduce Gn interface (GTPv1C) Support to PGW (#1351)
* [CORE] tlv: Store mode in ogs_tlv_t
This allows specifying the format of the IE for each individual IE,
hence allowing messages containing IEs formatted in different ways.
This is needed in order to support parsing GTPv1-C, since messages
contain IEs with different structure (TLV vs TV). Hence, this is a
preparation patch to add support for parsing TVs in ogs-tlv.c/.h.
* [CORE] tlv: Support parsing msg with both TLV and TV in it
IEs of type TV are sometimes used in GTPv1-C. Current tlv parser/builder
doesn't provide with ways to parse messages which contain TV formatted
IEs. This patch adds the relevant types and ways to encode/decode them.
Furthermore, the current parser/builder allows parsing/building messages
containing the exact same format in all its IEs. A new parser function
is added which allows parsing messages of different types (TV, TLV)
mixed in the same message. In order to be able to do so, it uses the
general msg_mode passed to it in order to know the general TLV format
(in essence, the length of the Tag field, and also the length of the
Length field if applicable each IE).
Looking up the instance in the TLV description is left undone and
hadcoded to 0, since the only user so far requiring this API is GTPv1-C,
which has no instances.
* [CORE] tlv: Support repeated tag+instance parsing TLV message
In GTPv2C, repeated IEs (same tag) are easily differentiated by the
Instance byte, which provides info to match different decoded
structures. In GTPv1C though, there's no Instance byte, and we still
encounter repeated IEs (like GSN Address in Create PDP Context Request).
Hence, the TLV decoder needs to be updated to track count of IEs found
(identified by tag+instance, where instance is always 0 in GTPv1C) and
get the proper description index + offset into the decoded structure.
* [GTP]: Move GTPv2-C specifics to its own libgtp subdir
This will allow adding GTPv1-C code by the side. Most GTPv2 code is left
in this patch as "gtp" instead of renaming it to "gtp2" in order to
avoid massive changes. It can be done at a later stage if wanted.
* [GTP] Support generating GTPv1-C messages
* [SMF] Add Gn interface support
This patch introduces GTPv1C support to open5gs-smfd. With it,
open5gs-becomes a GGSN too, where SGSN can connect to, hence supporting
GERAN and UTRAN networks.
2022-02-18 13:23:45 +00:00
|
|
|
SMF_EVT_GN_MESSAGE,
|
2020-04-26 19:36:05 +00:00
|
|
|
SMF_EVT_GX_MESSAGE,
|
2022-04-08 23:26:28 +00:00
|
|
|
SMF_EVT_GY_MESSAGE,
|
2020-04-26 19:36:05 +00:00
|
|
|
|
|
|
|
SMF_EVT_N4_MESSAGE,
|
|
|
|
SMF_EVT_N4_TIMER,
|
|
|
|
SMF_EVT_N4_NO_HEARTBEAT,
|
|
|
|
|
2020-05-18 21:00:37 +00:00
|
|
|
SMF_EVT_SBI_SERVER,
|
|
|
|
SMF_EVT_SBI_CLIENT,
|
|
|
|
SMF_EVT_SBI_TIMER,
|
|
|
|
|
2020-06-17 05:22:28 +00:00
|
|
|
SMF_EVT_NGAP_MESSAGE,
|
|
|
|
SMF_EVT_NGAP_TIMER,
|
|
|
|
|
|
|
|
SMF_EVT_5GSM_MESSAGE,
|
|
|
|
SMF_EVT_5GSM_TIMER,
|
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
SMF_EVT_TOP,
|
|
|
|
|
|
|
|
} smf_event_e;
|
|
|
|
|
|
|
|
typedef struct smf_event_s {
|
|
|
|
int id;
|
|
|
|
ogs_pkbuf_t *pkbuf;
|
|
|
|
int timer_id;
|
|
|
|
|
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
|
|
|
smf_gtp_node_t *gnode;
|
2020-04-26 19:36:05 +00:00
|
|
|
ogs_gtp_xact_t *gtp_xact;
|
|
|
|
|
|
|
|
ogs_pfcp_node_t *pfcp_node;
|
|
|
|
ogs_pfcp_xact_t *pfcp_xact;
|
|
|
|
ogs_pfcp_message_t *pfcp_message;
|
|
|
|
|
2022-04-14 01:30:58 +00:00
|
|
|
union {
|
|
|
|
ogs_gtp1_message_t *gtp1_message;
|
|
|
|
ogs_gtp2_message_t *gtp2_message;
|
|
|
|
};
|
|
|
|
|
2022-04-08 23:26:28 +00:00
|
|
|
union {
|
|
|
|
ogs_diam_gx_message_t *gx_message;
|
|
|
|
ogs_diam_gy_message_t *gy_message;
|
2022-04-20 12:42:18 +00:00
|
|
|
ogs_diam_s6b_message_t *s6b_message;
|
2022-04-08 23:26:28 +00:00
|
|
|
};
|
2022-02-19 00:47:44 +00:00
|
|
|
|
2020-05-18 21:00:37 +00:00
|
|
|
struct {
|
|
|
|
ogs_sbi_request_t *request;
|
|
|
|
ogs_sbi_response_t *response;
|
|
|
|
void *data;
|
2021-01-01 02:07:08 +00:00
|
|
|
int state;
|
2020-05-18 21:00:37 +00:00
|
|
|
|
|
|
|
ogs_sbi_message_t *message;
|
|
|
|
} sbi;
|
|
|
|
|
2020-06-17 05:22:28 +00:00
|
|
|
struct {
|
|
|
|
int type;
|
|
|
|
ogs_ngap_message_t *message;
|
|
|
|
} ngap;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint8_t type;
|
|
|
|
ogs_nas_5gs_message_t *message;
|
|
|
|
} nas;
|
|
|
|
|
2020-04-26 19:36:05 +00:00
|
|
|
smf_sess_t *sess;
|
|
|
|
} smf_event_t;
|
|
|
|
|
|
|
|
void smf_event_init(void);
|
|
|
|
void smf_event_final(void);
|
|
|
|
|
|
|
|
smf_event_t *smf_event_new(smf_event_e id);
|
|
|
|
void smf_event_free(smf_event_t *e);
|
|
|
|
|
|
|
|
const char *smf_event_get_name(smf_event_t *e);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* SMF_EVENT_H */
|