forked from acouzens/open5gs
update it
This commit is contained in:
parent
86d2ebd90c
commit
d499463df6
|
@ -5,10 +5,10 @@ SUBDIRS = freeDiameter
|
|||
noinst_LTLIBRARIES = libs6a.la
|
||||
|
||||
libs6a_la_SOURCES = \
|
||||
s6a_fd.h s6a_app.h
|
||||
s6a_app.h
|
||||
|
||||
nodist_libs6a_la_SOURCES = \
|
||||
s6a_fd_init.c s6a_fd_config.c \
|
||||
s6a_init.c s6a_fd.c s6a_config.c \
|
||||
s6a_app.c s6a_dict.c s6a_serv.c s6a_cli.c
|
||||
|
||||
libs6a_la_DEPENDENCIES = \
|
||||
|
|
|
@ -2,41 +2,20 @@
|
|||
|
||||
#include "s6a_app.h"
|
||||
|
||||
struct s6a_conf *s6a_conf = NULL;
|
||||
static struct s6a_conf _conf;
|
||||
static pthread_t s6a_stats_th = (pthread_t)NULL;
|
||||
|
||||
static int s6a_conf_init(void)
|
||||
{
|
||||
s6a_conf = &_conf;
|
||||
memset(s6a_conf, 0, sizeof(struct s6a_conf));
|
||||
|
||||
/* Set the default values */
|
||||
s6a_conf->vendor_id = 10415; /* 3GPP Vendor ID */
|
||||
s6a_conf->appli_id = 16777251; /* 3GPP S6A Application ID */
|
||||
s6a_conf->mode = MODE_SERV | MODE_CLI;
|
||||
s6a_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm);
|
||||
s6a_conf->dest_host = NULL;
|
||||
s6a_conf->user_name = strdup("01045238277");
|
||||
|
||||
/* Initialize the mutex */
|
||||
CHECK_POSIX( pthread_mutex_init(&s6a_conf->stats_lock, NULL) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void s6a_conf_dump(void)
|
||||
static void s6a_config_dump(void)
|
||||
{
|
||||
LOG_N( "------- s6a configuration dump: ---------");
|
||||
LOG_N( " Vendor Id .......... : %u", s6a_conf->vendor_id);
|
||||
LOG_N( " Application Id ..... : %u", s6a_conf->appli_id);
|
||||
LOG_N( " Vendor Id .......... : %u", s6a_config->vendor_id);
|
||||
LOG_N( " Application Id ..... : %u", s6a_config->appli_id);
|
||||
LOG_N( " Mode ............... : %s%s",
|
||||
s6a_conf->mode & MODE_SERV ? "Serv" : "",
|
||||
s6a_conf->mode & MODE_CLI ? "Cli" : "");
|
||||
s6a_config->mode & MODE_MME ? "MME" : "",
|
||||
s6a_config->mode & MODE_HSS ? "HSS" : "");
|
||||
LOG_N( " Destination Realm .. : %s",
|
||||
s6a_conf->dest_realm ?: "- none -");
|
||||
s6a_config->dest_realm ?: "- none -");
|
||||
LOG_N( " Destination Host ... : %s",
|
||||
s6a_conf->dest_host ?: "- none -");
|
||||
s6a_config->dest_host ?: "- none -");
|
||||
LOG_N( "------- /s6a configuration dump ---------");
|
||||
}
|
||||
|
||||
|
@ -55,9 +34,9 @@ static void * s6a_stats(void * arg) {
|
|||
sleep(10);
|
||||
|
||||
/* Now, get the current stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_conf->stats_lock), );
|
||||
memcpy(©, &s6a_conf->stats, sizeof(struct ta_stats));
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_conf->stats_lock), );
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_config->stats_lock), );
|
||||
memcpy(©, &s6a_config->stats, sizeof(struct ta_stats));
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_config->stats_lock), );
|
||||
|
||||
/* Get the current execution time */
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), );
|
||||
|
@ -74,11 +53,11 @@ static void * s6a_stats(void * arg) {
|
|||
(long)(now.tv_nsec + 1000000000 - start.tv_nsec) / 1000);
|
||||
}
|
||||
|
||||
if (s6a_conf->mode & MODE_SERV) {
|
||||
fd_log_debug( " Server: %llu message(s) echoed", copy.nb_echoed);
|
||||
if (s6a_config->mode & MODE_HSS) {
|
||||
fd_log_debug( " HSS: %llu message(s) echoed", copy.nb_echoed);
|
||||
}
|
||||
if (s6a_conf->mode & MODE_CLI) {
|
||||
fd_log_debug( " Client:");
|
||||
if (s6a_config->mode & MODE_MME) {
|
||||
fd_log_debug( " MME:");
|
||||
fd_log_debug( " %llu message(s) sent", copy.nb_sent);
|
||||
fd_log_debug( " %llu error(s) received", copy.nb_errs);
|
||||
fd_log_debug( " %llu answer(s) received", copy.nb_recv);
|
||||
|
@ -90,24 +69,24 @@ static void * s6a_stats(void * arg) {
|
|||
}
|
||||
|
||||
/* entry point */
|
||||
int s6a_app_init(void)
|
||||
int s6a_app_init(int mode)
|
||||
{
|
||||
/* Initialize configuration */
|
||||
CHECK_FCT( s6a_conf_init() );
|
||||
/* Initialize the mutex */
|
||||
CHECK_POSIX( pthread_mutex_init(&s6a_config->stats_lock, NULL) );
|
||||
|
||||
s6a_conf_dump();
|
||||
s6a_config_dump();
|
||||
|
||||
/* Install objects definitions for this test application */
|
||||
CHECK_FCT( s6a_dict_init() );
|
||||
|
||||
/* Install the handlers for incoming messages */
|
||||
if (s6a_conf->mode & MODE_SERV) {
|
||||
CHECK_FCT( s6a_serv_init() );
|
||||
/* Start the signal handler thread */
|
||||
if (s6a_config->mode & MODE_MME) {
|
||||
CHECK_FCT( s6a_cli_init() );
|
||||
}
|
||||
|
||||
/* Start the signal handler thread */
|
||||
if (s6a_conf->mode & MODE_CLI) {
|
||||
CHECK_FCT( s6a_cli_init() );
|
||||
/* Install the handlers for incoming messages */
|
||||
if (s6a_config->mode & MODE_HSS) {
|
||||
CHECK_FCT( s6a_serv_init() );
|
||||
}
|
||||
|
||||
/* Advertise the support for the test application in the peer */
|
||||
|
@ -122,11 +101,11 @@ int s6a_app_init(void)
|
|||
/* Unload */
|
||||
void s6a_app_final(void)
|
||||
{
|
||||
if (s6a_conf->mode & MODE_CLI)
|
||||
if (s6a_config->mode & MODE_MME)
|
||||
s6a_cli_fini();
|
||||
if (s6a_conf->mode & MODE_SERV)
|
||||
if (s6a_config->mode & MODE_HSS)
|
||||
s6a_serv_fini();
|
||||
|
||||
CHECK_FCT_DO( fd_thr_term(&s6a_stats_th), );
|
||||
CHECK_POSIX_DO( pthread_mutex_destroy(&s6a_conf->stats_lock), );
|
||||
CHECK_POSIX_DO( pthread_mutex_destroy(&s6a_config->stats_lock), );
|
||||
}
|
||||
|
|
|
@ -12,11 +12,25 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
/* Mode for the extension */
|
||||
#define MODE_SERV 0x1
|
||||
#define MODE_CLI 0x2
|
||||
#define MODE_MME 0x1
|
||||
#define MODE_HSS 0x2
|
||||
|
||||
/* The module configuration */
|
||||
struct s6a_conf {
|
||||
struct s6a_config_t {
|
||||
/* 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. */
|
||||
|
||||
c_uint32_t vendor_id; /* default 999999 */
|
||||
c_uint32_t appli_id; /* default 123456 */
|
||||
int mode; /* default MODE_SERV | MODE_CLI */
|
||||
|
@ -29,9 +43,11 @@ struct s6a_conf {
|
|||
c_uint64_t nb_recv; /* client */
|
||||
c_uint64_t nb_errs; /* client */
|
||||
} stats;
|
||||
pthread_mutex_t stats_lock;
|
||||
|
||||
pthread_mutex_t stats_lock;
|
||||
};
|
||||
extern struct s6a_conf *s6a_conf;
|
||||
|
||||
extern struct s6a_config_t *s6a_config;
|
||||
|
||||
/* Some global variables for dictionary */
|
||||
extern struct dict_object *s6a_vendor;
|
||||
|
@ -109,7 +125,17 @@ extern struct dict_object *s6a_pre_emption_capability;
|
|||
extern struct dict_object *s6a_pre_emption_vulnerability;
|
||||
extern struct dict_object *s6a_served_party_ip_addr;
|
||||
|
||||
CORE_DECLARE(int) s6a_app_init(void);
|
||||
CORE_DECLARE(int) s6a_init(void);
|
||||
CORE_DECLARE(void) s6a_final(void);
|
||||
|
||||
CORE_DECLARE(int) s6a_fd_init(const char *conffile);
|
||||
CORE_DECLARE(void) s6a_fd_final();
|
||||
|
||||
CORE_DECLARE(char *) s6a_hss_config();
|
||||
CORE_DECLARE(char *) s6a_mme_config();
|
||||
CORE_DECLARE(status_t) s6a_config_apply();
|
||||
|
||||
CORE_DECLARE(int) s6a_app_init(int mode);
|
||||
CORE_DECLARE(void) s6a_app_final(void);
|
||||
|
||||
CORE_DECLARE(int) s6a_dict_init(void);
|
||||
|
|
|
@ -89,16 +89,16 @@ static void s6a_aia_cb(void * data, struct msg ** msg)
|
|||
error++;
|
||||
}
|
||||
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_conf->stats_lock), );
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_config->stats_lock), );
|
||||
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) +
|
||||
((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
if (error)
|
||||
s6a_conf->stats.nb_errs++;
|
||||
s6a_config->stats.nb_errs++;
|
||||
else
|
||||
s6a_conf->stats.nb_recv++;
|
||||
s6a_config->stats.nb_recv++;
|
||||
|
||||
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_conf->stats_lock), );
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_config->stats_lock), );
|
||||
|
||||
/* Display how long it took */
|
||||
if (ts.tv_nsec > mi->ts.tv_nsec) {
|
||||
|
@ -152,19 +152,19 @@ void s6a_cli_test_message()
|
|||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( s6a_destination_realm, 0, &avp ),
|
||||
goto out );
|
||||
val.os.data = (unsigned char *)(s6a_conf->dest_realm);
|
||||
val.os.len = strlen(s6a_conf->dest_realm);
|
||||
val.os.data = (unsigned char *)(s6a_config->dest_realm);
|
||||
val.os.len = strlen(s6a_config->dest_realm);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ),
|
||||
goto out );
|
||||
}
|
||||
|
||||
/* Set the Destination-Host AVP if needed*/
|
||||
if (s6a_conf->dest_host) {
|
||||
if (s6a_config->dest_host) {
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( s6a_destination_host, 0, &avp ),
|
||||
goto out );
|
||||
val.os.data = (unsigned char *)(s6a_conf->dest_host);
|
||||
val.os.len = strlen(s6a_conf->dest_host);
|
||||
val.os.data = (unsigned char *)(s6a_config->dest_host);
|
||||
val.os.len = strlen(s6a_config->dest_host);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ),
|
||||
goto out );
|
||||
|
@ -174,10 +174,10 @@ void s6a_cli_test_message()
|
|||
CHECK_FCT_DO( fd_msg_add_origin ( req, 0 ), goto out );
|
||||
|
||||
/* Set the User-Name AVP if needed*/
|
||||
if (s6a_conf->user_name) {
|
||||
if (s6a_config->user_name) {
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( s6a_user_name, 0, &avp ), goto out );
|
||||
val.os.data = (unsigned char *)(s6a_conf->user_name);
|
||||
val.os.len = strlen(s6a_conf->user_name);
|
||||
val.os.data = (unsigned char *)(s6a_config->user_name);
|
||||
val.os.len = strlen(s6a_config->user_name);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ),
|
||||
goto out );
|
||||
|
@ -215,15 +215,15 @@ void s6a_cli_test_message()
|
|||
|
||||
/* Log sending the message */
|
||||
d_info("SEND %x to '%s' (%s)\n", svg->randval,
|
||||
s6a_conf->dest_realm, s6a_conf->dest_host?:"-" );
|
||||
s6a_config->dest_realm, s6a_config->dest_host?:"-" );
|
||||
|
||||
/* Send the request */
|
||||
CHECK_FCT_DO( fd_msg_send( &req, s6a_aia_cb, svg ), goto out );
|
||||
|
||||
/* Increment the counter */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_conf->stats_lock), );
|
||||
s6a_conf->stats.nb_sent++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_conf->stats_lock), );
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_config->stats_lock), );
|
||||
s6a_config->stats.nb_sent++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_config->stats_lock), );
|
||||
|
||||
out:
|
||||
return;
|
||||
|
@ -233,14 +233,14 @@ int s6a_cli_init(void)
|
|||
{
|
||||
CHECK_FCT( fd_sess_handler_create(&s6a_cli_reg, (void *)free, NULL, NULL) );
|
||||
|
||||
// CHECK_FCT( fd_event_trig_regcb(s6a_conf->signal, "test_app.cli", s6a_cli_test_message ) );
|
||||
// CHECK_FCT( fd_event_trig_regcb(s6a_config->signal, "test_app.cli", s6a_cli_test_message ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void s6a_cli_fini(void)
|
||||
{
|
||||
// CHECK_FCT_DO( fd_sig_unregister(s6a_conf->signal), /* continue */ );
|
||||
// CHECK_FCT_DO( fd_sig_unregister(s6a_config->signal), /* continue */ );
|
||||
|
||||
CHECK_FCT_DO( fd_sess_handler_destroy(&s6a_cli_reg, NULL), /* continue */ );
|
||||
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
#define TRACE_MODULE _s6a_fd_conf
|
||||
#define TRACE_MODULE _s6a_config
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
#include "core_file.h"
|
||||
|
||||
#include "s6a_fd.h"
|
||||
#include "s6a_app.h"
|
||||
|
||||
static struct s6a_fd_config_t g_conf;
|
||||
struct s6a_fd_config_t *s6a_fd_config;
|
||||
static struct s6a_config_t g_conf;
|
||||
struct s6a_config_t *s6a_config;
|
||||
|
||||
static char *s6a_fd_hss_conffile = SYSCONFDIR "hss_fd.conf";
|
||||
static char *s6a_fd_mme_conffile = SYSCONFDIR "mme_fd.conf";
|
||||
static char *s6a_hss_conffile = SYSCONFDIR "hss_fd.conf";
|
||||
static char *s6a_mme_conffile = SYSCONFDIR "mme_fd.conf";
|
||||
|
||||
static int s6a_fd_config_apply_internal()
|
||||
static int s6a_config_apply_internal()
|
||||
{
|
||||
struct peer_info fddpi;
|
||||
struct addrinfo hints, *ai;
|
||||
int ret;
|
||||
int disc = 0;
|
||||
|
||||
fd_g_config->cnf_diamid = s6a_fd_config->cnf_diamid;
|
||||
fd_g_config->cnf_diamid = s6a_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_g_config->cnf_diamrlm = s6a_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;
|
||||
if (s6a_config->cnf_port)
|
||||
fd_g_config->cnf_port = s6a_config->cnf_port;
|
||||
if (s6a_config->cnf_port_tls)
|
||||
fd_g_config->cnf_port_tls = s6a_config->cnf_port_tls;
|
||||
|
||||
memset(&fddpi, 0, sizeof(fddpi));
|
||||
fddpi.config.pic_flags.persist = PI_PRST_ALWAYS;
|
||||
|
@ -37,8 +37,8 @@ static int s6a_fd_config_apply_internal()
|
|||
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;
|
||||
fddpi.config.pic_port = s6a_config->pic_port;
|
||||
fddpi.pi_diamid = s6a_config->pi_diamid;
|
||||
|
||||
fd_list_init( &fddpi.pi_endpoints, NULL );
|
||||
|
||||
|
@ -57,12 +57,12 @@ static int s6a_fd_config_apply_internal()
|
|||
return 0;
|
||||
}
|
||||
|
||||
status_t s6a_fd_config_apply()
|
||||
status_t s6a_config_apply()
|
||||
{
|
||||
char * buf = NULL, *b;
|
||||
size_t len = 0;
|
||||
|
||||
CHECK_FCT( s6a_fd_config_apply_internal() );
|
||||
CHECK_FCT( s6a_config_apply_internal() );
|
||||
|
||||
/* The following module use data from the configuration */
|
||||
int fd_rtdisp_init(void);
|
||||
|
@ -81,31 +81,50 @@ status_t s6a_fd_config_apply()
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
#define HSS_IDENTITY "peer2.localdomain"
|
||||
#define HSS_IDENTITY "hss.localdomain"
|
||||
#define HSS_REALM "localdomain"
|
||||
#define HSS_PORT 30868
|
||||
#define HSS_SECURE_PORT 30869
|
||||
|
||||
#define MME_IDENTITY "peer1.localdomain"
|
||||
#define MME_IDENTITY "mme.localdomain"
|
||||
#define MME_REALM "localdomain"
|
||||
#define MME_PORT DIAMETER_PORT
|
||||
#define MME_SECURE_PORT DIAMETER_SECURE_PORT
|
||||
|
||||
char *s6a_fd_hss_config()
|
||||
static int s6a_common_config(void)
|
||||
{
|
||||
memset(&g_conf, 0, sizeof(struct s6a_config_t));
|
||||
s6a_config = &g_conf;
|
||||
|
||||
/* Set the default values */
|
||||
s6a_config->vendor_id = 10415; /* 3GPP Vendor ID */
|
||||
s6a_config->appli_id = 16777251; /* 3GPP S6A Application ID */
|
||||
s6a_config->mode = MODE_MME | MODE_HSS;
|
||||
#if 0
|
||||
s6a_config->dest_realm = strdup(fd_g_config->cnf_diamrlm);
|
||||
#else
|
||||
s6a_config->dest_realm = strdup(MME_REALM);
|
||||
#endif
|
||||
s6a_config->dest_host = NULL;
|
||||
s6a_config->user_name = strdup("01045238277");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *s6a_hss_config()
|
||||
{
|
||||
status_t rv;
|
||||
file_info_t file_info;
|
||||
char *conffile = s6a_fd_hss_conffile;
|
||||
|
||||
memset(&g_conf, 0, sizeof(struct s6a_fd_config_t));
|
||||
s6a_fd_config = &g_conf;
|
||||
char *conffile = s6a_hss_conffile;
|
||||
|
||||
s6a_fd_config->cnf_diamid = HSS_IDENTITY;
|
||||
s6a_fd_config->cnf_diamrlm = HSS_REALM;
|
||||
s6a_fd_config->cnf_port = HSS_PORT;
|
||||
s6a_fd_config->cnf_port_tls = HSS_SECURE_PORT;
|
||||
s6a_fd_config->pi_diamid = MME_IDENTITY;
|
||||
s6a_fd_config->pic_port = MME_PORT;
|
||||
s6a_common_config();
|
||||
|
||||
s6a_config->cnf_diamid = HSS_IDENTITY;
|
||||
s6a_config->cnf_diamrlm = HSS_REALM;
|
||||
s6a_config->cnf_port = HSS_PORT;
|
||||
s6a_config->cnf_port_tls = HSS_SECURE_PORT;
|
||||
s6a_config->pi_diamid = MME_IDENTITY;
|
||||
s6a_config->pic_port = MME_PORT;
|
||||
|
||||
rv = file_stat(&file_info, conffile, FILE_INFO_TYPE);
|
||||
if (rv == CORE_OK && file_info.filetype == FILE_REG)
|
||||
|
@ -116,19 +135,18 @@ char *s6a_fd_hss_config()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *s6a_fd_mme_config()
|
||||
char *s6a_mme_config()
|
||||
{
|
||||
status_t rv;
|
||||
file_info_t file_info;
|
||||
char *conffile = s6a_fd_mme_conffile;
|
||||
char *conffile = s6a_mme_conffile;
|
||||
|
||||
memset(&g_conf, 0, sizeof(struct s6a_fd_config_t));
|
||||
s6a_fd_config = &g_conf;
|
||||
s6a_common_config();
|
||||
|
||||
s6a_fd_config->cnf_diamid = MME_IDENTITY;
|
||||
s6a_fd_config->cnf_diamrlm = MME_REALM;
|
||||
s6a_fd_config->pi_diamid = HSS_IDENTITY;
|
||||
s6a_fd_config->pic_port = HSS_PORT;
|
||||
s6a_config->cnf_diamid = MME_IDENTITY;
|
||||
s6a_config->cnf_diamrlm = MME_REALM;
|
||||
s6a_config->pi_diamid = HSS_IDENTITY;
|
||||
s6a_config->pic_port = HSS_PORT;
|
||||
|
||||
rv = file_stat(&file_info, conffile, FILE_INFO_TYPE);
|
||||
if (rv == CORE_OK && file_info.filetype == FILE_REG)
|
|
@ -105,11 +105,11 @@ int s6a_dict_init(void)
|
|||
{
|
||||
CHECK_FCT(s6a_ext_load());
|
||||
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID,
|
||||
(void *)&s6a_conf->vendor_id, &s6a_vendor, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR,
|
||||
VENDOR_BY_ID, (void *)&s6a_config->vendor_id, &s6a_vendor, ENOENT));
|
||||
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_APPLICATION,
|
||||
APPLICATION_BY_ID, (void *)&s6a_conf->appli_id, &s6a_appli, ENOENT));
|
||||
APPLICATION_BY_ID, (void *)&s6a_config->appli_id, &s6a_appli, ENOENT));
|
||||
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME,
|
||||
"Authentication-Information-Request", &s6a_cmd_air, ENOENT));
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
#define TRACE_MODULE _s6a_init
|
||||
#define TRACE_MODULE _s6a_fd
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
#include "core_signal.h"
|
||||
#include "core_semaphore.h"
|
||||
|
||||
#include "s6a_fd.h"
|
||||
|
||||
static pid_t s6a_fd_hss_pid;
|
||||
#include "s6a_app.h"
|
||||
|
||||
static void s6a_gnutls_log_func(int level, const char *str);
|
||||
static void s6a_fd_logger(int printlevel, const char *format, va_list ap);
|
||||
|
||||
static int check_signal(int signum);
|
||||
|
||||
static int s6a_fd_init_internal(const char *conffile)
|
||||
int s6a_fd_init(const char *conffile)
|
||||
{
|
||||
int ret;
|
||||
|
||||
d_trace_level(&_s6a_init, 0);
|
||||
d_trace_level(&_s6a_fd, 0);
|
||||
|
||||
gnutls_global_set_log_function(s6a_gnutls_log_func);
|
||||
gnutls_global_set_log_level(TRACE_MODULE);
|
||||
|
@ -44,7 +40,7 @@ static int s6a_fd_init_internal(const char *conffile)
|
|||
}
|
||||
else
|
||||
{
|
||||
CHECK_FCT_DO( s6a_fd_config_apply(), goto error );
|
||||
CHECK_FCT_DO( s6a_config_apply(), goto error );
|
||||
}
|
||||
|
||||
/* Start the servers */
|
||||
|
@ -52,8 +48,6 @@ static int s6a_fd_init_internal(const char *conffile)
|
|||
|
||||
CHECK_FCT_DO( fd_core_waitstartcomplete(), goto error );
|
||||
|
||||
CHECK_FCT_DO( s6a_app_init(), goto error );
|
||||
|
||||
return 0;
|
||||
error:
|
||||
CHECK_FCT_DO( fd_core_shutdown(), );
|
||||
|
@ -62,58 +56,11 @@ error:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int s6a_fd_init()
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
semaphore_id semaphore;
|
||||
|
||||
rv = semaphore_create(&semaphore, 0);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_create() failed");
|
||||
|
||||
s6a_fd_hss_pid = fork();
|
||||
d_assert(s6a_fd_hss_pid >= 0, _exit(EXIT_FAILURE), "fork() failed");
|
||||
|
||||
if (s6a_fd_hss_pid == 0)
|
||||
{
|
||||
/* Child */
|
||||
rv = semaphore_wait(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_wait() failed");
|
||||
|
||||
rv = semaphore_delete(semaphore);
|
||||
d_assert(rv == CORE_OK, , "semaphore_delete() failed");
|
||||
|
||||
rv = s6a_fd_init_internal(s6a_fd_hss_config());
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "s6a_fd_init() failed");
|
||||
signal_thread(check_signal);
|
||||
s6a_fd_final();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
ret = s6a_fd_init_internal(s6a_fd_mme_config());
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("s6a_fd_init_internal() failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
rv = semaphore_post(semaphore);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_post() failed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void s6a_fd_final()
|
||||
{
|
||||
s6a_app_final();
|
||||
|
||||
CHECK_FCT_DO( fd_core_shutdown(), d_error("fd_core_shutdown() failed") );
|
||||
CHECK_FCT_DO( fd_core_wait_shutdown_complete(),
|
||||
d_error("fd_core_wait_shutdown_complete() failed"));
|
||||
|
||||
core_kill(s6a_fd_hss_pid, SIGTERM);
|
||||
}
|
||||
|
||||
static void s6a_gnutls_log_func(int level, const char *str)
|
||||
|
@ -161,31 +108,3 @@ static void s6a_fd_logger(int printlevel, const char *format, va_list ap)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int check_signal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
d_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
|
||||
return 1;
|
||||
}
|
||||
case SIGUSR1:
|
||||
{
|
||||
void s6a_cli_test_message();
|
||||
s6a_cli_test_message();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_error("Unknown signal number = %d\n", signum);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef __S6A_FD_H__
|
||||
#define __S6A_FD_H__
|
||||
|
||||
#include "core_errno.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct s6a_fd_config_t {
|
||||
/* 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(int) s6a_fd_init();
|
||||
CORE_DECLARE(void) s6a_fd_final();
|
||||
|
||||
CORE_DECLARE(char *) s6a_fd_hss_config();
|
||||
CORE_DECLARE(char *) s6a_fd_mme_config();
|
||||
CORE_DECLARE(status_t) s6a_fd_config_apply();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* ! __S6A_FD_H__ */
|
|
@ -0,0 +1,92 @@
|
|||
#define TRACE_MODULE _s6a_init
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
#include "core_signal.h"
|
||||
#include "core_semaphore.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
static pid_t s6a_hss_pid;
|
||||
|
||||
static int check_signal(int signum);
|
||||
|
||||
int s6a_init()
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
semaphore_id semaphore;
|
||||
|
||||
rv = semaphore_create(&semaphore, 0);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_create() failed");
|
||||
|
||||
s6a_hss_pid = fork();
|
||||
d_assert(s6a_hss_pid >= 0, _exit(EXIT_FAILURE), "fork() failed");
|
||||
|
||||
if (s6a_hss_pid == 0)
|
||||
{
|
||||
/* Child */
|
||||
rv = semaphore_wait(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_wait() failed");
|
||||
|
||||
rv = semaphore_delete(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_delete() failed");
|
||||
|
||||
CHECK_FCT_DO(s6a_fd_init(s6a_hss_config()),
|
||||
_exit(EXIT_FAILURE));
|
||||
|
||||
CHECK_FCT_DO(s6a_app_init(MODE_HSS), _exit(EXIT_FAILURE));
|
||||
|
||||
signal_thread(check_signal);
|
||||
s6a_final();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
CHECK_FCT_DO(s6a_fd_init(s6a_mme_config()), return -1);
|
||||
|
||||
CHECK_FCT_DO(s6a_app_init(MODE_MME), return -1);
|
||||
|
||||
rv = semaphore_post(semaphore);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_post() failed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void s6a_final()
|
||||
{
|
||||
s6a_app_final();
|
||||
|
||||
s6a_fd_final();
|
||||
|
||||
core_kill(s6a_hss_pid, SIGTERM);
|
||||
}
|
||||
|
||||
static int check_signal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
d_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
|
||||
return 1;
|
||||
}
|
||||
case SIGUSR1:
|
||||
{
|
||||
void s6a_cli_test_message();
|
||||
s6a_cli_test_message();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_error("Unknown signal number = %d\n", signum);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -45,7 +45,7 @@ static int s6a_air_cb( struct msg ** msg, struct avp * avp,
|
|||
}
|
||||
|
||||
/* Set the Test-Payload-AVP AVP */
|
||||
if (s6a_conf->long_avp_id) {
|
||||
if (s6a_config->long_avp_id) {
|
||||
struct avp * src = NULL;
|
||||
struct avp_hdr * hdr = NULL;
|
||||
|
||||
|
@ -66,9 +66,9 @@ static int s6a_air_cb( struct msg ** msg, struct avp * avp,
|
|||
CHECK_FCT( fd_msg_send( msg, NULL, NULL ) );
|
||||
|
||||
/* Add this value to the stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_conf->stats_lock), );
|
||||
s6a_conf->stats.nb_echoed++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_conf->stats_lock), );
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_config->stats_lock), );
|
||||
s6a_config->stats.nb_echoed++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_config->stats_lock), );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "core_thread.h"
|
||||
|
||||
#include "logger.h"
|
||||
#include "s6a_fd.h"
|
||||
#include "s6a_app.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "event.h"
|
||||
|
@ -39,7 +39,7 @@ status_t cellwire_initialize(char *config_path, char *log_path)
|
|||
rv = context_init();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
ret = s6a_fd_init();
|
||||
ret = s6a_init();
|
||||
if (ret != 0) return CORE_ERROR;
|
||||
|
||||
return CORE_OK;
|
||||
|
@ -47,7 +47,7 @@ status_t cellwire_initialize(char *config_path, char *log_path)
|
|||
|
||||
void cellwire_terminate(void)
|
||||
{
|
||||
s6a_fd_final();
|
||||
s6a_final();
|
||||
context_final();
|
||||
core_terminate();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue