mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-04 22:13:26 +00:00
[PCRF/HSS] Added missing files for enabling metrics (#3442)
This commit is contained in:
11
src/pcrf/metrics.c
Normal file
11
src/pcrf/metrics.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "metrics.h"
|
||||||
|
|
||||||
|
void pcrf_metrics_init(void)
|
||||||
|
{
|
||||||
|
ogs_metrics_context_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pcrf_metrics_final(void)
|
||||||
|
{
|
||||||
|
ogs_metrics_context_final();
|
||||||
|
}
|
||||||
17
src/pcrf/metrics.h
Normal file
17
src/pcrf/metrics.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef PCRF_METRICS_H
|
||||||
|
#define PCRF_METRICS_H
|
||||||
|
|
||||||
|
#include "ogs-metrics.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void pcrf_metrics_init(void);
|
||||||
|
void pcrf_metrics_final(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PCRF_METRICS_H */
|
||||||
76
src/pcrf/pcrf-event.c
Normal file
76
src/pcrf/pcrf-event.c
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pcrf-event.h"
|
||||||
|
#include "ogs-app.h"
|
||||||
|
|
||||||
|
static OGS_POOL(pool, pcrf_event_t);
|
||||||
|
|
||||||
|
void pcrf_event_init(void)
|
||||||
|
{
|
||||||
|
ogs_pool_init(&pool, ogs_app()->pool.event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pcrf_event_term(void)
|
||||||
|
{
|
||||||
|
ogs_queue_term(ogs_app()->queue);
|
||||||
|
ogs_pollset_notify(ogs_app()->pollset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pcrf_event_final(void)
|
||||||
|
{
|
||||||
|
ogs_pool_final(&pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
pcrf_event_t *pcrf_event_new(pcrf_event_e id)
|
||||||
|
{
|
||||||
|
pcrf_event_t *e = NULL;
|
||||||
|
|
||||||
|
ogs_pool_alloc(&pool, &e);
|
||||||
|
ogs_assert(e);
|
||||||
|
memset(e, 0, sizeof(*e));
|
||||||
|
|
||||||
|
e->id = id;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pcrf_event_free(pcrf_event_t *e)
|
||||||
|
{
|
||||||
|
ogs_assert(e);
|
||||||
|
ogs_pool_free(&pool, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *pcrf_event_get_name(pcrf_event_t *e)
|
||||||
|
{
|
||||||
|
if (e == NULL)
|
||||||
|
return OGS_FSM_NAME_INIT_SIG;
|
||||||
|
|
||||||
|
switch (e->id) {
|
||||||
|
case OGS_FSM_ENTRY_SIG:
|
||||||
|
return OGS_FSM_NAME_ENTRY_SIG;
|
||||||
|
case OGS_FSM_EXIT_SIG:
|
||||||
|
return OGS_FSM_NAME_EXIT_SIG;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "UNKNOWN_EVENT";
|
||||||
|
}
|
||||||
57
src/pcrf/pcrf-event.h
Normal file
57
src/pcrf/pcrf-event.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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 PCRF_EVENT_H
|
||||||
|
#define PCRF_EVENT_H
|
||||||
|
|
||||||
|
#include "ogs-proto.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PCRF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT,
|
||||||
|
|
||||||
|
PCRF_EVT_TOP,
|
||||||
|
} pcrf_event_e;
|
||||||
|
|
||||||
|
typedef struct pcrf_event_s {
|
||||||
|
int id;
|
||||||
|
int timer_id;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
void *document;
|
||||||
|
} dbi;
|
||||||
|
} pcrf_event_t;
|
||||||
|
|
||||||
|
void pcrf_event_init(void);
|
||||||
|
void pcrf_event_term(void);
|
||||||
|
void pcrf_event_final(void);
|
||||||
|
|
||||||
|
pcrf_event_t *pcrf_event_new(pcrf_event_e id);
|
||||||
|
void pcrf_event_free(pcrf_event_t *e);
|
||||||
|
|
||||||
|
const char *pcrf_event_get_name(pcrf_event_t *e);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PCRF_EVENT_H */
|
||||||
55
src/pcrf/pcrf-sm.c
Normal file
55
src/pcrf/pcrf-sm.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pcrf-sm.h"
|
||||||
|
#include "pcrf-context.h"
|
||||||
|
#include "pcrf-event.h"
|
||||||
|
|
||||||
|
void pcrf_state_initial(ogs_fsm_t *s, pcrf_event_t *e)
|
||||||
|
{
|
||||||
|
pcrf_sm_debug(e);
|
||||||
|
|
||||||
|
ogs_assert(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pcrf_state_final(ogs_fsm_t *s, pcrf_event_t *e)
|
||||||
|
{
|
||||||
|
pcrf_sm_debug(e);
|
||||||
|
|
||||||
|
ogs_assert(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pcrf_state_operational(ogs_fsm_t *s, pcrf_event_t *e)
|
||||||
|
{
|
||||||
|
pcrf_sm_debug(e);
|
||||||
|
|
||||||
|
ogs_assert(s);
|
||||||
|
|
||||||
|
switch (e->id) {
|
||||||
|
case OGS_FSM_ENTRY_SIG:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OGS_FSM_EXIT_SIG:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ogs_error("No handler for event %s", pcrf_event_get_name(e));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/pcrf/pcrf-sm.h
Normal file
42
src/pcrf/pcrf-sm.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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 PCRF_SM_H
|
||||||
|
#define PCRF_SM_H
|
||||||
|
|
||||||
|
#include "pcrf-event.h"
|
||||||
|
#include "ogs-proto.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void pcrf_state_initial(ogs_fsm_t *s, pcrf_event_t *e);
|
||||||
|
void pcrf_state_final(ogs_fsm_t *s, pcrf_event_t *e);
|
||||||
|
void pcrf_state_operational(ogs_fsm_t *s, pcrf_event_t *e);
|
||||||
|
void pcrf_state_exception(ogs_fsm_t *s, pcrf_event_t *e);
|
||||||
|
|
||||||
|
#define pcrf_sm_debug(__pe) \
|
||||||
|
ogs_debug("%s(): %s", __func__, pcrf_event_get_name(__pe))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PCRF_SM_H */
|
||||||
Reference in New Issue
Block a user