diff --git a/ChangeLog b/ChangeLog index 9ada86d..7e5cb4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 0.7.1 ===== + 02-Feb-2008: - More work on new plugin API. + - moved Call Logging functionality to it's own plugin. 22-Jan-2008: - closing tag missing in docu 21-Jan-2008: - new plugin API (dynamically loadable plugins) diff --git a/RELNOTES b/RELNOTES index e36f623..59286ee 100644 --- a/RELNOTES +++ b/RELNOTES @@ -2,7 +2,18 @@ Release Notes for siproxd-0.7.1 =============================== Major changes since 0.7.0: - - + - Plugin API + +Upgrade Notes 0.7.0 to 0.7.1: + With the new plugin API, some configurations have changed in + configuration file. + - plugin_shortdial: configuration options have been renamed + pi_shortdial_akey -> plugin_shortdial_akey + pi_shortdial_entry -> plugin_shortdial_entry + - Call logging: The log_calls directive does no longer exist. + You load plugin_logcall and get logging. You don't load it + and don't get logging to syslog. + General Overview: - SIP (RFC3261) Proxy for SIP based softphones hidden behind a diff --git a/doc/siproxd.conf.example b/doc/siproxd.conf.example index 6bca7dc..85aac75 100644 --- a/doc/siproxd.conf.example +++ b/doc/siproxd.conf.example @@ -74,11 +74,6 @@ daemonize = 1 # see what siproxd is doing - or NOT doing) silence_log = 1 -###################################################################### -# Shall I log call establishment to syslog? -# -log_calls = 1 - ###################################################################### # Secure Enviroment settings: # user: uid/gid to switch to after startup @@ -295,6 +290,7 @@ plugindir=/home/hb9xar/src/siproxd/src/.libs/ # List of plugins to load #load_plugin=plugin_demo.so load_plugin=plugin_shortdial.so +load_plugin=plugin_logcall.so ###################################################################### diff --git a/src/Makefile.am b/src/Makefile.am index 1b14f00..c9485b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,13 +39,17 @@ siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \ # Plugin modules, installed in "pkglib" directory ($prefix/lib/siproxd/) # pkglib_LTLIBRARIES = plugin_demo.la \ - plugin_shortdial.la + plugin_shortdial.la \ + plugin_logcall.la # plugin_demo_la_SOURCES = plugin_demo.c plugin_demo_la_LDFLAGS = -module # plugin_shortdial_la_SOURCES = plugin_shortdial.c plugin_shortdial_la_LDFLAGS = -module +# +plugin_logcall_la_SOURCES = plugin_logcall.c +plugin_logcall_la_LDFLAGS = -module # diff --git a/src/plugin_logcall.c b/src/plugin_logcall.c new file mode 100644 index 0000000..9e3abbf --- /dev/null +++ b/src/plugin_logcall.c @@ -0,0 +1,131 @@ +/* + Copyright (C) 2008 Thomas Ries + + This file is part of Siproxd. + + Siproxd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Siproxd is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warrantry of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Siproxd; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "config.h" + +#include + +#include +#include + +#include + +#include "siproxd.h" +#include "plugins.h" +#include "log.h" + +static char const ident[]="$Id$"; + +/* Plug-in identification */ +static char name[]="plugin_logcall"; +static char desc[]="Logs calls to syslog"; + +/* global configuration storage - required for config file location */ +extern struct siproxd_config configuration; + + +/* + * Initialization. + * Called once suring siproxd startup. + */ +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. */ + plugin_def->api_version=SIPROXD_API_VERSION; + + /* Name and descriptive text of the plugin */ + plugin_def->name=name; + plugin_def->desc=desc; + + /* Execution mask - during what stages of SIP processing shall + * the plugin be called. */ + plugin_def->exe_mask=PLUGIN_PRE_PROXY; + + return STS_SUCCESS; +} + +/* + * Processing. + * + */ +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; + char *to_username =NULL; + char *to_host = NULL; + char *from_username =NULL; + char *from_host = NULL; + char *call_type = NULL; + + request=ticket->sipmsg; + /* From: 1st preference is From header, then try contact header */ + if (request->from->url) { + from_url = request->from->url; + } else { + from_url = (osip_uri_t *)osip_list_get(&(request->contacts), 0); + } + + to_url = request->to->url; + + if (to_url) { + to_username = to_url->username; + to_host = to_url->host; + } + + if (from_url) { + from_username = from_url->username; + from_host = from_url->host; + } + + /* INVITE */ + if (MSG_IS_INVITE(request)) { + if (ticket->direction==REQTYP_INCOMING) call_type="Incoming"; + else call_type="Outgoing"; + /* BYE / CANCEL */ + } else if (MSG_IS_ACK(request)) { + call_type="ACK"; + } else if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) { + call_type="Ending"; + } + + if (call_type) { + INFO("%s Call: %s@%s -> %s@%s", + call_type, + from_username ? from_username: "*NULL*", + from_host ? from_host : "*NULL*", + to_username ? to_username : "*NULL*", + to_host ? to_host : "*NULL*"); + } + + return STS_SUCCESS; +} + +/* + * De-Initialization. + * Called during shutdown of siproxd. Gives the plugin the chance + * 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){ + return STS_SUCCESS; +} + diff --git a/src/proxy.c b/src/proxy.c index c68ba99..59fa297 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -111,60 +111,6 @@ int proxy_request (sip_ticket_t *ticket) { /*&&&& PLUGIN_PRE_PROXY */ call_plugins(PLUGIN_PRE_PROXY, ticket); - /* - * logging of passing calls - */ -/*&&&& this should be moved to its own logging plugin */ - if (configuration.log_calls) { - osip_uri_t *from_url = NULL; - osip_uri_t *to_url = NULL; - char *to_username =NULL; - char *to_host = NULL; - char *from_username =NULL; - char *from_host = NULL; - char *call_type = NULL; - - /* From: 1st preference is From header, then try contact header */ - if (request->from->url) { - from_url = request->from->url; - } else { - from_url = (osip_uri_t *)osip_list_get(&(request->contacts), 0); - } - - to_url = request->to->url; - - if (to_url) { - to_username = to_url->username; - to_host = to_url->host; - } - - if (from_url) { - from_username = from_url->username; - from_host = from_url->host; - } - - /* INVITE */ - if (MSG_IS_INVITE(request)) { - if (type==REQTYP_INCOMING) call_type="Incoming"; - else call_type="Outgoing"; - /* BYE / CANCEL */ - } else if (MSG_IS_ACK(request)) { - call_type="ACK"; - } else if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) { - call_type="Ending"; - } - - if (call_type) { - INFO("%s Call: %s@%s -> %s@%s", - call_type, - from_username ? from_username: "*NULL*", - from_host ? from_host : "*NULL*", - to_username ? to_username : "*NULL*", - to_host ? to_host : "*NULL*"); - } - - } /* log_calls */ - /* * RFC 3261, Section 16.6 step 1 diff --git a/src/siproxd.c b/src/siproxd.c index cdf166d..bdf6b63 100644 --- a/src/siproxd.c +++ b/src/siproxd.c @@ -78,7 +78,6 @@ static cfgopts_t main_cfg_opts[] = { { "outbound_domain_host",TYP_STRINGA,&configuration.outbound_proxy_domain_host }, { "outbound_domain_port",TYP_STRINGA,&configuration.outbound_proxy_domain_port }, { "registration_file", TYP_STRING, &configuration.registrationfile }, - { "log_calls", TYP_INT4, &configuration.log_calls }, { "pid_file", TYP_STRING, &configuration.pid_file }, { "default_expires", TYP_INT4, &configuration.default_expires }, { "autosave_registrations",TYP_INT4, &configuration.autosave_registrations }, diff --git a/src/siproxd.h b/src/siproxd.h index 1902843..be3802c 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -91,7 +91,6 @@ struct siproxd_config { stringa_t outbound_proxy_domain_host; stringa_t outbound_proxy_domain_port; char *registrationfile; - int log_calls; char *pid_file; int default_expires; int autosave_registrations;