Re-factoring the all library

This commit is contained in:
Sukchan Lee 2019-09-13 21:07:47 +09:00
parent bd0ac4bd80
commit 3c8af69805
707 changed files with 20755 additions and 24286 deletions

24
.gitignore vendored
View File

@ -9,24 +9,24 @@
.libs
# generated files
lib/freeDiameter-*/build-aux/*
lib/freeDiameter-*/config.status
lib/freeDiameter-*/m4/*.m4
lib/freeDiameter-*/!m4/ax_*.m4
lib/freeDiameter-*/libfdcore/fdd.tab.[chy]
lib/freeDiameter-*/libfdcore/lex.fdd.[cl]
lib/freeDiameter-*/include/freeDiameter/version.h
lib/freeDiameter-*/include/freeDiameter/config.h.in*
lib/freeDiameter-*/include/freeDiameter/config.h
lib/freeDiameter-*/include/freeDiameter/freeDiameter-host.h
lib/freeDiameter/build-aux/*
lib/freeDiameter/config.status
lib/freeDiameter/m4/*.m4
lib/freeDiameter/!m4/ax_*.m4
lib/freeDiameter/libfdcore/fdd.tab.[chy]
lib/freeDiameter/libfdcore/lex.fdd.[cl]
lib/freeDiameter/include/freeDiameter/version.h
lib/freeDiameter/include/freeDiameter/freeDiameter-config.h.in*
lib/freeDiameter/include/freeDiameter/freeDiameter-config.h
lib/freeDiameter/include/freeDiameter/freeDiameter-host.h
support/systemd/nextepc-*.service
support/logrotate/nextepc
# autotools
stamp-h1
config.h
lib/base/nextepc-config.h
lib/base/nextepc-config.h.in*
lib/nextepc-config.h
lib/nextepc-config.h.in*
config.log
config.status
configure

View File

@ -46,6 +46,12 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src \
$(NULL)
DEFS = \
@DEFS@ \
-DSYSCONF_DIR=\"$(sysconfdir)/\" \
-DLOCALSTATE_DIR=\"$(localstatedir)/\" \
$(NULL)
install-data-hook:
$(MKDIR_P) $(DESTDIR)/$(localstatedir)/log/nextepc
$(MKDIR_P) $(DESTDIR)/$(localstatedir)/run/nextepc-mmed

View File

@ -29,7 +29,7 @@ AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_HEADERS([lib/base/nextepc-config.h])
AC_CONFIG_HEADERS([lib/nextepc-config.h])
AC_CONFIG_SRCDIR([main.c])
LO_DEV="lo0"
@ -165,26 +165,26 @@ AC_CHECK_HEADERS(netinet/ip_icmp.h netinet/icmp6.h,,,[[
PKG_CHECK_MODULES([YAML], yaml-0.1 >= 0.1.4)
PKG_CHECK_MODULES([MONGOC], libmongoc-1.0 >= 1.3.1)
FREEDIAMETER_DIR=freeDiameter-1.2.1
AC_SUBST(FREEDIAMETER_DIR)
#####################
#### Conclusion. ####
#####################
AC_CONFIG_SUBDIRS([lib/freeDiameter-1.2.1])
AC_CONFIG_SUBDIRS([lib/freeDiameter])
AC_CONFIG_FILES([lib/base/Makefile])
AC_CONFIG_FILES([lib/asn1c/Makefile])
AC_CONFIG_FILES([lib/s1ap/Makefile])
AC_CONFIG_FILES([lib/nas/Makefile])
AC_CONFIG_FILES([lib/fd/Makefile])
AC_CONFIG_FILES([lib/diameter/Makefile])
AC_CONFIG_FILES([lib/gtp/Makefile])
AC_CONFIG_FILES([lib/ipfw/Makefile])
AC_CONFIG_FILES([lib/dbi/Makefile])
AC_CONFIG_FILES([lib/sctp/Makefile])
AC_CONFIG_FILES([lib/app/Makefile])
AC_CONFIG_FILES([lib/Makefile])
AC_CONFIG_FILES([src/app/Makefile])
AC_CONFIG_FILES([src/mme/Makefile])
AC_CONFIG_FILES([src/hss/Makefile])
AC_CONFIG_FILES([src/sgw/Makefile])
AC_CONFIG_FILES([src/pgw/ipfw/Makefile])
AC_CONFIG_FILES([src/pgw/Makefile])
AC_CONFIG_FILES([src/pcrf/Makefile])
AC_CONFIG_FILES([src/Makefile])

View File

@ -1,15 +1,9 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = @FREEDIAMETER_DIR@ ipfw
DIST_SUBDIRS = @FREEDIAMETER_DIR@ ipfw
SUBDIRS = freeDiameter
if WITH_SRCLIB
SUBDIRS += ogslib
DIST_SUBDIRS += ogslib
endif
SUBDIRS += base asn1c nas fd gtp
DIST_SUBDIRS += base asn1c nas fd gtp
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = *.stackdump
SUBDIRS += asn1c s1ap nas diameter gtp dbi sctp app

28
lib/app/Makefile.am Normal file
View File

@ -0,0 +1,28 @@
## Process this file with automake to produce Makefile.in.
pkglib_LTLIBRARIES = libogsapp.la
libogsapp_la_SOURCES = \
ogs-yaml.h ogs-yaml.c \
ogs-config.h ogs-config.c \
ogs-init.h ogs-init.c \
$(NULL)
libogsapp_la_LIBADD = \
@OGSCORE_LIBS@ \
@YAML_LIBS@ \
$(NULL)
libogsapp_la_DEPENDENCIES = \
$(NULL)
AM_CPPFLAGS = \
@OGSCORE_CFLAGS@ \
@YAML_CFLAGS@ \
-I$(top_srcdir)/lib \
$(NULL)
AM_CFLAGS = \
-DOGS_APP_COMPILATION \
-Wall -Werror \
$(NULL)

View File

@ -17,54 +17,45 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <mongoc.h>
#include <yaml.h>
#include "ogs-app.h"
#include "base/types.h"
static ogs_config_t self;
#include "context.h"
static int initialized = 0;
#define DEFAULT_SCTP_STREAMS 30
static context_t self;
static int context_initialized = 0;
int context_init()
int ogs_config_init()
{
ogs_assert(context_initialized == 0);
ogs_assert(initialized == 0);
memset(&self, 0, sizeof(context_t));
memset(&self, 0, sizeof(ogs_config_t));
context_initialized = 1;
initialized = 1;
return OGS_OK;
}
int context_final()
int ogs_config_final()
{
ogs_assert(context_initialized == 1);
ogs_assert(initialized == 1);
ogs_pkbuf_default_destroy();
if (self.config.document) {
yaml_document_delete(self.config.document);
free(self.config.document);
if (self.document) {
yaml_document_delete(self.document);
free(self.document);
}
context_initialized = 0;
initialized = 0;
return OGS_OK;
}
context_t* context_self()
ogs_config_t *ogs_config()
{
return &self;
}
int context_read_file()
int ogs_config_read()
{
config_t *config = &self.config;
ogs_config_t *config = &self;
FILE *file;
yaml_parser_t parser;
yaml_document_t *document = NULL;
@ -141,19 +132,23 @@ int context_read_file()
return OGS_OK;
}
static void context_recalculate_pool_size()
static void recalculate_pool_size()
{
self.pool.ue = self.config.max.ue * self.config.max.enb;
self.pool.sess = self.pool.ue * MAX_NUM_OF_SESS;
#define MAX_NUM_OF_BEARER 4 /* Num of Bearer per APN(Session) */
#define MAX_NUM_OF_TUNNEL 3 /* Num of Tunnel per Bearer */
#define MAX_NUM_OF_PF 16 /* Num of PacketFilter per Bearer */
self.pool.ue = self.max.ue * self.max.enb;
self.pool.sess = self.pool.ue * OGS_MAX_NUM_OF_SESS;
self.pool.bearer = self.pool.sess * MAX_NUM_OF_BEARER;
self.pool.tunnel = self.pool.bearer * MAX_NUM_OF_TUNNEL;
self.pool.pf = self.pool.bearer * MAX_NUM_OF_PF;
}
static int context_prepare()
static int config_prepare()
{
#define USRSCTP_LOCAL_UDP_PORT 9899
self.config.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT;
self.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT;
#define MAX_NUM_OF_SGW 32 /* Num of SGW per MME */
#define MAX_NUM_OF_PGW 32 /* Num of PGW per MME */
@ -161,38 +156,38 @@ static int context_prepare()
#define MAX_NUM_OF_CSMAP 128 /* Num of TAI-LAI MAP per MME */
#define MAX_NUM_OF_ENB 32 /* Num of eNodeB per MME */
#define MAX_NUM_OF_UE 128 /* Num of UE per eNodeB */
self.config.max.sgw = MAX_NUM_OF_SGW;
self.config.max.pgw = MAX_NUM_OF_PGW;
self.config.max.vlr = MAX_NUM_OF_VLR;
self.config.max.csmap = MAX_NUM_OF_CSMAP;
self.config.max.enb = MAX_NUM_OF_ENB;
self.config.max.ue = MAX_NUM_OF_UE;
self.max.sgw = MAX_NUM_OF_SGW;
self.max.pgw = MAX_NUM_OF_PGW;
self.max.vlr = MAX_NUM_OF_VLR;
self.max.csmap = MAX_NUM_OF_CSMAP;
self.max.enb = MAX_NUM_OF_ENB;
self.max.ue = MAX_NUM_OF_UE;
#define MAX_NUM_OF_PACKET_POOL 65536
self.config.pool.packet = MAX_NUM_OF_PACKET_POOL;
self.pool.packet = MAX_NUM_OF_PACKET_POOL;
ogs_pkbuf_default_init(&self.config.pool.defconfig);
ogs_pkbuf_default_init(&self.pool.defconfig);
context_recalculate_pool_size();
recalculate_pool_size();
return OGS_OK;
}
static int context_validation()
static int ogs_app_ctx_validation()
{
if (self.config.parameter.no_ipv4 == 1 &&
self.config.parameter.no_ipv6 == 1) {
if (self.parameter.no_ipv4 == 1 &&
self.parameter.no_ipv6 == 1) {
ogs_error("Both `no_ipv4` and `no_ipv6` set to `true` in `%s`",
context_self()->config.file);
self.file);
return OGS_ERROR;
}
return OGS_OK;
}
int context_parse_config()
int ogs_config_parse()
{
int rv;
config_t *config = &self.config;
ogs_config_t *config = &self;
yaml_document_t *document = NULL;
ogs_yaml_iter_t root_iter;
@ -200,7 +195,7 @@ int context_parse_config()
document = config->document;
ogs_assert(document);
rv = context_prepare();
rv = config_prepare();
if (rv != OGS_OK) return rv;
ogs_yaml_iter_init(&root_iter, document);
@ -208,7 +203,7 @@ int context_parse_config()
const char *root_key = ogs_yaml_iter_key(&root_iter);
ogs_assert(root_key);
if (!strcmp(root_key, "db_uri")) {
self.config.db_uri = ogs_yaml_iter_value(&root_iter);
self.db_uri = ogs_yaml_iter_value(&root_iter);
} else if (!strcmp(root_key, "logger")) {
ogs_yaml_iter_t logger_iter;
ogs_yaml_iter_recurse(&root_iter, &logger_iter);
@ -216,12 +211,12 @@ int context_parse_config()
const char *logger_key = ogs_yaml_iter_key(&logger_iter);
ogs_assert(logger_key);
if (!strcmp(logger_key, "file")) {
self.config.logger.file = ogs_yaml_iter_value(&logger_iter);
self.logger.file = ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "level")) {
self.config.logger.level =
self.logger.level =
ogs_yaml_iter_value(&logger_iter);
} else if (!strcmp(logger_key, "domain")) {
self.config.logger.domain =
self.logger.domain =
ogs_yaml_iter_value(&logger_iter);
}
}
@ -232,31 +227,31 @@ int context_parse_config()
const char *parameter_key = ogs_yaml_iter_key(&parameter_iter);
ogs_assert(parameter_key);
if (!strcmp(parameter_key, "no_hss")) {
self.config.parameter.no_hss =
self.parameter.no_hss =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "no_sgw")) {
self.config.parameter.no_sgw =
self.parameter.no_sgw =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "no_pgw")) {
self.config.parameter.no_pgw =
self.parameter.no_pgw =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "no_pcrf")) {
self.config.parameter.no_pcrf =
self.parameter.no_pcrf =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "no_ipv4")) {
self.config.parameter.no_ipv4 =
self.parameter.no_ipv4 =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "no_ipv6")) {
self.config.parameter.no_ipv6 =
self.parameter.no_ipv6 =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "prefer_ipv4")) {
self.config.parameter.prefer_ipv4 =
self.parameter.prefer_ipv4 =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "multicast")) {
self.config.parameter.multicast =
self.parameter.multicast =
ogs_yaml_iter_bool(&parameter_iter);
} else if (!strcmp(parameter_key, "no_slaac")) {
self.config.parameter.no_slaac =
self.parameter.no_slaac =
ogs_yaml_iter_bool(&parameter_iter);
} else
ogs_warn("unknown key `%s`", parameter_key);
@ -269,34 +264,34 @@ int context_parse_config()
ogs_assert(sctp_key);
if (!strcmp(sctp_key, "heartbit_interval")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.config.sockopt.sctp.heartbit_interval = atoi(v);
if (v) self.sockopt.sctp.heartbit_interval = atoi(v);
} else if (!strcmp(sctp_key, "rto_initial")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.config.sockopt.sctp.rto_initial = atoi(v);
if (v) self.sockopt.sctp.rto_initial = atoi(v);
} else if (!strcmp(sctp_key, "rto_min")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.config.sockopt.sctp.rto_min = atoi(v);
if (v) self.sockopt.sctp.rto_min = atoi(v);
} else if (!strcmp(sctp_key, "rto_max")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.config.sockopt.sctp.rto_max = atoi(v);
if (v) self.sockopt.sctp.rto_max = atoi(v);
} else if (!strcmp(sctp_key, "max_num_of_ostreams")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v)
self.config.sockopt.sctp.max_num_of_ostreams = atoi(v);
self.sockopt.sctp.max_num_of_ostreams = atoi(v);
} else if (!strcmp(sctp_key, "max_num_of_istreams")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v)
self.config.sockopt.sctp.max_num_of_istreams = atoi(v);
self.sockopt.sctp.max_num_of_istreams = atoi(v);
} else if (!strcmp(sctp_key, "max_attempts")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.config.sockopt.sctp.max_attempts = atoi(v);
if (v) self.sockopt.sctp.max_attempts = atoi(v);
} else if (!strcmp(sctp_key, "max_initial_timeout")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v)
self.config.sockopt.sctp.max_initial_timeout = atoi(v);
self.sockopt.sctp.max_initial_timeout = atoi(v);
} else if (!strcmp(sctp_key, "usrsctp_udp_port")) {
const char *v = ogs_yaml_iter_value(&sctp_iter);
if (v) self.config.usrsctp.udp_port = atoi(v);
if (v) self.usrsctp.udp_port = atoi(v);
} else
ogs_warn("unknown key `%s`", sctp_key);
}
@ -308,15 +303,15 @@ int context_parse_config()
ogs_assert(max_key);
if (!strcmp(max_key, "ue")) {
const char *v = ogs_yaml_iter_value(&max_iter);
if (v) self.config.max.ue = atoi(v);
if (v) self.max.ue = atoi(v);
} else if (!strcmp(max_key, "enb")) {
const char *v = ogs_yaml_iter_value(&max_iter);
if (v) self.config.max.enb = atoi(v);
if (v) self.max.enb = atoi(v);
} else
ogs_warn("unknown key `%s`", max_key);
}
context_recalculate_pool_size();
recalculate_pool_size();
} else if (!strcmp(root_key, "pool")) {
ogs_yaml_iter_t pool_iter;
ogs_yaml_iter_recurse(&root_iter, &pool_iter);
@ -326,35 +321,35 @@ int context_parse_config()
if (!strcmp(pool_key, "128")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_128_pool = atoi(v);
self.pool.defconfig.cluster_128_pool = atoi(v);
} else if (!strcmp(pool_key, "256")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_256_pool = atoi(v);
self.pool.defconfig.cluster_256_pool = atoi(v);
} else if (!strcmp(pool_key, "512")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_512_pool = atoi(v);
self.pool.defconfig.cluster_512_pool = atoi(v);
} else if (!strcmp(pool_key, "1024")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_1024_pool = atoi(v);
self.pool.defconfig.cluster_1024_pool = atoi(v);
} else if (!strcmp(pool_key, "2048")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_2048_pool = atoi(v);
self.pool.defconfig.cluster_2048_pool = atoi(v);
} else if (!strcmp(pool_key, "8192")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_8192_pool = atoi(v);
self.pool.defconfig.cluster_8192_pool = atoi(v);
} else if (!strcmp(pool_key, "big")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.defconfig.cluster_big_pool = atoi(v);
self.pool.defconfig.cluster_big_pool = atoi(v);
} else if (!strcmp(pool_key, "packet")) {
const char *v = ogs_yaml_iter_value(&pool_iter);
if (v)
self.config.pool.packet = atoi(v);
self.pool.packet = atoi(v);
} else
ogs_warn("unknown key `%s`", pool_key);
}
@ -362,94 +357,8 @@ int context_parse_config()
}
rv = context_validation();
rv = ogs_app_ctx_validation();
if (rv != OGS_OK) return rv;
return OGS_OK;
}
/*
* We've added it
* Because the following function is deprecated in the mongo-c-driver
*/
static bool
context_mongoc_client_get_server_status (mongoc_client_t *client, /* IN */
mongoc_read_prefs_t *read_prefs, /* IN */
bson_t *reply, /* OUT */
bson_error_t *error) /* OUT */
{
bson_t cmd = BSON_INITIALIZER;
bool ret = false;
BSON_ASSERT (client);
BSON_APPEND_INT32 (&cmd, "serverStatus", 1);
ret = mongoc_client_command_simple (
client, "admin", &cmd, read_prefs, reply, error);
bson_destroy (&cmd);
return ret;
}
int context_db_init(const char *db_uri)
{
bson_t reply;
bson_error_t error;
bson_iter_t iter;
const mongoc_uri_t *uri;
memset(&self.db, 0, sizeof self.db);
mongoc_init();
self.db.initialized = true;
self.db.client = mongoc_client_new(db_uri);
if (!self.db.client) {
ogs_error("Failed to parse DB URI [%s]", db_uri);
return OGS_ERROR;
}
#if MONGOC_MAJOR_VERSION >= 1 && MONGOC_MINOR_VERSION >= 4
mongoc_client_set_error_api(self.db.client, 2);
#endif
uri = mongoc_client_get_uri(self.db.client);
ogs_assert(uri);
self.db.name = mongoc_uri_get_database(uri);
ogs_assert(self.db.name);
self.db.database = mongoc_client_get_database(self.db.client, self.db.name);
ogs_assert(self.db.database);
if (!context_mongoc_client_get_server_status(
self.db.client, NULL, &reply, &error)) {
ogs_error("Failed to connect to server [%s]", db_uri);
return OGS_RETRY;
}
ogs_assert(bson_iter_init_find(&iter, &reply, "ok"));
bson_destroy(&reply);
return OGS_OK;
}
int context_db_final()
{
if (self.db.database) {
mongoc_database_destroy(self.db.database);
self.db.database = NULL;
}
if (self.db.client) {
mongoc_client_destroy(self.db.client);
self.db.client = NULL;
}
if (self.db.initialized) {
mongoc_cleanup();
self.db.initialized = false;
}
return OGS_OK;
}

View File

@ -17,17 +17,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef APP_CONTEXT_H
#define APP_CONTEXT_H
#if !defined(OGS_APP_INSIDE) && !defined(OGS_APP_COMPILATION)
#error "This header cannot be included directly."
#endif
#include "ogs-core.h"
#include "ogs-yaml.h"
#ifndef OGS_APP_CONFIG_H
#define OGS_APP_CONFIG_H
#include "ogs-app.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif
typedef struct _config_t {
typedef struct ogs_config_s {
const char *file;
void *document;
@ -70,42 +73,24 @@ typedef struct _config_t {
struct {
ogs_pkbuf_config_t defconfig;
int packet;
} pool;
} config_t;
typedef struct _context_t {
config_t config;
struct {
bool initialized;
const char *name;
void *uri;
void *client;
void *database;
} db;
struct {
int ue;
int sess;
int bearer;
int tunnel;
int pf;
} pool;
} ogs_config_t;
} context_t;
int ogs_config_init(void);
int ogs_config_final(void);
ogs_config_t *ogs_config(void);
int context_init(void);
int context_final(void);
context_t *context_self(void);
int context_read_file(void);
int context_parse_config(void);
int context_db_init(const char *db_uri);
int context_db_final(void);
int ogs_config_read(void);
int ogs_config_parse(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif /* APP_CONTEXT_H */
#endif /* OGS_APP_CONFIG_H */

View File

@ -17,23 +17,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "base/types.h"
#include "ogs-app.h"
#include "context.h"
#include "application.h"
int __ogs_app_domain;
#include "base/context.h"
#define DEFAULT_CONFIG_FILENAME SYSCONF_DIR "nextepc/nextepc.conf"
static char *version = "NextEPC daemon v" PACKAGE_VERSION;
char *app_version()
{
return version;
}
int app_will_initialize(char **argv)
int ogs_app_initialize(char *default_config, char **argv)
{
int rv, opt;
ogs_getopt_t options;
@ -47,7 +35,10 @@ int app_will_initialize(char **argv)
bool enable_trace;
} optarg;
context_init();
ogs_core_initialize();
ogs_app_setup_log();
ogs_config_init();
/**************************************************************************
* Stage 1 : Command Line Options
@ -80,106 +71,64 @@ int app_will_initialize(char **argv)
* Stage 2 : Load Configuration File
*/
if (optarg.config_file)
context_self()->config.file = optarg.config_file;
ogs_config()->file = optarg.config_file;
else
context_self()->config.file = DEFAULT_CONFIG_FILENAME;
ogs_config()->file = default_config;
rv = context_read_file();
rv = ogs_config_read();
if (rv != OGS_OK) return rv;
rv = context_parse_config();
rv = ogs_config_parse();
if (rv != OGS_OK) return rv;
/**************************************************************************
* Stage 3 : Initialize Default Memory Pool
*/
ogs_pkbuf_default_create(&context_self()->config.pool.defconfig);
ogs_pkbuf_default_create(&ogs_config()->pool.defconfig);
/**************************************************************************
* Stage 4 : Setup LOG Module
*/
if (optarg.log_file)
context_self()->config.logger.file = optarg.log_file;
ogs_config()->logger.file = optarg.log_file;
if (context_self()->config.logger.file) {
if (ogs_log_add_file(context_self()->config.logger.file) == NULL) {
if (ogs_config()->logger.file) {
if (ogs_log_add_file(ogs_config()->logger.file) == NULL) {
ogs_fatal("cannot open log file : %s",
context_self()->config.logger.file);
ogs_config()->logger.file);
return OGS_ERROR;
}
}
if (optarg.domain_mask)
context_self()->config.logger.domain = optarg.domain_mask;
ogs_config()->logger.domain = optarg.domain_mask;
if (optarg.log_level)
context_self()->config.logger.level = optarg.log_level;
ogs_config()->logger.level = optarg.log_level;
rv = ogs_log_config_domain(
context_self()->config.logger.domain,
context_self()->config.logger.level);
ogs_config()->logger.domain, ogs_config()->logger.level);
if (rv != OGS_OK) return rv;
/**************************************************************************
* Stage 5 : Setup DATABASE
* Stage 5 : Setup Database Module
*/
if (ogs_env_get("DB_URI"))
context_self()->config.db_uri = ogs_env_get("DB_URI");
if (context_self()->config.db_uri) {
rv = context_db_init(context_self()->config.db_uri);
if (rv != OGS_OK) return rv;
}
/**************************************************************************
* Stage 6 : Print Result
*/
ogs_log_print(OGS_LOG_INFO, "%s\n\n", version);
ogs_log_print(OGS_LOG_INFO, "Configuration: '%s'\n",
context_self()->config.file);
if (context_self()->config.logger.file) {
ogs_log_print(OGS_LOG_INFO,
"File Logging: '%s'\n", context_self()->config.logger.file);
if (context_self()->config.logger.level)
ogs_log_print(OGS_LOG_INFO,
"LOG-LEVEL: '%s'\n", context_self()->config.logger.level);
if (context_self()->config.logger.domain)
ogs_log_print(OGS_LOG_INFO,
"LOG-DOMAIN: '%s'\n", context_self()->config.logger.domain);
}
if (context_self()->config.db_uri) {
ogs_log_print(OGS_LOG_INFO, "MongoDB URI: '%s'\n",
context_self()->config.db_uri);
}
ogs_config()->db_uri = ogs_env_get("DB_URI");
return rv;
}
int app_did_initialize(void)
void ogs_app_terminate(void)
{
return OGS_OK;
ogs_config_final();
ogs_pkbuf_default_destroy();
ogs_core_terminate();
}
void app_will_terminate(void)
void ogs_app_setup_log(void)
{
ogs_log_install_domain(&__ogs_app_domain, "app", ogs_core()->log.level);
}
void app_did_terminate(void)
{
context_db_final();
context_final();
}
int app_logger_restart()
{
ogs_log_cycle();
return OGS_OK;
}

View File

@ -17,25 +17,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef APP_APPLICATION_H
#define APP_APPLICATION_H
#if !defined(OGS_APP_INSIDE) && !defined(OGS_APP_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_APP_INIT_H
#define OGS_APP_INIT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void show_version(void);
void show_help(const char *name);
int ogs_app_initialize(char *default_config, char **argv);
void ogs_app_terminate(void);
int app_will_initialize(char **argv);
int app_did_initialize(void);
void app_will_terminate(void);
void app_did_terminate(void);
int app_logger_restart(void);
void ogs_app_setup_log(void);
#ifdef __cplusplus
}
#endif
#endif /* APP_APPLICATION_H */
#endif /* OGS_APP_INIT_H */

View File

@ -19,8 +19,6 @@
#include "ogs-yaml.h"
#include <yaml.h>
void ogs_yaml_iter_init(ogs_yaml_iter_t *iter, yaml_document_t *document)
{
ogs_assert(iter);

View File

@ -17,19 +17,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if !defined(OGS_APP_INSIDE) && !defined(OGS_APP_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_YAML_H
#define OGS_YAML_H
#include "ogs-core.h"
#include <yaml.h>
#include "ogs-app.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct yaml_document_s yaml_document_t;
typedef struct yaml_node_s yaml_node_t;
typedef struct yaml_node_pair_s yaml_node_pair_t;
typedef int yaml_node_item_t;
#endif
typedef struct {
yaml_document_t *document;
@ -51,4 +52,4 @@ int ogs_yaml_iter_bool(ogs_yaml_iter_t *iter);
}
#endif
#endif /* OGS_OGS_YAML_H */
#endif /* OGS_YAML_H */

View File

@ -1127,24 +1127,16 @@ ASN_MODULE_CFLAGS=
pkglib_LTLIBRARIES=libasn1c.la
libasn1c_la_SOURCES= \
$(ASN_MODULE_SRCS) $(ASN_MODULE_HDRS) \
s1ap-asn1c.h s1ap-message.h \
s1ap-decoder.c s1ap-encoder.c s1ap-free.c \
$(NULL)
libasn1c_la_DEPENDENCIES = \
$(top_srcdir)/lib/base/libbase.la \
$(NULL)
libasn1c_la_LIBADD = \
@OGSCORE_LIBS@ \
$(top_srcdir)/lib/base/libbase.la \
$(NULL)
AM_CPPFLAGS = \
@OGSCORE_CFLAGS@ \
-I$(top_srcdir)/lib/asn1c/common \
-I$(top_srcdir)/lib/asn1c/s1ap \
-I$(top_srcdir)/lib \
$(NULL)
AM_CFLAGS = \

View File

@ -12,7 +12,7 @@
#if 0 /* modified by acetcom */
#include "config.h"
#else
#include "base/base.h"
#include "ogs-common.h"
#endif
#endif

View File

@ -1,49 +0,0 @@
/*
* 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/>.
*/
#include "s1ap-message.h"
#undef OGS_LOG_DOMAIN
#define OGS_LOG_DOMAIN __base_s1ap_domain
int s1ap_encode_pdu(ogs_pkbuf_t **pkbuf, s1ap_message_t *message)
{
asn_enc_rval_t enc_ret = {0};
ogs_assert(message);
if (ogs_log_get_domain_level(OGS_LOG_DOMAIN) >= OGS_LOG_TRACE)
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, message);
*pkbuf = ogs_pkbuf_alloc(NULL, MAX_SDU_LEN);
ogs_pkbuf_put(*pkbuf, MAX_SDU_LEN);
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_S1AP_PDU, NULL,
message, (*pkbuf)->data, MAX_SDU_LEN);
if (enc_ret.encoded < 0)
{
ogs_error("Failed to encode S1AP-PDU[%d]", (int)enc_ret.encoded);
ogs_pkbuf_free(*pkbuf);
return OGS_ERROR;
}
ogs_pkbuf_trim(*pkbuf, (enc_ret.encoded >> 3));
return OGS_OK;
}

View File

@ -1,24 +0,0 @@
## Process this file with automake to produce Makefile.in
pkglib_LTLIBRARIES = libbase.la
libbase_la_SOURCES = \
base.h \
types.h types.c \
context.h context.c \
$(NULL)
libbase_la_DEPENDENCIES = \
$(NULL)
libbase_la_LIBADD = \
@OGSCORE_LIBS@ \
$(NULL)
AM_CPPFLAGS = \
@OGSCORE_CFLAGS@ \
$(NULL)
AM_CFLAGS = \
-Wall -Werror \
$(NULL)

View File

@ -1,47 +0,0 @@
/*
* 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/>.
*/
#include "context.h"
int __base_s1ap_domain;
int __base_nas_domain;
int __base_gtp_domain;
int __base_fd_domain;
static base_context_t self = {
.gtp.node.pool = 512,
.gtp.xact.pool = 512,
};
void base_initialize(void)
{
ogs_log_install_domain(&__base_s1ap_domain, "s1ap", ogs_core()->log.level);
ogs_log_install_domain(&__base_nas_domain, "nas", ogs_core()->log.level);
ogs_log_install_domain(&__base_gtp_domain, "gtp", ogs_core()->log.level);
ogs_log_install_domain(&__base_fd_domain, "fd", ogs_core()->log.level);
}
void base_finalize(void)
{
}
base_context_t *base_self(void)
{
return &self;
}

View File

@ -1,179 +0,0 @@
/*
* 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/>.
*/
#include "types.h"
#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10)
#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10)
#define PLMN_ID_DIGIT3(x) ((x) % 10)
uint32_t plmn_id_hexdump(void *plmn_id)
{
uint32_t hex;
ogs_assert(plmn_id);
memcpy(&hex, plmn_id, sizeof(plmn_id_t));
hex = ntohl(hex) >> 8;
return hex;
}
uint16_t plmn_id_mcc(plmn_id_t *plmn_id)
{
return plmn_id->mcc1 * 100 + plmn_id->mcc2 * 10 + plmn_id->mcc3;
}
uint16_t plmn_id_mnc(plmn_id_t *plmn_id)
{
return plmn_id->mnc1 == 0xf ? plmn_id->mnc2 * 10 + plmn_id->mnc3 :
plmn_id->mnc1 * 100 + plmn_id->mnc2 * 10 + plmn_id->mnc3;
}
uint16_t plmn_id_mnc_len(plmn_id_t *plmn_id)
{
return plmn_id->mnc1 == 0xf ? 2 : 3;
}
void *plmn_id_build(plmn_id_t *plmn_id,
uint16_t mcc, uint16_t mnc, uint16_t mnc_len)
{
plmn_id->mcc1 = PLMN_ID_DIGIT1(mcc);
plmn_id->mcc2 = PLMN_ID_DIGIT2(mcc);
plmn_id->mcc3 = PLMN_ID_DIGIT3(mcc);
if (mnc_len == 2)
plmn_id->mnc1 = 0xf;
else
plmn_id->mnc1 = PLMN_ID_DIGIT1(mnc);
plmn_id->mnc2 = PLMN_ID_DIGIT2(mnc);
plmn_id->mnc3 = PLMN_ID_DIGIT3(mnc);
return plmn_id;
}
int fqdn_build(char *dst, char *src, int length)
{
int i = 0, j = 0;
for (i = 0, j = 0; i < length; i++, j++) {
if (src[i] == '.') {
dst[i-j] = j;
j = -1;
} else {
dst[i+1] = src[i];
}
}
dst[i-j] = j;
return length+1;
}
int fqdn_parse(char *dst, char *src, int length)
{
int i = 0, j = 0;
uint8_t len = 0;
do {
len = src[i++];
memcpy(&dst[j], &src[i], len);
i += len;
j += len;
if (i < length)
dst[j++] = '.';
else
dst[j] = 0;
} while (i < length);
return j;
}
/* 8.13 Protocol Configuration Options (PCO)
* 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 */
int pco_parse(pco_t *pco, void *data, int data_len)
{
pco_t *source = (pco_t *)data;
int size = 0;
int i = 0;
ogs_assert(pco);
ogs_assert(data);
ogs_assert(data_len);
memset(pco, 0, sizeof(pco_t));
pco->ext = source->ext;
pco->configuration_protocol = source->configuration_protocol;
size++;
while(size < data_len && i < MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID) {
pco_id_t *id = &pco->ids[i];
ogs_assert(size + sizeof(id->id) <= data_len);
memcpy(&id->id, data + size, sizeof(id->id));
id->id = ntohs(id->id);
size += sizeof(id->id);
ogs_assert(size + sizeof(id->len) <= data_len);
memcpy(&id->len, data + size, sizeof(id->len));
size += sizeof(id->len);
id->data = data + size;
size += id->len;
i++;
}
pco->num_of_id = i;
ogs_assert(size == data_len);
return size;
}
int pco_build(void *data, int data_len, pco_t *pco)
{
pco_t target;
int size = 0;
int i = 0;
ogs_assert(pco);
ogs_assert(data);
ogs_assert(data_len);
memcpy(&target, pco, sizeof(pco_t));
ogs_assert(size + 1 <= data_len);
memcpy(data + size, &target, 1);
size += 1;
ogs_assert(target.num_of_id <= MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID);
for (i = 0; i < target.num_of_id; i++) {
pco_id_t *id = &target.ids[i];
ogs_assert(size + sizeof(id->id) <= data_len);
id->id = htons(id->id);
memcpy(data + size, &id->id, sizeof(id->id));
size += sizeof(id->id);
ogs_assert(size + sizeof(id->len) <= data_len);
memcpy(data + size, &id->len, sizeof(id->len));
size += sizeof(id->len);
ogs_assert(size + id->len <= data_len);
memcpy(data + size, id->data, id->len);
size += id->len;
}
return size;
}

View File

@ -1,346 +0,0 @@
/*
* 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 __BASE_TYPES__
#define __BASE_TYPES__
#include "ogs-core.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define S1AP_SCTP_PORT 36412
#define GTPV2_C_UDP_PORT 2123
#define GTPV1_U_UDP_PORT 2152
#define SGSAP_SCTP_PORT 29118
#define SCTP_S1AP_PPID 18
#define SCTP_X2AP_PPID 27
#define SCTP_SGSAP_PPID 0
#define MAX_NUM_OF_SESS 4 /* Num of APN(Session) per UE */
#define MAX_NUM_OF_BEARER 4 /* Num of Bearer per APN(Session) */
#define MAX_NUM_OF_TUNNEL 3 /* Num of Tunnel per Bearer */
#define MAX_NUM_OF_PF 16 /* Num of Packet Filter per Bearer */
#define MAX_NUM_OF_HOSTNAME 16
#define MAX_NUM_OF_PCC_RULE 8
#define MAX_NUM_OF_FLOW 8 /* Num of Flow per PCC Rule */
#define MAX_NUM_OF_PACKET_FILTER 16 /* Num of Packet Filter per Bearer */
#define MAX_SDU_LEN 8192
#define PLMN_ID_LEN 3
#define BCD_TO_BUFFER_LEN(x) (((x)+1)/2)
#define MAX_IMSI_BCD_LEN 15
#define MAX_IMSI_LEN BCD_TO_BUFFER_LEN(MAX_IMSI_BCD_LEN)
#define RAND_LEN 16
#define AUTN_LEN 16
#define AUTS_LEN 14
#define MAX_RES_LEN 16
#define MAX_APN_LEN 100
#define MAX_PCO_LEN 251
#define MAX_FILEPATH_LEN 256
#define MAX_FQDN_LEN 256
#define OGS_ARG_MAX 256
#define NEXT_ID(__id, __min, __max) \
((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1)))
#define COMPARE_ID(__id1, __id2, __max) \
((__id2) > (__id1) ? ((__id2) - (__id1) < ((__max)-1) ? -1 : 1) : \
(__id1) > (__id2) ? ((__id1) - (__id2) < ((__max)-1) ? 1 : -1) : 0)
#define TIME_TO_BCD(x) \
(((((x) % 10) << 4) & 0xf0) | (((x) / 10) & 0x0f))
/**********************************
* PLMN_ID Structure */
typedef struct plmn_id_s {
ED2(uint8_t mcc2:4;,
uint8_t mcc1:4;)
ED2(uint8_t mnc1:4;,
uint8_t mcc3:4;)
ED2(uint8_t mnc3:4;,
uint8_t mnc2:4;)
} __attribute__ ((packed)) plmn_id_t;
uint32_t plmn_id_hexdump(void *plmn_id);
uint16_t plmn_id_mcc(plmn_id_t *plmn_id);
uint16_t plmn_id_mnc(plmn_id_t *plmn_id);
uint16_t plmn_id_mnc_len(plmn_id_t *plmn_id);
void *plmn_id_build(plmn_id_t *plmn_id,
uint16_t mcc, uint16_t mnc, uint16_t mnc_len);
#define MAX_NUM_OF_TAI 16
typedef struct tai_s {
plmn_id_t plmn_id;
uint16_t tac;
} __attribute__ ((packed)) tai_t;
typedef struct e_cgi_s {
plmn_id_t plmn_id;
uint32_t cell_id; /* 28 bit */
} __attribute__ ((packed)) e_cgi_t;
/**************************************************
* Common Structure
* S1AP : 9.2.2.1 Transport Layer Address, See 36.414
* GTP : 8.22 Fully Qualified TEID (F-TEID) */
#define IPV4_LEN 4
#define IPV6_LEN 16
#define IPV4V6_LEN 20
typedef struct ip_s {
union {
uint32_t addr;
uint8_t addr6[IPV6_LEN];
struct {
uint32_t addr;
uint8_t addr6[IPV6_LEN];
} both;
};
uint32_t len;
ED3(uint8_t ipv4:1;,
uint8_t ipv6:1;,
uint8_t reserved:6;)
} ip_t;
/**************************************************
* 8.14 PDN Address Allocation (PAA) */
#define PAA_IPV4_LEN 5
#define PAA_IPV6_LEN 18
#define PAA_IPV4V6_LEN 22
typedef struct paa_s {
/* 8.34 PDN Type */
#define GTP_PDN_TYPE_IPV4 1
#define GTP_PDN_TYPE_IPV6 2
#define GTP_PDN_TYPE_IPV4V6 3
#define GTP_PDN_TYPE_NON_IP 4
ED2(uint8_t spare:5;,
uint8_t pdn_type:3;)
union {
/* GTP_PDN_TYPE_IPV4 */
uint32_t addr;
/* GTP_PDN_TYPE_IPV6 */
struct {
/* the IPv6 Prefix Length */
uint8_t len;
/* IPv6 Prefix and Interface Identifier */
uint8_t addr6[IPV6_LEN];
};
/* GTP_PDN_TYPE_BOTH */
struct {
struct {
/* the IPv6 Prefix Length */
uint8_t len;
/* IPv6 Prefix and Interface Identifier */
uint8_t addr6[IPV6_LEN];
};
uint32_t addr;
} __attribute__ ((packed)) both;
};
} __attribute__ ((packed)) paa_t;
#define MAX_BIT_RATE 10000000000UL
typedef struct bitrate_s {
uint64_t downlink; /* bits per seconds */
uint64_t uplink; /* bits per seconds */
} bitrate_t;
/**********************************
* QoS Structure */
typedef struct qos_s {
#define PDN_QCI_1 1
#define PDN_QCI_2 2
#define PDN_QCI_3 3
#define PDN_QCI_4 4
#define PDN_QCI_5 5
#define PDN_QCI_6 6
#define PDN_QCI_7 7
#define PDN_QCI_8 8
#define PDN_QCI_9 9
#define PDN_QCI_65 65
#define PDN_QCI_66 66
#define PDN_QCI_69 69
#define PDN_QCI_70 70
uint8_t qci;
struct {
/* Values 1 to 8 should only be assigned for services that are
* authorized to receive prioritized treatment within an operator domain.
* Values 9 to 15 may be assigned to resources that are authorized
* by the home network and thus applicable when a UE is roaming. */
uint8_t priority_level;
#define PDN_PRE_EMPTION_CAPABILITY_ENABLED 0
#define PDN_PRE_EMPTION_CAPABILITY_DISABLED 1
uint8_t pre_emption_capability;
#define PDN_PRE_EMPTION_VULNERABILITY_ENABLED 0
#define PDN_PRE_EMPTION_VULNERABILITY_DISABLED 1
uint8_t pre_emption_vulnerability;
} arp;
bitrate_t mbr; /* Maxmimum Bit Rate (MBR) */
bitrate_t gbr; /* Guaranteed Bit Rate (GBR) */
} qos_t;
/**********************************
* Flow Structure */
#define FLOW_DOWNLINK_ONLY 1
#define FLOW_UPLINK_ONLY 2
typedef struct flow_s {
uint8_t direction;
char *description;
} flow_t;
#define FLOW_FREE(__fLOW) \
do { \
if ((__fLOW)->description) \
{ \
ogs_free((__fLOW)->description); \
} \
else \
ogs_assert_if_reached(); \
} while(0)
/**********************************
* PCC Rule Structure */
typedef struct pcc_rule_s {
#define PCC_RULE_TYPE_INSTALL 1
#define PCC_RULE_TYPE_REMOVE 2
uint8_t type;
#define MAX_PCC_RULE_NAME_LEN 256
char *name;
flow_t flow[MAX_NUM_OF_FLOW];
int num_of_flow;
#define FLOW_STATUS_ENABLED_UPLINK 0
#define FLOW_STATUS_ENABLED_DOWNLINK 1
#define FLOW_STATUS_ENABLED 2
#define FLOW_STATUS_DISABLED 3
#define FLOW_STATUS_REMOVE 4
int flow_status;
uint32_t precedence;
qos_t qos;
} pcc_rule_t;
#define PCC_RULE_FREE(__pCCrULE) \
do { \
int __pCCrULE_iNDEX; \
ogs_assert((__pCCrULE)); \
if ((__pCCrULE)->name) \
{ \
ogs_free((__pCCrULE)->name); \
} \
else \
ogs_assert_if_reached(); \
for (__pCCrULE_iNDEX = 0; \
__pCCrULE_iNDEX < (__pCCrULE)->num_of_flow; __pCCrULE_iNDEX++) \
{ \
FLOW_FREE(&((__pCCrULE)->flow[__pCCrULE_iNDEX])); \
} \
(__pCCrULE)->num_of_flow = 0; \
} while(0)
/**********************************
* PDN Structure */
typedef struct pdn_s {
uint32_t context_identifier;
char apn[MAX_APN_LEN+1];
#define HSS_PDN_TYPE_IPV4 0
#define HSS_PDN_TYPE_IPV6 1
#define HSS_PDN_TYPE_IPV4V6 2
#define HSS_PDN_TYPE_IPV4_OR_IPV6 3
int pdn_type;
qos_t qos;
bitrate_t ambr; /* APN-AMBR */
paa_t paa;
ip_t pgw_ip;
} pdn_t;
int fqdn_build(char *dst, char *src, int len);
int fqdn_parse(char *dst, char *src, int len);
/**************************************************
* Protocol Configuration Options Structure
* 8.13 Protocol Configuration Options (PCO)
* 10.5.6.3 Protocol configuration options in 3GPP TS 24.008
* RFC 3232 [103]
* RFC 1661 [102] */
#define PCO_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE 0
#define PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021
#define PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223
#define PCO_ID_P_CSCF_IPV6_ADDRESS_REQUEST 0x0001
#define PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST 0x0003
#define PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a
#define PCO_ID_P_CSCF_IPV4_ADDRESS_REQUEST 0x000c
#define PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d
#define PCO_ID_IPV4_LINK_MTU_REQUEST 0x0010
typedef struct pco_ipcp_options_s {
uint8_t type;
uint8_t len;
uint32_t addr;
} __attribute__ ((packed)) pco_ipcp_options_t;
#define PCO_MAX_NUM_OF_IPCO_OPTIONS 4
typedef struct pco_ipcp_s {
uint8_t code;
uint8_t identifier;
uint16_t len;
pco_ipcp_options_t options[PCO_MAX_NUM_OF_IPCO_OPTIONS];
} __attribute__ ((packed)) pco_ipcp_t;
typedef struct pco_id_s {
uint16_t id;
uint8_t len;
void *data;
} pco_id_t;
#define MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID 16
typedef struct pco_s {
ED3(uint8_t ext:1;,
uint8_t spare:4;,
uint8_t configuration_protocol:3;)
uint8_t num_of_id;
pco_id_t ids[MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID];
} pco_t;
int pco_parse(pco_t *pco, void *data, int data_len);
int pco_build(void *data, int data_len, pco_t *pco);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __BASE_TYPES_H__ */

