- enhancements in plugin API
This commit is contained in:
parent
1f71f5743c
commit
1d306f80e4
@ -52,8 +52,8 @@ static struct plugin_config {
|
|||||||
|
|
||||||
/* Instructions for config parser */
|
/* Instructions for config parser */
|
||||||
static cfgopts_t plugin_cfg_opts[] = {
|
static cfgopts_t plugin_cfg_opts[] = {
|
||||||
{ "plugin_defaulttarget_target", TYP_STRING, &plugin_cfg.target },
|
{ "plugin_defaulttarget_target", TYP_STRING, &plugin_cfg.target, {0, NULL} },
|
||||||
{ "plugin_defaulttarget_log", TYP_INT4, &plugin_cfg.log },
|
{ "plugin_defaulttarget_log", TYP_INT4, &plugin_cfg.log, {0, NULL} },
|
||||||
{0, 0, 0}
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
/* local storage */
|
/* local storage */
|
||||||
|
|||||||
@ -52,7 +52,7 @@ static struct plugin_config {
|
|||||||
|
|
||||||
/* Instructions for config parser */
|
/* Instructions for config parser */
|
||||||
static cfgopts_t plugin_cfg_opts[] = {
|
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}
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -54,8 +54,8 @@ static struct plugin_config {
|
|||||||
} plugin_cfg;
|
} plugin_cfg;
|
||||||
/* Instructions for config parser */
|
/* Instructions for config parser */
|
||||||
static cfgopts_t plugin_cfg_opts[] = {
|
static cfgopts_t plugin_cfg_opts[] = {
|
||||||
{ "plugin_shortdial_akey", TYP_STRING, &plugin_cfg.shortdial_akey },
|
{ "plugin_shortdial_akey", TYP_STRING, &plugin_cfg.shortdial_akey, {0, NULL} },
|
||||||
{ "plugin_shortdial_entry", TYP_STRINGA,&plugin_cfg.shortdial_entry },
|
{ "plugin_shortdial_entry", TYP_STRINGA,&plugin_cfg.shortdial_entry, {0, NULL} },
|
||||||
{0, 0, 0}
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ static int plugin_shortdial_redirect(sip_ticket_t *ticket, int shortcut_no) {
|
|||||||
char *new_to_host=NULL;
|
char *new_to_host=NULL;
|
||||||
int i;
|
int i;
|
||||||
size_t username_len;
|
size_t username_len;
|
||||||
size_t host_len;
|
size_t host_len=0;
|
||||||
osip_contact_t *contact = NULL;
|
osip_contact_t *contact = NULL;
|
||||||
|
|
||||||
new_to_user=plugin_cfg.shortdial_entry.string[shortcut_no-1];
|
new_to_user=plugin_cfg.shortdial_entry.string[shortcut_no-1];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2003-2008 Thomas Ries <tries@gmx.net>
|
Copyright (C) 2003-2009 Thomas Ries <tries@gmx.net>
|
||||||
|
|
||||||
This file is part of Siproxd.
|
This file is part of Siproxd.
|
||||||
|
|
||||||
@ -168,8 +168,9 @@ int call_plugins(int stage, sip_ticket_t *ticket) {
|
|||||||
int sts;
|
int sts;
|
||||||
func_plugin_process_t plugin_process;
|
func_plugin_process_t plugin_process;
|
||||||
|
|
||||||
/* sanity check, beware pluigins from crappy stuff */
|
/* sanity check, beware plugins from crappy stuff
|
||||||
if (!ticket || !ticket->sipmsg) return STS_FAILURE;
|
* 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 each plugin in plugins, do */
|
||||||
for (cur=siproxd_plugins; cur != NULL; cur = cur->next) {
|
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;
|
plugin_process=cur->plugin_process;
|
||||||
sts=(*plugin_process)(stage, ticket);
|
sts=(*plugin_process)(stage, ticket);
|
||||||
switch (stage) {
|
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_DETERMINE_TARGET can be prematurely ended by plugin -
|
||||||
plugin processes and sends the final SIP message itself */
|
plugin processes and sends the final SIP message itself */
|
||||||
case (PLUGIN_DETERMINE_TARGET):
|
case (PLUGIN_DETERMINE_TARGET):
|
||||||
/* return with the plugins status back to the caller */
|
/* return with the plugins status back to the caller */
|
||||||
if (sts == STS_SIP_SENT) {
|
if (sts == STS_SIP_SENT) {
|
||||||
DEBUGC(DBCLASS_PLUGIN, "call_plugins: prematurely ending "
|
DEBUGC(DBCLASS_PLUGIN, "call_plugins: PLUGIN_DETERMINE_TARGET "
|
||||||
"plugin processing in module %s sts=STS_SIP_SENT",
|
"prematurely ending plugin processing in module "
|
||||||
cur->desc);
|
"%s sts=STS_SIP_SENT", cur->desc);
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2002-2008 Thomas Ries <tries@gmx.net>
|
Copyright (C) 2002-2009 Thomas Ries <tries@gmx.net>
|
||||||
|
|
||||||
This file is part of Siproxd.
|
This file is part of Siproxd.
|
||||||
|
|
||||||
@ -30,16 +30,34 @@
|
|||||||
/*
|
/*
|
||||||
* Processing stages for Plugins
|
* 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 */
|
/* 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
|
#define PLUGIN_VALIDATE 0x00000010
|
||||||
|
|
||||||
/* Determining Request Targets */
|
/* Determining Request Targets */
|
||||||
/* may end the current SIP processing in siproxd by returning STS_SIP_SENT
|
/* may end the current SIP processing in siproxd by returning STS_SIP_SENT
|
||||||
* see plugin_shortcut that sends a redirect back to the client */
|
* see plugin_shortcut that sends a redirect back to the client */
|
||||||
#define PLUGIN_DETERMINE_TARGET 0x00000020 /* Determining Request Targets */
|
#define PLUGIN_DETERMINE_TARGET 0x00000020 /* Determining Request Targets */
|
||||||
|
|
||||||
/* SIP package before siproxd starts the proxying process */
|
/* SIP package before siproxd starts the proxying process */
|
||||||
#define PLUGIN_PRE_PROXY 0x00000040 /* before MASQuerading */
|
#define PLUGIN_PRE_PROXY 0x00000040 /* before MASQuerading */
|
||||||
|
|
||||||
/* to/from unregistered UA */
|
/* to/from unregistered UA */
|
||||||
#define PLUGIN_PROXY_UNK 0x00000080 /* e.g. incoming call to unknown UA */
|
#define PLUGIN_PROXY_UNK 0x00000080 /* e.g. incoming call to unknown UA */
|
||||||
|
|
||||||
/* before sending the SIP message */
|
/* before sending the SIP message */
|
||||||
#define PLUGIN_POST_PROXY 0x00000100 /* after MASQuerading */
|
#define PLUGIN_POST_PROXY 0x00000100 /* after MASQuerading */
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user