server/client template is added
This commit is contained in:
parent
f2748e490d
commit
145f5b5377
|
@ -8,7 +8,7 @@ libmessages6a_la_SOURCES = \
|
||||||
s6a_message.h
|
s6a_message.h
|
||||||
|
|
||||||
nodist_libmessages6a_la_SOURCES = \
|
nodist_libmessages6a_la_SOURCES = \
|
||||||
s6a_init.c s6a_dict.c
|
s6a_init.c s6a_dict.c s6a_server.c s6a_client.c
|
||||||
|
|
||||||
libmessages6a_la_DEPENDENCIES = \
|
libmessages6a_la_DEPENDENCIES = \
|
||||||
$(top_srcdir)/lib/message/s6a/freeDiameter/libmessages6afd.la
|
$(top_srcdir)/lib/message/s6a/freeDiameter/libmessages6afd.la
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#define TRACE_MODULE _s6a_client
|
||||||
|
|
||||||
|
#include "core_debug.h"
|
||||||
|
|
||||||
|
#include "freeDiameter/freeDiameter-host.h"
|
||||||
|
#include "freeDiameter/libfdcore.h"
|
||||||
|
#include "freeDiameter/extension.h"
|
||||||
|
|
||||||
|
#include "s6a_message.h"
|
||||||
|
|
||||||
|
static struct session_handler *s6a_cli_reg = NULL;
|
||||||
|
|
||||||
|
struct sess_state {
|
||||||
|
c_int32_t randval; /* a random value to store in Test-AVP */
|
||||||
|
struct timespec ts; /* Time of sending the message */
|
||||||
|
} ;
|
||||||
|
|
||||||
|
status_t s6a_client_start()
|
||||||
|
{
|
||||||
|
CHECK_FCT(fd_sess_handler_create(&s6a_cli_reg, (void *)free, NULL, NULL));
|
||||||
|
|
||||||
|
return CORE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void s6a_client_stop()
|
||||||
|
{
|
||||||
|
CHECK_FCT_DO(fd_sess_handler_destroy(&s6a_cli_reg, NULL), /* continue */ );
|
||||||
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
#define APP_S6A (16777251)
|
#define APP_S6A (16777251)
|
||||||
|
|
||||||
struct dict_object *s6a_vendor;
|
struct dict_object *s6a_vendor;
|
||||||
struct dict_object *s6a_app;
|
struct dict_object *s6a_appli;
|
||||||
|
|
||||||
struct dict_object *s6a_air;
|
struct dict_object *s6a_air;
|
||||||
struct dict_object *s6a_aia;
|
struct dict_object *s6a_aia;
|
||||||
|
@ -137,7 +137,7 @@ status_t s6a_dict_init()
|
||||||
(void *)&vendor_3gpp, &s6a_vendor, ENOENT));
|
(void *)&vendor_3gpp, &s6a_vendor, ENOENT));
|
||||||
|
|
||||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_APPLICATION,
|
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_APPLICATION,
|
||||||
APPLICATION_BY_ID, (void *)&app_s6a, &s6a_app, ENOENT));
|
APPLICATION_BY_ID, (void *)&app_s6a, &s6a_appli, ENOENT));
|
||||||
|
|
||||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME,
|
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME,
|
||||||
"Authentication-Information-Request", &s6a_air, ENOENT));
|
"Authentication-Information-Request", &s6a_air, ENOENT));
|
||||||
|
|
|
@ -75,6 +75,18 @@ status_t s6a_conf_handle(s6a_conf_t *conf)
|
||||||
return CORE_OK;
|
return CORE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void s6a_conf_show()
|
||||||
|
{
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (g_trace_mask && TRACE_MODULE >= 1)
|
||||||
|
{
|
||||||
|
printf("%s\n", fd_conf_dump(&buf, &len, NULL));
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
status_t s6a_thread_start()
|
status_t s6a_thread_start()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -93,6 +105,23 @@ status_t s6a_thread_start()
|
||||||
return CORE_ERROR;
|
return CORE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = s6a_server_start();
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
d_error("s6a_server_start() failed");
|
||||||
|
return CORE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = s6a_client_start();
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
d_error("s6a_client_start() failed");
|
||||||
|
return CORE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Advertise the support for the test application in the peer */
|
||||||
|
CHECK_FCT(fd_disp_app_support(s6a_appli, s6a_vendor, 1, 0));
|
||||||
|
|
||||||
return CORE_OK;
|
return CORE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +129,9 @@ void s6a_thread_stop()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
s6a_client_stop();
|
||||||
|
s6a_server_stop();
|
||||||
|
|
||||||
ret = fd_core_shutdown();
|
ret = fd_core_shutdown();
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
|
@ -113,18 +145,6 @@ void s6a_thread_stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void s6a_conf_show()
|
|
||||||
{
|
|
||||||
char *buf = NULL;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (g_trace_mask && TRACE_MODULE >= 1)
|
|
||||||
{
|
|
||||||
printf("%s\n", fd_conf_dump(&buf, &len, NULL));
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s6a_gnutls_log_func(int level, const char *str)
|
static void s6a_gnutls_log_func(int level, const char *str)
|
||||||
{
|
{
|
||||||
d_trace(level, "gnutls[%d]: %s", level, str);
|
d_trace(level, "gnutls[%d]: %s", level, str);
|
||||||
|
|
|
@ -19,13 +19,18 @@ CORE_DECLARE(status_t) s6a_initialize();
|
||||||
CORE_DECLARE(status_t) s6a_conf_handle(s6a_conf_t *conf);
|
CORE_DECLARE(status_t) s6a_conf_handle(s6a_conf_t *conf);
|
||||||
CORE_DECLARE(void) s6a_conf_show();
|
CORE_DECLARE(void) s6a_conf_show();
|
||||||
|
|
||||||
|
CORE_DECLARE(status_t) s6a_dict_init();
|
||||||
|
|
||||||
CORE_DECLARE(status_t) s6a_thread_start();
|
CORE_DECLARE(status_t) s6a_thread_start();
|
||||||
CORE_DECLARE(void) s6a_thread_stop();
|
CORE_DECLARE(void) s6a_thread_stop();
|
||||||
|
|
||||||
CORE_DECLARE(status_t) s6a_dict_init();
|
CORE_DECLARE(status_t) s6a_server_start();
|
||||||
|
CORE_DECLARE(void) s6a_server_stop();
|
||||||
|
CORE_DECLARE(status_t) s6a_client_start();
|
||||||
|
CORE_DECLARE(void) s6a_client_stop();
|
||||||
|
|
||||||
extern struct dict_object *s6a_vendor;
|
extern struct dict_object *s6a_vendor;
|
||||||
extern struct dict_object *s6a_app;
|
extern struct dict_object *s6a_appli;
|
||||||
|
|
||||||
extern struct dict_object *s6a_air;
|
extern struct dict_object *s6a_air;
|
||||||
extern struct dict_object *s6a_aia;
|
extern struct dict_object *s6a_aia;
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
#define TRACE_MODULE _s6a_serv
|
||||||
|
|
||||||
|
#include "core_debug.h"
|
||||||
|
|
||||||
|
#include "freeDiameter/freeDiameter-host.h"
|
||||||
|
#include "freeDiameter/libfdcore.h"
|
||||||
|
#include "freeDiameter/extension.h"
|
||||||
|
|
||||||
|
#include "s6a_message.h"
|
||||||
|
|
||||||
|
/* handler for fallback cb */
|
||||||
|
static struct disp_hdl *s6a_hdl_fb = NULL;
|
||||||
|
/* handler for Authentication-Information-Request cb */
|
||||||
|
static struct disp_hdl *s6a_hdl_air = NULL;
|
||||||
|
|
||||||
|
/* Default callback for the application. */
|
||||||
|
static int s6a_fb_cb( struct msg ** msg, struct avp * avp,
|
||||||
|
struct session * sess, void * opaque, enum disp_action * act)
|
||||||
|
{
|
||||||
|
/* This CB should never be called */
|
||||||
|
d_warn("Unexpected message received!");
|
||||||
|
|
||||||
|
return ENOTSUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Callback for incoming Authentication-Information-Answer messages */
|
||||||
|
static int s6a_air_cb( struct msg ** msg, struct avp * avp,
|
||||||
|
struct session * sess, void * opaque, enum disp_action * act)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
struct msg *ans, *qry;
|
||||||
|
struct avp * a;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
d_info("Authentication-Information-Answer received!");
|
||||||
|
|
||||||
|
if (msg == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t s6a_server_start()
|
||||||
|
{
|
||||||
|
struct disp_when data;
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
data.app = s6a_appli;
|
||||||
|
data.command = s6a_air;
|
||||||
|
|
||||||
|
/* fallback CB if Unexpected message received */
|
||||||
|
CHECK_FCT(fd_disp_register(
|
||||||
|
s6a_fb_cb, DISP_HOW_APPID, &data, NULL, &s6a_hdl_fb));
|
||||||
|
|
||||||
|
/* Now specific handler for Authentication-Information-Request */
|
||||||
|
CHECK_FCT(fd_disp_register(
|
||||||
|
s6a_air_cb, DISP_HOW_CC, &data, NULL, &s6a_hdl_air));
|
||||||
|
|
||||||
|
return CORE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void s6a_server_stop()
|
||||||
|
{
|
||||||
|
if (s6a_hdl_fb)
|
||||||
|
(void)fd_disp_unregister(&s6a_hdl_fb, NULL);
|
||||||
|
|
||||||
|
if (s6a_hdl_air)
|
||||||
|
(void) fd_disp_unregister(&s6a_hdl_air, NULL);
|
||||||
|
}
|
Loading…
Reference in New Issue