initial integration for S6A diameter, but more work is needed
This commit is contained in:
parent
1c15591aa8
commit
fd9a173f49
|
@ -8,7 +8,8 @@ libs6a_la_SOURCES = \
|
|||
s6a_app.h
|
||||
|
||||
nodist_libs6a_la_SOURCES = \
|
||||
s6a_app.c s6a_dict.c s6a_server.c s6a_client.c
|
||||
s6a_init.c s6a_app.c s6a_config.c \
|
||||
s6a_dict.c s6a_server.c s6a_client.c
|
||||
|
||||
libs6a_la_DEPENDENCIES = \
|
||||
$(top_srcdir)/lib/s6a/freeDiameter/libs6afreeDiameter.la
|
||||
|
|
|
@ -155,19 +155,11 @@ static void ta_hook_cb_oneline(enum fd_hook_type type, struct msg * msg, struct
|
|||
|
||||
|
||||
/* entry point */
|
||||
static int ta_entry(char * conffile)
|
||||
int s6a_app_init(void)
|
||||
{
|
||||
TRACE_ENTRY("%p", conffile);
|
||||
|
||||
/* Initialize configuration */
|
||||
CHECK_FCT( ta_conf_init() );
|
||||
|
||||
/* Parse configuration file */
|
||||
if (conffile != NULL) {
|
||||
CHECK_FCT( ta_conf_handle(conffile) );
|
||||
}
|
||||
|
||||
TRACE_DEBUG(INFO, "Extension Test_App initialized with configuration: '%s'", conffile);
|
||||
ta_conf_dump();
|
||||
|
||||
/* Install objects definitions for this test application */
|
||||
|
@ -180,11 +172,7 @@ static int ta_entry(char * conffile)
|
|||
|
||||
/* Start the signal handler thread */
|
||||
if (ta_conf->mode & MODE_CLI) {
|
||||
if (ta_conf->mode & MODE_BENCH) {
|
||||
CHECK_FCT( ta_bench_init() );
|
||||
} else {
|
||||
CHECK_FCT( ta_cli_init() );
|
||||
}
|
||||
CHECK_FCT( ta_cli_init() );
|
||||
}
|
||||
|
||||
/* Advertise the support for the test application in the peer */
|
||||
|
@ -206,7 +194,7 @@ static int ta_entry(char * conffile)
|
|||
}
|
||||
|
||||
/* Unload */
|
||||
void fd_ext_fini(void)
|
||||
void s6a_app_final(void)
|
||||
{
|
||||
if (ta_conf->mode & MODE_CLI)
|
||||
ta_cli_fini();
|
||||
|
@ -219,5 +207,3 @@ void fd_ext_fini(void)
|
|||
CHECK_FCT_DO( fd_thr_term(&ta_stats_th), );
|
||||
CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), );
|
||||
}
|
||||
|
||||
EXTENSION_ENTRY("test_app", ta_entry);
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
* See the app_test.conf.sample file for the format of the configuration file.
|
||||
*/
|
||||
|
||||
#include "core_errno.h"
|
||||
#include <freeDiameter/extension.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
@ -81,6 +82,19 @@ struct ta_conf {
|
|||
};
|
||||
extern struct ta_conf * ta_conf;
|
||||
|
||||
typedef struct _s6a_config_t {
|
||||
c_uint8_t *identity;
|
||||
c_uint8_t *realm;
|
||||
} s6a_config_t;
|
||||
|
||||
CORE_DECLARE(status_t) s6a_config_init(s6a_config_t *config);
|
||||
|
||||
CORE_DECLARE(status_t) s6a_thread_start();
|
||||
CORE_DECLARE(void) s6a_thread_stop();
|
||||
|
||||
int s6a_app_init(void);
|
||||
void s6a_app_final(void);
|
||||
|
||||
/* Parse the configuration file */
|
||||
int ta_conf_handle(char * conffile);
|
||||
|
||||
|
@ -92,10 +106,6 @@ void ta_serv_fini(void);
|
|||
int ta_cli_init(void);
|
||||
void ta_cli_fini(void);
|
||||
|
||||
/* Benchmark flavour */
|
||||
int ta_bench_init(void);
|
||||
void ta_bench_fini(void);
|
||||
|
||||
/* Initialize dictionary definitions */
|
||||
int ta_dict_init(void);
|
||||
|
||||
|
|
|
@ -279,7 +279,9 @@ int ta_cli_init(void)
|
|||
{
|
||||
CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, (void *)free, NULL, NULL) );
|
||||
|
||||
#if 0
|
||||
CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.cli", ta_cli_test_message ) );
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
#define TRACE_MODULE _s6a_init
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
|
||||
#include "freeDiameter/freeDiameter-host.h"
|
||||
#include "freeDiameter/libfdcore.h"
|
||||
#include "freeDiameter/extension.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);
|
||||
|
||||
status_t s6a_thread_start()
|
||||
{
|
||||
int ret;
|
||||
|
||||
d_trace_level(&_s6a_init, 100);
|
||||
|
||||
gnutls_global_set_log_function(s6a_gnutls_log_func);
|
||||
gnutls_global_set_log_level(TRACE_MODULE);
|
||||
|
||||
ret = fd_log_handler_register(s6a_fd_logger);
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("fd_log_handler_register() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
ret = fd_core_initialize();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("fd_core_initialize() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
ret = s6a_config_init(NULL);
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("s6a_config_init() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
ret = fd_core_start();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("fd_core_start() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
ret = fd_core_waitstartcomplete();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("fd_core_waitstartcomplete() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
ret = s6a_app_init();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("s6a_app_init() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void s6a_thread_stop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
s6a_app_final();
|
||||
|
||||
ret = fd_core_shutdown();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("fd_core_shutdown() failed");
|
||||
}
|
||||
|
||||
ret = fd_core_wait_shutdown_complete();
|
||||
if (ret != 0)
|
||||
{
|
||||
d_error("fd_core_wait_shutdown_complete() failed");
|
||||
}
|
||||
}
|
||||
|
||||
static void s6a_gnutls_log_func(int level, const char *str)
|
||||
{
|
||||
d_trace(level, "gnutls[%d]: %s", level, str);
|
||||
}
|
||||
|
||||
static void s6a_fd_logger(int printlevel, const char *format, va_list ap)
|
||||
{
|
||||
char buffer[HUGE_STRING_LEN];
|
||||
int ret = 0;
|
||||
|
||||
ret = vsnprintf(buffer, HUGE_STRING_LEN, format, ap);
|
||||
if (ret < 0 || ret > HUGE_STRING_LEN)
|
||||
{
|
||||
d_error("vsnprintf() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(printlevel)
|
||||
{
|
||||
case FD_LOG_ANNOYING:
|
||||
d_trace(10, "freeDiameter[%d]: %s\n", printlevel, buffer);
|
||||
break;
|
||||
case FD_LOG_DEBUG:
|
||||
d_trace(1, "freeDiameter[%d]: %s\n", printlevel, buffer);
|
||||
break;
|
||||
case FD_LOG_NOTICE:
|
||||
d_info("%s", buffer);
|
||||
break;
|
||||
case FD_LOG_ERROR:
|
||||
d_error("%s", buffer);
|
||||
break;
|
||||
case FD_LOG_FATAL:
|
||||
{
|
||||
char *except = "Initiating freeDiameter shutdown sequence";
|
||||
if (strncmp(buffer, except, strlen(except)) == 0)
|
||||
d_info("%s", buffer);
|
||||
else
|
||||
d_fatal("%s", buffer);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
d_warn("%s", buffer);
|
||||
break;
|
||||
}
|
||||
}
|
20
src/init.c
20
src/init.c
|
@ -20,9 +20,6 @@ static thread_id mme_net_thread;
|
|||
status_t cellwire_initialize(char *config_path)
|
||||
{
|
||||
status_t rv;
|
||||
#if 0
|
||||
s6a_conf_t conf;
|
||||
#endif
|
||||
|
||||
srand(time(NULL)*getpid());
|
||||
|
||||
|
@ -30,18 +27,6 @@ status_t cellwire_initialize(char *config_path)
|
|||
if (rv != CORE_OK)
|
||||
return rv;
|
||||
|
||||
#if 0
|
||||
rv = s6a_initialize();
|
||||
if (rv != CORE_OK)
|
||||
return rv;
|
||||
|
||||
conf.identity = "hss.cellwire.com";
|
||||
conf.realm = "cellwire.com";
|
||||
|
||||
rv = s6a_conf_handle(&conf);
|
||||
s6a_conf_show();
|
||||
#endif
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
|
@ -126,18 +111,15 @@ void threads_start()
|
|||
d_assert(rv == CORE_OK, return,
|
||||
"MME Network socket recv thread creation failed");
|
||||
|
||||
#if 0
|
||||
rv = s6a_thread_start();
|
||||
d_assert(rv == CORE_OK, return,
|
||||
"HSS thread creation failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
void threads_stop()
|
||||
{
|
||||
#if 0
|
||||
s6a_thread_stop();
|
||||
#endif
|
||||
|
||||
thread_delete(mme_net_thread);
|
||||
thread_delete(mme_sm_thread);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue