- default target plugin

This commit is contained in:
Thomas Ries 2008-02-04 20:38:44 +00:00
parent e8b2346781
commit 99111f01d7
8 changed files with 57 additions and 33 deletions

View File

@ -1,5 +1,7 @@
0.7.1
=====
04-Feb-2008: - 'Default Target' plugin: incoming calls to unknown
are redirected to a "catch-all" target.
02-Feb-2008: - More work on new plugin API.
- moved Call Logging functionality to it's own plugin.
22-Jan-2008: - closing </chapter> tag missing in docu

View File

@ -287,10 +287,11 @@ debug_port = 0
# plugin_dir: MUST be terminated with '/'
plugindir=/home/hb9xar/src/siproxd/src/.libs/
#
# List of plugins to load
# List of plugins to load:
#load_plugin=plugin_demo.so
load_plugin=plugin_shortdial.so
#load_plugin=plugin_shortdial.so
load_plugin=plugin_logcall.so
#load_plugin=plugin_defaulttarget.so
######################################################################
@ -320,3 +321,12 @@ plugin_shortdial_akey = *00
plugin_shortdial_entry = 17474743246
# *02 sipphone welcome message
plugin_shortdial_entry = 17474745000
######################################################################
# Plugin_defaulttarget
#
plugin_defaulttarget_log = 1
# target must be a full SIP URI with the syntax
# sip:user@hst[:port]
plugin_defaulttarget_target = sip:internal@dddd:port

View File

@ -40,7 +40,8 @@ siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \
#
pkglib_LTLIBRARIES = plugin_demo.la \
plugin_shortdial.la \
plugin_logcall.la
plugin_logcall.la \
plugin_defaulttarget.la
#
plugin_demo_la_SOURCES = plugin_demo.c
plugin_demo_la_LDFLAGS = -module
@ -50,6 +51,9 @@ plugin_shortdial_la_LDFLAGS = -module
#
plugin_logcall_la_SOURCES = plugin_logcall.c
plugin_logcall_la_LDFLAGS = -module
#
plugin_defaulttarget_la_SOURCES = plugin_defaulttarget.c
plugin_defaulttarget_la_LDFLAGS = -module
#

View File

@ -36,11 +36,11 @@
* 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 /* */
#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 /* */
#define PLUGIN_POST_PROXY 0x00000100 /* after MASQuerading */
/* Plugin "database" */

View File

@ -106,11 +106,11 @@ int proxy_request (sip_ticket_t *ticket) {
* figure out whether this is an incoming or outgoing request
* by doing a lookup in the registration table.
*/
sip_find_direction(ticket, &i);
type = ticket->direction;
sip_find_direction(ticket, &i);
type = ticket->direction;
/*&&&& PLUGIN_PRE_PROXY */
call_plugins(PLUGIN_PRE_PROXY, ticket);
/* Call Plugins for stage: PLUGIN_PRE_PROXY */
sts = call_plugins(PLUGIN_PRE_PROXY, ticket);
/*
* RFC 3261, Section 16.6 step 1
@ -237,8 +237,11 @@ sts=sip_obscure_callid(ticket);
* How about "408 Request Timeout" ?
*
*/
/*&&&& PLUGIN_PROXY_UNK */
call_plugins(PLUGIN_PROXY_UNK, ticket);
/* Call Plugins for stage: PLUGIN_PROXY_UNK */
sts = call_plugins(PLUGIN_PROXY_UNK, ticket);
/*&&& we might want have the possibility for a plugin to generate
and send a response, similar an in stage PLUGIN_DETERMINE_TARGET */
sip_gen_response(ticket, 408 /* Request Timeout */);
return STS_FAILURE;
@ -420,8 +423,8 @@ sts=sip_obscure_callid(ticket);
*/
/* not necessary, already in message and we do not support TCP */
/*&&&& PLUGIN_POST_PROXY */
call_plugins(PLUGIN_POST_PROXY, ticket);
/* Call Plugins for stage: PLUGIN_POST_PROXY */
sts = call_plugins(PLUGIN_POST_PROXY, ticket);
/*
* RFC 3261, Section 16.6 step 10
@ -433,8 +436,7 @@ sts=sip_obscure_callid(ticket);
return STS_FAILURE;
}
sipsock_send(sendto_addr, port, ticket->protocol,
buffer, buflen);
sipsock_send(sendto_addr, port, ticket->protocol, buffer, buflen);
osip_free (buffer);
/*
@ -502,10 +504,11 @@ int proxy_response (sip_ticket_t *ticket) {
* figure out if this is an request coming from the outside
* world to one of our registered clients
*/
sip_find_direction(ticket, NULL);
type = ticket->direction;
/*&&&& PLUGIN_PRE_PROXY */
call_plugins(PLUGIN_PRE_PROXY, ticket);
sip_find_direction(ticket, NULL);
type = ticket->direction;
/* Call Plugins for stage: PLUGIN_PRE_PROXY */
sts = call_plugins(PLUGIN_PRE_PROXY, ticket);
/*
* ok, we got a response that we are allowed to process.
@ -635,8 +638,9 @@ sts=sip_obscure_callid(ticket);
DEBUGC(DBCLASS_PROXY, "response from/to unregistered UA (%s@%s)",
response->from->url->username? response->from->url->username:"*NULL*",
response->from->url->host? response->from->url->host : "*NULL*");
/*&&&& PLUGIN_PROXY_UNK */
call_plugins(PLUGIN_PROXY_UNK, ticket);
/* Call Plugins for stage: PLUGIN_PROXY_UNK */
sts = call_plugins(PLUGIN_PROXY_UNK, ticket);
return STS_FAILURE;
}
@ -729,8 +733,8 @@ sts=sip_obscure_callid(ticket);
}
}
/*&&&& PLUGIN_POST_PROXY */
call_plugins(PLUGIN_POST_PROXY, ticket);
/* Call Plugins for stage: PLUGIN_POST_PROXY */
sts = call_plugins(PLUGIN_POST_PROXY, ticket);
/*
* Proxy Behavior - Forward the response
@ -741,8 +745,7 @@ sts=sip_obscure_callid(ticket);
return STS_FAILURE;
}
sipsock_send(sendto_addr, port, ticket->protocol,
buffer, buflen);
sipsock_send(sendto_addr, port, ticket->protocol, buffer, buflen);
osip_free (buffer);
return STS_SUCCESS;
}

View File

@ -973,9 +973,9 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
from=&ticket->from;
request=ticket->sipmsg;
response=ticket->sipmsg;
type = 0;
type = DIRTYP_UNKNOWN;
ticket->direction = 0;
ticket->direction = DIRTYP_UNKNOWN;
/*
* did I receive the telegram from a REGISTERED host?
@ -1004,7 +1004,7 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
* is the telegram directed to an internally registered host?
* -> it must be an INCOMING request
*/
if (type == 0) {
if (type == DIRTYP_UNKNOWN) {
for (i=0; i<URLMAP_SIZE; i++) {
if (urlmap[i].active == 0) continue;
/* RFC3261:
@ -1046,7 +1046,7 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
}
} /* is request */
} /* for i */
} /* if type == 0 */
} /* if type == DIRTYP_UNKNOWN */
if (MSG_IS_RESPONSE(ticket->sipmsg)) {
/* &&&& Open Issue &&&&
@ -1057,7 +1057,8 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
Maybe I should put in a 'siproxd' ftag value to recognize it as a header
inserted by myself
*/
if ((type == 0) && (!osip_list_eol(&(response->vias), 0))) {
if ((type == DIRTYP_UNKNOWN) &&
(!osip_list_eol(&(response->vias), 0))) {
osip_via_t *via;
struct in_addr addr_via, addr_myself;
int port_via, port_ua;
@ -1103,7 +1104,7 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
}
} /* for i */
}
} /* if type == 0 */
} /* if type == DIRTYP_UNKNOWN */
} /* is response */
/*
@ -1126,7 +1127,7 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
}
if (type == 0) {
if (type == DIRTYP_UNKNOWN) {
DEBUGC(DBCLASS_SIP, "sip_find_direction: unable to determine "
"direction of SIP packet");
return STS_FAILURE;

View File

@ -438,7 +438,9 @@ int main (int argc, char *argv[])
* (check request URI and refuse with 416 if not understood)
*/
/* NOT IMPLEMENTED */
/*&&& PLUGIN_VALIDATE */
/* Call Plugins for stage: PLUGIN_VALIDATE */
sts = call_plugins(PLUGIN_VALIDATE, &ticket);
/*
* RFC 3261, Section 16.3 step 3
@ -504,6 +506,7 @@ int main (int argc, char *argv[])
ticket.sipmsg->reason_phrase : "NULL")));
/*********************************
* Call Plugins for stage: PLUGIN_DETERMINE_TARGET
* The message did pass all the
* tests above and is now ready
* to be proxied.

View File

@ -120,6 +120,7 @@ typedef struct {
#define PROTO_UDP 1
#define PROTO_TCP 2
int protocol; /* received by protocol */
#define DIRTYP_UNKNOWN 0
#define REQTYP_INCOMING 1
#define REQTYP_OUTGOING 2
#define RESTYP_INCOMING 3