diff --git a/src/plugin_defaulttarget.c b/src/plugin_defaulttarget.c index 2951414..fe4d46e 100644 --- a/src/plugin_defaulttarget.c +++ b/src/plugin_defaulttarget.c @@ -52,8 +52,8 @@ static struct plugin_config { /* Instructions for config parser */ static cfgopts_t plugin_cfg_opts[] = { - { "plugin_defaulttarget_target", TYP_STRING, &plugin_cfg.target }, - { "plugin_defaulttarget_log", TYP_INT4, &plugin_cfg.log }, + { "plugin_defaulttarget_target", TYP_STRING, &plugin_cfg.target, {0, NULL} }, + { "plugin_defaulttarget_log", TYP_INT4, &plugin_cfg.log, {0, NULL} }, {0, 0, 0} }; /* local storage */ diff --git a/src/plugin_demo.c b/src/plugin_demo.c index 21ec7dd..c0b72ee 100644 --- a/src/plugin_demo.c +++ b/src/plugin_demo.c @@ -52,7 +52,7 @@ static struct plugin_config { /* Instructions for config parser */ static cfgopts_t plugin_cfg_opts[] = { - { "plugin_demo_string", TYP_STRING, &plugin_cfg.string }, + { "plugin_demo_string", TYP_STRING, &plugin_cfg.string, {0, NULL} }, {0, 0, 0} }; diff --git a/src/plugin_shortdial.c b/src/plugin_shortdial.c index 8fa7e71..cfa4a2f 100644 --- a/src/plugin_shortdial.c +++ b/src/plugin_shortdial.c @@ -54,8 +54,8 @@ static struct plugin_config { } plugin_cfg; /* Instructions for config parser */ static cfgopts_t plugin_cfg_opts[] = { - { "plugin_shortdial_akey", TYP_STRING, &plugin_cfg.shortdial_akey }, - { "plugin_shortdial_entry", TYP_STRINGA,&plugin_cfg.shortdial_entry }, + { "plugin_shortdial_akey", TYP_STRING, &plugin_cfg.shortdial_akey, {0, NULL} }, + { "plugin_shortdial_entry", TYP_STRINGA,&plugin_cfg.shortdial_entry, {0, NULL} }, {0, 0, 0} }; @@ -179,7 +179,7 @@ static int plugin_shortdial_redirect(sip_ticket_t *ticket, int shortcut_no) { char *new_to_host=NULL; int i; size_t username_len; - size_t host_len; + size_t host_len=0; osip_contact_t *contact = NULL; new_to_user=plugin_cfg.shortdial_entry.string[shortcut_no-1]; diff --git a/src/plugins.c b/src/plugins.c index 56280bd..395df8b 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2008 Thomas Ries + Copyright (C) 2003-2009 Thomas Ries This file is part of Siproxd. @@ -168,8 +168,9 @@ int call_plugins(int stage, sip_ticket_t *ticket) { int sts; func_plugin_process_t plugin_process; - /* sanity check, beware pluigins from crappy stuff */ - if (!ticket || !ticket->sipmsg) return STS_FAILURE; + /* sanity check, beware plugins from crappy stuff + * applies when SIP message has been parsed */ + if ((stage > PLUGIN_PROCESS_RAW) && (!ticket || !ticket->sipmsg)) return STS_FAILURE; /* for each plugin in plugins, do */ for (cur=siproxd_plugins; cur != NULL; cur = cur->next) { @@ -178,14 +179,36 @@ int call_plugins(int stage, sip_ticket_t *ticket) { plugin_process=cur->plugin_process; sts=(*plugin_process)(stage, ticket); switch (stage) { + /* PLUGIN_PROCESS_RAW can be prematurely ended by plugin - + plugin determines that the UDP message is to be discarded */ + case (PLUGIN_PROCESS_RAW): + /* return with the plugins status back to the caller */ + if (sts == STS_FAILURE) { + DEBUGC(DBCLASS_PLUGIN, "call_plugins: PLUGIN_PROCESS_RAW " + "prematurely ending plugin processing in module " + "%s sts=STS_FAILURE", cur->name); + return sts; + } + break; + /* PLUGIN_VALIDATE can be prematurely ended by plugin - + plugin determines that the UDP message is to be discarded */ + case (PLUGIN_VALIDATE): + /* return with the plugins status back to the caller */ + if (sts == STS_FAILURE) { + DEBUGC(DBCLASS_PLUGIN, "call_plugins: PLUGIN_VALIDATE " + "prematurely ending plugin processing in module " + "%s sts=STS_FAILURE", cur->name); + return sts; + } + break; /* PLUGIN_DETERMINE_TARGET can be prematurely ended by plugin - plugin processes and sends the final SIP message itself */ case (PLUGIN_DETERMINE_TARGET): /* return with the plugins status back to the caller */ if (sts == STS_SIP_SENT) { - DEBUGC(DBCLASS_PLUGIN, "call_plugins: prematurely ending " - "plugin processing in module %s sts=STS_SIP_SENT", - cur->desc); + DEBUGC(DBCLASS_PLUGIN, "call_plugins: PLUGIN_DETERMINE_TARGET " + "prematurely ending plugin processing in module " + "%s sts=STS_SIP_SENT", cur->desc); return sts; } break; diff --git a/src/plugins.h b/src/plugins.h index aa7c4f2..cd9cfaa 100644 --- a/src/plugins.h +++ b/src/plugins.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2008 Thomas Ries + Copyright (C) 2002-2009 Thomas Ries This file is part of Siproxd. @@ -30,16 +30,34 @@ /* * Processing stages for Plugins */ +/* get cyclic trigger */ +/* NO ticket is present (ticket = NULL pointer) */ +#define PLUGIN_TIMER 0x00000001 + +/* Process RAW data received */ +/* may end the current SIP processing in siproxd by returning STS_FALSE * + * may be used to intercept other traffic on SIP port */ +/* ticket with NO sipmsg is present (ticket.sipmsg = NULL pointer) */ +#define PLUGIN_PROCESS_RAW 0x00000005 + +/*--------- below here a valid sip message (ticket->sipmsg) is present ---*/ + /* Validation of SIP packet */ +/* may end the current SIP processing in siproxd by returning STS_FALSE * + * may be used to intercept other traffic on SIP port */ #define PLUGIN_VALIDATE 0x00000010 + /* Determining Request Targets */ /* may end the current SIP processing in siproxd by returning STS_SIP_SENT * see plugin_shortcut that sends a redirect back to the client */ #define PLUGIN_DETERMINE_TARGET 0x00000020 /* Determining Request Targets */ + /* SIP package before siproxd starts the proxying process */ #define PLUGIN_PRE_PROXY 0x00000040 /* before MASQuerading */ + /* to/from unregistered UA */ #define PLUGIN_PROXY_UNK 0x00000080 /* e.g. incoming call to unknown UA */ + /* before sending the SIP message */ #define PLUGIN_POST_PROXY 0x00000100 /* after MASQuerading */