mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 15:24:14 +00:00
106 lines
2.7 KiB
C
106 lines
2.7 KiB
C
#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;
|
|
}
|