Mercurial > hg > freeDiameter
changeset 9:fc7c18867cf7
New extension mechanism committed
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 24 Sep 2009 14:01:48 +0900 |
parents | 3e143f047f78 |
children | c5c99c73c2bf |
files | CMakeLists.txt doc/freediameter.conf.sample extensions/CMakeLists.txt extensions/_sample/CMakeLists.txt extensions/_sample/fini.c extensions/_sample/sample.c freeDiameter/extensions.c freeDiameter/main.c include/freeDiameter/freeDiameter-host.h.in |
diffstat | 9 files changed, 26 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Fri Sep 18 18:54:07 2009 +0900 +++ b/CMakeLists.txt Thu Sep 24 14:01:48 2009 +0900 @@ -22,6 +22,9 @@ # All source code should be POSIX 200112L compatible, but some other extensions might be used, so: ADD_DEFINITIONS(-D_GNU_SOURCE) +IF (CMAKE_BUILD_TYPE MATCHES "Debug") + SET(DEBUG 1) +ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug") # some subfolders use yacc and lex parsers SET(BISON_GENERATE_DEFINES TRUE)
--- a/doc/freediameter.conf.sample Fri Sep 18 18:54:07 2009 +0900 +++ b/doc/freediameter.conf.sample Thu Sep 24 14:01:48 2009 +0900 @@ -128,5 +128,5 @@ TcTimer = 60; TwTimer = 6; NoRelay; -LoadExtension = "extensions/sample.so"; -LoadExtension = "extensions/sample.so":"conf/sample.conf"; +#LoadExtension = "extensions/sample.fdx"; +LoadExtension = "extensions/sample.fdx":"conf/sample.conf";
--- a/extensions/CMakeLists.txt Fri Sep 18 18:54:07 2009 +0900 +++ b/extensions/CMakeLists.txt Thu Sep 24 14:01:48 2009 +0900 @@ -2,11 +2,15 @@ # We want all resulting objects in the same folder SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -# And named fdext_XXX instead of libXXX.so -#-- faire une macro ici! -SET(FD_EXT_PREFIX "fdext_" PARENT_SCOPE) -SET(FD_EXT_SUFFIX "" PARENT_SCOPE) +# Use the macro FD_ADD_EXTENSION(name files...) to create an extension +# It is equivalent to add_library with the appropriate parameters +# and naming conventions (.fdx : FreeDiameter eXtension) +MACRO(FD_ADD_EXTENSION EXTNAME) + ADD_LIBRARY(${EXTNAME} MODULE ${ARGN}) + SET_TARGET_PROPERTIES(${EXTNAME} PROPERTIES PREFIX "" ) + SET_TARGET_PROPERTIES(${EXTNAME} PROPERTIES SUFFIX ".fdx" ) +ENDMACRO(FD_ADD_EXTENSION) ########################### # Extensions section
--- a/extensions/_sample/CMakeLists.txt Fri Sep 18 18:54:07 2009 +0900 +++ b/extensions/_sample/CMakeLists.txt Thu Sep 24 14:01:48 2009 +0900 @@ -2,8 +2,4 @@ PROJECT("Sample extension" C) # Compile as a module -ADD_LIBRARY(sample MODULE sample.c fini.c) - -# Comply to naming scheme -SET_TARGET_PROPERTIES(sample PROPERTIES PREFIX "${FD_EXT_PREFIX}" ) -SET_TARGET_PROPERTIES(sample PROPERTIES SUFFIX "${FD_EXT_SUFFIX}" ) +FD_ADD_EXTENSION(sample sample.c fini.c)
--- a/extensions/_sample/fini.c Fri Sep 18 18:54:07 2009 +0900 +++ b/extensions/_sample/fini.c Thu Sep 24 14:01:48 2009 +0900 @@ -39,7 +39,7 @@ void fd_ext_fini(void) { - log_debug("Extension is terminated... Bye!\n"); + fd_log_debug("Extension is terminated... Bye!\n"); return ; }
--- a/extensions/_sample/sample.c Fri Sep 18 18:54:07 2009 +0900 +++ b/extensions/_sample/sample.c Thu Sep 24 14:01:48 2009 +0900 @@ -55,7 +55,7 @@ } /* Use the dictionary for test */ - log_debug("Let's create that 'Example-AVP'...\n"); + fd_log_debug("Let's create that 'Example-AVP'...\n"); { struct dict_object * origin_host_avp = NULL; struct dict_object * session_id_avp = NULL; @@ -78,7 +78,7 @@ rule_data.rule_max = -1; CHECK_FCT( fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL )); } - log_debug("'Example-AVP' created without error\n"); + fd_log_debug("'Example-AVP' created without error\n"); return 0; }
--- a/freeDiameter/extensions.c Fri Sep 18 18:54:07 2009 +0900 +++ b/freeDiameter/extensions.c Thu Sep 24 14:01:48 2009 +0900 @@ -96,7 +96,12 @@ TRACE_DEBUG (INFO, "Loading : %s", ext->filename); /* Load the extension */ +#ifndef DEBUG ext->handler = dlopen(ext->filename, RTLD_LAZY | RTLD_GLOBAL); +#else /* DEBUG */ + /* We resolve immediatly so it's easier to find problems in ABI */ + ext->handler = dlopen(ext->filename, RTLD_NOW | RTLD_GLOBAL); +#endif /* DEBUG */ if (ext->handler == NULL) { /* An error occured */ TRACE_DEBUG( NONE, "Loading of extension %s failed:\n %s\n", ext->filename, dlerror());
--- a/freeDiameter/main.c Fri Sep 18 18:54:07 2009 +0900 +++ b/freeDiameter/main.c Thu Sep 24 14:01:48 2009 +0900 @@ -246,7 +246,8 @@ TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon is stopping..."); /* cleanups */ - CHECK_FCT( fd_thr_term(&sig_th) ); + CHECK_FCT_DO( fd_ext_fini(), /* continue */ ); + CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ ); return ret; }
--- a/include/freeDiameter/freeDiameter-host.h.in Fri Sep 18 18:54:07 2009 +0900 +++ b/include/freeDiameter/freeDiameter-host.h.in Thu Sep 24 14:01:48 2009 +0900 @@ -45,6 +45,8 @@ #cmakedefine DISABLE_SCTP +#cmakedefine DEBUG + #cmakedefine FD_PROJECT_BINARY "@FD_PROJECT_BINARY@" #cmakedefine FD_PROJECT_NAME "@FD_PROJECT_NAME@" #cmakedefine FD_PROJECT_VERSION_MAJOR @FD_PROJECT_VERSION_MAJOR@