- Reworked handling of plugin mechanism (libltdl "static"
inclusion of plugins should work now). Building under Windows (with Cygwin) does work (build with ./configure --enable-static-libosip2).
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
0.7.2
|
||||
=====
|
||||
22-Feb-2009: - Reworked handling of plugin mechanism (libltdl "static"
|
||||
inclusion of plugins should work now). Building under
|
||||
Windows (with Cygwin) does work (build with
|
||||
./configure --enable-static-libosip2).
|
||||
11-Feb-2009: - Don't abort RTP streams on ENOBUFS (Internet upstream
|
||||
saturated and a Packet is dropped)
|
||||
24-Jan-2009: - fixed an issue with RTP timeouts (on calls with multiple
|
||||
|
||||
+1
-1
@@ -304,7 +304,7 @@
|
||||
/* type osip_MD5_CTX */
|
||||
#undef osip_MD5_CTX
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* typedef socklen_t available */
|
||||
|
||||
+13
-5
@@ -40,6 +40,8 @@ dnl 10-Jun-2007 tries test more .h files (DNS resolver related)
|
||||
dnl 18-Dec-2007 tries requires libosip2-3.x.x
|
||||
dnl 02-Feb-2008 tries removed variety of fli4l and static extra
|
||||
dnl build options
|
||||
dnl 21-Feb-2009 tries --enable-static-libosip2 does search static
|
||||
dnl libs now in libosip_prefix_dir
|
||||
dnl
|
||||
dnl
|
||||
|
||||
@@ -278,8 +280,9 @@ else
|
||||
dnl link statically to this lib
|
||||
dnl (this probably only will work on linux yet...)
|
||||
AC_MSG_CHECKING("where I can find libosip2.a")
|
||||
libosip_static=`find $extra_libs /lib /usr/lib /usr/local/lib \
|
||||
-name libosip2.a 2>/dev/null|head -1`
|
||||
libosip_static=`find $extra_libs $libosip_prefix_dir/lib /lib \
|
||||
/usr/lib /usr/local/lib \
|
||||
-name libosip2.a 2>/dev/null|head -1`
|
||||
if test "x$libosip_static" != "x"; then
|
||||
LIBS="$libosip_static $LIBS"
|
||||
AC_MSG_RESULT($libosip_static)
|
||||
@@ -287,8 +290,9 @@ else
|
||||
echo "*** ERROR: a static libosip library is required!";exit 1;
|
||||
fi
|
||||
AC_MSG_CHECKING("where I can find libosipparser2.a")
|
||||
libosip_static=`find $extra_libs /lib /usr/lib /usr/local/lib \
|
||||
-name libosipparser2.a 2>/dev/null|head -1`
|
||||
libosip_static=`find $extra_libs $libosip_prefix_dir/lib /lib \
|
||||
/usr/lib /usr/local/lib \
|
||||
-name libosipparser2.a 2>/dev/null|head -1`
|
||||
if test "x$libosip_static" != "x"; then
|
||||
LIBS="$libosip_static $LIBS"
|
||||
AC_MSG_RESULT($libosip_static)
|
||||
@@ -344,7 +348,11 @@ AC_CHECK_DECL(SOL_IP,
|
||||
[[$ac_includes_default]
|
||||
[#ifdef HAVE_NETDB_H]
|
||||
[#include <netdb.h>]
|
||||
[#endif]]
|
||||
[#endif]
|
||||
[#ifdef HAVE_SYS_SOCKET_H]
|
||||
[#include <sys/socket.h>]
|
||||
[#endif]
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
||||
+16
-9
@@ -520,15 +520,22 @@ debug_port = 0
|
||||
<?dbhtml filename="siproxd_guide_c5s1.html">
|
||||
<title>Plug-in API</title>
|
||||
<para>Siproxd plug-ins are dynamic loadable libraries and must provide
|
||||
3 functions towards siproxd:
|
||||
3 functions towards siproxd. As we make use of some libltdl features
|
||||
we do some internal macor magic - the PLUGIN_xxx funcation names
|
||||
are actually CPP macros that will expand in unique names. Th have
|
||||
this working properly the PLUGIN_NAME must be #defined before
|
||||
the plugins.h header file is included:
|
||||
</para>
|
||||
<screen>
|
||||
int plugin_init(plugin_def_t *plugin_def);
|
||||
int plugin_process(int stage, sip_ticket_t *ticket);
|
||||
int plugin_end(plugin_def_t *plugin_def);
|
||||
#define PLUGIN_NAME plugin_myplugin
|
||||
#include "plugins.h"
|
||||
[...]
|
||||
int PLUGIN_INIT(plugin_def_t *plugin_def);
|
||||
int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket);
|
||||
int PLUGIN_END(plugin_def_t *plugin_def);
|
||||
</screen>
|
||||
<para>
|
||||
The <filename>plugin_init</filename> function is called when
|
||||
The <filename>PLUGIN_INIT</filename> function is called when
|
||||
the plug-in is loaded during startup of siproxd. The plug-in must
|
||||
define the following 4 fields of the plugin_def structure:
|
||||
<orderedlist numeration="arabic">
|
||||
@@ -557,12 +564,12 @@ plugin_def->desc=strdup("This is just a demo plugin without any purpose");
|
||||
plugin_def->exe_mask=PLUGIN_DETERMINE_TARGET|PLUGIN_PRE_PROXY;
|
||||
</screen>
|
||||
<para>
|
||||
The <filename>plugin_process</filename> function is called at
|
||||
The <filename>PLUGIN_PROCESS</filename> function is called at
|
||||
the requested SIP processing stages (see 'execution mask').
|
||||
Your processing will be done here.
|
||||
</para>
|
||||
<para>
|
||||
The <filename>plugin_end</filename> function is called at
|
||||
The <filename>PLUGIN_END</filename> function is called at
|
||||
shutdown of siproxd and gives the plug-in the opportunity
|
||||
to clean up and properly shutdown itself.</para>
|
||||
<para>Note: The previously allocated 'name' and 'desc' must be
|
||||
@@ -571,7 +578,7 @@ plugin_def->exe_mask=PLUGIN_DETERMINE_TARGET|PLUGIN_PRE_PROXY;
|
||||
<para>
|
||||
Minimum required clean up procedure:
|
||||
<screen>
|
||||
int plugin_end(plugin_def_t *plugin_def){
|
||||
int PLUGIN_END(plugin_def_t *plugin_def){
|
||||
/* free my allocated rescources (if allocated via malloc only) */
|
||||
if (plugin_def->name) {free(plugin_def->name); plugin_def->name=NULL;}
|
||||
if (plugin_def->desc) {free(plugin_def->desc); plugin_def->desc=NULL;}
|
||||
@@ -647,7 +654,7 @@ plugin_demo_string = This_is_a_string_passed_to_the_demo_plugin
|
||||
none
|
||||
</screen>
|
||||
<para>Description:</para>
|
||||
<para>XXXXXXXXXXXXXXXXxThe numbering starts with "1" ("*01") and every following
|
||||
<para>The numbering starts with "1" ("*01") and every following
|
||||
"plugin_shortdial_entry" entry will allocate the following position.
|
||||
It is not possible to freely assign the positions.</para>
|
||||
</sect2>
|
||||
|
||||
+12
-6
@@ -27,7 +27,7 @@ AM_CFLAGS = -Wall -D_GNU_SOURCE \
|
||||
#
|
||||
sbin_PROGRAMS = siproxd
|
||||
siproxd_LDFLAGS=-export-dynamic
|
||||
siproxd_LDADD = $(LIBLTDL)
|
||||
siproxd_LDADD = $(LIBLTDL) $(DLOPENPLUGINS)
|
||||
siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \
|
||||
sip_utils.c sip_layer.c log.c readconf.c rtpproxy.c \
|
||||
rtpproxy_relay.c accessctl.c route_processing.c \
|
||||
@@ -35,6 +35,7 @@ siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \
|
||||
dejitter.c plugins.c
|
||||
# addrcache.c
|
||||
|
||||
|
||||
#
|
||||
# Plugin modules, installed in "pkglib" directory ($prefix/lib/siproxd/)
|
||||
#
|
||||
@@ -43,21 +44,26 @@ pkglib_LTLIBRARIES = plugin_demo.la \
|
||||
plugin_logcall.la \
|
||||
plugin_defaulttarget.la \
|
||||
plugin_fix_bogus_via.la
|
||||
DLOPENPLUGINS = -dlopen plugin_demo.la \
|
||||
-dlopen plugin_shortdial.la \
|
||||
-dlopen plugin_logcall.la \
|
||||
-dlopen plugin_defaulttarget.la \
|
||||
-dlopen plugin_fix_bogus_via.la
|
||||
#
|
||||
plugin_demo_la_SOURCES = plugin_demo.c
|
||||
plugin_demo_la_LDFLAGS = -module
|
||||
plugin_demo_la_LDFLAGS = -module -avoid-version -shrext '.so'
|
||||
#
|
||||
plugin_shortdial_la_SOURCES = plugin_shortdial.c
|
||||
plugin_shortdial_la_LDFLAGS = -module
|
||||
plugin_shortdial_la_LDFLAGS = -module -avoid-version -shrext '.so'
|
||||
#
|
||||
plugin_logcall_la_SOURCES = plugin_logcall.c
|
||||
plugin_logcall_la_LDFLAGS = -module
|
||||
plugin_logcall_la_LDFLAGS = -module -avoid-version -shrext '.so'
|
||||
#
|
||||
plugin_defaulttarget_la_SOURCES = plugin_defaulttarget.c
|
||||
plugin_defaulttarget_la_LDFLAGS = -module
|
||||
plugin_defaulttarget_la_LDFLAGS = -module -avoid-version -shrext '.so'
|
||||
#
|
||||
plugin_fix_bogus_via_la_SOURCES = plugin_fix_bogus_via.c
|
||||
plugin_fix_bogus_via_la_LDFLAGS = -module
|
||||
plugin_fix_bogus_via_la_LDFLAGS = -module -avoid-version -shrext '.so'
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* must be defined before including <plugin.h> */
|
||||
#define PLUGIN_NAME plugin_defaulttarget
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -65,7 +68,7 @@ static int plugin_defaulttarget_redirect(sip_ticket_t *ticket);
|
||||
* Initialization.
|
||||
* Called once suring siproxd startup.
|
||||
*/
|
||||
int plugin_init(plugin_def_t *plugin_def) {
|
||||
int PLUGIN_INIT(plugin_def_t *plugin_def) {
|
||||
|
||||
/* API version number of siproxd that this plugin is built against.
|
||||
* This constant will change whenever changes to the API are made
|
||||
@@ -105,7 +108,7 @@ int plugin_init(plugin_def_t *plugin_def) {
|
||||
* Processing.
|
||||
*
|
||||
*/
|
||||
int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
|
||||
/* stage contains the PLUGIN_* value - the stage of SIP processing. */
|
||||
int sts;
|
||||
|
||||
@@ -153,7 +156,7 @@ int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
* to clean up its mess (e.g. dynamic memory allocation, database
|
||||
* connections, whatever the plugin messes around with)
|
||||
*/
|
||||
int plugin_end(plugin_def_t *plugin_def){
|
||||
int PLUGIN_END(plugin_def_t *plugin_def){
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -18,6 +18,9 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* must be defined before including <plugin.h> */
|
||||
#define PLUGIN_NAME plugin_demo
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -32,6 +35,7 @@
|
||||
#include "plugins.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
static char const ident[]="$Id$";
|
||||
|
||||
/* Plug-in identification */
|
||||
@@ -57,7 +61,7 @@ static cfgopts_t plugin_cfg_opts[] = {
|
||||
* Initialization.
|
||||
* Called once suring siproxd startup.
|
||||
*/
|
||||
int plugin_init(plugin_def_t *plugin_def) {
|
||||
int PLUGIN_INIT(plugin_def_t *plugin_def) {
|
||||
/* API version number of siproxd that this plugin is built against.
|
||||
* This constant will change whenever changes to the API are made
|
||||
* that require adaptions in the plugin. */
|
||||
@@ -87,7 +91,7 @@ int plugin_init(plugin_def_t *plugin_def) {
|
||||
* Processing.
|
||||
*
|
||||
*/
|
||||
int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
|
||||
/* stage contains the PLUGIN_* value - the stage of SIP processing. */
|
||||
INFO("plugin_demo: processing - stage %i",stage);
|
||||
return STS_SUCCESS;
|
||||
@@ -99,7 +103,7 @@ int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
* to clean up its mess (e.g. dynamic memory allocation, database
|
||||
* connections, whatever the plugin messes around with)
|
||||
*/
|
||||
int plugin_end(plugin_def_t *plugin_def){
|
||||
int PLUGIN_END(plugin_def_t *plugin_def){
|
||||
INFO("plugin_demo ends here");
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* must be defined before including <plugin.h> */
|
||||
#define PLUGIN_NAME plugin_fix_bogus_via
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -60,7 +63,7 @@ static int sip_patch_topvia(sip_ticket_t *ticket);
|
||||
* Initialization.
|
||||
* Called once suring siproxd startup.
|
||||
*/
|
||||
int plugin_init(plugin_def_t *plugin_def) {
|
||||
int PLUGIN_INIT(plugin_def_t *plugin_def) {
|
||||
/* API version number of siproxd that this plugin is built against.
|
||||
* This constant will change whenever changes to the API are made
|
||||
* that require adaptions in the plugin. */
|
||||
@@ -90,7 +93,7 @@ int plugin_init(plugin_def_t *plugin_def) {
|
||||
* Processing.
|
||||
*
|
||||
*/
|
||||
int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
|
||||
/* stage contains the PLUGIN_* value - the stage of SIP processing. */
|
||||
int type;
|
||||
osip_via_t *via;
|
||||
@@ -129,7 +132,7 @@ DEBUGC(DBCLASS_PLUGIN, "plugin_fix_bogus_via: type=%i", type);
|
||||
* to clean up its mess (e.g. dynamic memory allocation, database
|
||||
* connections, whatever the plugin messes around with)
|
||||
*/
|
||||
int plugin_end(plugin_def_t *plugin_def){
|
||||
int PLUGIN_END(plugin_def_t *plugin_def){
|
||||
INFO("plugin_fix_bogus_via ends here");
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* must be defined before including <plugin.h> */
|
||||
#define PLUGIN_NAME plugin_logcall
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -46,7 +49,7 @@ extern struct siproxd_config configuration;
|
||||
* Initialization.
|
||||
* Called once suring siproxd startup.
|
||||
*/
|
||||
int plugin_init(plugin_def_t *plugin_def) {
|
||||
int PLUGIN_INIT(plugin_def_t *plugin_def) {
|
||||
/* API version number of siproxd that this plugin is built against.
|
||||
* This constant will change whenever changes to the API are made
|
||||
* that require adaptions in the plugin. */
|
||||
@@ -67,7 +70,7 @@ int plugin_init(plugin_def_t *plugin_def) {
|
||||
* Processing.
|
||||
*
|
||||
*/
|
||||
int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
|
||||
osip_message_t *request;
|
||||
osip_uri_t *from_url = NULL;
|
||||
osip_uri_t *to_url = NULL;
|
||||
@@ -126,7 +129,7 @@ int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
* to clean up its mess (e.g. dynamic memory allocation, database
|
||||
* connections, whatever the plugin messes around with)
|
||||
*/
|
||||
int plugin_end(plugin_def_t *plugin_def){
|
||||
int PLUGIN_END(plugin_def_t *plugin_def){
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* must be defined before including <plugin.h> */
|
||||
#define PLUGIN_NAME plugin_shortdial
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -66,7 +69,7 @@ static int plugin_shortdial(sip_ticket_t *ticket);
|
||||
* Plugin API functions code
|
||||
*/
|
||||
/* Initialization */
|
||||
int plugin_init(plugin_def_t *plugin_def) {
|
||||
int PLUGIN_INIT(plugin_def_t *plugin_def) {
|
||||
plugin_def->api_version=SIPROXD_API_VERSION;
|
||||
plugin_def->name=name;
|
||||
plugin_def->desc=desc;
|
||||
@@ -84,14 +87,14 @@ int plugin_init(plugin_def_t *plugin_def) {
|
||||
}
|
||||
|
||||
/* Processing */
|
||||
int plugin_process(int stage, sip_ticket_t *ticket){
|
||||
int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
|
||||
int sts;
|
||||
sts=plugin_shortdial(ticket);
|
||||
return sts;
|
||||
}
|
||||
|
||||
/* De-Initialization */
|
||||
int plugin_end(plugin_def_t *plugin_def){
|
||||
int PLUGIN_END(plugin_def_t *plugin_def){
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ int load_plugins (void) {
|
||||
func_plugin_end_t plugin_end = NULL;
|
||||
|
||||
/* initialize the libtool dynamic loader */
|
||||
LTDL_SET_PRELOADED_SYMBOLS();
|
||||
sts = lt_dlinit();
|
||||
if (sts != 0) {
|
||||
ERROR("ltdl (libtool dynamic loader) initialization failed.");
|
||||
@@ -151,6 +152,7 @@ int load_plugins (void) {
|
||||
/* complain and dlclose the handle...*/
|
||||
ERROR("plugin %s does not provide correct API functions - skipped",
|
||||
configuration.load_plugin.string[i]);
|
||||
INFO("make sure to specify plugin_<name>.la to load and not the .so!");
|
||||
lt_dlclose(handle);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -58,7 +58,7 @@ typedef struct {
|
||||
lt_ptr dlhandle; /* handle returned by dlopen() */
|
||||
} plugin_def_t;
|
||||
|
||||
#define SIPROXD_API_VERSION 0x0100
|
||||
#define SIPROXD_API_VERSION 0x0101
|
||||
|
||||
|
||||
/* The plugin must provide the following entry points */
|
||||
@@ -80,3 +80,14 @@ typedef struct {
|
||||
int plugin_init(plugin_def_t *plugin_def);
|
||||
int plugin_process(int stage, sip_ticket_t *ticket);
|
||||
int plugin_end(plugin_def_t *plugin_def);
|
||||
|
||||
/* libltdl symbol name magic...
|
||||
convert plugin_init into <module>_LTX_plugin_init */
|
||||
|
||||
#if defined (PLUGIN_NAME)
|
||||
#define JOIN(x, y) JOIN_AGAIN(x, y)
|
||||
#define JOIN_AGAIN(x, y) x ## y
|
||||
#define PLUGIN_INIT JOIN(PLUGIN_NAME, _LTX_plugin_init)
|
||||
#define PLUGIN_PROCESS JOIN(PLUGIN_NAME, _LTX_plugin_process)
|
||||
#define PLUGIN_END JOIN(PLUGIN_NAME, _LTX_plugin_end)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user