From 282b156207ccae94c8d80efec72c106cf7e3b4f2 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 17 Dec 2010 21:25:45 -0600 Subject: [PATCH 01/10] windows tweak mod_say_pt add to vs2010 others not for now --- Freeswitch.2010.sln | 20 +++++++++++++++++++ src/mod/say/mod_say_pt/mod_say_pt.2008.vcproj | 2 +- .../say/mod_say_pt/mod_say_pt.2010.vcxproj | 2 +- src/mod/say/mod_say_pt/mod_say_pt.vcproj | 2 +- w32/Setup/Setup.wixproj | 9 +++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln index 186969891a..edee701d51 100644 --- a/Freeswitch.2010.sln +++ b/Freeswitch.2010.sln @@ -707,6 +707,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_distributor", "src\mod\ EndProject Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "w32\Setup\Setup.wixproj", "{47213370-B933-487D-9F45-BCA26D7E2B6F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_pt", "src\mod\say\mod_say_pt\mod_say_pt.2010.vcxproj", "{7C22BDFF-CC09-400C-8A09-660733980028}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -3619,6 +3621,23 @@ Global {47213370-B933-487D-9F45-BCA26D7E2B6F}.Release|x64 Setup.Build.0 = Release|x64 {47213370-B933-487D-9F45-BCA26D7E2B6F}.Release|x86 Setup.ActiveCfg = Release|x86 {47213370-B933-487D-9F45-BCA26D7E2B6F}.Release|x86 Setup.Build.0 = Release|x86 + {7C22BDFF-CC09-400C-8A09-660733980028}.All|Win32.ActiveCfg = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.All|x64.ActiveCfg = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.All|x64.Build.0 = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.All|x64 Setup.ActiveCfg = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.All|x86 Setup.ActiveCfg = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Debug|Win32.ActiveCfg = Debug|Win32 + {7C22BDFF-CC09-400C-8A09-660733980028}.Debug|Win32.Build.0 = Debug|Win32 + {7C22BDFF-CC09-400C-8A09-660733980028}.Debug|x64.ActiveCfg = Debug|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Debug|x64.Build.0 = Debug|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Debug|x86 Setup.ActiveCfg = Debug|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Release|Win32.ActiveCfg = Release|Win32 + {7C22BDFF-CC09-400C-8A09-660733980028}.Release|Win32.Build.0 = Release|Win32 + {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64.ActiveCfg = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64.Build.0 = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64 Setup.ActiveCfg = Release|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x86 Setup.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3769,6 +3788,7 @@ Global {A4B122CF-5196-476B-8C0E-D8BD59AC3C14} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {B6A9FB7A-1CC4-442B-812D-EC33E4E4A36E} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {0382E8FD-CFDC-41C0-8B03-792C7C84FC31} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} + {7C22BDFF-CC09-400C-8A09-660733980028} = {6CD61A1D-797C-470A-BE08-8C31B68BB336} {3B08FEFD-4D3D-4C16-BA94-EE83509E32A0} = {57D119DC-484F-420F-B9E9-8589FD9A8DF8} {7BFD517E-7F8F-4A40-A78E-8D3632738227} = {57D119DC-484F-420F-B9E9-8589FD9A8DF8} {6374D55C-FABE-4A02-9CF1-4145308A56C5} = {57D119DC-484F-420F-B9E9-8589FD9A8DF8} diff --git a/src/mod/say/mod_say_pt/mod_say_pt.2008.vcproj b/src/mod/say/mod_say_pt/mod_say_pt.2008.vcproj index bf8c0333c5..ee0fffde02 100644 --- a/src/mod/say/mod_say_pt/mod_say_pt.2008.vcproj +++ b/src/mod/say/mod_say_pt/mod_say_pt.2008.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="9.00" Name="mod_say_pt" - ProjectGUID="{FA429E98-8B03-45E6-A096-A4BC5E821DE4}" + ProjectGUID="{7C22BDFF-CC09-400C-8A09-660733980028}" RootNamespace="mod_say_pt" Keyword="Win32Proj" TargetFrameworkVersion="131072" diff --git a/src/mod/say/mod_say_pt/mod_say_pt.2010.vcxproj b/src/mod/say/mod_say_pt/mod_say_pt.2010.vcxproj index 63fba6fae0..8c94e2cb65 100644 --- a/src/mod/say/mod_say_pt/mod_say_pt.2010.vcxproj +++ b/src/mod/say/mod_say_pt/mod_say_pt.2010.vcxproj @@ -20,7 +20,7 @@ mod_say_pt - {FA429E98-8B03-45E6-A096-A4BC5E821DE4} + {7C22BDFF-CC09-400C-8A09-660733980028} mod_say_pt Win32Proj diff --git a/src/mod/say/mod_say_pt/mod_say_pt.vcproj b/src/mod/say/mod_say_pt/mod_say_pt.vcproj index fb5d2dbab9..ce2a3344fc 100644 --- a/src/mod/say/mod_say_pt/mod_say_pt.vcproj +++ b/src/mod/say/mod_say_pt/mod_say_pt.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="mod_say_pt" - ProjectGUID="{FA429E98-8B03-45E6-A096-A4BC5E821DE4}" + ProjectGUID="{7C22BDFF-CC09-400C-8A09-660733980028}" RootNamespace="mod_say_pt" Keyword="Win32Proj" > diff --git a/w32/Setup/Setup.wixproj b/w32/Setup/Setup.wixproj index fa6c832777..f97000b585 100644 --- a/w32/Setup/Setup.wixproj +++ b/w32/Setup/Setup.wixproj @@ -723,6 +723,15 @@ Binaries;Content;Satellites MODLOCATION + + mod_say_pt + {7c22bdff-cc09-400c-8a09-660733980028} + True + + + Binaries;Content;Satellites + MODLOCATION + mod_say_ru {0382e8fd-cfdc-41c0-8b03-792c7c84fc31} From 1f26f2f86ad63865a13df010cc3c62e34a2d6d55 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 17 Dec 2010 22:29:33 -0600 Subject: [PATCH 02/10] presence is a 4-letter word --- src/mod/endpoints/mod_sofia/sofia_presence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 5d666f03ee..f0cade3e61 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -818,7 +818,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_dialog_callback, &dh); switch_safe_free(sql); - if ((sql = switch_mprintf("select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host," + if ((sql = switch_mprintf("select distinct sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host," "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event," "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from," "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent," From fcd6c54162a6270554de3b037c03398d7655732c Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Sun, 19 Dec 2010 00:13:08 -0500 Subject: [PATCH 03/10] freetdm: fix attempt for OPENZAP-130 --- libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c | 9 ++++----- libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c index fbe6ca0822..bfb67e4c78 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c @@ -127,9 +127,8 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen) } else { ftdm_log(FTDM_LOG_CRIT, "span %d D-READ TIMEOUT\n", spri->span->span_id); } - - ftdm_clear_flag(spri, LPWRAP_PRI_READY); - return -1; + /* we cannot return -1, libpri seems to expect values >= 0 */ + return 0; } spri->errs = 0; res = (int)len; @@ -156,8 +155,8 @@ static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen) if (ftdm_channel_write(spri->dchan, buf, buflen, &len) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "span %d D-WRITE FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error); - ftdm_clear_flag(spri, LPWRAP_PRI_READY); - return -1; + /* we cannot return -1, libpri seems to expect values >= 0 */ + return 0; } #ifdef IODEBUG diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c index 09208f8d2c..b16ead7a66 100644 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c +++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c @@ -1152,6 +1152,7 @@ static FIO_WRITE_FUNCTION(zt_write) bytes += 2; } +tryagain: w = write(ftdmchan->sockfd, data, bytes); if (w >= 0) { @@ -1159,6 +1160,17 @@ static FIO_WRITE_FUNCTION(zt_write) return FTDM_SUCCESS; } + if (errno == ELAST) { + zt_event_t zt_event_id = 0; + if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event after ELAST on write: %s\n", strerror(errno)); + return FTDM_FAIL; + } + /* we should enqueue this event somewhere so it can be retrieved by the user, for now, dropping it to see what it is! */ + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dropping event %d to be able to write data\n", zt_event_id); + goto tryagain; + } + return FTDM_FAIL; } From dd4bad220ca1f4ddcacfe69e720e7d32b744b6f9 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Sun, 19 Dec 2010 12:55:55 -0500 Subject: [PATCH 04/10] freetdm: ftmod_libpri - update to use proper structure member for signaling status change notifications --- libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c | 5 ++--- libs/freetdm/src/include/freetdm.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c index 8cbc0f4f45..1d3c76d2e2 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c @@ -1397,8 +1397,7 @@ static int on_dchan_up(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ev sig.chan_id = ftdm_channel_get_id(chan); sig.channel = chan; sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.raw_data = &status; - + sig.ev_data.sigstatus.status = status; ftdm_span_send_signal(span, &sig); } } @@ -1434,7 +1433,7 @@ static int on_dchan_down(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ sig.chan_id = ftdm_channel_get_id(chan); sig.channel = chan; sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.raw_data = &status; + sig.ev_data.sigstatus.status = status; ftdm_span_send_signal(span, &sig); } diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 69b90f1acd..a74fd7075a 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -438,7 +438,7 @@ struct ftdm_sigmsg { union { ftdm_event_sigstatus_t sigstatus; /*!< valid if event_id is FTDM_SIGEVENT_SIGSTATUS_CHANGED */ ftdm_event_trace_t logevent; /*!< valid if event_id is FTDM_SIGEVENT_TRACE or FTDM_SIGEVENT_TRACE_RAW */ - }ev_data; + } ev_data; }; /*! \brief Crash policy From 299c139c3ec6c9b276cefce4d6f1568d0d7100dc Mon Sep 17 00:00:00 2001 From: Giovanni Maruzzelli Date: Sun, 19 Dec 2010 13:40:27 -0600 Subject: [PATCH 05/10] skypopen: refined hrtimers support to OSS audio driver --- src/mod/endpoints/mod_skypopen/oss/main.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_skypopen/oss/main.c b/src/mod/endpoints/mod_skypopen/oss/main.c index 2abc5b342a..a96e38d68a 100644 --- a/src/mod/endpoints/mod_skypopen/oss/main.c +++ b/src/mod/endpoints/mod_skypopen/oss/main.c @@ -250,6 +250,10 @@ static ssize_t skypopen_read(struct file *filp, char __user *buf, size_t count, { DEFINE_WAIT(wait); struct skypopen_dev *dev = filp->private_data; + + if(unload) + return -1; + #ifdef WANT_HRTIMER #if 1 if(dev->timer_inq_started == 0){ @@ -278,6 +282,10 @@ static ssize_t skypopen_write(struct file *filp, const char __user *buf, size_t { DEFINE_WAIT(wait); struct skypopen_dev *dev = filp->private_data; + + if(unload) + return -1; + #ifdef WANT_HRTIMER #if 1 if(dev->timer_outq_started == 0){ @@ -372,10 +380,14 @@ void skypopen_cleanup_module(void) ret= del_timer( &lptr->device.timer_outq ); printk( "Stopped skypopen OSS driver write timer\n"); #else// WANT_HRTIMER - ret = hrtimer_cancel( &lptr->device.timer_inq ); - printk( "Stopped skypopen OSS driver read HRtimer\n"); - ret = hrtimer_cancel( &lptr->device.timer_outq ); - printk( "Stopped skypopen OSS driver write HRtimer\n"); + if(lptr->device.timer_inq_started){ + ret = hrtimer_cancel( &lptr->device.timer_inq ); + printk( "Stopped skypopen OSS driver read HRtimer\n"); + } + if(lptr->device.timer_outq_started){ + ret = hrtimer_cancel( &lptr->device.timer_outq ); + printk( "Stopped skypopen OSS driver write HRtimer\n"); + } #endif// WANT_HRTIMER list_del(&lptr->list); From b84b71defa49a715d04d9776a5f0c7040103d6db Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sun, 19 Dec 2010 21:09:50 +0100 Subject: [PATCH 06/10] FreeTDM: Stop using raw_data for FTDM_SIGEVENT_SIGSTATUS_CHANGED events. The raw_data member is used for passing heap allocated data with an event, (e.g. strings of dtmf data) the memory is freed after the event has been processed. Recent changes in the event structure added a way to pass sig status changes inline, so remove the raw_data usage for FTDM_SIGEVENT_SIGSTATUS_CHANGED events. NOTE: This (finally) fixes a bug in ftmod_libpri that was caused by the event handling changes (stack corruption due to using free() on a variable on the stack, which turned into a NULL ptr deref caused by some compat code in ftdm_io.c:ftdm_span_send_signal(). Compiles and tested on my BRI setup, i did a quick audit of all places that generate FTDM_SIGEVENT_SIGSTATUS_CHANGED events and except for the sangoma_boost module there's nothing else that left using raw_data for this event. Signed-off-by: Stefan Knoblich --- libs/freetdm/mod_freetdm/mod_freetdm.c | 2 +- libs/freetdm/src/ftdm_io.c | 3 +-- .../src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 7637932b79..80006f1ae5 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2086,7 +2086,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal) case FTDM_SIGEVENT_SIGSTATUS_CHANGED: { - ftdm_signaling_status_t sigstatus = sigmsg->raw_data ? *((ftdm_signaling_status_t*)(sigmsg->raw_data)) : sigmsg->ev_data.sigstatus.status; + ftdm_signaling_status_t sigstatus = sigmsg->ev_data.sigstatus.status; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d:%d signalling changed to: %s\n", spanid, chanid, ftdm_signaling_status2str(sigstatus)); } diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 94a01aa7ba..297c08e5ea 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -5403,8 +5403,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t case FTDM_SIGEVENT_SIGSTATUS_CHANGED: { - ftdm_signaling_status_t sigstatus = ftdm_test_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE) ? sigmsg->ev_data.sigstatus.status : *((ftdm_signaling_status_t*)(sigmsg->raw_data)); - if (sigstatus == FTDM_SIG_STATE_UP) { + if (sigmsg->ev_data.sigstatus.status == FTDM_SIG_STATE_UP) { ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_SIG_UP); } else { ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_SIG_UP); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c index f59b3b8c4f..97e242dacb 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c @@ -2478,7 +2478,7 @@ static BOOST_SIG_STATUS_CB_FUNCTION(ftdm_boost_sig_status_change) sig.span_id = ftdmchan->span_id; sig.channel = ftdmchan; sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.raw_data = &status; + sig.ev_data.sigstatus.status = status; ftdm_span_send_signal(ftdmchan->span, &sig); return; } From 1c4c84fc0ffdba48fd42154e7f0e85ddbb1c5ede Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Sun, 19 Dec 2010 21:38:55 +0100 Subject: [PATCH 07/10] Perl's Net::Skinny : update to current handle PACKED structs --- src/mod/endpoints/mod_skinny/Net/Skinny/Protocol.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_skinny/Net/Skinny/Protocol.pm b/src/mod/endpoints/mod_skinny/Net/Skinny/Protocol.pm index 90de304817..94708881e3 100644 --- a/src/mod/endpoints/mod_skinny/Net/Skinny/Protocol.pm +++ b/src/mod/endpoints/mod_skinny/Net/Skinny/Protocol.pm @@ -48,7 +48,7 @@ sub _find { my ($name, $value) = ($1,hex($2)); $sub{$name} = sub () { $value }; $const{$name} = $value; - } elsif(/^\s*struct\s+([a-z_]+)\s*\{\s*$/) { + } elsif(/^\s*struct\s+PACKED\s+([a-z_]+)\s*\{\s*$/) { my $struct_name = $1; $struct{$struct_name} = []; while(<$fh>) { From 709c4e5f9729dfad0862fa2daaf2f0687d04a56f Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Sun, 19 Dec 2010 22:16:09 +0100 Subject: [PATCH 08/10] Skinny: Event skinny::xml_alarm --- src/mod/endpoints/mod_skinny/mod_skinny.h | 1 + .../endpoints/mod_skinny/skinny_protocol.h | 3 +-- src/mod/endpoints/mod_skinny/skinny_server.c | 22 +++++++++++++++++++ src/mod/endpoints/mod_skinny/test-skinny.pl | 6 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index b5cc96b7ae..20d68faba5 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -42,6 +42,7 @@ #define SKINNY_EVENT_UNREGISTER "skinny::unregister" #define SKINNY_EVENT_EXPIRE "skinny::expire" #define SKINNY_EVENT_ALARM "skinny::alarm" +#define SKINNY_EVENT_XML_ALARM "skinny::xml_alarm" #define SKINNY_EVENT_CALL_STATE "skinny::call_state" #define SKINNY_EVENT_USER_TO_DEVICE "skinny::user_to_device" #define SKINNY_EVENT_DEVICE_TO_USER "skinny::device_to_user" diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index ee3c33a497..20e7d7f92f 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -627,8 +627,7 @@ union skinny_data { struct extended_data_message extended_data; uint16_t as_uint16; - char as_char; - void *raw; + char as_char[1]; }; /* diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 9bf9d9fb9b..5874be4c6c 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1963,6 +1963,26 @@ switch_status_t skinny_handle_extended_data_message(listener_t *listener, skinny return SWITCH_STATUS_SUCCESS; } +switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t *request) +{ + switch_event_t *event = NULL; + char *tmp = NULL; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, + "Received XML alarm.\n"); + /* skinny::xml_alarm event */ + skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_XML_ALARM); + /* Ensure that the body is null-terminated */ + tmp = malloc(request->length - 4 + 1); + memcpy(tmp, request->data.as_char, request->length - 4); + tmp[request->length - 4] = '\0'; + switch_event_add_body(event, "%s", tmp); + switch_safe_free(tmp); + switch_event_fire(&event); + + return SWITCH_STATUS_SUCCESS; +} + switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *request) { if (listener->profile->debug >= 10 || request->type != KEEP_ALIVE_MESSAGE) { @@ -2032,6 +2052,8 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re return skinny_handle_extended_data_message(listener, request); case DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE: return skinny_handle_extended_data_message(listener, request); + case XML_ALARM_MESSAGE: + return skinny_handle_xml_alarm(listener, request); default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled request %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length); diff --git a/src/mod/endpoints/mod_skinny/test-skinny.pl b/src/mod/endpoints/mod_skinny/test-skinny.pl index a44afa33dc..02cf3cc2f6 100644 --- a/src/mod/endpoints/mod_skinny/test-skinny.pl +++ b/src/mod/endpoints/mod_skinny/test-skinny.pl @@ -34,6 +34,12 @@ if(!$socket) { exit 1; } # ============================================================================= +$socket->send_raw( + XML_ALARM_MESSAGE, + "\x0a\x0a\x0a\x0aSEP002699438F62\x0a192.168.3.201/24\x0a192.168.3.254\x0a\x0a\x0aCP-7961G\x0a192.168.0.253\x0a\x0asw2.wvds.local\x0a3\x0a1\x0a0\x0a0\x0a0\x0a0\x0a0\x0a4095\x0a\x0a-1\x0a1289313813826\x0a\x0a1:Register\x0a129:RegisterAck\x0a\x0a\x0a\x0a" + ); + $socket->sleep(20); + exit; $socket->send_message( REGISTER_MESSAGE, device_name => $device_name, From 9b70d9a7a565b7af2f6ee4511f687316d1ba5a48 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Sun, 19 Dec 2010 22:20:09 +0100 Subject: [PATCH 09/10] Revert perl's Net::Skinny test --- src/mod/endpoints/mod_skinny/test-skinny.pl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/test-skinny.pl b/src/mod/endpoints/mod_skinny/test-skinny.pl index 02cf3cc2f6..a44afa33dc 100644 --- a/src/mod/endpoints/mod_skinny/test-skinny.pl +++ b/src/mod/endpoints/mod_skinny/test-skinny.pl @@ -34,12 +34,6 @@ if(!$socket) { exit 1; } # ============================================================================= -$socket->send_raw( - XML_ALARM_MESSAGE, - "\x0a\x0a\x0a\x0aSEP002699438F62\x0a192.168.3.201/24\x0a192.168.3.254\x0a\x0a\x0aCP-7961G\x0a192.168.0.253\x0a\x0asw2.wvds.local\x0a3\x0a1\x0a0\x0a0\x0a0\x0a0\x0a0\x0a4095\x0a\x0a-1\x0a1289313813826\x0a\x0a1:Register\x0a129:RegisterAck\x0a\x0a\x0a\x0a" - ); - $socket->sleep(20); - exit; $socket->send_message( REGISTER_MESSAGE, device_name => $device_name, From f4d52d4caae78359b59d97bf596a269e47f4def3 Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 20 Dec 2010 08:43:13 -0600 Subject: [PATCH 10/10] FS-2943: improve fail2ban logging --- src/mod/endpoints/mod_sofia/sofia_reg.c | 46 ++++++++++++------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 570e297f6d..945740eb57 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1139,30 +1139,24 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand } if (auth_res != AUTH_OK && !stale) { - if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) { - if (regtype == REG_REGISTER) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SIP auth %s (REGISTER) on sofia profile '%s' " - "for [%s@%s] from ip %s\n", forbidden ? "failure" : "challenge", profile->name, to_user, to_host, network_ip); - } + if (auth_res == AUTH_FORBIDDEN) { + nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END()); + forbidden = 1; + } else { + nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END()); } if (profile->debug) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send %s for [%s@%s]\n", forbidden ? "forbidden" : "challenge", to_user, to_host); } - if (auth_res == AUTH_FORBIDDEN) { - nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END()); - - /* Log line added to support Fail2Ban */ - if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) { - if (regtype == REG_INVITE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth failure (INVITE) on sofia profile '%s' " - "for [%s@%s] from ip %s\n", profile->name, to_user, to_host, network_ip); - } - } - } else { - nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END()); + /* Log line added to support Fail2Ban */ + if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth %s (%s) on sofia profile '%s' " + "for [%s@%s] from ip %s\n", forbidden ? "failure" : "challenge", + (regtype == REG_INVITE) ? "INVITE" : "REGISTER", profile->name, to_user, to_host, network_ip); } + switch_goto_int(r, 1, end); } } @@ -1193,14 +1187,18 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand realm = from_host; } - if (regtype == REG_REGISTER) { - sofia_reg_auth_challenge(nua, profile, nh, regtype, realm, stale); - if (profile->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting Registration from: [%s@%s]\n", to_user, to_host); - } - } else { - sofia_reg_auth_challenge(nua, profile, nh, regtype, realm, stale); + sofia_reg_auth_challenge(nua, profile, nh, regtype, realm, stale); + + if (profile->debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send challenge for [%s@%s]\n", to_user, to_host); } + /* Log line added to support Fail2Ban */ + if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth challenge (%s) on sofia profile '%s' " + "for [%s@%s] from ip %s\n", (regtype == REG_INVITE) ? "INVITE" : "REGISTER", + profile->name, to_user, to_host, network_ip); + } + switch_goto_int(r, 1, end); } reg: