forked from acouzens/open5gs
update it
This commit is contained in:
parent
ff8d1eb91c
commit
6a613d2544
|
@ -8,8 +8,8 @@ libs6a_la_SOURCES = \
|
|||
s6a_app.h
|
||||
|
||||
nodist_libs6a_la_SOURCES = \
|
||||
s6a_init.c s6a_app.c s6a_config.c \
|
||||
s6a_dict.c s6a_server.c s6a_client.c
|
||||
s6a_fd_init.c s6a_fd_config.c \
|
||||
s6a_app.c s6a_dict.c s6a_server.c s6a_client.c
|
||||
|
||||
libs6a_la_DEPENDENCIES = \
|
||||
$(top_srcdir)/lib/s6a/freeDiameter/libs6afreeDiameter.la
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
#define TRACE_MODULE _s6a_conf
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
#include "freeDiameter/freeDiameter-host.h"
|
||||
#include "freeDiameter/libfdcore.h"
|
||||
|
||||
#if 0
|
||||
/* The validator function */
|
||||
static int aw_validate(struct peer_info * info, int * auth, int (**cb2)(struct peer_info *))
|
||||
{
|
||||
/* We don't use the second callback */
|
||||
*cb2 = NULL;
|
||||
|
||||
/* Default to unknown result */
|
||||
*auth = 1;
|
||||
|
||||
info->config.pic_flags.sec = PI_SEC_NONE;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int s6a_conf_parse(int hss)
|
||||
{
|
||||
struct peer_info fddpi;
|
||||
struct addrinfo hints, *ai;
|
||||
int ret;
|
||||
int disc = 0;
|
||||
|
||||
#if 0
|
||||
fd_peer_validate_register(aw_validate);
|
||||
#endif
|
||||
|
||||
/* Resolve hostname if not provided */
|
||||
if (hss)
|
||||
{
|
||||
fd_g_config->cnf_diamid = "peer2.localdomain";
|
||||
fd_g_config->cnf_port = 30868;
|
||||
fd_g_config->cnf_port_tls = 30869;
|
||||
}
|
||||
else
|
||||
{
|
||||
fd_g_config->cnf_diamid = "peer1.localdomain";
|
||||
}
|
||||
fd_os_validate_DiameterIdentity(&fd_g_config->cnf_diamid, &fd_g_config->cnf_diamid_len, 1);
|
||||
|
||||
/* Handle the realm part */
|
||||
fd_g_config->cnf_diamrlm = "localdomain";
|
||||
fd_os_validate_DiameterIdentity(&fd_g_config->cnf_diamrlm, &fd_g_config->cnf_diamrlm_len, 1);
|
||||
|
||||
memset(&fddpi, 0, sizeof(fddpi));
|
||||
fddpi.config.pic_flags.persist = PI_PRST_ALWAYS;
|
||||
fddpi.config.pic_flags.pro3 = PI_P3_IP;
|
||||
fddpi.config.pic_flags.pro4 = PI_P4_TCP;
|
||||
fddpi.config.pic_flags.alg = PI_ALGPREF_TCP;
|
||||
fddpi.config.pic_flags.sec |= PI_SEC_NONE;
|
||||
if (hss)
|
||||
fddpi.config.pic_port = (uint16_t)3868;
|
||||
else
|
||||
fddpi.config.pic_port = (uint16_t)30868;
|
||||
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST;
|
||||
ret = getaddrinfo("127.0.0.1", NULL, &hints, &ai);
|
||||
if (ret) { return CORE_ERROR; }
|
||||
|
||||
fd_list_init( &fddpi.pi_endpoints, NULL );
|
||||
|
||||
if (hss)
|
||||
fddpi.pi_diamid = "peer1.localdomain";
|
||||
else
|
||||
fddpi.pi_diamid = "peer2.localdomain";
|
||||
fd_ep_add_merge( &fddpi.pi_endpoints, ai->ai_addr, ai->ai_addrlen, EP_FL_CONF | (disc ?: EP_ACCEPTALL) );
|
||||
fd_peer_add ( &fddpi, NULL, NULL, NULL );
|
||||
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t s6a_config_init(int hss)
|
||||
{
|
||||
char * buf = NULL, *b;
|
||||
size_t len = 0;
|
||||
|
||||
CHECK_FCT( s6a_conf_parse(hss) );
|
||||
|
||||
/* The following module use data from the configuration */
|
||||
int fd_rtdisp_init(void);
|
||||
fd_rtdisp_init();
|
||||
|
||||
/* Display configuration */
|
||||
b = fd_conf_dump(&buf, &len, NULL);
|
||||
LOG_SPLIT(FD_LOG_DEBUG, NULL, b ?: "<Error during configuration dump...>", NULL);
|
||||
free(buf);
|
||||
|
||||
/* Since some extensions might have modified the definitions from the dict_base_protocol, we only load the objects now */
|
||||
int fd_msg_init(void);
|
||||
fd_msg_init();
|
||||
|
||||
return CORE_OK;
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
#define TRACE_MODULE _s6a_fd_conf
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
#include "s6a_lib.h"
|
||||
|
||||
#include "freeDiameter/freeDiameter-host.h"
|
||||
#include "freeDiameter/libfdcore.h"
|
||||
|
||||
static struct s6a_fd_config_t g_conf;
|
||||
struct s6a_fd_config_t *s6a_fd_config;
|
||||
|
||||
static int s6a_conf_parse()
|
||||
{
|
||||
struct peer_info fddpi;
|
||||
struct addrinfo hints, *ai;
|
||||
int ret;
|
||||
int disc = 0;
|
||||
|
||||
fd_g_config->cnf_diamid = s6a_fd_config->cnf_diamid;
|
||||
fd_os_validate_DiameterIdentity(
|
||||
&fd_g_config->cnf_diamid, &fd_g_config->cnf_diamid_len, 1);
|
||||
fd_g_config->cnf_diamrlm = s6a_fd_config->cnf_diamrlm;
|
||||
fd_os_validate_DiameterIdentity(
|
||||
&fd_g_config->cnf_diamrlm, &fd_g_config->cnf_diamrlm_len, 1);
|
||||
if (s6a_fd_config->cnf_port)
|
||||
fd_g_config->cnf_port = s6a_fd_config->cnf_port;
|
||||
if (s6a_fd_config->cnf_port_tls)
|
||||
fd_g_config->cnf_port_tls = s6a_fd_config->cnf_port_tls;
|
||||
|
||||
memset(&fddpi, 0, sizeof(fddpi));
|
||||
fddpi.config.pic_flags.persist = PI_PRST_ALWAYS;
|
||||
fddpi.config.pic_flags.pro3 = PI_P3_IP;
|
||||
fddpi.config.pic_flags.pro4 = PI_P4_TCP;
|
||||
fddpi.config.pic_flags.alg = PI_ALGPREF_TCP;
|
||||
fddpi.config.pic_flags.sec |= PI_SEC_NONE;
|
||||
|
||||
fddpi.config.pic_port = s6a_fd_config->pic_port;
|
||||
fddpi.pi_diamid = s6a_fd_config->pi_diamid;
|
||||
|
||||
fd_list_init( &fddpi.pi_endpoints, NULL );
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST;
|
||||
ret = getaddrinfo("127.0.0.1", NULL, &hints, &ai);
|
||||
if (ret)
|
||||
return CORE_ERROR;
|
||||
|
||||
fd_ep_add_merge( &fddpi.pi_endpoints,
|
||||
ai->ai_addr, ai->ai_addrlen, EP_FL_CONF | (disc ?: EP_ACCEPTALL) );
|
||||
fd_peer_add ( &fddpi, NULL, NULL, NULL );
|
||||
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t s6a_default_fd_config()
|
||||
{
|
||||
char * buf = NULL, *b;
|
||||
size_t len = 0;
|
||||
|
||||
CHECK_FCT( s6a_conf_parse() );
|
||||
|
||||
/* The following module use data from the configuration */
|
||||
int fd_rtdisp_init(void);
|
||||
fd_rtdisp_init();
|
||||
|
||||
/* Display configuration */
|
||||
b = fd_conf_dump(&buf, &len, NULL);
|
||||
LOG_SPLIT(FD_LOG_DEBUG, NULL, b ?: "<Error during configuration dump...>", NULL);
|
||||
free(buf);
|
||||
|
||||
/* Since some extensions might have modified the definitions from the dict_base_protocol, we only load the objects now */
|
||||
int fd_msg_init(void);
|
||||
fd_msg_init();
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void s6a_fd_config_init()
|
||||
{
|
||||
memset(&g_conf, 0, sizeof(struct s6a_fd_config_t));
|
||||
s6a_fd_config = &g_conf;
|
||||
}
|
||||
|
||||
void s6a_fd_hss_config()
|
||||
{
|
||||
s6a_fd_config_init();
|
||||
|
||||
s6a_fd_config->cnf_diamid = "peer2.localdomain";
|
||||
s6a_fd_config->cnf_diamrlm = "localdomain";
|
||||
s6a_fd_config->cnf_port = 30868;
|
||||
s6a_fd_config->cnf_port_tls = 30869;
|
||||
s6a_fd_config->pi_diamid = "peer1.localdomain";
|
||||
s6a_fd_config->pic_port = (c_uint16_t)3868;
|
||||
}
|
||||
|
||||
void s6a_fd_mme_config()
|
||||
{
|
||||
s6a_fd_config_init();
|
||||
|
||||
s6a_fd_config->cnf_diamid = "peer1.localdomain";
|
||||
s6a_fd_config->cnf_diamrlm = "localdomain";
|
||||
s6a_fd_config->pi_diamid = "peer2.localdomain";
|
||||
s6a_fd_config->pic_port = (c_uint16_t)30868;
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
#include "core_lib.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
#include "s6a_lib.h"
|
||||
|
||||
#include "freeDiameter/freeDiameter-host.h"
|
||||
#include "freeDiameter/libfdcore.h"
|
||||
|
@ -12,7 +13,7 @@
|
|||
static void s6a_gnutls_log_func(int level, const char *str);
|
||||
static void s6a_fd_logger(int printlevel, const char *format, va_list ap);
|
||||
|
||||
status_t s6a_fd_init(int hss)
|
||||
status_t s6a_fd_init()
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -35,7 +36,7 @@ status_t s6a_fd_init(int hss)
|
|||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
ret = s6a_config_init(hss);
|
||||
ret = s6a_default_fd_config();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("s6a_config_init() failed");
|
||||
|
@ -66,6 +67,43 @@ status_t s6a_fd_init(int hss)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t s6a_fd_hss_init()
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
|
||||
s6a_fd_hss_config();
|
||||
rv = s6a_fd_init();
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("s6a_fd_init() failed");
|
||||
return rv;
|
||||
}
|
||||
ret = fd_core_wait_shutdown_complete();
|
||||
if (ret != 0)
|
||||
{
|
||||
return CORE_ERROR;
|
||||
d_error("fd_core_wait_shutdown_complete() failed");
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t s6a_fd_mme_init()
|
||||
{
|
||||
status_t rv;
|
||||
s6a_fd_mme_config();
|
||||
|
||||
rv = s6a_fd_init();
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("s6a_fd_init() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void s6a_fd_final()
|
||||
{
|
||||
int ret;
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef __S6A_LIB_H__
|
||||
#define __S6A_LIB_H__
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct s6a_fd_config_t {
|
||||
/* Configuration file to parse */
|
||||
const char *cnf_file;
|
||||
|
||||
/* Diameter Identity of the local peer (FQDN -- ASCII) */
|
||||
char *cnf_diamid;
|
||||
/* Diameter realm of the local peer, default to realm part of cnf_diamid */
|
||||
char *cnf_diamrlm;
|
||||
|
||||
/* the local port for legacy Diameter (default: 3868) in host byte order */
|
||||
c_uint16_t cnf_port;
|
||||
/* the local port for Diameter/TLS (default: 5658) in host byte order */
|
||||
c_uint16_t cnf_port_tls;
|
||||
|
||||
/* (supposedly) UTF-8, \0 terminated.
|
||||
* The Diameter Identity of the remote peer. */
|
||||
char *pi_diamid;
|
||||
c_uint16_t pic_port; /* port to connect to. 0: default. */
|
||||
|
||||
};
|
||||
|
||||
extern struct s6a_fd_config_t *s6a_fd_config;
|
||||
|
||||
CORE_DECLARE(status_t) s6a_fd_hss_init();
|
||||
CORE_DECLARE(status_t) s6a_fd_mme_init();
|
||||
CORE_DECLARE(void) s6a_fd_final();
|
||||
|
||||
CORE_DECLARE(status_t) s6a_default_fd_config();
|
||||
CORE_DECLARE(void) s6a_fd_config_init();
|
||||
CORE_DECLARE(void) s6a_fd_hss_config();
|
||||
CORE_DECLARE(void) s6a_fd_mme_config();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* ! __S6A_LIB_H__ */
|
Loading…
Reference in New Issue