26
lib/dbi/Makefile.am Normal file
View File

@ -0,0 +1,26 @@
## Process this file with automake to produce Makefile.in.
pkglib_LTLIBRARIES = libogsdbi.la
libogsdbi_la_SOURCES = \
ogs-mongoc.h ogs-mongoc.c \
$(NULL)
libogsdbi_la_LIBADD = \
@OGSCORE_LIBS@ \
@MONGOC_LIBS@ \
$(NULL)
libogsdbi_la_DEPENDENCIES = \
$(NULL)
AM_CPPFLAGS = \
@OGSCORE_CFLAGS@ \
@MONGOC_CFLAGS@ \
-I$(top_srcdir)/lib \
$(NULL)
AM_CFLAGS = \
-DOGS_DBI_COMPILATION \
-Wall -Werror \
$(NULL)

124
lib/dbi/ogs-mongoc.c Normal file
View File

@ -0,0 +1,124 @@
/*
* 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/>.
*/
#include <mongoc.h>
#include "ogs-dbi.h"
int __ogs_dbi_domain;
static ogs_mongoc_t self;
/*
* We've added it
* Because the following function is deprecated in the mongo-c-driver
*/
static bool
ogs_mongoc_mongoc_client_get_server_status (mongoc_client_t *client, /* IN */
mongoc_read_prefs_t *read_prefs, /* IN */
bson_t *reply, /* OUT */
bson_error_t *error) /* OUT */
{
bson_t cmd = BSON_INITIALIZER;
bool ret = false;
BSON_ASSERT (client);
BSON_APPEND_INT32 (&cmd, "serverStatus", 1);
ret = mongoc_client_command_simple (
client, "admin", &cmd, read_prefs, reply, error);
bson_destroy (&cmd);
return ret;
}
int ogs_mongoc_init(const char *db_uri)
{
bson_t reply;
bson_error_t error;
bson_iter_t iter;
const mongoc_uri_t *uri;
if (!db_uri) {
ogs_error("No DB_URI");
return OGS_ERROR;
}
memset(&self, 0, sizeof(ogs_mongoc_t));
mongoc_init();
self.initialized = true;
self.client = mongoc_client_new(db_uri);
if (!self.client) {
ogs_error("Failed to parse DB URI [%s]", db_uri);
return OGS_ERROR;
}
#if MONGOC_MAJOR_VERSION >= 1 && MONGOC_MINOR_VERSION >= 4
mongoc_client_set_error_api(self.client, 2);
#endif
uri = mongoc_client_get_uri(self.client);
ogs_assert(uri);
self.name = mongoc_uri_get_database(uri);
ogs_assert(self.name);
self.database = mongoc_client_get_database(self.client, self.name);
ogs_assert(self.database);
if (!ogs_mongoc_mongoc_client_get_server_status(
self.client, NULL, &reply, &error)) {
ogs_error("Failed to connect to server [%s]", db_uri);
return OGS_RETRY;
}
ogs_assert(bson_iter_init_find(&iter, &reply, "ok"));
bson_destroy(&reply);
ogs_info("MongoDB URI: '%s'", db_uri);
return OGS_OK;
}
void ogs_mongoc_final(void)
{
if (self.database) {
mongoc_database_destroy(self.database);
self.database = NULL;
}
if (self.client) {
mongoc_client_destroy(self.client);
self.client = NULL;
}
if (self.initialized) {
mongoc_cleanup();
self.initialized = false;
}
}
ogs_mongoc_t *ogs_mongoc(void)
{
return &self;
}

View File

@ -17,37 +17,33 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __BASE_CONTEXT__
#define __BASE_CONTEXT__
#if !defined(OGS_DBI_INSIDE) && !defined(OGS_DBI_COMPILATION)
#error "This header cannot be included directly."
#endif
#include "base.h"
#ifndef OGS_MONGOC_H
#define OGS_MONGOC_H
#include <mongoc.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern int __base_s1ap_domain;
extern int __base_nas_domain;
extern int __base_gtp_domain;
extern int __base_fd_domain;
typedef struct ogs_mongoc_s {
bool initialized;
const char *name;
void *uri;
void *client;
void *database;
} ogs_mongoc_t;
typedef struct base_context_s {
struct {
struct {
int pool;
} node;
struct {
int pool;
} xact;
} gtp;
} base_context_t;
void base_initialize(void);
void base_finalize(void);
base_context_t *base_self(void);
int ogs_mongoc_init(const char *db_uri);
void ogs_mongoc_final(void);
ogs_mongoc_t *ogs_mongoc(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif /* __BASE_CONTEXT_H__ */
#endif /* OGS_MONGOC_H */

View File

@ -15,41 +15,36 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
pkglib_LTLIBRARIES = libfd.la
pkglib_LTLIBRARIES = libogsdiameter.la
libfd_la_SOURCES = \
fd-message.h fd-logger.h fd-lib.h \
libapp_sip.c fd-message.c fd-logger.c fd-config.c fd-init.c \
libogsdiameter_la_SOURCES = \
message.h logger.h base.h \
libapp_sip.c message.c logger.c \
config.c init.c \
\
s6a/s6a-dict.h s6a/s6a-message.h \
s6a/dict-init.c \
\
gx/gx-dict.h gx/gx-message.h \
gx/dict-init.c gx/gx-message.c \
\
rx/rx-dict.h rx/rx-message.h \
rx/dict-init.c rx/rx-message.c \
s6a/dict.h s6a/message.h s6a/dict.c \
gx/dict.h gx/message.h gx/dict.c gx/message.c \
rx/dict.h rx/message.h rx/dict.c rx/message.c \
$(NULL)
libfd_la_DEPENDENCIES = \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la \
$(top_srcdir)/lib/base/libbase.la \
libogsdiameter_la_DEPENDENCIES = \
$(top_srcdir)/lib/freeDiameter/libfdcore/libfdcore.la \
$(top_srcdir)/lib/freeDiameter/libfdproto/libfdproto.la \
$(NULL)
libfd_la_LIBADD = \
libogsdiameter_la_LIBADD = \
@OGSCORE_LIBS@ \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdcore/libfdcore.la \
$(top_srcdir)/lib/@FREEDIAMETER_DIR@/libfdproto/libfdproto.la \
$(top_srcdir)/lib/base/libbase.la \
$(top_srcdir)/lib/freeDiameter/libfdcore/libfdcore.la \
$(top_srcdir)/lib/freeDiameter/libfdproto/libfdproto.la \
$(NULL)
AM_CPPFLAGS = \
@OGSCORE_CFLAGS@ \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/@FREEDIAMETER_DIR@/include \
-I$(top_srcdir)/lib/freeDiameter/include \
$(NULL)
AM_CFLAGS = \
-DOGS_DIAMETER_COMPILATION \
-Wall -Werror \
$(NULL)

View File

@ -17,18 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef FD_LIB_H
#define FD_LIB_H
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#include "ogs-core.h"
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#include "base/context.h"
#include "fd-message.h"
#include "fd-logger.h"
#ifndef OGS_DIAM_BASE_H
#define OGS_DIAM_BASE_H
#ifdef __cplusplus
extern "C" {
@ -36,7 +30,7 @@ extern "C" {
/* This is default diameter configuration if there is no config file
* The Configuration : No TLS, Only TCP */
typedef struct fd_config_s {
typedef struct ogs_diam_config_s {
/* Diameter Identity of the local peer (FQDN -- ASCII) */
const char *cnf_diamid;
/* Diameter realm of the local peer, default to realm part of cnf_diamid */
@ -69,12 +63,12 @@ typedef struct fd_config_s {
uint16_t port; /* port to connect to. 0: default. */
} conn[MAX_NUM_OF_FD_CONN];
int num_of_conn;
} fd_config_t;
} ogs_diam_config_t;
int fd_init(int mode, const char *conffile, fd_config_t *fd_config);
void fd_final(void);
int ogs_diam_init(int mode, const char *conffile, ogs_diam_config_t *fd_config);
void ogs_diam_final(void);
int fd_config_init(fd_config_t *fd_config);
int ogs_diam_config_init(ogs_diam_config_t *fd_config);
int fd_avp_search_avp ( struct avp * groupedavp,
struct dict_object * what, struct avp ** avp );
@ -83,4 +77,4 @@ int fd_avp_search_avp ( struct avp * groupedavp,
}
#endif
#endif /* FD_LIB_H */
#endif /* OGS_DIAM_BASE_H */

View File

@ -17,12 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "fd-lib.h"
#include "ogs-diameter.h"
#undef OGS_LOG_DOMAIN
#define OGS_LOG_DOMAIN __base_fd_domain
static int fd_config_apply(fd_config_t *fd_config)
static int diam_config_apply(ogs_diam_config_t *fd_config)
{
struct addrinfo hints, *ai;
int ret;
@ -173,12 +170,12 @@ static int fd_config_apply(fd_config_t *fd_config)
return OGS_OK;
}
int fd_config_init(fd_config_t *fd_config)
int ogs_diam_config_init(ogs_diam_config_t *fd_config)
{
char * buf = NULL, *b;
size_t len = 0;
CHECK_FCT( fd_config_apply(fd_config) );
CHECK_FCT( diam_config_apply(fd_config) );
/* The following module use data from the configuration */
int fd_rtdisp_init(void);

156
lib/diameter/gx/dict.c Normal file
View File

@ -0,0 +1,156 @@
/*
* 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/>.
*/
#include "diameter/ogs-gx.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
struct dict_object *ogs_diam_gx_application = NULL;
struct dict_object *ogs_diam_gx_cmd_ccr = NULL;
struct dict_object *ogs_diam_gx_cmd_cca = NULL;
struct dict_object *ogs_diam_gx_cmd_rar = NULL;
struct dict_object *ogs_diam_gx_cmd_raa = NULL;
struct dict_object *ogs_diam_gx_cc_request_type = NULL;
struct dict_object *ogs_diam_gx_cc_request_number = NULL;
struct dict_object *ogs_diam_gx_network_request_support = NULL;
struct dict_object *ogs_diam_gx_subscription_id = NULL;
struct dict_object *ogs_diam_gx_subscription_id_type = NULL;
struct dict_object *ogs_diam_gx_subscription_id_data = NULL;
struct dict_object *ogs_diam_gx_supported_features = NULL;
struct dict_object *ogs_diam_gx_feature_list_id = NULL;
struct dict_object *ogs_diam_gx_feature_list = NULL;
struct dict_object *ogs_diam_gx_framed_ip_address = NULL;
struct dict_object *ogs_diam_gx_framed_ipv6_prefix = NULL;
struct dict_object *ogs_diam_gx_ip_can_type = NULL;
struct dict_object *ogs_diam_gx_rat_type = NULL;
struct dict_object *ogs_diam_gx_qos_information = NULL;
struct dict_object *ogs_diam_gx_qos_class_identifier = NULL;
struct dict_object *ogs_diam_gx_max_requested_bandwidth_ul = NULL;
struct dict_object *ogs_diam_gx_max_requested_bandwidth_dl = NULL;
struct dict_object *ogs_diam_gx_min_requested_bandwidth_ul = NULL;
struct dict_object *ogs_diam_gx_min_requested_bandwidth_dl = NULL;
struct dict_object *ogs_diam_gx_guaranteed_bitrate_ul = NULL;
struct dict_object *ogs_diam_gx_guaranteed_bitrate_dl = NULL;
struct dict_object *ogs_diam_gx_allocation_retention_priority = NULL;
struct dict_object *ogs_diam_gx_priority_level = NULL;
struct dict_object *ogs_diam_gx_pre_emption_capability = NULL;
struct dict_object *ogs_diam_gx_pre_emption_vulnerability = NULL;
struct dict_object *ogs_diam_gx_apn_aggregate_max_bitrate_ul = NULL;
struct dict_object *ogs_diam_gx_apn_aggregate_max_bitrate_dl = NULL;
struct dict_object *ogs_diam_gx_3gpp_user_location_info = NULL;
struct dict_object *ogs_diam_gx_called_station_id = NULL;
struct dict_object *ogs_diam_gx_default_eps_bearer_qos = NULL;
struct dict_object *ogs_diam_gx_3gpp_ms_timezone = NULL;
struct dict_object *ogs_diam_gx_event_trigger = NULL;
struct dict_object *ogs_diam_gx_bearer_control_mode = NULL;
struct dict_object *ogs_diam_gx_charging_rule_install = NULL;
struct dict_object *ogs_diam_gx_charging_rule_remove = NULL;
struct dict_object *ogs_diam_gx_charging_rule_definition = NULL;
struct dict_object *ogs_diam_gx_charging_rule_base_name = NULL;
struct dict_object *ogs_diam_gx_charging_rule_name = NULL;
struct dict_object *ogs_diam_gx_flow_information = NULL;
struct dict_object *ogs_diam_gx_flow_direction = NULL;
struct dict_object *ogs_diam_gx_flow_description = NULL;
struct dict_object *ogs_diam_gx_flow_status = NULL;
struct dict_object *ogs_diam_gx_precedence = NULL;
struct dict_object *ogs_diam_gx_flows = NULL;
struct dict_object *ogs_diam_gx_media_component_description = NULL;
struct dict_object *ogs_diam_gx_media_component_number = NULL;
struct dict_object *ogs_diam_gx_media_type = NULL;
struct dict_object *ogs_diam_gx_rr_bandwidth = NULL;
struct dict_object *ogs_diam_gx_rs_bandwidth = NULL;
struct dict_object *ogs_diam_gx_codec_data = NULL;
struct dict_object *ogs_diam_gx_media_sub_component = NULL;
struct dict_object *ogs_diam_gx_flow_number = NULL;
struct dict_object *ogs_diam_gx_flow_usage = NULL;
int ogs_diam_gx_dict_init(void)
{
application_id_t id = OGS_DIAM_GX_APPLICATION_ID;
CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &ogs_diam_gx_application);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &ogs_diam_gx_cmd_ccr);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Answer", &ogs_diam_gx_cmd_cca);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Request", &ogs_diam_gx_cmd_rar);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Answer", &ogs_diam_gx_cmd_raa);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Type", &ogs_diam_gx_cc_request_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Number", &ogs_diam_gx_cc_request_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Network-Request-Support", &ogs_diam_gx_network_request_support);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id", &ogs_diam_gx_subscription_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Type", &ogs_diam_gx_subscription_id_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Data", &ogs_diam_gx_subscription_id_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Supported-Features", &ogs_diam_gx_supported_features);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List-ID", &ogs_diam_gx_feature_list_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List", &ogs_diam_gx_feature_list);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IP-Address", &ogs_diam_gx_framed_ip_address);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IPv6-Prefix", &ogs_diam_gx_framed_ipv6_prefix);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IP-CAN-Type", &ogs_diam_gx_ip_can_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &ogs_diam_gx_rat_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Information", &ogs_diam_gx_qos_information);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier" , &ogs_diam_gx_qos_class_identifier);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_gx_max_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_gx_max_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &ogs_diam_gx_min_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &ogs_diam_gx_min_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-UL" , &ogs_diam_gx_guaranteed_bitrate_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-DL" , &ogs_diam_gx_guaranteed_bitrate_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority" , &ogs_diam_gx_allocation_retention_priority);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &ogs_diam_gx_priority_level);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &ogs_diam_gx_pre_emption_capability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &ogs_diam_gx_pre_emption_vulnerability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-UL" , &ogs_diam_gx_apn_aggregate_max_bitrate_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-DL" , &ogs_diam_gx_apn_aggregate_max_bitrate_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-User-Location-Info", &ogs_diam_gx_3gpp_user_location_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Called-Station-Id", &ogs_diam_gx_called_station_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Default-EPS-Bearer-QoS", &ogs_diam_gx_default_eps_bearer_qos);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-MS-TimeZone", &ogs_diam_gx_3gpp_ms_timezone);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Event-Trigger", &ogs_diam_gx_event_trigger);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Bearer-Control-Mode", &ogs_diam_gx_bearer_control_mode);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Install", &ogs_diam_gx_charging_rule_install);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Remove", &ogs_diam_gx_charging_rule_remove);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Definition", &ogs_diam_gx_charging_rule_definition);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Base-Name", &ogs_diam_gx_charging_rule_base_name);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Name", &ogs_diam_gx_charging_rule_name);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Information", &ogs_diam_gx_flow_information);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Direction", &ogs_diam_gx_flow_direction);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Description", &ogs_diam_gx_flow_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Status", &ogs_diam_gx_flow_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Precedence", &ogs_diam_gx_precedence);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flows", &ogs_diam_gx_flows);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Description", &ogs_diam_gx_media_component_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Number", &ogs_diam_gx_media_component_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Type", &ogs_diam_gx_media_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &ogs_diam_gx_rr_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &ogs_diam_gx_rs_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Codec-Data", &ogs_diam_gx_codec_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Sub-Component", &ogs_diam_gx_media_sub_component);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Number", &ogs_diam_gx_flow_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Usage", &ogs_diam_gx_flow_usage);
return 0;
}

136
lib/diameter/gx/dict.h Normal file
View File

@ -0,0 +1,136 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_GX_DICT_H
#define OGS_DIAM_GX_DICT_H
#ifdef __cplusplus
extern "C" {
#endif
#define OGS_DIAM_GX_APPLICATION_ID 16777238
#define OGS_DIAM_GX_AVP_CODE_RE_AUTH_REQUEST_TYPE (285)
#define OGS_DIAM_GX_AVP_CODE_CC_REQUEST_NUMBER (415)
#define OGS_DIAM_GX_AVP_CODE_CC_REQUEST_TYPE (416)
#define OGS_DIAM_GX_AVP_CODE_DEFAULT_EPS_BEARER_QOS (1049)
#define OGS_DIAM_GX_AVP_CODE_SUPPORTED_FEATURES (628)
#define OGS_DIAM_GX_AVP_CODE_CHARGING_RULE_INSTALL (1001)
#define OGS_DIAM_GX_AVP_CODE_CHARGING_RULE_REMOVE (1002)
#define OGS_DIAM_GX_AVP_CODE_CHARGING_RULE_DEFINITION (1003)
#define OGS_DIAM_GX_AVP_CODE_CHARGING_RULE_NAME (1005)
#define OGS_DIAM_GX_AVP_CODE_FLOW_INFORMATION (1058)
#define OGS_DIAM_GX_AVP_CODE_FLOW_STATUS (511)
#define OGS_DIAM_GX_AVP_CODE_QOS_INFORMATION (1016)
#define OGS_DIAM_GX_AVP_CODE_PRECEDENCE (1010)
extern struct dict_object *ogs_diam_gx_application;
extern struct dict_object *ogs_diam_gx_cmd_ccr;
extern struct dict_object *ogs_diam_gx_cmd_cca;
extern struct dict_object *ogs_diam_gx_cmd_rar;
extern struct dict_object *ogs_diam_gx_cmd_raa;
extern struct dict_object *ogs_diam_gx_cc_request_type;
extern struct dict_object *ogs_diam_gx_cc_request_number;
extern struct dict_object *ogs_diam_gx_network_request_support;
extern struct dict_object *ogs_diam_gx_subscription_id;
#define OGS_DIAM_GX_SUBSCRIPTION_ID_TYPE_END_USER_E164 0
#define OGS_DIAM_GX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI 1
#define OGS_DIAM_GX_SUBSCRIPTION_ID_TYPE_END_USER_SIP_URI 2
#define OGS_DIAM_GX_SUBSCRIPTION_ID_TYPE_END_USER_NAI 3
extern struct dict_object *ogs_diam_gx_subscription_id_type;
extern struct dict_object *ogs_diam_gx_subscription_id_data;
extern struct dict_object *ogs_diam_gx_supported_features;
extern struct dict_object *ogs_diam_gx_feature_list_id;
extern struct dict_object *ogs_diam_gx_feature_list;
extern struct dict_object *ogs_diam_gx_framed_ip_address;
extern struct dict_object *ogs_diam_gx_framed_ipv6_prefix;
#define OGS_DIAM_GX_IP_CAN_TYPE_3GPP_GPRS 0
#define OGS_DIAM_GX_IP_CAN_TYPE_DOCSIS 1
#define OGS_DIAM_GX_IP_CAN_TYPE_xDSL 2
#define OGS_DIAM_GX_IP_CAN_TYPE_WiMAX 3
#define OGS_DIAM_GX_IP_CAN_TYPE_3GPP2 4
#define OGS_DIAM_GX_IP_CAN_TYPE_3GPP_EPS 5
#define OGS_DIAM_GX_IP_CAN_TYPE_Non_3GPP_EPS 6
extern struct dict_object *ogs_diam_gx_ip_can_type;
#define OGS_DIAM_GX_RAT_TYPE_WLAN 0
#define OGS_DIAM_GX_RAT_TYPE_VIRTUAL 1
#define OGS_DIAM_GX_RAT_TYPE_UTRAN 1000
#define OGS_DIAM_GX_RAT_TYPE_GERAN 1001
#define OGS_DIAM_GX_RAT_TYPE_GAN 1002
#define OGS_DIAM_GX_RAT_TYPE_HSPA_EVOLUTION 1003
#define OGS_DIAM_GX_RAT_TYPE_EUTRAN 1004
#define OGS_DIAM_GX_RAT_TYPE_EUTRAN_NB_IoT 1005
#define OGS_DIAM_GX_RAT_TYPE_CDMA2000_1X 2000
#define OGS_DIAM_GX_RAT_TYPE_HRPD 2001
#define OGS_DIAM_GX_RAT_TYPE_UMB 2002
#define OGS_DIAM_GX_RAT_TYPE_EHRPD 2003
extern struct dict_object *ogs_diam_gx_rat_type;
extern struct dict_object *ogs_diam_gx_qos_information;
extern struct dict_object *ogs_diam_gx_qos_class_identifier;
extern struct dict_object *ogs_diam_gx_max_requested_bandwidth_ul;
extern struct dict_object *ogs_diam_gx_max_requested_bandwidth_dl;
extern struct dict_object *ogs_diam_gx_guaranteed_bitrate_ul;
extern struct dict_object *ogs_diam_gx_guaranteed_bitrate_dl;
extern struct dict_object *ogs_diam_gx_allocation_retention_priority;
extern struct dict_object *ogs_diam_gx_priority_level;
extern struct dict_object *ogs_diam_gx_pre_emption_capability;
extern struct dict_object *ogs_diam_gx_pre_emption_vulnerability;
extern struct dict_object *ogs_diam_gx_apn_aggregate_max_bitrate_ul;
extern struct dict_object *ogs_diam_gx_apn_aggregate_max_bitrate_dl;
#define OGS_DIAM_GX_3GPP_USER_LOCATION_INFO_TYPE_TAI_AND_ECGI 130
extern struct dict_object *ogs_diam_gx_3gpp_user_location_info;
extern struct dict_object *ogs_diam_gx_called_station_id;
extern struct dict_object *ogs_diam_gx_default_eps_bearer_qos;
extern struct dict_object *ogs_diam_gx_3gpp_ms_timezone;
extern struct dict_object *ogs_diam_gx_event_trigger;
extern struct dict_object *ogs_diam_gx_bearer_control_mode;
extern struct dict_object *ogs_diam_gx_charging_rule_install;
extern struct dict_object *ogs_diam_gx_charging_rule_remove;
extern struct dict_object *ogs_diam_gx_charging_rule_definition;
extern struct dict_object *ogs_diam_gx_charging_rule_base_name;
extern struct dict_object *ogs_diam_gx_charging_rule_name;
extern struct dict_object *ogs_diam_gx_flow_information;
extern struct dict_object *ogs_diam_gx_flow_direction;
extern struct dict_object *ogs_diam_gx_flow_description;
extern struct dict_object *ogs_diam_gx_flow_status;
extern struct dict_object *ogs_diam_gx_precedence;
extern struct dict_object *ogs_diam_gx_flows;
extern struct dict_object *ogs_diam_gx_media_component_description;
extern struct dict_object *ogs_diam_gx_media_component_number;
extern struct dict_object *ogs_diam_gx_media_type;
extern struct dict_object *ogs_diam_gx_rr_bandwidth;
extern struct dict_object *ogs_diam_gx_rs_bandwidth;
extern struct dict_object *ogs_diam_gx_codec_data;
extern struct dict_object *ogs_diam_gx_media_sub_component;
extern struct dict_object *ogs_diam_gx_flow_number;
extern struct dict_object *ogs_diam_gx_flow_usage;
int ogs_diam_gx_dict_init(void);
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_GX_DICT_H */

View File

@ -17,16 +17,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "gx-message.h"
#include "diameter/ogs-gx.h"
void gx_message_free(gx_message_t *gx_message)
void ogs_diam_gx_message_free(ogs_diam_gx_message_t *gx_message)
{
int i;
ogs_assert(gx_message);
for (i = 0; i < gx_message->num_of_pcc_rule; i++)
{
PCC_RULE_FREE(&gx_message->pcc_rule[i]);
for (i = 0; i < gx_message->num_of_pcc_rule; i++) {
OGS_PCC_RULE_FREE(&gx_message->pcc_rule[i]);
}
}

66
lib/diameter/gx/message.h Normal file
View File

@ -0,0 +1,66 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_GX_MESSAGE_H
#define OGS_DIAM_GX_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ogs_diam_gx_message_s {
#define OGS_DIAM_GX_CMD_CODE_CREDIT_CONTROL 272
#define OGS_DIAM_GX_CMD_RE_AUTH 258
uint16_t cmd_code;
/* Experimental-Result-Codes */
#define OGS_DIAM_GX_DIAMETER_ERROR_LATE_OVERLAPPING_REQUEST 5453
#define OGS_DIAM_GX_DIAMETER_ERROR_TIMED_OUT_REQUEST 5454
#define OGS_DIAM_GX_DIAMETER_ERROR_INITIAL_PARAMETERS 5140
#define OGS_DIAM_GX_DIAMETER_ERROR_TRIGGER_EVENT 5141
#define OGS_DIAM_GX_DIAMETER_PCC_RULE_EVENT 5142
#define OGS_DIAM_GX_DIAMETER_ERROR_BEARER_NOT_AUTHORIZED 5143
#define OGS_DIAM_GX_DIAMETER_ERROR_TRAFFIC_MAPPING_INFO_REJECTED 5144
#define OGS_DIAM_GX_DIAMETER_ERROR_CONFLICTING_REQUEST 5147
#define OGS_DIAM_GX_DIAMETER_ADC_RULE_EVENT 5148
#define OGS_DIAM_GX_DIAMETER_ERROR_NBIFOM_NOT_AUTHORIZED 5149
uint32_t result_code;
#define OGS_DIAM_GX_CC_REQUEST_TYPE_INITIAL_REQUEST 1
#define OGS_DIAM_GX_CC_REQUEST_TYPE_UPDATE_REQUEST 2
#define OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST 3
#define OGS_DIAM_GX_CC_REQUEST_TYPE_EVENT_REQUEST 4
uint32_t cc_request_type;
ogs_pdn_t pdn;
ogs_pcc_rule_t pcc_rule[OGS_MAX_NUM_OF_PCC_RULE];
int num_of_pcc_rule;
} ogs_diam_gx_message_t;
void ogs_diam_gx_message_free(ogs_diam_gx_message_t *gx_message);
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_GX_MESSAGE_H */

View File

@ -17,24 +17,22 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "fd-logger.h"
#include "fd-lib.h"
#include "ogs-diameter.h"
#undef OGS_LOG_DOMAIN
#define OGS_LOG_DOMAIN __base_fd_domain
int __ogs_diam_domain;
static void fd_gnutls_log_func(int level, const char *str);
static void fd_log_func(int printlevel, const char *format, va_list ap);
static void diam_gnutls_log_func(int level, const char *str);
static void diam_log_func(int printlevel, const char *format, va_list ap);
int fd_init(int mode, const char *conffile, fd_config_t *fd_config)
int ogs_diam_init(int mode, const char *conffile, ogs_diam_config_t *fd_config)
{
int ret;
gnutls_global_set_log_level(0);
gnutls_global_set_log_function(fd_gnutls_log_func);
gnutls_global_set_log_function(diam_gnutls_log_func);
fd_g_debug_lvl = FD_LOG_ERROR;
ret = fd_log_handler_register(fd_log_func);
ret = fd_log_handler_register(diam_log_func);
if (ret != 0)
{
ogs_error("fd_log_handler_register() failed");
@ -55,21 +53,21 @@ int fd_init(int mode, const char *conffile, fd_config_t *fd_config)
}
else
{
CHECK_FCT_DO( fd_config_init(fd_config), goto error );
CHECK_FCT_DO( ogs_diam_config_init(fd_config), goto error );
}
/* Initialize FD Message */
CHECK_FCT( fd_message_init() );
CHECK_FCT( ogs_diam_message_init() );
/* Initialize FD logger */
CHECK_FCT_DO( fd_logger_init(mode), goto error );
CHECK_FCT_DO( ogs_diam_logger_init(mode), goto error );
/* Start the servers */
CHECK_FCT_DO( fd_core_start(), goto error );
CHECK_FCT_DO( fd_core_waitstartcomplete(), goto error );
CHECK_FCT( fd_logger_stats_start() );
CHECK_FCT( ogs_diam_logger_stats_start() );
return 0;
error:
@ -79,21 +77,21 @@ error:
return -1;
}
void fd_final()
void ogs_diam_final()
{
fd_logger_final();
ogs_diam_logger_final();
CHECK_FCT_DO( fd_core_shutdown(), ogs_error("fd_core_shutdown() failed") );
CHECK_FCT_DO( fd_core_wait_shutdown_complete(),
ogs_error("fd_core_wait_shutdown_complete() failed"));
}
static void fd_gnutls_log_func(int level, const char *str)
static void diam_gnutls_log_func(int level, const char *str)
{
ogs_trace("gnutls[%d]: %s", level, str);
}
static void fd_log_func(int printlevel, const char *format, va_list ap)
static void diam_log_func(int printlevel, const char *format, va_list ap)
{
char buffer[OGS_HUGE_LEN];
int ret = 0;

View File

@ -34,8 +34,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*********************************************************************************************************/
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#include "ogs-diameter.h"
/* Search a given AVP model in an AVP (extracted from libfreediameter/message.c ) */
int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp )

View File

@ -17,44 +17,39 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ogs-core.h"
#include "base/context.h"
#include "fd-logger.h"
#include "ogs-diameter.h"
#undef OGS_LOG_DOMAIN
#define OGS_LOG_DOMAIN __base_fd_domain
static struct fd_logger_t self;
static struct ogs_diam_logger_t self;
static struct fd_hook_hdl *logger_hdl = NULL;
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
static pthread_t fd_stats_th = (pthread_t)NULL;
static fd_logger_user_handler user_handler = NULL;
static ogs_diam_logger_user_handler user_handler = NULL;
static void fd_logger_cb(enum fd_hook_type type, struct msg * msg,
static void ogs_diam_logger_cb(enum fd_hook_type type, struct msg * msg,
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
void * regdata);
static void * fd_stats_worker(void * arg);
static void * diam_stats_worker(void * arg);
int fd_logger_init(int mode)
int ogs_diam_logger_init(int mode)
{
uint32_t mask_peers = HOOK_MASK( HOOK_PEER_CONNECT_SUCCESS );
memset(&self, 0, sizeof(struct fd_logger_t));
memset(&self, 0, sizeof(struct ogs_diam_logger_t));
self.mode = mode;
self.duration = 60; /* 60 seconds */
CHECK_FCT( fd_hook_register(
mask_peers, fd_logger_cb, NULL, NULL, &logger_hdl) );
mask_peers, ogs_diam_logger_cb, NULL, NULL, &logger_hdl) );
CHECK_POSIX( pthread_mutex_init(&self.stats_lock, NULL) );
return 0;
}
void fd_logger_final()
void ogs_diam_logger_final()
{
CHECK_FCT_DO( fd_thr_term(&fd_stats_th), );
CHECK_POSIX_DO( pthread_mutex_destroy(&self.stats_lock), );
@ -62,31 +57,31 @@ void fd_logger_final()
if (logger_hdl) { CHECK_FCT_DO( fd_hook_unregister( logger_hdl ), ); }
}
struct fd_logger_t* fd_logger_self()
struct ogs_diam_logger_t* ogs_diam_logger_self()
{
return &self;
}
int fd_logger_stats_start()
int ogs_diam_logger_stats_start()
{
/* Start the statistics thread */
CHECK_POSIX( pthread_create(&fd_stats_th, NULL, fd_stats_worker, NULL) );
CHECK_POSIX( pthread_create(&fd_stats_th, NULL, diam_stats_worker, NULL) );
return 0;
}
void fd_logger_register(fd_logger_user_handler instance)
void ogs_diam_logger_register(ogs_diam_logger_user_handler instance)
{
user_handler = instance;
}
void fd_logger_unregister(void)
void ogs_diam_logger_unregister(void)
{
user_handler = NULL;
}
/* The callback called when messages are received and sent */
static void fd_logger_cb(enum fd_hook_type type, struct msg * msg,
static void ogs_diam_logger_cb(enum fd_hook_type type, struct msg * msg,
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
void * regdata)
{
@ -122,7 +117,7 @@ static void fd_logger_cb(enum fd_hook_type type, struct msg * msg,
}
/* Function to display statistics periodically */
static void * fd_stats_worker(void * arg)
static void * diam_stats_worker(void * arg)
{
struct timespec start, now;
struct fd_stats copy;

View File

@ -17,19 +17,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef FD_LOGGER_H
#define FD_LOGGER_H
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#include "ogs-core.h"
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#ifndef OGS_DIAM_LOGGER_H
#define OGS_DIAM_LOGGER_H
#ifdef __cplusplus
extern "C" {
#endif
struct fd_logger_t {
struct ogs_diam_logger_t {
#define FD_MODE_SERVER 0x1
#define FD_MODE_CLIENT 0x2
@ -49,22 +48,22 @@ struct fd_logger_t {
pthread_mutex_t stats_lock;
};
int fd_logger_init(int mode);
void fd_logger_final();
int ogs_diam_logger_init(int mode);
void ogs_diam_logger_final();
struct fd_logger_t* fd_logger_self();
struct ogs_diam_logger_t* ogs_diam_logger_self();
int fd_logger_stats_start();
int ogs_diam_logger_stats_start();
typedef void (*fd_logger_user_handler)(
typedef void (*ogs_diam_logger_user_handler)(
enum fd_hook_type type, struct msg *msg, struct peer_hdr *peer,
void *other, struct fd_hook_permsgdata *pmd, void *regdata);
void fd_logger_register(fd_logger_user_handler instance);
void fd_logger_unregister();
void ogs_diam_logger_register(ogs_diam_logger_user_handler instance);
void ogs_diam_logger_unregister();
#ifdef __cplusplus
}
#endif
#endif /* FD_LOGGER_H */
#endif /* OGS_DIAM_LOGGER_H */

View File

@ -17,68 +17,68 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "fd-message.h"
#include "ogs-diameter.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
#define FD_3GPP_VENDOR_ID 10415
#define OGS_3GPP_VENDOR_ID 10415
struct dict_object *fd_session_id = NULL;
struct dict_object *fd_origin_host = NULL;
struct dict_object *fd_origin_realm = NULL;
struct dict_object *fd_destination_host = NULL;
struct dict_object *fd_destination_realm = NULL;
struct dict_object *fd_user_name = NULL;
struct dict_object *fd_auth_session_state = NULL;
struct dict_object *fd_auth_application_id = NULL;
struct dict_object *fd_auth_request_type = NULL;
struct dict_object *fd_re_auth_request_type = NULL;
struct dict_object *fd_result_code = NULL;
struct dict_object *fd_experimental_result = NULL;
struct dict_object *fd_experimental_result_code = NULL;
struct dict_object *fd_vendor_specific_application_id = NULL;
struct dict_object *fd_mip6_agent_info = NULL;
struct dict_object *fd_mip_home_agent_address = NULL;
struct dict_object *ogs_diam_session_id = NULL;
struct dict_object *ogs_diam_origin_host = NULL;
struct dict_object *ogs_diam_origin_realm = NULL;
struct dict_object *ogs_diam_destination_host = NULL;
struct dict_object *ogs_diam_destination_realm = NULL;
struct dict_object *ogs_diam_user_name = NULL;
struct dict_object *ogs_diam_auth_session_state = NULL;
struct dict_object *ogs_diam_auth_application_id = NULL;
struct dict_object *ogs_diam_auth_request_type = NULL;
struct dict_object *ogs_diam_re_auth_request_type = NULL;
struct dict_object *ogs_diam_result_code = NULL;
struct dict_object *ogs_diam_experimental_result = NULL;
struct dict_object *ogs_diam_experimental_result_code = NULL;
struct dict_object *ogs_diam_vendor_specific_application_id = NULL;
struct dict_object *ogs_diam_mip6_agent_info = NULL;
struct dict_object *ogs_diam_mip_home_agent_address = NULL;
struct dict_object *fd_vendor = NULL;
struct dict_object *fd_vendor_id = NULL;
struct dict_object *ogs_diam_vendor = NULL;
struct dict_object *ogs_diam_vendor_id = NULL;
int fd_message_init()
int ogs_diam_message_init()
{
vendor_id_t id = FD_3GPP_VENDOR_ID;
vendor_id_t id = OGS_3GPP_VENDOR_ID;
CHECK_dict_search( DICT_VENDOR, VENDOR_BY_ID, (void *)&id, &fd_vendor);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &fd_vendor_id);
CHECK_dict_search( DICT_VENDOR, VENDOR_BY_ID, (void *)&id, &ogs_diam_vendor);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &ogs_diam_vendor_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Session-Id", &fd_session_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Host", &fd_origin_host);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Realm", &fd_origin_realm);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Host", &fd_destination_host);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &fd_destination_realm);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "User-Name", &fd_user_name);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Session-State", &fd_auth_session_state);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &fd_auth_application_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Request-Type", &fd_auth_request_type);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Re-Auth-Request-Type", &fd_re_auth_request_type);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Result-Code", &fd_result_code);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Experimental-Result", &fd_experimental_result);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Experimental-Result-Code", &fd_experimental_result_code);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &fd_vendor_specific_application_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "MIP6-Agent-Info", &fd_mip6_agent_info);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "MIP-Home-Agent-Address", &fd_mip_home_agent_address);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Session-Id", &ogs_diam_session_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Host", &ogs_diam_origin_host);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Realm", &ogs_diam_origin_realm);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Host", &ogs_diam_destination_host);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &ogs_diam_destination_realm);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "User-Name", &ogs_diam_user_name);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Session-State", &ogs_diam_auth_session_state);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &ogs_diam_auth_application_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Request-Type", &ogs_diam_auth_request_type);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Re-Auth-Request-Type", &ogs_diam_re_auth_request_type);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Result-Code", &ogs_diam_result_code);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Experimental-Result", &ogs_diam_experimental_result);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Experimental-Result-Code", &ogs_diam_experimental_result_code);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &ogs_diam_vendor_specific_application_id);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "MIP6-Agent-Info", &ogs_diam_mip6_agent_info);
CHECK_dict_search( DICT_AVP, AVP_BY_NAME, "MIP-Home-Agent-Address", &ogs_diam_mip_home_agent_address);
return 0;
}
int fd_message_session_id_set(
int ogs_diam_message_session_id_set(
struct msg *msg, uint8_t *sid, size_t sidlen)
{
struct avp *avp;
union avp_value val;
/* Create an AVP to hold it */
CHECK_FCT( fd_msg_avp_new( fd_session_id, 0, &avp ) );
CHECK_FCT( fd_msg_avp_new( ogs_diam_session_id, 0, &avp ) );
/* Set its value */
memset(&val, 0, sizeof(val));
@ -92,7 +92,7 @@ int fd_message_session_id_set(
return 0;
}
int fd_message_experimental_rescode_set(
int ogs_diam_message_experimental_rescode_set(
struct msg *msg, uint32_t result_code)
{
struct avp *avp;
@ -100,15 +100,15 @@ int fd_message_experimental_rescode_set(
struct avp *avp_experimental_result_code;
union avp_value value;
CHECK_FCT( fd_msg_avp_new(fd_experimental_result, 0, &avp) );
CHECK_FCT( fd_msg_avp_new(ogs_diam_experimental_result, 0, &avp) );
CHECK_FCT( fd_msg_avp_new(fd_vendor_id, 0, &avp_vendor) );
value.u32 = FD_3GPP_VENDOR_ID;
CHECK_FCT( fd_msg_avp_new(ogs_diam_vendor_id, 0, &avp_vendor) );
value.u32 = OGS_3GPP_VENDOR_ID;
CHECK_FCT( fd_msg_avp_setvalue(avp_vendor, &value) );
CHECK_FCT( fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_vendor) );
CHECK_FCT( fd_msg_avp_new(
fd_experimental_result_code, 0, &avp_experimental_result_code) );
ogs_diam_experimental_result_code, 0, &avp_experimental_result_code) );
value.u32 = result_code;
CHECK_FCT( fd_msg_avp_setvalue(avp_experimental_result_code, &value) );
CHECK_FCT( fd_msg_avp_add(
@ -121,22 +121,22 @@ int fd_message_experimental_rescode_set(
return 0;
}
int fd_message_vendor_specific_appid_set(struct msg *msg, uint32_t app_id)
int ogs_diam_message_vendor_specific_appid_set(struct msg *msg, uint32_t app_id)
{
struct avp *avp;
struct avp *avp_vendor;
struct avp *avp_vendor_specific_application_id;
union avp_value value;
CHECK_FCT( fd_msg_avp_new(fd_vendor_specific_application_id, 0, &avp) );
CHECK_FCT( fd_msg_avp_new(ogs_diam_vendor_specific_application_id, 0, &avp) );
CHECK_FCT( fd_msg_avp_new(fd_vendor_id, 0, &avp_vendor) );
value.u32 = FD_3GPP_VENDOR_ID;
CHECK_FCT( fd_msg_avp_new(ogs_diam_vendor_id, 0, &avp_vendor) );
value.u32 = OGS_3GPP_VENDOR_ID;
CHECK_FCT( fd_msg_avp_setvalue(avp_vendor, &value) );
CHECK_FCT( fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_vendor) );
CHECK_FCT( fd_msg_avp_new(
fd_auth_application_id, 0, &avp_vendor_specific_application_id) );
ogs_diam_auth_application_id, 0, &avp_vendor_specific_application_id) );
value.u32 = app_id;
CHECK_FCT(
fd_msg_avp_setvalue(avp_vendor_specific_application_id, &value) );

79
lib/diameter/message.h Normal file
View File

@ -0,0 +1,79 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_MESSAGE_H
#define OGS_DIAM_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
#define OGS_DIAM_AVP_CODE_FRAME_IP_ADDRESS 8
#define OGS_DIAM_AVP_CODE_FRAME_IPV6_PREFIX 97
/* Result-Code AVP */
#define OGS_DIAM_UNKNOWN_PEER 3010
#define OGS_DIAM_AVP_UNSUPPORTED 5001
#define OGS_DIAM_UNKNOWN_SESSION_ID 5002
#define OGS_DIAM_AUTHORIZATION_REJECTED 5003
#define OGS_DIAM_MISSING_AVP 5004
#define OGS_DIAM_INVALID_AVP_VALUE 5005
extern struct dict_object *ogs_diam_session_id;
extern struct dict_object *ogs_diam_origin_host;
extern struct dict_object *ogs_diam_origin_realm;
extern struct dict_object *ogs_diam_destination_host;
extern struct dict_object *ogs_diam_destination_realm;
extern struct dict_object *ogs_diam_user_name;
#define OGS_DIAM_AUTH_SESSION_STATE_MAINTAINED 0
#define OGS_DIAM_AUTH_SESSION_NO_STATE_MAINTAINED 1
extern struct dict_object *ogs_diam_auth_session_state;
extern struct dict_object *ogs_diam_auth_application_id;
#define OGS_DIAM_AUTH_REQUEST_TYPE_AUTHENTICATE_ONLY 1
#define OGS_DIAM_AUTH_REQUEST_TYPE_AUTHORIZE_ONLY 2
#define OGS_DIAM_AUTH_REQUEST_TYPE_AUTHORIZE_AUTHENTICATE 3
extern struct dict_object *ogs_diam_auth_request_type;
#define OGS_DIAM_RE_AUTH_REQUEST_TYPE_AUTHORIZE_ONLY 0
#define OGS_DIAM_RE_AUTH_REQUEST_TYPE_AUTHORIZE_AUTHENTICATE 1
extern struct dict_object *ogs_diam_re_auth_request_type;
extern struct dict_object *ogs_diam_result_code;
extern struct dict_object *ogs_diam_experimental_result;
extern struct dict_object *ogs_diam_experimental_result_code;
extern struct dict_object *ogs_diam_vendor_specific_application_id;
extern struct dict_object *ogs_diam_mip6_agent_info;
extern struct dict_object *ogs_diam_mip_home_agent_address;
extern struct dict_object *ogs_diam_vendor;
extern struct dict_object *ogs_diam_vendor_id;
int ogs_diam_message_init(void);
int ogs_diam_message_session_id_set(struct msg *msg, uint8_t *sid, size_t sidlen);
int ogs_diam_message_experimental_rescode_set(
struct msg *msg, uint32_t result_code);
int ogs_diam_message_vendor_specific_appid_set(struct msg *msg, uint32_t app_id);
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_MESSAGE_H */

View File

@ -17,25 +17,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NAS_CONV_H
#define NAS_CONV_H
#ifndef OGS_DIAMETER_GX_H
#define OGS_DIAMETER_GX_H
#include "nas/nas-message.h"
#include "ogs-diameter.h"
#define OGS_DIAMETER_INSIDE
#include "gx/dict.h"
#include "gx/message.h"
#undef OGS_DIAMETER_INSIDE
#ifdef __cplusplus
extern "C" {
#endif
void nas_imsi_to_buffer(
nas_mobile_identity_imsi_t *imsi, uint8_t imsi_len,
uint8_t *buf, uint8_t *buf_len);
void nas_imsi_to_bcd(
nas_mobile_identity_imsi_t *imsi, uint8_t imsi_len, char *bcd);
/* Nothing */
#ifdef __cplusplus
}
#endif
#endif /* NAS_CONV_H */
#endif /* OGS_DIAMETER_GX_H */

42
lib/diameter/ogs-rx.h Normal file
View File

@ -0,0 +1,42 @@
/*
* 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 OGS_DIAMETER_RX_H
#define OGS_DIAMETER_RX_H
#include "ogs-diameter.h"
#define OGS_DIAMETER_INSIDE
#include "rx/dict.h"
#include "rx/message.h"
#undef OGS_DIAMETER_INSIDE
#ifdef __cplusplus
extern "C" {
#endif
/* Nothing */
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAMETER_RX_H */

42
lib/diameter/ogs-s6a.h Normal file
View File

@ -0,0 +1,42 @@
/*
* 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 OGS_DIMAETER_S6A_H
#define OGS_DIMAETER_S6A_H
#include "ogs-diameter.h"
#define OGS_DIAMETER_INSIDE
#include "s6a/dict.h"
#include "s6a/message.h"
#undef OGS_DIAMETER_INSIDE
#ifdef __cplusplus
extern "C" {
#endif
/* Nothing */
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIMAETER_S6A_H */

100
lib/diameter/rx/dict.c Normal file
View File

@ -0,0 +1,100 @@
/*
* 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/>.
*/
#include "diameter/ogs-rx.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
struct dict_object *ogs_diam_rx_application = NULL;
struct dict_object *ogs_diam_rx_cmd_aar = NULL;
struct dict_object *ogs_diam_rx_cmd_aaa = NULL;
struct dict_object *ogs_diam_rx_cmd_asr = NULL;
struct dict_object *ogs_diam_rx_cmd_asa = NULL;
struct dict_object *ogs_diam_rx_cmd_str = NULL;
struct dict_object *ogs_diam_rx_cmd_sta = NULL;
struct dict_object *ogs_diam_rx_media_component_description = NULL;
struct dict_object *ogs_diam_rx_media_component_number = NULL;
struct dict_object *ogs_diam_rx_media_type = NULL;
struct dict_object *ogs_diam_rx_max_requested_bandwidth_ul = NULL;
struct dict_object *ogs_diam_rx_max_requested_bandwidth_dl = NULL;
struct dict_object *ogs_diam_rx_min_requested_bandwidth_ul = NULL;
struct dict_object *ogs_diam_rx_min_requested_bandwidth_dl = NULL;
struct dict_object *ogs_diam_rx_rr_bandwidth = NULL;
struct dict_object *ogs_diam_rx_rs_bandwidth = NULL;
struct dict_object *ogs_diam_rx_flow_status = NULL;
struct dict_object *ogs_diam_rx_codec_data = NULL;
struct dict_object *ogs_diam_rx_media_sub_component = NULL;
struct dict_object *ogs_diam_rx_flow_number = NULL;
struct dict_object *ogs_diam_rx_flow_usage = NULL;
struct dict_object *ogs_diam_rx_flow_description = NULL;
struct dict_object *ogs_diam_rx_subscription_id = NULL;
struct dict_object *ogs_diam_rx_subscription_id_type = NULL;
struct dict_object *ogs_diam_rx_subscription_id_data = NULL;
struct dict_object *ogs_diam_rx_specific_action = NULL;
struct dict_object *ogs_diam_rx_framed_ip_address = NULL;
struct dict_object *ogs_diam_rx_framed_ipv6_prefix = NULL;
struct dict_object *ogs_diam_rx_ip_can_type = NULL;
struct dict_object *ogs_diam_rx_rat_type = NULL;
struct dict_object *ogs_diam_rx_abort_cause = NULL;
struct dict_object *ogs_diam_rx_termination_cause = NULL;
int ogs_diam_rx_dict_init(void)
{
application_id_t id = OGS_DIAM_RX_APPLICATION_ID;
CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &ogs_diam_rx_application);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "AA-Request", &ogs_diam_rx_cmd_aar);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "AA-Answer", &ogs_diam_rx_cmd_aaa);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Abort-Session-Request", &ogs_diam_rx_cmd_asr);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Abort-Session-Answer", &ogs_diam_rx_cmd_asa);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Session-Termination-Request", &ogs_diam_rx_cmd_str);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Session-Termination-Answer", &ogs_diam_rx_cmd_sta);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Description", &ogs_diam_rx_media_component_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Number", &ogs_diam_rx_media_component_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Type", &ogs_diam_rx_media_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &ogs_diam_rx_max_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &ogs_diam_rx_max_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &ogs_diam_rx_min_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &ogs_diam_rx_min_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &ogs_diam_rx_rr_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &ogs_diam_rx_rs_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Status", &ogs_diam_rx_flow_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Codec-Data", &ogs_diam_rx_codec_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Sub-Component", &ogs_diam_rx_media_sub_component);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Number", &ogs_diam_rx_flow_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Usage", &ogs_diam_rx_flow_usage);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Description", &ogs_diam_rx_flow_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id", &ogs_diam_rx_subscription_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Type", &ogs_diam_rx_subscription_id_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Data", &ogs_diam_rx_subscription_id_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Specific-Action", &ogs_diam_rx_specific_action);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IP-Address", &ogs_diam_rx_framed_ip_address);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IPv6-Prefix", &ogs_diam_rx_framed_ipv6_prefix);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IP-CAN-Type", &ogs_diam_rx_ip_can_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &ogs_diam_rx_rat_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Abort-Cause", &ogs_diam_rx_abort_cause);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Termination-Cause", &ogs_diam_rx_termination_cause);
return 0;
}

132
lib/diameter/rx/dict.h Normal file
View File

@ -0,0 +1,132 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_RX_DICT_H
#define OGS_DIAM_RX_DICT_H
#ifdef __cplusplus
extern "C" {
#endif
#define OGS_DIAM_RX_APPLICATION_ID 16777236
#define OGS_DIAM_RX_AVP_CODE_SUBSCRIPTION_ID (443)
#define OGS_DIAM_RX_AVP_CODE_SPECIFIC_ACTION (513)
#define OGS_DIAM_RX_AVP_CODE_MEDIA_COMPONENT_DESCRIPTION (517)
#define OGS_DIAM_RX_AVP_CODE_MEDIA_TYPE (520)
#define OGS_DIAM_RX_AVP_CODE_MAX_REQUESTED_BANDWIDTH_DL (515)
#define OGS_DIAM_RX_AVP_CODE_MAX_REQUESTED_BANDWIDTH_UL (516)
#define OGS_DIAM_RX_AVP_CODE_RR_BANDWIDTH (521)
#define OGS_DIAM_RX_AVP_CODE_RS_BANDWIDTH (522)
#define OGS_DIAM_RX_AVP_CODE_MIN_REQUESTED_BANDWIDTH_DL (534)
#define OGS_DIAM_RX_AVP_CODE_MIN_REQUESTED_BANDWIDTH_UL (535)
#define OGS_DIAM_RX_AVP_CODE_MEDIA_COMPONENT_NUMBER (518)
#define OGS_DIAM_RX_AVP_CODE_MEDIA_SUB_COMPONENT (519)
#define OGS_DIAM_RX_AVP_CODE_FLOW_DESCRIPTION (507)
#define OGS_DIAM_RX_AVP_CODE_FLOW_NUMBER (509)
#define OGS_DIAM_RX_AVP_CODE_FLOW_USAGE (512)
extern struct dict_object *ogs_diam_rx_application;
extern struct dict_object *ogs_diam_rx_cmd_aar;
extern struct dict_object *ogs_diam_rx_cmd_aaa;
extern struct dict_object *ogs_diam_rx_cmd_asr;
extern struct dict_object *ogs_diam_rx_cmd_asa;
extern struct dict_object *ogs_diam_rx_cmd_str;
extern struct dict_object *ogs_diam_rx_cmd_sta;
extern struct dict_object *ogs_diam_rx_media_component_description;
extern struct dict_object *ogs_diam_rx_media_component_number;
extern struct dict_object *ogs_diam_rx_media_type;
extern struct dict_object *ogs_diam_rx_max_requested_bandwidth_ul;
extern struct dict_object *ogs_diam_rx_max_requested_bandwidth_dl;
extern struct dict_object *ogs_diam_rx_min_requested_bandwidth_ul;
extern struct dict_object *ogs_diam_rx_min_requested_bandwidth_dl;
extern struct dict_object *ogs_diam_rx_rr_bandwidth;
extern struct dict_object *ogs_diam_rx_rs_bandwidth;
#define OGS_DIAM_RX_FLOW_STATUS_ENABLED_UPLINK 0
#define OGS_DIAM_RX_FLOW_STATUS_ENABLED_DOWNLINK 1
#define OGS_DIAM_RX_FLOW_STATUS_ENABLED 2
#define OGS_DIAM_RX_FLOW_STATUS_DISABLED 3
extern struct dict_object *ogs_diam_rx_flow_status;
extern struct dict_object *ogs_diam_rx_codec_data;
extern struct dict_object *ogs_diam_rx_media_sub_component;
extern struct dict_object *ogs_diam_rx_flow_number;
extern struct dict_object *ogs_diam_rx_flow_usage;
extern struct dict_object *ogs_diam_rx_flow_description;
extern struct dict_object *ogs_diam_rx_subscription_id;
#define OGS_DIAM_RX_SUBSCRIPTION_ID_TYPE_END_USER_E164 0
#define OGS_DIAM_RX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI 1
#define OGS_DIAM_RX_SUBSCRIPTION_ID_TYPE_END_USER_SIP_URI 2
#define OGS_DIAM_RX_SUBSCRIPTION_ID_TYPE_END_USER_NAI 3
extern struct dict_object *ogs_diam_rx_subscription_id_type;
extern struct dict_object *ogs_diam_rx_subscription_id_data;
extern struct dict_object *ogs_diam_rx_specific_action;
extern struct dict_object *ogs_diam_rx_framed_ip_address;
extern struct dict_object *ogs_diam_rx_framed_ipv6_prefix;
#define OGS_DIAM_RX_IP_CAN_TYPE_3GPP_GPRS 0
#define OGS_DIAM_RX_IP_CAN_TYPE_DOCSIS 1
#define OGS_DIAM_RX_IP_CAN_TYPE_xDSL 2
#define OGS_DIAM_RX_IP_CAN_TYPE_WiMAX 3
#define OGS_DIAM_RX_IP_CAN_TYPE_3GPP2 4
#define OGS_DIAM_RX_IP_CAN_TYPE_3GPP_EPS 5
#define OGS_DIAM_RX_IP_CAN_TYPE_Non_3GPP_EPS 6
extern struct dict_object *ogs_diam_rx_ip_can_type;
#define OGS_DIAM_RX_RAT_TYPE_WLAN 0
#define OGS_DIAM_RX_RAT_TYPE_VIRTUAL 1
#define OGS_DIAM_RX_RAT_TYPE_UTRAN 1000
#define OGS_DIAM_RX_RAT_TYPE_GERAN 1001
#define OGS_DIAM_RX_RAT_TYPE_GAN 1002
#define OGS_DIAM_RX_RAT_TYPE_HSPA_EVOLUTION 1003
#define OGS_DIAM_RX_RAT_TYPE_EUTRAN 1004
#define OGS_DIAM_RX_RAT_TYPE_EUTRAN_NB_IoT 1005
#define OGS_DIAM_RX_RAT_TYPE_CDMA2000_1X 2000
#define OGS_DIAM_RX_RAT_TYPE_HRPD 2001
#define OGS_DIAM_RX_RAT_TYPE_UMB 2002
#define OGS_DIAM_RX_RAT_TYPE_EHRPD 2003
extern struct dict_object *ogs_diam_rx_rat_type;
#define OGS_DIAM_RX_ABORT_CAUSE_BEARER_RELEASED 0
#define OGS_DIAM_RX_ABORT_CAUSE_INSUFFICIENT_SERVER_RESOURCES 1
#define OGS_DIAM_RX_ABORT_CAUSE_INSUFFICIENT_BEARER_RESOURCES 2
#define OGS_DIAM_RX_ABORT_CAUSE_PS_TO_CS_HANDOVER 3
#define OGS_DIAM_RX_ABORT_CAUSE_SPONSORED_DATA_CONNECTIVITY_DISALLOWED 4
extern struct dict_object *ogs_diam_rx_abort_cause;
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_LOGOUT 1
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_SERVICE_NOT_PROVIDED 2
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_BAD_ANSWER 3
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_DIAMETER_ADMINISTRATIVE 4
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_LINK_BROKEN 5
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_AUTH_EXPIRED 6
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_USER_MOVED 7
#define OGS_DIAM_RX_TERMINATION_CAUSE_DIAMETER_SESSION_TIMEOUT 8
extern struct dict_object *ogs_diam_rx_termination_cause;
int ogs_diam_rx_dict_init(void);
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_RX_DICT_H */

View File

@ -17,29 +17,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "rx-message.h"
#include "diameter/ogs-rx.h"
void rx_message_free(rx_message_t *rx_message)
void ogs_diam_rx_message_free(ogs_diam_rx_message_t *rx_message)
{
int i, j, k;
ogs_assert(rx_message);
for (i = 0; i < rx_message->num_of_media_component; i++)
{
rx_media_component_t *media_component =
for (i = 0; i < rx_message->num_of_media_component; i++) {
ogs_diam_rx_media_component_t *media_component =
&rx_message->media_component[i];
for (j = 0; j < media_component->num_of_sub; j++)
{
rx_media_sub_component_t *sub = &media_component->sub[j];
for (j = 0; j < media_component->num_of_sub; j++) {
ogs_diam_rx_media_sub_component_t *sub = &media_component->sub[j];
for (k = 0; k < sub->num_of_flow; k++)
{
flow_t *flow = &sub->flow[k];
for (k = 0; k < sub->num_of_flow; k++) {
ogs_flow_t *flow = &sub->flow[k];
if (flow->description)
{
if (flow->description) {
ogs_free(flow->description);
}
else

94
lib/diameter/rx/message.h Normal file
View File

@ -0,0 +1,94 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_RX_MESSAGE_H
#define OGS_DIAM_RX_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ogs_diam_rx_media_sub_component_s {
uint32_t flow_number;
#define OGS_DIAM_RX_FLOW_USAGE_NO_INFORMATION 0
#define OGS_DIAM_RX_FLOW_USAGE_RTCP 1
#define OGS_DIAM_RX_FLOW_USAGE_AF_SIGNALLING 2
uint32_t flow_usage;
ogs_flow_t flow[OGS_MAX_NUM_OF_FLOW];
int num_of_flow;
} ogs_diam_rx_media_sub_component_t;
typedef struct ogs_diam_rx_media_component_s {
uint32_t media_component_number;
#define OGS_DIAM_RX_MEDIA_TYPE_AUDIO 0
#define OGS_DIAM_RX_MEDIA_TYPE_VIDEO 1
#define OGS_DIAM_RX_MEDIA_TYPE_DATA 2
#define OGS_DIAM_RX_MEDIA_TYPE_APPLICATION 3
#define OGS_DIAM_RX_MEDIA_TYPE_CONTROL 4
#define OGS_DIAM_RX_MEDIA_TYPE_TEXT 5
#define OGS_DIAM_RX_MEDIA_TYPE_MESSAGE 6
#define OGS_DIAM_RX_MEDIA_TYPE_OTHER 0xFFFFFFFF
uint32_t media_type;
uint64_t max_requested_bandwidth_dl;
uint64_t max_requested_bandwidth_ul;
uint64_t min_requested_bandwidth_dl;
uint64_t min_requested_bandwidth_ul;
uint64_t rr_bandwidth;
uint64_t rs_bandwidth;
#define OGS_DIAM_MAX_NUM_OF_MEDIA_SUB_COMPONENT 8
ogs_diam_rx_media_sub_component_t
sub[OGS_DIAM_MAX_NUM_OF_MEDIA_SUB_COMPONENT];
int num_of_sub;
} ogs_diam_rx_media_component_t;
typedef struct ogs_diam_rx_message_s {
#define OGS_DIAM_RX_CMD_CODE_AA 265
#define OGS_DIAM_RX_CMD_CODE_SESSION_TERMINATION 275
uint16_t cmd_code;
/* Experimental-Result-Codes */
#define OGS_DIAM_RX_DIAMETER_INVALID_SERVICE_INFORMATION 5061
#define OGS_DIAM_RX_DIAMETER_FILTER_RESTRICTIONS 5062
#define OGS_DIAM_RX_DIAMETER_REQUESTED_SERVICE_NOT_AUTHORIZED 5063
#define OGS_DIAM_RX_DIAMETER_DUPLICATED_AF_SESSION 5064
#define OGS_DIAM_RX_DIAMETER_IP_CAN_SESSION_NOT_AVAILABLE 5065
#define OGS_DIAM_RX_DIAMETER_UNAUTHORIZED_NON_EMERGENCY_SESSION 5066
#define OGS_DIAM_RX_DIAMETER_UNAUTHORIZED_SPONSORED_DATA_CONNECTIVITY 5067
#define OGS_DIAM_RX_DIAMETER_TEMPORARY_NETWORK_FAILURE 5068
uint32_t result_code;
#define OGS_DIAM_MAX_NUM_OF_MEDIA_COMPONENT 16
ogs_diam_rx_media_component_t
media_component[OGS_DIAM_MAX_NUM_OF_MEDIA_COMPONENT];
int num_of_media_component;
} ogs_diam_rx_message_t;
void ogs_diam_rx_message_free(ogs_diam_rx_message_t *rx_message);
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_OGS_DIAM_RX_MESSAGE_H */

125
lib/diameter/s6a/dict.c Normal file
View File

@ -0,0 +1,125 @@
/*
* 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/>.
*/
#include "diameter/ogs-s6a.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
struct dict_object *ogs_diam_s6a_application = NULL;
struct dict_object *ogs_diam_s6a_cmd_air = NULL;
struct dict_object *ogs_diam_s6a_cmd_aia = NULL;
struct dict_object *ogs_diam_s6a_cmd_ulr = NULL;
struct dict_object *ogs_diam_s6a_cmd_ula = NULL;
struct dict_object *ogs_diam_s6a_cmd_pur = NULL;
struct dict_object *ogs_diam_s6a_cmd_pua = NULL;
struct dict_object *ogs_diam_s6a_visited_plmn_id = NULL;
struct dict_object *ogs_diam_s6a_rat_type = NULL;
struct dict_object *ogs_diam_s6a_ulr_flags = NULL;
struct dict_object *ogs_diam_s6a_ula_flags = NULL;
struct dict_object *ogs_diam_s6a_subscription_data = NULL;
struct dict_object *ogs_diam_s6a_req_eutran_auth_info = NULL;
struct dict_object *ogs_diam_s6a_number_of_requested_vectors = NULL;
struct dict_object *ogs_diam_s6a_immediate_response_preferred = NULL;
struct dict_object *ogs_diam_s6a_authentication_info = NULL;
struct dict_object *ogs_diam_s6a_re_synchronization_info = NULL;
struct dict_object *ogs_diam_s6a_service_selection = NULL;
struct dict_object *ogs_diam_s6a_ue_srvcc_capability = NULL;
struct dict_object *ogs_diam_s6a_e_utran_vector = NULL;
struct dict_object *ogs_diam_s6a_rand = NULL;
struct dict_object *ogs_diam_s6a_xres = NULL;
struct dict_object *ogs_diam_s6a_autn = NULL;
struct dict_object *ogs_diam_s6a_kasme = NULL;
struct dict_object *ogs_diam_s6a_subscriber_status = NULL;
struct dict_object *ogs_diam_s6a_ambr = NULL;
struct dict_object *ogs_diam_s6a_network_access_mode = NULL;
struct dict_object *ogs_diam_s6a_access_restriction_data = NULL;
struct dict_object *ogs_diam_s6a_apn_configuration_profile = NULL;
struct dict_object *ogs_diam_s6a_subscribed_rau_tau_timer = NULL;
struct dict_object *ogs_diam_s6a_context_identifier = NULL;
struct dict_object *ogs_diam_s6a_all_apn_configuration_included_indicator = NULL;
struct dict_object *ogs_diam_s6a_apn_configuration = NULL;
struct dict_object *ogs_diam_s6a_max_bandwidth_ul = NULL;
struct dict_object *ogs_diam_s6a_max_bandwidth_dl = NULL;
struct dict_object *ogs_diam_s6a_pdn_type = NULL;
struct dict_object *ogs_diam_s6a_eps_subscribed_qos_profile = NULL;
struct dict_object *ogs_diam_s6a_qos_class_identifier = NULL;
struct dict_object *ogs_diam_s6a_allocation_retention_priority = NULL;
struct dict_object *ogs_diam_s6a_priority_level = NULL;
struct dict_object *ogs_diam_s6a_pre_emption_capability = NULL;
struct dict_object *ogs_diam_s6a_pre_emption_vulnerability = NULL;
int ogs_diam_s6a_dict_init(void)
{
application_id_t id = OGS_DIAM_S6A_APPLICATION_ID;
CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &ogs_diam_s6a_application);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Authentication-Information-Request", &ogs_diam_s6a_cmd_air);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Authentication-Information-Answer", &ogs_diam_s6a_cmd_aia);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Update-Location-Request", &ogs_diam_s6a_cmd_ulr);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Update-Location-Answer", &ogs_diam_s6a_cmd_ula);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Request", &ogs_diam_s6a_cmd_pur);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Answer", &ogs_diam_s6a_cmd_pua);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Visited-PLMN-Id", &ogs_diam_s6a_visited_plmn_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &ogs_diam_s6a_rat_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULR-Flags", &ogs_diam_s6a_ulr_flags);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULA-Flags", &ogs_diam_s6a_ula_flags);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "UE-SRVCC-Capability", &ogs_diam_s6a_ue_srvcc_capability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info", &ogs_diam_s6a_req_eutran_auth_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Number-Of-Requested-Vectors", &ogs_diam_s6a_number_of_requested_vectors);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Immediate-Response-Preferred", &ogs_diam_s6a_immediate_response_preferred);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Re-Synchronization-Info", &ogs_diam_s6a_re_synchronization_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Authentication-Info", &ogs_diam_s6a_authentication_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "E-UTRAN-Vector", &ogs_diam_s6a_e_utran_vector);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAND", &ogs_diam_s6a_rand);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "XRES", &ogs_diam_s6a_xres);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AUTN", &ogs_diam_s6a_autn);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "KASME", &ogs_diam_s6a_kasme);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "EPS-Subscribed-QoS-Profile", &ogs_diam_s6a_eps_subscribed_qos_profile);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier", &ogs_diam_s6a_qos_class_identifier);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority", &ogs_diam_s6a_allocation_retention_priority);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &ogs_diam_s6a_priority_level);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &ogs_diam_s6a_pre_emption_capability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &ogs_diam_s6a_pre_emption_vulnerability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AMBR", &ogs_diam_s6a_ambr);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL", &ogs_diam_s6a_max_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL", &ogs_diam_s6a_max_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Configuration-Profile", &ogs_diam_s6a_apn_configuration_profile);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Context-Identifier", &ogs_diam_s6a_context_identifier);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "All-APN-Configurations-Included-Indicator", &ogs_diam_s6a_all_apn_configuration_included_indicator);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Configuration", &ogs_diam_s6a_apn_configuration);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Selection", &ogs_diam_s6a_service_selection);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "PDN-Type", &ogs_diam_s6a_pdn_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Data", &ogs_diam_s6a_subscription_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscriber-Status", &ogs_diam_s6a_subscriber_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Network-Access-Mode", &ogs_diam_s6a_network_access_mode);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Access-Restriction-Data", &ogs_diam_s6a_access_restriction_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscribed-Periodic-RAU-TAU-Timer", &ogs_diam_s6a_subscribed_rau_tau_timer);
return 0;
}

113
lib/diameter/s6a/dict.h Normal file
View File

@ -0,0 +1,113 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_S6A_DICT_H
#define OGS_DIAM_S6A_DICT_H
#ifdef __cplusplus
extern "C" {
#endif
#define OGS_DIAM_S6A_APPLICATION_ID 16777251
#define OGS_DIAM_S6A_AVP_CODE_CONTEXT_IDENTIFIER (1423)
#define OGS_DIAM_S6A_AVP_CODE_ALL_APN_CONFIG_INC_IND (1428)
#define OGS_DIAM_S6A_AVP_CODE_APN_CONFIGURATION (1430)
#define OGS_DIAM_S6A_AVP_CODE_MIP_HOME_AGENT_ADDRESS (334)
#define OGS_DIAM_S6A_RAT_TYPE_WLAN 0
#define OGS_DIAM_S6A_RAT_TYPE_VIRTUAL 1
#define OGS_DIAM_S6A_RAT_TYPE_UTRAN 1000
#define OGS_DIAM_S6A_RAT_TYPE_GERAN 1001
#define OGS_DIAM_S6A_RAT_TYPE_GAN 1002
#define OGS_DIAM_S6A_RAT_TYPE_HSPA_EVOLUTION 1003
#define OGS_DIAM_S6A_RAT_TYPE_EUTRAN 1004
#define OGS_DIAM_S6A_RAT_TYPE_EUTRAN_NB_IOT 1005
#define OGS_DIAM_S6A_RAT_TYPE_CDMA2000_1X 2000
#define OGS_DIAM_S6A_RAT_TYPE_HRPD 2001
#define OGS_DIAM_S6A_RAT_TYPE_UMB 2002
#define OGS_DIAM_S6A_RAT_TYPE_EHRPD 2003
#define OGS_DIAM_S6A_ULR_SINGLE_REGISTRATION_IND (1)
#define OGS_DIAM_S6A_ULR_S6A_S6D_INDICATOR (1 << 1)
#define OGS_DIAM_S6A_ULR_SKIP_SUBSCRIBER_DATA (1 << 2)
#define OGS_DIAM_S6A_ULR_GPRS_SUBSCRIPTION_DATA_IND (1 << 3)
#define OGS_DIAM_S6A_ULR_NODE_TYPE_IND (1 << 4)
#define OGS_DIAM_S6A_ULR_INITIAL_ATTACH_IND (1 << 5)
#define OGS_DIAM_S6A_ULR_PS_LCS_SUPPORTED_BY_UE (1 << 6)
#define OGS_DIAM_S6A_UE_SRVCC_NOT_SUPPORTED (0)
#define OGS_DIAM_S6A_UE_SRVCC_SUPPORTED (1)
extern struct dict_object *ogs_diam_s6a_application;
extern struct dict_object *ogs_diam_s6a_cmd_air;
extern struct dict_object *ogs_diam_s6a_cmd_aia;
extern struct dict_object *ogs_diam_s6a_cmd_ulr;
extern struct dict_object *ogs_diam_s6a_cmd_ula;
extern struct dict_object *ogs_diam_s6a_cmd_pur;
extern struct dict_object *ogs_diam_s6a_cmd_pua;
extern struct dict_object *ogs_diam_s6a_visited_plmn_id;
extern struct dict_object *ogs_diam_s6a_rat_type;
extern struct dict_object *ogs_diam_s6a_ulr_flags;
extern struct dict_object *ogs_diam_s6a_ula_flags;
extern struct dict_object *ogs_diam_s6a_subscription_data;
extern struct dict_object *ogs_diam_s6a_req_eutran_auth_info;
extern struct dict_object *ogs_diam_s6a_number_of_requested_vectors;
extern struct dict_object *ogs_diam_s6a_immediate_response_preferred;
extern struct dict_object *ogs_diam_s6a_authentication_info;
extern struct dict_object *ogs_diam_s6a_re_synchronization_info;
extern struct dict_object *ogs_diam_s6a_service_selection;
extern struct dict_object *ogs_diam_s6a_ue_srvcc_capability;
extern struct dict_object *ogs_diam_s6a_e_utran_vector;
extern struct dict_object *ogs_diam_s6a_rand;
extern struct dict_object *ogs_diam_s6a_xres;
extern struct dict_object *ogs_diam_s6a_autn;
extern struct dict_object *ogs_diam_s6a_kasme;
extern struct dict_object *ogs_diam_s6a_subscriber_status;
extern struct dict_object *ogs_diam_s6a_ambr;
extern struct dict_object *ogs_diam_s6a_network_access_mode;
extern struct dict_object *ogs_diam_s6a_access_restriction_data;
extern struct dict_object *ogs_diam_s6a_apn_configuration_profile;
extern struct dict_object *ogs_diam_s6a_subscribed_rau_tau_timer;
extern struct dict_object *ogs_diam_s6a_context_identifier;
extern struct dict_object *ogs_diam_s6a_all_apn_configuration_included_indicator;
extern struct dict_object *ogs_diam_s6a_apn_configuration;
extern struct dict_object *ogs_diam_s6a_max_bandwidth_ul;
extern struct dict_object *ogs_diam_s6a_max_bandwidth_dl;
extern struct dict_object *ogs_diam_s6a_pdn_type;
extern struct dict_object *ogs_diam_s6a_eps_subscribed_qos_profile;
extern struct dict_object *ogs_diam_s6a_qos_class_identifier;
extern struct dict_object *ogs_diam_s6a_allocation_retention_priority;
extern struct dict_object *ogs_diam_s6a_priority_level;
extern struct dict_object *ogs_diam_s6a_pre_emption_capability;
extern struct dict_object *ogs_diam_s6a_pre_emption_vulnerability;
int ogs_diam_s6a_dict_init(void);
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_OGS_DIAM_S6A_DICT_H */

102
lib/diameter/s6a/message.h Normal file
View File

@ -0,0 +1,102 @@
/*
* 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/>.
*/
#if !defined(OGS_DIAMETER_INSIDE) && !defined(OGS_DIAMETER_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_DIAM_S6A_MESSAGE_H
#define OGS_DIAM_S6A_MESSAGE_H
#include "ogs-crypt.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ogs_diam_e_utran_vector_s {
uint8_t xres[OGS_MAX_RES_LEN];
uint8_t xres_len;
uint8_t kasme[OGS_SHA256_DIGEST_SIZE];
uint8_t rand[OGS_RAND_LEN];
uint8_t autn[OGS_AUTN_LEN];
} ogs_diam_e_utran_vector_t;
typedef struct ogs_diam_s6a_aia_message_s {
ogs_diam_e_utran_vector_t e_utran_vector;
} ogs_diam_s6a_aia_message_t;
typedef struct ogs_diam_s6a_subscription_data_s {
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1)
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1)
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2)
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3)
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4)
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5)
#define OGS_DIAM_S6A_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6)
uint32_t access_restriction_data;
#define OGS_DIAM_S6A_SUBSCRIBER_STATUS_SERVICE_GRANTED 0
#define OGS_DIAM_S6A_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1
uint32_t subscriber_status;
#define OGS_DIAM_S6A_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0
#define OGS_DIAM_S6A_NETWORK_ACCESS_MODE_RESERVED 1
#define OGS_DIAM_S6A_NETWORK_ACCESS_MODE_ONLY_PACKET 2
uint32_t network_access_mode;
ogs_bitrate_t ambr; /* UE-AMBR */
#define OGS_DIAM_S6A_RAU_TAU_DEFAULT_TIME (12*60) /* 12 min */
uint32_t subscribed_rau_tau_timer; /* unit : seconds */
uint32_t context_identifier; /* default APN */
ogs_pdn_t pdn[OGS_MAX_NUM_OF_SESS];
int num_of_pdn;
} ogs_diam_s6a_subscription_data_t;
typedef struct ogs_diam_s6a_ula_message_s {
#define OGS_DIAM_S6A_ULA_FLAGS_SEPARATION_INDICATION (0)
#define OGS_DIAM_S6A_ULA_FLAGS_MME_REGISTERED_FOR_SMS (1)
uint32_t ula_flags;
ogs_diam_s6a_subscription_data_t subscription_data;
} ogs_diam_s6a_ula_message_t;
typedef struct ogs_diam_s6a_message_s {
#define OGS_DIAM_S6A_CMD_CODE_UPDATE_LOCATION 316
#define OGS_DIAM_S6A_CMD_CODE_AUTHENTICATION_INFORMATION 318
uint16_t cmd_code;
/* Experimental Result Code */
#define OGS_DIAM_S6A_AUTHENTICATION_DATA_UNAVAILABLE 4181
#define OGS_DIAM_S6A_ERROR_USER_UNKNOWN 5001
#define OGS_DIAM_S6A_ERROR_ROAMING_NOT_ALLOWED 5004
#define OGS_DIAM_S6A_ERROR_UNKNOWN_EPS_SUBSCRIPTION 5420
#define OGS_DIAM_S6A_ERROR_RAT_NOT_ALLOWED 5421
#define OGS_DIAM_S6A_ERROR_EQUIPMENT_UNKNOWN 5422
#define OGS_DIAM_S6A_ERROR_UNKOWN_SERVING_NODE 5423
uint32_t result_code;
ogs_diam_s6a_aia_message_t aia_message;
ogs_diam_s6a_ula_message_t ula_message;
} ogs_diam_s6a_message_t;
#ifdef __cplusplus
}
#endif
#endif /* OGS_DIAM_S6A_MESSAGE_H */

View File

@ -1,78 +0,0 @@
/*
* 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 FD_MESSAGE_H
#define FD_MESSAGE_H
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FD_AVP_CODE_FRAME_IP_ADDRESS 8
#define FD_AVP_CODE_FRAME_IPV6_PREFIX 97
/* Result-Code AVP */
#define FD_DIAMETER_UNKNOWN_PEER 3010
#define FD_DIAMETER_AVP_UNSUPPORTED 5001
#define FD_DIAMETER_UNKNOWN_SESSION_ID 5002
#define FD_DIAMETER_AUTHORIZATION_REJECTED 5003
#define FD_DIAMETER_MISSING_AVP 5004
#define FD_DIAMETER_INVALID_AVP_VALUE 5005
extern struct dict_object *fd_session_id;
extern struct dict_object *fd_origin_host;
extern struct dict_object *fd_origin_realm;
extern struct dict_object *fd_destination_host;
extern struct dict_object *fd_destination_realm;
extern struct dict_object *fd_user_name;
#define FD_AUTH_SESSION_STATE_MAINTAINED 0
#define FD_AUTH_SESSION_NO_STATE_MAINTAINED 1
extern struct dict_object *fd_auth_session_state;
extern struct dict_object *fd_auth_application_id;
#define FD_AUTH_REQUEST_TYPE_AUTHENTICATE_ONLY 1
#define FD_AUTH_REQUEST_TYPE_AUTHORIZE_ONLY 2
#define FD_AUTH_REQUEST_TYPE_AUTHORIZE_AUTHENTICATE 3
extern struct dict_object *fd_auth_request_type;
#define FD_RE_AUTH_REQUEST_TYPE_AUTHORIZE_ONLY 0
#define FD_RE_AUTH_REQUEST_TYPE_AUTHORIZE_AUTHENTICATE 1
extern struct dict_object *fd_re_auth_request_type;
extern struct dict_object *fd_result_code;
extern struct dict_object *fd_experimental_result;
extern struct dict_object *fd_experimental_result_code;
extern struct dict_object *fd_vendor_specific_application_id;
extern struct dict_object *fd_mip6_agent_info;
extern struct dict_object *fd_mip_home_agent_address;
extern struct dict_object *fd_vendor;
extern struct dict_object *fd_vendor_id;
int fd_message_init(void);
int fd_message_session_id_set(struct msg *msg, uint8_t *sid, size_t sidlen);
int fd_message_experimental_rescode_set(
struct msg *msg, uint32_t result_code);
int fd_message_vendor_specific_appid_set(struct msg *msg, uint32_t app_id);
#ifdef __cplusplus
}
#endif
#endif /* FD_MESSAGE_H */

View File

@ -1,156 +0,0 @@
/*
* 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/>.
*/
#include "gx-dict.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
struct dict_object *gx_application = NULL;
struct dict_object *gx_cmd_ccr = NULL;
struct dict_object *gx_cmd_cca = NULL;
struct dict_object *gx_cmd_rar = NULL;
struct dict_object *gx_cmd_raa = NULL;
struct dict_object *gx_cc_request_type = NULL;
struct dict_object *gx_cc_request_number = NULL;
struct dict_object *gx_network_request_support = NULL;
struct dict_object *gx_subscription_id = NULL;
struct dict_object *gx_subscription_id_type = NULL;
struct dict_object *gx_subscription_id_data = NULL;
struct dict_object *gx_supported_features = NULL;
struct dict_object *gx_feature_list_id = NULL;
struct dict_object *gx_feature_list = NULL;
struct dict_object *gx_framed_ip_address = NULL;
struct dict_object *gx_framed_ipv6_prefix = NULL;
struct dict_object *gx_ip_can_type = NULL;
struct dict_object *gx_rat_type = NULL;
struct dict_object *gx_qos_information = NULL;
struct dict_object *gx_qos_class_identifier = NULL;
struct dict_object *gx_max_requested_bandwidth_ul = NULL;
struct dict_object *gx_max_requested_bandwidth_dl = NULL;
struct dict_object *gx_min_requested_bandwidth_ul = NULL;
struct dict_object *gx_min_requested_bandwidth_dl = NULL;
struct dict_object *gx_guaranteed_bitrate_ul = NULL;
struct dict_object *gx_guaranteed_bitrate_dl = NULL;
struct dict_object *gx_allocation_retention_priority = NULL;
struct dict_object *gx_priority_level = NULL;
struct dict_object *gx_pre_emption_capability = NULL;
struct dict_object *gx_pre_emption_vulnerability = NULL;
struct dict_object *gx_apn_aggregate_max_bitrate_ul = NULL;
struct dict_object *gx_apn_aggregate_max_bitrate_dl = NULL;
struct dict_object *gx_3gpp_user_location_info = NULL;
struct dict_object *gx_called_station_id = NULL;
struct dict_object *gx_default_eps_bearer_qos = NULL;
struct dict_object *gx_3gpp_ms_timezone = NULL;
struct dict_object *gx_event_trigger = NULL;
struct dict_object *gx_bearer_control_mode = NULL;
struct dict_object *gx_charging_rule_install = NULL;
struct dict_object *gx_charging_rule_remove = NULL;
struct dict_object *gx_charging_rule_definition = NULL;
struct dict_object *gx_charging_rule_base_name = NULL;
struct dict_object *gx_charging_rule_name = NULL;
struct dict_object *gx_flow_information = NULL;
struct dict_object *gx_flow_direction = NULL;
struct dict_object *gx_flow_description = NULL;
struct dict_object *gx_flow_status = NULL;
struct dict_object *gx_precedence = NULL;
struct dict_object *gx_flows = NULL;
struct dict_object *gx_media_component_description = NULL;
struct dict_object *gx_media_component_number = NULL;
struct dict_object *gx_media_type = NULL;
struct dict_object *gx_rr_bandwidth = NULL;
struct dict_object *gx_rs_bandwidth = NULL;
struct dict_object *gx_codec_data = NULL;
struct dict_object *gx_media_sub_component = NULL;
struct dict_object *gx_flow_number = NULL;
struct dict_object *gx_flow_usage = NULL;
int gx_dict_init(void)
{
application_id_t id = GX_APPLICATION_ID;
CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &gx_application);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &gx_cmd_ccr);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Answer", &gx_cmd_cca);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Request", &gx_cmd_rar);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Re-Auth-Answer", &gx_cmd_raa);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Type", &gx_cc_request_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "CC-Request-Number", &gx_cc_request_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Network-Request-Support", &gx_network_request_support);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id", &gx_subscription_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Type", &gx_subscription_id_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Data", &gx_subscription_id_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Supported-Features", &gx_supported_features);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List-ID", &gx_feature_list_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Feature-List", &gx_feature_list);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IP-Address", &gx_framed_ip_address);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IPv6-Prefix", &gx_framed_ipv6_prefix);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IP-CAN-Type", &gx_ip_can_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &gx_rat_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Information", &gx_qos_information);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier" , &gx_qos_class_identifier);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &gx_max_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &gx_max_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &gx_min_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &gx_min_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-UL" , &gx_guaranteed_bitrate_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Guaranteed-Bitrate-DL" , &gx_guaranteed_bitrate_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority" , &gx_allocation_retention_priority);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &gx_priority_level);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &gx_pre_emption_capability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &gx_pre_emption_vulnerability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-UL" , &gx_apn_aggregate_max_bitrate_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Aggregate-Max-Bitrate-DL" , &gx_apn_aggregate_max_bitrate_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-User-Location-Info", &gx_3gpp_user_location_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Called-Station-Id", &gx_called_station_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Default-EPS-Bearer-QoS", &gx_default_eps_bearer_qos);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "3GPP-MS-TimeZone", &gx_3gpp_ms_timezone);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Event-Trigger", &gx_event_trigger);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Bearer-Control-Mode", &gx_bearer_control_mode);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Install", &gx_charging_rule_install);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Remove", &gx_charging_rule_remove);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Definition", &gx_charging_rule_definition);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Base-Name", &gx_charging_rule_base_name);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Charging-Rule-Name", &gx_charging_rule_name);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Information", &gx_flow_information);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Direction", &gx_flow_direction);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Description", &gx_flow_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Status", &gx_flow_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Precedence", &gx_precedence);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flows", &gx_flows);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Description", &gx_media_component_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Number", &gx_media_component_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Type", &gx_media_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &gx_rr_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &gx_rs_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Codec-Data", &gx_codec_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Sub-Component", &gx_media_sub_component);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Number", &gx_flow_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Usage", &gx_flow_usage);
return 0;
}

View File

@ -1,135 +0,0 @@
/*
* 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 GX_DICT_H
#define GX_DICT_H
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#ifdef __cplusplus
extern "C" {
#endif
#define GX_APPLICATION_ID 16777238
#define GX_AVP_CODE_RE_AUTH_REQUEST_TYPE (285)
#define GX_AVP_CODE_CC_REQUEST_NUMBER (415)
#define GX_AVP_CODE_CC_REQUEST_TYPE (416)
#define GX_AVP_CODE_DEFAULT_EPS_BEARER_QOS (1049)
#define GX_AVP_CODE_SUPPORTED_FEATURES (628)
#define GX_AVP_CODE_CHARGING_RULE_INSTALL (1001)
#define GX_AVP_CODE_CHARGING_RULE_REMOVE (1002)
#define GX_AVP_CODE_CHARGING_RULE_DEFINITION (1003)
#define GX_AVP_CODE_CHARGING_RULE_NAME (1005)
#define GX_AVP_CODE_FLOW_INFORMATION (1058)
#define GX_AVP_CODE_FLOW_STATUS (511)
#define GX_AVP_CODE_QOS_INFORMATION (1016)
#define GX_AVP_CODE_PRECEDENCE (1010)
extern struct dict_object *gx_application;
extern struct dict_object *gx_cmd_ccr;
extern struct dict_object *gx_cmd_cca;
extern struct dict_object *gx_cmd_rar;
extern struct dict_object *gx_cmd_raa;
extern struct dict_object *gx_cc_request_type;
extern struct dict_object *gx_cc_request_number;
extern struct dict_object *gx_network_request_support;
extern struct dict_object *gx_subscription_id;
#define GX_SUBSCRIPTION_ID_TYPE_END_USER_E164 0
#define GX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI 1
#define GX_SUBSCRIPTION_ID_TYPE_END_USER_SIP_URI 2
#define GX_SUBSCRIPTION_ID_TYPE_END_USER_NAI 3
extern struct dict_object *gx_subscription_id_type;
extern struct dict_object *gx_subscription_id_data;
extern struct dict_object *gx_supported_features;
extern struct dict_object *gx_feature_list_id;
extern struct dict_object *gx_feature_list;
extern struct dict_object *gx_framed_ip_address;
extern struct dict_object *gx_framed_ipv6_prefix;
#define GX_IP_CAN_TYPE_3GPP_GPRS 0
#define GX_IP_CAN_TYPE_DOCSIS 1
#define GX_IP_CAN_TYPE_xDSL 2
#define GX_IP_CAN_TYPE_WiMAX 3
#define GX_IP_CAN_TYPE_3GPP2 4
#define GX_IP_CAN_TYPE_3GPP_EPS 5
#define GX_IP_CAN_TYPE_Non_3GPP_EPS 6
extern struct dict_object *gx_ip_can_type;
#define GX_RAT_TYPE_WLAN 0
#define GX_RAT_TYPE_VIRTUAL 1
#define GX_RAT_TYPE_UTRAN 1000
#define GX_RAT_TYPE_GERAN 1001
#define GX_RAT_TYPE_GAN 1002
#define GX_RAT_TYPE_HSPA_EVOLUTION 1003
#define GX_RAT_TYPE_EUTRAN 1004
#define GX_RAT_TYPE_EUTRAN_NB_IoT 1005
#define GX_RAT_TYPE_CDMA2000_1X 2000
#define GX_RAT_TYPE_HRPD 2001
#define GX_RAT_TYPE_UMB 2002
#define GX_RAT_TYPE_EHRPD 2003
extern struct dict_object *gx_rat_type;
extern struct dict_object *gx_qos_information;
extern struct dict_object *gx_qos_class_identifier;
extern struct dict_object *gx_max_requested_bandwidth_ul;
extern struct dict_object *gx_max_requested_bandwidth_dl;
extern struct dict_object *gx_guaranteed_bitrate_ul;
extern struct dict_object *gx_guaranteed_bitrate_dl;
extern struct dict_object *gx_allocation_retention_priority;
extern struct dict_object *gx_priority_level;
extern struct dict_object *gx_pre_emption_capability;
extern struct dict_object *gx_pre_emption_vulnerability;
extern struct dict_object *gx_apn_aggregate_max_bitrate_ul;
extern struct dict_object *gx_apn_aggregate_max_bitrate_dl;
#define GX_3GPP_USER_LOCATION_INFO_TYPE_TAI_AND_ECGI 130
extern struct dict_object *gx_3gpp_user_location_info;
extern struct dict_object *gx_called_station_id;
extern struct dict_object *gx_default_eps_bearer_qos;
extern struct dict_object *gx_3gpp_ms_timezone;
extern struct dict_object *gx_event_trigger;
extern struct dict_object *gx_bearer_control_mode;
extern struct dict_object *gx_charging_rule_install;
extern struct dict_object *gx_charging_rule_remove;
extern struct dict_object *gx_charging_rule_definition;
extern struct dict_object *gx_charging_rule_base_name;
extern struct dict_object *gx_charging_rule_name;
extern struct dict_object *gx_flow_information;
extern struct dict_object *gx_flow_direction;
extern struct dict_object *gx_flow_description;
extern struct dict_object *gx_flow_status;
extern struct dict_object *gx_precedence;
extern struct dict_object *gx_flows;
extern struct dict_object *gx_media_component_description;
extern struct dict_object *gx_media_component_number;
extern struct dict_object *gx_media_type;
extern struct dict_object *gx_rr_bandwidth;
extern struct dict_object *gx_rs_bandwidth;
extern struct dict_object *gx_codec_data;
extern struct dict_object *gx_media_sub_component;
extern struct dict_object *gx_flow_number;
extern struct dict_object *gx_flow_usage;
int gx_dict_init(void);
#ifdef __cplusplus
}
#endif
#endif /* GX_DICT_H */

View File

@ -1,64 +0,0 @@
/*
* 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 GX_MESSAGE_H
#define GX_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "base/types.h"
typedef struct _gx_message_t {
#define GX_CMD_CODE_CREDIT_CONTROL 272
#define GX_CMD_RE_AUTH 258
uint16_t cmd_code;
/* Experimental-Result-Codes */
#define GX_DIAMETER_ERROR_LATE_OVERLAPPING_REQUEST 5453
#define GX_DIAMETER_ERROR_TIMED_OUT_REQUEST 5454
#define GX_DIAMETER_ERROR_INITIAL_PARAMETERS 5140
#define GX_DIAMETER_ERROR_TRIGGER_EVENT 5141
#define GX_DIAMETER_PCC_RULE_EVENT 5142
#define GX_DIAMETER_ERROR_BEARER_NOT_AUTHORIZED 5143
#define GX_DIAMETER_ERROR_TRAFFIC_MAPPING_INFO_REJECTED 5144
#define GX_DIAMETER_ERROR_CONFLICTING_REQUEST 5147
#define GX_DIAMETER_ADC_RULE_EVENT 5148
#define GX_DIAMETER_ERROR_NBIFOM_NOT_AUTHORIZED 5149
uint32_t result_code;
#define GX_CC_REQUEST_TYPE_INITIAL_REQUEST 1
#define GX_CC_REQUEST_TYPE_UPDATE_REQUEST 2
#define GX_CC_REQUEST_TYPE_TERMINATION_REQUEST 3
#define GX_CC_REQUEST_TYPE_EVENT_REQUEST 4
uint32_t cc_request_type;
pdn_t pdn;
pcc_rule_t pcc_rule[MAX_NUM_OF_PCC_RULE];
int num_of_pcc_rule;
} gx_message_t;
void gx_message_free(gx_message_t *gx_message);
#ifdef __cplusplus
}
#endif
#endif /* GX_MESSAGE_H */

View File

@ -1,100 +0,0 @@
/*
* 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/>.
*/
#include "rx-dict.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
struct dict_object *rx_application = NULL;
struct dict_object *rx_cmd_aar = NULL;
struct dict_object *rx_cmd_aaa = NULL;
struct dict_object *rx_cmd_asr = NULL;
struct dict_object *rx_cmd_asa = NULL;
struct dict_object *rx_cmd_str = NULL;
struct dict_object *rx_cmd_sta = NULL;
struct dict_object *rx_media_component_description = NULL;
struct dict_object *rx_media_component_number = NULL;
struct dict_object *rx_media_type = NULL;
struct dict_object *rx_max_requested_bandwidth_ul = NULL;
struct dict_object *rx_max_requested_bandwidth_dl = NULL;
struct dict_object *rx_min_requested_bandwidth_ul = NULL;
struct dict_object *rx_min_requested_bandwidth_dl = NULL;
struct dict_object *rx_rr_bandwidth = NULL;
struct dict_object *rx_rs_bandwidth = NULL;
struct dict_object *rx_flow_status = NULL;
struct dict_object *rx_codec_data = NULL;
struct dict_object *rx_media_sub_component = NULL;
struct dict_object *rx_flow_number = NULL;
struct dict_object *rx_flow_usage = NULL;
struct dict_object *rx_flow_description = NULL;
struct dict_object *rx_subscription_id = NULL;
struct dict_object *rx_subscription_id_type = NULL;
struct dict_object *rx_subscription_id_data = NULL;
struct dict_object *rx_specific_action = NULL;
struct dict_object *rx_framed_ip_address = NULL;
struct dict_object *rx_framed_ipv6_prefix = NULL;
struct dict_object *rx_ip_can_type = NULL;
struct dict_object *rx_rat_type = NULL;
struct dict_object *rx_abort_cause = NULL;
struct dict_object *rx_termination_cause = NULL;
int rx_dict_init(void)
{
application_id_t id = RX_APPLICATION_ID;
CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &rx_application);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "AA-Request", &rx_cmd_aar);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "AA-Answer", &rx_cmd_aaa);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Abort-Session-Request", &rx_cmd_asr);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Abort-Session-Answer", &rx_cmd_asa);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Session-Termination-Request", &rx_cmd_str);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Session-Termination-Answer", &rx_cmd_sta);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Description", &rx_media_component_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Component-Number", &rx_media_component_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Type", &rx_media_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL" , &rx_max_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL" , &rx_max_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-UL" , &rx_min_requested_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Min-Requested-Bandwidth-DL" , &rx_min_requested_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RR-Bandwidth" , &rx_rr_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RS-Bandwidth" , &rx_rs_bandwidth);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Status", &rx_flow_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Codec-Data", &rx_codec_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Media-Sub-Component", &rx_media_sub_component);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Number", &rx_flow_number);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Usage", &rx_flow_usage);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Flow-Description", &rx_flow_description);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id", &rx_subscription_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Type", &rx_subscription_id_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Id-Data", &rx_subscription_id_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Specific-Action", &rx_specific_action);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IP-Address", &rx_framed_ip_address);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Framed-IPv6-Prefix", &rx_framed_ipv6_prefix);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "IP-CAN-Type", &rx_ip_can_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &rx_rat_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Abort-Cause", &rx_abort_cause);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Termination-Cause", &rx_termination_cause);
return 0;
}

View File

@ -1,131 +0,0 @@
/*
* 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 RX_DICT_H
#define RX_DICT_H
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#ifdef __cplusplus
extern "C" {
#endif
#define RX_APPLICATION_ID 16777236
#define RX_AVP_CODE_SUBSCRIPTION_ID (443)
#define RX_AVP_CODE_SPECIFIC_ACTION (513)
#define RX_AVP_CODE_MEDIA_COMPONENT_DESCRIPTION (517)
#define RX_AVP_CODE_MEDIA_TYPE (520)
#define RX_AVP_CODE_MAX_REQUESTED_BANDWIDTH_DL (515)
#define RX_AVP_CODE_MAX_REQUESTED_BANDWIDTH_UL (516)
#define RX_AVP_CODE_RR_BANDWIDTH (521)
#define RX_AVP_CODE_RS_BANDWIDTH (522)
#define RX_AVP_CODE_MIN_REQUESTED_BANDWIDTH_DL (534)
#define RX_AVP_CODE_MIN_REQUESTED_BANDWIDTH_UL (535)
#define RX_AVP_CODE_MEDIA_COMPONENT_NUMBER (518)
#define RX_AVP_CODE_MEDIA_SUB_COMPONENT (519)
#define RX_AVP_CODE_FLOW_DESCRIPTION (507)
#define RX_AVP_CODE_FLOW_NUMBER (509)
#define RX_AVP_CODE_FLOW_USAGE (512)
extern struct dict_object *rx_application;
extern struct dict_object *rx_cmd_aar;
extern struct dict_object *rx_cmd_aaa;
extern struct dict_object *rx_cmd_asr;
extern struct dict_object *rx_cmd_asa;
extern struct dict_object *rx_cmd_str;
extern struct dict_object *rx_cmd_sta;
extern struct dict_object *rx_media_component_description;
extern struct dict_object *rx_media_component_number;
extern struct dict_object *rx_media_type;
extern struct dict_object *rx_max_requested_bandwidth_ul;
extern struct dict_object *rx_max_requested_bandwidth_dl;
extern struct dict_object *rx_min_requested_bandwidth_ul;
extern struct dict_object *rx_min_requested_bandwidth_dl;
extern struct dict_object *rx_rr_bandwidth;
extern struct dict_object *rx_rs_bandwidth;
#define RX_FLOW_STATUS_ENABLED_UPLINK 0
#define RX_FLOW_STATUS_ENABLED_DOWNLINK 1
#define RX_FLOW_STATUS_ENABLED 2
#define RX_FLOW_STATUS_DISABLED 3
extern struct dict_object *rx_flow_status;
extern struct dict_object *rx_codec_data;
extern struct dict_object *rx_media_sub_component;
extern struct dict_object *rx_flow_number;
extern struct dict_object *rx_flow_usage;
extern struct dict_object *rx_flow_description;
extern struct dict_object *rx_subscription_id;
#define RX_SUBSCRIPTION_ID_TYPE_END_USER_E164 0
#define RX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI 1
#define RX_SUBSCRIPTION_ID_TYPE_END_USER_SIP_URI 2
#define RX_SUBSCRIPTION_ID_TYPE_END_USER_NAI 3
extern struct dict_object *rx_subscription_id_type;
extern struct dict_object *rx_subscription_id_data;
extern struct dict_object *rx_specific_action;
extern struct dict_object *rx_framed_ip_address;
extern struct dict_object *rx_framed_ipv6_prefix;
#define RX_IP_CAN_TYPE_3GPP_GPRS 0
#define RX_IP_CAN_TYPE_DOCSIS 1
#define RX_IP_CAN_TYPE_xDSL 2
#define RX_IP_CAN_TYPE_WiMAX 3
#define RX_IP_CAN_TYPE_3GPP2 4
#define RX_IP_CAN_TYPE_3GPP_EPS 5
#define RX_IP_CAN_TYPE_Non_3GPP_EPS 6
extern struct dict_object *rx_ip_can_type;
#define RX_RAT_TYPE_WLAN 0
#define RX_RAT_TYPE_VIRTUAL 1
#define RX_RAT_TYPE_UTRAN 1000
#define RX_RAT_TYPE_GERAN 1001
#define RX_RAT_TYPE_GAN 1002
#define RX_RAT_TYPE_HSPA_EVOLUTION 1003
#define RX_RAT_TYPE_EUTRAN 1004
#define RX_RAT_TYPE_EUTRAN_NB_IoT 1005
#define RX_RAT_TYPE_CDMA2000_1X 2000
#define RX_RAT_TYPE_HRPD 2001
#define RX_RAT_TYPE_UMB 2002
#define RX_RAT_TYPE_EHRPD 2003
extern struct dict_object *rx_rat_type;
#define RX_ABORT_CAUSE_BEARER_RELEASED 0
#define RX_ABORT_CAUSE_INSUFFICIENT_SERVER_RESOURCES 1
#define RX_ABORT_CAUSE_INSUFFICIENT_BEARER_RESOURCES 2
#define RX_ABORT_CAUSE_PS_TO_CS_HANDOVER 3
#define RX_ABORT_CAUSE_SPONSORED_DATA_CONNECTIVITY_ DISALLOWED 4
extern struct dict_object *rx_abort_cause;
#define RX_TERMINATION_CAUSE_DIAMETER_LOGOUT 1
#define RX_TERMINATION_CAUSE_DIAMETER_SERVICE_NOT_PROVIDED 2
#define RX_TERMINATION_CAUSE_DIAMETER_BAD_ANSWER 3
#define RX_TERMINATION_CAUSE_DIAMETER_DIAMETER_ADMINISTRATIVE 4
#define RX_TERMINATION_CAUSE_DIAMETER_LINK_BROKEN 5
#define RX_TERMINATION_CAUSE_DIAMETER_AUTH_EXPIRED 6
#define RX_TERMINATION_CAUSE_DIAMETER_USER_MOVED 7
#define RX_TERMINATION_CAUSE_DIAMETER_SESSION_TIMEOUT 8
extern struct dict_object *rx_termination_cause;
int rx_dict_init(void);
#ifdef __cplusplus
}
#endif
#endif /* RX_DICT_H */

View File

@ -1,90 +0,0 @@
/*
* 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 RX_MESSAGE_H
#define RX_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "base/types.h"
typedef struct _rx_media_sub_component_t {
uint32_t flow_number;
#define RX_FLOW_USAGE_NO_INFORMATION 0
#define RX_FLOW_USAGE_RTCP 1
#define RX_FLOW_USAGE_AF_SIGNALLING 2
uint32_t flow_usage;
flow_t flow[MAX_NUM_OF_FLOW];
int num_of_flow;
} rx_media_sub_component_t;
typedef struct _rx_media_component_t {
uint32_t media_component_number;
#define RX_MEDIA_TYPE_AUDIO 0
#define RX_MEDIA_TYPE_VIDEO 1
#define RX_MEDIA_TYPE_DATA 2
#define RX_MEDIA_TYPE_APPLICATION 3
#define RX_MEDIA_TYPE_CONTROL 4
#define RX_MEDIA_TYPE_TEXT 5
#define RX_MEDIA_TYPE_MESSAGE 6
#define RX_MEDIA_TYPE_OTHER 0xFFFFFFFF
uint32_t media_type;
uint64_t max_requested_bandwidth_dl;
uint64_t max_requested_bandwidth_ul;
uint64_t min_requested_bandwidth_dl;
uint64_t min_requested_bandwidth_ul;
uint64_t rr_bandwidth;
uint64_t rs_bandwidth;
#define MAX_NUM_OF_MEDIA_SUB_COMPONENT 8
rx_media_sub_component_t sub[MAX_NUM_OF_MEDIA_SUB_COMPONENT];
int num_of_sub;
} rx_media_component_t;
typedef struct _rx_message_t {
#define RX_CMD_CODE_AA 265
#define RX_CMD_CODE_SESSION_TERMINATION 275
uint16_t cmd_code;
/* Experimental-Result-Codes */
#define RX_DIAMETER_INVALID_SERVICE_INFORMATION 5061
#define RX_DIAMETER_FILTER_RESTRICTIONS 5062
#define RX_DIAMETER_REQUESTED_SERVICE_NOT_AUTHORIZED 5063
#define RX_DIAMETER_DUPLICATED_AF_SESSION 5064
#define RX_DIAMETER_IP_CAN_SESSION_NOT_AVAILABLE 5065
#define RX_DIAMETER_UNAUTHORIZED_NON_EMERGENCY_SESSION 5066
#define RX_DIAMETER_UNAUTHORIZED_SPONSORED_DATA_CONNECTIVITY 5067
#define RX_DIAMETER_TEMPORARY_NETWORK_FAILURE 5068
uint32_t result_code;
#define MAX_NUM_OF_MEDIA_COMPONENT 16
rx_media_component_t media_component[MAX_NUM_OF_MEDIA_COMPONENT];
int num_of_media_component;
} rx_message_t;
void rx_message_free(rx_message_t *rx_message);
#ifdef __cplusplus
}
#endif
#endif /* RX_MESSAGE_H */

View File

@ -1,125 +0,0 @@
/*
* 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/>.
*/
#include "s6a-dict.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
struct dict_object *s6a_application = NULL;
struct dict_object *s6a_cmd_air = NULL;
struct dict_object *s6a_cmd_aia = NULL;
struct dict_object *s6a_cmd_ulr = NULL;
struct dict_object *s6a_cmd_ula = NULL;
struct dict_object *s6a_cmd_pur = NULL;
struct dict_object *s6a_cmd_pua = NULL;
struct dict_object *s6a_visited_plmn_id = NULL;
struct dict_object *s6a_rat_type = NULL;
struct dict_object *s6a_ulr_flags = NULL;
struct dict_object *s6a_ula_flags = NULL;
struct dict_object *s6a_subscription_data = NULL;
struct dict_object *s6a_req_eutran_auth_info = NULL;
struct dict_object *s6a_number_of_requested_vectors = NULL;
struct dict_object *s6a_immediate_response_preferred = NULL;
struct dict_object *s6a_authentication_info = NULL;
struct dict_object *s6a_re_synchronization_info = NULL;
struct dict_object *s6a_service_selection = NULL;
struct dict_object *s6a_ue_srvcc_capability = NULL;
struct dict_object *s6a_e_utran_vector = NULL;
struct dict_object *s6a_rand = NULL;
struct dict_object *s6a_xres = NULL;
struct dict_object *s6a_autn = NULL;
struct dict_object *s6a_kasme = NULL;
struct dict_object *s6a_subscriber_status = NULL;
struct dict_object *s6a_ambr = NULL;
struct dict_object *s6a_network_access_mode = NULL;
struct dict_object *s6a_access_restriction_data = NULL;
struct dict_object *s6a_apn_configuration_profile = NULL;
struct dict_object *s6a_subscribed_rau_tau_timer = NULL;
struct dict_object *s6a_context_identifier = NULL;
struct dict_object *s6a_all_apn_configuration_included_indicator = NULL;
struct dict_object *s6a_apn_configuration = NULL;
struct dict_object *s6a_max_bandwidth_ul = NULL;
struct dict_object *s6a_max_bandwidth_dl = NULL;
struct dict_object *s6a_pdn_type = NULL;
struct dict_object *s6a_eps_subscribed_qos_profile = NULL;
struct dict_object *s6a_qos_class_identifier = NULL;
struct dict_object *s6a_allocation_retention_priority = NULL;
struct dict_object *s6a_priority_level = NULL;
struct dict_object *s6a_pre_emption_capability = NULL;
struct dict_object *s6a_pre_emption_vulnerability = NULL;
int s6a_dict_init(void)
{
application_id_t id = S6A_APPLICATION_ID;
CHECK_dict_search(DICT_APPLICATION, APPLICATION_BY_ID, (void *)&id, &s6a_application);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Authentication-Information-Request", &s6a_cmd_air);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Authentication-Information-Answer", &s6a_cmd_aia);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Update-Location-Request", &s6a_cmd_ulr);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Update-Location-Answer", &s6a_cmd_ula);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Request", &s6a_cmd_pur);
CHECK_dict_search(DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Answer", &s6a_cmd_pua);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Visited-PLMN-Id", &s6a_visited_plmn_id);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &s6a_rat_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULR-Flags", &s6a_ulr_flags);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULA-Flags", &s6a_ula_flags);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "UE-SRVCC-Capability", &s6a_ue_srvcc_capability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info", &s6a_req_eutran_auth_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Number-Of-Requested-Vectors", &s6a_number_of_requested_vectors);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Immediate-Response-Preferred", &s6a_immediate_response_preferred);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Re-Synchronization-Info", &s6a_re_synchronization_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Authentication-Info", &s6a_authentication_info);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "E-UTRAN-Vector", &s6a_e_utran_vector);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAND", &s6a_rand);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "XRES", &s6a_xres);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AUTN", &s6a_autn);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "KASME", &s6a_kasme);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "EPS-Subscribed-QoS-Profile", &s6a_eps_subscribed_qos_profile);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier", &s6a_qos_class_identifier);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority", &s6a_allocation_retention_priority);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Priority-Level", &s6a_priority_level);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability", &s6a_pre_emption_capability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability", &s6a_pre_emption_vulnerability);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "AMBR", &s6a_ambr);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL", &s6a_max_bandwidth_ul);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL", &s6a_max_bandwidth_dl);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Configuration-Profile", &s6a_apn_configuration_profile);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Context-Identifier", &s6a_context_identifier);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "All-APN-Configurations-Included-Indicator", &s6a_all_apn_configuration_included_indicator);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "APN-Configuration", &s6a_apn_configuration);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Selection", &s6a_service_selection);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "PDN-Type", &s6a_pdn_type);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Data", &s6a_subscription_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscriber-Status", &s6a_subscriber_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Network-Access-Mode", &s6a_network_access_mode);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Access-Restriction-Data", &s6a_access_restriction_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscribed-Periodic-RAU-TAU-Timer", &s6a_subscribed_rau_tau_timer);
return 0;
}

View File

@ -1,112 +0,0 @@
/*
* 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 S6A_DICT_H
#define S6A_DICT_H
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#ifdef __cplusplus
extern "C" {
#endif
#define S6A_APPLICATION_ID 16777251
#define S6A_AVP_CODE_CONTEXT_IDENTIFIER (1423)
#define S6A_AVP_CODE_ALL_APN_CONFIG_INC_IND (1428)
#define S6A_AVP_CODE_APN_CONFIGURATION (1430)
#define S6A_AVP_CODE_MIP_HOME_AGENT_ADDRESS (334)
#define S6A_RAT_TYPE_WLAN 0
#define S6A_RAT_TYPE_VIRTUAL 1
#define S6A_RAT_TYPE_UTRAN 1000
#define S6A_RAT_TYPE_GERAN 1001
#define S6A_RAT_TYPE_GAN 1002
#define S6A_RAT_TYPE_HSPA_EVOLUTION 1003
#define S6A_RAT_TYPE_EUTRAN 1004
#define S6A_RAT_TYPE_EUTRAN_NB_IOT 1005
#define S6A_RAT_TYPE_CDMA2000_1X 2000
#define S6A_RAT_TYPE_HRPD 2001
#define S6A_RAT_TYPE_UMB 2002
#define S6A_RAT_TYPE_EHRPD 2003
#define S6A_ULR_SINGLE_REGISTRATION_IND (1)
#define S6A_ULR_S6A_S6D_INDICATOR (1 << 1)
#define S6A_ULR_SKIP_SUBSCRIBER_DATA (1 << 2)
#define S6A_ULR_GPRS_SUBSCRIPTION_DATA_IND (1 << 3)
#define S6A_ULR_NODE_TYPE_IND (1 << 4)
#define S6A_ULR_INITIAL_ATTACH_IND (1 << 5)
#define S6A_ULR_PS_LCS_SUPPORTED_BY_UE (1 << 6)
#define S6A_UE_SRVCC_NOT_SUPPORTED (0)
#define S6A_UE_SRVCC_SUPPORTED (1)
extern struct dict_object *s6a_application;
extern struct dict_object *s6a_cmd_air;
extern struct dict_object *s6a_cmd_aia;
extern struct dict_object *s6a_cmd_ulr;
extern struct dict_object *s6a_cmd_ula;
extern struct dict_object *s6a_cmd_pur;
extern struct dict_object *s6a_cmd_pua;
extern struct dict_object *s6a_visited_plmn_id;
extern struct dict_object *s6a_rat_type;
extern struct dict_object *s6a_ulr_flags;
extern struct dict_object *s6a_ula_flags;
extern struct dict_object *s6a_subscription_data;
extern struct dict_object *s6a_req_eutran_auth_info;
extern struct dict_object *s6a_number_of_requested_vectors;
extern struct dict_object *s6a_immediate_response_preferred;
extern struct dict_object *s6a_authentication_info;
extern struct dict_object *s6a_re_synchronization_info;
extern struct dict_object *s6a_service_selection;
extern struct dict_object *s6a_ue_srvcc_capability;
extern struct dict_object *s6a_e_utran_vector;
extern struct dict_object *s6a_rand;
extern struct dict_object *s6a_xres;
extern struct dict_object *s6a_autn;
extern struct dict_object *s6a_kasme;
extern struct dict_object *s6a_subscriber_status;
extern struct dict_object *s6a_ambr;
extern struct dict_object *s6a_network_access_mode;
extern struct dict_object *s6a_access_restriction_data;
extern struct dict_object *s6a_apn_configuration_profile;
extern struct dict_object *s6a_subscribed_rau_tau_timer;
extern struct dict_object *s6a_context_identifier;
extern struct dict_object *s6a_all_apn_configuration_included_indicator;
extern struct dict_object *s6a_apn_configuration;
extern struct dict_object *s6a_max_bandwidth_ul;
extern struct dict_object *s6a_max_bandwidth_dl;
extern struct dict_object *s6a_pdn_type;
extern struct dict_object *s6a_eps_subscribed_qos_profile;
extern struct dict_object *s6a_qos_class_identifier;
extern struct dict_object *s6a_allocation_retention_priority;
extern struct dict_object *s6a_priority_level;
extern struct dict_object *s6a_pre_emption_capability;
extern struct dict_object *s6a_pre_emption_vulnerability;
int s6a_dict_init(void);
#ifdef __cplusplus
}
#endif
#endif /* S6A_DICT_H */

View File

@ -1,100 +0,0 @@
/*
* 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 S6A_MESSAGE_H
#define S6A_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "ogs-crypt.h"
#include "base/types.h"
typedef struct _e_utran_vector_t {
uint8_t xres[MAX_RES_LEN];
uint8_t xres_len;
uint8_t kasme[OGS_SHA256_DIGEST_SIZE];
uint8_t rand[RAND_LEN];
uint8_t autn[AUTN_LEN];
} e_utran_vector_t;
typedef struct _s6a_aia_message_t {
e_utran_vector_t e_utran_vector;
} s6a_aia_message_t;
typedef struct _s6a_subscription_data_t {
#define HSS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1)
#define HSS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1)
#define HSS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2)
#define HSS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3)
#define HSS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4)
#define HSS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5)
#define HSS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6)
uint32_t access_restriction_data;
#define HSS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0
#define HSS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1
uint32_t subscriber_status;
#define HSS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0
#define HSS_NETWORK_ACCESS_MODE_RESERVED 1
#define HSS_NETWORK_ACCESS_MODE_ONLY_PACKET 2
uint32_t network_access_mode;
bitrate_t ambr; /* UE-AMBR */
#define HSS_RAU_TAU_DEFAULT_TIME (12*60) /* 12 min */
uint32_t subscribed_rau_tau_timer; /* unit : seconds */
uint32_t context_identifier; /* default APN */
pdn_t pdn[MAX_NUM_OF_SESS];
int num_of_pdn;
} s6a_subscription_data_t;
typedef struct _s6a_ula_message_t {
#define S6A_ULA_FLAGS_SEPARATION_INDICATION (0)
#define S6A_ULA_FLAGS_MME_REGISTERED_FOR_SMS (1)
uint32_t ula_flags;
s6a_subscription_data_t subscription_data;
} s6a_ula_message_t;
typedef struct _s6a_message_t {
#define S6A_CMD_CODE_UPDATE_LOCATION 316
#define S6A_CMD_CODE_AUTHENTICATION_INFORMATION 318
uint16_t cmd_code;
/* Experimental Result Code */
#define S6A_DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE 4181
#define S6A_DIAMETER_ERROR_USER_UNKNOWN 5001
#define S6A_DIAMETER_ERROR_ROAMING_NOT_ALLOWED 5004
#define S6A_DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION 5420
#define S6A_DIAMETER_ERROR_RAT_NOT_ALLOWED 5421
#define S6A_DIAMETER_ERROR_EQUIPMENT_UNKNOWN 5422
#define S6A_DIAMETER_ERROR_UNKOWN_SERVING_NODE 5423
uint32_t result_code;
s6a_aia_message_t aia_message;
s6a_ula_message_t ula_message;
} s6a_message_t;
#ifdef __cplusplus
}
#endif
#endif /* S6A_MESSAGE_H */

View File

@ -8,14 +8,14 @@ dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_INIT([nextepc], [1.2.1], [acetcom@gmail.com])
AC_INIT([ogs-freeDiameter], [1.2.1], [acetcom@gmail.com])
dnl Must come before AM_INIT_AUTOMAKE.
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign])
# Where to generate output; srcdir location.
AC_CONFIG_HEADERS([include/freeDiameter/config.h])
AC_CONFIG_HEADERS([include/freeDiameter/freeDiameter-config.h])
AC_CANONICAL_HOST
case $host in
*-freebsd*)

Some files were not shown because too many files have changed in this diff Show More