Commit 7b1b8ec8 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

New extension mechanism committed

parent 4767c880
......@@ -22,6 +22,9 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# 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)
......
......@@ -128,5 +128,5 @@ ListenOn = "2001:200:903:2::202:1";
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";
......@@ -2,11 +2,15 @@ PROJECT("freeDiameter extensions" C)
# 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
......
......@@ -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)
......@@ -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 ;
}
......@@ -55,7 +55,7 @@ static int sample_main(char * conffile)
}
/* 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 @@ static int sample_main(char * conffile)
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;
}
......@@ -96,7 +96,12 @@ int fd_ext_load()
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());
......
......@@ -246,7 +246,8 @@ end:
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;
}
......@@ -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@
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment