forked from open5gs/open5gs
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pcrf json dbi #1
Open
lynxis
wants to merge
12
commits into
pespin:main
Choose a base branch
from
lynxis:pcrf_json_dbi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c72f41f
[dbi]: ogs_mongoc.h: remove include <mongoc.h>
lynxis 8b3abcc
[dbi]: ogs-dbi.h: add comment to the include of ogs-mongoc.h
lynxis 68efeac
[dbi]: move all mongo related files into subdirectory
lynxis 9c66348
[dbi]: introduce an abstraction layer to allow multiple database back…
lynxis f0c97bf
[dbi]: mongo: merge all parts from ogs_dbi_final() into ogs_mongoc_fi…
lynxis 0e0de17
[dbi]: make ogs_dbi_final depend on the selected database driver
lynxis c54fb59
[dbi]: make all db functions optional
lynxis 0d6ef1e
[dbi] add database backend json
lynxis 9d7737c
[dbi] session_data(): add argument charging characteristics
lynxis 1a6ceca
[app/pcrf]: parse json database configuration
lynxis 8960372
[pcrf]: Gx: parse 3GPP Charging Characteristic
lynxis 1151c6a
[dbi]: allow to build without mongodb
lynxis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <[email protected]> | ||
* Author: Alexander Couzens <[email protected]> | ||
* | ||
* 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/>. | ||
*/ | ||
|
||
#if !defined(OGS_DBI_INSIDE) && !defined(OGS_DBI_COMPILATION) | ||
#error "This header cannot be included directly." | ||
#endif | ||
|
||
#ifndef OGS_DBI_PRIVATE_H | ||
#define OGS_DBI_PRIVATE_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
struct ogs_dbi_s { | ||
const char *name; | ||
void (*final)(void); | ||
/* session */ | ||
int (*session_data)(char *supi, ogs_s_nssai_t *s_nssai, char *dnn, | ||
ogs_session_data_t *data); | ||
/* ims */ | ||
int (*msisdn_data)(char *imsi_or_msisdn_bcd, ogs_msisdn_data_t *msisdn_data); | ||
int (*ims_data)(char *supi, ogs_ims_data_t *ims_data); | ||
/* subscription */ | ||
int (*auth_info)(char *supi, ogs_dbi_auth_info_t *auth_info); | ||
int (*update_sqn)(char *supi, uint64_t sqn); | ||
int (*increment_sqn)(char *supi); | ||
int (*update_imeisv)(char *supi, char *imeisv); | ||
int (*subscription_data)(char *supi, | ||
ogs_subscription_data_t *subscription_data); | ||
}; | ||
typedef struct ogs_dbi_s ogs_dbi_t; | ||
|
||
int ogs_dbi_deselect_interface(void); | ||
int ogs_dbi_select_interface(const char *dbi_name); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* OGS_DBI_PRIVATE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <[email protected]> | ||
* Author: Alexander Couzens <[email protected]> | ||
* | ||
* 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 "ogs-dbi.h" | ||
|
||
#include "dbi-private.h" | ||
#include "dbi-config-private.h" | ||
|
||
#ifdef WITH_MONGOC | ||
#include "mongo/mongo-private.h" | ||
#endif | ||
#include "json/json-private.h" | ||
|
||
int __ogs_dbi_domain; | ||
|
||
static ogs_dbi_t *dbi_interfaces[] = { | ||
#ifdef WITH_MONGOC | ||
&ogs_dbi_mongo_interface, | ||
#endif | ||
&ogs_dbi_json_interface, | ||
NULL, | ||
}; | ||
|
||
static ogs_dbi_t *dbi_selected; | ||
|
||
int ogs_dbi_deselect_interface() | ||
{ | ||
dbi_selected = NULL; | ||
|
||
return 0; | ||
} | ||
|
||
int ogs_dbi_select_interface(const char *dbi_name) | ||
{ | ||
ogs_dbi_t *dbi; | ||
int i; | ||
ogs_assert(dbi_name); | ||
|
||
for (i = 0; i < OGS_ARRAY_SIZE(dbi_interfaces); i++) { | ||
dbi = dbi_interfaces[i]; | ||
if (!ogs_strcasecmp(dbi->name, dbi_name)) { | ||
dbi_selected = dbi; | ||
return 0; | ||
} | ||
} | ||
|
||
ogs_error("Couldn't find dbi interface %s", dbi_name); | ||
return -1; | ||
} | ||
|
||
void ogs_dbi_final(void) | ||
{ | ||
if (!dbi_selected) | ||
return; | ||
|
||
dbi_selected->final(); | ||
} | ||
|
||
/* ims */ | ||
int ogs_dbi_msisdn_data( | ||
char *imsi_or_msisdn_bcd, ogs_msisdn_data_t *msisdn_data) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->msisdn_data) | ||
return OGS_ERROR; | ||
return dbi_selected->msisdn_data(imsi_or_msisdn_bcd, msisdn_data); | ||
} | ||
|
||
int ogs_dbi_ims_data(char *supi, ogs_ims_data_t *ims_data) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->ims_data) | ||
return OGS_ERROR; | ||
return dbi_selected->ims_data(supi, ims_data); | ||
} | ||
|
||
/* session */ | ||
int ogs_dbi_session_data(char *supi, ogs_s_nssai_t *s_nssai, char *dnn, | ||
ogs_session_data_t *session_data) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->session_data) | ||
return OGS_ERROR; | ||
return dbi_selected->session_data(supi, s_nssai, dnn, session_data); | ||
} | ||
|
||
/* subscription */ | ||
int ogs_dbi_auth_info(char *supi, ogs_dbi_auth_info_t *auth_info) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->auth_info) | ||
return OGS_ERROR; | ||
return dbi_selected->auth_info(supi, auth_info); | ||
} | ||
|
||
int ogs_dbi_update_sqn(char *supi, uint64_t sqn) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->update_sqn) | ||
return OGS_ERROR; | ||
return dbi_selected->update_sqn(supi, sqn); | ||
} | ||
|
||
int ogs_dbi_increment_sqn(char *supi) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->increment_sqn) | ||
return OGS_ERROR; | ||
return dbi_selected->increment_sqn(supi); | ||
} | ||
|
||
int ogs_dbi_update_imeisv(char *supi, char *imeisv) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->update_imeisv) | ||
return OGS_ERROR; | ||
return dbi_selected->update_imeisv(supi, imeisv); | ||
} | ||
|
||
int ogs_dbi_subscription_data(char *supi, | ||
ogs_subscription_data_t *subscription_data) | ||
{ | ||
ogs_assert(dbi_selected); | ||
if (!dbi_selected->subscription_data) | ||
return OGS_ERROR; | ||
return dbi_selected->subscription_data(supi, subscription_data); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so how is one or the other selected for use? I don't recall seeing any explanation anywhere.