Commit a9f583cd authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Added some extensions and functions in the daemon

parent 7b1b8ec8
......@@ -128,5 +128,6 @@ ListenOn = "2001:200:903:2::202:1";
TcTimer = 60;
TwTimer = 6;
NoRelay;
#LoadExtension = "extensions/sample.fdx";
LoadExtension = "extensions/sample.fdx":"conf/sample.conf";
LoadExtension = "extensions/dbg_monitor.fdx";
LoadExtension = "extensions/dict_nasreq.fdx";
LoadExtension = "extensions/dict_eap.fdx";
......@@ -17,15 +17,15 @@ ENDMACRO(FD_ADD_EXTENSION)
####
# Diameter applications dictionary
# OPTION(BUILD_DICT_NASREQ "Build NASREQ (RFC4005) Dictionary definitions?" ON)
# IF (BUILD_DICT_NASREQ)
# SUBDIRS(dict_nasreq)
# ENDIF (BUILD_DICT_NASREQ)
OPTION(BUILD_DICT_NASREQ "Build NASREQ (RFC4005) Dictionary definitions?" ON)
IF (BUILD_DICT_NASREQ)
SUBDIRS(dict_nasreq)
ENDIF (BUILD_DICT_NASREQ)
# OPTION(BUILD_DICT_EAP "Build Diameter EAP (RFC4072) Dictionary definitions?" ON)
# IF (BUILD_DICT_EAP)
# SUBDIRS(dict_eap)
# ENDIF (BUILD_DICT_EAP)
OPTION(BUILD_DICT_EAP "Build Diameter EAP (RFC4072) Dictionary definitions?" ON)
IF (BUILD_DICT_EAP)
SUBDIRS(dict_eap)
ENDIF (BUILD_DICT_EAP)
......@@ -58,11 +58,16 @@ ENDMACRO(FD_ADD_EXTENSION)
####
# Debug / development extensions
OPTION(BUILD_SAMPLE "Build sample? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)
OPTION(BUILD_SAMPLE "Build sample.fdx? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)
IF (BUILD_SAMPLE)
SUBDIRS(_sample)
ENDIF (BUILD_SAMPLE)
OPTION(BUILD_MONITOR "Build monitor.fdx? (display periodical debug information on the console)" OFF)
IF (BUILD_MONITOR)
SUBDIRS(dbg_monitor)
ENDIF (BUILD_MONITOR)
# OPTION(BUILD_RT_ANY "Build rt_any? (Routing extension sending message to any peer available, for testing purpose only)" OFF)
# IF (BUILD_RT_ANY)
# SUBDIRS(rt_any)
......
......@@ -2,4 +2,4 @@
PROJECT("Sample extension" C)
# Compile as a module
FD_ADD_EXTENSION(sample sample.c fini.c)
FD_ADD_EXTENSION(dbg_sample sample.c fini.c)
......@@ -33,13 +33,13 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*********************************************************************************************************/
/* Sample extension exit point */
#include <freeDiameter/extension.h>
/* The function MUST be called this */
void fd_ext_fini(void)
{
fd_log_debug("Extension is terminated... Bye!\n");
/* This code is executed when the daemon is exiting; cleanup management should be placed here */
TRACE_DEBUG(INFO, "Extension is terminated... Bye!");
return ;
}
......@@ -44,18 +44,21 @@ EXTENSION_ENTRY("sample", sample_main);
/* The extension-specific initialization code */
static int sample_main(char * conffile)
{
/* The debug macro from main tree can be used the same way */
TRACE_ENTRY("%p", conffile);
fprintf(stdout, "I am extension " __FILE__ " running on host %s\n", fd_g_config->diam_id);
/* This is how we access daemon's global vars */
fprintf(stdout, "I am extension " __FILE__ " running on host %s.", fd_g_config->cnf_diamid);
/* The configuration file name is received in the conffile var. It's up to extension to parse it */
if (conffile) {
fprintf(stdout, "I should parse my configuration file there: %s\n", conffile);
} else {
fprintf(stdout, "I received no configuration file to parse\n");
}
/* Use the dictionary for test */
fd_log_debug("Let's create that 'Example-AVP'...\n");
/* Functions from the libfreediameter can also be used as demonstrated here: */
TRACE_DEBUG(INFO, "Let's create that 'Example-AVP'...");
{
struct dict_object * origin_host_avp = NULL;
struct dict_object * session_id_avp = NULL;
......@@ -63,22 +66,27 @@ static int sample_main(char * conffile)
struct dict_rule_data rule_data = { NULL, RULE_REQUIRED, 0, -1, 1 };
struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };
CHECK_FCT( fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT));
CHECK_FCT( fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT));
CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT));
CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT));
CHECK_FCT( fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ));
CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ));
rule_data.rule_avp = origin_host_avp;
rule_data.rule_min = 1;
rule_data.rule_max = 1;
CHECK_FCT( fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
rule_data.rule_avp = session_id_avp;
rule_data.rule_min = 1;
rule_data.rule_max = -1;
CHECK_FCT( fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
fd_dict_dump_object(example_avp_avp);
}
fd_log_debug("'Example-AVP' created without error\n");
TRACE_DEBUG(INFO, "'Example-AVP' created without error\n");
/* The initialization function returns an error code with the standard POSIX meaning (ENOMEM, and so on) */
return 0;
}
/* See file fini.c for an example of destructor */
# Monitoring extension
PROJECT("Monitor extension" C)
FD_ADD_EXTENSION(dbg_monitor monitor.c)
/*********************************************************************************************************
* Software License Agreement (BSD License) *
* Author: Sebastien Decugis <sdecugis@nict.go.jp> *
* *
* Copyright (c) 2009, 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. *
*********************************************************************************************************/
/* Monitoring extension:
- periodically display queues and peers information
- upon SIGUSR1, display additional debug information
*/
#include <freeDiameter/extension.h>
#include <signal.h>
static int monitor_main(char * conffile);
EXTENSION_ENTRY("monitor", monitor_main);
/* Function called on receipt of SIGUSR1 */
static void got_sig(int signal)
{
CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_DICT, NULL), /* continue */);
CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_CONFIG, NULL), /* continue */);
CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_EXT, NULL), /* continue */);
}
/* Thread to display periodical debug information */
static pthread_t thr;
static void * mn_thr(void * arg)
{
sigset_t sig;
struct sigaction act;
fd_log_threadname("Monitor thread");
/* Catch signal SIGUSR1 */
memset(&act, 0, sizeof(act));
act.sa_handler = got_sig;
CHECK_SYS_DO( sigaction(SIGUSR1, &act, NULL), /* conitnue */ );
sigemptyset(&sig);
sigaddset(&sig, SIGUSR1);
CHECK_POSIX_DO( pthread_sigmask(SIG_UNBLOCK, &sig, NULL), /* conitnue */ );
/* Loop */
while (1) {
sleep(60);
TRACE_DEBUG(NONE, "Monitor information");
CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_QUEUES, NULL), /* continue */);
CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_PEERS, NULL), /* continue */);
pthread_testcancel();
}
return NULL;
}
static int monitor_main(char * conffile)
{
TRACE_ENTRY("%p", conffile);
CHECK_POSIX( pthread_create( &thr, NULL, mn_thr, NULL ) );
return 0;
}
void fd_ext_fini(void)
{
TRACE_ENTRY();
CHECK_FCT_DO( fd_thr_term(&thr), /* continue */ );
return ;
}
# The dict_nasreq extension
PROJECT("Diameter EAP (RFC4072) dictionary definitions" C)
# Compile as a module
FD_ADD_EXTENSION(dict_eap dict_eap.c)
This diff is collapsed.
# The dict_nasreq extension
PROJECT("Diameter NASREQ (RFC4005) dictionary definitions" C)
# Compile as a module
FD_ADD_EXTENSION(dict_nasreq dict_nasreq.c)
This diff is collapsed.
......@@ -10,8 +10,11 @@ SET_SOURCE_FILES_PROPERTIES(lex.fdd.c fdd.tab.c PROPERTIES COMPILE_FLAGS "-I ${C
SET(FD_COMMON_SRC
fD.h
config.c
dispatch.c
extensions.c
dict_base_proto.c
messages.c
queues.c
)
SET(FD_COMMON_GEN_SRC
......
......@@ -42,25 +42,25 @@ int fd_conf_init()
{
TRACE_ENTRY();
fd_g_config->eyec = EYEC_CONFIG;
fd_g_config->conf_file = DEFAULT_CONF_FILE;
fd_g_config->cnf_eyec = EYEC_CONFIG;
fd_g_config->cnf_file = DEFAULT_CONF_FILE;
fd_g_config->loc_port = 3868;
fd_g_config->loc_port_tls = 3869;
fd_g_config->loc_sctp_str = 30;
fd_list_init(&fd_g_config->loc_endpoints, NULL);
fd_g_config->cnf_timer_tc = 30;
fd_g_config->cnf_timer_tw = 30;
fd_g_config->cnf_port = 3868;
fd_g_config->cnf_port_tls = 3869;
fd_g_config->cnf_sctp_str = 30;
fd_list_init(&fd_g_config->cnf_endpoints, NULL);
fd_list_init(&fd_g_config->cnf_apps, NULL);
#ifdef DISABLE_SCTP
fd_g_config->flags.no_sctp = 1;
fd_g_config->cnf_flags.no_sctp = 1;
#endif /* DISABLE_SCTP */
fd_g_config->timer_tc = 30;
fd_g_config->timer_tw = 30;
fd_g_config->cnf_orstateid = (uint32_t) time(NULL);
fd_g_config->or_state_id = (uint32_t) time(NULL);
CHECK_FCT( fd_dict_init(&fd_g_config->g_dict) );
CHECK_FCT( fd_fifo_new(&fd_g_config->g_fifo_main) );
CHECK_FCT( fd_dict_init(&fd_g_config->cnf_dict) );
CHECK_FCT( fd_fifo_new(&fd_g_config->cnf_main_ev) );
return 0;
}
......@@ -72,39 +72,56 @@ void fd_conf_dump()
fd_log_debug("-- Configuration :\n");
fd_log_debug(" Debug trace level ...... : %+d\n", fd_g_debug_lvl);
fd_log_debug(" Configuration file ..... : %s\n", fd_g_config->conf_file);
fd_log_debug(" Diameter Identity ...... : %s (l:%Zi)\n", fd_g_config->diam_id, fd_g_config->diam_id_len);
fd_log_debug(" Diameter Realm ......... : %s (l:%Zi)\n", fd_g_config->diam_realm, fd_g_config->diam_realm_len);
fd_log_debug(" Local port ............. : %hu\n", fd_g_config->loc_port);
fd_log_debug(" Local secure port ...... : %hu\n", fd_g_config->loc_port_tls);
fd_log_debug(" Number of SCTP streams . : %hu\n", fd_g_config->loc_sctp_str);
if (FD_IS_LIST_EMPTY(&fd_g_config->loc_endpoints)) {
fd_log_debug(" Configuration file ..... : %s\n", fd_g_config->cnf_file);
fd_log_debug(" Diameter Identity ...... : %s (l:%Zi)\n", fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len);
fd_log_debug(" Diameter Realm ......... : %s (l:%Zi)\n", fd_g_config->cnf_diamrlm, fd_g_config->cnf_diamrlm_len);
fd_log_debug(" Tc Timer ............... : %u\n", fd_g_config->cnf_timer_tc);
fd_log_debug(" Tw Timer ............... : %u\n", fd_g_config->cnf_timer_tw);
fd_log_debug(" Local port ............. : %hu\n", fd_g_config->cnf_port);
fd_log_debug(" Local secure port ...... : %hu\n", fd_g_config->cnf_port_tls);
fd_log_debug(" Number of SCTP streams . : %hu\n", fd_g_config->cnf_sctp_str);
if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) {
fd_log_debug(" Local endpoints ........ : Default (use all available)\n");
} else {
struct fd_list * li = fd_g_config->loc_endpoints.next;
struct fd_list * li = fd_g_config->cnf_endpoints.next;
fd_log_debug(" Local endpoints ........ : ");
while (li != &fd_g_config->loc_endpoints) {
while (li != &fd_g_config->cnf_endpoints) {
struct fd_endpoint * ep = (struct fd_endpoint *)li;
if (li != fd_g_config->loc_endpoints.next) fd_log_debug(" ");
if (li != fd_g_config->cnf_endpoints.next) fd_log_debug(" ");
sSA_DUMP_NODE( &ep->ss, NI_NUMERICHOST );
fd_log_debug("\n");
li = li->next;
}
}
fd_log_debug(" Flags : - IP ........... : %s\n", fd_g_config->flags.no_ip4 ? "DISABLED" : "Enabled");
fd_log_debug(" - IPv6 ......... : %s\n", fd_g_config->flags.no_ip6 ? "DISABLED" : "Enabled");
fd_log_debug(" - Relay app .... : %s\n", fd_g_config->flags.no_fwd ? "DISABLED" : "Enabled");
fd_log_debug(" - TCP .......... : %s\n", fd_g_config->flags.no_tcp ? "DISABLED" : "Enabled");
if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_apps)) {
fd_log_debug(" Local applications ..... : (none)\n");
} else {
struct fd_list * li = fd_g_config->cnf_apps.next;
fd_log_debug(" Local applications ..... : ");
while (li != &fd_g_config->cnf_apps) {
struct fd_app * app = (struct fd_app *)li;
if (li != fd_g_config->cnf_apps.next) fd_log_debug(" ");
fd_log_debug("App: %u\t%s%s%s\tVnd: %u\n",
app->appid,
app->flags.auth ? "Au" : "--",
app->flags.acct ? "Ac" : "--",
app->flags.common ? "C" : "-",
app->vndid);
li = li->next;
}
}
fd_log_debug(" Flags : - IP ........... : %s\n", fd_g_config->cnf_flags.no_ip4 ? "DISABLED" : "Enabled");
fd_log_debug(" - IPv6 ......... : %s\n", fd_g_config->cnf_flags.no_ip6 ? "DISABLED" : "Enabled");
fd_log_debug(" - Relay app .... : %s\n", fd_g_config->cnf_flags.no_fwd ? "DISABLED" : "Enabled");
fd_log_debug(" - TCP .......... : %s\n", fd_g_config->cnf_flags.no_tcp ? "DISABLED" : "Enabled");
#ifdef DISABLE_SCTP
fd_log_debug(" - SCTP ......... : DISABLED (at compilation)\n");
#else /* DISABLE_SCTP */
fd_log_debug(" - SCTP ......... : %s\n", fd_g_config->flags.no_sctp ? "DISABLED" : "Enabled");
fd_log_debug(" - SCTP ......... : %s\n", fd_g_config->cnf_flags.no_sctp ? "DISABLED" : "Enabled");
#endif /* DISABLE_SCTP */
fd_log_debug(" - Pref. proto .. : %s\n", fd_g_config->flags.pr_tcp ? "TCP" : "SCTP");
fd_log_debug(" - TLS method ... : %s\n", fd_g_config->flags.tls_alg ? "INBAND" : "Separate port");
fd_log_debug(" Tc Timer ............... : %u\n", fd_g_config->timer_tc);
fd_log_debug(" Tw Timer ............... : %u\n", fd_g_config->timer_tw);
fd_log_debug(" Origin-State-Id ........ : %u\n", fd_g_config->or_state_id);
fd_log_debug(" - Pref. proto .. : %s\n", fd_g_config->cnf_flags.pr_tcp ? "TCP" : "SCTP");
fd_log_debug(" - TLS method ... : %s\n", fd_g_config->cnf_flags.tls_alg ? "INBAND" : "Separate port");
fd_log_debug(" Origin-State-Id ........ : %u\n", fd_g_config->cnf_orstateid);
}
/* Parse the configuration file (using the yacc parser) */
......@@ -112,12 +129,12 @@ int fd_conf_parse()
{
extern FILE * fddin;
TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->conf_file);
TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->cnf_file);
fddin = fopen(fd_g_config->conf_file, "r");
fddin = fopen(fd_g_config->cnf_file, "r");
if (fddin == NULL) {
int ret = errno;
fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->conf_file, strerror(ret));
fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->cnf_file, strerror(ret));
return ret;
}
......@@ -128,7 +145,7 @@ int fd_conf_parse()
fclose(fddin);
/* Resolve hostname if not provided */
if (fd_g_config->diam_id == NULL) {
if (fd_g_config->cnf_diamid == NULL) {
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 1024
#endif /* HOST_NAME_MAX */
......@@ -151,36 +168,36 @@ int fd_conf_parse()
buf, gai_strerror(ret));
return EINVAL;
}
CHECK_MALLOC( fd_g_config->diam_id = strdup(info->ai_canonname) );
CHECK_MALLOC( fd_g_config->cnf_diamid = strdup(info->ai_canonname) );
freeaddrinfo(info);
}
/* cache the length of the diameter id for the session module */
fd_g_config->diam_id_len = strlen(fd_g_config->diam_id);
fd_g_config->cnf_diamid_len = strlen(fd_g_config->cnf_diamid);
/* Handle the realm part */
if (fd_g_config->diam_realm == NULL) {
if (fd_g_config->cnf_diamrlm == NULL) {
char * start = NULL;
/* Check the diameter identity is a fqdn */
start = strchr(fd_g_config->diam_id, '.');
start = strchr(fd_g_config->cnf_diamid, '.');
if ((start == NULL) || (start[1] == '\0')) {
fprintf(stderr, "Unable to extract realm from the LocalIdentity '%s'.\n"
"Please fix your LocalIdentity setting or provide LocalRealm.\n",
fd_g_config->diam_id);
fd_g_config->cnf_diamid);
return EINVAL;
}
CHECK_MALLOC( fd_g_config->diam_realm = strdup( start + 1 ) );
CHECK_MALLOC( fd_g_config->cnf_diamrlm = strdup( start + 1 ) );
}
fd_g_config->diam_realm_len = strlen(fd_g_config->diam_realm);
fd_g_config->cnf_diamrlm_len = strlen(fd_g_config->cnf_diamrlm);
/* Validate some flags */
if (fd_g_config->flags.no_ip4 && fd_g_config->flags.no_ip6) {
if (fd_g_config->cnf_flags.no_ip4 && fd_g_config->cnf_flags.no_ip6) {
fprintf(stderr, "IP and IPv6 cannot be disabled at the same time.\n");
return EINVAL;
}
if (fd_g_config->flags.no_tcp && fd_g_config->flags.no_sctp) {
if (fd_g_config->cnf_flags.no_tcp && fd_g_config->cnf_flags.no_sctp) {
fprintf(stderr, "TCP and SCTP cannot be disabled at the same time.\n");
return EINVAL;
}
......
/*********************************************************************************************************
* Software License Agreement (BSD License) *
* Author: Sebastien Decugis <sdecugis@nict.go.jp> *
* *
* Copyright (c) 2009, 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. *
*********************************************************************************************************/
#include "fD.h"
int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int auth, int acct )
{
vendor_id_t vid = 0;
application_id_t aid = 0;
struct fd_list * li;
int skip = 0;
TRACE_ENTRY("%p %p %d %d", app, vendor, auth, acct);
CHECK_PARAMS( app && (auth || acct) );
{
enum dict_object_type type = 0;
struct dict_application_data data;
CHECK_FCT( fd_dict_gettype(app, &type) );
CHECK_PARAMS( type == DICT_APPLICATION );
CHECK_FCT( fd_dict_getval(app, &data) );
aid = data.application_id;
}
/* Now insert in the list ordered by appid. Avoid duplicates */
for (li = &fd_g_config->cnf_apps; li->next != &fd_g_config->cnf_apps; li = li->next) {
struct fd_app * na = (struct fd_app *)(li->next);
if (na->appid < aid)
continue;
if (na->appid > aid)
break;
/* Otherwise, we merge with existing entry -- ignore vendor id in this case */
skip = 1;
if (auth)
na->flags.auth = 1;
if (acct)
na->flags.acct = 1;
break;
}
if (!skip) {
struct fd_app * new = NULL;
if (vendor) {
enum dict_object_type type = 0;
struct dict_vendor_data data;
CHECK_FCT( fd_dict_gettype(vendor, &type) );
CHECK_PARAMS( type == DICT_VENDOR );
CHECK_FCT( fd_dict_getval(vendor, &data) );
vid = data.vendor_id;
}
CHECK_MALLOC( new = malloc(sizeof(struct fd_app)) );
memset(new, 0, sizeof(struct fd_app));
fd_list_init(&new->chain, NULL);
new->flags.auth = (auth ? 1 : 0);
new->flags.acct = (acct ? 1 : 0);
new->vndid = vid;
new->appid = aid;
fd_list_insert_after(li, &new->chain);
}
return 0;
}
......@@ -80,6 +80,20 @@ int fd_ext_add( char * filename, char * conffile )
return 0;
}
/* Dump the list */
void fd_ext_dump(void)
{
struct fd_list * li;
fd_log_debug("Dumping extensions list :\n");
for (li = ext_list.next; li != &ext_list; li = li->next)
{
struct fd_ext_info * ext = (struct fd_ext_info *)li;
fd_log_debug(" - '%s'[%s] is %sloaded\n", ext->filename, ext->conffile?:"no conf", ext->handler ? "" : "not ");
}
}
/* Load all extensions in the list */
int fd_ext_load()
{
......
......@@ -41,11 +41,6 @@
#include <freeDiameter/freeDiameter-host.h>
#include <freeDiameter/freeDiameter.h>
/* Events codespace for fd_g_config->g_fifo_main */
enum {
FM_TERMINATE = 1000 /* request to terminate */
};
/* Configuration */
int fd_conf_init();
void fd_conf_dump();
......@@ -56,8 +51,20 @@ int fddparse(struct fd_config * conf); /* yacc generated */
int fd_ext_init();
int fd_ext_add( char * filename, char * conffile );
int fd_ext_load();
void fd_ext_dump(void);
int fd_ext_fini(void);
/* Messages */
int fd_msg_init(void);
/* Global message queues */
extern struct fifo * fd_g_incoming; /* all messages received from other peers, except local messages (CER, ...) */
extern struct fifo * fd_g_outgoing; /* messages to be sent to other peers on the network following routing procedure */
extern struct fifo * fd_g_local; /* messages to be handled to local extensions */
/* Message queues */
int fd_queues_init(void);
int fd_queues_fini(void);
/* Create all the dictionary objects defined in the Diameter base RFC. */
int fd_dict_base_protocol(struct dictionary * dict);
......