[app/pcrf]: parse json database configuration
To make use of the new json database backend, allow the pcrf to parse json backend configuration.
This commit is contained in:
parent
eabb847a48
commit
6b1813131c
|
@ -0,0 +1,17 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 4660,
|
||||||
|
"qci": 8,
|
||||||
|
"priority": 5,
|
||||||
|
"pre_emption_capability": 0,
|
||||||
|
"pre_emption_vulnerability": 1,
|
||||||
|
"ambr": {
|
||||||
|
"up": 999,
|
||||||
|
"down": 1000
|
||||||
|
},
|
||||||
|
"gmbr": {
|
||||||
|
"up": 500,
|
||||||
|
"down": 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,32 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": -1,
|
||||||
|
"qci": 5,
|
||||||
|
"priority": 5,
|
||||||
|
"pre_emption_capability": 0,
|
||||||
|
"pre_emption_vulnerability": 1,
|
||||||
|
"ambr": {
|
||||||
|
"up": 1000,
|
||||||
|
"down": 10000
|
||||||
|
},
|
||||||
|
"gmbr": {
|
||||||
|
"up": 500,
|
||||||
|
"down": 500
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4660,
|
||||||
|
"qci": 5,
|
||||||
|
"priority": 5,
|
||||||
|
"pre_emption_capability": 0,
|
||||||
|
"pre_emption_vulnerability": 1,
|
||||||
|
"ambr": {
|
||||||
|
"up": 1000,
|
||||||
|
"down": 10000
|
||||||
|
},
|
||||||
|
"gmbr": {
|
||||||
|
"up": 500,
|
||||||
|
"down": 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,55 @@
|
||||||
|
# db_json
|
||||||
|
# allow to use json templates for the policy
|
||||||
|
# a * will be used if the apn isn't defined. it can be omitted.
|
||||||
|
db_json:
|
||||||
|
internet: @sysconfdir@/open5gs/pcrf-internet.json
|
||||||
|
"*": @sysconfdir@/open5gs/pcrf-default.json
|
||||||
|
|
||||||
|
#
|
||||||
|
# logger:
|
||||||
|
#
|
||||||
|
# o Set OGS_LOG_INFO to all domain level
|
||||||
|
# - If `level` is omitted, the default level is OGS_LOG_INFO)
|
||||||
|
# - If `domain` is omitted, the all domain level is set from 'level'
|
||||||
|
# (Nothing is needed)
|
||||||
|
#
|
||||||
|
# o Set OGS_LOG_ERROR to all domain level
|
||||||
|
# - `level` can be set with none, fatal, error, warn, info, debug, trace
|
||||||
|
# level: error
|
||||||
|
#
|
||||||
|
# o Set OGS_LOG_DEBUG to mme/emm domain level
|
||||||
|
# level: debug
|
||||||
|
# domain: mme,emm
|
||||||
|
#
|
||||||
|
# o Set OGS_LOG_TRACE to all domain level
|
||||||
|
# level: trace
|
||||||
|
# domain: core,fd,pcrf,event,mem,sock
|
||||||
|
logger:
|
||||||
|
file: @localstatedir@/log/open5gs/pcrf.log
|
||||||
|
|
||||||
|
pcrf:
|
||||||
|
freeDiameter: @sysconfdir@/freeDiameter/pcrf.conf
|
||||||
|
|
||||||
|
#
|
||||||
|
# parameter:
|
||||||
|
#
|
||||||
|
# o Disable use of IPv4 addresses (only IPv6)
|
||||||
|
# no_ipv4: true
|
||||||
|
#
|
||||||
|
# o Disable use of IPv6 addresses (only IPv4)
|
||||||
|
# no_ipv6: true
|
||||||
|
#
|
||||||
|
# o Prefer IPv4 instead of IPv6 for estabishing new GTP connections.
|
||||||
|
# prefer_ipv4: true
|
||||||
|
#
|
||||||
|
parameter:
|
||||||
|
|
||||||
|
#
|
||||||
|
# max:
|
||||||
|
#
|
||||||
|
# o Maximum Number of UE
|
||||||
|
# ue: 1024
|
||||||
|
# o Maximum Number of Peer(S1AP/NGAP, DIAMETER, GTP, PFCP or SBI)
|
||||||
|
# peer: 64
|
||||||
|
#
|
||||||
|
max:
|
|
@ -252,6 +252,25 @@ int ogs_app_context_parse_config(void)
|
||||||
ogs_assert(root_key);
|
ogs_assert(root_key);
|
||||||
if (!strcmp(root_key, "db_uri")) {
|
if (!strcmp(root_key, "db_uri")) {
|
||||||
self.db_uri = ogs_yaml_iter_value(&root_iter);
|
self.db_uri = ogs_yaml_iter_value(&root_iter);
|
||||||
|
} else if (!strcmp(root_key, "db_json")) {
|
||||||
|
ogs_yaml_iter_t dbjson_iter;
|
||||||
|
ogs_yaml_iter_recurse(&root_iter, &dbjson_iter);
|
||||||
|
int apns = 0;
|
||||||
|
while (ogs_yaml_iter_next(&dbjson_iter)) {
|
||||||
|
const char *apn = ogs_yaml_iter_key(&dbjson_iter);
|
||||||
|
const char *apn_filepath;
|
||||||
|
|
||||||
|
if (apns >= OGS_APP_DB_JSON_MAX_APNS) {
|
||||||
|
ogs_error("db_json: too many apns defined!");
|
||||||
|
return OGS_ERROR;
|
||||||
|
}
|
||||||
|
ogs_assert(apn);
|
||||||
|
apn_filepath = ogs_yaml_iter_value(&dbjson_iter);
|
||||||
|
ogs_assert(apn_filepath);
|
||||||
|
self.db_json[apns].apn = apn;
|
||||||
|
self.db_json[apns].filepath = apn_filepath;
|
||||||
|
apns++;
|
||||||
|
}
|
||||||
} else if (!strcmp(root_key, "logger")) {
|
} else if (!strcmp(root_key, "logger")) {
|
||||||
ogs_yaml_iter_t logger_iter;
|
ogs_yaml_iter_t logger_iter;
|
||||||
ogs_yaml_iter_recurse(&root_iter, &logger_iter);
|
ogs_yaml_iter_recurse(&root_iter, &logger_iter);
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define OGS_APP_DB_JSON_MAX_APNS 16
|
||||||
|
|
||||||
typedef struct ogs_app_context_s {
|
typedef struct ogs_app_context_s {
|
||||||
const char *version;
|
const char *version;
|
||||||
|
|
||||||
|
@ -35,6 +37,11 @@ typedef struct ogs_app_context_s {
|
||||||
void *document;
|
void *document;
|
||||||
|
|
||||||
const char *db_uri;
|
const char *db_uri;
|
||||||
|
struct {
|
||||||
|
const char *apn;
|
||||||
|
const char *filepath;
|
||||||
|
} db_json[OGS_APP_DB_JSON_MAX_APNS];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *file;
|
const char *file;
|
||||||
const char *level;
|
const char *level;
|
||||||
|
|
|
@ -35,8 +35,21 @@ int pcrf_initialize(void)
|
||||||
ogs_app()->logger.domain, ogs_app()->logger.level);
|
ogs_app()->logger.domain, ogs_app()->logger.level);
|
||||||
if (rv != OGS_OK) return rv;
|
if (rv != OGS_OK) return rv;
|
||||||
|
|
||||||
rv = ogs_dbi_init(ogs_app()->db_uri);
|
if (ogs_app()->db_uri) {
|
||||||
if (rv != OGS_OK) return rv;
|
rv = ogs_dbi_mongo_init(ogs_app()->db_uri);
|
||||||
|
if (rv != OGS_OK) return rv;
|
||||||
|
} else if (ogs_app()->db_json[0].apn) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < OGS_APP_DB_JSON_MAX_APNS; i++) {
|
||||||
|
if (ogs_app()->db_json[i].apn && ogs_app()->db_json[i].filepath) {
|
||||||
|
rv = ogs_dbi_json_init(ogs_app()->db_json[i].filepath, ogs_app()->db_json[i].apn);
|
||||||
|
if (rv != OGS_OK) return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ogs_error("No database selected!");
|
||||||
|
return OGS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
rv = pcrf_fd_init();
|
rv = pcrf_fd_init();
|
||||||
if (rv != OGS_OK) return OGS_ERROR;
|
if (rv != OGS_OK) return OGS_ERROR;
|
||||||
|
|
Loading…
Reference in New Issue