Index: extensions/CMakeLists.txt
===================================================================
--- extensions/CMakeLists.txt	(revision 600)
+++ extensions/CMakeLists.txt	(revision 609)
@@ -86,4 +86,5 @@
 FD_EXTENSION_SUBDIR(test_app    "Testing application to send dummy message to another peer, like a Diameter 'ping'" OFF)
 FD_EXTENSION_SUBDIR(test_sip    "Testing application to simulate Diameter-SIP client (RFC4740)" OFF)
+FD_EXTENSION_SUBDIR(dbg_interactive "Python-interpreter based module"                OFF)
 
 
Index: extensions/dbg_interactive/CMakeLists.txt
===================================================================
--- extensions/dbg_interactive/CMakeLists.txt	(revision 609)
+++ extensions/dbg_interactive/CMakeLists.txt	(revision 609)
@@ -0,0 +1,22 @@
+# The rt_debug extension
+PROJECT("Interactive debug facility based on SWIG" C)
+
+
+# This module is using Python
+FIND_PACKAGE(PythonLibs)
+INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+
+##### 
+# Wrapper to fD in python
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(${SWIG_USE_FILE})
+SET(CMAKE_SWIG_FLAGS "")
+
+# We create the module even if we don't use it, so that intermediate values are defined
+SWIG_ADD_MODULE(diwrap python diwrap.i)
+
+#####
+# Extension that embeds the python interpreter
+FD_ADD_EXTENSION(dbg_interactive dbg_interactive.c ${swig_generated_sources} ${swig_other_sources})
+TARGET_LINK_LIBRARIES(dbg_interactive ${PYTHON_LIBRARIES})
+
Index: extensions/dbg_interactive/dbg_interactive.c
===================================================================
--- extensions/dbg_interactive/dbg_interactive.c	(revision 609)
+++ extensions/dbg_interactive/dbg_interactive.c	(revision 609)
@@ -0,0 +1,97 @@
+/*********************************************************************************************************
+* Software License Agreement (BSD License)                                                               *
+* Author: Sebastien Decugis <sdecugis@nict.go.jp>							 *
+*													 *
+* Copyright (c) 2010, 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 <Python.h>
+#include <freeDiameter/extension.h>
+
+/* wrapper generated by SWIG */
+extern void init_diwrap(void);
+
+/* Run an interactive interpreter in a separate thread */
+static pthread_t pyinterp = (pthread_t)NULL;
+static void * myinterp (void * arg)
+{
+	char * dum[2] = { arg, NULL };
+	TRACE_ENTRY("%p", arg);
+	
+	sleep(1);
+	fd_log_debug("\nStarting python interpreter [experimental].\n");
+	fd_log_debug("Example syntax:\n>>> print fd_config_cnf_diamid_get(cvar.fd_g_config)\n\n");
+	Py_Main(arg ? 1 : 0, dum);
+	
+	/* Upon exit, issue the order of terminating to fD */
+	CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
+
+	return NULL;
+}
+
+/* Register the callbacks to the daemon */
+static int di_main(char * conffile)
+{
+	TRACE_ENTRY("%p", conffile);
+	
+	Py_Initialize();
+	init_diwrap();
+	
+	PyRun_SimpleString("from _diwrap import *\n");
+	if (TRACE_BOOL(INFO)) {
+		PyRun_SimpleString("print \"[dbg_interactive] fD \",FD_PROJECT_VERSION_MAJOR,\".\",FD_PROJECT_VERSION_MINOR,\".\",FD_PROJECT_VERSION_REV\n");
+	}
+	
+	/*
+	PyRun_SimpleString("config = cvar.fd_g_config\n");
+	PyRun_SimpleString("dict = fd_config_cnf_dict_get(config)\n");
+	PyRun_SimpleString("fd_dict_dump(dict)\n");
+	*/
+	CHECK_POSIX( pthread_create(&pyinterp, NULL, myinterp, conffile) );
+ 
+	return 0;
+}
+
+/* Terminate the extension */
+void fd_ext_fini(void)
+{
+	TRACE_ENTRY();
+	
+	CHECK_FCT_DO(fd_thr_term(&pyinterp), );
+	
+	/* Cleanup the python interpreter */
+	Py_Finalize();
+	
+	return ;
+}
+
+/* Define the entry point function */
+EXTENSION_ENTRY("dbg_interactive", di_main);
Index: extensions/dbg_interactive/diwrap.i
===================================================================
--- extensions/dbg_interactive/diwrap.i	(revision 609)
+++ extensions/dbg_interactive/diwrap.i	(revision 609)
@@ -0,0 +1,46 @@
+/*********************************************************************************************************
+* Software License Agreement (BSD License)                                                               *
+* Author: Sebastien Decugis <sdecugis@nict.go.jp>							 *
+*													 *
+* Copyright (c) 2010, 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.								 *
+*********************************************************************************************************/
+
+%module diwrap
+%{
+/* include the header in the wrapper code */
+#include <freeDiameter/extension.h>
+%}
+
+/* Parse the header to generate the wrappers */
+%include "freeDiameter/freeDiameter-host.h"
+%include "freeDiameter/libfreeDiameter.h"
+%include "freeDiameter/freeDiameter.h"
+
Index: include/freeDiameter/libfreeDiameter.h
===================================================================
--- include/freeDiameter/libfreeDiameter.h	(revision 602)
+++ include/freeDiameter/libfreeDiameter.h	(revision 609)
@@ -570,4 +570,5 @@
 /*                          THREADS                           */
 /*============================================================*/
+#ifndef SWIG
 
 /* Terminate a thread */
@@ -633,4 +634,5 @@
 }
 
+#endif /* SWIG */
 
 /*============================================================*/
