update it

This commit is contained in:
Sukchan Lee 2017-02-27 23:01:15 +09:00
parent 4c67cafd96
commit 51bc2a93a9
5 changed files with 119 additions and 248 deletions

View File

@ -9,7 +9,7 @@ libs6a_la_SOURCES = \
nodist_libs6a_la_SOURCES = \
s6a_fd_init.c s6a_fd_config.c \
s6a_app.c s6a_dict.c
s6a_app.c s6a_dict.c s6a_server.c s6a_client.c
libs6a_la_DEPENDENCIES = \
$(top_srcdir)/lib/s6a/freeDiameter/libs6afreeDiameter.la

View File

@ -98,22 +98,20 @@ int s6a_app_init(void)
/* Install objects definitions for this test application */
CHECK_FCT( s6a_dict_init() );
#if 0
/* Install the handlers for incoming messages */
if (ta_conf->mode & MODE_SERV) {
CHECK_FCT( ta_serv_init() );
if (s6a_conf->mode & MODE_SERV) {
CHECK_FCT( s6a_serv_init() );
}
/* Start the signal handler thread */
if (ta_conf->mode & MODE_CLI) {
CHECK_FCT( ta_cli_init() );
if (s6a_conf->mode & MODE_CLI) {
CHECK_FCT( s6a_cli_init() );
}
/* Advertise the support for the test application in the peer */
CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) );
CHECK_FCT( fd_disp_app_support ( s6a_appli, s6a_vendor, 1, 0 ) );
#endif
/* Start the statistics thread */
CHECK_POSIX( pthread_create(&s6a_stats_th, NULL, s6a_stats, NULL) );
@ -123,12 +121,10 @@ int s6a_app_init(void)
/* Unload */
void s6a_app_final(void)
{
#if 0
if (ta_conf->mode & MODE_CLI)
ta_cli_fini();
if (ta_conf->mode & MODE_SERV)
ta_serv_fini();
#endif
if (s6a_conf->mode & MODE_CLI)
s6a_cli_fini();
if (s6a_conf->mode & MODE_SERV)
s6a_serv_fini();
CHECK_FCT_DO( fd_thr_term(&s6a_stats_th), );
CHECK_POSIX_DO( pthread_mutex_destroy(&s6a_conf->stats_lock), );

View File

@ -112,23 +112,15 @@ extern struct dict_object *s6a_served_party_ip_addr;
CORE_DECLARE(int) s6a_app_init(void);
CORE_DECLARE(void) s6a_app_final(void);
/* Initialize dictionary definitions */
CORE_DECLARE(int) s6a_dict_init(void);
CORE_DECLARE(int) s6a_serv_init(void);
CORE_DECLARE(void) s6a_serv_fini(void);
CORE_DECLARE(int) s6a_cli_init(void);
CORE_DECLARE(void) s6a_cli_fini(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ! __S6A_APP_H__ */
#if 0
/* Handle incoming messages (server) */
int ta_serv_init(void);
void ta_serv_fini(void);
/* Create outgoing message (client) */
int ta_cli_init(void);
void ta_cli_fini(void);
#endif

View File

@ -1,49 +1,8 @@
/*********************************************************************************************************
* Software License Agreement (BSD License) *
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
* *
* Copyright (c) 2013, WIDE Project and NICT *
* All rights reserved. *
* *
* Redistribution and use of this software in source and binary forms, with or without modification, are *
* permitted provided that the following conditions are met: *
* *
* * Redistributions of source code must retain the above *
* copyright notice, this list of conditions and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other *
* materials provided with the distribution. *
* *
* * Neither the name of the WIDE Project or NICT nor the *
* names of its contributors may be used to endorse or *
* promote products derived from this software without *
* specific prior written permission of WIDE Project and *
* NICT. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*********************************************************************************************************/
/* Create and send a message, and receive it */
/* Note that we use both sessions and the argument to answer callback to pass the same value.
* This is just for the purpose of checking everything went OK.
*/
#include "core_debug.h"
#include "s6a_app.h"
#include <stdio.h>
static struct session_handler * ta_cli_reg = NULL;
static struct session_handler * s6a_cli_reg = NULL;
struct sess_state {
int32_t randval; /* a random value to store in Test-AVP */
@ -51,7 +10,7 @@ struct sess_state {
} ;
/* Cb called when an answer is received */
static void ta_cb_ans(void * data, struct msg ** msg)
static void s6a_aia_cb(void * data, struct msg ** msg)
{
struct sess_state * mi = NULL;
struct timespec ts;
@ -66,19 +25,21 @@ static void ta_cb_ans(void * data, struct msg ** msg)
/* Search the session, retrieve its data */
{
int new;
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &sess, &new), return );
ASSERT( new == 0 );
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &sess, &new),
return );
d_assert(new == 0, return, "fd_msg_sess_get() failed");
CHECK_FCT_DO( fd_sess_state_retrieve( ta_cli_reg, sess, &mi ), return );
TRACE_DEBUG( INFO, "%p %p", mi, data);
ASSERT( (void *)mi == data );
CHECK_FCT_DO( fd_sess_state_retrieve( s6a_cli_reg, sess, &mi ),
return );
d_assert((void *)mi == data, return, "fd_sess_state_retrieve() failed");
}
/* Now log content of the answer */
fprintf(stderr, "RECV ");
#if 0
/* Value of Test-AVP */
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_avp, &avp), return );
CHECK_FCT_DO( fd_msg_search_avp ( *msg, s6a_avp, &avp), return );
if (avp) {
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
if (hdr->avp_value->i32 == mi->randval) {
@ -91,75 +52,64 @@ static void ta_cb_ans(void * data, struct msg ** msg)
fprintf(stderr, "no_Test-AVP ");
error++;
}
#endif
/* Value of Result Code */
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_res_code, &avp), return );
CHECK_FCT_DO( fd_msg_search_avp ( *msg, s6a_result_code, &avp),
return );
if (avp) {
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
fprintf(stderr, "Status: %d ", hdr->avp_value->i32);
d_info("Status: %d ", hdr->avp_value->i32);
if (hdr->avp_value->i32 != 2001)
error++;
} else {
fprintf(stderr, "no_Result-Code ");
d_error("no_Result-Code");
error++;
}
/* Value of Origin-Host */
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_host, &avp), return );
CHECK_FCT_DO( fd_msg_search_avp ( *msg, s6a_origin_host, &avp), return );
if (avp) {
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
fprintf(stderr, "From '%.*s' ", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
d_info("From '%.*s' ",
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
} else {
fprintf(stderr, "no_Origin-Host ");
d_error("no_Origin-Host ");
error++;
}
/* Value of Origin-Realm */
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_realm, &avp), return );
CHECK_FCT_DO( fd_msg_search_avp ( *msg, s6a_origin_realm, &avp), return );
if (avp) {
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
fprintf(stderr, "('%.*s') ", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
d_info("('%.*s') ",
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
} else {
fprintf(stderr, "no_Origin-Realm ");
d_error("no_Origin-Realm ");
error++;
}
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) + ((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
if (ta_conf->stats.nb_recv) {
/* Ponderate in the avg */
ta_conf->stats.avg = (ta_conf->stats.avg * ta_conf->stats.nb_recv + dur) / (ta_conf->stats.nb_recv + 1);
/* Min, max */
if (dur < ta_conf->stats.shortest)
ta_conf->stats.shortest = dur;
if (dur > ta_conf->stats.longest)
ta_conf->stats.longest = dur;
} else {
ta_conf->stats.shortest = dur;
ta_conf->stats.longest = dur;
ta_conf->stats.avg = dur;
}
CHECK_POSIX_DO( pthread_mutex_lock(&s6a_conf->stats_lock), );
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) +
((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
if (error)
ta_conf->stats.nb_errs++;
s6a_conf->stats.nb_errs++;
else
ta_conf->stats.nb_recv++;
s6a_conf->stats.nb_recv++;
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
CHECK_POSIX_DO( pthread_mutex_unlock(&s6a_conf->stats_lock), );
/* Display how long it took */
if (ts.tv_nsec > mi->ts.tv_nsec) {
fprintf(stderr, "in %d.%06ld sec",
d_info("in %d.%06ld sec",
(int)(ts.tv_sec - mi->ts.tv_sec),
(long)(ts.tv_nsec - mi->ts.tv_nsec) / 1000);
} else {
fprintf(stderr, "in %d.%06ld sec",
d_info("in %d.%06ld sec",
(int)(ts.tv_sec + 1 - mi->ts.tv_sec),
(long)(1000000000 + ts.tv_nsec - mi->ts.tv_nsec) / 1000);
}
fprintf(stderr, "\n");
fflush(stderr);
/* Free the message */
CHECK_FCT_DO(fd_msg_free(*msg), return);
@ -171,7 +121,7 @@ static void ta_cb_ans(void * data, struct msg ** msg)
}
/* Create a test message */
static void ta_cli_test_message()
static void s6a_cli_test_message()
{
struct msg * req = NULL;
struct avp * avp;
@ -179,22 +129,20 @@ static void ta_cli_test_message()
struct sess_state * mi = NULL, *svg;
struct session *sess = NULL;
TRACE_DEBUG(FULL, "Creating a new message for sending.");
/* Create the request */
CHECK_FCT_DO( fd_msg_new( ta_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out );
CHECK_FCT_DO( fd_msg_new( s6a_cmd_air,
MSGFL_ALLOC_ETEID, &req ), goto out );
/* Create a new session */
#define TEST_APP_SID_OPT "app_test"
CHECK_FCT_DO( fd_msg_new_session( req, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL), goto out );
#define TEST_APP_SID_OPT "app_s6a"
CHECK_FCT_DO( fd_msg_new_session( req, (os0_t)TEST_APP_SID_OPT,
CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL),
goto out );
/* Create the random value to store with the session */
mi = malloc(sizeof(struct sess_state));
if (mi == NULL) {
fd_log_debug("malloc failed: %s", strerror(errno));
goto out;
}
d_assert(mi, goto out, "malloc failed: %s", strerror(errno));
mi->randval = (int32_t)random();
@ -202,53 +150,37 @@ static void ta_cli_test_message()
/* Set the Destination-Realm AVP */
{
CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_realm, 0, &avp ), goto out );
val.os.data = (unsigned char *)(ta_conf->dest_realm);
val.os.len = strlen(ta_conf->dest_realm);
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);
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 );
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ),
goto out );
}
/* Set the Destination-Host AVP if needed*/
if (ta_conf->dest_host) {
CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_host, 0, &avp ), goto out );
val.os.data = (unsigned char *)(ta_conf->dest_host);
val.os.len = strlen(ta_conf->dest_host);
if (s6a_conf->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);
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 );
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ),
goto out );
}
/* Set Origin-Host & Origin-Realm */
CHECK_FCT_DO( fd_msg_add_origin ( req, 0 ), goto out );
/* Set the User-Name AVP if needed*/
if (ta_conf->user_name) {
CHECK_FCT_DO( fd_msg_avp_new ( ta_user_name, 0, &avp ), goto out );
val.os.data = (unsigned char *)(ta_conf->user_name);
val.os.len = strlen(ta_conf->user_name);
if (s6a_conf->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);
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 Test-AVP AVP */
{
CHECK_FCT_DO( fd_msg_avp_new ( ta_avp, 0, &avp ), goto out );
val.i32 = mi->randval;
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 Test-Payload-AVP AVP */
if (ta_conf->long_avp_id) {
int l;
CHECK_FCT_DO( fd_msg_avp_new ( ta_avp_long, 0, &avp ), goto out );
CHECK_MALLOC_DO( val.os.data = malloc(ta_conf->long_avp_len), goto out);
val.os.len = ta_conf->long_avp_len;
for (l=0; l < ta_conf->long_avp_len; l++)
val.os.data[l]=l;
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
free(val.os.data);
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out );
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ),
goto out );
}
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
@ -257,38 +189,38 @@ static void ta_cli_test_message()
svg = mi;
/* Store this value in the session */
CHECK_FCT_DO( fd_sess_state_store ( ta_cli_reg, sess, &mi ), goto out );
CHECK_FCT_DO( fd_sess_state_store ( s6a_cli_reg, sess, &mi ), goto out );
/* Log sending the message */
fprintf(stderr, "SEND %x to '%s' (%s)\n", svg->randval, ta_conf->dest_realm, ta_conf->dest_host?:"-" );
fflush(stderr);
d_info("SEND %x to '%s' (%s)\n", svg->randval,
s6a_conf->dest_realm, s6a_conf->dest_host?:"-" );
/* Send the request */
CHECK_FCT_DO( fd_msg_send( &req, ta_cb_ans, svg ), goto out );
CHECK_FCT_DO( fd_msg_send( &req, s6a_aia_cb, svg ), goto out );
/* Increment the counter */
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
ta_conf->stats.nb_sent++;
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
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), );
out:
return;
}
int ta_cli_init(void)
int s6a_cli_init(void)
{
CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, (void *)free, NULL, NULL) );
CHECK_FCT( fd_sess_handler_create(&s6a_cli_reg, (void *)free, NULL, NULL) );
CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.cli", ta_cli_test_message ) );
// CHECK_FCT( fd_event_trig_regcb(s6a_conf->signal, "test_app.cli", s6a_cli_test_message ) );
return 0;
}
void ta_cli_fini(void)
void s6a_cli_fini(void)
{
// CHECK_FCT_DO( fd_sig_unregister(ta_conf->signal), /* continue */ );
// CHECK_FCT_DO( fd_sig_unregister(s6a_conf->signal), /* continue */ );
CHECK_FCT_DO( fd_sess_handler_destroy(&ta_cli_reg, NULL), /* continue */ );
CHECK_FCT_DO( fd_sess_handler_destroy(&s6a_cli_reg, NULL), /* continue */ );
return;
};

View File

@ -1,111 +1,62 @@
/*********************************************************************************************************
* Software License Agreement (BSD License) *
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
* *
* Copyright (c) 2013, WIDE Project and NICT *
* All rights reserved. *
* *
* Redistribution and use of this software in source and binary forms, with or without modification, are *
* permitted provided that the following conditions are met: *
* *
* * Redistributions of source code must retain the above *
* copyright notice, this list of conditions and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other *
* materials provided with the distribution. *
* *
* * Neither the name of the WIDE Project or NICT nor the *
* names of its contributors may be used to endorse or *
* promote products derived from this software without *
* specific prior written permission of WIDE Project and *
* NICT. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*********************************************************************************************************/
/* Install the dispatch callbacks */
#include "core_debug.h"
#include "s6a_app.h"
static struct disp_hdl * ta_hdl_fb = NULL; /* handler for fallback cb */
static struct disp_hdl * ta_hdl_tr = NULL; /* handler for Test-Request req cb */
static struct disp_hdl * s6a_hdl_fb = NULL; /* handler for fallback cb */
static struct disp_hdl * s6a_hdl_tr = NULL; /* handler for Test-Request req cb */
/* Default callback for the application. */
static int ta_fb_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
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 */
TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
fd_log_debug("Unexpected message received!");
d_warn("Unexpected message received!");
return ENOTSUP;
}
/* Callback for incoming Test-Request messages */
static int ta_tr_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
static int s6a_air_cb( struct msg ** msg, struct avp * avp,
struct session * sess, void * opaque, enum disp_action * act)
{
struct msg *ans, *qry;
struct avp * a;
TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
if (msg == NULL)
return EINVAL;
/* Value of Origin-Host */
if (! (ta_conf->mode & MODE_BENCH)) {
fprintf(stderr, "ECHO Test-Request received from ");
CHECK_FCT( fd_msg_search_avp ( *msg, ta_origin_host, &a) );
if (a) {
struct avp_hdr * hdr;
CHECK_FCT( fd_msg_avp_hdr( a, &hdr ) );
fprintf(stderr, "'%.*s'", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
} else {
fprintf(stderr, "no_Origin-Host");
}
fprintf(stderr, ", replying...\n");
}
/* Create answer header */
qry = *msg;
CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) );
ans = *msg;
#if 0
/* Set the Test-AVP AVP */
{
struct avp * src = NULL;
struct avp_hdr * hdr = NULL;
CHECK_FCT( fd_msg_search_avp ( qry, ta_avp, &src) );
CHECK_FCT( fd_msg_search_avp ( qry, s6a_avp, &src) );
CHECK_FCT( fd_msg_avp_hdr( src, &hdr ) );
CHECK_FCT( fd_msg_avp_new ( ta_avp, 0, &avp ) );
CHECK_FCT( fd_msg_avp_new ( s6a_avp, 0, &avp ) );
CHECK_FCT( fd_msg_avp_setvalue( avp, hdr->avp_value ) );
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, avp ) );
}
/* Set the Test-Payload-AVP AVP */
if (ta_conf->long_avp_id) {
if (s6a_conf->long_avp_id) {
struct avp * src = NULL;
struct avp_hdr * hdr = NULL;
CHECK_FCT( fd_msg_search_avp ( qry, ta_avp_long, &src) );
CHECK_FCT( fd_msg_search_avp ( qry, s6a_avp_long, &src) );
CHECK_FCT( fd_msg_avp_hdr( src, &hdr ) );
CHECK_FCT( fd_msg_avp_new ( ta_avp_long, 0, &avp ) );
CHECK_FCT( fd_msg_avp_new ( s6a_avp_long, 0, &avp ) );
CHECK_FCT( fd_msg_avp_setvalue( avp, hdr->avp_value ) );
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, avp ) );
}
#endif
/* Set the Origin-Host, Origin-Realm, Result-Code AVPs */
@ -115,39 +66,39 @@ static int ta_tr_cb( struct msg ** msg, struct avp * avp, struct session * sess,
CHECK_FCT( fd_msg_send( msg, NULL, NULL ) );
/* Add this value to the stats */
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
ta_conf->stats.nb_echoed++;
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
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), );
return 0;
}
int ta_serv_init(void)
int s6a_serv_init(void)
{
struct disp_when data;
TRACE_DEBUG(FULL, "Initializing dispatch callbacks for test");
memset(&data, 0, sizeof(data));
data.app = ta_appli;
data.command = ta_cmd_r;
data.app = s6a_appli;
data.command = s6a_cmd_air;
/* fallback CB if command != Test-Request received */
CHECK_FCT( fd_disp_register( ta_fb_cb, DISP_HOW_APPID, &data, NULL, &ta_hdl_fb ) );
/* fallback CB if command != unexpected message received */
CHECK_FCT( fd_disp_register( s6a_fb_cb, DISP_HOW_APPID, &data, NULL,
&s6a_hdl_fb ) );
/* Now specific handler for Test-Request */
CHECK_FCT( fd_disp_register( ta_tr_cb, DISP_HOW_CC, &data, NULL, &ta_hdl_tr ) );
/* Now specific handler for Authentication-Information-Request */
CHECK_FCT( fd_disp_register( s6a_air_cb, DISP_HOW_CC, &data, NULL,
&s6a_hdl_tr ) );
return 0;
}
void ta_serv_fini(void)
void s6a_serv_fini(void)
{
if (ta_hdl_fb) {
(void) fd_disp_unregister(&ta_hdl_fb, NULL);
if (s6a_hdl_fb) {
(void) fd_disp_unregister(&s6a_hdl_fb, NULL);
}
if (ta_hdl_tr) {
(void) fd_disp_unregister(&ta_hdl_tr, NULL);
if (s6a_hdl_tr) {
(void) fd_disp_unregister(&s6a_hdl_tr, NULL);
}
return;