From robertj at freeswitch.org Sun Mar 1 19:19:57 2009 From: robertj at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Mar 2009 21:19:57 -0600 Subject: [Freeswitch-svn] [commit] r12347 - freeswitch/trunk/src/mod/endpoints/mod_opal Message-ID: Author: robertj Date: Sun Mar 1 21:19:57 2009 New Revision: 12347 Log: Added "jitter-size" to config file to set jitter buffer size. Fixed transmission of Q.931 Calling-Party-Number, and DisplayName on H.323 Setup. Was previously being set on the wrong connection. Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp (original) +++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp Sun Mar 1 21:19:57 2009 @@ -323,8 +323,6 @@ m_FreeSwitch->io_routines = &opalfs_io_routines; m_FreeSwitch->state_handler = &opalfs_event_handlers; - SetAudioJitterDelay(800, 3000); // should be config option - silenceDetectParams.m_mode = OpalSilenceDetector::NoSilenceDetection; if (m_listeners.empty()) { @@ -411,6 +409,15 @@ set_global_dialplan(val); } else if (!strcasecmp(var, "codec-prefs")) { set_global_codec_string(val); + } else if (!strcasecmp(var, "jitter-size")) { + char * next; + unsigned minJitter = strtoul(val, &next, 10); + if (minJitter >= 10) { + unsigned maxJitter = minJitter; + if (*next == ',') + maxJitter = atoi(next+1); + SetAudioJitterDelay(minJitter, maxJitter); // In milliseconds + } } } } @@ -455,6 +462,12 @@ } +OpalCall * FSManager::CreateCall(void * /*userData*/) +{ + return new FSCall(*this); +} + + /////////////////////////////////////////////////////////////////////// FSEndPoint::FSEndPoint(FSManager & manager) @@ -478,6 +491,32 @@ /////////////////////////////////////////////////////////////////////// +FSCall::FSCall(OpalManager & manager) + : OpalCall(manager) +{ +} + + +PBoolean FSCall::OnSetUp(OpalConnection & connection) +{ + // Transfer FS caller_id_number & caller_id_name from the FSConnection + // to the protocol connectionm (e.g. H.323) so gets sent correctly + // in outgoing packets + PSafePtr local = GetConnectionAs(); + if (local != NULL) { + PSafePtr proto = local->GetOtherPartyConnection(); + if (proto != NULL) { + proto->SetLocalPartyName(local->GetLocalPartyName()); + proto->SetDisplayName(local->GetDisplayName()); + } + } + + return OpalCall::OnSetUp(connection); +} + + +/////////////////////////////////////////////////////////////////////// + FSConnection::FSConnection(OpalCall & call, FSEndPoint & endpoint, switch_caller_profile_t *outbound_profile) : OpalLocalConnection(call, endpoint, NULL) Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h Sun Mar 1 21:19:57 2009 @@ -82,6 +82,14 @@ }; +class FSCall : public OpalCall { + PCLASSINFO(FSCall, OpalCall); + public: + FSCall(OpalManager & manager); + virtual PBoolean OnSetUp(OpalConnection & connection); +}; + + class FSManager : public OpalManager { PCLASSINFO(FSManager, OpalManager); @@ -96,6 +104,8 @@ return m_FreeSwitch; } + virtual OpalCall * CreateCall(void * userData); + private: switch_endpoint_interface_t *m_FreeSwitch; @@ -106,6 +116,7 @@ list < FSListener > m_listeners; }; + class FSConnection; typedef struct { switch_timer_t read_timer; From anthm at freeswitch.org Mon Mar 2 07:45:00 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 09:45:00 -0600 Subject: [Freeswitch-svn] [commit] r12348 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 2 09:45:00 2009 New Revision: 12348 Log: add some more thread joins to avoid races Modified: freeswitch/trunk/src/switch_core_memory.c freeswitch/trunk/src/switch_time.c Modified: freeswitch/trunk/src/switch_core_memory.c ============================================================================== --- freeswitch/trunk/src/switch_core_memory.c (original) +++ freeswitch/trunk/src/switch_core_memory.c Mon Mar 2 09:45:00 2009 @@ -440,11 +440,17 @@ return NULL; } +static switch_thread_t *pool_thread_p = NULL; + void switch_core_memory_stop(void) { + switch_status_t st; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n"); #ifndef INSTANTLY_DESTROY_POOLS memory_manager.pool_thread_running = -1; + switch_thread_join(&st, pool_thread_p); + while (memory_manager.pool_thread_running) { switch_cond_next(); } @@ -454,7 +460,6 @@ switch_memory_pool_t *switch_core_memory_init(void) { #ifndef INSTANTLY_DESTROY_POOLS - switch_thread_t *thread; switch_threadattr_t *thd_attr; #endif #ifdef PER_POOL_LOCK @@ -502,7 +507,7 @@ switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&thread, thd_attr, pool_thread, NULL, memory_manager.memory_pool); + switch_thread_create(&pool_thread_p, thd_attr, pool_thread, NULL, memory_manager.memory_pool); while (!memory_manager.pool_thread_running) { switch_cond_next(); Modified: freeswitch/trunk/src/switch_time.c ============================================================================== --- freeswitch/trunk/src/switch_time.c (original) +++ freeswitch/trunk/src/switch_time.c Mon Mar 2 09:45:00 2009 @@ -113,7 +113,7 @@ SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void) { - return runtime.timestamp ? runtime.timestamp : switch_time_now(); + return (globals.RUNNING == 1 && runtime.timestamp) ? runtime.timestamp : switch_time_now(); } @@ -195,7 +195,7 @@ #ifdef DISABLE_1MS_COND do_sleep(1000); #else - if (!runtime.timestamp || globals.use_cond_yield != 1) { + if (globals.RUNNING != 1 || !runtime.timestamp || globals.use_cond_yield != 1) { do_sleep(1000); return; } @@ -210,7 +210,7 @@ switch_time_t want; if (!t) return; - if (!runtime.timestamp || globals.use_cond_yield != 1) { + if (globals.RUNNING != 1 || !runtime.timestamp || globals.use_cond_yield != 1) { do_sleep(t); return; } From anthm at freeswitch.org Mon Mar 2 08:09:32 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:09:32 -0600 Subject: [Freeswitch-svn] [commit] r12349 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket Message-ID: Author: anthm Date: Mon Mar 2 10:09:32 2009 New Revision: 12349 Log: MODEVENT-40 ahem `Math Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Mon Mar 2 10:09:32 2009 @@ -1275,10 +1275,6 @@ SWITCH_STANDARD_STREAM(stream); - if (!strcasecmp(acs->api_cmd, "unload") || !strcasecmp(acs->arg, "mod_event_socket")) { - - } - if ((status = switch_api_execute(acs->api_cmd, acs->arg, NULL, &stream)) == SWITCH_STATUS_SUCCESS) { reply = stream.data; } else { From mrene at freeswitch.org Mon Mar 2 08:11:42 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:11:42 -0600 Subject: [Freeswitch-svn] [commit] r12350 - freeswitch/trunk/support-d Message-ID: Author: mrene Date: Mon Mar 2 10:11:42 2009 New Revision: 12350 Log: New event_dump gdb macro Modified: freeswitch/trunk/support-d/.gdbinit Modified: freeswitch/trunk/support-d/.gdbinit ============================================================================== --- freeswitch/trunk/support-d/.gdbinit (original) +++ freeswitch/trunk/support-d/.gdbinit Mon Mar 2 10:11:42 2009 @@ -30,20 +30,6 @@ Prints the content of a hashtable displaying the key as a string and the value as pointer end -define hash_it_int - dont-repeat - set $i = 0 - set $x=$arg0->table->first - while($x != 0x0) - printf "key: %d valueptr: %p\n", $x->pKey, $x->data - set $x = $x->next - set $i = $i + 1 - end -end -document hash_it_int -Usage: hash_it_int [hashtable] -Prints the content of a hashtable displaying the key as an int and the value as pointer -end define hash_it_str_x dont-repeat @@ -62,19 +48,10 @@ Prints the content of a hashtable displaying the key as a string and a specific member of the value struct. Args: hashtable value_type member end -define hash_it_int_x - dont-repeat - set $i = 0 - set $x=$arg0->table->first +define event_dump + set $x = $arg0->headers while($x != 0x0) - printf "key: %d\n", $x->pKey - print (($arg1*)$x->data)->$arg2 - printf "\n\n" + printf "%s = %s\n", $x->name, $x->value set $x = $x->next - set $i = $i + 1 - end -end -document hash_it_int_x -Usage: hash_it_int_x [hashtable] [value_type] [member] -Prints the content of a hashtable displaying the key as a string and a specific member of the value struct. -end + end +end \ No newline at end of file From mrene at freeswitch.org Mon Mar 2 08:12:36 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:12:36 -0600 Subject: [Freeswitch-svn] [commit] r12351 - freeswitch/trunk/support-d Message-ID: Author: mrene Date: Mon Mar 2 10:12:36 2009 New Revision: 12351 Log: Now with a document statement Modified: freeswitch/trunk/support-d/.gdbinit Modified: freeswitch/trunk/support-d/.gdbinit ============================================================================== --- freeswitch/trunk/support-d/.gdbinit (original) +++ freeswitch/trunk/support-d/.gdbinit Mon Mar 2 10:12:36 2009 @@ -49,9 +49,14 @@ end define event_dump + dont-repeat set $x = $arg0->headers while($x != 0x0) printf "%s = %s\n", $x->name, $x->value set $x = $x->next end +end +document event_dump +Usage: event_dump [switch_event_t*] +Print and event's headers and values end \ No newline at end of file From mikej at freeswitch.org Mon Mar 2 08:24:30 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:24:30 -0600 Subject: [Freeswitch-svn] [commit] r12352 - in freeswitch/trunk/libs/spandsp: src src/spandsp test-data/etsi/fax test-data/itu/fax tests Message-ID: Author: mikej Date: Mon Mar 2 10:24:30 2009 New Revision: 12352 Log: update to snapshot spandsp-20090301 Modified: freeswitch/trunk/libs/spandsp/src/Makefile.am freeswitch/trunk/libs/spandsp/src/spandsp/bit_operations.h freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h freeswitch/trunk/libs/spandsp/src/spandsp/version.h freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in freeswitch/trunk/libs/spandsp/src/t4.c freeswitch/trunk/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c freeswitch/trunk/libs/spandsp/test-data/itu/fax/generate_sized_pages.c freeswitch/trunk/libs/spandsp/tests/t4_tests.c Modified: freeswitch/trunk/libs/spandsp/src/Makefile.am ============================================================================== --- freeswitch/trunk/libs/spandsp/src/Makefile.am (original) +++ freeswitch/trunk/libs/spandsp/src/Makefile.am Mon Mar 2 10:24:30 2009 @@ -16,7 +16,7 @@ ## License along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -## $Id: Makefile.am,v 1.127 2009/02/25 15:30:21 steveu Exp $ +## $Id: Makefile.am,v 1.128 2009/03/01 12:49:28 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) @@ -293,6 +293,10 @@ at_interpreter_dictionary.h: make_at_dictionary$(EXEEXT) ./make_at_dictionary$(EXEEXT) >at_interpreter_dictionary.h +t4.$(OBJEXT): spandsp/version.h + +t4.lo: spandsp/version.h + v17rx.$(OBJEXT): v17rx_fixed_rrc.h v17rx_floating_rrc.h v17rx.lo: v17rx_fixed_rrc.h v17rx_floating_rrc.h Modified: freeswitch/trunk/libs/spandsp/src/spandsp/bit_operations.h ============================================================================== --- freeswitch/trunk/libs/spandsp/src/spandsp/bit_operations.h (original) +++ freeswitch/trunk/libs/spandsp/src/spandsp/bit_operations.h Mon Mar 2 10:24:30 2009 @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: bit_operations.h,v 1.25 2009/02/24 14:14:03 steveu Exp $ + * $Id: bit_operations.h,v 1.26 2009/02/26 16:08:50 steveu Exp $ */ /*! \file */ Modified: freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h ============================================================================== --- freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h (original) +++ freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h Mon Mar 2 10:24:30 2009 @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: fast_convert.h,v 1.5 2009/02/24 14:14:03 steveu Exp $ + * $Id: fast_convert.h,v 1.6 2009/02/26 16:08:51 steveu Exp $ */ #if !defined(_SPANDSP_FAST_CONVERT_H_) Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h ============================================================================== --- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original) +++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Mon Mar 2 10:24:30 2009 @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: version.h.in,v 1.2 2007/04/06 13:20:36 steveu Exp $ + * $Id: version.h.in,v 1.3 2009/03/01 12:39:02 steveu Exp $ */ #if !defined(_SPANDSP_VERSION_H_) @@ -30,8 +30,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20090226 -#define SPANDSP_RELEASE_TIME 121601 +#define SPANDSP_RELEASE_DATE 20090301 +#define SPANDSP_RELEASE_TIME 125126 +#define SPANDSP_RELEASE_DATETIME_STRING "20090301 125126" #endif /*- End of file ------------------------------------------------------------*/ Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in ============================================================================== --- freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in (original) +++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in Mon Mar 2 10:24:30 2009 @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: version.h.in,v 1.2 2007/04/06 13:20:36 steveu Exp $ + * $Id: version.h.in,v 1.3 2009/03/01 12:39:02 steveu Exp $ */ #if !defined(_SPANDSP_VERSION_H_) @@ -30,8 +30,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE $SPANDSP_RELEASE_DATE -#define SPANDSP_RELEASE_TIME $SPANDSP_RELEASE_TIME +#define SPANDSP_RELEASE_DATE $SPANDSP_RELEASE_DATE +#define SPANDSP_RELEASE_TIME $SPANDSP_RELEASE_TIME +#define SPANDSP_RELEASE_DATETIME_STRING "$SPANDSP_RELEASE_DATE $SPANDSP_RELEASE_TIME" #endif /*- End of file ------------------------------------------------------------*/ Modified: freeswitch/trunk/libs/spandsp/src/t4.c ============================================================================== --- freeswitch/trunk/libs/spandsp/src/t4.c (original) +++ freeswitch/trunk/libs/spandsp/src/t4.c Mon Mar 2 10:24:30 2009 @@ -24,7 +24,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t4.c,v 1.127 2009/02/21 04:27:46 steveu Exp $ + * $Id: t4.c,v 1.128 2009/03/01 11:47:03 steveu Exp $ */ /* @@ -86,6 +86,7 @@ #include "spandsp/bit_operations.h" #include "spandsp/async.h" #include "spandsp/t4.h" +#include "spandsp/version.h" #include "spandsp/private/logging.h" #include "spandsp/private/t4.h" @@ -205,7 +206,7 @@ TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit); #endif /* TODO: add the version of spandsp */ - TIFFSetField(t->tiff_file, TIFFTAG_SOFTWARE, "spandsp"); + TIFFSetField(t->tiff_file, TIFFTAG_SOFTWARE, "Spandsp " SPANDSP_RELEASE_DATETIME_STRING); if (gethostname(buf, sizeof(buf)) == 0) TIFFSetField(t->tiff_file, TIFFTAG_HOSTCOMPUTER, buf); @@ -330,9 +331,11 @@ if (t->photo_metric != PHOTOMETRIC_MINISWHITE) span_log(&s->logging, SPAN_LOG_FLOW, "%s: Photometric needs swapping.\n", s->file); t->fill_order = FILLORDER_LSB2MSB; +#if 0 TIFFGetField(t->tiff_file, TIFFTAG_FILLORDER, &t->fill_order); if (t->fill_order != FILLORDER_LSB2MSB) span_log(&s->logging, SPAN_LOG_FLOW, "%s: Fill order needs swapping.\n", s->file); +#endif /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the precise value. The other value should be exact. */ Modified: freeswitch/trunk/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c ============================================================================== --- freeswitch/trunk/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c (original) +++ freeswitch/trunk/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c Mon Mar 2 10:24:30 2009 @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: generate_etsi_300_242_pages.c,v 1.3 2009/02/20 12:34:20 steveu Exp $ + * $Id: generate_etsi_300_242_pages.c,v 1.4 2009/03/01 12:39:02 steveu Exp $ */ /*! \file */ @@ -177,8 +177,8 @@ }, }; -int reverse_photo_metric = FALSE; -int reverse_fill_order = FALSE; +int photo_metric = PHOTOMETRIC_MINISWHITE; +int fill_order = FILLORDER_LSB2MSB; static void clear_row(uint8_t buf[], int width) { @@ -256,13 +256,15 @@ { clear_row(image_buffer, 1728); set_pixel_range(image_buffer, 1, start_pixel, start_pixel + 63); - if (reverse_photo_metric) + if (photo_metric != PHOTOMETRIC_MINISWHITE) { for (i = 0; i < 1728/8; i++) image_buffer[i] = ~image_buffer[i]; } - if (reverse_fill_order) +#if 0 + if (fill_order != FILLORDER_LSB2MSB) bit_reverse(image_buffer, image_buffer, 1728/8); +#endif if (TIFFWriteScanline(tiff_file, image_buffer, row, 0) < 0) { printf("Write error at row %d.\n", row); @@ -558,6 +560,37 @@ float y_resolution; int i; int image_length; + int opt; + int compression; + + compression = T4_COMPRESSION_ITU_T6; + photo_metric = PHOTOMETRIC_MINISWHITE; + fill_order = FILLORDER_LSB2MSB; + while ((opt = getopt(argc, argv, "126ir")) != -1) + { + switch (opt) + { + case '1': + compression = T4_COMPRESSION_ITU_T4_1D; + break; + case '2': + compression = T4_COMPRESSION_ITU_T4_2D; + break; + case '6': + compression = T4_COMPRESSION_ITU_T6; + break; + case 'i': + photo_metric = PHOTOMETRIC_MINISBLACK; + break; + case 'r': + fill_order = FILLORDER_MSB2LSB; + break; + default: + //usage(); + exit(2); + break; + } + } tiff_file = NULL; for (i = 0; sequence[i].name; i++) @@ -582,14 +615,8 @@ TIFFSetField(tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - if (reverse_photo_metric) - TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); - else - TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); - if (reverse_fill_order) - TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); - else - TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); + TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, photo_metric); + TIFFSetField(tiff_file, TIFFTAG_FILLORDER, fill_order); x_resolution = sequence[i].x_res/100.0f; y_resolution = sequence[i].y_res/100.0f; TIFFSetField(tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*2.54f + 0.5f)); Modified: freeswitch/trunk/libs/spandsp/test-data/itu/fax/generate_sized_pages.c ============================================================================== --- freeswitch/trunk/libs/spandsp/test-data/itu/fax/generate_sized_pages.c (original) +++ freeswitch/trunk/libs/spandsp/test-data/itu/fax/generate_sized_pages.c Mon Mar 2 10:24:30 2009 @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: generate_sized_pages.c,v 1.2 2008/07/10 13:34:01 steveu Exp $ + * $Id: generate_sized_pages.c,v 1.3 2009/03/01 12:39:02 steveu Exp $ */ /*! \file */ @@ -289,6 +289,39 @@ float x_resolution; float y_resolution; int i; + int opt; + int compression; + int photo_metric; + int fill_order; + + compression = T4_COMPRESSION_ITU_T6; + photo_metric = PHOTOMETRIC_MINISWHITE; + fill_order = FILLORDER_LSB2MSB; + while ((opt = getopt(argc, argv, "126ir")) != -1) + { + switch (opt) + { + case '1': + compression = T4_COMPRESSION_ITU_T4_1D; + break; + case '2': + compression = T4_COMPRESSION_ITU_T4_2D; + break; + case '6': + compression = T4_COMPRESSION_ITU_T6; + break; + case 'i': + photo_metric = PHOTOMETRIC_MINISBLACK; + break; + case 'r': + fill_order = FILLORDER_MSB2LSB; + break; + default: + //usage(); + exit(2); + break; + } + } for (i = 0; sequence[i].name; i++) { @@ -296,15 +329,15 @@ exit(2); /* Prepare the directory entry fully before writing the image, or libtiff complains */ - TIFFSetField(tiff_file, TIFFTAG_COMPRESSION, COMPRESSION_CCITT_T6); + TIFFSetField(tiff_file, TIFFTAG_COMPRESSION, compression); TIFFSetField(tiff_file, TIFFTAG_IMAGEWIDTH, sequence[i].width); TIFFSetField(tiff_file, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); - TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); + TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, photo_metric); + TIFFSetField(tiff_file, TIFFTAG_FILLORDER, fill_order); x_resolution = sequence[i].x_res/100.0f; y_resolution = sequence[i].y_res/100.0f; Modified: freeswitch/trunk/libs/spandsp/tests/t4_tests.c ============================================================================== --- freeswitch/trunk/libs/spandsp/tests/t4_tests.c (original) +++ freeswitch/trunk/libs/spandsp/tests/t4_tests.c Mon Mar 2 10:24:30 2009 @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t4_tests.c,v 1.67 2009/02/20 12:34:20 steveu Exp $ + * $Id: t4_tests.c,v 1.68 2009/03/01 12:39:02 steveu Exp $ */ /*! \file */ @@ -341,6 +341,17 @@ break; } } + else if (sscanf(buf, "%08x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4) + { + for (i = 0; i < 16; i++) + { + if (sscanf(&buf[10 + 3*i], "%x", (unsigned int *) &bit) != 1) + break; + bit = bit_reverse8(bit); + if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) + break; + } + } else if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1) { if ((end_of_page = t4_rx_put_bit(&receive_state, bit))) From mikej at freeswitch.org Mon Mar 2 08:31:34 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:31:34 -0600 Subject: [Freeswitch-svn] [commit] r12353 - freeswitch/trunk/libs/libsndfile/src Message-ID: Author: mikej Date: Mon Mar 2 10:31:34 2009 New Revision: 12353 Log: libsndfile: add executable permissions to libs/libsndfile/src/create_symbols_file.py (FSBUILD-134) Modified: freeswitch/trunk/libs/libsndfile/src/create_symbols_file.py (props changed) From mrene at freeswitch.org Mon Mar 2 08:36:59 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:36:59 -0600 Subject: [Freeswitch-svn] [commit] r12354 - freeswitch/trunk/support-d Message-ID: Author: mrene Date: Mon Mar 2 10:36:59 2009 New Revision: 12354 Log: typo Modified: freeswitch/trunk/support-d/.gdbinit Modified: freeswitch/trunk/support-d/.gdbinit ============================================================================== --- freeswitch/trunk/support-d/.gdbinit (original) +++ freeswitch/trunk/support-d/.gdbinit Mon Mar 2 10:36:59 2009 @@ -58,5 +58,5 @@ end document event_dump Usage: event_dump [switch_event_t*] -Print and event's headers and values +Print an event's headers and values end \ No newline at end of file From brian at freeswitch.org Mon Mar 2 08:40:22 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:40:22 -0600 Subject: [Freeswitch-svn] [commit] r12355 - freeswitch/trunk/conf/dialplan Message-ID: Author: brian Date: Mon Mar 2 10:40:21 2009 New Revision: 12355 Log: typo Modified: freeswitch/trunk/conf/dialplan/default.xml Modified: freeswitch/trunk/conf/dialplan/default.xml ============================================================================== --- freeswitch/trunk/conf/dialplan/default.xml (original) +++ freeswitch/trunk/conf/dialplan/default.xml Mon Mar 2 10:40:21 2009 @@ -368,7 +368,7 @@ - + From brian at freeswitch.org Mon Mar 2 08:47:09 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 10:47:09 -0600 Subject: [Freeswitch-svn] [commit] r12356 - freeswitch/trunk/conf/dialplan Message-ID: Author: brian Date: Mon Mar 2 10:47:09 2009 New Revision: 12356 Log: typo Modified: freeswitch/trunk/conf/dialplan/default.xml Modified: freeswitch/trunk/conf/dialplan/default.xml ============================================================================== --- freeswitch/trunk/conf/dialplan/default.xml (original) +++ freeswitch/trunk/conf/dialplan/default.xml Mon Mar 2 10:47:09 2009 @@ -375,7 +375,7 @@ - + From anthm at freeswitch.org Mon Mar 2 11:30:41 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 13:30:41 -0600 Subject: [Freeswitch-svn] [commit] r12357 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 2 13:30:41 2009 New Revision: 12357 Log: refactor record code in the core Modified: freeswitch/trunk/src/switch_core_media_bug.c freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/switch_core_media_bug.c ============================================================================== --- freeswitch/trunk/src/switch_core_media_bug.c (original) +++ freeswitch/trunk/src/switch_core_media_bug.c Mon Mar 2 13:30:41 2009 @@ -104,105 +104,88 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *bug, switch_frame_t *frame) { - uint32_t bytes = 0; - uint32_t datalen = 0; + switch_size_t bytes = 0, datalen = 0; int16_t *dp, *fp; uint32_t x; size_t rlen = 0; size_t wlen = 0; uint32_t blen; - size_t rdlen = 0; - uint32_t maxlen; switch_codec_implementation_t read_impl = {0}; - switch_core_session_get_read_impl(bug->session, &read_impl); + int16_t *tp; - if (bug->raw_read_buffer) { - rlen = switch_buffer_inuse(bug->raw_read_buffer); - } + switch_core_session_get_read_impl(bug->session, &read_impl); - if (bug->raw_write_buffer) { - wlen = switch_buffer_inuse(bug->raw_write_buffer); - } + bytes = read_impl.decoded_bytes_per_packet; - if ((bug->raw_read_buffer && bug->raw_write_buffer) && (!rlen && !wlen)) { + if (frame->buflen < bytes) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s frame buffer too small!\n", switch_channel_get_name(bug->session->channel)); return SWITCH_STATUS_FALSE; } - - maxlen = SWITCH_RECOMMENDED_BUFFER_SIZE > frame->buflen ? frame->buflen : SWITCH_RECOMMENDED_BUFFER_SIZE; - - if ((rdlen = rlen > wlen ? wlen : rlen) > maxlen) { - rdlen = maxlen; - } - - if (!rdlen) { - rdlen = maxlen; + + if (!(bug->raw_read_buffer && bug->raw_write_buffer)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%sBuffer Error\n", switch_channel_get_name(bug->session->channel)); } - + frame->datalen = 0; - - if (rlen) { - switch_mutex_lock(bug->read_mutex); - - frame->datalen = (uint32_t) switch_buffer_read(bug->raw_read_buffer, frame->data, rdlen); - switch_mutex_unlock(bug->read_mutex); - } - - if (wlen) { - switch_mutex_lock(bug->write_mutex); - datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer, bug->data, rdlen); - switch_mutex_unlock(bug->write_mutex); + + switch_mutex_lock(bug->read_mutex); + frame->datalen = (uint32_t) switch_buffer_read(bug->raw_read_buffer, frame->data, bytes); + if (frame->datalen < bytes) { + memset(((unsigned char *)frame->data) + frame->datalen, 0, bytes - frame->datalen); + frame->datalen = bytes; } - - - bytes = (datalen > frame->datalen) ? datalen : frame->datalen; - switch_assert(bytes <= maxlen); - - if (bytes) { - int16_t *tp = bug->tmp; - - dp = (int16_t *) bug->data; - fp = (int16_t *) frame->data; - rlen = frame->datalen / 2; - wlen = datalen / 2; - blen = bytes / 2; - - if (switch_test_flag(bug, SMBF_STEREO)) { - for (x = 0; x < blen; x++) { - if (x < rlen) { - *(tp++) = *(fp + x); - } else { - *(tp++) = 0; - } - if (x < wlen) { - *(tp++) = *(dp + x); - } else { - *(tp++) = 0; - } + switch_mutex_unlock(bug->read_mutex); + + switch_mutex_lock(bug->write_mutex); + datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer, bug->data, bytes); + if (datalen < bytes) { + memset(((unsigned char *)bug->data) + datalen, 0, bytes - datalen); + datalen = bytes; + } + switch_mutex_unlock(bug->write_mutex); + + tp = bug->tmp; + dp = (int16_t *) bug->data; + fp = (int16_t *) frame->data; + rlen = frame->datalen / 2; + wlen = datalen / 2; + blen = bytes / 2; + + if (switch_test_flag(bug, SMBF_STEREO)) { + for (x = 0; x < blen; x++) { + if (x < rlen) { + *(tp++) = *(fp + x); + } else { + *(tp++) = 0; } - memcpy(frame->data, bug->tmp, bytes * 2); - } else { - for (x = 0; x < blen; x++) { - int32_t z = 0; - - if (x < rlen) { - z += (int32_t) *(fp + x); - } - if (x < wlen) { - z += (int32_t) *(dp + x); - } - switch_normalize_to_16bit(z); - *(fp + x) = (int16_t) z; + if (x < wlen) { + *(tp++) = *(dp + x); + } else { + *(tp++) = 0; } } + memcpy(frame->data, bug->tmp, bytes * 2); + } else { + for (x = 0; x < blen; x++) { + int32_t z = 0; - frame->datalen = bytes; - frame->samples = bytes / sizeof(int16_t); - frame->rate = read_impl.actual_samples_per_second; - - return SWITCH_STATUS_SUCCESS; + if (x < rlen) { + z += (int32_t) *(fp + x); + } + if (x < wlen) { + z += (int32_t) *(dp + x); + } + switch_normalize_to_16bit(z); + *(fp + x) = (int16_t) z / 2; + } } - return SWITCH_STATUS_FALSE; + frame->datalen = bytes; + frame->samples = bytes / sizeof(int16_t); + frame->rate = read_impl.actual_samples_per_second; + frame->codec = NULL; + + return SWITCH_STATUS_SUCCESS; } #define MAX_BUG_BUFFER 1024 * 512 Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Mon Mar 2 13:30:41 2009 @@ -413,11 +413,6 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) { switch_file_handle_t *fh = (switch_file_handle_t *) user_data; - uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_frame_t frame = { 0 }; - - frame.data = data; - frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; switch (type) { case SWITCH_ABC_TYPE_INIT: @@ -427,11 +422,16 @@ switch_core_file_close(fh); } break; - case SWITCH_ABC_TYPE_READ: + case SWITCH_ABC_TYPE_READ_PING: if (fh) { switch_size_t len; switch_core_session_t *session = switch_core_media_bug_get_session(bug); switch_channel_t *channel = switch_core_session_get_channel(session); + uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; + switch_frame_t frame = { 0 }; + + frame.data = data; + frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) { int doit = 1; @@ -441,7 +441,7 @@ if (doit) { len = (switch_size_t) frame.datalen / 2; - switch_core_file_write(fh, frame.data, &len); + switch_core_file_write(fh, data, &len); } } } @@ -482,7 +482,7 @@ struct eavesdrop_pvt *ep = (struct eavesdrop_pvt *) user_data; uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; switch_frame_t frame = { 0 }; - + frame.data = data; frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; @@ -494,7 +494,7 @@ case SWITCH_ABC_TYPE_WRITE: break; case SWITCH_ABC_TYPE_READ_PING: - if (ep->buffer) { + if (ep->buffer) { if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) { switch_buffer_lock(ep->buffer); switch_buffer_zwrite(ep->buffer, frame.data, frame.datalen); @@ -821,7 +821,7 @@ switch_media_bug_t *bug; switch_status_t status; time_t to = 0; - switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM; + switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING; uint8_t channels; switch_codec_implementation_t read_impl = {0}; switch_core_session_get_read_impl(session, &read_impl); From anthm at freeswitch.org Mon Mar 2 11:43:17 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 13:43:17 -0600 Subject: [Freeswitch-svn] [commit] r12358 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Mon Mar 2 13:43:17 2009 New Revision: 12358 Log: MODENDP-192 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Mon Mar 2 13:43:17 2009 @@ -2355,6 +2355,10 @@ nchannel = switch_core_session_get_channel(nsession); + if ((hval = switch_event_get_header(var_event, "sip_invite_to_uri"))) { + dest_to = switch_core_session_strdup(nsession, hval); + } + if (!strncasecmp(profile_name, "gateway", 7)) { char *gw, *params; sofia_gateway_t *gateway_ptr = NULL; From anthm at freeswitch.org Mon Mar 2 12:52:46 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 14:52:46 -0600 Subject: [Freeswitch-svn] [commit] r12359 - in freeswitch/trunk/libs/esl: lua perl php python ruby src src/include Message-ID: Author: anthm Date: Mon Mar 2 14:52:46 2009 New Revision: 12359 Log: add some methods Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp freeswitch/trunk/libs/esl/perl/ESL.pm freeswitch/trunk/libs/esl/perl/esl_wrap.cpp freeswitch/trunk/libs/esl/perl/events.pl freeswitch/trunk/libs/esl/php/ESL.php freeswitch/trunk/libs/esl/php/esl_wrap.cpp freeswitch/trunk/libs/esl/php/php_ESL.h freeswitch/trunk/libs/esl/python/_ESL.py freeswitch/trunk/libs/esl/python/esl_wrap.cpp freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp freeswitch/trunk/libs/esl/src/esl_oop.cpp freeswitch/trunk/libs/esl/src/include/esl_oop.h Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/lua/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/lua/esl_wrap.cpp Mon Mar 2 14:52:46 2009 @@ -2084,6 +2084,56 @@ } +static int _wrap_ESLevent_firstHeader(lua_State* L) { + int SWIG_arg = -1; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + SWIG_check_num_args("firstHeader",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("firstHeader",1,"ESLevent *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLevent,0))){ + SWIG_fail_ptr("ESLevent_firstHeader",1,SWIGTYPE_p_ESLevent); + } + + result = (char *)(arg1)->firstHeader(); + SWIG_arg=0; + lua_pushstring(L,(const char*)result); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_ESLevent_nextHeader(lua_State* L) { + int SWIG_arg = -1; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + + SWIG_check_num_args("nextHeader",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("nextHeader",1,"ESLevent *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLevent,0))){ + SWIG_fail_ptr("ESLevent_nextHeader",1,SWIGTYPE_p_ESLevent); + } + + result = (char *)(arg1)->nextHeader(); + SWIG_arg=0; + lua_pushstring(L,(const char*)result); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static void swig_delete_ESLevent(void *obj) { ESLevent *arg1 = (ESLevent *) obj; delete arg1; @@ -2097,6 +2147,8 @@ {"addBody", _wrap_ESLevent_addBody}, {"addHeader", _wrap_ESLevent_addHeader}, {"delHeader", _wrap_ESLevent_delHeader}, + {"firstHeader", _wrap_ESLevent_firstHeader}, + {"nextHeader", _wrap_ESLevent_nextHeader}, {0,0} }; static swig_lua_attribute swig_ESLevent_attributes[] = { Modified: freeswitch/trunk/libs/esl/perl/ESL.pm ============================================================================== --- freeswitch/trunk/libs/esl/perl/ESL.pm (original) +++ freeswitch/trunk/libs/esl/perl/ESL.pm Mon Mar 2 14:52:46 2009 @@ -89,6 +89,8 @@ *addBody = *ESLc::ESLevent_addBody; *addHeader = *ESLc::ESLevent_addHeader; *delHeader = *ESLc::ESLevent_delHeader; +*firstHeader = *ESLc::ESLevent_firstHeader; +*nextHeader = *ESLc::ESLevent_nextHeader; sub DISOWN { my $self = shift; my $ptr = tied(%$self); Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Mon Mar 2 14:52:46 2009 @@ -2504,6 +2504,62 @@ } +XS(_wrap_ESLevent_firstHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_firstHeader(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_firstHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->firstHeader(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_nextHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_nextHeader(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_nextHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->nextHeader(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + XS(_wrap_new_ESLconnection__SWIG_0) { { char *arg1 = (char *) 0 ; @@ -3361,6 +3417,8 @@ {"ESLc::ESLevent_addBody", _wrap_ESLevent_addBody}, {"ESLc::ESLevent_addHeader", _wrap_ESLevent_addHeader}, {"ESLc::ESLevent_delHeader", _wrap_ESLevent_delHeader}, +{"ESLc::ESLevent_firstHeader", _wrap_ESLevent_firstHeader}, +{"ESLc::ESLevent_nextHeader", _wrap_ESLevent_nextHeader}, {"ESLc::new_ESLconnection", _wrap_new_ESLconnection}, {"ESLc::delete_ESLconnection", _wrap_delete_ESLconnection}, {"ESLc::ESLconnection_connected", _wrap_ESLconnection_connected}, Modified: freeswitch/trunk/libs/esl/perl/events.pl ============================================================================== --- freeswitch/trunk/libs/esl/perl/events.pl (original) +++ freeswitch/trunk/libs/esl/perl/events.pl Mon Mar 2 14:52:46 2009 @@ -4,12 +4,18 @@ $con->events("plain", "all"); -for(;;) { +while($con->connected()) { #my $e = $con->recvEventTimed(100); my $e = $con->recvEvent(); if ($e) { - print $e->serialize(); + #print $e->serialize(); + my $h = $e->firstHeader(); + while ($h) { + printf "Header: [%s] = [%s]\n", $h, $e->getHeader($h); + $h = $e->nextHeader(); + } + } } Modified: freeswitch/trunk/libs/esl/php/ESL.php ============================================================================== --- freeswitch/trunk/libs/esl/php/ESL.php (original) +++ freeswitch/trunk/libs/esl/php/ESL.php Mon Mar 2 14:52:46 2009 @@ -99,6 +99,14 @@ function delHeader($header_name) { return ESLevent_delHeader($this->_cPtr,$header_name); } + + function firstHeader() { + return ESLevent_firstHeader($this->_cPtr); + } + + function nextHeader() { + return ESLevent_nextHeader($this->_cPtr); + } } class ESLconnection { Modified: freeswitch/trunk/libs/esl/php/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/php/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/php/esl_wrap.cpp Mon Mar 2 14:52:46 2009 @@ -1091,7 +1091,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1159,7 +1159,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; @@ -1213,13 +1213,13 @@ WRONG_PARAM_COUNT; - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[0]); arg1 = (char *) Z_STRVAL_PP(args[0]); /*@SWIG@*/; if(arg_count > 1) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1254,7 +1254,7 @@ } } if(arg_count > 1) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; @@ -1384,7 +1384,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); if(arg_count > 1) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1460,7 +1460,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1557,7 +1557,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1591,13 +1591,13 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; @@ -1630,7 +1630,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1645,6 +1645,66 @@ } +ZEND_NAMED_FUNCTION(_wrap_ESLevent_firstHeader) { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + zval **args[1]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + { + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLevent, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLevent_firstHeader. Expected SWIGTYPE_p_ESLevent"); + } + } + if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); + result = (char *)(arg1)->firstHeader(); + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ESLevent_nextHeader) { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + zval **args[1]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + { + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLevent, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLevent_nextHeader. Expected SWIGTYPE_p_ESLevent"); + } + } + if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); + result = (char *)(arg1)->nextHeader(); + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_0) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -1658,19 +1718,19 @@ } - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[0]); arg1 = (char *) Z_STRVAL_PP(args[0]); /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; @@ -1696,7 +1756,7 @@ } - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[0]); arg1 = (int) Z_LVAL_PP(args[0]); /*@SWIG@*/; @@ -1831,7 +1891,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1864,7 +1924,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -1900,13 +1960,13 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; @@ -1943,13 +2003,13 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; @@ -2041,7 +2101,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[1]); arg2 = (int) Z_LVAL_PP(args[1]); /*@SWIG@*/; @@ -2075,13 +2135,13 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; @@ -2115,13 +2175,13 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; @@ -2158,20 +2218,20 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; if(arg_count > 2) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[2]); arg3 = (char *) Z_STRVAL_PP(args[2]); /*@SWIG@*/; } if(arg_count > 3) { - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[3]); arg4 = (char *) Z_STRVAL_PP(args[3]); /*@SWIG@*/; @@ -2205,7 +2265,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -2238,7 +2298,7 @@ } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ convert_to_string_ex(args[1]); arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; @@ -2263,7 +2323,7 @@ } - /*@SWIG:/usr/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ convert_to_long_ex(args[0]); arg1 = (int) Z_LVAL_PP(args[0]); /*@SWIG@*/; @@ -2314,6 +2374,8 @@ SWIG_ZEND_NAMED_FE(eslevent_addbody,_wrap_ESLevent_addBody,NULL) SWIG_ZEND_NAMED_FE(eslevent_addheader,_wrap_ESLevent_addHeader,NULL) SWIG_ZEND_NAMED_FE(eslevent_delheader,_wrap_ESLevent_delHeader,NULL) + SWIG_ZEND_NAMED_FE(eslevent_firstheader,_wrap_ESLevent_firstHeader,NULL) + SWIG_ZEND_NAMED_FE(eslevent_nextheader,_wrap_ESLevent_nextHeader,NULL) SWIG_ZEND_NAMED_FE(new_eslconnection,_wrap_new_ESLconnection,NULL) SWIG_ZEND_NAMED_FE(eslconnection_connected,_wrap_ESLconnection_connected,NULL) SWIG_ZEND_NAMED_FE(eslconnection_getinfo,_wrap_ESLconnection_getInfo,NULL) Modified: freeswitch/trunk/libs/esl/php/php_ESL.h ============================================================================== --- freeswitch/trunk/libs/esl/php/php_ESL.h (original) +++ freeswitch/trunk/libs/esl/php/php_ESL.h Mon Mar 2 14:52:46 2009 @@ -47,6 +47,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_addBody); ZEND_NAMED_FUNCTION(_wrap_ESLevent_addHeader); ZEND_NAMED_FUNCTION(_wrap_ESLevent_delHeader); +ZEND_NAMED_FUNCTION(_wrap_ESLevent_firstHeader); +ZEND_NAMED_FUNCTION(_wrap_ESLevent_nextHeader); ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_connected); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_getInfo); Modified: freeswitch/trunk/libs/esl/python/_ESL.py ============================================================================== --- freeswitch/trunk/libs/esl/python/_ESL.py (original) +++ freeswitch/trunk/libs/esl/python/_ESL.py Mon Mar 2 14:52:46 2009 @@ -60,6 +60,8 @@ def addBody(*args): return apply(__ESL.ESLevent_addBody, args) def addHeader(*args): return apply(__ESL.ESLevent_addHeader, args) def delHeader(*args): return apply(__ESL.ESLevent_delHeader, args) + def firstHeader(*args): return apply(__ESL.ESLevent_firstHeader, args) + def nextHeader(*args): return apply(__ESL.ESLevent_nextHeader, args) ESLevent_swigregister = __ESL.ESLevent_swigregister ESLevent_swigregister(ESLevent) Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/python/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp Mon Mar 2 14:52:46 2009 @@ -3469,6 +3469,50 @@ } +SWIGINTERN PyObject *_wrap_ESLevent_firstHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_firstHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_firstHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->firstHeader(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_nextHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_nextHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_nextHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->nextHeader(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *ESLevent_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; @@ -4174,6 +4218,8 @@ { (char *)"ESLevent_addBody", _wrap_ESLevent_addBody, METH_VARARGS, NULL}, { (char *)"ESLevent_addHeader", _wrap_ESLevent_addHeader, METH_VARARGS, NULL}, { (char *)"ESLevent_delHeader", _wrap_ESLevent_delHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_firstHeader", _wrap_ESLevent_firstHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_nextHeader", _wrap_ESLevent_nextHeader, METH_VARARGS, NULL}, { (char *)"ESLevent_swigregister", ESLevent_swigregister, METH_VARARGS, NULL}, { (char *)"new_ESLconnection", _wrap_new_ESLconnection, METH_VARARGS, NULL}, { (char *)"delete_ESLconnection", _wrap_delete_ESLconnection, METH_VARARGS, NULL}, Modified: freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp Mon Mar 2 14:52:46 2009 @@ -1902,7 +1902,7 @@ } -/*@SWIG:/usr/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/ +/*@SWIG:/usr/local/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) { VALUE obj = args[0]; @@ -2591,6 +2591,54 @@ } +SWIGINTERN VALUE +_wrap_ESLevent_firstHeader(int argc, VALUE *argv, VALUE self) { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLevent *","firstHeader", 1, self )); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->firstHeader(); + vresult = SWIG_FromCharPtr((const char *)result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ESLevent_nextHeader(int argc, VALUE *argv, VALUE self) { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLevent *","nextHeader", 1, self )); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->nextHeader(); + vresult = SWIG_FromCharPtr((const char *)result); + return vresult; +fail: + return Qnil; +} + + swig_class cESLconnection; SWIGINTERN VALUE @@ -3586,6 +3634,8 @@ rb_define_method(cESLevent.klass, "addBody", VALUEFUNC(_wrap_ESLevent_addBody), -1); rb_define_method(cESLevent.klass, "addHeader", VALUEFUNC(_wrap_ESLevent_addHeader), -1); rb_define_method(cESLevent.klass, "delHeader", VALUEFUNC(_wrap_ESLevent_delHeader), -1); + rb_define_method(cESLevent.klass, "firstHeader", VALUEFUNC(_wrap_ESLevent_firstHeader), -1); + rb_define_method(cESLevent.klass, "nextHeader", VALUEFUNC(_wrap_ESLevent_nextHeader), -1); cESLevent.mark = 0; cESLevent.destroy = (void (*)(void *)) free_ESLevent; cESLevent.trackObjects = 0; Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Mon Mar 2 14:52:46 2009 @@ -2,7 +2,7 @@ #include #define connection_construct_common() memset(&handle, 0, sizeof(handle)); last_event_obj = NULL -#define event_construct_common() event = NULL; serialized_string = NULL; mine = 0 +#define event_construct_common() event = NULL; serialized_string = NULL; mine = 0; hp = NULL void eslSetLogLevel(int level) { @@ -264,6 +264,26 @@ } } +const char *ESLevent::nextHeader(void) +{ + const char *name = NULL; + + if (hp) { + name = hp->name; + hp = hp->next; + } + + return name; +} + +const char *ESLevent::firstHeader(void) +{ + if (event) { + hp = event->headers; + } + + return nextHeader(); +} const char *ESLevent::serialize(const char *format) { Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Mon Mar 2 14:52:46 2009 @@ -44,6 +44,8 @@ class ESLevent { + private: + esl_event_header_t *hp; public: esl_event_t *event; char *serialized_string; @@ -61,6 +63,8 @@ bool addBody(const char *value); bool addHeader(const char *header_name, const char *value); bool delHeader(const char *header_name); + const char *firstHeader(void); + const char *nextHeader(void); }; From anthm at freeswitch.org Mon Mar 2 14:19:36 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 16:19:36 -0600 Subject: [Freeswitch-svn] [commit] r12360 - freeswitch/trunk/libs/esl/src Message-ID: Author: anthm Date: Mon Mar 2 16:19:36 2009 New Revision: 12360 Log: ESL-4 Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Mon Mar 2 16:19:36 2009 @@ -69,7 +69,8 @@ assert(cmd_buf); snprintf(cmd_buf, len, "api %s %s", cmd, arg ? arg : ""); - *(cmd_buf + len) = '\0'; + *(cmd_buf + (len + 1)) = '\0'; + if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) { esl_event_t *event; From anthm at freeswitch.org Mon Mar 2 15:55:00 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 17:55:00 -0600 Subject: [Freeswitch-svn] [commit] r12361 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Mon Mar 2 17:55:00 2009 New Revision: 12361 Log: FSCORE-297 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_scheduler.c freeswitch/trunk/src/switch_time.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Mar 2 17:55:00 2009 @@ -394,9 +394,9 @@ (char *) sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key), network_ip, NULL, 0, REG_INVITE, NULL); } - + if (auth_res != AUTH_OK) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + //switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); nua_respond(nh, SIP_401_UNAUTHORIZED, TAG_END()); goto done; } Modified: freeswitch/trunk/src/switch_scheduler.c ============================================================================== --- freeswitch/trunk/src/switch_scheduler.c (original) +++ freeswitch/trunk/src/switch_scheduler.c Mon Mar 2 17:55:00 2009 @@ -285,9 +285,11 @@ return delcnt; } +switch_thread_t *task_thread_p = NULL; + SWITCH_DECLARE(void) switch_scheduler_task_thread_start(void) { - switch_thread_t *thread; + switch_threadattr_t *thd_attr; switch_core_new_memory_pool(&globals.memory_pool); @@ -295,7 +297,7 @@ switch_mutex_init(&globals.task_mutex, SWITCH_MUTEX_NESTED, globals.memory_pool); switch_threadattr_detach_set(thd_attr, 1); - switch_thread_create(&thread, thd_attr, switch_scheduler_task_thread, NULL, globals.memory_pool); + switch_thread_create(task_thread_p, thd_attr, switch_scheduler_task_thread, NULL, globals.memory_pool); } SWITCH_DECLARE(void) switch_scheduler_task_thread_stop(void) @@ -303,8 +305,11 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping Task Thread\n"); if (globals.task_thread_running == 1) { int sanity = 0; + switch_status_t st; globals.task_thread_running = -1; + + switch_thread_join(&st, task_thread_p); while (globals.task_thread_running) { switch_yield(100000); Modified: freeswitch/trunk/src/switch_time.c ============================================================================== --- freeswitch/trunk/src/switch_time.c (original) +++ freeswitch/trunk/src/switch_time.c Mon Mar 2 17:55:00 2009 @@ -174,7 +174,7 @@ SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t) { - if (t < 1000 || t >= 10000) { + if (!globals.RUNNING || t < 1000 || t >= 10000) { do_sleep(t); return; } From anthm at freeswitch.org Mon Mar 2 15:59:04 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 17:59:04 -0600 Subject: [Freeswitch-svn] [commit] r12362 - freeswitch/trunk/libs/esl/src Message-ID: Author: anthm Date: Mon Mar 2 17:59:04 2009 New Revision: 12362 Log: return nothing on timeout Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Mon Mar 2 17:59:04 2009 @@ -186,8 +186,7 @@ } } - last_event_obj = new ESLevent("server_disconnected"); - return last_event_obj; + return NULL; } int ESLconnection::filter(const char *header, const char *value) From anthm at freeswitch.org Mon Mar 2 16:21:11 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 18:21:11 -0600 Subject: [Freeswitch-svn] [commit] r12363 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 2 18:21:11 2009 New Revision: 12363 Log: doh Modified: freeswitch/trunk/src/switch_scheduler.c Modified: freeswitch/trunk/src/switch_scheduler.c ============================================================================== --- freeswitch/trunk/src/switch_scheduler.c (original) +++ freeswitch/trunk/src/switch_scheduler.c Mon Mar 2 18:21:11 2009 @@ -297,7 +297,7 @@ switch_mutex_init(&globals.task_mutex, SWITCH_MUTEX_NESTED, globals.memory_pool); switch_threadattr_detach_set(thd_attr, 1); - switch_thread_create(task_thread_p, thd_attr, switch_scheduler_task_thread, NULL, globals.memory_pool); + switch_thread_create(&task_thread_p, thd_attr, switch_scheduler_task_thread, NULL, globals.memory_pool); } SWITCH_DECLARE(void) switch_scheduler_task_thread_stop(void) From mcollins at freeswitch.org Mon Mar 2 16:28:16 2009 From: mcollins at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 18:28:16 -0600 Subject: [Freeswitch-svn] [commit] r12364 - freeswitch/trunk/build Message-ID: Author: mcollins Date: Mon Mar 2 18:28:16 2009 New Revision: 12364 Log: Add commented out mod_http to modules.conf.in Modified: freeswitch/trunk/build/modules.conf.in Modified: freeswitch/trunk/build/modules.conf.in ============================================================================== --- freeswitch/trunk/build/modules.conf.in (original) +++ freeswitch/trunk/build/modules.conf.in Mon Mar 2 18:28:16 2009 @@ -7,6 +7,7 @@ applications/mod_enum applications/mod_fifo #applications/mod_fax +#applications/mod_http applications/mod_voicemail #applications/mod_lcr applications/mod_limit From mrene at freeswitch.org Mon Mar 2 17:52:25 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Mar 2009 19:52:25 -0600 Subject: [Freeswitch-svn] [commit] r12365 - freeswitch/trunk/src Message-ID: Author: mrene Date: Mon Mar 2 19:52:25 2009 New Revision: 12365 Log: Add log message when the softtimer thread exits Modified: freeswitch/trunk/src/switch_time.c Modified: freeswitch/trunk/src/switch_time.c ============================================================================== --- freeswitch/trunk/src/switch_time.c (original) +++ freeswitch/trunk/src/switch_time.c Mon Mar 2 19:52:25 2009 @@ -553,7 +553,7 @@ globals.RUNNING = 0; switch_mutex_unlock(globals.mutex); - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Soft timer thread exiting.\n"); return SWITCH_STATUS_TERM; } From anthm at freeswitch.org Tue Mar 3 06:17:29 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 08:17:29 -0600 Subject: [Freeswitch-svn] [commit] r12366 - freeswitch/trunk/src Message-ID: Author: anthm Date: Tue Mar 3 08:17:28 2009 New Revision: 12366 Log: FSCORE-316 Modified: freeswitch/trunk/src/switch_utils.c Modified: freeswitch/trunk/src/switch_utils.c ============================================================================== --- freeswitch/trunk/src/switch_utils.c (original) +++ freeswitch/trunk/src/switch_utils.c Tue Mar 3 08:17:28 2009 @@ -1475,7 +1475,7 @@ break; } if (*p < ' ' || *p > '~' || strchr(urlunsafe, *p)) { - if ((x + 3) >= len) { + if ((x + 3) > len) { break; } buf[x++] = '%'; From anthm at freeswitch.org Tue Mar 3 06:21:26 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 08:21:26 -0600 Subject: [Freeswitch-svn] [commit] r12367 - freeswitch/trunk/src/mod/applications/mod_voicemail Message-ID: Author: anthm Date: Tue Mar 3 08:21:26 2009 New Revision: 12367 Log: MODAPP-225 Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Tue Mar 3 08:21:26 2009 @@ -2886,6 +2886,8 @@ args.buf = buf; args.buflen = sizeof(buf); + switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL); + if (!switch_strlen_zero(greet_path)) { memset(buf, 0, sizeof(buf)); TRY_CODE(switch_ivr_play_file(session, NULL, greet_path, &args)); From brian at freeswitch.org Tue Mar 3 08:55:08 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 10:55:08 -0600 Subject: [Freeswitch-svn] [commit] r12368 - freeswitch/trunk/src Message-ID: Author: brian Date: Tue Mar 3 10:55:07 2009 New Revision: 12368 Log: fix MODAPP-224 Modified: freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Tue Mar 3 10:55:07 2009 @@ -182,7 +182,14 @@ break; case SWITCH_ABC_TYPE_CLOSE: if (dh) { + switch_core_session_t *session = switch_core_media_bug_get_session(bug); + switch_channel_t *channel; + switch_core_file_close(&dh->fh); + + if (session && (channel = switch_core_session_get_channel(session))) { + switch_channel_set_private(channel, dh->file, NULL); + } } break; case SWITCH_ABC_TYPE_READ_REPLACE: @@ -256,7 +263,14 @@ break; case SWITCH_ABC_TYPE_CLOSE: if (dh) { + switch_core_session_t *session = switch_core_media_bug_get_session(bug); + switch_channel_t *channel; + switch_core_file_close(&dh->fh); + + if (session && (channel = switch_core_session_get_channel(session))) { + switch_channel_set_private(channel, dh->file, NULL); + } } break; case SWITCH_ABC_TYPE_WRITE_REPLACE: From mrene at freeswitch.org Tue Mar 3 08:58:25 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 10:58:25 -0600 Subject: [Freeswitch-svn] [commit] r12369 - in freeswitch/trunk/src: . include Message-ID: Author: mrene Date: Tue Mar 3 10:58:24 2009 New Revision: 12369 Log: MODAPP-244 bkw stop trying to commit faster than me :P Modified: freeswitch/trunk/src/include/switch_channel.h freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Mar 3 10:58:24 2009 @@ -410,6 +410,14 @@ SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, const char *key); /*! + \brief Unsets private from a given channel + \param channel channel to unsets data from + \param key your private data's unique keyname + \return void pointer to channel's private data +*/ +SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key); + +/*! \brief Assign a name to a given channel \param channel channel to assign name to \param name name to assign Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Tue Mar 3 10:58:24 2009 @@ -565,6 +565,18 @@ return SWITCH_STATUS_SUCCESS; } +SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key) +{ + switch_status_t status; + switch_assert(channel != NULL); + + switch_mutex_lock(channel->profile_mutex); + status = switch_core_hash_delete(channel->private_hash, key); + switch_mutex_unlock(channel->profile_mutex); + + return status; +} + SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, const char *key) { void *val; Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Tue Mar 3 10:58:24 2009 @@ -188,7 +188,7 @@ switch_core_file_close(&dh->fh); if (session && (channel = switch_core_session_get_channel(session))) { - switch_channel_set_private(channel, dh->file, NULL); + switch_channel_unset_private(channel, dh->file); } } break; @@ -269,7 +269,7 @@ switch_core_file_close(&dh->fh); if (session && (channel = switch_core_session_get_channel(session))) { - switch_channel_set_private(channel, dh->file, NULL); + switch_channel_unset_private(channel, dh->file); } } break; From mrene at freeswitch.org Tue Mar 3 09:01:50 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:01:50 -0600 Subject: [Freeswitch-svn] [commit] r12370 - in freeswitch/trunk/src: . include mod/applications/mod_limit mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Tue Mar 3 11:01:50 2009 New Revision: 12370 Log: fix doxygen comment Modified: freeswitch/trunk/src/include/switch_channel.h freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/switch_core.c freeswitch/trunk/src/switch_core_db.c Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Mar 3 11:01:50 2009 @@ -413,7 +413,7 @@ \brief Unsets private from a given channel \param channel channel to unsets data from \param key your private data's unique keyname - \return void pointer to channel's private data + \return SWITCH_STATUS_SUCCESS if data was unset */ SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key); Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Tue Mar 3 11:01:50 2009 @@ -289,7 +289,7 @@ sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname); limit_execute_sql(sql, globals.mutex); - switch_safe_free(sql); + switch_core_db_free(sql); switch_xml_free(xml); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Tue Mar 3 11:01:50 2009 @@ -3133,7 +3133,7 @@ switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_registrations", NULL); switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL); } - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname); @@ -3143,7 +3143,7 @@ switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL); } - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { @@ -3158,21 +3158,21 @@ switch_odbc_handle_exec(profile->master_odbc, pres_sql, NULL); } - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_authentication where hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_authentication", NULL); switch_odbc_handle_exec(profile->master_odbc, auth_sql, NULL); } - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL); switch_odbc_handle_exec(profile->master_odbc, shared_appearance_sql, NULL); } - free(test_sql); + switch_core_db_free(test_sql); for (x = 0; indexes[x]; x++) { switch_odbc_handle_exec(profile->master_odbc, indexes[x], NULL); @@ -3192,28 +3192,28 @@ mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql); - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql); - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_dialogs", dialog_sql); - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_presence where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_presence", pres_sql); - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_authentication where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_sql); - free(test_sql); + switch_core_db_free(test_sql); test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql); - free(test_sql); + switch_core_db_free(test_sql); switch_core_db_exec(profile->master_db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)", NULL, NULL, NULL); Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Tue Mar 3 11:01:50 2009 @@ -758,7 +758,7 @@ end: - switch_safe_free(mime_path); + switch_core_db_free(mime_path); } @@ -1034,7 +1034,7 @@ dir_path = switch_mprintf("%s%ssounds", SWITCH_GLOBAL_dirs.base_dir, SWITCH_PATH_SEPARATOR); switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); - switch_safe_free(dir_path); + switch_core_db_free(dir_path); switch_dir_make_recursive(SWITCH_GLOBAL_dirs.base_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); switch_dir_make_recursive(SWITCH_GLOBAL_dirs.mod_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); switch_dir_make_recursive(SWITCH_GLOBAL_dirs.conf_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); Modified: freeswitch/trunk/src/switch_core_db.c ============================================================================== --- freeswitch/trunk/src/switch_core_db.c (original) +++ freeswitch/trunk/src/switch_core_db.c Tue Mar 3 11:01:50 2009 @@ -85,7 +85,7 @@ ret = sqlite3_exec(db, sql, callback, data, &err); if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) { if (sane > 1) { - switch_safe_free(err); + switch_core_db_free(err); switch_cond_next(); continue; } From mrene at freeswitch.org Tue Mar 3 09:03:48 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:03:48 -0600 Subject: [Freeswitch-svn] [commit] r12371 - in freeswitch/trunk/src: . include mod/applications/mod_limit mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Tue Mar 3 11:03:48 2009 New Revision: 12371 Log: Revert 12370 Modified: freeswitch/trunk/src/include/switch_channel.h freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/switch_core.c freeswitch/trunk/src/switch_core_db.c Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Mar 3 11:03:48 2009 @@ -413,7 +413,7 @@ \brief Unsets private from a given channel \param channel channel to unsets data from \param key your private data's unique keyname - \return SWITCH_STATUS_SUCCESS if data was unset + \return void pointer to channel's private data */ SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key); Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Tue Mar 3 11:03:48 2009 @@ -289,7 +289,7 @@ sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname); limit_execute_sql(sql, globals.mutex); - switch_core_db_free(sql); + switch_safe_free(sql); switch_xml_free(xml); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Tue Mar 3 11:03:48 2009 @@ -3133,7 +3133,7 @@ switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_registrations", NULL); switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL); } - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname); @@ -3143,7 +3143,7 @@ switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL); } - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { @@ -3158,21 +3158,21 @@ switch_odbc_handle_exec(profile->master_odbc, pres_sql, NULL); } - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_authentication where hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_authentication", NULL); switch_odbc_handle_exec(profile->master_odbc, auth_sql, NULL); } - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL); switch_odbc_handle_exec(profile->master_odbc, shared_appearance_sql, NULL); } - switch_core_db_free(test_sql); + free(test_sql); for (x = 0; indexes[x]; x++) { switch_odbc_handle_exec(profile->master_odbc, indexes[x], NULL); @@ -3192,28 +3192,28 @@ mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql); - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql); - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_dialogs", dialog_sql); - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_presence where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_presence", pres_sql); - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_authentication where hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_sql); - switch_core_db_free(test_sql); + free(test_sql); test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql); - switch_core_db_free(test_sql); + free(test_sql); switch_core_db_exec(profile->master_db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)", NULL, NULL, NULL); Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Tue Mar 3 11:03:48 2009 @@ -758,7 +758,7 @@ end: - switch_core_db_free(mime_path); + switch_safe_free(mime_path); } @@ -1034,7 +1034,7 @@ dir_path = switch_mprintf("%s%ssounds", SWITCH_GLOBAL_dirs.base_dir, SWITCH_PATH_SEPARATOR); switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); - switch_core_db_free(dir_path); + switch_safe_free(dir_path); switch_dir_make_recursive(SWITCH_GLOBAL_dirs.base_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); switch_dir_make_recursive(SWITCH_GLOBAL_dirs.mod_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); switch_dir_make_recursive(SWITCH_GLOBAL_dirs.conf_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool); Modified: freeswitch/trunk/src/switch_core_db.c ============================================================================== --- freeswitch/trunk/src/switch_core_db.c (original) +++ freeswitch/trunk/src/switch_core_db.c Tue Mar 3 11:03:48 2009 @@ -85,7 +85,7 @@ ret = sqlite3_exec(db, sql, callback, data, &err); if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) { if (sane > 1) { - switch_core_db_free(err); + switch_safe_free(err); switch_cond_next(); continue; } From mrene at freeswitch.org Tue Mar 3 09:05:18 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:05:18 -0600 Subject: [Freeswitch-svn] [commit] r12372 - freeswitch/trunk/src/include Message-ID: Author: mrene Date: Tue Mar 3 11:05:17 2009 New Revision: 12372 Log: Fix doxygen comment without messing with the rest Modified: freeswitch/trunk/src/include/switch_channel.h Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Mar 3 11:05:17 2009 @@ -413,7 +413,7 @@ \brief Unsets private from a given channel \param channel channel to unsets data from \param key your private data's unique keyname - \return void pointer to channel's private data + \return void SWITCH_STATUS_SUCCESS if data was unset */ SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key); From mrene at freeswitch.org Tue Mar 3 09:14:59 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:14:59 -0600 Subject: [Freeswitch-svn] [commit] r12373 - in freeswitch/trunk/src: . include Message-ID: Author: mrene Date: Tue Mar 3 11:14:58 2009 New Revision: 12373 Log: Revert 12369 since inserting NULL is the same as deleting in sqlite3 Modified: freeswitch/trunk/src/include/switch_channel.h freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Mar 3 11:14:58 2009 @@ -410,14 +410,6 @@ SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, const char *key); /*! - \brief Unsets private from a given channel - \param channel channel to unsets data from - \param key your private data's unique keyname - \return void SWITCH_STATUS_SUCCESS if data was unset -*/ -SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key); - -/*! \brief Assign a name to a given channel \param channel channel to assign name to \param name name to assign Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Tue Mar 3 11:14:58 2009 @@ -565,18 +565,6 @@ return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(switch_status_t) switch_channel_unset_private(switch_channel_t *channel, const char *key) -{ - switch_status_t status; - switch_assert(channel != NULL); - - switch_mutex_lock(channel->profile_mutex); - status = switch_core_hash_delete(channel->private_hash, key); - switch_mutex_unlock(channel->profile_mutex); - - return status; -} - SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, const char *key) { void *val; Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Tue Mar 3 11:14:58 2009 @@ -188,7 +188,7 @@ switch_core_file_close(&dh->fh); if (session && (channel = switch_core_session_get_channel(session))) { - switch_channel_unset_private(channel, dh->file); + switch_channel_set_private(channel, dh->file, NULL); } } break; @@ -269,7 +269,7 @@ switch_core_file_close(&dh->fh); if (session && (channel = switch_core_session_get_channel(session))) { - switch_channel_unset_private(channel, dh->file); + switch_channel_set_private(channel, dh->file, NULL); } } break; From mikej at freeswitch.org Tue Mar 3 09:19:09 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:19:09 -0600 Subject: [Freeswitch-svn] [commit] r12374 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/tport Message-ID: Author: mikej Date: Tue Mar 3 11:19:09 2009 New Revision: 12374 Log: Tue Mar 3 07:56:30 CST 2009 Pekka Pessi * tport.c: add TPTAG_LOG() and TPTAG_DUMP() to tport_get_params() Fixed return value from tport_set_params(), too. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:19:09 2009 @@ -1 +1 @@ -Thu Feb 26 12:40:06 CST 2009 +Tue Mar 3 11:18:41 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c Tue Mar 3 11:19:09 2009 @@ -472,6 +472,7 @@ tp_name_t const *tpn; tport_t *tp; unsigned idle; + int logging = -1; BEGIN(); @@ -552,6 +553,15 @@ TPTAG_IDLE_REF(idle), TAG_END()), 1); + /* Check that logging tag works */ + TEST(tport_get_params(tt->tt_srv_tports, + TPTAG_LOG_REF(logging), + TAG_END()), 1); + TEST(tport_set_params(tt->tt_srv_tports, + TPTAG_LOG(logging), + TAG_END()), 1); + + for (tp = tport_primaries(tt->tt_srv_tports); tp; tp = tport_next(tp)) TEST_S(tport_name(tp)->tpn_ident, "server"); @@ -1298,6 +1308,7 @@ TEST_1(pending_client_close > 0); tp = tt->tt_rtport; pending_server_close = tport_pend(tp, NULL, server_closed_callback, NULL); + TEST_1(pending_server_close > 0); /* Send a largish message */ Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c Tue Mar 3 11:19:09 2009 @@ -1196,6 +1196,7 @@ int n; tport_params_t const *tpp; int connect; + tport_master_t *mr = self->tp_master; if (self == NULL) return su_seterrno(EINVAL); @@ -1227,6 +1228,10 @@ TPTAG_PUBLIC(self->tp_pri ? self->tp_pri->pri_public : 0)), TPTAG_TOS(tpp->tpp_tos), + TAG_IF((void *)self == (void *)mr, + TPTAG_LOG(mr->mr_log != 0)), + TAG_IF((void *)self == (void *)mr, + TPTAG_DUMP(mr->mr_dump)), TAG_END()); ta_end(ta); @@ -1321,7 +1326,7 @@ tpp->tpp_pong2ping = pong2ping; if (memcmp(tpp0, tpp, sizeof tpp) == 0) - return n; + return n + m; if (tport_is_secondary(self) && self->tp_params == self->tp_pri->pri_primary->tp_params) { From mikej at freeswitch.org Tue Mar 3 09:19:58 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:19:58 -0600 Subject: [Freeswitch-svn] [commit] r12375 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:19:58 2009 New Revision: 12375 Log: Mon Mar 2 11:21:17 CST 2009 Pekka Pessi * sl_utils_print.c: propagate error from fwrite() Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:19:58 2009 @@ -1 +1 @@ -Tue Mar 3 11:18:41 CST 2009 +Tue Mar 3 11:19:17 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c Tue Mar 3 11:19:58 2009 @@ -218,11 +218,18 @@ crlf = su_strnspn(s + n, end - s - n, "\r\n"); if (prefix) fputs(prefix, stream), total += strlen(prefix); +v v v v v v v actual = fwrite(s, 1, n + crlf, stream) ; if (actual == 0) return -1; s += actual; total += actual; +************* + if (fwrite(s, 1, n + crlf, stream) < n + crlf) + return (issize_t)-1; + s += n + crlf; + total += n + crlf; +^ ^ ^ ^ ^ ^ ^ } if (crlf == 0) fputs("\n", stream), total++; From mikej at freeswitch.org Tue Mar 3 09:20:24 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:20:24 -0600 Subject: [Freeswitch-svn] [commit] r12376 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 3 11:20:24 2009 New Revision: 12376 Log: Thu Feb 26 15:39:37 CST 2009 Pekka Pessi * nua/check_simple.c: removed extra debug logging, fixed 6.3.4 name Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:20:24 2009 @@ -1 +1 @@ -Tue Mar 3 11:19:17 CST 2009 +Tue Mar 3 11:20:05 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Tue Mar 3 11:20:24 2009 @@ -711,7 +711,7 @@ struct event *response; sip_t *sip; - s2_case("6.3.3", "NOTIFY server - terminate with error response to NOTIFY", + s2_case("6.3.4", "NOTIFY server - terminate with error response to NOTIFY", "NUA receives SUBSCRIBE, sends 202 and NOTIFY. " "The subscription terminates when watcher " "returns 481 to second NOTIFY. The queued 3rd NOTIFY gets " @@ -719,9 +719,6 @@ nh = subscribe_to_nua("presence", SIPTAG_EXPIRES_STR("300"), TAG_END()); - tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); - s2_setup_logs(7); - nua_notify(nh, NUTAG_SUBSTATE(nua_substate_active), SIPTAG_PAYLOAD_STR(presence_closed), Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Tue Mar 3 11:20:24 2009 @@ -1767,11 +1767,23 @@ else if (nh->nh_soa == NULL) { offer_sent = session_get_description(sip, NULL, NULL); } - /* When 100rel response status was 183 do support for preconditions */ - else if (ss->ss_precondition && cri->cr_status == 183 && - cri->cr_offer_sent && cri->cr_answer_recv) { - if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 || - session_include_description(nh->nh_soa, 1, msg, sip) < 0) { + else { + /* When 100rel response status was 183 do support for preconditions */ + int send_offer = ss->ss_precondition && + cri->cr_status == 183 && cri->cr_offer_sent && cri->cr_answer_recv; + + if (!send_offer) { + tagi_t const *t = tl_find_last(tags, nutag_include_extra_sdp); + send_offer = t && t->t_value; + } + + if (!send_offer) { + } + else if (soa_generate_offer(nh->nh_soa, 0, NULL) >= 0 && + session_include_description(nh->nh_soa, 1, msg, sip) >= 0) { + offer_sent = 1; + } + else { status = soa_error_as_sip_response(nh->nh_soa, &phrase); SU_DEBUG_3(("nua(%p): PRACK offer: %d %s\n", (void *)nh, status, phrase)); @@ -1779,9 +1791,6 @@ nua_i_media_error, status, phrase, NULL); return nua_client_return(cr, status, phrase, msg); } - else { - offer_sent = 1; - } } retval = nua_base_client_request(cr, msg, sip, NULL); From mikej at freeswitch.org Tue Mar 3 09:20:55 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:20:55 -0600 Subject: [Freeswitch-svn] [commit] r12377 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 3 11:20:55 2009 New Revision: 12377 Log: Thu Feb 26 16:28:28 CST 2009 Pekka Pessi * nua/check_session.c: added test cases for REFER Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:20:55 2009 @@ -1 +1 @@ -Tue Mar 3 11:20:05 CST 2009 +Tue Mar 3 11:20:37 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 3 11:20:55 2009 @@ -96,9 +96,13 @@ s2_register_teardown(); + mark_point(); + nua_shutdown(nua); fail_unless(s2_check_event(nua_r_shutdown, 200)); + mark_point(); + s2_nua_teardown(); } @@ -3095,6 +3099,145 @@ call_teardown(); } +/* ====================================================================== */ +/* Test cases for REFER */ + +START_TEST(refer_5_2_1) +{ + nua_handle_t *nh; + sip_refer_to_t r[1]; + struct event *refer; + struct message *notify; + + s2_case("5.2.1", "Receive REFER", + "Make a call, receive REFER."); + + nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + invite_by_nua(nh, TAG_END()); + + *sip_refer_to_init(r)->r_url = *s2->local->a_url; + r->r_url->url_user = "bob2"; + + s2_request_to(dialog, SIP_METHOD_REFER, NULL, + SIPTAG_REFER_TO(r), + TAG_END()); + refer = s2_wait_for_event(nua_i_refer, 202); + + bye_by_nua(nh, TAG_END()); + + nua_handle_destroy(nh); + + notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); +} +END_TEST + + +START_TEST(refer_5_2_2) +{ + nua_handle_t *nh, *nh2; + sip_refer_to_t r[1]; + sip_referred_by_t by[1]; + struct event *refer, *notified; + sip_t const *sip; + sip_event_t const *refer_event = NULL; + sip_subscription_state_t const *ss; + struct message *invite; + struct message *notify0, *notify1, *notify2; + struct dialog *dialog1, *dialog2; + + s2_case("5.2.2", "Receive REFER", + "Make a call, receive REFER, " + "make another call with automatic NOTIFYs"); + + dialog2 = su_home_new(sizeof *dialog2); fail_unless(dialog2 != NULL); + + nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + invite_by_nua(nh, TAG_END()); + + *sip_refer_to_init(r)->r_url = *s2->local->a_url; + r->r_url->url_user = "bob2"; + + tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); + s2_setup_logs(7); + + s2_request_to(dialog, SIP_METHOD_REFER, NULL, + SIPTAG_REFER_TO(r), + TAG_END()); + refer = s2_wait_for_event(nua_i_refer, 202); + sip = sip_object(refer->data->e_msg); + fail_unless(sip && sip->sip_refer_to); + + bye_by_nua(nh, TAG_END()); + + dialog1 = dialog, dialog = dialog2; + + *sip_referred_by_init(by)->b_url = + *sip->sip_from->a_url; + + fail_unless(tl_gets(refer->data->e_tags, + NUTAG_REFER_EVENT_REF(refer_event), + TAG_END()) == 1); + + nua_notify(nh, + SIPTAG_EVENT(refer_event), + SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), + SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"), + NUTAG_SUBSTATE(nua_substate_active), + TAG_END()); + notify0 = s2_wait_for_request(SIP_METHOD_NOTIFY); + fail_unless((ss = notify0->sip->sip_subscription_state) != NULL); + fail_unless(su_casematch("active", ss->ss_substate)); + s2_respond_to(notify0, dialog1, SIP_200_OK, TAG_END()); + notified = s2_wait_for_event(nua_r_notify, 200); + + nh2 = nua_handle(nua, NULL, NUTAG_URL(r->r_url), TAG_END()); + + invite = invite_sent_by_nua(nh2, + NUTAG_REFER_EVENT(refer_event), + NUTAG_NOTIFY_REFER(nh), + SIPTAG_REFERRED_BY(by), + TAG_END()); + process_offer(invite); + + respond_with_sdp( + invite, dialog, SIP_180_RINGING, + SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), + TAG_END()); + fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless(s2_check_callstate(nua_callstate_proceeding)); + + notify1 = s2_wait_for_request(SIP_METHOD_NOTIFY); + s2_respond_to(notify1, dialog1, SIP_200_OK, TAG_END()); + + respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); + s2_free_message(invite); + fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless(s2_check_callstate(nua_callstate_ready)); + fail_unless(s2_check_request(SIP_METHOD_ACK)); + + notify2 = s2_wait_for_request(SIP_METHOD_NOTIFY); + s2_respond_to(notify2, dialog1, SIP_200_OK, TAG_END()); + fail_unless((ss = notify2->sip->sip_subscription_state) != NULL); + fail_unless(su_casematch("terminated", ss->ss_substate)); + + nua_handle_destroy(nh); + bye_by_nua(nh2, TAG_END()); + nua_handle_destroy(nh2); +} +END_TEST + +TCase *refer_tcase(int threading) +{ + TCase *tc = tcase_create("5.2 - Call Transfer"); + + add_call_fixtures(tc, threading); + + tcase_add_test(tc, refer_5_2_1); + tcase_add_test(tc, refer_5_2_2); + + return tc; +} /* ====================================================================== */ @@ -3137,6 +3280,7 @@ suite_add_tcase(suite, termination_tcase(threading)); suite_add_tcase(suite, destroy_tcase(threading)); suite_add_tcase(suite, options_tcase(threading)); + suite_add_tcase(suite, refer_tcase(threading)); if (0) /* Template */ suite_add_tcase(suite, empty_tcase(threading)); From mrene at freeswitch.org Tue Mar 3 09:21:00 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:21:00 -0600 Subject: [Freeswitch-svn] [commit] r12378 - freeswitch/trunk/src/include Message-ID: Author: mrene Date: Tue Mar 3 11:21:00 2009 New Revision: 12378 Log: Add doxygen comment to switch_channel_set_private Modified: freeswitch/trunk/src/include/switch_channel.h Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Mar 3 11:21:00 2009 @@ -398,6 +398,7 @@ \param key unique keyname to associate your private data to \param private_info void pointer to private data \return SWITCH_STATUS_SUCCESS if data was set + \remarks set NULL to delete your private data */ SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info); From mikej at freeswitch.org Tue Mar 3 09:21:26 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:21:26 -0600 Subject: [Freeswitch-svn] [commit] r12379 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:21:26 2009 New Revision: 12379 Log: Mon Mar 2 11:58:01 CST 2009 Pekka Pessi * nta.c: use already-resolved transport for CANCEL/ACK to [3456]XX Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:21:26 2009 @@ -1 +1 @@ -Tue Mar 3 11:20:37 CST 2009 +Tue Mar 3 11:21:02 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 3 11:21:26 2009 @@ -7679,7 +7679,17 @@ } } - if (route_url && !orq->orq_user_tport) { + if (tpn) { + /* CANCEL or ACK to [3456]XX */ + invalid = tport_name_dup(home, orq->orq_tpn, tpn); +#if HAVE_SOFIA_SRESOLV + assert(tport_name_is_resolved(orq->orq_tpn)); +#endif + resolved = tport_name_is_resolved(orq->orq_tpn); + orq->orq_url = url_hdup(home, sip->sip_request->rq_url); + scheme = "sip"; /* XXX */ + } + else if (route_url && !orq->orq_user_tport) { invalid = nta_tpn_by_url(home, orq->orq_tpn, &scheme, &port, route_url); if (override_tport) { /* Use transport protocol name from transport */ @@ -7692,15 +7702,6 @@ if (route_url != (url_string_t *)agent->sa_default_proxy) orq->orq_route = url_hdup(home, route_url->us_url); } - else if (tpn) { - invalid = tport_name_dup(home, orq->orq_tpn, tpn); -#if HAVE_SOFIA_SRESOLV - assert(tport_name_is_resolved(orq->orq_tpn)); -#endif - resolved = tport_name_is_resolved(orq->orq_tpn); - orq->orq_url = url_hdup(home, sip->sip_request->rq_url); - scheme = "sip"; /* XXX */ - } else { invalid = nta_tpn_by_url(home, orq->orq_tpn, &scheme, &port, (url_string_t *)sip->sip_request->rq_url); From mikej at freeswitch.org Tue Mar 3 09:22:02 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:22:02 -0600 Subject: [Freeswitch-svn] [commit] r12380 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:22:01 2009 New Revision: 12380 Log: Tue Mar 3 10:40:57 CST 2009 Pekka Pessi * nta: nta_agent_set_params() now returns correct value for tport parameters set Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:22:01 2009 @@ -1 +1 @@ -Tue Mar 3 11:21:02 CST 2009 +Tue Mar 3 11:21:35 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 3 11:22:01 2009 @@ -1537,12 +1537,13 @@ m = 0; for (tport = agent->sa_tports; tport; tport = tport_next(tport)) { - m = tport_set_params(tport, TAG_NEXT(tags)); + int m0 = tport_set_params(tport, TAG_NEXT(tags)); + if (m0 < 0) + return m0; + if (m0 > m) + m = m0; } - if (m == -1) - return m; - n += m; if (aliases != NONE) { From mikej at freeswitch.org Tue Mar 3 09:22:36 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:22:36 -0600 Subject: [Freeswitch-svn] [commit] r12381 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:22:35 2009 New Revision: 12381 Log: Tue Mar 3 10:47:00 CST 2009 Pekka Pessi * nta: timeout CANCELed INVITE transactions properly Ignore-this: 4e7fdc56065dba617352443a9310bb28 Use timer D (instead of timer C) to timeout CANCELed INVITE transactions. Also, generate 408 Request Timeout to all forks that have not received a final response. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:22:35 2009 @@ -1 +1 @@ -Tue Mar 3 11:21:35 CST 2009 +Tue Mar 3 11:22:16 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 3 11:22:35 2009 @@ -556,6 +556,8 @@ nta_outgoing_t *orq_cancel; /**< CANCEL transaction */ + nta_outgoing_t *orq_forking; /**< Untagged transaction */ + nta_outgoing_t *orq_forks; /**< Tagged transactions */ uint32_t orq_rseq; /**< Latest incoming rseq */ }; @@ -7022,10 +7024,10 @@ static void outgoing_destroy(nta_outgoing_t *orq); su_inline int outgoing_is_queued(nta_outgoing_t const *orq); su_inline void outgoing_queue(outgoing_queue_t *queue, - nta_outgoing_t *orq); + nta_outgoing_t *orq); su_inline void outgoing_remove(nta_outgoing_t *orq); su_inline void outgoing_set_timer(nta_outgoing_t *orq, uint32_t interval); -su_inline void outgoing_reset_timer(nta_outgoing_t *orq); +static void outgoing_reset_timer(nta_outgoing_t *orq); static size_t outgoing_timer_dk(outgoing_queue_t *q, char const *timer, uint32_t now); @@ -7043,6 +7045,7 @@ static void outgoing_trying(nta_outgoing_t *orq); static void outgoing_timeout(nta_outgoing_t *orq, uint32_t now); static int outgoing_complete(nta_outgoing_t *orq); +static void outgoing_terminate_invite(nta_outgoing_t *); static int outgoing_terminate(nta_outgoing_t *orq); static size_t outgoing_mass_destroy(nta_agent_t *sa, outgoing_queue_t *q); static void outgoing_estimate_delay(nta_outgoing_t *orq, sip_t *sip); @@ -7350,8 +7353,7 @@ ta_end(ta); - if ((cancel_2543 || cancel_408) && - !orq->orq_stateless && !orq->orq_destroyed) + if ((cancel_2543 || cancel_408) && !orq->orq_stateless) outgoing_reply(orq, SIP_487_REQUEST_CANCELLED, 1); if (msg) { @@ -7369,8 +7371,11 @@ if (delay_sending) orq->orq_cancel = cancel; - if (cancel) + if (cancel) { + if (!delay_sending) + outgoing_complete(orq); return cancel; + } msg_destroy(msg); } @@ -7684,6 +7689,7 @@ /* CANCEL or ACK to [3456]XX */ invalid = tport_name_dup(home, orq->orq_tpn, tpn); #if HAVE_SOFIA_SRESOLV + /* We send ACK or CANCEL only if original request was really sent */ assert(tport_name_is_resolved(orq->orq_tpn)); #endif resolved = tport_name_is_resolved(orq->orq_tpn); @@ -8318,8 +8324,8 @@ /** @internal * Test if an outgoing transaction is in a queue. */ -su_inline -int outgoing_is_queued(nta_outgoing_t const *orq) +su_inline int +outgoing_is_queued(nta_outgoing_t const *orq) { return orq && orq->orq_queue; } @@ -8330,9 +8336,9 @@ * Insert a client transaction into a queue and set the corresponding * timeout at the same time. */ -su_inline -void outgoing_queue(outgoing_queue_t *queue, - nta_outgoing_t *orq) +static void +outgoing_queue(outgoing_queue_t *queue, + nta_outgoing_t *orq) { if (orq->orq_queue == queue) { assert(queue->q_timeout == 0); @@ -8422,7 +8428,7 @@ orq->orq_agent->sa_out.re_t1 = rq; } -su_inline +static void outgoing_reset_timer(nta_outgoing_t *orq) { if (orq->orq_rprev) { @@ -8541,8 +8547,10 @@ /* Application is expected to handle 200 OK statelessly => kill transaction immediately */ else if (orq->orq_method == sip_method_invite && !orq->orq_completed - /* (unless we the transaction has been canceled) */ - && !orq->orq_canceled) { + /* (unless transaction has been canceled) */ + && !orq->orq_canceled + /* or it has been forked */ + && !orq->orq_forking && !orq->orq_forks) { orq->orq_destroyed = 1; outgoing_terminate(orq); } @@ -8717,12 +8725,11 @@ SU_DEBUG_5(("nta: timer %s fired, %s %s (%u)\n", timer, "CANCEL and timeout", orq->orq_method_name, orq->orq_cseq->cs_seq)); - + /* + * If the client transaction has received a provisional response, the + * proxy MUST generate a CANCEL request matching that transaction. + */ nta_outgoing_tcancel(orq, NULL, NULL, TAG_NULL()); - - outgoing_timeout(orq, now); - - assert(q->q_head != orq); } return timeout; @@ -8731,16 +8738,18 @@ /** @internal Signal transaction timeout to the application. */ void outgoing_timeout(nta_outgoing_t *orq, uint32_t now) { - nta_outgoing_t *cancel; + nta_outgoing_t *cancel = NULL; - if (outgoing_other_destinations(orq)) { + if (orq->orq_status || orq->orq_canceled) + ; + else if (outgoing_other_destinations(orq)) { SU_DEBUG_5(("%s(%p): %s\n", "nta", (void *)orq, "try next after timeout")); outgoing_try_another(orq); return; } - cancel = orq->orq_cancel; orq->orq_cancel = NULL; + cancel = orq->orq_cancel, orq->orq_cancel = NULL; orq->orq_agent->sa_stats->as_tout_request++; outgoing_reply(orq, SIP_408_REQUEST_TIMEOUT, 0); @@ -8753,15 +8762,19 @@ * * @return True if transaction was free()d. */ -static -int outgoing_complete(nta_outgoing_t *orq) +static int +outgoing_complete(nta_outgoing_t *orq) { orq->orq_completed = 1; outgoing_reset_timer(orq); /* Timer A / Timer E */ - if (orq->orq_stateless || orq->orq_reliable) + if (orq->orq_stateless) return outgoing_terminate(orq); + if (orq->orq_reliable) { + if (orq->orq_method != sip_method_invite || !orq->orq_agent->sa_is_a_uas) + return outgoing_terminate(orq); + } if (orq->orq_method == sip_method_invite) { if (orq->orq_queue != orq->orq_agent->sa_out.inv_completed) @@ -8793,12 +8806,52 @@ SU_DEBUG_5(("nta: timer %s fired, %s %s (%u)\n", timer, "terminate", orq->orq_method_name, orq->orq_cseq->cs_seq)); - outgoing_terminate(orq); + if (orq->orq_method == sip_method_invite) + outgoing_terminate_invite(orq); + else + outgoing_terminate(orq); } return terminated; } + +/** Terminate an INVITE client transaction. */ +static void +outgoing_terminate_invite(nta_outgoing_t *original) +{ + nta_outgoing_t *orq = original; + + while (original->orq_forks) { + orq = original->orq_forks; + original->orq_forks = orq->orq_forks; + + assert(orq->orq_forking == original); + + SU_DEBUG_5(("nta: timer %s fired, %s %s (%u);tag=%s\n", "D", + "terminate", orq->orq_method_name, orq->orq_cseq->cs_seq, + orq->orq_tag)); + + if (outgoing_terminate(orq)) + continue; + + if (orq->orq_status < 200) { + /* Fork has timed out */ + orq->orq_agent->sa_stats->as_tout_request++; + outgoing_reply(orq, SIP_408_REQUEST_TIMEOUT, 0); + } + } + + if (outgoing_terminate(orq = original)) + return; + + if (orq->orq_status < 200) { + /* Original INVITE has timed out */ + orq->orq_agent->sa_stats->as_tout_request++; + outgoing_reply(orq, SIP_408_REQUEST_TIMEOUT, 0); + } +} + /** Terminate a client transaction. */ static int outgoing_terminate(nta_outgoing_t *orq) @@ -8946,46 +8999,38 @@ } /** Process a response message. */ -int outgoing_recv(nta_outgoing_t *orq, +int outgoing_recv(nta_outgoing_t *_orq, int status, msg_t *msg, sip_t *sip) { + nta_outgoing_t *orq = _orq->orq_forking ? _orq->orq_forking : _orq; nta_agent_t *sa = orq->orq_agent; - short orq_status = orq->orq_status; int internal = sip == NULL || (sip->sip_flags & NTA_INTERNAL_MSG) != 0; int uas = sa->sa_is_a_uas; + assert(!internal || status >= 300); + assert(orq == _orq || orq->orq_method == sip_method_invite); + if (status < 100) status = 100; if (!internal && orq->orq_delay == UINT_MAX) outgoing_estimate_delay(orq, sip); - assert(!internal || status >= 300); - if (orq->orq_cc) agent_accept_compressed(orq->orq_agent, msg, orq->orq_cc); if (orq->orq_cancel) { nta_outgoing_t *cancel; - cancel = orq->orq_cancel; orq->orq_cancel = NULL; - cancel->orq_delayed = 0; - if (status < 200) + if (status < 200) { outgoing_send(cancel, 0); - else + outgoing_complete(orq); + } + else { outgoing_reply(cancel, SIP_481_NO_TRANSACTION, 0); - - if (status < 300 && orq->orq_destroyed && - orq->orq_method == sip_method_invite) { - outgoing_terminate(orq); /* We can now kill transaction */ - if (status == 100) { - msg_destroy(msg); - return 0; - } - return -1; } } @@ -8998,9 +9043,12 @@ /* The state machines */ if (orq->orq_method == sip_method_invite) { + nta_outgoing_t *original = orq; - if (uas && orq->orq_destroyed && 200 <= status && status < 300) { - if (su_strcasecmp(sip->sip_to->a_tag, orq->orq_tag) != 0) { + orq = _orq; + + if (orq->orq_destroyed && 200 <= status && status < 300) { + if (uas && su_strcasecmp(sip->sip_to->a_tag, orq->orq_tag) != 0) { /* Orphan 200 Ok to INVITE. ACK and BYE it */ SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE\n")); return nta_msg_ackbye(sa, msg); @@ -9008,38 +9056,41 @@ return -1; /* Proxy statelessly (RFC3261 section 16.11) */ } - outgoing_reset_timer(orq); + outgoing_reset_timer(original); if (status < 200) { - if (orq->orq_queue == sa->sa_out.inv_calling) { - orq->orq_status = status; - outgoing_queue(sa->sa_out.inv_proceeding, orq); + original->orq_status = status; + orq->orq_status = status; + if (original->orq_queue == sa->sa_out.inv_calling) { + outgoing_queue(sa->sa_out.inv_proceeding, original); } - else if (orq->orq_queue == sa->sa_out.inv_proceeding) { - orq->orq_status = status; + else if (original->orq_queue == sa->sa_out.inv_proceeding) { if (sa->sa_out.inv_proceeding->q_timeout) { - outgoing_remove(orq); - outgoing_queue(sa->sa_out.inv_proceeding, orq); + outgoing_remove(original); + outgoing_queue(sa->sa_out.inv_proceeding, original); } } + } + if (status < 200) { /* Handle 100rel */ - if (sip && sip->sip_rseq) + if (sip && sip->sip_rseq) { if (outgoing_recv_reliable(orq, msg, sip) < 0) { msg_destroy(msg); return 0; } + } } else { /* Final response */ if (status >= 300 && !internal) - outgoing_ack(orq, sip); + outgoing_ack(original, sip); - if (!orq->orq_completed) { - if (outgoing_complete(orq)) + if (!original->orq_completed) { + if (outgoing_complete(original)) return 0; - if (sip && uas) { + if (uas && sip && orq == original) { /* * We silently discard duplicate final responses to INVITE below * with outgoing_duplicate() @@ -9049,7 +9100,7 @@ } } /* Retransmission or response from another fork */ - else { + else if (orq->orq_status >= 200) { /* Once 2xx has been received, non-2xx will not be forwarded */ if (status >= 300) return outgoing_duplicate(orq, msg, sip); @@ -9072,7 +9123,7 @@ /* Non-INVITE */ if (orq->orq_queue == sa->sa_out.trying || orq->orq_queue == sa->sa_out.resolving) { - assert(orq_status < 200); (void)orq_status; + assert(orq->orq_status < 200); if (status < 200) { /* @RFC3261 17.1.2.1: @@ -11066,9 +11117,20 @@ if (orq == NULL || to_tag == NULL) return NULL; + if (orq->orq_to->a_tag) { - SU_DEBUG_1(("%s: transaction %p already in dialog\n", __func__, - (void *)orq)); + SU_DEBUG_1(("%s: transaction %p (CSeq: %s %u) already in dialog\n", __func__, + (void *)orq, orq->orq_cseq->cs_method_name, orq->orq_cseq->cs_seq)); + return NULL; + } + if (orq->orq_method != sip_method_invite) { + SU_DEBUG_1(("%s: transaction %p (CSeq: %s %u) cannot be tagged\n", __func__, + (void *)orq, orq->orq_cseq->cs_method_name, orq->orq_cseq->cs_seq)); + return NULL; + } + if (orq->orq_status < 100) { + SU_DEBUG_1(("%s: transaction %p (CSeq: %s %u) still calling\n", __func__, + (void *)orq, orq->orq_cseq->cs_method_name, orq->orq_cseq->cs_seq)); return NULL; } @@ -11098,17 +11160,12 @@ tagged->orq_request = msg_ref_create(orq->orq_request); tagged->orq_response = msg_ref_create(orq->orq_response); tagged->orq_cancel = NULL; - - tagged->orq_pending = tport_pend(orq->orq_tport, - orq->orq_request, - outgoing_tport_error, - tagged); - if (tagged->orq_pending < 0) - tagged->orq_pending = 0; + tagged->orq_forking = orq; + tagged->orq_forks = orq->orq_forks; + orq->orq_forks = tagged; tagged->orq_rseq = 0; - outgoing_queue(orq->orq_queue, tagged); outgoing_insert(agent, tagged); return tagged; From mikej at freeswitch.org Tue Mar 3 09:23:03 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:23:03 -0600 Subject: [Freeswitch-svn] [commit] r12382 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:23:03 2009 New Revision: 12382 Log: Tue Mar 3 10:47:40 CST 2009 Pekka Pessi * nta_tag.c: fixed NTATAG_TIMER_C() documentation Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:23:03 2009 @@ -1 +1 @@ -Tue Mar 3 11:22:16 CST 2009 +Tue Mar 3 11:22:42 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c Tue Mar 3 11:23:03 2009 @@ -634,7 +634,7 @@ * instead if NTATAG_TIMER_C(0) is given. * * @par Default Value - * - 180000 (milliseconds, 3 minutes) + * - 185000 (milliseconds, 3 minutes) * * @sa @RFC3261 sections 13.3.1.1, 16.7 and 16.8, * NTATAG_UA(1), NTATAG_TIMER_C(), From mikej at freeswitch.org Tue Mar 3 09:23:31 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:23:31 -0600 Subject: [Freeswitch-svn] [commit] r12383 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:23:31 2009 New Revision: 12383 Log: Tue Mar 3 10:49:51 CST 2009 Pekka Pessi * test_nta.c: timer C now CANCELs INVITE transaction Ignore-this: 8de2e5747e7ae0e62e2d8ad9aeb0cbed 408 response is not generated (unless CANCEL times out, too.) Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:23:31 2009 @@ -1 +1 @@ -Tue Mar 3 11:22:42 CST 2009 +Tue Mar 3 11:23:11 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c Tue Mar 3 11:23:31 2009 @@ -530,7 +530,7 @@ { agent_t *ag = c->c_ag; - for (ag->ag_canceled = 0; !ag->ag_canceled;) { + for (ag->ag_canceled = 0; !ag->ag_canceled || c->c_status < 200;) { if (tstflags & tst_verbatim) { fputs(".", stdout); fflush(stdout); } @@ -3612,8 +3612,9 @@ SIPTAG_PAYLOAD(sdp), TAG_END())); - /* Run until 1) server gets CANCEL and 2) client gets 408 */ - TEST_1(!client_run_until_canceled(ctx, 408)); + /* Run until 1) server gets CANCEL and 2) client gets 487 */ + /* Note: this has been changed in 1.12.11 */ + TEST_1(!client_run_until_canceled(ctx, 487)); TEST_1(ag->ag_canceled != 0); TEST_P(ag->ag_latest_leg, ag->ag_server_leg); From mikej at freeswitch.org Tue Mar 3 09:24:01 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:24:01 -0600 Subject: [Freeswitch-svn] [commit] r12384 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/soa Message-ID: Author: mikej Date: Tue Mar 3 11:24:01 2009 New Revision: 12384 Log: Tue Mar 3 10:56:34 CST 2009 Pekka Pessi * test_soa.c: ignore fgets() return value. really. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:24:01 2009 @@ -1 +1 @@ -Tue Mar 3 11:23:11 CST 2009 +Tue Mar 3 11:23:38 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c Tue Mar 3 11:24:01 2009 @@ -2504,10 +2504,11 @@ #endif if (o_attach) { - char line[10]; + char line[10], *cr; printf("%s: pid %u\n", name, getpid()); printf("\n"); - fgets(line, sizeof line, stdin); + cr = fgets(line, sizeof line, stdin); + (void)cr; } #if HAVE_ALARM else if (o_alarm) { From mikej at freeswitch.org Tue Mar 3 09:25:03 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:25:03 -0600 Subject: [Freeswitch-svn] [commit] r12385 - freeswitch/trunk/libs/sofia-sip Message-ID: Author: mikej Date: Tue Mar 3 11:25:03 2009 New Revision: 12385 Log: Tue Mar 3 11:03:53 CST 2009 Pekka Pessi * RELEASE: describe nta changes with forking, timer C, timer D, and CANCEL Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/RELEASE Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:25:03 2009 @@ -1 +1 @@ -Tue Mar 3 11:23:38 CST 2009 +Tue Mar 3 11:24:11 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/RELEASE ============================================================================== --- freeswitch/trunk/libs/sofia-sip/RELEASE (original) +++ freeswitch/trunk/libs/sofia-sip/RELEASE Tue Mar 3 11:25:03 2009 @@ -25,6 +25,16 @@ libsofia-sip-ua: - **template**: Added foobar() function (sofia-sip/foobar.h). +- Timing out CANCELed INVITE client transactions is now done with timer D. + Previously, the INVITE client transactions were restarted instead of + timing out under certain circumstances. +- An INVITE transaction that has been timed out with stack timer C is now + CANCELed automatically. Previously, such the INVITE client transactions + were restarted instead of timing out under certain circumstances. +- Timing out forked INVITE client transactions is now done by stack. + The stack generates a 408 response to each INVITE transaction fork that + has not received a final response within 32 seconds (or 64 times SIP T1) + after first final response to the INVITE was received. - The mp_len type was changed from usize_t to unsigned. The change is binary-incompatible on 64-bit platforms when compiled with the configure opetion --disable-size-compat @@ -42,6 +52,7 @@ - t_next_next(), t_next_move(), t_next_len(), t_next_dup(), t_next_filter() - t_filter_with(), t_any_filter() - sres_record_class() + - u2s_alloc() libsofia-sip-ua-glib: - No ABI/API changes, compatible with 1.12.0. Note, libsofia-sip-ua-glib From mikej at freeswitch.org Tue Mar 3 09:25:39 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:25:39 -0600 Subject: [Freeswitch-svn] [commit] r12386 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 3 11:25:39 2009 New Revision: 12386 Log: Tue Mar 3 11:04:23 CST 2009 Pekka Pessi * s2check/Makefile.am: more clue about name Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:25:39 2009 @@ -1 +1 @@ -Tue Mar 3 11:24:11 CST 2009 +Tue Mar 3 11:25:14 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am Tue Mar 3 11:25:39 2009 @@ -1,5 +1,5 @@ # -# Makefile.am for Sofia-SIP module and unit testing +# Makefile.am for "Sofia-SIP 2 Check", module and unit testing library # # Copyright (C) 2009 Nokia Corporation # Contact: Pekka Pessi From mikej at freeswitch.org Tue Mar 3 09:26:13 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:26:13 -0600 Subject: [Freeswitch-svn] [commit] r12387 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 3 11:26:13 2009 New Revision: 12387 Log: Tue Mar 3 07:47:19 CST 2009 Pekka Pessi * nta: calculate timer D correctly Ignore-this: f43d9dcc11fb6a19c3674a6da35ee7ec Timer D is either 32 seconds or 64 times T1, whichever is larger. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:26:13 2009 @@ -1 +1 @@ -Tue Mar 3 11:25:14 CST 2009 +Tue Mar 3 11:25:58 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 3 11:26:13 2009 @@ -860,7 +860,7 @@ ta_start(ta, tag, value); if ((agent = su_home_new(sizeof(*agent)))) { - unsigned timer_c; + unsigned timer_c = 0, timer_d = 32000; agent->sa_root = root; agent->sa_callback = callback; @@ -925,6 +925,11 @@ agent->sa_out.re_t1 = &agent->sa_out.re_list; + if (agent->sa_use_timer_c || !agent->sa_is_a_uas) + timer_c = agent->sa_timer_c; + if (timer_d < agent->sa_t1x64) + timer_d = agent->sa_t1x64; + outgoing_queue_init(agent->sa_out.delayed, 0); outgoing_queue_init(agent->sa_out.resolving, 0); outgoing_queue_init(agent->sa_out.trying, agent->sa_t1x64); /* F */ @@ -932,10 +937,8 @@ outgoing_queue_init(agent->sa_out.terminated, 0); /* Special queues (states) for outgoing INVITE transactions */ outgoing_queue_init(agent->sa_out.inv_calling, agent->sa_t1x64); /* B */ - timer_c = (agent->sa_use_timer_c || !agent->sa_is_a_uas) - ? agent->sa_timer_c : 0; outgoing_queue_init(agent->sa_out.inv_proceeding, timer_c); /* C */ - outgoing_queue_init(agent->sa_out.inv_completed, 32000); /* Timer D */ + outgoing_queue_init(agent->sa_out.inv_completed, timer_d); /* D */ if (leg_htable_resize(agent->sa_home, agent->sa_dialogs, 0) < 0 || leg_htable_resize(agent->sa_home, agent->sa_defaults, 0) < 0 || @@ -1446,6 +1449,7 @@ unsigned sip_t4 = agent->sa_t4; unsigned sip_t1x64 = agent->sa_t1x64; unsigned timer_c = agent->sa_timer_c; + unsigned timer_d = 32000; unsigned graylist = agent->sa_graylist; unsigned blacklist = agent->sa_blacklist; int ua = agent->sa_is_a_uas; @@ -1646,6 +1650,9 @@ agent->sa_timer_c = timer_c; outgoing_queue_adjust(agent, agent->sa_out.inv_proceeding, timer_c); } + if (timer_d < sip_t1x64) + timer_d = sip_t1x64; + outgoing_queue_adjust(agent, agent->sa_out.inv_completed, timer_d); if (graylist > 24 * 60 * 60) graylist = 24 * 60 * 60; From mikej at freeswitch.org Tue Mar 3 09:27:41 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 11:27:41 -0600 Subject: [Freeswitch-svn] [commit] r12388 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 3 11:27:41 2009 New Revision: 12388 Log: Tue Mar 3 10:37:30 CST 2009 Pekka Pessi * s2check: added s2base.[hc], s2sip.[hc] Ignore-this: 6a32b36a47a6f9dd2b5fec7c7375c564 Moved nua/test_s2 code here. Added: freeswitch/trunk/libs/sofia-sip/s2check/s2base.c freeswitch/trunk/libs/sofia-sip/s2check/s2base.h freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 11:27:41 2009 @@ -1 +1 @@ -Tue Mar 3 11:25:58 CST 2009 +Tue Mar 3 11:27:12 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am Tue Mar 3 11:27:41 2009 @@ -19,6 +19,8 @@ # Rules for building the targets libs2_a_SOURCES = s2check.h s2tcase.c \ + s2base.h s2base.c \ + s2sip.c s2sip.h \ s2_localinfo.h s2_localinfo.c \ s2dns.h s2dns.c \ s2util.h s2time.c Added: freeswitch/trunk/libs/sofia-sip/s2check/s2base.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.c Tue Mar 3 11:27:41 2009 @@ -0,0 +1,198 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE s2base.c + * @brief Common check-based tester for Sofia SIP modules + * + * @author Pekka Pessi + * + * @date Created: Wed Apr 30 12:48:27 EEST 2008 ppessi + */ + +#include "config.h" + +#undef NDEBUG + +#define TP_MAGIC_T struct tp_magic_s + +#include "s2base.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#if HAVE_SYS_TIME_H +#include /* Get struct timeval */ +#endif + +#if HAVE_CLOCK_GETTIME +static double +now(void) +{ + struct timespec tv; + +#if CLOCK_MONOTONIC + if (clock_gettime(CLOCK_MONOTONIC, &tv) != 0) +#endif + clock_gettime(CLOCK_REALTIME, &tv); + + return tv.tv_sec * 1.0 + tv.tv_nsec * 1e-9; +} +#elif HAVE_GETTIMEOFDAY +static double +now(void) +{ + struct timespec tv; + + gettimeofday(&tv, NULL); + + return tv.tv_sec * 1.0 + tv.tv_usec * 1e-6; +} + +#else +#error no gettimeofday for test timing +#endif + +/* -- Module globals ---------------------------------------------------- */ + +struct s2base *s2base; + +char const *s2_tester = "s2_tester"; +int s2_start_stop; + +char const *_s2_suite = "X"; +char const *_s2_case = "0.0"; + +static struct { + double setup, start, done, toredown; +} stamps; + +void s2_suite(char const *name) +{ + _s2_suite = name; +} + +/** Basic setup for test cases */ +void s2_setup(char const *label) +{ + assert(s2base == NULL); + + stamps.setup = now(); + + if (s2_start_stop > 1) { + printf("%s - setup %s test case\n", s2_tester, label ? label : "next"); + } + + su_init(); + + s2base = su_home_new(sizeof *s2base); + assert(s2base != NULL); + + s2base->root = su_root_create(s2base); + assert(s2base->root != NULL); +} + +void s2_case(char const *number, + char const *title, + char const *description) +{ + stamps.start = now(); + + _s2_case = number; + if (s2_start_stop) + printf("%s - starting %s/%s-%s\n", s2_tester, _s2_suite, _s2_case, title); +} + +SOFIAPUBVAR su_log_t nua_log[]; +SOFIAPUBVAR su_log_t soa_log[]; +SOFIAPUBVAR su_log_t nea_log[]; +SOFIAPUBVAR su_log_t nta_log[]; +SOFIAPUBVAR su_log_t tport_log[]; +SOFIAPUBVAR su_log_t su_log_default[]; + +void +s2_setup_logs(int level) +{ + assert(s2base); + + su_log_soft_set_level(nua_log, level); + su_log_soft_set_level(soa_log, level); + su_log_soft_set_level(su_log_default, level); + su_log_soft_set_level(nea_log, level); + su_log_soft_set_level(nta_log, level); + su_log_soft_set_level(tport_log, level); +} + +void s2_step(void) +{ + su_root_step(s2base->root, 10); +} + +static char const *s2_teardown_label = NULL; + +void +s2_teardown_started(char const *label) +{ + stamps.done = now(); + + if (!s2_teardown_label) { + s2_teardown_label = label; + if (s2_start_stop > 1) { + double ms = (stamps.done - stamps.start) * 1000.0; + printf("%s - tearing down %s test case (%g ms)\n", s2_tester, label, ms); + } + } +} + +void +s2_teardown(void) +{ + struct s2base *_zap = s2base; + + s2base = NULL; + + su_root_destroy(_zap->root); + su_deinit(); + + stamps.toredown = now(); + + if (s2_start_stop > 1) { + double ms = (stamps.toredown - stamps.setup) * 1000.0; + printf("%s - %s test case tore down (total %g ms)\n", s2_tester, + s2_teardown_label ? s2_teardown_label : "previous", ms); + } + + s2_teardown_label = NULL; +} Added: freeswitch/trunk/libs/sofia-sip/s2check/s2base.h ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.h Tue Mar 3 11:27:41 2009 @@ -0,0 +1,54 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef S2BASE_H +#define S2BASE_H + +#include +#include +#include "s2util.h" + +extern struct s2base +{ + su_home_t home[1]; + su_root_t *root; +} *s2base; + +extern char const *s2_tester, *_s2_suite, *_s2_case; +extern int s2_start_stop; + +void s2_suite(char const *label); +void s2_setup(char const *label); + +void s2_setup_logs(int level); + +void s2_step(void); + +void s2_case(char const *tag, + char const *title, + char const *description); + +void s2_teardown_started(char const *label); +void s2_teardown(void); + +#endif Added: freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c Tue Mar 3 11:27:41 2009 @@ -0,0 +1,815 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE s2sip.c + * @brief Check-Based Test Suite for Sofia SIP + * + * @author Pekka Pessi + * + * @date Created: Wed Apr 30 12:48:27 EEST 2008 ppessi + */ + +#include "config.h" + +#undef NDEBUG + +#define TP_STACK_T struct s2sip +#define TP_MAGIC_T struct tp_magic_s +#define SU_ROOT_MAGIC_T struct s2sip + +#include "s2sip.h" +#include "s2base.h" +#include "s2dns.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +/* -- Module types ------------------------------------------------------ */ + +struct tp_magic_s +{ + sip_via_t *via; + sip_contact_t *contact; +}; + +/* -- Module prototypes ------------------------------------------------- */ + +static msg_t *s2_msg(int flags); +static int s2_complete_response(msg_t *response, + int status, char const *phrase, + msg_t *request); + +/* -- Module globals ---------------------------------------------------- */ + +struct s2sip *s2sip; + +/* ---------------------------------------------------------------------- */ + +char * +s2_sip_generate_tag(su_home_t *home) +{ + static unsigned s2_tag_generator = 0; + + return su_sprintf(home, "tag=%s-%s/%u", _s2_suite, _s2_case, ++s2_tag_generator); +} + +/* ---------------------------------------------------------------------- */ +/* SIP messages */ + +struct message * +s2_sip_remove_message(struct message *m) +{ + if ((*m->prev = m->next)) + m->next->prev = m->prev; + + m->prev = NULL, m->next = NULL; + + return m; +} + +void +s2_sip_free_message(struct message *m) +{ + if (m) { + if (m->prev) { + if ((*m->prev = m->next)) + m->next->prev = m->prev; + } + msg_destroy(m->msg); + tport_unref(m->tport); + free(m); + } +} + +void s2_sip_flush_messages(void) +{ + while (s2sip->received) { + s2_sip_free_message(s2sip->received); + } +} + +struct message * +s2_sip_next_response(void) +{ + struct message *m; + + for (;;) { + for (m = s2sip->received; m; m = m->next) { + if (m->sip->sip_status) + return s2_sip_remove_message(m); + } + s2_step(); + } +} + +struct message * +s2_sip_wait_for_response(int status, sip_method_t method, char const *name) +{ + struct message *m; + + for (;;) { + for (m = s2sip->received; m; m = m->next) { + if (!m->sip->sip_status) + continue; + + if (status != 0 && m->sip->sip_status->st_status != status) + continue; + + if (method == sip_method_unknown && name == NULL) + break; + + if (m->sip->sip_cseq == NULL) + continue; + + if (m->sip->sip_cseq->cs_method != method) + continue; + if (name == NULL) + break; + if (strcmp(m->sip->sip_cseq->cs_method_name, name) == 0) + break; + } + + if (m) + return s2_sip_remove_message(m); + + s2_step(); + } +} + +int +s2_sip_check_response(int status, sip_method_t method, char const *name) +{ + struct message *m = s2_sip_wait_for_response(status, method, name); + s2_sip_free_message(m); + return m != NULL; +} + +int +s2_check_in_response(struct dialog *dialog, + int status, sip_method_t method, char const *name) +{ + struct message *m = s2_sip_wait_for_response(status, method, name); + s2_sip_update_dialog(dialog, m); + s2_sip_free_message(m); + return m != NULL; +} + +struct message * +s2_sip_next_request(sip_method_t method, char const *name) +{ + struct message *m; + + for (m = s2sip->received; m; m = m->next) { + if (m->sip->sip_request) + if (method == sip_method_unknown && name == NULL) + return s2_sip_remove_message(m); + + if (m->sip->sip_request->rq_method == method && + strcmp(m->sip->sip_request->rq_method_name, name) == 0) + return s2_sip_remove_message(m); + } + + return NULL; +} + +struct message * +s2_sip_wait_for_request(sip_method_t method, char const *name) +{ + return s2_sip_wait_for_request_timeout(method, name, (unsigned)-1); +} + +struct message * +s2_sip_wait_for_request_timeout(sip_method_t method, char const *name, unsigned steps) +{ + struct message *m; + + for (; steps > 0; steps--, s2_step()) { + for (m = s2sip->received; m; m = m->next) { + if (m->sip->sip_request) { + if (method == sip_method_unknown && name == NULL) + return s2_sip_remove_message(m); + + if (m->sip->sip_request->rq_method == method && + strcmp(m->sip->sip_request->rq_method_name, name) == 0) + return s2_sip_remove_message(m); + } + } + } + + return NULL; +} + +int +s2_sip_check_request(sip_method_t method, char const *name) +{ + struct message *m = s2_sip_wait_for_request(method, name); + if (m) s2_sip_free_message(m); + return m != NULL; +} + +int +s2_sip_check_request_timeout(sip_method_t method, + char const *name, + unsigned timeout) +{ + struct message *m = s2_sip_wait_for_request_timeout(method, name, timeout); + if (m) s2_sip_free_message(m); + return m != NULL; +} + +void +s2_sip_save_uas_dialog(struct dialog *d, sip_t *sip) +{ + if (d && !d->local) { + assert(sip->sip_request); + d->local = sip_from_dup(d->home, sip->sip_to); + if (d->local->a_tag == NULL) + sip_from_tag(d->home, d->local, s2_sip_generate_tag(d->home)); + d->remote = sip_to_dup(d->home, sip->sip_from); + d->call_id = sip_call_id_dup(d->home, sip->sip_call_id); + d->rseq = sip->sip_cseq->cs_seq; + /* d->route = sip_route_dup(d->home, sip->sip_record_route); */ + d->target = sip_contact_dup(d->home, sip->sip_contact); + } +} + +struct message * +s2_sip_respond_to(struct message *m, struct dialog *d, + int status, char const *phrase, + tag_type_t tag, tag_value_t value, ...) +{ + ta_list ta; + msg_t *reply; + sip_t *sip; + su_home_t *home; + tp_name_t tpn[1]; + char *rport; + + assert(m); assert(m->msg); assert(m->tport); + assert(100 <= status && status < 700); + + s2_sip_save_uas_dialog(d, m->sip); + + ta_start(ta, tag, value); + + reply = s2_msg(0); sip = sip_object(reply); home = msg_home(reply); + + assert(reply && home && sip); + + if (sip_add_tl(reply, sip, ta_tags(ta)) < 0) { + abort(); + } + + s2_complete_response(reply, status, phrase, m->msg); + + if (sip->sip_status && sip->sip_status->st_status > 100 && + sip->sip_to && !sip->sip_to->a_tag && + sip->sip_cseq && sip->sip_cseq->cs_method != sip_method_cancel) { + char const *ltag = NULL; + + if (d && d->local) + ltag = d->local->a_tag; + + if (ltag == NULL) + ltag = s2_sip_generate_tag(home); + + if (sip_to_tag(msg_home(reply), sip->sip_to, ltag) < 0) { + assert(!"add To tag"); + } + } + + if (d && !d->contact) { + d->contact = sip_contact_dup(d->home, sip->sip_contact); + } + + *tpn = *tport_name(m->tport); + + rport = su_sprintf(home, "rport=%u", + ntohs(((su_sockaddr_t *) + msg_addrinfo(m->msg)->ai_addr)->su_port)); + + if (s2sip->server_uses_rport && + sip->sip_via->v_rport && + sip->sip_via->v_rport[0] == '\0') { + msg_header_add_param(home, sip->sip_via->v_common, rport); + } + + tpn->tpn_port = rport + strlen("rport="); + + tport_tsend(m->tport, reply, tpn, TPTAG_MTU(INT_MAX), ta_tags(ta)); + msg_destroy(reply); + + ta_end(ta); + + return m; +} + +/** Add headers from the request to the response message. */ +static int +s2_complete_response(msg_t *response, + int status, char const *phrase, + msg_t *request) +{ + su_home_t *home = msg_home(response); + sip_t *response_sip = sip_object(response); + sip_t const *request_sip = sip_object(request); + + int incomplete = 0; + + if (!response_sip || !request_sip || !request_sip->sip_request) + return -1; + + if (!response_sip->sip_status) + response_sip->sip_status = sip_status_create(home, status, phrase, NULL); + if (!response_sip->sip_via) + response_sip->sip_via = sip_via_dup(home, request_sip->sip_via); + if (!response_sip->sip_from) + response_sip->sip_from = sip_from_dup(home, request_sip->sip_from); + if (!response_sip->sip_to) + response_sip->sip_to = sip_to_dup(home, request_sip->sip_to); + if (!response_sip->sip_call_id) + response_sip->sip_call_id = + sip_call_id_dup(home, request_sip->sip_call_id); + if (!response_sip->sip_cseq) + response_sip->sip_cseq = sip_cseq_dup(home, request_sip->sip_cseq); + + if (!response_sip->sip_record_route && request_sip->sip_record_route) + sip_add_dup(response, response_sip, (void*)request_sip->sip_record_route); + + incomplete = sip_complete_message(response) < 0; + + msg_serialize(response, (msg_pub_t *)response_sip); + + if (incomplete || + !response_sip->sip_status || + !response_sip->sip_via || + !response_sip->sip_from || + !response_sip->sip_to || + !response_sip->sip_call_id || + !response_sip->sip_cseq || + !response_sip->sip_content_length || + !response_sip->sip_separator || + (request_sip->sip_record_route && !response_sip->sip_record_route)) + return -1; + + return 0; +} + +/* Send request (updating dialog). + * + * Return zero upon success, nonzero upon failure. + */ +int +s2_sip_request_to(struct dialog *d, + sip_method_t method, char const *name, + tport_t *tport, + tag_type_t tag, tag_value_t value, ...) +{ + ta_list ta; + tagi_t const *tags; + + msg_t *msg = s2_msg(0); + sip_t *sip = sip_object(msg); + url_t const *target = NULL; + sip_cseq_t cseq[1]; + sip_via_t via[1]; char const *v_params[8]; + sip_content_length_t l[1]; + tp_name_t tpn[1]; + tp_magic_t *magic; + int user_via = 0; + + ta_start(ta, tag, value); + tags = ta_args(ta); + + if (sip_add_tagis(msg, sip, &tags) < 0) + goto error; + + if (sip->sip_request) + target = sip->sip_request->rq_url; + else if (d->target) + target = d->target->m_url; + else if (s2sip->sut.contact) + target = s2sip->sut.contact->m_url; + else + target = NULL; + + if (target == NULL) + goto error; + + if (!sip->sip_request) { + sip_request_t *rq; + rq = sip_request_create(msg_home(msg), method, name, + (url_string_t *)target, NULL); + sip_header_insert(msg, sip, (sip_header_t *)rq); + } + + if (!d->local && sip->sip_from) + d->local = sip_from_dup(d->home, sip->sip_from); + if (!d->contact && sip->sip_contact) + d->contact = sip_contact_dup(d->home, sip->sip_contact); + if (!d->remote && sip->sip_to) + d->remote = sip_to_dup(d->home, sip->sip_to); + if (!d->target && sip->sip_request) + d->target = sip_contact_create(d->home, + (url_string_t *)sip->sip_request->rq_url, + NULL); + if (!d->call_id && sip->sip_call_id) + d->call_id = sip_call_id_dup(d->home, sip->sip_call_id); + if (!d->lseq && sip->sip_cseq) + d->lseq = sip->sip_cseq->cs_seq; + + if (!d->local) + d->local = sip_from_dup(d->home, s2sip->aor); + if (!d->contact) + d->contact = sip_contact_dup(d->home, s2sip->contact); + if (!d->remote) + d->remote = sip_to_dup(d->home, s2sip->sut.aor); + if (!d->call_id) + d->call_id = sip_call_id_create(d->home, NULL); + assert(d->local && d->contact); + assert(d->remote && d->target); + assert(d->call_id); + + if (tport == NULL) + tport = d->tport; + + if (tport == NULL) + tport = s2sip->sut.tport; + + if (tport == NULL && d->target->m_url->url_type == url_sips) + tport = s2sip->tls.tport; + + if (tport == NULL) + tport = s2sip->udp.tport; + else if (tport == NULL) + tport = s2sip->tcp.tport; + else if (tport == NULL) + tport = s2sip->tls.tport; + + assert(tport); + + *tpn = *tport_name(tport); + + if (tport_is_primary(tport)) { + tpn->tpn_host = target->url_host; + tpn->tpn_port = url_port(target); + if (!tpn->tpn_port || !tpn->tpn_port[0]) + tpn->tpn_port = url_port_default(target->url_type); + } + + magic = tport_magic(tport); + assert(magic != NULL); + + sip_cseq_init(cseq); + cseq->cs_method = method; + cseq->cs_method_name = name; + + if (d->invite && (method == sip_method_ack || method == sip_method_cancel)) { + cseq->cs_seq = sip_object(d->invite)->sip_cseq->cs_seq; + } + else { + cseq->cs_seq = ++d->lseq; + } + + if (sip->sip_via) { + user_via = 1; + } + else if (d->invite && method == sip_method_cancel) { + *via = *sip_object(d->invite)->sip_via; + } + else { + *via = *magic->via; + via->v_params = v_params; + v_params[0] = su_sprintf(msg_home(msg), "branch=z9hG4bK%lx", ++s2sip->tid); + v_params[1] = NULL; + } + + sip_content_length_init(l); + if (sip->sip_payload) + l->l_length = sip->sip_payload->pl_len; + + if (d->local->a_tag == NULL) { + char const *ltag = s2_sip_generate_tag(d->home); + + if (sip_from_tag(d->home, d->local, ltag) < 0) { + assert(!"add To tag"); + } + + if (sip->sip_from && sip->sip_from->a_tag == NULL) { + if (sip_from_tag(msg_home(msg), sip->sip_from, ltag) < 0) { + assert(!"add To tag"); + } + } + } + + sip_add_tl(msg, sip, + TAG_IF(!sip->sip_from, SIPTAG_FROM(d->local)), + TAG_IF(!sip->sip_contact, SIPTAG_CONTACT(d->contact)), + TAG_IF(!sip->sip_to, SIPTAG_TO(d->remote)), + TAG_IF(!sip->sip_call_id, SIPTAG_CALL_ID(d->call_id)), + TAG_IF(!sip->sip_cseq, SIPTAG_CSEQ(cseq)), + TAG_IF(!user_via, SIPTAG_VIA(via)), + TAG_IF(!sip->sip_content_length, SIPTAG_CONTENT_LENGTH(l)), + TAG_IF(!sip->sip_separator, SIPTAG_SEPARATOR_STR("\r\n")), + TAG_END()); + + msg_serialize(msg, NULL); + + if (method == sip_method_invite) { + msg_destroy(d->invite); + d->invite = msg_ref_create(msg); + } + + tport = tport_tsend(tport, msg, tpn, ta_tags(ta)); + ta_end(ta); + + if (d->tport != tport) { + tport_unref(d->tport); + d->tport = tport_ref(tport); + } + + return tport ? 0 : -1; + + error: + ta_end(ta); + return -1; +} + +/** Save information from response. + * + * Send ACK for error messages to INVITE. + */ +int s2_sip_update_dialog(struct dialog *d, struct message *m) +{ + int status = 0; + + if (m->sip->sip_status) + status = m->sip->sip_status->st_status; + + if (100 < status && status < 300) { + d->remote = sip_to_dup(d->home, m->sip->sip_to); + if (m->sip->sip_contact) + d->contact = sip_contact_dup(d->home, m->sip->sip_contact); + } + + if (300 <= status && m->sip->sip_cseq && + m->sip->sip_cseq->cs_method == sip_method_invite && + d->invite) { + msg_t *ack = s2_msg(0); + sip_t *sip = sip_object(ack); + sip_t *invite = sip_object(d->invite); + sip_request_t rq[1]; + sip_cseq_t cseq[1]; + tp_name_t tpn[1]; + + *rq = *invite->sip_request; + rq->rq_method = sip_method_ack, rq->rq_method_name = "ACK"; + *cseq = *invite->sip_cseq; + cseq->cs_method = sip_method_ack, cseq->cs_method_name = "ACK"; + + sip_add_tl(ack, sip, + SIPTAG_REQUEST(rq), + SIPTAG_VIA(invite->sip_via), + SIPTAG_FROM(invite->sip_from), + SIPTAG_TO(invite->sip_to), + SIPTAG_CALL_ID(invite->sip_call_id), + SIPTAG_CSEQ(cseq), + SIPTAG_CONTENT_LENGTH_STR("0"), + SIPTAG_SEPARATOR_STR("\r\n"), + TAG_END()); + + *tpn = *tport_name(d->tport); + if (!tport_is_secondary(d->tport) || + !tport_is_clear_to_send(d->tport)) { + tpn->tpn_host = rq->rq_url->url_host; + tpn->tpn_port = rq->rq_url->url_port; + } + + msg_serialize(ack, NULL); + tport_tsend(d->tport, ack, tpn, TAG_END()); + } + + return 0; +} + +/* ---------------------------------------------------------------------- */ +/* tport interface */ +static void +s2_sip_stack_recv(struct s2sip *s2, + tport_t *tp, + msg_t *msg, + tp_magic_t *magic, + su_time_t now) +{ + struct message *next = calloc(1, sizeof *next), **prev; + + next->msg = msg; + next->sip = sip_object(msg); + next->when = now; + next->tport = tport_ref(tp); + +#if 0 + if (next->sip->sip_request) + printf("%s: sent: %s\n", s2tester, next->sip->sip_request->rq_method_name); + else + printf("%s: sent: SIP/2.0 %u %s\n", s2tester, + next->sip->sip_status->st_status, + next->sip->sip_status->st_phrase); +#endif + + for (prev = &s2->received; *prev; prev = &(*prev)->next) + ; + + next->prev = prev, *prev = next; +} + +static void +s2_sip_stack_error(struct s2sip *s2, + tport_t *tp, + int errcode, + char const *remote) +{ + fprintf(stderr, "%s(%p): error %d (%s) from %s\n", + "s2_sip_error", + (void *)tp, errcode, su_strerror(errcode), + remote ? remote : ""); +} + +static msg_t * +s2_sip_stack_alloc(struct s2sip *s2sip, int flags, + char const data[], usize_t size, + tport_t const *tport, + tp_client_t *tpc) +{ + return msg_create(s2sip->mclass, flags | s2sip->flags); +} + +static msg_t * +s2_msg(int flags) +{ + return msg_create(s2sip->mclass, flags | s2sip->flags); +} + +tp_stack_class_t const s2_sip_stack[1] = + {{ + /* tpac_size */ (sizeof s2_sip_stack), + /* tpac_recv */ s2_sip_stack_recv, + /* tpac_error */ s2_sip_stack_error, + /* tpac_alloc */ s2_sip_stack_alloc, + }}; + +static char const *default_protocols[] = { "udp", "tcp", NULL }; + +/** Setup for SIP transports */ +void s2_sip_setup(char const *hostname, + char const * const *protocols, + tag_type_t tag, tag_value_t value, ...) +{ + su_home_t *home; + ta_list ta; + tp_name_t tpn[1]; + int bound; + tport_t *tp; + + assert(s2base != NULL); + assert(s2sip == NULL); + + s2sip = su_home_new(sizeof *s2sip); + home = s2sip->home; + + s2sip->root = su_root_clone(s2base->root, s2sip); + + s2sip->aor = sip_from_format(home, "Bob ", + hostname ? hostname : "example.net"); + if (hostname == NULL) + hostname = "127.0.0.1"; + s2sip->hostname = hostname; + s2sip->tid = (unsigned long)time(NULL) * 510633671UL; + + ta_start(ta, tag, value); + + s2sip->master = tport_tcreate(s2sip, s2_sip_stack, s2sip->root, + TPTAG_LOG(getenv("S2_TPORT_LOG") != NULL), + ta_tags(ta)); + assert(s2sip->master); + s2sip->mclass = sip_default_mclass(); + s2sip->flags = 0; + + memset(tpn, 0, (sizeof tpn)); + tpn->tpn_proto = "*"; + tpn->tpn_host = "*"; + tpn->tpn_port = "*"; + + if (protocols == NULL) + protocols = default_protocols; + + bound = tport_tbind(s2sip->master, tpn, protocols, + TPTAG_SERVER(1), + ta_tags(ta)); + assert(bound != -1); + + tp = tport_primaries(s2sip->master); + + *tpn = *tport_name(tp); + s2sip->contact = sip_contact_format(home, "", + tpn->tpn_host, + tpn->tpn_port); + + for (;tp; tp = tport_next(tp)) { + sip_via_t *v; + sip_contact_t *m; + tp_magic_t *magic; + + if (tport_magic(tp)) + continue; + + *tpn = *tport_name(tp); + + v = sip_via_format(home, "SIP/2.0/%s %s:%s", + tpn->tpn_proto, + tpn->tpn_host, + tpn->tpn_port); + assert(v != NULL); + if (!su_casenmatch(tpn->tpn_proto, "tls", 3)) { + m = sip_contact_format(home, "", + tpn->tpn_host, + tpn->tpn_port, + tpn->tpn_proto); + if (s2sip->udp.contact == NULL && su_casematch(tpn->tpn_proto, "udp")) { + s2sip->udp.tport = tport_ref(tp); + s2sip->udp.contact = m; + } + if (s2sip->tcp.contact == NULL && su_casematch(tpn->tpn_proto, "tcp")) { + s2sip->tcp.tport = tport_ref(tp); + s2sip->tcp.contact = m; + } + } + else if (!su_casematch(tpn->tpn_proto, "tls")) { + m = sip_contact_format(s2sip->home, "", + tpn->tpn_host, + tpn->tpn_port, + tpn->tpn_proto); + } + else { + m = sip_contact_format(s2sip->home, "", + tpn->tpn_host, + tpn->tpn_port); + if (s2sip->tls.contact == NULL) { + s2sip->tls.tport = tport_ref(tp); + s2sip->tls.contact = m; + } + } + assert(m != NULL); + + magic = su_zalloc(home, (sizeof *magic)); + magic->via = v, magic->contact = m; + + if (s2sip->contact == NULL) + s2sip->contact = m; + + tport_set_magic(tp, magic); + } +} + +void +s2_sip_teardown(void) +{ + if (s2sip) { + tport_destroy(s2sip->master), s2sip->master = NULL; + su_root_destroy(s2sip->root), s2sip->root = NULL; + } +} Added: freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h Tue Mar 3 11:27:41 2009 @@ -0,0 +1,124 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef S2SIP_H +#define S2SIP_H + +#include +#include +#include +#include + +#include "s2util.h" + +extern struct s2sip +{ + su_home_t home[1]; + + su_root_t *root; + msg_mclass_t const *mclass; + int flags; + + int server_uses_rport; + + char const *hostname; + tport_t *master; + + sip_to_t *aor; + sip_contact_t *contact; + + struct { + sip_contact_t *contact; + tport_t *tport; + } udp, tcp, tls; + + struct { + sip_to_t *aor; + sip_contact_t *contact; + tport_t *tport; + } sut; + + struct message { + struct message *next, **prev; + msg_t *msg; + sip_t *sip; + tport_t *tport; + su_time_t when; + } *received; + + unsigned long tid; +} *s2sip; + +struct dialog +{ + su_home_t home[1]; + sip_from_t *local; + sip_to_t *remote; + sip_call_id_t *call_id; + uint32_t lseq, rseq; + sip_contact_t *target; + sip_route_t *route; + sip_contact_t *contact; + + tport_t *tport; + msg_t *invite; /* latest invite sent */ +}; + +extern tp_stack_class_t const s2_sip_stack[1]; + +char *s2_sip_generate_tag(su_home_t *home); + +struct message *s2_sip_remove_message(struct message *m); +void s2_sip_free_message(struct message *m); +void s2_sip_flush_messages(void); + +struct message *s2_sip_next_response(void); +struct message *s2_sip_wait_for_response(int status, sip_method_t , char const *); +int s2_sip_check_response(int status, sip_method_t method, char const *name); + +struct message *s2_sip_next_request(sip_method_t method, char const *name); +struct message *s2_sip_wait_for_request(sip_method_t method, char const *name); +struct message *s2_sip_wait_for_request_timeout(sip_method_t, char const *, + unsigned timeout); +int s2_sip_check_request(sip_method_t method, char const *name); +int s2_sip_check_request_timeout(sip_method_t method, char const *, unsigned timeout); + +void s2_sip_save_uas_dialog(struct dialog *d, sip_t *sip); + +struct message *s2_sip_respond_to(struct message *m, struct dialog *d, + int status, char const *phrase, + tag_type_t tag, tag_value_t value, ...); + +int s2_sip_request_to(struct dialog *d, + sip_method_t method, char const *name, + tport_t *tport, + tag_type_t tag, tag_value_t value, ...); + +int s2_sip_update_dialog(struct dialog *d, struct message *response); + +void s2_sip_setup(char const *hostname, + char const * const *protocols, + tag_type_t tag, tag_value_t value, ...); +void s2_sip_teardown(void); + +#endif From brian at freeswitch.org Tue Mar 3 10:03:26 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 12:03:26 -0600 Subject: [Freeswitch-svn] [commit] r12390 - freeswitch/trunk/src Message-ID: Author: brian Date: Tue Mar 3 12:03:25 2009 New Revision: 12390 Log: FSCORE-317 Modified: freeswitch/trunk/src/switch_core_speech.c Modified: freeswitch/trunk/src/switch_core_speech.c ============================================================================== --- freeswitch/trunk/src/switch_core_speech.c (original) +++ freeswitch/trunk/src/switch_core_speech.c Tue Mar 3 12:03:25 2009 @@ -154,7 +154,7 @@ if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_DONE)) { switch_clear_flag(sh, SWITCH_SPEECH_FLAG_DONE); *datalen = 0; - return SWITCH_STATUS_FALSE; + return SWITCH_STATUS_BREAK; } more: From mrene at freeswitch.org Tue Mar 3 11:01:21 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 13:01:21 -0600 Subject: [Freeswitch-svn] [commit] r12391 - in freeswitch/trunk/src: . include Message-ID: Author: mrene Date: Tue Mar 3 13:01:21 2009 New Revision: 12391 Log: Add switch_vmprintf Modified: freeswitch/trunk/src/include/switch_core_db.h freeswitch/trunk/src/switch_core_db.c Modified: freeswitch/trunk/src/include/switch_core_db.h ============================================================================== --- freeswitch/trunk/src/include/switch_core_db.h (original) +++ freeswitch/trunk/src/include/switch_core_db.h Tue Mar 3 13:01:21 2009 @@ -541,6 +541,11 @@ */ SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...); +/*! + * \see switch_mprintf + */ +SWITCH_DECLARE(char *) switch_vmprintf(const char *zFormat, va_list ap); + SWITCH_END_EXTERN_C #endif /* For Emacs: Modified: freeswitch/trunk/src/switch_core_db.c ============================================================================== --- freeswitch/trunk/src/switch_core_db.c (original) +++ freeswitch/trunk/src/switch_core_db.c Tue Mar 3 13:01:21 2009 @@ -180,6 +180,12 @@ return z; } +SWITCH_DECLARE(char *) switch_vmprintf(const char *zFormat, va_list ap) +{ + + return sqlite3_vmprintf(zFormat, ap); +} + SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename) { switch_core_db_t *db; From anthm at freeswitch.org Tue Mar 3 12:16:05 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 14:16:05 -0600 Subject: [Freeswitch-svn] [commit] r12392 - in freeswitch/trunk: . conf/autoload_configs libs/esl/perl src src/mod/applications/mod_enum src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Tue Mar 3 14:16:05 2009 New Revision: 12392 Log: FSCORE-297 FSCORE-305 FSCORE-315 Modified: freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml freeswitch/trunk/libs/esl/perl/ESL.pm freeswitch/trunk/libs/esl/perl/esl_wrap.cpp freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_core.c freeswitch/trunk/src/switch_rtp.c Changes in other areas also in this revision: Modified: freeswitch/trunk/ (props changed) Modified: freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml Tue Mar 3 14:16:05 2009 @@ -3,8 +3,8 @@ - - - + + + Modified: freeswitch/trunk/libs/esl/perl/ESL.pm ============================================================================== --- freeswitch/trunk/libs/esl/perl/ESL.pm (original) +++ freeswitch/trunk/libs/esl/perl/ESL.pm Tue Mar 3 14:16:05 2009 @@ -1,8 +1,5 @@ -# This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 -# +# This file was created automatically by SWIG 1.3.29. # Don't modify this file, modify the SWIG interface instead. - package ESL; require Exporter; require DynaLoader; Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Tue Mar 3 14:16:05 2009 @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.29 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -12,7 +12,7 @@ #define SWIG_CASTRANK_MODE #ifdef __cplusplus -template class SwigValueWrapper { +template class SwigValueWrapper { T *tt; public: SwigValueWrapper() : tt(0) { } @@ -25,10 +25,6 @@ private: SwigValueWrapper& operator=(const SwigValueWrapper& rhs); }; - -template T SwigValueInit() { - return T(); -} #endif /* ----------------------------------------------------------------------------- @@ -38,14 +34,14 @@ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif # else -# define SWIGTEMPLATEDISAMBIGUATOR +# define SWIGTEMPLATEDISAMBIGUATOR # endif #endif @@ -124,16 +120,10 @@ #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - - /* ----------------------------------------------------------------------------- * swigrun.swg * @@ -143,7 +133,7 @@ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" +#define SWIG_RUNTIME_VERSION "2" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -178,7 +168,6 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -319,10 +308,10 @@ extern "C" { #endif -typedef void *(*swig_converter_func)(void *, int *); +typedef void *(*swig_converter_func)(void *); typedef struct swig_type_info *(*swig_dycast_func)(void **); -/* Structure to store information on one type */ +/* Structure to store inforomation on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ @@ -367,7 +356,7 @@ while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } - return (int)((l1 - f1) - (l2 - f2)); + return (l1 - f1) - (l2 - f2); } /* @@ -449,8 +438,8 @@ Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); } /* @@ -803,10 +792,6 @@ # endif #endif /* !INT2PTR */ -#ifndef SvPV_nolen -# define SvPV_nolen(x) SvPV(x,PL_na) -#endif - #ifndef get_sv # define get_sv perl_get_sv #endif @@ -955,11 +940,6 @@ /* SWIG Perl macros */ -/* Macro to declare an XS function */ -#ifndef XSPROTO -# define XSPROTO(name) void name(pTHX_ CV* cv) -#endif - /* Macro to call an XS function */ #ifdef PERL_OBJECT # define SWIG_CALLXS(_name) _name(cv,pPerl) @@ -971,50 +951,51 @@ # endif #endif +/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ + #ifdef PERL_OBJECT #define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus extern "C" { #endif -typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); +typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); #ifdef __cplusplus } #endif #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) #define SWIGCLASS_STATIC - -#else /* PERL_OBJECT */ - +#else #define MAGIC_PPERL #define SWIGCLASS_STATIC static SWIGUNUSED - #ifndef MULTIPLICITY #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus extern "C" { #endif -typedef int (*SwigMagicFunc)(SV *, MAGIC *); +typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); #ifdef __cplusplus } #endif -#else /* MULTIPLICITY */ +#else #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) - +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #ifdef __cplusplus extern "C" { #endif -typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); #ifdef __cplusplus } #endif -#endif /* MULTIPLICITY */ -#endif /* PERL_OBJECT */ +#endif +#endif /* Workaround for bug in perl 5.6.x croak and earlier */ #if (PERL_VERSION < 8) @@ -1038,35 +1019,6 @@ #endif -/* - Define how strict is the cast between strings and integers/doubles - when overloading between these types occurs. - - The default is making it as strict as possible by using SWIG_AddCast - when needed. - - You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to - disable the SWIG_AddCast, making the casting between string and - numbers less strict. - - In the end, we try to solve the overloading between strings and - numerical types in the more natural way, but if you can avoid it, - well, avoid it using %rename, for example. -*/ -#ifndef SWIG_PERL_NO_STRICT_STR2NUM -# ifndef SWIG_PERL_STRICT_STR2NUM -# define SWIG_PERL_STRICT_STR2NUM -# endif -#endif -#ifdef SWIG_PERL_STRICT_STR2NUM -/* string takes precedence */ -#define SWIG_Str2NumCast(x) SWIG_AddCast(x) -#else -/* number takes precedence */ -#define SWIG_Str2NumCast(x) x -#endif - - #include @@ -1083,7 +1035,7 @@ SWIGRUNTIME swig_cast_info * SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); } @@ -1141,11 +1093,7 @@ if (!tc) { return SWIG_ERROR; } - { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } + *ptr = SWIG_TypeCast(tc,voidptr); } else { *ptr = voidptr; } @@ -1235,7 +1183,7 @@ const char *c = 0; if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; - c = SvPV_nolen(obj); + c = SvPV(obj, PL_na); /* Pointer values must start with leading underscore */ if (*c != '_') return SWIG_ERROR; c++; @@ -1252,7 +1200,7 @@ #define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } -typedef XSPROTO(SwigPerlWrapper); +typedef XS(SwigPerlWrapper); typedef SwigPerlWrapper *SwigPerlWrapperPtr; /* Structure for command table */ @@ -1305,8 +1253,8 @@ sv_magic(sv,sv,'U',(char *) name,strlen(name)); mg = mg_find(sv,'U'); mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); - mg->mg_virtual->svt_get = (SwigMagicFunc) get; - mg->mg_virtual->svt_set = (SwigMagicFunc) set; + mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; + mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; mg->mg_virtual->svt_len = 0; mg->mg_virtual->svt_clear = 0; mg->mg_virtual->svt_free = 0; @@ -1320,7 +1268,7 @@ /* first check if pointer already created */ if (!type_pointer) { - pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); if (pointer && SvOK(pointer)) { type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); } @@ -1334,7 +1282,7 @@ SV *pointer; /* create a new pointer */ - pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); sv_setiv(pointer, PTR2IV(module)); } @@ -1429,12 +1377,6 @@ #ifdef check #undef check #endif -#ifdef seekdir - #undef seekdir -#endif -#ifdef open - #undef open -#endif @@ -1463,8 +1405,7 @@ #define SWIG_name "ESLc::boot_ESL" #define SWIG_prefix "ESLc::" -#define SWIGVERSION 0x010335 -#define SWIG_VERSION SWIGVERSION +#define SWIGVERSION 0x010329 #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) @@ -1493,7 +1434,7 @@ SWIGINTERN swig_type_info* -SWIG_pchar_descriptor(void) +SWIG_pchar_descriptor() { static int init = 0; static swig_type_info* info = 0; @@ -1547,8 +1488,16 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SV *obj = sv_newmortal(); - if (carray) { - sv_setpvn(obj, carray, size); + if (size && carray) { + if (carray[size - 1] == 0) { + sv_setpv(obj, carray); + } else { + char *tmp = (new char[size + 1]); + memcpy(tmp, carray, size); + tmp[size] = 0; + sv_setpv(obj, tmp); + delete[] tmp; + } } else { sv_setsv(obj, &PL_sv_undef); } @@ -1564,12 +1513,14 @@ #include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX #endif @@ -1583,7 +1534,7 @@ if (val) *val = (double) SvIV(obj); return SWIG_AddCast(SWIG_OK); } else { - const char *nptr = SvPV_nolen(obj); + const char *nptr = SvPV(obj, PL_na); if (nptr) { char *endptr; double v = strtod(nptr, &endptr); @@ -1593,7 +1544,7 @@ } else { if (*endptr == '\0') { if (val) *val = v; - return SWIG_Str2NumCast(SWIG_OK); + return SWIG_AddCast(SWIG_OK); } } } @@ -1646,19 +1597,17 @@ return SWIG_OK; } else { int dispatch = 0; - const char *nptr = SvPV_nolen(obj); + const char *nptr = SvPV(obj, PL_na); if (nptr) { char *endptr; - long v; - errno = 0; - v = strtol(nptr, &endptr,0); + long v = strtol(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; - return SWIG_Str2NumCast(SWIG_OK); + return SWIG_AddCast(SWIG_OK); } } } @@ -1719,10 +1668,6 @@ return obj; } -#ifdef __cplusplus -extern "C" { -#endif - #ifdef PERL_OBJECT #define MAGIC_CLASS _wrap_ESL_var:: class _wrap_ESL_var : public CPerlObj { @@ -1742,10 +1687,6 @@ #endif #ifdef __cplusplus -} -#endif - -#ifdef __cplusplus extern "C" { #endif XS(_wrap_ESLevent_event_set) { @@ -1838,11 +1779,11 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialized_string_set" "', argument " "2"" of type '" "char *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; if (arg1->serialized_string) delete[] arg1->serialized_string; if (arg2) { - size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1; - arg1->serialized_string = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size))); + size_t size = strlen(arg2) + 1; + arg1->serialized_string = reinterpret_cast< char* >(memcpy((new char[size]), arg2, sizeof(char)*(size))); } else { arg1->serialized_string = 0; } @@ -1876,7 +1817,7 @@ } arg1 = reinterpret_cast< ESLevent * >(argp1); result = (char *) ((arg1)->serialized_string); - ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; XSRETURN(argvi); fail: @@ -1973,13 +1914,13 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "char const *""'"); } - arg1 = reinterpret_cast< char * >(buf1); + arg1 = buf1; if (items > 1) { res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLevent" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; } result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; @@ -2222,10 +2163,10 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialize" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; } result = (char *)(arg1)->serialize((char const *)arg2); - ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; XSRETURN(argvi); @@ -2306,9 +2247,9 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (char *)(arg1)->getHeader(arg2); - ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; XSRETURN(argvi); @@ -2338,7 +2279,7 @@ } arg1 = reinterpret_cast< ESLevent * >(argp1); result = (char *)(arg1)->getBody(); - ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; XSRETURN(argvi); fail: @@ -2366,7 +2307,7 @@ } arg1 = reinterpret_cast< ESLevent * >(argp1); result = (char *)(arg1)->getType(); - ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; XSRETURN(argvi); fail: @@ -2401,7 +2342,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addBody" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (bool)(arg1)->addBody((char const *)arg2); ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; @@ -2444,12 +2385,12 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addHeader" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_addHeader" "', argument " "3"" of type '" "char const *""'"); } - arg3 = reinterpret_cast< char * >(buf3); + arg3 = buf3; result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; @@ -2490,7 +2431,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_delHeader" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (bool)(arg1)->delHeader((char const *)arg2); ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; @@ -2585,17 +2526,17 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); } - arg1 = reinterpret_cast< char * >(buf1); + arg1 = buf1; res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); } - arg3 = reinterpret_cast< char * >(buf3); + arg3 = buf3; result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; @@ -2826,7 +2767,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_send" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (int)(arg1)->send((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -2865,7 +2806,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendRecv" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (ESLevent *)(arg1)->sendRecv((char const *)arg2); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | SWIG_SHADOW); argvi++ ; @@ -3116,12 +3057,12 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_filter" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'"); } - arg3 = reinterpret_cast< char * >(buf3); + arg3 = buf3; result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3166,12 +3107,12 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_events" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_events" "', argument " "3"" of type '" "char const *""'"); } - arg3 = reinterpret_cast< char * >(buf3); + arg3 = buf3; result = (int)(arg1)->events((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3220,20 +3161,20 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_execute" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; if (items > 2) { res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_execute" "', argument " "3"" of type '" "char const *""'"); } - arg3 = reinterpret_cast< char * >(buf3); + arg3 = buf3; } if (items > 3) { res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_execute" "', argument " "4"" of type '" "char const *""'"); } - arg4 = reinterpret_cast< char * >(buf4); + arg4 = buf4; } result = (int)(arg1)->execute((char const *)arg2,(char const *)arg3,(char const *)arg4); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3277,7 +3218,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setBlockingExecute" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (int)(arg1)->setBlockingExecute((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3316,7 +3257,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setEventLock" "', argument " "2"" of type '" "char const *""'"); } - arg2 = reinterpret_cast< char * >(buf2); + arg2 = buf2; result = (int)(arg1)->setEventLock((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3452,7 +3393,7 @@ * structures together. * * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop through that array, and handle each type individually. + * array. We just loop though that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a @@ -3490,58 +3431,32 @@ #define SWIGRUNTIME_DEBUG #endif - SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; - swig_module_info *module_head, *iter; - int found, init; + swig_module_info *module_head; + static int init_run = 0; clientdata = clientdata; - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next==0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; - iter=module_head; - do { - if (iter==&swig_module) { - found=1; - break; - } - iter=iter->next; - } while (iter!= module_head); - - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ + if (module_head) { swig_module.next = module_head->next; module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); } - /* When multiple interpeters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); @@ -3695,7 +3610,7 @@ /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; - sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { @@ -3707,7 +3622,7 @@ /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; - sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c (original) +++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c Tue Mar 3 14:16:05 2009 @@ -93,9 +93,9 @@ route = switch_core_alloc(globals.pool, sizeof(*route)); - route->service = strdup(service); - route->regex = strdup(regex); - route->replace = strdup(replace); + route->service = switch_core_strdup(globals.pool, service); + route->regex = switch_core_strdup(globals.pool, regex); + route->replace = switch_core_strdup(globals.pool, replace); switch_mutex_lock(MUTEX); if (!globals.route_order) { Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Mar 3 14:16:05 2009 @@ -2964,12 +2964,12 @@ while (mod_sofia_globals.threads) { switch_cond_next(); - if (++sanity >= 10000) { + if (++sanity >= 60000) { break; } } - switch_yield(1000000); + //switch_yield(1000000); su_deinit(); switch_mutex_lock(mod_sofia_globals.hash_mutex); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 3 14:16:05 2009 @@ -662,7 +662,7 @@ return NULL; } -void launch_sofia_worker_thread(sofia_profile_t *profile) +switch_thread_t *launch_sofia_worker_thread(sofia_profile_t *profile) { switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; @@ -680,6 +680,8 @@ break; } } + + return thread; } void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj) @@ -693,6 +695,8 @@ int use_timer = !sofia_test_pflag(profile, PFLAG_DISABLE_TIMER); const char *supported = NULL; int sanity; + switch_thread_t *worker_thread; + switch_status_t st; switch_mutex_lock(mod_sofia_globals.mutex); mod_sofia_globals.threads++; @@ -823,7 +827,7 @@ profile->started = switch_epoch_time_now(NULL); sofia_set_pflag_locked(profile, PFLAG_RUNNING); - launch_sofia_worker_thread(profile); + worker_thread = launch_sofia_worker_thread(profile); switch_yield(1000000); @@ -850,15 +854,11 @@ sofia_reg_unregister(profile); nua_shutdown(profile->nua); su_root_run(profile->s_root); - nua_shutdown(profile->nua); - su_root_run(profile->s_root); - + sofia_clear_pflag_locked(profile, PFLAG_RUNNING); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n"); - while (sofia_test_pflag(profile, PFLAG_WORKER_RUNNING)) { - switch_yield(100000); - } + switch_thread_join(&st, worker_thread); sanity = 4; while (profile->inuse) { @@ -3243,10 +3243,7 @@ case nua_callstate_terminating: if (status == 488 || switch_channel_get_state(channel) == CS_HIBERNATE) { tech_pvt->q850_cause = SWITCH_CAUSE_MANDATORY_IE_MISSING; - } else if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); } - break; case nua_callstate_terminated: if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { sofia_set_flag_locked(tech_pvt, TFLAG_BYE); @@ -3274,17 +3271,17 @@ switch_channel_hangup(channel, cause); } } - - if (tech_pvt->sofia_private) { - tech_pvt->sofia_private = NULL; - } - - tech_pvt->nh = NULL; - - - if (nh) { - nua_handle_bind(nh, NULL); - nua_handle_destroy(nh); + if (ss_state == nua_callstate_terminated) { + if (tech_pvt->sofia_private) { + tech_pvt->sofia_private = NULL; + } + + tech_pvt->nh = NULL; + + if (nh) { + nua_handle_bind(nh, NULL); + nua_handle_destroy(nh); + } } break; } Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Tue Mar 3 14:16:05 2009 @@ -249,6 +249,20 @@ return val; } +static void switch_core_unset_variables(void) +{ + switch_hash_index_t *hi; + const void *var; + void *val; + + switch_mutex_lock(runtime.global_var_mutex); + for (hi = switch_hash_first(NULL, runtime.global_vars); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &var, NULL, &val); + free(val); + } + switch_mutex_unlock(runtime.global_var_mutex); +} + SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *value) { char *val; @@ -1488,6 +1502,7 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Finalizing Shutdown.\n"); switch_log_shutdown(); + switch_core_unset_variables(); switch_core_memory_stop(); if (runtime.console && runtime.console != stdout && runtime.console != stderr) { Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Tue Mar 3 14:16:05 2009 @@ -409,7 +409,26 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void) { + switch_core_port_allocator_t *alloc = NULL; + switch_hash_index_t *hi; + const void *var; + void *val; + + switch_mutex_lock(port_lock); + + for (hi = switch_hash_first(NULL, alloc_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &var, NULL, &val); + if ((alloc = (switch_core_port_allocator_t *) val)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy port allocator for %s\n", (char *)var); + switch_core_port_allocator_destroy(&alloc); + } + } + switch_core_hash_destroy(&alloc_hash); + switch_mutex_unlock(port_lock); + + crypto_kernel_shutdown(); + } SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port) From brian at freeswitch.org Tue Mar 3 12:20:27 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 14:20:27 -0600 Subject: [Freeswitch-svn] [commit] r12393 - in freeswitch/trunk: conf/autoload_configs libs/esl/perl Message-ID: Author: brian Date: Tue Mar 3 14:20:27 2009 New Revision: 12393 Log: revert Modified: freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml freeswitch/trunk/libs/esl/perl/ESL.pm freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Modified: freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml Tue Mar 3 14:20:27 2009 @@ -3,8 +3,8 @@ - - - + + + Modified: freeswitch/trunk/libs/esl/perl/ESL.pm ============================================================================== --- freeswitch/trunk/libs/esl/perl/ESL.pm (original) +++ freeswitch/trunk/libs/esl/perl/ESL.pm Tue Mar 3 14:20:27 2009 @@ -1,5 +1,8 @@ -# This file was created automatically by SWIG 1.3.29. +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.35 +# # Don't modify this file, modify the SWIG interface instead. + package ESL; require Exporter; require DynaLoader; Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Tue Mar 3 14:20:27 2009 @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.29 + * Version 1.3.35 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -12,7 +12,7 @@ #define SWIG_CASTRANK_MODE #ifdef __cplusplus -template class SwigValueWrapper { +template class SwigValueWrapper { T *tt; public: SwigValueWrapper() : tt(0) { } @@ -25,6 +25,10 @@ private: SwigValueWrapper& operator=(const SwigValueWrapper& rhs); }; + +template T SwigValueInit() { + return T(); +} #endif /* ----------------------------------------------------------------------------- @@ -34,14 +38,14 @@ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) -# if (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template # else -# define SWIGTEMPLATEDISAMBIGUATOR +# define SWIGTEMPLATEDISAMBIGUATOR # endif #endif @@ -120,10 +124,16 @@ #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + /* ----------------------------------------------------------------------------- * swigrun.swg * @@ -133,7 +143,7 @@ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" +#define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -168,6 +178,7 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -308,10 +319,10 @@ extern "C" { #endif -typedef void *(*swig_converter_func)(void *); +typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); -/* Structure to store inforomation on one type */ +/* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ @@ -356,7 +367,7 @@ while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } - return (l1 - f1) - (l2 - f2); + return (int)((l1 - f1) - (l2 - f2)); } /* @@ -438,8 +449,8 @@ Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* @@ -792,6 +803,10 @@ # endif #endif /* !INT2PTR */ +#ifndef SvPV_nolen +# define SvPV_nolen(x) SvPV(x,PL_na) +#endif + #ifndef get_sv # define get_sv perl_get_sv #endif @@ -940,6 +955,11 @@ /* SWIG Perl macros */ +/* Macro to declare an XS function */ +#ifndef XSPROTO +# define XSPROTO(name) void name(pTHX_ CV* cv) +#endif + /* Macro to call an XS function */ #ifdef PERL_OBJECT # define SWIG_CALLXS(_name) _name(cv,pPerl) @@ -951,51 +971,50 @@ # endif #endif -/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ - #ifdef PERL_OBJECT #define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; -typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus extern "C" { #endif -typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus } #endif #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) #define SWIGCLASS_STATIC -#else + +#else /* PERL_OBJECT */ + #define MAGIC_PPERL #define SWIGCLASS_STATIC static SWIGUNUSED + #ifndef MULTIPLICITY #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) -typedef int (*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus extern "C" { #endif -typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); +typedef int (*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus } #endif +#else /* MULTIPLICITY */ -#else #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) -typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); + #ifdef __cplusplus extern "C" { #endif -typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #ifdef __cplusplus } #endif -#endif -#endif +#endif /* MULTIPLICITY */ +#endif /* PERL_OBJECT */ /* Workaround for bug in perl 5.6.x croak and earlier */ #if (PERL_VERSION < 8) @@ -1019,6 +1038,35 @@ #endif +/* + Define how strict is the cast between strings and integers/doubles + when overloading between these types occurs. + + The default is making it as strict as possible by using SWIG_AddCast + when needed. + + You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to + disable the SWIG_AddCast, making the casting between string and + numbers less strict. + + In the end, we try to solve the overloading between strings and + numerical types in the more natural way, but if you can avoid it, + well, avoid it using %rename, for example. +*/ +#ifndef SWIG_PERL_NO_STRICT_STR2NUM +# ifndef SWIG_PERL_STRICT_STR2NUM +# define SWIG_PERL_STRICT_STR2NUM +# endif +#endif +#ifdef SWIG_PERL_STRICT_STR2NUM +/* string takes precedence */ +#define SWIG_Str2NumCast(x) SWIG_AddCast(x) +#else +/* number takes precedence */ +#define SWIG_Str2NumCast(x) x +#endif + + #include @@ -1035,7 +1083,7 @@ SWIGRUNTIME swig_cast_info * SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); } @@ -1093,7 +1141,11 @@ if (!tc) { return SWIG_ERROR; } - *ptr = SWIG_TypeCast(tc,voidptr); + { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } } else { *ptr = voidptr; } @@ -1183,7 +1235,7 @@ const char *c = 0; if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; - c = SvPV(obj, PL_na); + c = SvPV_nolen(obj); /* Pointer values must start with leading underscore */ if (*c != '_') return SWIG_ERROR; c++; @@ -1200,7 +1252,7 @@ #define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } -typedef XS(SwigPerlWrapper); +typedef XSPROTO(SwigPerlWrapper); typedef SwigPerlWrapper *SwigPerlWrapperPtr; /* Structure for command table */ @@ -1253,8 +1305,8 @@ sv_magic(sv,sv,'U',(char *) name,strlen(name)); mg = mg_find(sv,'U'); mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); - mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; - mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; + mg->mg_virtual->svt_get = (SwigMagicFunc) get; + mg->mg_virtual->svt_set = (SwigMagicFunc) set; mg->mg_virtual->svt_len = 0; mg->mg_virtual->svt_clear = 0; mg->mg_virtual->svt_free = 0; @@ -1268,7 +1320,7 @@ /* first check if pointer already created */ if (!type_pointer) { - pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); if (pointer && SvOK(pointer)) { type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); } @@ -1282,7 +1334,7 @@ SV *pointer; /* create a new pointer */ - pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); sv_setiv(pointer, PTR2IV(module)); } @@ -1377,6 +1429,12 @@ #ifdef check #undef check #endif +#ifdef seekdir + #undef seekdir +#endif +#ifdef open + #undef open +#endif @@ -1405,7 +1463,8 @@ #define SWIG_name "ESLc::boot_ESL" #define SWIG_prefix "ESLc::" -#define SWIGVERSION 0x010329 +#define SWIGVERSION 0x010335 +#define SWIG_VERSION SWIGVERSION #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) @@ -1434,7 +1493,7 @@ SWIGINTERN swig_type_info* -SWIG_pchar_descriptor() +SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; @@ -1488,16 +1547,8 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SV *obj = sv_newmortal(); - if (size && carray) { - if (carray[size - 1] == 0) { - sv_setpv(obj, carray); - } else { - char *tmp = (new char[size + 1]); - memcpy(tmp, carray, size); - tmp[size] = 0; - sv_setpv(obj, tmp); - delete[] tmp; - } + if (carray) { + sv_setpvn(obj, carray, size); } else { sv_setsv(obj, &PL_sv_undef); } @@ -1513,14 +1564,12 @@ #include -#ifndef LLONG_MIN -# define LLONG_MIN LONG_LONG_MIN -#endif -#ifndef LLONG_MAX -# define LLONG_MAX LONG_LONG_MAX -#endif -#ifndef ULLONG_MAX -# define ULLONG_MAX ULONG_LONG_MAX +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif #endif @@ -1534,7 +1583,7 @@ if (val) *val = (double) SvIV(obj); return SWIG_AddCast(SWIG_OK); } else { - const char *nptr = SvPV(obj, PL_na); + const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; double v = strtod(nptr, &endptr); @@ -1544,7 +1593,7 @@ } else { if (*endptr == '\0') { if (val) *val = v; - return SWIG_AddCast(SWIG_OK); + return SWIG_Str2NumCast(SWIG_OK); } } } @@ -1597,17 +1646,19 @@ return SWIG_OK; } else { int dispatch = 0; - const char *nptr = SvPV(obj, PL_na); + const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; - long v = strtol(nptr, &endptr,0); + long v; + errno = 0; + v = strtol(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; - return SWIG_AddCast(SWIG_OK); + return SWIG_Str2NumCast(SWIG_OK); } } } @@ -1668,6 +1719,10 @@ return obj; } +#ifdef __cplusplus +extern "C" { +#endif + #ifdef PERL_OBJECT #define MAGIC_CLASS _wrap_ESL_var:: class _wrap_ESL_var : public CPerlObj { @@ -1687,6 +1742,10 @@ #endif #ifdef __cplusplus +} +#endif + +#ifdef __cplusplus extern "C" { #endif XS(_wrap_ESLevent_event_set) { @@ -1779,11 +1838,11 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialized_string_set" "', argument " "2"" of type '" "char *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); if (arg1->serialized_string) delete[] arg1->serialized_string; if (arg2) { - size_t size = strlen(arg2) + 1; - arg1->serialized_string = reinterpret_cast< char* >(memcpy((new char[size]), arg2, sizeof(char)*(size))); + size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1; + arg1->serialized_string = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size))); } else { arg1->serialized_string = 0; } @@ -1817,7 +1876,7 @@ } arg1 = reinterpret_cast< ESLevent * >(argp1); result = (char *) ((arg1)->serialized_string); - ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; XSRETURN(argvi); fail: @@ -1914,13 +1973,13 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = reinterpret_cast< char * >(buf1); if (items > 1) { res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLevent" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); } result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; @@ -2163,10 +2222,10 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialize" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); } result = (char *)(arg1)->serialize((char const *)arg2); - ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; XSRETURN(argvi); @@ -2247,9 +2306,9 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (char *)(arg1)->getHeader(arg2); - ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; XSRETURN(argvi); @@ -2279,7 +2338,7 @@ } arg1 = reinterpret_cast< ESLevent * >(argp1); result = (char *)(arg1)->getBody(); - ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; XSRETURN(argvi); fail: @@ -2307,7 +2366,7 @@ } arg1 = reinterpret_cast< ESLevent * >(argp1); result = (char *)(arg1)->getType(); - ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; XSRETURN(argvi); fail: @@ -2342,7 +2401,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addBody" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (bool)(arg1)->addBody((char const *)arg2); ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; @@ -2385,12 +2444,12 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addHeader" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_addHeader" "', argument " "3"" of type '" "char const *""'"); } - arg3 = buf3; + arg3 = reinterpret_cast< char * >(buf3); result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; @@ -2431,7 +2490,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_delHeader" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (bool)(arg1)->delHeader((char const *)arg2); ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; @@ -2526,17 +2585,17 @@ if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); } - arg1 = buf1; + arg1 = reinterpret_cast< char * >(buf1); res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); } - arg3 = buf3; + arg3 = reinterpret_cast< char * >(buf3); result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; @@ -2767,7 +2826,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_send" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (int)(arg1)->send((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -2806,7 +2865,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendRecv" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (ESLevent *)(arg1)->sendRecv((char const *)arg2); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | SWIG_SHADOW); argvi++ ; @@ -3057,12 +3116,12 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_filter" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'"); } - arg3 = buf3; + arg3 = reinterpret_cast< char * >(buf3); result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3107,12 +3166,12 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_events" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_events" "', argument " "3"" of type '" "char const *""'"); } - arg3 = buf3; + arg3 = reinterpret_cast< char * >(buf3); result = (int)(arg1)->events((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3161,20 +3220,20 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_execute" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); if (items > 2) { res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_execute" "', argument " "3"" of type '" "char const *""'"); } - arg3 = buf3; + arg3 = reinterpret_cast< char * >(buf3); } if (items > 3) { res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_execute" "', argument " "4"" of type '" "char const *""'"); } - arg4 = buf4; + arg4 = reinterpret_cast< char * >(buf4); } result = (int)(arg1)->execute((char const *)arg2,(char const *)arg3,(char const *)arg4); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3218,7 +3277,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setBlockingExecute" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (int)(arg1)->setBlockingExecute((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3257,7 +3316,7 @@ if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setEventLock" "', argument " "2"" of type '" "char const *""'"); } - arg2 = buf2; + arg2 = reinterpret_cast< char * >(buf2); result = (int)(arg1)->setEventLock((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; @@ -3393,7 +3452,7 @@ * structures together. * * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop though that array, and handle each type individually. + * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a @@ -3431,32 +3490,58 @@ #define SWIGRUNTIME_DEBUG #endif + SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; - swig_module_info *module_head; - static int init_run = 0; + swig_module_info *module_head, *iter; + int found, init; clientdata = clientdata; - if (init_run) return; - init_run = 1; - - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); - if (module_head) { + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; - } else { - /* This is the first module loaded */ - swig_module.next = &swig_module; - SWIG_SetModule(clientdata, &swig_module); } + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); @@ -3610,7 +3695,7 @@ /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; - sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { @@ -3622,7 +3707,7 @@ /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; - sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); From anthm at freeswitch.org Tue Mar 3 12:55:39 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 14:55:39 -0600 Subject: [Freeswitch-svn] [commit] r12395 - freeswitch/trunk/src/mod/applications/mod_dptools Message-ID: Author: anthm Date: Tue Mar 3 14:55:39 2009 New Revision: 12395 Log: FSCORE-313 Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Mar 3 14:55:39 2009 @@ -2238,6 +2238,8 @@ unsigned int timelimit = 60; switch_channel_t *new_channel = NULL; switch_event_t *params = NULL; + char stupid[128] = ""; + if (switch_strlen_zero(outbound_profile->destination_number)) { goto done; } @@ -2357,7 +2359,11 @@ myflags |= SOF_NOBLOCK; } - if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, + switch_snprintf(stupid, sizeof(stupid), "user/%s", user); + if (switch_stristr(stupid, d_dest)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid); + cause = SWITCH_CAUSE_INVALID_IE_CONTENTS; + } else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, cid_name_override, cid_num_override, NULL, var_event, myflags) == SWITCH_STATUS_SUCCESS) { const char *context; switch_caller_profile_t *cp; From brian at freeswitch.org Tue Mar 3 13:47:19 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 15:47:19 -0600 Subject: [Freeswitch-svn] [commit] r12396 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Tue Mar 3 15:47:18 2009 New Revision: 12396 Log: you can't join a detached thread later on Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 3 15:47:18 2009 @@ -669,7 +669,6 @@ int x = 0; switch_threadattr_create(&thd_attr, profile->pool); - switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_priority_increase(thd_attr); switch_thread_create(&thread, thd_attr, sofia_profile_worker_thread_run, profile, profile->pool); From mikej at freeswitch.org Tue Mar 3 14:00:18 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 16:00:18 -0600 Subject: [Freeswitch-svn] [commit] r12397 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 3 16:00:18 2009 New Revision: 12397 Log: Tue Mar 3 11:30:32 CST 2009 Pekka Pessi * check_nua: added test case for CANCELed INVITE timing out Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 16:00:18 2009 @@ -1 +1 @@ -Tue Mar 3 11:27:12 CST 2009 +Tue Mar 3 15:59:49 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 3 16:00:18 2009 @@ -1005,6 +1005,53 @@ } END_TEST + +START_TEST(cancel_2_2_8) +{ + nua_handle_t *nh; + struct message *invite, *cancel; + int timeout; + + s2_case("2.2.8", "CANCEL and INVITE times out", + "NUA is caller, NUA sends CANCEL after receiving 180 " + "but UAS never responds."); + + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); + + nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), + TAG_END()); + fail_unless(s2_check_callstate(nua_callstate_calling)); + + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); + process_offer(invite); + respond_with_sdp( + invite, dialog, SIP_180_RINGING, + SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), + TAG_END()); + fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless(s2_check_callstate(nua_callstate_proceeding)); + + nua_cancel(nh, TAG_END()); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); + s2_sip_free_message(cancel); + fail_if(!cancel); + + /* Now, time out both CANCEL and INVITE */ + for (timeout = 0; timeout < 34; timeout++) { + s2_nua_fast_forward(1, s2base->root); + cancel = s2_sip_next_request(SIP_METHOD_CANCEL); + if (cancel) + s2_sip_free_message(cancel); + } + + fail_unless(s2_check_event(nua_r_cancel, 408)); + fail_unless(s2_check_event(nua_r_invite, 408)); + fail_unless(s2_check_callstate(nua_callstate_terminated)); + nua_handle_destroy(nh); +} +END_TEST + + TCase *cancel_tcase(int threading) { TCase *tc = tcase_create("2.2 - CANCEL"); @@ -1017,6 +1064,7 @@ if (XXX) tcase_add_test(tc, cancel_2_2_5); tcase_add_test(tc, cancel_2_2_6); tcase_add_test(tc, cancel_2_2_7); + tcase_add_test(tc, cancel_2_2_8); return tc; } From mikej at freeswitch.org Tue Mar 3 14:00:57 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 16:00:57 -0600 Subject: [Freeswitch-svn] [commit] r12398 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 3 16:00:56 2009 New Revision: 12398 Log: Tue Mar 3 12:15:01 CST 2009 Pekka Pessi * nua: check_nua now uses s2base.h and s2sip.h Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 16:00:56 2009 @@ -1 +1 @@ -Tue Mar 3 15:59:49 CST 2009 +Tue Mar 3 16:00:35 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am Tue Mar 3 16:00:56 2009 @@ -55,8 +55,6 @@ check_nua_LDADD = $(nua_libs) ${top_builddir}/s2check/libs2.a \ @CHECK_LIBS@ -check_nua_CFLAGS = $(CFLAGS) -I$(top_srcdir)/s2check - nua_libs = libnua.la \ ../iptsec/libiptsec.la \ ../ipt/libipt.la \ @@ -84,6 +82,6 @@ include $(top_srcdir)/rules/sofia.am -INCLUDES = ${INTERNAL_INCLUDES} +INCLUDES = ${INTERNAL_INCLUDES} -I$(top_srcdir)/s2check TAG_DLL_FLAGS = LIST=nua_tag_list Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c Tue Mar 3 16:00:56 2009 @@ -71,7 +71,7 @@ NUTAG_OUTBOUND("no-options-keepalive, no-validate"), TAG_END()); - soa = soa_create(NULL, s2->root, NULL); + soa = soa_create(NULL, s2base->root, NULL); fail_if(!soa); @@ -148,7 +148,7 @@ fail_if(soa_get_local_sdp(soa, NULL, &body, &bodylen) != 1); ta_start(ta, tag, value); - s2_respond_to(request, dialog, status, phrase, + s2_sip_respond_to(request, dialog, status, phrase, SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(body), SIPTAG_CONTENT_DISPOSITION_STR("session"), @@ -168,7 +168,7 @@ fail_unless(s2_check_callstate(nua_callstate_calling)); - return s2_wait_for_request(SIP_METHOD_INVITE); + return s2_sip_wait_for_request(SIP_METHOD_INVITE); } static void @@ -182,10 +182,10 @@ nua_bye(nh, ta_tags(ta)); ta_end(ta); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); } @@ -208,7 +208,7 @@ "sends an ACK request with a To header identical to the " "received one for each received Success (200 OK) responses."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); @@ -218,17 +218,17 @@ fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); respond_with_sdp(invite, d2, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, d2, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, d2, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); bye_by_nua(d1, nh, TAG_END()); @@ -248,39 +248,39 @@ "that matches the transaction, still answer with an " "ACK request until timer D set to at least 32 second expires."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); - s2_respond_to(invite, d1, 404, "First not found", TAG_END()); + s2_sip_respond_to(invite, d1, 404, "First not found", TAG_END()); fail_unless(s2_check_event(nua_r_invite, 404)); fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); - s2_respond_to(invite, d1, 404, "Not found after 5 seconds", TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_respond_to(invite, d1, 404, "Not found after 5 seconds", TAG_END()); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); - s2_respond_to(invite, d1, 404, "Not found after 10 seconds", TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_respond_to(invite, d1, 404, "Not found after 10 seconds", TAG_END()); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(21, s2->root); + s2_nua_fast_forward(21, s2base->root); - s2_respond_to(invite, d1, 404, "Not found after 31 seconds", TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_respond_to(invite, d1, 404, "Not found after 31 seconds", TAG_END()); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); /* Wake up nua thread and let it time out INVITE transaction */ nua_set_params(s2->nua, TAG_END()); s2_check_event(nua_r_set_params, 0); - s2_respond_to(invite, d1, 404, "Not found after 32 seconds", TAG_END()); - s2_free_message(invite); - fail_if(s2_check_request_timeout(SIP_METHOD_ACK, 500)); + s2_sip_respond_to(invite, d1, 404, "Not found after 32 seconds", TAG_END()); + s2_sip_free_message(invite); + fail_if(s2_sip_check_request_timeout(SIP_METHOD_ACK, 3)); nua_handle_destroy(nh); } @@ -299,7 +299,7 @@ "on receipt of a retransmitted Success (200 OK) " "responses does not send an ACK request."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); @@ -309,29 +309,29 @@ fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); respond_with_sdp(invite, d1, SIP_200_OK, TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); respond_with_sdp(invite, d1, SIP_200_OK, TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(21, s2->root); + s2_nua_fast_forward(20, s2base->root); respond_with_sdp(invite, d1, SIP_200_OK, TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - s2_fast_forward(5, s2->root); + /* Stack times out the INVITE transaction */ + s2_nua_fast_forward(5, s2base->root); - /* Wake up nua thread and let it time out INVITE transaction */ - nua_set_params(s2->nua, TAG_END()); - s2_check_event(nua_r_set_params, 0); - - respond_with_sdp(invite, d1, SIP_200_OK, TAG_END()); - s2_free_message(invite); - fail_if(s2_check_request_timeout(SIP_METHOD_ACK, 500)); + respond_with_sdp(invite, d1, SIP_200_OK, + SIPTAG_SUBJECT_STR("Stray 200 OK"), + TAG_END()); + s2_sip_free_message(invite); + mark_point(); + fail_if(s2_sip_check_request_timeout(SIP_METHOD_ACK, 3)); bye_by_nua(d1, nh, TAG_END()); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Tue Mar 3 16:00:56 2009 @@ -33,6 +33,7 @@ #include "config.h" +#include "test_s2.h" #include "check_nua.h" #include @@ -43,8 +44,6 @@ #include #endif -#include "test_s2.h" - static void usage(int exitcode) { fprintf(exitcode ? stderr : stdout, @@ -62,6 +61,8 @@ s2_tester = "check_nua"; + s2_suite("N2"); + if (getenv("CHECK_NUA_VERBOSE")) s2_start_stop = strtoul(getenv("CHECK_NUA_VERBOSE"), NULL, 10); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c Tue Mar 3 16:00:56 2009 @@ -75,7 +75,7 @@ TPTAG_PINGPONG(20000), TPTAG_KEEPALIVE(10000), TAG_END()); - tport_set_params(s2->tcp.tport, TPTAG_PONG2PING(1), TAG_END()); + tport_set_params(s2sip->tcp.tport, TPTAG_PONG2PING(1), TAG_END()); } static void pingpong_thread_setup(void) @@ -121,12 +121,12 @@ nua_register(nh, TAG_END()); - fail_unless((m = s2_wait_for_request(SIP_METHOD_REGISTER)) != NULL, NULL); + fail_unless((m = s2_sip_wait_for_request(SIP_METHOD_REGISTER)) != NULL, NULL); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_403_FORBIDDEN, TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); nua_handle_destroy(nh); @@ -156,38 +156,38 @@ nua_register(nh, TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); - s2_respond_to(m, NULL, + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); + s2_sip_respond_to(m, NULL, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 407); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); - s2_respond_to(m, NULL, + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); + s2_sip_respond_to(m, NULL, SIP_401_UNAUTHORIZED, SIPTAG_WWW_AUTHENTICATE_STR(s2_auth2_digest_str), SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth2_credentials), TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_proxy_authorization); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); assert(s2->registration->contact != NULL); s2_check_event(nua_r_register, 200); @@ -237,32 +237,32 @@ nua_register(nh, TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_contact || m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); assert(s2->registration->contact != NULL); s2_check_event(nua_r_register, 100); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); @@ -286,19 +286,19 @@ nua_register(nh, ta_tags(ta)); ta_end(ta); - m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); - s2_respond_to(m, NULL, + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); + s2_sip_respond_to(m, NULL, SIP_401_UNAUTHORIZED, SIPTAG_WWW_AUTHENTICATE_STR(s2_auth_digest_str), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); /* should not unregister the previous contact @@ -307,12 +307,12 @@ fail_if(m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); assert(s2->registration->contact != NULL); s2_check_event(nua_r_register, 200); @@ -350,61 +350,61 @@ mark_point(); - m = s2_wait_for_request(SIP_METHOD_OPTIONS); + m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); fail_if(!m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_VIA(natted_via(m)), SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); mark_point(); - m = s2_wait_for_request(SIP_METHOD_OPTIONS); + m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); fail_if(!m); fail_if(!m->sip->sip_proxy_authorization); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); - su_root_step(s2->root, 20); su_root_step(s2->root, 20); - s2_fast_forward(120, s2->root); /* Default keepalive interval */ + su_root_step(s2base->root, 20); su_root_step(s2base->root, 20); + s2_nua_fast_forward(120, s2base->root); /* Default keepalive interval */ mark_point(); - m = s2_wait_for_request(SIP_METHOD_OPTIONS); - s2_respond_to(m, NULL, + m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); - su_root_step(s2->root, 20); su_root_step(s2->root, 20); - s2_fast_forward(120, s2->root); /* Default keepalive interval */ + su_root_step(s2base->root, 20); su_root_step(s2base->root, 20); + s2_nua_fast_forward(120, s2base->root); /* Default keepalive interval */ mark_point(); receive_natted = "received=4.255.255.10"; - m = s2_wait_for_request(SIP_METHOD_OPTIONS); - s2_respond_to(m, NULL, + m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_i_outbound, 0); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 200); @@ -434,33 +434,33 @@ receive_natted = "received=4.255.255.10"; - s2_fast_forward(3600, s2->root); + s2_nua_fast_forward(3600, s2base->root); mark_point(); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 100); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); @@ -484,28 +484,28 @@ mark_point(); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_contact || m->sip->sip_contact->m_next); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, 400, "Bad Contact", SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 100); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); @@ -530,34 +530,34 @@ nh = nua_handle(nua, NULL, TAG_END()); - nua_register(nh, NUTAG_PROXY(s2->tcp.contact->m_url), TAG_END()); + nua_register(nh, NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_contact || m->sip->sip_contact->m_next); fail_if(!tport_is_tcp(m->tport)); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); assert(s2->registration->contact != NULL); s2_check_event(nua_r_register, 100); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); @@ -581,7 +581,7 @@ mark_point(); s2->registration->nh = nh; - make_auth_natted_register(nh, NUTAG_PROXY(s2->tcp.contact->m_url), TAG_END()); + make_auth_natted_register(nh, NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END()); fail_if(!tport_is_tcp(s2->registration->tport)); s2_register_teardown(); } @@ -604,38 +604,38 @@ mark_point(); s2->registration->nh = nh; make_auth_natted_register( - nh, NUTAG_PROXY(s2->tcp.contact->m_url), + nh, NUTAG_PROXY(s2sip->tcp.contact->m_url), NUTAG_OUTBOUND("no-options-keepalive, no-validate"), TAG_END()); fail_if(!tport_is_tcp(s2->registration->tport)); tport_shutdown(s2->registration->tport, 2); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); /* The "NAT binding" changed when new TCP connection is established */ /* => NUA re-REGISTERs with newly detected contact */ s2_check_event(nua_r_register, 100); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 200); @@ -667,22 +667,22 @@ /* NTA tries with UDP, we drop them */ for (;;) { - m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); if (!tport_is_udp(m->tport)) /* Drop UDP */ break; - s2_free_message(m); - s2_fast_forward(4, s2->root); + s2_sip_free_message(m); + s2_nua_fast_forward(4, s2base->root); } tcp = tport_ref(m->tport); /* Respond to request over TCP */ - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_401_UNAUTHORIZED, SIPTAG_WWW_AUTHENTICATE_STR(s2_auth_digest_str), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); @@ -690,32 +690,32 @@ tport_set_params(tcp, TPTAG_PONG2PING(0), TAG_END()); /* Now request over UDP ... registering TCP contact! */ - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); s2_save_register(m); fail_unless( url_has_param(s2->registration->contact->m_url, "transport=tcp")); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); /* NUA detects oops... re-registers UDP */ s2_check_event(nua_r_register, 100); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m)), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_register, 200); @@ -726,10 +726,10 @@ { int i; for (i = 0; i < 5; i++) { - su_root_step(s2->root, 5); - su_root_step(s2->root, 5); - su_root_step(s2->root, 5); - s2_fast_forward(5, s2->root); + su_root_step(s2base->root, 5); + su_root_step(s2base->root, 5); + su_root_step(s2base->root, 5); + s2_nua_fast_forward(5, s2base->root); } } Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 3 16:00:56 2009 @@ -68,7 +68,7 @@ NUTAG_OUTBOUND("no-options-keepalive, no-validate"), TAG_END()); - soa = soa_create(NULL, s2->root, NULL); + soa = soa_create(NULL, s2base->root, NULL); fail_if(!soa); @@ -161,7 +161,7 @@ fail_if(soa_get_local_sdp(soa, NULL, &body, &bodylen) != 1); ta_start(ta, tag, value); - s2_respond_to(request, dialog, status, phrase, + s2_sip_respond_to(request, dialog, status, phrase, SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(body), SIPTAG_CONTENT_DISPOSITION_STR("session"), @@ -184,7 +184,7 @@ ta_start(ta, tag, value); fail_if( - s2_request_to(dialog, method, name, tport, + s2_sip_request_to(dialog, method, name, tport, SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(body), ta_tags(ta))); @@ -203,7 +203,7 @@ fail_unless(s2_check_callstate(nua_callstate_calling)); - return s2_wait_for_request(SIP_METHOD_INVITE); + return s2_sip_wait_for_request(SIP_METHOD_INVITE); } static uint32_t s2_rseq; @@ -233,7 +233,7 @@ ta_tags(ta)); } else { - s2_respond_to( + s2_sip_respond_to( invite, dialog, status, phrase, SIPTAG_REQUIRE_STR("100rel"), SIPTAG_RSEQ(rs), @@ -243,7 +243,7 @@ fail_unless(s2_check_event(nua_r_invite, status)); - return s2_wait_for_request(SIP_METHOD_PRACK); + return s2_sip_wait_for_request(SIP_METHOD_PRACK); } static void @@ -267,10 +267,10 @@ fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); } static nua_handle_t * @@ -295,7 +295,7 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); nua_respond(nh, SIP_180_RINGING, @@ -303,23 +303,23 @@ TAG_END()); fail_unless(s2_check_callstate(nua_callstate_early)); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); + s2_sip_update_dialog(dialog, response); process_answer(response); - s2_free_message(response); + s2_sip_free_message(response); nua_respond(nh, SIP_200_OK, TAG_END()); fail_unless(s2_check_callstate(nua_callstate_completed)); - response = s2_wait_for_response(200, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); - s2_free_message(response); + s2_sip_update_dialog(dialog, response); + s2_sip_free_message(response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); fail_unless(s2_check_event(nua_i_ack, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -338,10 +338,10 @@ nua_bye(nh, ta_tags(ta)); ta_end(ta); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); } @@ -359,19 +359,19 @@ nua_bye(nh, ta_tags(ta)); ta_end(ta); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, + s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(bye); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 407)); nua_authenticate(nh, NUTAG_AUTH("Digest:\"s2test\":abc:abc"), TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_if(s2->events); @@ -391,14 +391,14 @@ nua_cancel(nh, ta_tags(ta)); ta_end(ta); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); fail_unless(s2_check_event(nua_r_cancel, 200)); - s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); fail_unless(s2_check_event(nua_r_invite, 487)); } @@ -410,12 +410,12 @@ ta_list ta; ta_start(ta, tag, value); - fail_if(s2_request_to(dialog, SIP_METHOD_BYE, NULL, ta_tags(ta))); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, ta_tags(ta))); ta_end(ta); fail_unless(s2_check_event(nua_i_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_response(200, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); } /* ====================================================================== */ @@ -430,7 +430,7 @@ s2_case("2.1.1", "Basic call", "NUA sends INVITE, NUA sends BYE"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); @@ -448,7 +448,7 @@ s2_case("2.1.2.1", "Basic call", "NUA sends INVITE, NUA receives BYE"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); @@ -465,11 +465,11 @@ s2_case("2.1.2.2", "Basic call over TCP", "NUA sends INVITE, NUA receives BYE"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, - NUTAG_PROXY(s2->tcp.contact->m_url), + NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END()); bye_to_nua(nh, TAG_END()); @@ -502,7 +502,7 @@ s2_case("2.1.3.2", "Incoming call over TCP", "NUA receives INVITE and BYE"); - dialog->tport = s2->tcp.tport; + dialog->tport = s2sip->tcp.tport; nh = invite_to_nua(TAG_END()); @@ -569,44 +569,44 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); nua_respond(nh, SIP_180_RINGING, /* Dialog-specific proxy is saved */ - NUTAG_PROXY(s2->tcp.contact->m_url), + NUTAG_PROXY(s2sip->tcp.contact->m_url), SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_early)); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); + s2_sip_update_dialog(dialog, response); process_answer(response); - s2_free_message(response); + s2_sip_free_message(response); nua_respond(nh, SIP_200_OK, TAG_END()); fail_unless(s2_check_callstate(nua_callstate_completed)); - response = s2_wait_for_response(200, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); - s2_free_message(response); + s2_sip_update_dialog(dialog, response); + s2_sip_free_message(response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); fail_unless(s2_check_event(nua_i_ack, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); /* Check that NUA used dialog-specific proxy with BYE */ fail_unless(tport_is_tcp(bye->tport)); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); @@ -623,7 +623,7 @@ s2_case("2.1.7", "Call lookup", "Test dialog and call-id lookup"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); @@ -656,11 +656,11 @@ s2_case("2.1.8", "Call using NUTAG_PROXY()", "Test handle-specific NUTAG_PROXY()."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua( nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), - NUTAG_PROXY(s2->tcp.contact->m_url), TAG_END()); + NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END()); process_offer(invite); respond_with_sdp( @@ -672,10 +672,10 @@ fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_unless(ack && tport_is_tcp(ack->tport)); bye_by_nua(nh, TAG_END()); @@ -715,23 +715,23 @@ s2_case("2.2.1", "Cancel call", "NUA is caller, NUA sends CANCEL immediately"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_calling)); nua_cancel(nh, TAG_END()); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - fail_if(s2->received != NULL); - s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + fail_if(s2sip->received != NULL); + s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); - s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); fail_unless(s2_check_event(nua_r_invite, 487)); fail_unless(s2_check_callstate(nua_callstate_terminated)); @@ -751,15 +751,15 @@ s2_case("2.2.2", "Canceled call", "NUA is caller, NUA sends CANCEL after receiving 100"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); process_offer(invite); - s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); cancel_by_nua(nh, invite, dialog, TAG_END()); @@ -778,13 +778,13 @@ s2_case("2.2.3", "Canceled call", "NUA is caller, NUA sends CANCEL after receiving 180"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); process_offer(invite); respond_with_sdp( invite, dialog, SIP_180_RINGING, @@ -810,13 +810,13 @@ "NUA is caller, NUA sends CANCEL after receiving 180 " "but UAS already sent 200 OK."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); process_offer(invite); respond_with_sdp( invite, dialog, SIP_180_RINGING, @@ -826,16 +826,16 @@ fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_cancel(nh, TAG_END()); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); + s2_sip_free_message(cancel); fail_unless(s2_check_event(nua_r_cancel, 481)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -858,14 +858,14 @@ "but UAS already sent 200 OK.\n" "Test case checks that NUA really sends BYE after nua_bye() is called\n"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), NUTAG_AUTOACK(0), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); process_offer(invite); respond_with_sdp( invite, dialog, SIP_180_RINGING, @@ -875,23 +875,23 @@ fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_bye(nh, TAG_END()); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); + s2_sip_free_message(cancel); fail_unless(s2_check_event(nua_r_cancel, 481)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); fail_unless(s2_check_callstate(nua_callstate_terminating)); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); @@ -919,7 +919,7 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); nua_respond(nh, SIP_180_RINGING, @@ -927,22 +927,22 @@ TAG_END()); fail_unless(s2_check_callstate(nua_callstate_early)); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); + s2_sip_update_dialog(dialog, response); process_answer(response); - s2_free_message(response); + s2_sip_free_message(response); - fail_if(s2_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END())); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END())); fail_unless(s2_check_event(nua_i_cancel, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); - response = s2_wait_for_response(200, SIP_METHOD_CANCEL); + response = s2_sip_wait_for_response(200, SIP_METHOD_CANCEL); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); - response = s2_wait_for_response(487, SIP_METHOD_INVITE); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + response = s2_sip_wait_for_response(487, SIP_METHOD_INVITE); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); @@ -974,7 +974,7 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); nua_respond(nh, SIP_180_RINGING, @@ -982,22 +982,22 @@ TAG_END()); fail_unless(s2_check_callstate(nua_callstate_early)); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); + s2_sip_update_dialog(dialog, response); process_answer(response); - s2_free_message(response); + s2_sip_free_message(response); - fail_if(s2_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END())); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END())); fail_unless(s2_check_event(nua_i_cancel, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); - response = s2_wait_for_response(200, SIP_METHOD_CANCEL); + response = s2_sip_wait_for_response(200, SIP_METHOD_CANCEL); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); - response = s2_wait_for_response(487, SIP_METHOD_INVITE); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + response = s2_sip_wait_for_response(487, SIP_METHOD_INVITE); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); @@ -1082,7 +1082,7 @@ struct message *invite, *ack; fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); process_offer(invite); respond_with_sdp( invite, dialog, SIP_200_OK, @@ -1090,12 +1090,12 @@ SIPTAG_REQUIRE_STR("timer"), SIPTAG_RECORD_ROUTE(rr), TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); if (rr == NULL) - s2_free_message(ack); + s2_sip_free_message(ack); return ack; } @@ -1106,7 +1106,7 @@ struct message *ack; sip_record_route_init(rr); - *rr->r_url = *s2->contact->m_url; + *rr->r_url = *s2sip->contact->m_url; rr->r_url->url_user = "record"; rr->r_url->url_params = "lr"; @@ -1121,11 +1121,11 @@ SIPTAG_REQUIRE_STR("timer"), TAG_END()); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); ack = invite_timer_round(nh, "300;refresher=uac", rr); fail_if(ack->sip->sip_route && su_strmatch(ack->sip->sip_route->r_url->url_user, "record")); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); invite_timer_round(nh, "300;refresher=uac", NULL); bye_by_nua(nh, TAG_END()); @@ -1149,9 +1149,9 @@ SIPTAG_REQUIRE_STR("timer"), TAG_END()); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); invite_timer_round(nh, "300", NULL); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); invite_timer_round(nh, "300", NULL); bye_by_nua(nh, TAG_END()); @@ -1190,11 +1190,11 @@ "receives 200, send ACK."); sip_record_route_init(rr); - *rr->r_url = *s2->contact->m_url; + *rr->r_url = *s2sip->contact->m_url; rr->r_url->url_user = "record"; rr->r_url->url_params = "lr"; - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua( nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), @@ -1205,8 +1205,8 @@ SIP_183_SESSION_PROGRESS, SIPTAG_RECORD_ROUTE(rr), TAG_END()); - s2_respond_to(prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); fail_unless(s2_check_event(nua_r_prack, 200)); @@ -1216,23 +1216,23 @@ fail_unless(prack->sip->sip_route != NULL); fail_unless(su_strmatch(prack->sip->sip_route->r_url->url_user, "record")); - s2_respond_to(prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); fail_unless(s2_check_event(nua_r_prack, 200)); /* Change the record-route */ rr->r_url->url_user = "record2"; - s2_respond_to(invite, dialog, SIP_200_OK, + s2_sip_respond_to(invite, dialog, SIP_200_OK, SIPTAG_RECORD_ROUTE(rr), TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); fail_unless(su_strmatch(ack->sip->sip_route->r_url->url_user, "record2")); - s2_free_message(ack); + s2_sip_free_message(ack); bye_to_nua(nh, TAG_END()); @@ -1252,7 +1252,7 @@ "receives 180, sends PRACK, receives 200 for it, " "receives 200, send ACK."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua( nh, @@ -1269,24 +1269,24 @@ prack = respond_with_100rel(invite, dialog, with_sdp = 0, SIP_183_SESSION_PROGRESS, TAG_END()); - s2_respond_to(prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); fail_unless(s2_check_event(nua_r_prack, 200)); prack = respond_with_100rel(invite, dialog, with_sdp = 0, SIP_180_RINGING, TAG_END()); - s2_respond_to(prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); fail_unless(s2_check_event(nua_r_prack, 200)); - s2_respond_to(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); bye_to_nua(nh, TAG_END()); @@ -1321,7 +1321,7 @@ "receives 180, sends PRACK, receives 200 for it, " "receives 200, send ACK."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua( nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), @@ -1338,11 +1338,11 @@ prack, dialog, SIP_200_OK, SIPTAG_REQUIRE_STR("100rel"), TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_event(nua_r_prack, 200)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); - update = s2_wait_for_request(SIP_METHOD_UPDATE); + update = s2_sip_wait_for_request(SIP_METHOD_UPDATE); /* UPDATE sent by stack, stack sends event for it */ fail_unless(s2_check_callstate(nua_callstate_proceeding)); @@ -1350,7 +1350,7 @@ respond_with_sdp( update, dialog, SIP_200_OK, TAG_END()); - s2_free_message(update), update = NULL; + s2_sip_free_message(update), update = NULL; fail_unless(s2_check_event(nua_r_update, 200)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); @@ -1358,16 +1358,16 @@ prack = respond_with_100rel(invite, dialog, with_sdp = 0, SIP_180_RINGING, TAG_END()); - s2_respond_to(prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); fail_unless(s2_check_event(nua_r_prack, 200)); - s2_respond_to(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); bye_to_nua(nh, TAG_END()); @@ -1391,7 +1391,7 @@ "sends UPDATE, " "receives 200 to UPDATE."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua( nh, @@ -1416,24 +1416,24 @@ rack->ra_method_name = invite->sip->sip_cseq->cs_method_name; nua_prack(nh, SIPTAG_RACK(rack), TAG_END()); - prack = s2_wait_for_request(SIP_METHOD_PRACK); + prack = s2_sip_wait_for_request(SIP_METHOD_PRACK); process_offer(prack); - s2_respond_to(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_completing)); respond_with_sdp( prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_event(nua_r_prack, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - update = s2_wait_for_request(SIP_METHOD_UPDATE); + update = s2_sip_wait_for_request(SIP_METHOD_UPDATE); /* UPDATE sent by stack, stack sends event for it */ fail_unless(s2_check_callstate(nua_callstate_calling)); @@ -1441,7 +1441,7 @@ respond_with_sdp( update, dialog, SIP_200_OK, TAG_END()); - s2_free_message(update), update = NULL; + s2_sip_free_message(update), update = NULL; fail_unless(s2_check_event(nua_r_update, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1467,7 +1467,7 @@ "receives 200 to UPDATE, " "sends ACK."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua( nh, @@ -1492,21 +1492,21 @@ rack->ra_method_name = invite->sip->sip_cseq->cs_method_name; nua_prack(nh, SIPTAG_RACK(rack), TAG_END()); - prack = s2_wait_for_request(SIP_METHOD_PRACK); + prack = s2_sip_wait_for_request(SIP_METHOD_PRACK); process_offer(prack); respond_with_sdp( prack, dialog, SIP_200_OK, TAG_END()); - s2_free_message(prack), prack = NULL; + s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_event(nua_r_prack, 200)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); - update = s2_wait_for_request(SIP_METHOD_UPDATE); + update = s2_sip_wait_for_request(SIP_METHOD_UPDATE); /* UPDATE sent by stack, stack sends event for it */ fail_unless(s2_check_callstate(nua_callstate_proceeding)); - s2_respond_to(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_completing)); @@ -1514,11 +1514,11 @@ respond_with_sdp( update, dialog, SIP_200_OK, TAG_END()); - s2_free_message(update), update = NULL; + s2_sip_free_message(update), update = NULL; fail_unless(s2_check_event(nua_r_update, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); bye_to_nua(nh, TAG_END()); @@ -1560,15 +1560,15 @@ for (i = 0; i < 2; i++) { fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); process_offer(invite); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1597,40 +1597,40 @@ soa_generate_offer(soa, 1, NULL); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); respond_with_sdp(invite, dialog, SIP_500_INTERNAL_SERVER_ERROR, SIPTAG_RETRY_AFTER_STR("8"), TAG_END()); - s2_free_message(invite); - ack = s2_wait_for_request(SIP_METHOD_ACK); + s2_sip_free_message(invite); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); - response = s2_wait_for_response(491, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(491, SIP_METHOD_INVITE); fail_if(!response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); - s2_free_message(response); + s2_sip_free_message(response); fail_if(soa_process_reject(soa, NULL) < 0); /* We get nua_r_invite with 100 trying (and 500 in sip->sip_status) */ fail_unless(s2_check_event(nua_r_invite, 100)); - s2_fast_forward(10, s2->root); + s2_nua_fast_forward(10, s2base->root); fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); process_offer(invite); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); bye_by_nua(nh, TAG_END()); @@ -1652,7 +1652,7 @@ nh = invite_to_nua( TAG_END()); - s2_request_to(dialog, SIP_METHOD_INVITE, NULL, + s2_sip_request_to(dialog, SIP_METHOD_INVITE, NULL, SIPTAG_USER_AGENT_STR("evil (evil) evil"), TAG_END()); @@ -1660,24 +1660,24 @@ fail_unless(s2_check_callstate(nua_callstate_completed)); - response = s2_wait_for_response(200, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); + s2_sip_update_dialog(dialog, response); fail_if(!response->sip->sip_content_type); - s2_free_message(response); + s2_sip_free_message(response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); fail_unless(s2_check_event(nua_i_ack, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - s2_fast_forward(10, s2->root); + s2_nua_fast_forward(10, s2base->root); nua_set_hparams(nh, NUTAG_REFRESH_WITHOUT_SDP(1), TAG_END()); fail_unless(s2_check_event(nua_r_set_params, 200)); - s2_request_to(dialog, SIP_METHOD_INVITE, NULL, + s2_sip_request_to(dialog, SIP_METHOD_INVITE, NULL, SIPTAG_USER_AGENT_STR("evil (evil) evil"), TAG_END()); @@ -1685,14 +1685,14 @@ fail_unless(s2_check_callstate(nua_callstate_completed)); - response = s2_wait_for_response(200, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE); fail_if(!response); - s2_update_dialog(dialog, response); + s2_sip_update_dialog(dialog, response); fail_if(response->sip->sip_content_type); - s2_free_message(response); + s2_sip_free_message(response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); fail_unless(s2_check_event(nua_i_ack, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1719,17 +1719,17 @@ nua_invite(nh, SIPTAG_PAYLOAD_STR(""), TAG_END()); fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); fail_if(invite->sip->sip_content_type); soa_generate_offer(soa, 1, NULL); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); process_answer(ack); - s2_free_message(ack); + s2_sip_free_message(ack); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1764,7 +1764,7 @@ struct message *invite, *ack; s2_case("3.1.1", "Call failure", "Call fails with 403 response"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), @@ -1772,17 +1772,17 @@ fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - s2_respond_to(invite, NULL, SIP_403_FORBIDDEN, + s2_sip_respond_to(invite, NULL, SIP_403_FORBIDDEN, SIPTAG_TO_STR("UAS Changed "), TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); fail_if(strcmp(ack->sip->sip_to->a_display, "UAS Changed")); - s2_free_message(ack); + s2_sip_free_message(ack); fail_unless(s2_check_event(nua_r_invite, 403)); fail_unless(s2_check_callstate(nua_callstate_terminated)); @@ -1800,7 +1800,7 @@ s2_case("3.1.2", "Call fails after too many retries", "Call fails after 4 times 500 Retry-After"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), NUTAG_RETRY_COUNT(3), TAG_END()); @@ -1809,17 +1809,17 @@ for (i = 0;; i++) { fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - s2_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR, + s2_sip_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR, SIPTAG_RETRY_AFTER_STR("5"), TAG_END()); - s2_free_message(invite); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_free_message(invite); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); if (i == 3) break; fail_unless(s2_check_event(nua_r_invite, 100)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); } fail_unless(s2_check_event(nua_r_invite, 500)); @@ -1835,7 +1835,7 @@ struct message *invite; s2_case("3.2.1", "Re-INVITE failure", "Re-INVITE fails with 403 response"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); @@ -1844,12 +1844,12 @@ fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - s2_respond_to(invite, NULL, SIP_403_FORBIDDEN, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, NULL, SIP_403_FORBIDDEN, TAG_END()); + s2_sip_free_message(invite); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); fail_unless(s2_check_event(nua_r_invite, 403)); /* Return to previous state */ fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1868,7 +1868,7 @@ s2_case("3.2.2", "Re-INVITE fails after too many retries", "Call fails after 4 times 500 Retry-After"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), NUTAG_RETRY_COUNT(3), TAG_END()); @@ -1879,26 +1879,26 @@ for (i = 0;; i++) { fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - s2_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR, + s2_sip_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR, SIPTAG_RETRY_AFTER_STR("5"), TAG_END()); - s2_free_message(invite); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_free_message(invite); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); if (i == 3) break; fail_unless(s2_check_event(nua_r_invite, 100)); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); } fail_unless(s2_check_event(nua_r_invite, 500)); /* Graceful termination */ fail_unless(s2_check_callstate(nua_callstate_terminating)); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); @@ -1913,7 +1913,7 @@ struct message *invite; s2_case("3.2.3", "Re-INVITE failure", "Re-INVITE fails with 491 response"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); @@ -1922,11 +1922,11 @@ fail_unless(s2_check_callstate(nua_callstate_calling)); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - s2_respond_to(invite, NULL, SIP_491_REQUEST_PENDING, TAG_END()); - s2_free_message(invite); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + s2_sip_respond_to(invite, NULL, SIP_491_REQUEST_PENDING, TAG_END()); + s2_sip_free_message(invite); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); fail_unless(s2_check_event(nua_r_invite, 491)); /* Return to previous state */ fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1971,12 +1971,12 @@ nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, + s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(bye); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 407)); soa_generate_offer(soa, 1, NULL); @@ -1984,11 +1984,11 @@ request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); do { - r481 = s2_wait_for_response(0, SIP_METHOD_INVITE); + r481 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE); } while (r481->sip->sip_status->st_status < 200); - s2_update_dialog(dialog, r481); /* send ACK */ + s2_sip_update_dialog(dialog, r481); /* send ACK */ fail_unless(s2_check_callstate(nua_callstate_terminated)); @@ -2010,22 +2010,22 @@ s2_flush_events(); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); do { - r481 = s2_wait_for_response(0, SIP_METHOD_INVITE); + r481 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE); } while (r481->sip->sip_status->st_status < 200); - s2_update_dialog(dialog, r481); /* send ACK */ + s2_sip_update_dialog(dialog, r481); /* send ACK */ fail_unless(s2_check_callstate(nua_callstate_terminated)); - s2_respond_to(bye, dialog, SIP_200_OK, + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); nua_handle_destroy(nh); @@ -2051,22 +2051,22 @@ s2_flush_events(); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); i_bye = s2_wait_for_event(nua_i_bye, 100); fail_if(!i_bye); nua_respond(nh, 200, "OKOK", NUTAG_WITH(i_bye->data->e_msg), TAG_END()); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_response(200, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); nua_handle_destroy(nh); } @@ -2089,23 +2089,23 @@ fail_unless(s2_check_event(nua_r_set_params, 200)); s2_flush_events(); - s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); i_bye = s2_wait_for_event(nua_i_bye, 100); fail_if(!i_bye); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_respond(nh, 200, "OKOK", NUTAG_WITH(i_bye->data->e_msg), TAG_END()); - fail_unless(s2_check_response(200, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); nua_handle_destroy(nh); } @@ -2128,23 +2128,23 @@ fail_unless(s2_check_event(nua_r_set_params, 200)); s2_flush_events(); - s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); i_bye = s2_wait_for_event(nua_i_bye, 100); fail_if(!i_bye); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); - fail_unless(s2_check_response(500, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(500, SIP_METHOD_BYE)); } END_TEST @@ -2165,22 +2165,22 @@ s2_flush_events(); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); - fail_unless(s2_check_response(100, SIP_METHOD_INVITE)); + fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE)); nua_bye(nh, TAG_END()); fail_unless(s2_check_event(nua_i_invite, 100)); fail_unless(s2_check_callstate(nua_callstate_received)); do { - r486 = s2_wait_for_response(0, SIP_METHOD_INVITE); + r486 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE); } while (r486->sip->sip_status->st_status < 200); - s2_update_dialog(dialog, r486); /* send ACK */ + s2_sip_update_dialog(dialog, r486); /* send ACK */ fail_unless(r486->sip->sip_status->st_status == 486); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); nua_handle_destroy(nh); } @@ -2203,21 +2203,21 @@ s2_flush_events(); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); - fail_unless(s2_check_response(100, SIP_METHOD_INVITE)); + fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE)); nua_bye(nh, TAG_END()); fail_unless(s2_check_event(nua_i_invite, 100)); fail_unless(s2_check_callstate(nua_callstate_received)); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); do { - r486 = s2_wait_for_response(0, SIP_METHOD_INVITE); + r486 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE); } while (r486->sip->sip_status->st_status < 200); - s2_update_dialog(dialog, r486); /* send ACK */ + s2_sip_update_dialog(dialog, r486); /* send ACK */ fail_unless(r486->sip->sip_status->st_status == 486); nua_handle_destroy(nh); @@ -2232,14 +2232,14 @@ s2_case("4.1.8", "BYE followed by response to INVITE", "NUA receives INVITE, sends BYE at same time"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, NUTAG_AUTOANSWER(0), TAG_END()); s2_flush_events(); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); - fail_unless(s2_check_response(100, SIP_METHOD_INVITE)); + fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE)); nua_bye(nh, TAG_END()); fail_unless(s2_check_event(nua_i_invite, 100)); fail_unless(s2_check_callstate(nua_callstate_received)); @@ -2247,16 +2247,16 @@ nua_respond(nh, SIP_486_BUSY_HERE, TAG_END()); do { - r486 = s2_wait_for_response(0, SIP_METHOD_INVITE); + r486 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE); } while (r486->sip->sip_status->st_status < 200); - s2_update_dialog(dialog, r486); /* send ACK */ + s2_sip_update_dialog(dialog, r486); /* send ACK */ fail_unless(r486->sip->sip_status->st_status == 486); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); nua_handle_destroy(nh); } @@ -2279,29 +2279,29 @@ s2_flush_events(); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); i_bye = s2_wait_for_event(nua_i_bye, 200); fail_if(!i_bye); s2_free_event(i_bye), i_bye = NULL; fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_response(200, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); nua_handle_destroy(nh); mark_point(); - su_root_step(s2->root, 10); - su_root_step(s2->root, 10); - su_root_step(s2->root, 10); + su_root_step(s2base->root, 10); + su_root_step(s2base->root, 10); + su_root_step(s2base->root, 10); mark_point(); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); mark_point(); while (su_home_check_alloc((su_home_t *)nua, (void *)nh)) { - su_root_step(s2->root, 10); + su_root_step(s2base->root, 10); } } END_TEST @@ -2323,37 +2323,37 @@ s2_flush_events(); nua_invite(nh, TAG_END()); - invite = s2_wait_for_request(SIP_METHOD_INVITE); + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); fail_if(!invite); - s2_respond_to(invite, dialog, SIP_501_NOT_IMPLEMENTED, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_501_NOT_IMPLEMENTED, TAG_END()); + s2_sip_free_message(invite); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); fail_unless(s2_check_callstate(nua_callstate_calling)); fail_unless(s2_check_event(nua_r_invite, 501)); fail_unless(s2_check_callstate(nua_callstate_terminating)); - s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); i_bye = s2_wait_for_event(nua_i_bye, 200); fail_if(!i_bye); s2_free_event(i_bye), i_bye = NULL; fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_response(200, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); nua_handle_destroy(nh); - su_root_step(s2->root, 10); - su_root_step(s2->root, 10); - su_root_step(s2->root, 10); + su_root_step(s2base->root, 10); + su_root_step(s2base->root, 10); + su_root_step(s2base->root, 10); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); while (su_home_check_alloc((su_home_t *)nua, (void *)nh)) { - su_root_step(s2->root, 10); + su_root_step(s2base->root, 10); } } END_TEST @@ -2367,29 +2367,29 @@ s2_case("4.1.11", "Receive BYE in completing state", "NUA sends INVITE, receives 200, receives BYE."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_completing)); - s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); i_bye = s2_wait_for_event(nua_i_bye, 200); fail_if(!i_bye); s2_free_event(i_bye), i_bye = NULL; fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_response(200, SIP_METHOD_BYE)); + fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); nua_handle_destroy(nh); } @@ -2411,26 +2411,26 @@ SIPTAG_REQUIRE_STR("timer"), TAG_END()); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); invite_timer_round(nh, "300", NULL); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, + s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(bye); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 407)); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); nua_authenticate(nh, NUTAG_AUTH("Digest:\"s2test\":abc:abc"), TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_if(s2->events); @@ -2455,28 +2455,28 @@ SIPTAG_REQUIRE_STR("timer"), TAG_END()); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); invite_timer_round(nh, "300", NULL); - s2_fast_forward(140, s2->root); + s2_nua_fast_forward(140, s2base->root); nua_bye(nh, TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, + s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); - s2_free_message(bye); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 407)); - s2_fast_forward(160, s2->root); + s2_nua_fast_forward(160, s2base->root); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); fail_unless(s2_check_event(nua_r_bye, 200)); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_if(s2->events); @@ -2518,22 +2518,22 @@ s2_case("4.3.1", "Destroy handle after INVITE sent", "NUA sends INVITE, handle gets destroyed."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); nua_handle_destroy(nh); - s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); + s2_sip_free_message(invite); - s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); } END_TEST @@ -2546,23 +2546,23 @@ s2_case("4.3.2", "Destroy handle in calling state", "NUA sends INVITE, receives 180, handle gets destroyed."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_handle_destroy(nh); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); + s2_sip_free_message(invite); - s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); } END_TEST @@ -2574,11 +2574,11 @@ s2_case("4.3.3", "Destroy handle in completing state", "NUA sends INVITE, receives 200, handle gets destroyed."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); @@ -2588,16 +2588,16 @@ nua_handle_destroy(nh); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); - s2_free_message(invite); + s2_sip_free_message(invite); } END_TEST @@ -2610,11 +2610,11 @@ s2_case("4.3.3", "Destroy handle in ready state ", "NUA sends INVITE, receives 200, handle gets destroyed."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); @@ -2623,20 +2623,20 @@ fail_unless(s2_check_callstate(nua_callstate_completing)); nua_ack(nh, TAG_END()); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); fail_unless(s2_check_callstate(nua_callstate_ready)); nua_handle_destroy(nh); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); - s2_free_message(invite); + s2_sip_free_message(invite); } END_TEST @@ -2656,15 +2656,15 @@ nua_handle_destroy(nh); - s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END()); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); + s2_sip_free_message(invite); - s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); } END_TEST @@ -2681,19 +2681,19 @@ invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_handle_destroy(nh); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); - s2_free_message(invite); + s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); + s2_sip_free_message(invite); - s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); } END_TEST @@ -2710,7 +2710,7 @@ invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); @@ -2720,16 +2720,16 @@ nua_handle_destroy(nh); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); - s2_free_message(invite); + s2_sip_free_message(invite); } END_TEST @@ -2739,15 +2739,12 @@ nua_handle_t *nh; struct message *invite, *ack, *bye; - tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); - s2_setup_logs(7); - s2_case("4.3.8", "Destroy handle after INVITE sent", "NUA sends INVITE, handle gets destroyed, " "but remote end returns 200 OK. " "Make sure nua tries to release call properly."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); @@ -2755,16 +2752,16 @@ nua_handle_destroy(nh); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); } END_TEST @@ -2774,40 +2771,37 @@ nua_handle_t *nh; struct message *invite, *cancel, *ack, *bye; - tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); - s2_setup_logs(7); - s2_case("4.3.9", "Destroy handle in calling state", "NUA sends INVITE, receives 180, handle gets destroyed, " "but remote end returns 200 OK. " "Make sure nua tries to release call properly."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); - s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); + s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_handle_destroy(nh); - cancel = s2_wait_for_request(SIP_METHOD_CANCEL); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); fail_if(!cancel); - s2_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); - s2_free_message(cancel); + s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); + s2_sip_free_message(cancel); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); - ack = s2_wait_for_request(SIP_METHOD_ACK); + ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); - s2_free_message(ack); + s2_sip_free_message(ack); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); } END_TEST @@ -2831,18 +2825,18 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_handle_destroy(nh); - response = s2_wait_for_response(480, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(480, SIP_METHOD_INVITE); fail_if(!response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); - s2_free_message(response); + s2_sip_free_message(response); } END_TEST @@ -2866,24 +2860,24 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_respond(nh, SIP_180_RINGING, TAG_END()); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_handle_destroy(nh); - response = s2_wait_for_response(480, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(480, SIP_METHOD_INVITE); fail_if(!response); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); - s2_free_message(response); + s2_sip_free_message(response); } END_TEST @@ -2907,37 +2901,37 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_respond(nh, SIP_180_RINGING, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); fail_unless(s2_check_callstate(nua_callstate_early)); nua_respond(nh, SIP_200_OK, TAG_END()); fail_unless(s2_check_callstate(nua_callstate_completed)); - response = s2_wait_for_response(200, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE); fail_if(!response); nua_handle_destroy(nh); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); - s2_free_message(response); + s2_sip_free_message(response); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); } END_TEST @@ -2961,37 +2955,37 @@ s2_free_event(invite); - response = s2_wait_for_response(100, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_respond(nh, SIP_180_RINGING, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), TAG_END()); - response = s2_wait_for_response(180, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); fail_unless(s2_check_callstate(nua_callstate_early)); nua_respond(nh, SIP_200_OK, TAG_END()); fail_unless(s2_check_callstate(nua_callstate_completed)); - response = s2_wait_for_response(200, SIP_METHOD_INVITE); + response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE); fail_if(!response); nua_handle_destroy(nh); - bye = s2_wait_for_request(SIP_METHOD_BYE); + bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); - s2_respond_to(bye, dialog, SIP_200_OK, TAG_END()); - s2_free_message(bye); + s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(bye); - fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, SIPTAG_VIA(sip_object(dialog->invite)->sip_via), TAG_END())); - s2_free_message(response); + s2_sip_free_message(response); } END_TEST @@ -3037,23 +3031,23 @@ s2_case("5.1.1", "Test nua_respond() API", "Test nua_respond() API with OPTIONS."); - s2_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); options = s2_wait_for_event(nua_i_options, 200); fail_unless(options != NULL); nh = options->nh; fail_if(!nh); - response = s2_wait_for_response(200, SIP_METHOD_OPTIONS); + response = s2_sip_wait_for_response(200, SIP_METHOD_OPTIONS); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_handle_destroy(nh); nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END()); fail_unless(s2_check_event(nua_r_set_params, 200)); - s2_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); options = s2_wait_for_event(nua_i_options, 100); fail_unless(options != NULL); @@ -3061,9 +3055,9 @@ nua_respond(nh, 202, "okok", NUTAG_WITH_SAVED(options->event), TAG_END()); - response = s2_wait_for_response(202, SIP_METHOD_OPTIONS); + response = s2_sip_wait_for_response(202, SIP_METHOD_OPTIONS); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_handle_destroy(nh); } @@ -3099,7 +3093,7 @@ nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END()); fail_unless(s2_check_event(nua_r_set_params, 200)); - s2_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); options = s2_wait_for_event(nua_i_options, 100); fail_unless(options != NULL); @@ -3109,9 +3103,9 @@ pthread_join(tid, &thread_return); fail_unless(thread_return == (void *)options); - response = s2_wait_for_response(202, SIP_METHOD_OPTIONS); + response = s2_sip_wait_for_response(202, SIP_METHOD_OPTIONS); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_handle_destroy(nh); } @@ -3160,13 +3154,13 @@ s2_case("5.2.1", "Receive REFER", "Make a call, receive REFER."); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); - *sip_refer_to_init(r)->r_url = *s2->local->a_url; + *sip_refer_to_init(r)->r_url = *s2sip->aor->a_url; r->r_url->url_user = "bob2"; - s2_request_to(dialog, SIP_METHOD_REFER, NULL, + s2_sip_request_to(dialog, SIP_METHOD_REFER, NULL, SIPTAG_REFER_TO(r), TAG_END()); refer = s2_wait_for_event(nua_i_refer, 202); @@ -3175,8 +3169,8 @@ nua_handle_destroy(nh); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); - s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); + s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); } END_TEST @@ -3200,16 +3194,13 @@ dialog2 = su_home_new(sizeof *dialog2); fail_unless(dialog2 != NULL); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); invite_by_nua(nh, TAG_END()); - *sip_refer_to_init(r)->r_url = *s2->local->a_url; + *sip_refer_to_init(r)->r_url = *s2sip->aor->a_url; r->r_url->url_user = "bob2"; - tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); - s2_setup_logs(7); - - s2_request_to(dialog, SIP_METHOD_REFER, NULL, + s2_sip_request_to(dialog, SIP_METHOD_REFER, NULL, SIPTAG_REFER_TO(r), TAG_END()); refer = s2_wait_for_event(nua_i_refer, 202); @@ -3233,10 +3224,10 @@ SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"), NUTAG_SUBSTATE(nua_substate_active), TAG_END()); - notify0 = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify0 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless((ss = notify0->sip->sip_subscription_state) != NULL); fail_unless(su_casematch("active", ss->ss_substate)); - s2_respond_to(notify0, dialog1, SIP_200_OK, TAG_END()); + s2_sip_respond_to(notify0, dialog1, SIP_200_OK, TAG_END()); notified = s2_wait_for_event(nua_r_notify, 200); nh2 = nua_handle(nua, NULL, NUTAG_URL(r->r_url), TAG_END()); @@ -3255,17 +3246,17 @@ fail_unless(s2_check_event(nua_r_invite, 180)); fail_unless(s2_check_callstate(nua_callstate_proceeding)); - notify1 = s2_wait_for_request(SIP_METHOD_NOTIFY); - s2_respond_to(notify1, dialog1, SIP_200_OK, TAG_END()); + notify1 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); + s2_sip_respond_to(notify1, dialog1, SIP_200_OK, TAG_END()); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - s2_free_message(invite); + s2_sip_free_message(invite); fail_unless(s2_check_event(nua_r_invite, 200)); fail_unless(s2_check_callstate(nua_callstate_ready)); - fail_unless(s2_check_request(SIP_METHOD_ACK)); + fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - notify2 = s2_wait_for_request(SIP_METHOD_NOTIFY); - s2_respond_to(notify2, dialog1, SIP_200_OK, TAG_END()); + notify2 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); + s2_sip_respond_to(notify2, dialog1, SIP_200_OK, TAG_END()); fail_unless((ss = notify2->sip->sip_subscription_state) != NULL); fail_unless(su_casematch("terminated", ss->ss_substate)); @@ -3296,10 +3287,10 @@ s2_case("0.0.0", "Empty test case", "Detailed explanation for empty test case."); - tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); + tport_set_params(s2sip->master, TPTAG_LOG(1), TAG_END()); s2_setup_logs(7); s2_setup_logs(0); - tport_set_params(s2->master, TPTAG_LOG(0), TAG_END()); + tport_set_params(s2sip->master, TPTAG_LOG(0), TAG_END()); } END_TEST Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Tue Mar 3 16:00:56 2009 @@ -56,7 +56,6 @@ /* ====================================================================== */ static nua_t *nua; -static soa_session_t *soa = NULL; static struct dialog *dialog = NULL; #define CRLF "\r\n" @@ -138,7 +137,7 @@ ta_list ta; ta_start(ta, tag, value); - s2_respond_to(subscribe, dialog, status, phrase, + s2_sip_respond_to(subscribe, dialog, status, phrase, ta_tags(ta)); ta_end(ta); @@ -156,15 +155,15 @@ ta_list ta; ta_start(ta, tag, value); - fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL, SIPTAG_CONTENT_TYPE_STR(event_mime_type), SIPTAG_PAYLOAD_STR(event_state), ta_tags(ta))); ta_end(ta); - response = s2_wait_for_response(200, SIP_METHOD_NOTIFY); + response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event); fail_unless(s2_check_substate(event, expect_substate)); @@ -186,7 +185,7 @@ char const *substate_str = subscription_state; char const *expires = "600"; - subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE); + subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE); if (event_type) fail_if(!subscribe->sip->sip_event || strcmp(event_type, subscribe->sip->sip_event->o_type)); @@ -200,7 +199,7 @@ ta_start(ta, tag, value); if (send_notify_before_response) { - s2_save_uas_dialog(dialog, subscribe->sip); + s2_sip_save_uas_dialog(dialog, subscribe->sip); notify = notify_to_nua(substate, SIPTAG_EVENT(subscribe->sip->sip_event), SIPTAG_SUBSCRIPTION_STATE_STR(substate_str), @@ -223,7 +222,7 @@ ta_tags(ta)); } - s2_free_message(subscribe); + s2_sip_free_message(subscribe); return notify; } @@ -235,15 +234,15 @@ struct event *event; nua_unsubscribe(nh, TAG_END()); - subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE); + subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE); - s2_respond_to(subscribe, dialog, SIP_200_OK, SIPTAG_EXPIRES_STR("0"), TAG_END()); + s2_sip_respond_to(subscribe, dialog, SIP_200_OK, SIPTAG_EXPIRES_STR("0"), TAG_END()); event = s2_wait_for_event(nua_r_unsubscribe, 200); fail_if(!event); fail_unless(s2_check_substate(event, nua_substate_active)); s2_free_event(event); - fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL, SIPTAG_EVENT(subscribe->sip->sip_event), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=tiemout"), SIPTAG_CONTENT_TYPE_STR(event_mime_type), @@ -254,9 +253,9 @@ fail_unless(s2_check_substate(event, nua_substate_terminated)); s2_free_event(event); - response = s2_wait_for_response(200, SIP_METHOD_NOTIFY); + response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY); fail_if(!response); - s2_free_message(response); s2_free_message(subscribe); + s2_sip_free_message(response); s2_sip_free_message(subscribe); } /* ====================================================================== */ @@ -269,7 +268,7 @@ s2_case("6.1.1", "Basic subscription", "NUA sends SUBSCRIBE, waits for NOTIFY, sends un-SUBSCRIBE"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END()); notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_free_event(notify); @@ -291,15 +290,15 @@ send_notify_before_response = 1; - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END()); notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_free_event(notify); /* Wait for refresh */ - s2_fast_forward(600, s2->root); - subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE); - s2_respond_to(subscribe, dialog, SIP_200_OK, + s2_nua_fast_forward(600, s2base->root); + subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE); + s2_sip_respond_to(subscribe, dialog, SIP_200_OK, SIPTAG_EXPIRES_STR("600"), TAG_END()); @@ -307,7 +306,7 @@ fail_unless(s2_check_substate(event, nua_substate_active)); s2_free_event(event); - fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL, SIPTAG_EVENT(subscribe->sip->sip_event), SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=600"), SIPTAG_CONTENT_TYPE_STR(event_mime_type), @@ -316,9 +315,9 @@ event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event); fail_unless(s2_check_substate(event, nua_substate_active)); s2_free_event(event); - response = s2_wait_for_response(200, SIP_METHOD_NOTIFY); + response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); unsubscribe_by_nua(nh, TAG_END()); @@ -336,21 +335,21 @@ "NUA sends SUBSCRIBE, waits for NOTIFY, " "gets NOTIFY terminating the subscription,"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END()); notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_free_event(notify); - fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL, SIPTAG_EVENT_STR(event_type), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), TAG_END())); event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event); fail_unless(s2_check_substate(event, nua_substate_terminated)); s2_free_event(event); - response = s2_wait_for_response(200, SIP_METHOD_NOTIFY); + response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); nua_handle_destroy(nh); } @@ -366,25 +365,25 @@ "NUA sends SUBSCRIBE, waits for NOTIFY, " "gets NOTIFY terminating the subscription,"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END()); notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_free_event(notify); - fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL, + fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL, SIPTAG_EVENT_STR(event_type), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=deactivated"), TAG_END())); event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event); fail_unless(s2_check_substate(event, nua_substate_embryonic)); s2_free_event(event); - response = s2_wait_for_response(200, SIP_METHOD_NOTIFY); + response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY); fail_if(!response); - s2_free_message(response); + s2_sip_free_message(response); su_home_unref((void *)dialog), dialog = su_home_new(sizeof *dialog); fail_if(!dialog); - s2_fast_forward(5, s2->root); + s2_nua_fast_forward(5, s2base->root); /* nua re-establishes the subscription */ notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_free_event(notify); @@ -423,7 +422,7 @@ s2_case("6.2.1", "Event fetch - NOTIFY after 202", "NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), SIPTAG_EXPIRES_STR("0"), TAG_END()); notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_check_substate(notify, nua_substate_terminated); @@ -442,7 +441,7 @@ send_notify_before_response = 1; - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), SIPTAG_EXPIRES_STR("0"), TAG_END()); notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END()); s2_check_substate(notify, nua_substate_terminated); @@ -460,18 +459,18 @@ s2_case("6.2.3", "Event fetch - no NOTIFY", "NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY, times out"); - nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END()); + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), SIPTAG_EXPIRES_STR("0"), TAG_END()); - subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE); - s2_respond_to(subscribe, dialog, SIP_202_ACCEPTED, + subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE); + s2_sip_respond_to(subscribe, dialog, SIP_202_ACCEPTED, SIPTAG_EXPIRES_STR("0"), TAG_END()); - s2_free_message(subscribe); + s2_sip_free_message(subscribe); event = s2_wait_for_event(nua_r_subscribe, 202); fail_if(!event); fail_unless(s2_check_substate(event, nua_substate_embryonic)); s2_free_event(event); - s2_fast_forward(600, s2->root); + s2_nua_fast_forward(600, s2base->root); event = s2_wait_for_event(nua_i_notify, 408); fail_if(!event); fail_unless(s2_check_substate(event, nua_substate_terminated)); @@ -513,7 +512,7 @@ s2_check_event(nua_r_set_params, 200); ta_start(ta, tag, value); - s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, + s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, SIPTAG_EVENT_STR(event), ta_tags(ta)); ta_end(ta); @@ -525,10 +524,10 @@ TAG_END()); s2_free_event(subscribe); - response = s2_wait_for_response(202, SIP_METHOD_SUBSCRIBE); - s2_update_dialog(dialog, response); + response = s2_sip_wait_for_response(202, SIP_METHOD_SUBSCRIBE); + s2_sip_update_dialog(dialog, response); fail_unless(response->sip->sip_expires != NULL); - s2_free_message(response); + s2_sip_free_message(response); return nh; } @@ -544,24 +543,24 @@ "NUA receives SUBSCRIBE, sends 202 and NOTIFY. " "First NOTIFY terminates subscription. "); - s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, - SIPTAG_EVENT_STR("presence"), - TAG_END()); + s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, + SIPTAG_EVENT_STR("presence"), + TAG_END()); /* 489 Bad Event by default */ - s2_check_response(489, SIP_METHOD_SUBSCRIBE); + s2_sip_check_response(489, SIP_METHOD_SUBSCRIBE); nua_set_params(nua, NUTAG_APPL_METHOD("SUBSCRIBE"), TAG_END()); s2_check_event(nua_r_set_params, 200); - s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, + s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, SIPTAG_EVENT_STR("presence"), TAG_END()); - s2_check_response(489, SIP_METHOD_SUBSCRIBE); + s2_sip_check_response(489, SIP_METHOD_SUBSCRIBE); nua_set_params(nua, SIPTAG_ALLOW_EVENTS_STR("presence"), TAG_END()); s2_check_event(nua_r_set_params, 200); - s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, + s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, SIPTAG_EVENT_STR("presence"), TAG_END()); subscribe = s2_wait_for_event(nua_i_subscribe, 100); @@ -571,11 +570,11 @@ TAG_END()); s2_free_event(subscribe); - s2_check_response(403, SIP_METHOD_SUBSCRIBE); + s2_sip_check_response(403, SIP_METHOD_SUBSCRIBE); nua_handle_destroy(nh); - s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, + s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, SIPTAG_EVENT_STR("presence"), TAG_END()); subscribe = s2_wait_for_event(nua_i_subscribe, 100); @@ -585,22 +584,22 @@ TAG_END()); s2_free_event(subscribe); - response = s2_wait_for_response(202, SIP_METHOD_SUBSCRIBE); - s2_update_dialog(dialog, response); + response = s2_sip_wait_for_response(202, SIP_METHOD_SUBSCRIBE); + s2_sip_update_dialog(dialog, response); fail_unless(response->sip->sip_expires != NULL); - s2_free_message(response); + s2_sip_free_message(response); nua_notify(nh, NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR(presence_closed), TAG_END()); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "terminated")); - s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); s2_check_event(nua_r_notify, 200); nua_handle_destroy(nh); @@ -610,8 +609,7 @@ START_TEST(notify_6_3_2) { nua_handle_t *nh; - struct event *subscribe; - struct message *notify, *response; + struct message *notify; sip_t *sip; s2_case("6.3.2", "NOTIFY server - automatic subscription termination", @@ -624,24 +622,24 @@ NUTAG_SUBSTATE(nua_substate_active), SIPTAG_PAYLOAD_STR(presence_closed), TAG_END()); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); - s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); s2_check_event(nua_r_notify, 200); - s2_fast_forward(300, s2->root); + s2_nua_fast_forward(300, s2base->root); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "terminated")); - s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); s2_check_event(nua_r_notify, 200); nua_handle_destroy(nh); @@ -677,26 +675,26 @@ NUTAG_SUBSTATE(nua_substate_active), SIPTAG_PAYLOAD_STR(presence_closed), TAG_END()); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); - s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); s2_check_event(nua_r_notify, 200); nua_notify(nh, NUTAG_SUBSTATE(nua_substate_active), SIPTAG_PAYLOAD_STR(presence_closed), TAG_END()); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); - s2_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END()); response = s2_wait_for_event(nua_r_notify, 481); fail_unless(s2_event_substate(response) == nua_substate_terminated); @@ -723,13 +721,13 @@ NUTAG_SUBSTATE(nua_substate_active), SIPTAG_PAYLOAD_STR(presence_closed), TAG_END()); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); - s2_respond_to(notify, dialog, SIP_200_OK, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); s2_check_event(nua_r_notify, 200); nua_notify(nh, @@ -740,13 +738,13 @@ NUTAG_SUBSTATE(nua_substate_active), SIPTAG_PAYLOAD_STR(presence_closed), TAG_END()); - notify = s2_wait_for_request(SIP_METHOD_NOTIFY); + notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); fail_unless(notify != NULL); sip = notify->sip; fail_unless(sip->sip_subscription_state != NULL); fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); - s2_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END()); + s2_sip_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END()); response = s2_wait_for_event(nua_r_notify, 481); fail_unless(s2_event_substate(response) == nua_substate_terminated); response = s2_wait_for_event(nua_r_notify, 481); @@ -783,10 +781,10 @@ s2_case("0.0.0", "Empty test case", "Detailed explanation for empty test case."); - tport_set_params(s2->master, TPTAG_LOG(1), TAG_END()); + tport_set_params(s2sip->master, TPTAG_LOG(1), TAG_END()); s2_setup_logs(7); s2_setup_logs(0); - tport_set_params(s2->master, TPTAG_LOG(0), TAG_END()); + tport_set_params(s2sip->master, TPTAG_LOG(0), TAG_END()); } END_TEST Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c Tue Mar 3 16:00:56 2009 @@ -54,33 +54,11 @@ #include #include -char const *s2_tester = "s2_tester"; -int s2_start_stop; +/* -- Globals -------------------------------------------------------------- */ -/* -- Module types ------------------------------------------------------ */ +struct s2nua *s2; -struct tp_magic_s -{ - sip_via_t *via; - sip_contact_t *contact; -}; - -/* -- Module prototypes ------------------------------------------------- */ - -static msg_t *s2_msg(int flags); -static int s2_complete_response(msg_t *response, - int status, char const *phrase, - msg_t *request); -static char *s2_generate_tag(su_home_t *home); - -/* -- Module globals ---------------------------------------------------- */ - -struct tester *s2; - -static char const *_s2case = "0.0"; -static unsigned s2_tag_generator = 0; - -/* -- Globals ----------------------------------------------------------- */ +int s2_nua_thread = 0; unsigned s2_default_registration_duration = 3600; @@ -108,8 +86,6 @@ char const s2_auth3_credentials[] = "Digest:\"s2test3\":abc:abc"; -int s2_nua_thread = 0; - /* -- NUA events -------------------------------------------------------- */ struct event *s2_remove_event(struct event *e) @@ -148,7 +124,7 @@ if (s2->events) return s2_remove_event(s2->events); - su_root_step(s2->root, 100); + su_root_step(s2base->root, 100); } } @@ -165,7 +141,7 @@ return s2_remove_event(e); } - su_root_step(s2->root, 100); + su_root_step(s2base->root, 100); } } @@ -230,862 +206,6 @@ *prev = e, e->prev = prev; } -/* ---------------------------------------------------------------------- */ -/* SIP messages sent by nua */ - -struct message * -s2_remove_message(struct message *m) -{ - if ((*m->prev = m->next)) - m->next->prev = m->prev; - - m->prev = NULL, m->next = NULL; - - return m; -} - -void -s2_free_message(struct message *m) -{ - if (m) { - if (m->prev) { - if ((*m->prev = m->next)) - m->next->prev = m->prev; - } - msg_destroy(m->msg); - tport_unref(m->tport); - free(m); - } -} - -void s2_flush_messages(void) -{ - while (s2->received) { - s2_free_message(s2->received); - } -} - -struct message * -s2_next_response(void) -{ - struct message *m; - - for (;;) { - for (m = s2->received; m; m = m->next) { - if (m->sip->sip_status) - return s2_remove_message(m); - } - su_root_step(s2->root, 100); - } -} - -struct message * -s2_wait_for_response(int status, sip_method_t method, char const *name) -{ - struct message *m; - - for (;;) { - for (m = s2->received; m; m = m->next) { - if (!m->sip->sip_status) - continue; - - if (status != 0 && m->sip->sip_status->st_status != status) - continue; - - if (method == sip_method_unknown && name == NULL) - break; - - if (m->sip->sip_cseq == NULL) - continue; - - if (m->sip->sip_cseq->cs_method != method) - continue; - if (name == NULL) - break; - if (strcmp(m->sip->sip_cseq->cs_method_name, name) == 0) - break; - } - - if (m) - return s2_remove_message(m); - - su_root_step(s2->root, 100); - } -} - -int -s2_check_response(int status, sip_method_t method, char const *name) -{ - struct message *m = s2_wait_for_response(status, method, name); - s2_free_message(m); - return m != NULL; -} - - -struct message * -s2_next_request(void) -{ - struct message *m; - - for (;;) { - for (m = s2->received; m; m = m->next) { - if (m->sip->sip_request) - return s2_remove_message(m); - } - - su_root_step(s2->root, 100); - } - - return NULL; -} - -struct message * -s2_wait_for_request(sip_method_t method, char const *name) -{ - return s2_wait_for_request_timeout(method, name, -1); -} - -struct message * -s2_wait_for_request_timeout(sip_method_t method, char const *name, int timeout) -{ - struct message *m; - int t = timeout; - - for (;;) { - for (m = s2->received; m; m = m->next) { - if (m->sip->sip_request) { - if (method == sip_method_unknown && name == NULL) - return s2_remove_message(m); - - if (m->sip->sip_request->rq_method == method && - strcmp(m->sip->sip_request->rq_method_name, name) == 0) - return s2_remove_message(m); - } - } - - su_root_step(s2->root, 100); - if (timeout != -1 && ((t -= 100) <= 0)) - break; - } - - return NULL; -} - -int -s2_check_request(sip_method_t method, char const *name) -{ - struct message *m = s2_wait_for_request(method, name); - s2_free_message(m); - return m != NULL; -} - -int -s2_check_request_timeout(sip_method_t method, char const *name, int timeout) -{ - struct message *m = s2_wait_for_request_timeout(method, name, timeout); - s2_free_message(m); - return m != NULL; -} - -void -s2_save_uas_dialog(struct dialog *d, sip_t *sip) -{ - if (d && !d->local) { - assert(sip->sip_request); - d->local = sip_from_dup(d->home, sip->sip_to); - if (d->local->a_tag == NULL) - sip_from_tag(d->home, d->local, s2_generate_tag(d->home)); - d->remote = sip_to_dup(d->home, sip->sip_from); - d->call_id = sip_call_id_dup(d->home, sip->sip_call_id); - d->rseq = sip->sip_cseq->cs_seq; - /* d->route = sip_route_dup(d->home, sip->sip_record_route); */ - d->target = sip_contact_dup(d->home, sip->sip_contact); - } -} - -struct message * -s2_respond_to(struct message *m, struct dialog *d, - int status, char const *phrase, - tag_type_t tag, tag_value_t value, ...) -{ - ta_list ta; - msg_t *reply; - sip_t *sip; - su_home_t *home; - tp_name_t tpn[1]; - char *rport; - - assert(m); assert(m->msg); assert(m->tport); - assert(100 <= status && status < 700); - - s2_save_uas_dialog(d, m->sip); - - ta_start(ta, tag, value); - - reply = s2_msg(0); sip = sip_object(reply); home = msg_home(reply); - - assert(reply && home && sip); - - if (sip_add_tl(reply, sip, ta_tags(ta)) < 0) { - abort(); - } - - s2_complete_response(reply, status, phrase, m->msg); - - if (sip->sip_status && sip->sip_status->st_status > 100 && - sip->sip_to && !sip->sip_to->a_tag && - sip->sip_cseq && sip->sip_cseq->cs_method != sip_method_cancel) { - char const *ltag = NULL; - - if (d && d->local) - ltag = d->local->a_tag; - - if (ltag == NULL) - ltag = s2_generate_tag(home); - - if (sip_to_tag(msg_home(reply), sip->sip_to, ltag) < 0) { - assert(!"add To tag"); - } - } - - if (d && !d->contact) { - d->contact = sip_contact_dup(d->home, sip->sip_contact); - } - - *tpn = *tport_name(m->tport); - - rport = su_sprintf(home, "rport=%u", - ntohs(((su_sockaddr_t *) - msg_addrinfo(m->msg)->ai_addr)->su_port)); - - if (s2->server_uses_rport && - sip->sip_via->v_rport && - sip->sip_via->v_rport[0] == '\0') { - msg_header_add_param(home, sip->sip_via->v_common, rport); - } - - tpn->tpn_port = rport + strlen("rport="); - - tport_tsend(m->tport, reply, tpn, TPTAG_MTU(INT_MAX), ta_tags(ta)); - msg_destroy(reply); - - ta_end(ta); - - return m; -} - -/** Add headers from the request to the response message. */ -static int -s2_complete_response(msg_t *response, - int status, char const *phrase, - msg_t *request) -{ - su_home_t *home = msg_home(response); - sip_t *response_sip = sip_object(response); - sip_t const *request_sip = sip_object(request); - - int incomplete = 0; - - if (!response_sip || !request_sip || !request_sip->sip_request) - return -1; - - if (!response_sip->sip_status) - response_sip->sip_status = sip_status_create(home, status, phrase, NULL); - if (!response_sip->sip_via) - response_sip->sip_via = sip_via_dup(home, request_sip->sip_via); - if (!response_sip->sip_from) - response_sip->sip_from = sip_from_dup(home, request_sip->sip_from); - if (!response_sip->sip_to) - response_sip->sip_to = sip_to_dup(home, request_sip->sip_to); - if (!response_sip->sip_call_id) - response_sip->sip_call_id = - sip_call_id_dup(home, request_sip->sip_call_id); - if (!response_sip->sip_cseq) - response_sip->sip_cseq = sip_cseq_dup(home, request_sip->sip_cseq); - - if (!response_sip->sip_record_route && request_sip->sip_record_route) - sip_add_dup(response, response_sip, (void*)request_sip->sip_record_route); - - incomplete = sip_complete_message(response) < 0; - - msg_serialize(response, (msg_pub_t *)response_sip); - - if (incomplete || - !response_sip->sip_status || - !response_sip->sip_via || - !response_sip->sip_from || - !response_sip->sip_to || - !response_sip->sip_call_id || - !response_sip->sip_cseq || - !response_sip->sip_content_length || - !response_sip->sip_separator || - (request_sip->sip_record_route && !response_sip->sip_record_route)) - return -1; - - return 0; -} - -/* Send request (updating dialog). - * - * Return zero upon success, nonzero upon failure. - */ -int -s2_request_to(struct dialog *d, - sip_method_t method, char const *name, - tport_t *tport, - tag_type_t tag, tag_value_t value, ...) -{ - ta_list ta; - tagi_t const *tags; - - msg_t *msg = s2_msg(0); - sip_t *sip = sip_object(msg); - url_t const *target = NULL; - sip_cseq_t cseq[1]; - sip_via_t via[1]; char const *v_params[8]; - sip_content_length_t l[1]; - tp_name_t tpn[1]; - tp_magic_t *magic; - int user_via = 0; - - ta_start(ta, tag, value); - tags = ta_args(ta); - - if (sip_add_tagis(msg, sip, &tags) < 0) - goto error; - - if (sip->sip_request) - target = sip->sip_request->rq_url; - else if (d->target) - target = d->target->m_url; - else if (s2->registration->contact) - target = s2->registration->contact->m_url; - else - target = NULL; - - if (target == NULL) - goto error; - - if (!sip->sip_request) { - sip_request_t *rq; - rq = sip_request_create(msg_home(msg), method, name, - (url_string_t *)target, NULL); - sip_header_insert(msg, sip, (sip_header_t *)rq); - } - - if (!d->local && sip->sip_from) - d->local = sip_from_dup(d->home, sip->sip_from); - if (!d->contact && sip->sip_contact) - d->contact = sip_contact_dup(d->home, sip->sip_contact); - if (!d->remote && sip->sip_to) - d->remote = sip_to_dup(d->home, sip->sip_to); - if (!d->target && sip->sip_request) - d->target = sip_contact_create(d->home, - (url_string_t *)sip->sip_request->rq_url, - NULL); - if (!d->call_id && sip->sip_call_id) - d->call_id = sip_call_id_dup(d->home, sip->sip_call_id); - if (!d->lseq && sip->sip_cseq) - d->lseq = sip->sip_cseq->cs_seq; - - if (!d->local) - d->local = sip_from_dup(d->home, s2->local); - if (!d->contact) - d->contact = sip_contact_dup(d->home, s2->contact); - if (!d->remote) - d->remote = sip_to_dup(d->home, s2->registration->aor); - if (!d->call_id) - d->call_id = sip_call_id_create(d->home, NULL); - assert(d->local && d->contact); - assert(d->remote && d->target); - assert(d->call_id); - - if (tport == NULL) - tport = d->tport; - - if (tport == NULL) - tport = s2->registration->tport; - - if (tport == NULL && d->target->m_url->url_type == url_sips) - tport = s2->tls.tport; - - if (tport == NULL) - tport = s2->udp.tport; - else if (tport == NULL) - tport = s2->tcp.tport; - else if (tport == NULL) - tport = s2->tls.tport; - - assert(tport); - - *tpn = *tport_name(tport); - - if (tport_is_primary(tport)) { - tpn->tpn_host = target->url_host; - tpn->tpn_port = url_port(target); - if (!tpn->tpn_port || !tpn->tpn_port[0]) - tpn->tpn_port = url_port_default(target->url_type); - } - - magic = tport_magic(tport); - assert(magic != NULL); - - sip_cseq_init(cseq); - cseq->cs_method = method; - cseq->cs_method_name = name; - - if (d->invite && (method == sip_method_ack || method == sip_method_cancel)) { - cseq->cs_seq = sip_object(d->invite)->sip_cseq->cs_seq; - } - else { - cseq->cs_seq = ++d->lseq; - } - - if (sip->sip_via) { - user_via = 1; - } - else if (d->invite && method == sip_method_cancel) { - *via = *sip_object(d->invite)->sip_via; - } - else { - *via = *magic->via; - via->v_params = v_params; - v_params[0] = su_sprintf(msg_home(msg), "branch=z9hG4bK%lx", ++s2->tid); - v_params[1] = NULL; - } - - sip_content_length_init(l); - if (sip->sip_payload) - l->l_length = sip->sip_payload->pl_len; - - if (d->local->a_tag == NULL) { - char const *ltag = s2_generate_tag(d->home); - - if (sip_from_tag(d->home, d->local, ltag) < 0) { - assert(!"add To tag"); - } - - if (sip->sip_from && sip->sip_from->a_tag == NULL) { - if (sip_from_tag(msg_home(msg), sip->sip_from, ltag) < 0) { - assert(!"add To tag"); - } - } - } - - sip_add_tl(msg, sip, - TAG_IF(!sip->sip_from, SIPTAG_FROM(d->local)), - TAG_IF(!sip->sip_contact, SIPTAG_CONTACT(d->contact)), - TAG_IF(!sip->sip_to, SIPTAG_TO(d->remote)), - TAG_IF(!sip->sip_call_id, SIPTAG_CALL_ID(d->call_id)), - TAG_IF(!sip->sip_cseq, SIPTAG_CSEQ(cseq)), - TAG_IF(!user_via, SIPTAG_VIA(via)), - TAG_IF(!sip->sip_content_length, SIPTAG_CONTENT_LENGTH(l)), - TAG_IF(!sip->sip_separator, SIPTAG_SEPARATOR_STR("\r\n")), - TAG_END()); - - msg_serialize(msg, NULL); - - if (method == sip_method_invite) { - msg_destroy(d->invite); - d->invite = msg_ref_create(msg); - } - - tport = tport_tsend(tport, msg, tpn, ta_tags(ta)); - ta_end(ta); - - if (d->tport != tport) { - tport_unref(d->tport); - d->tport = tport_ref(tport); - } - - return tport ? 0 : -1; - - error: - ta_end(ta); - return -1; -} - -/** Save information from response. - * - * Send ACK for error messages to INVITE. - */ -int s2_update_dialog(struct dialog *d, struct message *m) -{ - int status = 0; - - if (m->sip->sip_status) - status = m->sip->sip_status->st_status; - - if (100 < status && status < 300) { - d->remote = sip_to_dup(d->home, m->sip->sip_to); - if (m->sip->sip_contact) - d->contact = sip_contact_dup(d->home, m->sip->sip_contact); - } - - if (300 <= status && m->sip->sip_cseq && - m->sip->sip_cseq->cs_method == sip_method_invite && - d->invite) { - msg_t *ack = s2_msg(0); - sip_t *sip = sip_object(ack); - sip_t *invite = sip_object(d->invite); - sip_request_t rq[1]; - sip_cseq_t cseq[1]; - tp_name_t tpn[1]; - - *rq = *invite->sip_request; - rq->rq_method = sip_method_ack, rq->rq_method_name = "ACK"; - *cseq = *invite->sip_cseq; - cseq->cs_method = sip_method_ack, cseq->cs_method_name = "ACK"; - - sip_add_tl(ack, sip, - SIPTAG_REQUEST(rq), - SIPTAG_VIA(invite->sip_via), - SIPTAG_FROM(invite->sip_from), - SIPTAG_TO(invite->sip_to), - SIPTAG_CALL_ID(invite->sip_call_id), - SIPTAG_CSEQ(cseq), - SIPTAG_CONTENT_LENGTH_STR("0"), - SIPTAG_SEPARATOR_STR("\r\n"), - TAG_END()); - - *tpn = *tport_name(d->tport); - if (!tport_is_secondary(d->tport) || - !tport_is_clear_to_send(d->tport)) { - tpn->tpn_host = rq->rq_url->url_host; - tpn->tpn_port = rq->rq_url->url_port; - } - - msg_serialize(ack, NULL); - tport_tsend(d->tport, ack, tpn, TAG_END()); - } - - return 0; -} - -/* ---------------------------------------------------------------------- */ - -int -s2_save_register(struct message *rm) -{ - sip_contact_t *contact, *m, **m_prev; - sip_expires_t const *ex; - sip_date_t const *date; - sip_time_t now = rm->when.tv_sec, expires; - - msg_header_free_all(s2->home, (msg_header_t *)s2->registration->aor); - msg_header_free_all(s2->home, (msg_header_t *)s2->registration->contact); - tport_unref(s2->registration->tport); - - s2->registration->aor = NULL; - s2->registration->contact = NULL; - s2->registration->tport = NULL; - - if (rm == NULL) - return 0; - - assert(rm && rm->sip && rm->sip->sip_request); - assert(rm->sip->sip_request->rq_method == sip_method_register); - - ex = rm->sip->sip_expires; - date = rm->sip->sip_date; - - contact = sip_contact_dup(s2->home, rm->sip->sip_contact); - - for (m_prev = &contact; *m_prev;) { - m = *m_prev; - - expires = sip_contact_expires(m, ex, date, - s2_default_registration_duration, - now); - if (expires) { - char *p = su_sprintf(s2->home, "expires=%lu", (unsigned long)expires); - msg_header_add_param(s2->home, m->m_common, p); - m_prev = &m->m_next; - } - else { - *m_prev = m->m_next; - m->m_next = NULL; - msg_header_free(s2->home, (msg_header_t *)m); - } - } - - if (contact == NULL) - return 0; - - s2->registration->aor = sip_to_dup(s2->home, rm->sip->sip_to); - s2->registration->contact = contact; - s2->registration->tport = tport_ref(rm->tport); - - return 0; -} - -/* ---------------------------------------------------------------------- */ - -static char * -s2_generate_tag(su_home_t *home) -{ - s2_tag_generator += 1; - - return su_sprintf(home, "tag=N2-%s/%u", _s2case, s2_tag_generator); -} - -void s2_case(char const *number, - char const *title, - char const *description) -{ - _s2case = number; - - if (s2_start_stop) - printf("%s - starting %s %s\n", s2_tester, number, title); -} - -/* ---------------------------------------------------------------------- */ -/* tport interface */ -static void -s2_stack_recv(struct tester *s2, - tport_t *tp, - msg_t *msg, - tp_magic_t *magic, - su_time_t now) -{ - struct message *next = calloc(1, sizeof *next), **prev; - - next->msg = msg; - next->sip = sip_object(msg); - next->when = now; - next->tport = tport_ref(tp); - -#if 0 - if (next->sip->sip_request) - printf("nua sent: %s\n", next->sip->sip_request->rq_method_name); - else - printf("nua sent: SIP/2.0 %u %s\n", - next->sip->sip_status->st_status, - next->sip->sip_status->st_phrase); -#endif - - for (prev = &s2->received; *prev; prev = &(*prev)->next) - ; - - next->prev = prev, *prev = next; -} - -static void -s2_stack_error(struct tester *s2, - tport_t *tp, - int errcode, - char const *remote) -{ - fprintf(stderr, "%s(%p): error %d (%s) from %s\n", - "nua_tester_error", - (void *)tp, errcode, su_strerror(errcode), - remote ? remote : ""); -} - -static msg_t * -s2_stack_alloc(struct tester *s2, int flags, - char const data[], usize_t size, - tport_t const *tport, - tp_client_t *tpc) -{ - return msg_create(s2->mclass, flags | s2->flags); -} - -static msg_t * -s2_msg(int flags) -{ - return msg_create(s2->mclass, flags | s2->flags); -} - -tp_stack_class_t const s2_stack[1] = - {{ - /* tpac_size */ (sizeof s2_stack), - /* tpac_recv */ s2_stack_recv, - /* tpac_error */ s2_stack_error, - /* tpac_alloc */ s2_stack_alloc, - }}; - -/** Basic setup for test cases */ -void s2_setup_base(char const *label, char const *hostname) -{ - assert(s2 == NULL); - - if (s2_start_stop > 1) { - printf("%s - setup %s test case\n", s2_tester, label ? label : "next"); - } - - su_init(); - - s2 = su_home_new(sizeof *s2); - - assert(s2 != NULL); - - s2->root = su_root_create(s2); - - assert(s2->root != NULL); - - s2->local = sip_from_format(s2->home, "Bob ", - hostname ? hostname : "example.net"); - - if (hostname == NULL) - hostname = "127.0.0.1"; - - s2->hostname = hostname; - s2->tid = (unsigned long)time(NULL) * 510633671UL; - -} - -SOFIAPUBVAR su_log_t nua_log[]; -SOFIAPUBVAR su_log_t soa_log[]; -SOFIAPUBVAR su_log_t nea_log[]; -SOFIAPUBVAR su_log_t nta_log[]; -SOFIAPUBVAR su_log_t tport_log[]; -SOFIAPUBVAR su_log_t su_log_default[]; - -void -s2_setup_logs(int level) -{ - assert(s2); - - su_log_soft_set_level(nua_log, level); - su_log_soft_set_level(soa_log, level); - su_log_soft_set_level(su_log_default, level); - su_log_soft_set_level(nea_log, level); - su_log_soft_set_level(nta_log, level); - su_log_soft_set_level(tport_log, level); -} - -static char const * default_protocols[] = { "udp", "tcp", NULL }; - -void -s2_setup_tport(char const * const *protocols, - tag_type_t tag, tag_value_t value, ...) -{ - ta_list ta; - tp_name_t tpn[1]; - int bound; - tport_t *tp; - - assert(s2 != NULL); - - ta_start(ta, tag, value); - - if (s2->master == NULL) { - s2->master = tport_tcreate(s2, s2_stack, s2->root, - TPTAG_LOG(getenv("S2_TPORT_LOG") != NULL), - ta_tags(ta)); - - if (s2->master == NULL) { - assert(s2->master); - } - s2->mclass = sip_default_mclass(); - s2->flags = 0; - } - - memset(tpn, 0, (sizeof tpn)); - tpn->tpn_proto = "*"; - tpn->tpn_host = s2->hostname; - tpn->tpn_port = "*"; - - if (protocols == NULL) - protocols = default_protocols; - - bound = tport_tbind(s2->master, tpn, protocols, - TPTAG_SERVER(1), - ta_tags(ta)); - assert(bound != -1); - - tp = tport_primaries(s2->master); - - if (protocols == default_protocols && s2->contact == NULL) { - *tpn = *tport_name(tp); - s2->contact = sip_contact_format(s2->home, "", - tpn->tpn_host, - tpn->tpn_port); - } - - for (;tp; tp = tport_next(tp)) { - sip_via_t *v; - sip_contact_t *m; - tp_magic_t *magic; - - if (tport_magic(tp)) - continue; - - *tpn = *tport_name(tp); - - v = sip_via_format(s2->home, "SIP/2.0/%s %s:%s", - tpn->tpn_proto, - tpn->tpn_host, - tpn->tpn_port); - assert(v != NULL); - if (!su_casenmatch(tpn->tpn_proto, "tls", 3)) { - m = sip_contact_format(s2->home, "", - tpn->tpn_host, - tpn->tpn_port, - tpn->tpn_proto); - if (s2->udp.contact == NULL && su_casematch(tpn->tpn_proto, "udp")) { - s2->udp.tport = tport_ref(tp); - s2->udp.contact = m; - } - if (s2->tcp.contact == NULL && su_casematch(tpn->tpn_proto, "tcp")) { - s2->tcp.tport = tport_ref(tp); - s2->tcp.contact = m; - } - } - else if (!su_casematch(tpn->tpn_proto, "tls")) { - m = sip_contact_format(s2->home, "", - tpn->tpn_host, - tpn->tpn_port, - tpn->tpn_proto); - } - else { - m = sip_contact_format(s2->home, "", - tpn->tpn_host, - tpn->tpn_port); - if (s2->tls.contact == NULL) { - s2->tls.tport = tport_ref(tp); - s2->tls.contact = m; - } - } - assert(m != NULL); - - magic = su_zalloc(s2->home, (sizeof *magic)); - magic->via = v, magic->contact = m; - - if (s2->contact == NULL) - s2->contact = m; - - tport_set_magic(tp, magic); - } -} - -static char const *s2_teardown_label = NULL; - -void -s2_teardown_started(char const *label) -{ - if (!s2_teardown_label) { - s2_teardown_label = label; - if (s2_start_stop > 1) { - printf("%s - tearing down %s test case\n", s2_tester, label); - } - } -} - -void -s2_teardown(void) -{ - s2 = NULL; - su_deinit(); - - if (s2_start_stop > 1) { - printf("%s - %s test case tore down\n", s2_tester, - s2_teardown_label ? s2_teardown_label : "previous"); - } - - s2_teardown_label = NULL; -} /* ====================================================================== */ @@ -1094,27 +214,31 @@ { ta_list ta; - s2_setup_base(label, NULL); - s2_dns_setup(s2->root); + s2_setup(label); + + s2 = su_home_new(sizeof *s2); + + s2_dns_setup(s2base->root); s2_setup_logs(0); - s2_setup_tport(NULL, TAG_END()); - assert(s2->contact); + s2_sip_setup("example.org", NULL, TAG_END()); + assert(s2sip->contact); + s2_dns_domain("example.org", 1, - "s2", 1, s2->udp.contact->m_url, - "s2", 1, s2->tcp.contact->m_url, + "s2", 1, s2sip->udp.contact->m_url, + "s2", 1, s2sip->tcp.contact->m_url, NULL); /* enable/disable multithreading */ - su_root_threading(s2->root, s2_nua_thread); + su_root_threading(s2base->root, s2_nua_thread); ta_start(ta, tag, value); s2->nua = - nua_create(s2->root, + nua_create(s2base->root, s2_nua_callback, s2, SIPTAG_FROM_STR("Alice "), - /* NUTAG_PROXY((url_string_t *)s2->contact->m_url), */ + /* NUTAG_PROXY((url_string_t *)s2sip->contact->m_url), */ /* Use internal DNS server */ NUTAG_PROXY("sip:example.org"), /* Force sresolv to use localhost and s2dns as DNS server */ @@ -1129,12 +253,33 @@ return s2->nua; } +void +s2_nua_fast_forward(unsigned long seconds, + su_root_t *steproot) +{ + s2_fast_forward(seconds, NULL); + + if (s2_nua_thread) + /* Wake up nua thread */ + nua_handle_by_call_id(s2->nua, NULL); + + if (steproot) + su_root_step(steproot, 0); +} + void s2_nua_teardown(void) { - nua_destroy(s2->nua); - s2->nua = NULL; + if (s2) { + struct s2nua *zap = s2; + nua_destroy(s2->nua), s2->nua = NULL; + s2 = NULL; + su_home_unref(zap->home); + } + s2_dns_teardown(); + s2_sip_teardown(); s2_teardown(); + } /* ====================================================================== */ @@ -1160,15 +305,16 @@ nua_register(nh, TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); assert(m); + s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), TAG_END()); - s2_free_message(m); + s2_sip_free_message(m); assert(s2->registration->contact != NULL); s2_check_event(nua_r_register, 200); @@ -1193,15 +339,15 @@ nua_unregister(nh, TAG_END()); - m = s2_wait_for_request(SIP_METHOD_REGISTER); assert(m); + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); assert(m); s2_save_register(m); - s2_respond_to(m, NULL, + s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), TAG_END()); assert(s2->registration->contact == NULL); - s2_free_message(m); + s2_sip_free_message(m); s2_check_event(nua_r_unregister, 200); @@ -1209,3 +355,62 @@ s2->registration->nh = NULL; } } + +int +s2_save_register(struct message *rm) +{ + sip_contact_t *contact, *m, **m_prev; + sip_expires_t const *ex; + sip_date_t const *date; + sip_time_t now = rm->when.tv_sec, expires; + + msg_header_free_all(s2->home, (msg_header_t *)s2->registration->aor); + msg_header_free_all(s2->home, (msg_header_t *)s2->registration->contact); + tport_unref(s2->registration->tport); + + s2->registration->aor = NULL; + s2->registration->contact = NULL; + s2->registration->tport = NULL; + + if (rm == NULL) + return 0; + + assert(rm && rm->sip && rm->sip->sip_request); + assert(rm->sip->sip_request->rq_method == sip_method_register); + + ex = rm->sip->sip_expires; + date = rm->sip->sip_date; + + contact = sip_contact_dup(s2->home, rm->sip->sip_contact); + + for (m_prev = &contact; *m_prev;) { + m = *m_prev; + + expires = sip_contact_expires(m, ex, date, + s2_default_registration_duration, + now); + if (expires) { + char *p = su_sprintf(s2->home, "expires=%lu", (unsigned long)expires); + msg_header_add_param(s2->home, m->m_common, p); + m_prev = &m->m_next; + } + else { + *m_prev = m->m_next; + m->m_next = NULL; + msg_header_free(s2->home, (msg_header_t *)m); + } + } + + if (contact == NULL) + return 0; + + s2->registration->aor = sip_to_dup(s2->home, rm->sip->sip_to); + s2->registration->contact = contact; + s2->registration->tport = tport_ref(rm->tport); + + s2sip->sut.aor = s2->registration->aor; + s2sip->sut.contact = s2->registration->contact; + s2sip->sut.tport = s2->registration->tport; + + return 0; +} Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h Tue Mar 3 16:00:56 2009 @@ -24,42 +24,20 @@ #ifndef S2TESTER_H #define S2TESTER_H -#define TP_STACK_T struct tester -#define SU_ROOT_MAGIC_T struct tester - #include #include #include #include +#include +#include "s2base.h" #include "s2util.h" +#include "s2sip.h" -struct tester +struct s2nua { su_home_t home[1]; - su_root_t *root; - msg_mclass_t const *mclass; - int flags; - - char const *hostname; - tport_t *master; - - sip_to_t *local; - sip_contact_t *contact; - struct { - sip_contact_t *contact; - tport_t *tport; - } udp, tcp, tls; - - struct message { - struct message *next, **prev; - msg_t *msg; - sip_t *sip; - tport_t *tport; - su_time_t when; - } *received; - nua_t *nua; struct event { @@ -76,33 +54,8 @@ sip_contact_t *contact; tport_t *tport; } registration[1]; - - unsigned long tid; - - /* Settings */ - int server_uses_rport; }; -struct dialog -{ - su_home_t home[1]; - sip_from_t *local; - sip_to_t *remote; - sip_call_id_t *call_id; - uint32_t lseq, rseq; - sip_contact_t *target; - sip_route_t *route; - sip_contact_t *contact; - - tport_t *tport; - msg_t *invite; /* latest invite sent */ -}; - -extern char const *s2_tester; -extern int s2_start_stop; -extern struct tester *s2; -extern tp_stack_class_t const s2_stack[1]; - extern unsigned s2_default_registration_duration; extern char const s2_auth_digest_str[]; extern char const s2_auth_credentials[]; @@ -115,9 +68,7 @@ extern int s2_nua_thread; -void s2_case(char const *tag, - char const *title, - char const *description); +extern struct s2nua *s2; struct event *s2_remove_event(struct event *); void s2_free_event(struct event *); @@ -127,54 +78,23 @@ struct event *s2_wait_for_event(nua_event_t event, int status); int s2_check_event(nua_event_t event, int status); int s2_check_callstate(enum nua_callstate state); - -struct message *s2_remove_message(struct message *m); -void s2_free_message(struct message *m); -void s2_flush_messages(void); - -struct message *s2_next_response(void); -struct message *s2_wait_for_response(int status, sip_method_t , char const *); -int s2_check_response(int status, sip_method_t method, char const *name); - -struct message *s2_next_request(void); -struct message *s2_wait_for_request(sip_method_t method, char const *name); -struct message *s2_wait_for_request_timeout(sip_method_t, char const *, - int timeout); -int s2_check_request(sip_method_t method, char const *name); -int s2_check_request_timeout(sip_method_t method, char const *, int timeout); - int s2_check_substate(struct event *e, enum nua_substate state); #define SIP_METHOD_UNKNOWN sip_method_unknown, NULL -void s2_save_uas_dialog(struct dialog *d, sip_t *sip); - -struct message *s2_respond_to(struct message *m, struct dialog *d, - int status, char const *phrase, - tag_type_t tag, tag_value_t value, ...); - -int s2_request_to(struct dialog *d, - sip_method_t method, char const *name, - tport_t *tport, - tag_type_t tag, tag_value_t value, ...); - -int s2_update_dialog(struct dialog *d, struct message *response); - -int s2_save_register(struct message *m); - void s2_flush_all(void); -void s2_setup_base(char const *label, char const *hostname); -void s2_setup_logs(int level); -void s2_setup_tport(char const * const *protocols, - tag_type_t tag, tag_value_t value, ...); -void s2_teardown(void); - nua_t *s2_nua_setup(char const *label, tag_type_t tag, tag_value_t value, ...); -void s2_teardown_started(char const *label); void s2_nua_teardown(void); + +void s2_nua_fast_forward(unsigned long seconds, + su_root_t *steproot); + +int s2_save_register(struct message *m); + void s2_register_setup(void); void s2_register_teardown(void); #endif + From mikej at freeswitch.org Tue Mar 3 14:01:25 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 16:01:25 -0600 Subject: [Freeswitch-svn] [commit] r12399 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 3 16:01:25 2009 New Revision: 12399 Log: Tue Mar 3 12:18:30 CST 2009 Pekka Pessi * check_session.c: more CANCEL timeout cases Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 16:01:25 2009 @@ -1 +1 @@ -Tue Mar 3 16:00:35 CST 2009 +Tue Mar 3 16:01:07 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 3 16:01:25 2009 @@ -96,10 +96,11 @@ s2_register_teardown(); - mark_point(); - - nua_shutdown(nua); - fail_unless(s2_check_event(nua_r_shutdown, 200)); + if (s2->shutdown == 0) { + mark_point(); + nua_shutdown(nua); + fail_unless(s2_check_event(nua_r_shutdown, 200)); + } mark_point(); @@ -1051,6 +1052,110 @@ } END_TEST +START_TEST(cancel_2_2_9) +{ + nua_handle_t *nh; + struct message *invite, *cancel; + int timeout; + + s2_case("2.2.9", "CANCEL a RFC2543 UA", + "NUA is caller, NUA sends CANCEL after receiving 180, " + "UAS sends 200 OK to CANCEL but no response to INVITE."); + + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); + + nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), + TAG_END()); + fail_unless(s2_check_callstate(nua_callstate_calling)); + + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); + process_offer(invite); + respond_with_sdp( + invite, dialog, SIP_180_RINGING, + SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), + TAG_END()); + fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless(s2_check_callstate(nua_callstate_proceeding)); + + nua_cancel(nh, TAG_END()); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); + fail_if(!cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); + + /* Time out INVITE */ + for (timeout = 0; timeout < 34; timeout++) { + s2_nua_fast_forward(1, s2base->root); + } + + fail_unless(s2_check_event(nua_r_invite, 408)); + fail_unless(s2_check_callstate(nua_callstate_terminated)); + nua_handle_destroy(nh); +} +END_TEST + +START_TEST(cancel_2_2_10) +{ + nua_handle_t *nh; + struct message *invite, *cancel; + struct event *event; + int timeout; + + s2_case("2.2.10", "CANCEL and INVITE times out", + "NUA is caller, NUA sends CANCEL after receiving 180 " + "but UAS never responds."); + + nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); + + nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), + TAG_END()); + fail_unless(s2_check_callstate(nua_callstate_calling)); + + invite = s2_sip_wait_for_request(SIP_METHOD_INVITE); + process_offer(invite); + respond_with_sdp( + invite, dialog, SIP_180_RINGING, + SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), + TAG_END()); + fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless(s2_check_callstate(nua_callstate_proceeding)); + + nua_cancel(nh, TAG_END()); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); + s2_sip_free_message(cancel); + fail_if(!cancel); + + nua_cancel(nh, TAG_END()); + cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL); + fail_if(!cancel); + s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); + s2_sip_free_message(cancel); + + s2_register_teardown(); + + nua_set_params(s2->nua, NUTAG_SHUTDOWN_EVENTS(1), TAG_END()); + fail_unless(s2_check_event(nua_r_set_params, 200)); + + nua_shutdown(s2->nua); + event = s2_wait_for_event(nua_r_shutdown, 100); + fail_unless(event != NULL); + s2_free_event(event); + + /* Time out */ + for (timeout = 0; timeout < 34; timeout++) { + s2_nua_fast_forward(5, s2base->root); + nua_shutdown(s2->nua); + event = s2_wait_for_event(nua_r_shutdown, 0); + fail_unless(event != NULL); + if (event->data->e_status >= 200) + break; + } + + s2->shutdown = 200; +} +END_TEST + + TCase *cancel_tcase(int threading) { @@ -1065,6 +1170,8 @@ tcase_add_test(tc, cancel_2_2_6); tcase_add_test(tc, cancel_2_2_7); tcase_add_test(tc, cancel_2_2_8); + tcase_add_test(tc, cancel_2_2_9); + tcase_add_test(tc, cancel_2_2_10); return tc; } Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h Tue Mar 3 16:01:25 2009 @@ -40,6 +40,8 @@ nua_t *nua; + int shutdown; + struct event { struct event *next, **prev; nua_saved_event_t event[1]; From mikej at freeswitch.org Tue Mar 3 14:02:55 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 16:02:55 -0600 Subject: [Freeswitch-svn] [commit] r12400 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su Message-ID: Author: mikej Date: Tue Mar 3 16:02:55 2009 New Revision: 12400 Log: Tue Mar 3 12:23:35 CST 2009 Della Betta Filippo * su_uniqueid.c: srand() must be called per-thread on windows Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 16:02:55 2009 @@ -1 +1 @@ -Tue Mar 3 16:01:07 CST 2009 +Tue Mar 3 16:01:38 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Tue Mar 3 16:02:55 2009 @@ -73,8 +73,13 @@ #include "sofia-sip/su_time.h" #include "sofia-sip/su_uniqueid.h" +#ifdef SU_HAVE_WINSOCK +#define PERTHREAD __declspec(thread) +#else +#define PERTHREAD +#endif /* For random number generator */ -static int initialized = 0; +static PERTHREAD int initialized = 0; static void init(void); static void init_node(void); From mikej at freeswitch.org Tue Mar 3 15:00:52 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 17:00:52 -0600 Subject: [Freeswitch-svn] [commit] r12401 - freeswitch/trunk/libs/esl/python Message-ID: Author: mikej Date: Tue Mar 3 17:00:52 2009 New Revision: 12401 Log: revert 12339 Added: freeswitch/trunk/libs/esl/python/ESL.py Removed: freeswitch/trunk/libs/esl/python/_ESL.py Modified: freeswitch/trunk/libs/esl/python/Makefile freeswitch/trunk/libs/esl/python/esl_wrap.cpp Added: freeswitch/trunk/libs/esl/python/ESL.py ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/esl/python/ESL.py Tue Mar 3 17:00:52 2009 @@ -0,0 +1,99 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.35 +# +# Don't modify this file, modify the SWIG interface instead. +# This file is compatible with both classic and new-style classes. + +import _ESL +import new +new_instancemethod = new.instancemethod +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'PySwigObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +class ESLevent: + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ESLevent, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ESLevent, name) + __repr__ = _swig_repr + __swig_setmethods__["event"] = _ESL.ESLevent_event_set + __swig_getmethods__["event"] = _ESL.ESLevent_event_get + __swig_setmethods__["serialized_string"] = _ESL.ESLevent_serialized_string_set + __swig_getmethods__["serialized_string"] = _ESL.ESLevent_serialized_string_get + __swig_setmethods__["mine"] = _ESL.ESLevent_mine_set + __swig_getmethods__["mine"] = _ESL.ESLevent_mine_get + def __init__(self, *args): + this = apply(_ESL.new_ESLevent, args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _ESL.delete_ESLevent + __del__ = lambda self : None; + def serialize(*args): return apply(_ESL.ESLevent_serialize, args) + def setPriority(*args): return apply(_ESL.ESLevent_setPriority, args) + def getHeader(*args): return apply(_ESL.ESLevent_getHeader, args) + def getBody(*args): return apply(_ESL.ESLevent_getBody, args) + def getType(*args): return apply(_ESL.ESLevent_getType, args) + def addBody(*args): return apply(_ESL.ESLevent_addBody, args) + def addHeader(*args): return apply(_ESL.ESLevent_addHeader, args) + def delHeader(*args): return apply(_ESL.ESLevent_delHeader, args) + def firstHeader(*args): return apply(_ESL.ESLevent_firstHeader, args) + def nextHeader(*args): return apply(_ESL.ESLevent_nextHeader, args) +ESLevent_swigregister = _ESL.ESLevent_swigregister +ESLevent_swigregister(ESLevent) + +class ESLconnection: + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ESLconnection, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ESLconnection, name) + __repr__ = _swig_repr + def __init__(self, *args): + this = apply(_ESL.new_ESLconnection, args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _ESL.delete_ESLconnection + __del__ = lambda self : None; + def connected(*args): return apply(_ESL.ESLconnection_connected, args) + def getInfo(*args): return apply(_ESL.ESLconnection_getInfo, args) + def send(*args): return apply(_ESL.ESLconnection_send, args) + def sendRecv(*args): return apply(_ESL.ESLconnection_sendRecv, args) + def api(*args): return apply(_ESL.ESLconnection_api, args) + def bgapi(*args): return apply(_ESL.ESLconnection_bgapi, args) + def sendEvent(*args): return apply(_ESL.ESLconnection_sendEvent, args) + def recvEvent(*args): return apply(_ESL.ESLconnection_recvEvent, args) + def recvEventTimed(*args): return apply(_ESL.ESLconnection_recvEventTimed, args) + def filter(*args): return apply(_ESL.ESLconnection_filter, args) + def events(*args): return apply(_ESL.ESLconnection_events, args) + def execute(*args): return apply(_ESL.ESLconnection_execute, args) + def setBlockingExecute(*args): return apply(_ESL.ESLconnection_setBlockingExecute, args) + def setEventLock(*args): return apply(_ESL.ESLconnection_setEventLock, args) +ESLconnection_swigregister = _ESL.ESLconnection_swigregister +ESLconnection_swigregister(ESLconnection) + +eslSetLogLevel = _ESL.eslSetLogLevel + + Modified: freeswitch/trunk/libs/esl/python/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/python/Makefile (original) +++ freeswitch/trunk/libs/esl/python/Makefile Tue Mar 3 17:00:52 2009 @@ -4,7 +4,7 @@ all: _ESL.so esl_wrap.cpp: - swig -module _ESL -classic -python -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i + swig -module ESL -classic -python -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i esl_wrap.o: esl_wrap.cpp $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/python/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp Tue Mar 3 17:00:52 2009 @@ -2515,11 +2515,11 @@ #endif /*----------------------------------------------- - @(target):= __ESL.so + @(target):= _ESL.so ------------------------------------------------*/ -#define SWIG_init init__ESL +#define SWIG_init init_ESL -#define SWIG_name "__ESL" +#define SWIG_name "_ESL" #define SWIGVERSION 0x010335 #define SWIG_VERSION SWIGVERSION From brian at freeswitch.org Tue Mar 3 16:06:52 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 18:06:52 -0600 Subject: [Freeswitch-svn] [commit] r12402 - freeswitch/trunk/src Message-ID: Author: brian Date: Tue Mar 3 18:06:52 2009 New Revision: 12402 Log: FSCORE-297 tony fixed this via telephone blind.. its not ME. Modified: freeswitch/trunk/src/switch_core.c freeswitch/trunk/src/switch_time.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Tue Mar 3 18:06:52 2009 @@ -1525,9 +1525,7 @@ if (runtime.memory_pool) { apr_pool_destroy(runtime.memory_pool); - if (switch_test_flag((&runtime), SCF_RESTART)) { - apr_terminate(); - } + apr_terminate(); } return switch_test_flag((&runtime), SCF_RESTART) ? SWITCH_STATUS_RESTART : SWITCH_STATUS_SUCCESS; Modified: freeswitch/trunk/src/switch_time.c ============================================================================== --- freeswitch/trunk/src/switch_time.c (original) +++ freeswitch/trunk/src/switch_time.c Tue Mar 3 18:06:52 2009 @@ -762,7 +762,7 @@ timer_interface->timer_destroy = timer_destroy; /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_NOUNLOAD; + return SWITCH_STATUS_SUCCESS; } SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown) @@ -790,7 +790,7 @@ switch_core_destroy_memory_pool(&TIMEZONES_LIST.pool); } - return SWITCH_STATUS_NOUNLOAD; + return SWITCH_STATUS_SUCCESS; } From anthm at freeswitch.org Tue Mar 3 20:19:34 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 22:19:34 -0600 Subject: [Freeswitch-svn] [commit] r12403 - in freeswitch/trunk/src: . include mod/event_handlers/mod_cdr_csv mod/event_handlers/mod_radius_cdr mod/xml_int/mod_xml_cdr Message-ID: Author: anthm Date: Tue Mar 3 22:19:33 2009 New Revision: 12403 Log: add new state for CDR and leg_delay_start originate var and fix FSCORE-315 Modified: freeswitch/trunk/src/include/switch_module_interfaces.h freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_core_state_machine.c freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/include/switch_module_interfaces.h ============================================================================== --- freeswitch/trunk/src/include/switch_module_interfaces.h (original) +++ freeswitch/trunk/src/include/switch_module_interfaces.h Tue Mar 3 22:19:33 2009 @@ -55,7 +55,8 @@ SWITCH_SHN_ON_CONSUME_MEDIA, SWITCH_SHN_ON_HIBERNATE, SWITCH_SHN_ON_RESET, - SWITCH_SHN_ON_PARK + SWITCH_SHN_ON_PARK, + SWITCH_SHN_ON_REPORTING } switch_state_handler_name_t; struct switch_state_handler_table { @@ -79,6 +80,8 @@ switch_state_handler_t on_reset; /*! executed when the state changes to park */ switch_state_handler_t on_park; + /*! executed when the state changes to reporting */ + switch_state_handler_t on_reporting; void *padding[10]; }; Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Tue Mar 3 22:19:33 2009 @@ -753,17 +753,18 @@ \enum switch_channel_state_t \brief Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are often overridden by specific apps)
-CS_NEW       - Channel is newly created 
-CS_INIT      - Channel has been initilized
-CS_ROUTING   - Channel is looking for an extension to execute
-CS_SOFT_EXECUTE  - Channel is ready to execute from 3rd party control
-CS_EXECUTE   - Channel is executing it's dialplan 
+CS_NEW       - Channel is newly created.
+CS_INIT      - Channel has been initilized.
+CS_ROUTING   - Channel is looking for an extension to execute.
+CS_SOFT_EXECUTE  - Channel is ready to execute from 3rd party control.
+CS_EXECUTE   - Channel is executing it's dialplan.
 CS_EXCHANGE_MEDIA  - Channel is exchanging media with another channel.
 CS_PARK      - Channel is accepting media awaiting commands.
 CS_CONSUME_MEDIA		 - Channel is consuming all media and dropping it.
-CS_HIBERNATE - Channel is in a sleep state
-CS_RESET 	 - Channel is in a reset state
-CS_HANGUP    - Channel is flagged for hangup and ready to end
+CS_HIBERNATE - Channel is in a sleep state.
+CS_RESET 	 - Channel is in a reset state.
+CS_HANGUP    - Channel is flagged for hangup and ready to end.
+CS_HANGUP    - Channel is ready to collect call detail.
 CS_DONE      - Channel is ready to be destroyed and out of the state machine
 
*/ @@ -779,6 +780,7 @@ CS_HIBERNATE, CS_RESET, CS_HANGUP, + CS_REPORTING, CS_DONE, CS_NONE } switch_channel_state_t; @@ -851,6 +853,7 @@ CF_VERBOSE_EVENTS, CF_PAUSE_BUGS, CF_DIVERT_EVENTS, + CF_BLOCK_STATE, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CF_FLAG_MAX } switch_channel_flag_t; Modified: freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c Tue Mar 3 22:19:33 2009 @@ -165,7 +165,7 @@ switch_mutex_unlock(fd->mutex); } -static switch_status_t my_on_hangup(switch_core_session_t *session) +static switch_status_t my_on_reporting(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -286,9 +286,14 @@ /*.on_init */ NULL, /*.on_routing */ NULL, /*.on_execute */ NULL, - /*.on_hangup */ my_on_hangup, + /*.on_hangup */ NULL, /*.on_exchange_media */ NULL, - /*.on_soft_execute */ NULL + /*.on_soft_execute */ NULL, + /*.on_consume_media*/ NULL, + /*.on_hibernate*/ NULL, + /*.on_reset*/ NULL, + /*.on_park*/ NULL, + /*.on_reporting*/ my_on_reporting }; Modified: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c Tue Mar 3 22:19:33 2009 @@ -371,7 +371,7 @@ return (retval); } -static switch_status_t my_on_hangup(switch_core_session_t *session) +static switch_status_t my_on_reporting(switch_core_session_t *session) { switch_xml_t cdr; switch_channel_t *channel = switch_core_session_get_channel(session); @@ -406,7 +406,7 @@ switch_thread_rwlock_rdlock(globals.rwlock); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[mod_radius_cdr] Entering my_on_hangup\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[mod_radius_cdr] Entering my_on_reporting\n"); rad_config = my_radius_init(); @@ -705,9 +705,14 @@ /*.on_init */ NULL, /*.on_routing */ my_on_routing, /*.on_execute */ NULL, - /*.on_hangup */ my_on_hangup, + /*.on_hangup */ NULL, /*.on_exchange_media */ NULL, - /*.on_soft_execute */ NULL + /*.on_soft_execute */ NULL, + /*.on_consume_media*/ NULL, + /*.on_hibernate*/ NULL, + /*.on_reset*/ NULL, + /*.on_park*/ NULL, + /*.on_reporting*/ my_on_reporting }; SWITCH_MODULE_LOAD_FUNCTION(mod_radius_cdr_load) Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c ============================================================================== --- freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c (original) +++ freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c Tue Mar 3 22:19:33 2009 @@ -66,7 +66,7 @@ return size * nitems; } -static switch_status_t my_on_hangup(switch_core_session_t *session) +static switch_status_t my_on_reporting(switch_core_session_t *session) { switch_xml_t cdr; char *xml_text = NULL; @@ -264,9 +264,14 @@ /*.on_init */ NULL, /*.on_routing */ NULL, /*.on_execute */ NULL, - /*.on_hangup */ my_on_hangup, + /*.on_hangup */ NULL, /*.on_exchange_media */ NULL, - /*.on_soft_execute */ NULL + /*.on_soft_execute */ NULL, + /*.on_consume_media*/ NULL, + /*.on_hibernate*/ NULL, + /*.on_reset*/ NULL, + /*.on_park*/ NULL, + /*.on_reporting*/ my_on_reporting }; SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load) Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Tue Mar 3 22:19:33 2009 @@ -767,7 +767,7 @@ return SWITCH_STATUS_FALSE; } - if (!switch_channel_ready(channel)) { + if (switch_channel_down(channel)) { return SWITCH_STATUS_FALSE; } @@ -925,6 +925,7 @@ "CS_HIBERNATE", "CS_RESET", "CS_HANGUP", + "CS_REPORTING", "CS_DONE", NULL }; @@ -1177,6 +1178,16 @@ case CS_HANGUP: switch (state) { + case CS_REPORTING: + case CS_DONE: + ok++; + default: + break; + } + break; + + case CS_REPORTING: + switch (state) { case CS_DONE: ok++; default: @@ -1573,6 +1584,9 @@ const char *file, const char *func, int line, switch_call_cause_t hangup_cause) { switch_assert(channel != NULL); + + switch_channel_clear_flag(channel, CF_BLOCK_STATE); + switch_mutex_lock(channel->state_mutex); if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { @@ -1609,6 +1623,7 @@ } switch_mutex_unlock(channel->state_mutex); + return channel->state; } Modified: freeswitch/trunk/src/switch_core_state_machine.c ============================================================================== --- freeswitch/trunk/src/switch_core_state_machine.c (original) +++ freeswitch/trunk/src/switch_core_state_machine.c Tue Mar 3 22:19:33 2009 @@ -47,6 +47,13 @@ switch_channel_get_name(session->channel), switch_channel_cause2str(switch_channel_get_cause(session->channel))); } +static void switch_core_standard_on_reporting(switch_core_session_t *session) +{ + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard REPORTING, cause: %s\n", + switch_channel_get_name(session->channel), switch_channel_cause2str(switch_channel_get_cause(session->channel))); +} + static void switch_core_standard_on_reset(switch_core_session_t *session) { @@ -373,28 +380,29 @@ switch_mutex_lock(session->mutex); while ((state = switch_channel_get_state(session->channel)) != CS_DONE) { + + switch_channel_wait_for_flag(session->channel, CF_BLOCK_STATE, SWITCH_FALSE, 0, NULL); + midstate = state; - if (state != switch_channel_get_running_state(session->channel) || state == CS_HANGUP) { + if (state != switch_channel_get_running_state(session->channel) || state >= CS_HANGUP) { int index = 0; int proceed = 1; int global_proceed = 1; int do_extra_handlers = 1; - + switch_channel_set_running_state(session->channel, state); switch_channel_clear_flag(session->channel, CF_TRANSFER); switch_channel_clear_flag(session->channel, CF_REDIRECT); switch (state) { - case CS_NEW: /* Just created, Waiting for first instructions */ + case CS_NEW: /* Just created, Waiting for first instructions */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State NEW\n", switch_channel_get_name(session->channel)); break; case CS_DONE: goto done; - case CS_HANGUP: /* Deactivate and end the thread */ + case CS_REPORTING: /* Call Detail */ { const char *var = switch_channel_get_variable(session->channel, SWITCH_PROCESS_CDR_VARIABLE); - const char *hook_var; - switch_core_session_t *use_session = NULL; if (!switch_strlen_zero(var)) { if (!strcasecmp(var, "a_only")) { @@ -410,6 +418,16 @@ } } + STATE_MACRO(reporting, "REPORTING"); + + switch_channel_set_state(session->channel, CS_DONE); + } + goto done; + case CS_HANGUP: /* Deactivate and end the thread */ + { + const char *hook_var; + switch_core_session_t *use_session = NULL; + switch_core_media_bug_remove_all(session); STATE_MACRO(hangup, "HANGUP"); @@ -448,7 +466,8 @@ switch_safe_free(stream.data); } } - goto done; + switch_channel_set_state(session->channel, CS_REPORTING); + break; case CS_INIT: /* Basic setup tasks */ STATE_MACRO(init, "INIT"); break; Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Tue Mar 3 22:19:33 2009 @@ -86,6 +86,7 @@ uint8_t answered; uint32_t per_channel_timelimit_sec; uint32_t per_channel_progress_timelimit_sec; + uint32_t per_channel_delay_start; } originate_status_t; @@ -177,7 +178,7 @@ goto wbreak; } - if (!switch_channel_ready(channel)) { + if (switch_channel_up(channel)) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); goto wbreak; } @@ -228,6 +229,11 @@ time_t elapsed = switch_epoch_time_now(NULL) - start; for (i = 0; i < max; i++) { + if (originate_status[i].peer_channel && originate_status[i].per_channel_delay_start && elapsed > originate_status[i].per_channel_delay_start) { + switch_channel_clear_flag(originate_status[i].peer_channel, CF_BLOCK_STATE); + originate_status[i].per_channel_delay_start = 0; + } + if (originate_status[i].peer_channel && switch_channel_up(originate_status[i].peer_channel)) { if (originate_status[i].per_channel_progress_timelimit_sec && elapsed > originate_status[i].per_channel_progress_timelimit_sec && !( @@ -1493,6 +1499,15 @@ originate_status[i].per_channel_progress_timelimit_sec = (uint32_t) val; } } + + if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_delay_start"))) { + int val = atoi(vvar); + if (val > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Setting leg delay start to %d\n", + switch_channel_get_name(originate_status[0].peer_channel), val); + originate_status[i].per_channel_delay_start = (uint32_t) val; + } + } } if (!table) { @@ -1511,11 +1526,9 @@ } if (!switch_core_session_running(originate_status[i].peer_session)) { - /*if (!(flags & SOF_NOBLOCK)) { - switch_channel_set_state(originate_status[i].peer_channel, CS_ROUTING); - } - } else { - */ + if (originate_status[i].per_channel_delay_start) { + switch_channel_set_flag(originate_status[i].peer_channel, CF_BLOCK_STATE); + } switch_core_session_thread_launch(originate_status[i].peer_session); } } @@ -1842,6 +1855,8 @@ continue; } + switch_channel_clear_flag(originate_status[i].peer_channel, CF_BLOCK_STATE); + if (switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) || switch_channel_test_flag(originate_status[i].peer_channel, CF_REDIRECT) || switch_channel_test_flag(originate_status[i].peer_channel, CF_BRIDGED) || @@ -1867,7 +1882,7 @@ } } } - if (switch_channel_ready(originate_status[i].peer_channel)) { + if (switch_channel_up(originate_status[i].peer_channel)) { if (caller_channel && i == 0) { holding = switch_channel_get_variable(caller_channel, SWITCH_HOLDING_UUID_VARIABLE); holding = switch_core_session_strdup(oglobals.session, holding); From anthm at freeswitch.org Tue Mar 3 20:28:06 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 22:28:06 -0600 Subject: [Freeswitch-svn] [commit] r12404 - freeswitch/trunk/src Message-ID: Author: anthm Date: Tue Mar 3 22:28:06 2009 New Revision: 12404 Log: tweak on last one Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Tue Mar 3 22:28:06 2009 @@ -1855,7 +1855,7 @@ continue; } - switch_channel_clear_flag(originate_status[i].peer_channel, CF_BLOCK_STATE); + //switch_channel_clear_flag(originate_status[i].peer_channel, CF_BLOCK_STATE); if (switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) || switch_channel_test_flag(originate_status[i].peer_channel, CF_REDIRECT) From mikej at freeswitch.org Tue Mar 3 20:35:30 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Mar 2009 22:35:30 -0600 Subject: [Freeswitch-svn] [commit] r12405 - freeswitch/trunk/src/include Message-ID: Author: mikej Date: Tue Mar 3 22:35:30 2009 New Revision: 12405 Log: dox Modified: freeswitch/trunk/src/include/switch_types.h Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Tue Mar 3 22:35:30 2009 @@ -764,7 +764,7 @@ CS_HIBERNATE - Channel is in a sleep state. CS_RESET - Channel is in a reset state. CS_HANGUP - Channel is flagged for hangup and ready to end. -CS_HANGUP - Channel is ready to collect call detail. +CS_REPORTING - Channel is ready to collect call detail. CS_DONE - Channel is ready to be destroyed and out of the state machine */ From mrene at freeswitch.org Wed Mar 4 06:21:52 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 08:21:52 -0600 Subject: [Freeswitch-svn] [commit] r12406 - freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su Message-ID: Author: mrene Date: Wed Mar 4 08:21:51 2009 New Revision: 12406 Log: Revert 12400 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Wed Mar 4 08:21:51 2009 @@ -73,13 +73,8 @@ #include "sofia-sip/su_time.h" #include "sofia-sip/su_uniqueid.h" -#ifdef SU_HAVE_WINSOCK -#define PERTHREAD __declspec(thread) -#else -#define PERTHREAD -#endif /* For random number generator */ -static PERTHREAD int initialized = 0; +static int initialized = 0; static void init(void); static void init_node(void); From brian at freeswitch.org Wed Mar 4 07:26:39 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 09:26:39 -0600 Subject: [Freeswitch-svn] [commit] r12407 - freeswitch/trunk/libs/esl/src Message-ID: Author: brian Date: Wed Mar 4 09:26:39 2009 New Revision: 12407 Log: missed a spot Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Wed Mar 4 09:26:39 2009 @@ -98,7 +98,7 @@ assert(cmd_buf); snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg ? arg : ""); - *(cmd_buf + len) = '\0'; + *(cmd_buf + (len + 1)) = '\0'; if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) { esl_event_t *event; From brian at freeswitch.org Wed Mar 4 08:02:02 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 10:02:02 -0600 Subject: [Freeswitch-svn] [commit] r12408 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Wed Mar 4 10:02:02 2009 New Revision: 12408 Log: add sip_route_uri var to set proxy route Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 4 10:02:02 2009 @@ -1296,7 +1296,7 @@ session_timeout = SOFIA_NAT_SESSION_TIMEOUT; switch_channel_set_variable(channel, "sip_nat_detected", "true"); } - + /* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */ if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) { priv = "name"; @@ -1418,6 +1418,10 @@ route_uri = sofia_overcome_sip_uri_weakness(tech_pvt->session, route_uri, 0, SWITCH_TRUE, NULL); } + if ((val = switch_channel_get_variable(channel, "sip_route_uri"))) { + route_uri = switch_core_session_strdup(session, val); + route = NULL; + } if (route_uri) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Setting proxy route to %s\n", route_uri, switch_channel_get_name(channel)); From anthm at freeswitch.org Wed Mar 4 10:19:30 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 12:19:30 -0600 Subject: [Freeswitch-svn] [commit] r12409 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 4 12:19:30 2009 New Revision: 12409 Log: MODENDP-195 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 4 12:19:30 2009 @@ -1110,6 +1110,7 @@ const char *call_id = NULL; char *route = NULL; char *route_uri = NULL; + char *sendto = NULL; rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER); @@ -1171,7 +1172,7 @@ const char *invite_contact_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_contact_params"); const char *invite_from_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_params"); const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri"); - + if (switch_strlen_zero(tech_pvt->dest)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error!\n"); return SWITCH_STATUS_FALSE; @@ -1422,6 +1423,10 @@ route_uri = switch_core_session_strdup(session, val); route = NULL; } + + if ((val = switch_channel_get_variable(channel, "sip_network_destination"))) { + sendto = switch_core_session_strdup(session, val); + } if (route_uri) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Setting proxy route to %s\n", route_uri, switch_channel_get_name(channel)); @@ -1436,6 +1441,7 @@ TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_IF(route_uri, NUTAG_PROXY(route_uri)), TAG_IF(route, SIPTAG_ROUTE_STR(route)), + TAG_IF(!switch_strlen_zero(sendto), NTATAG_DEFAULT_PROXY(sendto)), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), From mrene at freeswitch.org Wed Mar 4 10:54:43 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 12:54:43 -0600 Subject: [Freeswitch-svn] [commit] r12410 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Wed Mar 4 12:54:43 2009 New Revision: 12410 Log: Move sofia logging to the core logging engine, add change sofia loglevel api and add sofia profile xxx siptrace on-off for TPORT_LOG Modified: freeswitch/trunk/src/include/switch_log.h freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_log.c Modified: freeswitch/trunk/src/include/switch_log.h ============================================================================== --- freeswitch/trunk/src/include/switch_log.h (original) +++ freeswitch/trunk/src/include/switch_log.h Wed Mar 4 12:54:43 2009 @@ -93,12 +93,31 @@ \param level the current log level \param fmt desired format \param ... variable args - \note there are channel macros to supply the first 4 parameters + \note there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...) + \see switch_types.h */ SWITCH_DECLARE(void) switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt, ...) PRINTF_FUNCTION(7, 8); +/*! + \brief Write log data to the logging engine + \param channel the log channel to write to + \param file the current file + \param func the current function + \param line the current line + \param userdata ununsed + \param level the current log level + \param fmt desired format + \param ap variable args + \note there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...) + \see switch_types.h +*/ +SWITCH_DECLARE(void) switch_log_vprintf(_In_ switch_text_channel_t channel, _In_z_ const char *file, + _In_z_ const char *func, _In_ int line, + _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, + const char *fmt, va_list ap); + #endif /*! \brief Shut down the logging engine Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 4 12:54:43 2009 @@ -2076,6 +2076,17 @@ } goto done; } + + if (!strcasecmp(argv[1], "siptrace")) { + if (argc > 2) { + int value = switch_true(argv[2]); + nua_set_params(profile->nua, TPTAG_LOG(value), TAG_END()); + stream->write_function(stream, "%s sip debugging on %s", value ? "Enabled" : "Disabled", profile->name); + } else { + stream->write_function(stream, "Usage: sofia profile siptrace \n"); + } + goto done; + } stream->write_function(stream, "-ERR Unknown command!\n"); @@ -2232,7 +2243,8 @@ "sofia profile [[start|stop|restart|rescan] [reloadxml]|flush_inbound_reg [] [reboot]|[register|unregister] [|all]|killgw |[stun-auto-disable|stun-enabled] [true|false]]\n" "sofia status profile [ reg ] | [ pres ]\n" "sofia status gateway \n" - "sofia loglevel [0-9]\n" "--------------------------------------------------------------------------------\n"; + "sofia loglevel [0-9]\n" + "--------------------------------------------------------------------------------\n"; if (session) { return SWITCH_STATUS_FALSE; @@ -2260,12 +2272,17 @@ } else if (!strcasecmp(argv[0], "xmlstatus")) { func = cmd_xml_status; } else if (!strcasecmp(argv[0], "loglevel")) { - if (argc > 1 && argv[1]) { - int level; - level = atoi(argv[1]); - if (level >= 0 && level <= 9) { - su_log_set_level(NULL, atoi(argv[1])); - stream->write_function(stream, "Sofia-sip log level set to [%d]", level); + if (argc > 2 && argv[2] && switch_is_number(argv[2])) { + int level = atoi(argv[2]); + if (sofia_set_loglevel(argv[1], level) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "Sofia log level for component [%s] has been set to [%d]", argv[1], level); + } else { + stream->write_function(stream, "%s", usage_string); + } + } else if (argc > 1 && argv[1]) { + int level = sofia_get_loglevel(argv[1]); + if (level >= 0) { + stream->write_function(stream, "Sofia-sip loglevel for [%s] is [%d]", argv[1], level); } else { stream->write_function(stream, "%s", usage_string); } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Wed Mar 4 12:54:43 2009 @@ -104,6 +104,7 @@ #include #include #include +#include #include "nua_stack.h" typedef enum { @@ -804,3 +805,23 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); void sofia_sla_handle_sip_r_subscribe(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); + +/* + * Logging control functions + */ + +/*! + * \brief Changes the loglevel of a sofia component + * \param name the sofia component on which to change the loglevel, or "all" to change them all + * \note Valid components are "all", "default" (sofia's default logger), "tport", "iptsec", "nea", "nta", "nth_client", "nth_server", "nua", "soa", "sresolv", "stun" + * \return SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if the component isnt valid, or the level is out of range + */ +switch_status_t sofia_set_loglevel(const char *name, int level); + +/*! + * \brief Gets the loglevel of a sofia component + * \param name the sofia component on which to change the loglevel + * \note Valid components are "default" (sofia's default logger), "tport", "iptsec", "nea", "nta", "nth_client", "nth_server", "nua", "soa", "sresolv", "stun" + * \return the component's loglevel, or -1 if the component isn't valid + */ +int sofia_get_loglevel(const char *name); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 4 12:54:43 2009 @@ -50,6 +50,7 @@ extern su_log_t sresolv_log[]; extern su_log_t stun_log[]; + static void set_variable_sip_param(switch_channel_t *channel, char *header_type, sip_param_t const *params); static void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t *bleg); @@ -931,27 +932,81 @@ static void logger(void *logarg, char const *fmt, va_list ap) { - char *data = NULL; + if (fmt && ap) { + switch_log_vprintf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, fmt, ap); + } else if (fmt && !ap) { + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "%s", fmt); + } +} - if (fmt) { -#ifdef HAVE_VASPRINTF - int ret; - ret = vasprintf(&data, fmt, ap); - if ((ret == -1) || !data) { - return; - } -#else - data = (char *) malloc(2048); - if (data) { - vsnprintf(data, 2048, fmt, ap); - } else { - return; - } -#endif +static switch_status_t sofia_get_logger(const char *name, su_log_t **out) +{ + *out = (void*)0x1; + if (!strcasecmp(name, "tport")) { + *out = tport_log; + } else if (!strcasecmp(name, "iptsec")) { + *out = iptsec_log; + } else if (!strcasecmp(name, "nea")) { + *out = nea_log; + } else if (!strcasecmp(name, "nta")) { + *out = nta_log; + } else if (!strcasecmp(name, "nth_client")) { + *out = nth_client_log; + } else if (!strcasecmp(name, "nth_server")) { + *out = nth_server_log; + } else if (!strcasecmp(name, "nua")) { + *out = nua_log; + } else if (!strcasecmp(name, "sresolv")) { + *out = sresolv_log; + } else if (!strcasecmp(name, "stun")) { + *out = stun_log; + } else if (!strcasecmp(name, "default")){ + *out = NULL; + } + + return (*out != (void*)0x1) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; +} + +switch_status_t sofia_set_loglevel(const char *name, int level) +{ + su_log_t *log = NULL; + switch_status_t status; + + if (level < 0 || level > 9) { + return SWITCH_STATUS_FALSE; + } + + if (!strcasecmp(name, "all")) { + su_log_set_level(NULL, level); + su_log_set_level(tport_log, level); + su_log_set_level(iptsec_log, level); + su_log_set_level(nea_log, level); + su_log_set_level(nta_log, level); + su_log_set_level(nth_client_log, level); + su_log_set_level(nth_server_log, level); + su_log_set_level(nua_log, level); + su_log_set_level(soa_log, level); + su_log_set_level(sresolv_log, level); + su_log_set_level(stun_log, level); + return SWITCH_STATUS_SUCCESS; } - if (data) { - switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char *) "%s", data); - free(data); + + if ((status = sofia_get_logger(name, &log)) == SWITCH_STATUS_SUCCESS) { + su_log_set_level(log, level); + } + + return status; +} + +int sofia_get_loglevel(const char *name) +{ + su_log_t *log = NULL; + switch_status_t status; + + if ((status = sofia_get_logger(name, &log)) == SWITCH_STATUS_SUCCESS && log) { /* default logger is NULL */ + return log->log_level; + } else { + return -1; } } @@ -1718,9 +1773,19 @@ su_deinit(); return SWITCH_STATUS_FALSE; } - - su_log_redirect(NULL, logger, NULL); + + /* Redirect loggers in sofia */ + su_log_redirect(NULL /* default */, logger, NULL); su_log_redirect(tport_log, logger, NULL); + su_log_redirect(iptsec_log, logger, NULL); + su_log_redirect(nea_log, logger, NULL); + su_log_redirect(nta_log, logger, NULL); + su_log_redirect(nth_client_log, logger, NULL); + su_log_redirect(nth_server_log, logger, NULL); + su_log_redirect(nua_log, logger, NULL); + su_log_redirect(soa_log, logger, NULL); + su_log_redirect(sresolv_log, logger, NULL); + su_log_redirect(stun_log, logger, NULL); } if (!switch_strlen_zero(profile_name) && (profile = sofia_glue_find_profile(profile_name))) { Modified: freeswitch/trunk/src/switch_log.c ============================================================================== --- freeswitch/trunk/src/switch_log.c (original) +++ freeswitch/trunk/src/switch_log.c Wed Mar 4 12:54:43 2009 @@ -243,14 +243,23 @@ return NULL; } -#define do_mods (LOG_QUEUE && THREAD_RUNNING) SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *userdata, switch_log_level_t level, const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + switch_log_vprintf(channel, file, func, line, userdata, level, fmt, ap); + va_end(ap); +} + +#define do_mods (LOG_QUEUE && THREAD_RUNNING) +SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const char *file, const char *func, int line, + const char *userdata, switch_log_level_t level, const char *fmt, va_list ap) +{ char *data = NULL; char *new_fmt = NULL; int ret = 0; - va_list ap; FILE *handle; const char *filep = (file ? switch_cut_path(file) : ""); const char *funcp = (func ? func : ""); @@ -265,8 +274,6 @@ switch_assert(level < SWITCH_LOG_INVALID); - va_start(ap, fmt); - handle = switch_core_data_channel(channel); if (channel != SWITCH_CHANNEL_ID_LOG_CLEAN) { @@ -285,7 +292,6 @@ } ret = switch_vasprintf(&data, fmt, ap); - va_end(ap); if (ret == -1) { fprintf(stderr, "Memory Error\n"); From gmaruzz at freeswitch.org Wed Mar 4 11:03:25 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 13:03:25 -0600 Subject: [Freeswitch-svn] [commit] r12411 - freeswitch/trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Mar 4 13:03:25 2009 New Revision: 12411 Log: skypiax: do EARLY MEDIA when requested (mainly by skypeout calls) Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Wed Mar 4 13:03:25 2009 @@ -1241,8 +1241,8 @@ ERRORA("No session???\n", SKYPIAX_P_LOG); } if (channel) { - //switch_channel_mark_pre_answered(channel); - NOTICA("skype_call: REMOTE PARTY EARLY MEDIA, we will pass you the audio, just the code is not yet written :-)\n", SKYPIAX_P_LOG); + switch_channel_mark_pre_answered(channel); + NOTICA("skype_call: REMOTE PARTY EARLY MEDIA\n", SKYPIAX_P_LOG); } else { ERRORA("No channel???\n", SKYPIAX_P_LOG); } Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Wed Mar 4 13:03:25 2009 @@ -270,10 +270,19 @@ remote_party_is_ringing(tech_pvt); } } else if (!strcasecmp(value, "EARLYMEDIA")) { + char msg_to_skype[1024]; tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; tech_pvt->interface_state = SKYPIAX_STATE_DIALING; NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG, id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + start_audio_threads(tech_pvt); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, + tech_pvt->tcp_srv_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + remote_party_is_early_media(tech_pvt); } else if (!strcasecmp(value, "MISSED")) { DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); @@ -344,10 +353,11 @@ if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) || !strcasecmp(tech_pvt->skype_call_id, id)) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_UP; DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA){ + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + tech_pvt->interface_state = SKYPIAX_STATE_UP; sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port); skypiax_signaling_write(tech_pvt, msg_to_skype); @@ -355,6 +365,7 @@ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port); skypiax_signaling_write(tech_pvt, msg_to_skype); + } tech_pvt->skype_callflow = SKYPIAX_STATE_UP; if (!strlen(tech_pvt->session_uuid_str)) { DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); @@ -445,6 +456,7 @@ break; while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { unsigned int fdselect; @@ -595,7 +607,7 @@ if (!running) break; while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS + && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { unsigned int fdselect; int rt; From mrene at freeswitch.org Wed Mar 4 11:21:55 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 13:21:55 -0600 Subject: [Freeswitch-svn] [commit] r12412 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Wed Mar 4 13:21:55 2009 New Revision: 12412 Log: MODENDP-145 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 4 13:21:55 2009 @@ -690,7 +690,6 @@ switch_memory_pool_t *pool; sip_alias_node_t *node; switch_event_t *s_event; - int tportlog = 0; int use_100rel = !sofia_test_pflag(profile, PFLAG_DISABLE_100REL); int use_timer = !sofia_test_pflag(profile, PFLAG_DISABLE_TIMER); const char *supported = NULL; @@ -713,10 +712,6 @@ goto end; } - if (sofia_test_flag(profile, TFLAG_TPORT_LOG)) { - tportlog = 1; - } - supported = switch_core_sprintf(profile->pool, "%s%sprecondition, path, replaces", use_100rel ? "100rel, " : "", use_timer ? "timer, " : "" @@ -736,7 +731,7 @@ TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_NAPTR), NTATAG_USE_NAPTR(0)), NTATAG_DEFAULT_PROXY(profile->outbound_proxy), NTATAG_SERVER_RPORT(profile->rport_level), - TAG_IF(tportlog, TPTAG_LOG(1)), + TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)), TAG_END()); /* Last tag should always finish the sequence */ if (!profile->nua) { @@ -1434,6 +1429,13 @@ char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "debug")) { profile->debug = atoi(val); + } else if (!strcasecmp(var, "sip-trace")) { + if (switch_true(val)) { + sofia_set_flag(profile, TFLAG_TPORT_LOG); + } else { + sofia_clear_flag(profile, TFLAG_TPORT_LOG); + } + nua_set_params(profile->nua, TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)), TAG_END()); } else if (!strcasecmp(var, "auto-rtp-bugs")) { parse_rtp_bugs(profile, val); } else if (!strcasecmp(var, "user-agent-string")) { From gmaruzz at freeswitch.org Wed Mar 4 11:36:02 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 13:36:02 -0600 Subject: [Freeswitch-svn] [commit] r12413 - freeswitch/trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Mar 4 13:36:02 2009 New Revision: 12413 Log: skypiax: better timing on loading/starting module (thanks to Jeff Lenk) Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Wed Mar 4 13:36:02 2009 @@ -942,9 +942,8 @@ NOTICA("WAITING roughly 10/15 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d. NB: on XP will wait for much much more! (on Vista and Linux is OK)\n", SKYPIAX_P_LOG, interface_id); i = 0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 10000) { // 400 x 1000 is 6sec on windows XP but only 0.4 seconds on Vista FIXME - //DEBUGA_SKYPE("interface_id=%d, times=%d\n", SKYPIAX_P_LOG, interface_id, i); - switch_sleep(1000); + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 200) { // 10 seconds? thanks Jeff Lenk + switch_sleep(50000); i++; } if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) { @@ -956,9 +955,8 @@ } i = 0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 60000) { // 4000 * 1000 is 60sec on windows XP but 4seconds on Vista FIXME - //DEBUGA_SKYPE("interface_id=%d, times=%d\n", SKYPIAX_P_LOG, interface_id, i); - switch_sleep(1000); + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 1200) { // 60 seconds? thanks Jeff Lenk + switch_sleep(50000); i++; } if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) { From anthm at freeswitch.org Wed Mar 4 11:45:10 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 13:45:10 -0600 Subject: [Freeswitch-svn] [commit] r12414 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 4 13:45:10 2009 New Revision: 12414 Log: MODENDP-194 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 4 13:45:10 2009 @@ -27,6 +27,7 @@ * Ken Rice, Asteria Solutions Group, Inc * Paul D. Tinsley * Bret McDanel + * Eliot Gable * * * sofia_glue.c -- SOFIA SIP Endpoint (code to tie sofia to freeswitch) @@ -1169,6 +1170,7 @@ const char *screen = "no"; const char *invite_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_params"); const char *invite_to_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_to_params"); + const char *invite_to_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_to_uri"); const char *invite_contact_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_contact_params"); const char *invite_from_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_params"); const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri"); @@ -1260,7 +1262,7 @@ url_str = sofia_overcome_sip_uri_weakness(session, url, tech_pvt->transport, SWITCH_TRUE, invite_params); invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, tech_pvt->transport, SWITCH_FALSE, invite_contact_params); from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, 0, SWITCH_TRUE, invite_from_params); - to_str = sofia_overcome_sip_uri_weakness(session, tech_pvt->dest_to, 0, SWITCH_FALSE, invite_to_params ? invite_to_params : invite_params); + to_str = sofia_overcome_sip_uri_weakness(session, invite_to_uri ? invite_to_uri : tech_pvt->dest_to, 0, SWITCH_FALSE, invite_to_params ? invite_to_params : invite_params); /* @@ -1435,6 +1437,7 @@ nua_invite(tech_pvt->nh, NUTAG_AUTOANSWER(0), NUTAG_SESSION_TIMER(session_timeout), + TAG_IF(!switch_strlen_zero(sendto), NTATAG_DEFAULT_PROXY(sendto)), TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_HEADER_STR(tech_pvt->rpid)), TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)), TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), @@ -3019,7 +3022,9 @@ " server_user VARCHAR(255),\n" " server_host VARCHAR(255),\n" " profile_name VARCHAR(255),\n" - " hostname VARCHAR(255)\n" + " hostname VARCHAR(255),\n" + " network_ip VARCHAR(255),\n" + " network_port VARCHAR(6)\n" ");\n"; @@ -3032,7 +3037,9 @@ " expires INTEGER,\n" " user_agent VARCHAR(255),\n" " profile_name VARCHAR(255),\n" - " hostname VARCHAR(255)\n" + " hostname VARCHAR(255),\n" + " network_ip VARCHAR(255),\n" + " network_port VARCHAR(6)\n" ");\n"; char dialog_sql[] = @@ -3104,6 +3111,8 @@ "create index sr_expires on sip_registrations (expires)", "create index sr_hostname on sip_registrations (hostname)", "create index sr_status on sip_registrations (status)", + "create index sr_network_ip on sip_registrations (network_ip)", + "create index sr_network_port on sip_registrations (network_port)", "create index ss_call_id on sip_subscriptions (call_id)", "create index ss_hostname on sip_subscriptions (hostname)", "create index ss_sip_user on sip_subscriptions (sip_user)", @@ -3136,7 +3145,8 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn); test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' " - "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q'", + "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " + "and network_ip!='-1' and network_port!='-1'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { @@ -3146,7 +3156,7 @@ free(test_sql); - test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname); + test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip!='-1' and network_port!='-1'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL); @@ -3198,7 +3208,8 @@ } test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' " - "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q'", + "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " + "and network_ip!='-1' and network_port!='-1'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql); @@ -3244,6 +3255,8 @@ switch_core_db_exec(profile->master_db, "create index if not exists sr_expires on sip_registrations (expires)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists sr_hostname on sip_registrations (hostname)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists sr_status on sip_registrations (status)", NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists sr_network_ip on sip_registrations (network_ip)", NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists sr_network_port on sip_registrations (network_port)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Wed Mar 4 13:45:10 2009 @@ -29,6 +29,7 @@ * Bret McDanel * Marcel Barbulescu * David Knell <> + * Eliot Gable * * * sofia_ref.c -- SOFIA SIP Endpoint (registration code) @@ -653,6 +654,7 @@ const char *rpid = "unknown"; const char *display = "\"user\""; char network_ip[80]; + char network_port_c[6]; char url_ip[80]; char *register_gateway = NULL; int network_port; @@ -669,6 +671,8 @@ get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr,my_addrinfo->ai_addrlen); network_port = get_port(my_addrinfo->ai_addr); + snprintf(network_port_c, sizeof(network_port_c), "%d", network_port); + snprintf(url_ip, sizeof(url_ip), my_addrinfo->ai_addr->sa_family == AF_INET6 ? "[%s]" : "%s", network_ip); expires = sip->sip_expires; @@ -940,11 +944,11 @@ switch_find_local_ip(guess_ip4, sizeof(guess_ip4), AF_INET); sql = switch_mprintf("insert into sip_registrations " - "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname) " - "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q')", + "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port) " + "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q')", call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host, contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2, - agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname); + agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c); if (sql) { sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); @@ -965,6 +969,8 @@ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", (long) exptime); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-user", from_user); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-host", from_host); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "network-ip", network_ip); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "network-port", network_port_c); switch_event_fire(&s_event); } From mrene at freeswitch.org Wed Mar 4 12:17:36 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:17:36 -0600 Subject: [Freeswitch-svn] [commit] r12415 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Wed Mar 4 14:17:36 2009 New Revision: 12415 Log: Link with su_log_default and avoid dealing with NULL ptrs Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 4 14:17:36 2009 @@ -49,7 +49,7 @@ extern su_log_t soa_log[]; extern su_log_t sresolv_log[]; extern su_log_t stun_log[]; - +extern su_log_t su_log_default[]; static void set_variable_sip_param(switch_channel_t *channel, char *header_type, sip_param_t const *params); @@ -934,45 +934,43 @@ } } -static switch_status_t sofia_get_logger(const char *name, su_log_t **out) +static su_log_t *sofia_get_logger(const char *name) { - *out = (void*)0x1; if (!strcasecmp(name, "tport")) { - *out = tport_log; + return tport_log; } else if (!strcasecmp(name, "iptsec")) { - *out = iptsec_log; + return iptsec_log; } else if (!strcasecmp(name, "nea")) { - *out = nea_log; + return nea_log; } else if (!strcasecmp(name, "nta")) { - *out = nta_log; + return nta_log; } else if (!strcasecmp(name, "nth_client")) { - *out = nth_client_log; + return nth_client_log; } else if (!strcasecmp(name, "nth_server")) { - *out = nth_server_log; + return nth_server_log; } else if (!strcasecmp(name, "nua")) { - *out = nua_log; + return nua_log; } else if (!strcasecmp(name, "sresolv")) { - *out = sresolv_log; + return sresolv_log; } else if (!strcasecmp(name, "stun")) { - *out = stun_log; - } else if (!strcasecmp(name, "default")){ - *out = NULL; + return stun_log; + } else if (!strcasecmp(name, "default")) { + return su_log_default; + } else { + return NULL; } - - return (*out != (void*)0x1) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; } switch_status_t sofia_set_loglevel(const char *name, int level) { su_log_t *log = NULL; - switch_status_t status; if (level < 0 || level > 9) { return SWITCH_STATUS_FALSE; } - + if (!strcasecmp(name, "all")) { - su_log_set_level(NULL, level); + su_log_set_level(su_log_default, level); su_log_set_level(tport_log, level); su_log_set_level(iptsec_log, level); su_log_set_level(nea_log, level); @@ -986,19 +984,20 @@ return SWITCH_STATUS_SUCCESS; } - if ((status = sofia_get_logger(name, &log)) == SWITCH_STATUS_SUCCESS) { - su_log_set_level(log, level); + if (!(log = sofia_get_logger(name))) { + return SWITCH_STATUS_FALSE; } - return status; + su_log_set_level(log, level); + + return SWITCH_STATUS_SUCCESS; } int sofia_get_loglevel(const char *name) { su_log_t *log = NULL; - switch_status_t status; - if ((status = sofia_get_logger(name, &log)) == SWITCH_STATUS_SUCCESS && log) { /* default logger is NULL */ + if ((log = sofia_get_logger(name))) { return log->log_level; } else { return -1; @@ -1777,7 +1776,7 @@ } /* Redirect loggers in sofia */ - su_log_redirect(NULL /* default */, logger, NULL); + su_log_redirect(su_log_default, logger, NULL); su_log_redirect(tport_log, logger, NULL); su_log_redirect(iptsec_log, logger, NULL); su_log_redirect(nea_log, logger, NULL); From gmaruzz at freeswitch.org Wed Mar 4 12:18:37 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:18:37 -0600 Subject: [Freeswitch-svn] [commit] r12416 - in freeswitch/trunk/src/mod/endpoints/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Wed Mar 4 14:18:37 2009 New Revision: 12416 Log: skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c Wed Mar 4 14:18:37 2009 @@ -144,7 +144,7 @@ AST_CLI_DEFINE(skypiax_console_skype, "Sends a Skype command"), AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, "imports entries from cellphone"), AST_CLI_DEFINE(skypiax_console_skypiax, "all things skypiax"), - #endif +#endif }; #else struct ast_cli_entry myclis[] = { @@ -313,15 +313,15 @@ return NULL; } -char interface[256]; -int i; -memset(interface, '\0', sizeof(interface)); - -for (i=0; ivalue, &skypiax_default.capture_boost)) M_UINT("skypiax_dir_entry_extension_prefix", skypiax_default.skypiax_dir_entry_extension_prefix) - M_END(; - ); + M_END(;); } } @@ -1161,8 +1160,7 @@ M_STR("skype_user", tmp->skype_user) M_UINT("skypiax_dir_entry_extension_prefix", tmp->skypiax_dir_entry_extension_prefix) - M_END(; - ); + M_END(;); } if (debug_all) { @@ -1861,7 +1859,9 @@ switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { + if ((session = + switch_core_session_request(skypiax_endpoint_interface, + SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { switch_core_session_add_stream(session, NULL); channel = switch_core_session_get_channel(session); skypiax_tech_init(tech_pvt, session); @@ -1889,6 +1889,7 @@ #endif return 0; } + int remote_party_is_ringing(private_t * p) { if (p->owner) { @@ -1897,6 +1898,7 @@ return 0; } + int remote_party_is_early_media(private_t * p) { if (p->owner) { @@ -1906,7 +1908,6 @@ return 0; } - int outbound_channel_answered(private_t * p) { Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Wed Mar 4 14:18:37 2009 @@ -506,7 +506,9 @@ switch_memory_pool_t ** pool, switch_originate_flag_t flags) { - if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) { + if ((*new_session = + switch_core_session_request(skypiax_endpoint_interface, + SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) { private_t *tech_pvt; switch_channel_t *channel; switch_caller_profile_t *caller_profile; @@ -940,29 +942,43 @@ skypiax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]); - NOTICA("WAITING roughly 10/15 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d. NB: on XP will wait for much much more! (on Vista and Linux is OK)\n", SKYPIAX_P_LOG, interface_id); + NOTICA + ("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n", + SKYPIAX_P_LOG, interface_id); i = 0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 200) { // 10 seconds? thanks Jeff Lenk + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 200) { // 10 seconds! thanks Jeff Lenk switch_sleep(50000); i++; } if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) { - NOTICA("Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting roughly 60/90 seconds for CURRENTUSERHANDLE==%s. NB: on XP will wait for much much more! (on Vista and Linux is OK)\n", SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user); + NOTICA + ("Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting 60 seconds for CURRENTUSERHANDLE==%s\n", + SKYPIAX_P_LOG, interface_id, + globals.SKYPIAX_INTERFACES[interface_id].skype_user); } else { - ERRORA("Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n", SKYPIAX_P_LOG, interface_id); + ERRORA + ("Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n", + SKYPIAX_P_LOG, interface_id); running = 0; return SWITCH_STATUS_FALSE; } i = 0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 1200) { // 60 seconds? thanks Jeff Lenk + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 1200) { // 60 seconds! thanks Jeff Lenk switch_sleep(50000); i++; } if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) { - WARNINGA("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n", SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user); + WARNINGA + ("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n", + SKYPIAX_P_LOG, interface_id, + globals.SKYPIAX_INTERFACES[interface_id].skype_user); } else { - ERRORA("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n", SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user, globals.SKYPIAX_INTERFACES[interface_id].skype_user); + ERRORA + ("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n", + SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user, + interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user, + globals.SKYPIAX_INTERFACES[interface_id].skype_user); running = 0; return SWITCH_STATUS_FALSE; } @@ -1056,7 +1072,7 @@ DEBUGA_SKYPE ("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError()); - globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread=NULL; + globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL; } #else XEvent e; @@ -1075,9 +1091,9 @@ XSync(tech_pvt->SkypiaxHandles.disp, False); #endif } - while (x) {//FIXME 2 seconds? + while (x) { //FIXME 2 seconds? x--; - switch_yield(20000); + switch_yield(20000); } if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) { switch_thread_join(&status, @@ -1164,7 +1180,9 @@ switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { + if ((session = + switch_core_session_request(skypiax_endpoint_interface, + SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { switch_core_session_add_stream(session, NULL); channel = switch_core_session_get_channel(session); skypiax_tech_init(tech_pvt, session); @@ -1221,7 +1239,6 @@ return 0; } - int remote_party_is_early_media(private_t * tech_pvt) { switch_core_session_t *session = NULL; Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Wed Mar 4 14:18:37 2009 @@ -273,17 +273,17 @@ char msg_to_skype[1024]; tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", - SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); - start_audio_threads(tech_pvt); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, - tech_pvt->tcp_srv_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); + NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG, + id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + start_audio_threads(tech_pvt); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, + tech_pvt->tcp_srv_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); - remote_party_is_early_media(tech_pvt); + remote_party_is_early_media(tech_pvt); } else if (!strcasecmp(value, "MISSED")) { DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); } else if (!strcasecmp(value, "FINISHED")) { @@ -355,17 +355,17 @@ || !strcasecmp(tech_pvt->skype_call_id, id)) { strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA){ - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - tech_pvt->interface_state = SKYPIAX_STATE_UP; - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); - start_audio_threads(tech_pvt); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, - tech_pvt->tcp_srv_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); - } + if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + tech_pvt->interface_state = SKYPIAX_STATE_UP; + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + start_audio_threads(tech_pvt); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, + tech_pvt->tcp_srv_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + } tech_pvt->skype_callflow = SKYPIAX_STATE_UP; if (!strlen(tech_pvt->session_uuid_str)) { DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); @@ -456,7 +456,7 @@ break; while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA + || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { unsigned int fdselect; @@ -607,7 +607,8 @@ if (!running) break; while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA + && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { unsigned int fdselect; int rt; @@ -921,8 +922,8 @@ lReturnCode = 0; fIssueDefProc = 0; tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA); - if(!running) - return lReturnCode; + if (!running) + return lReturnCode; switch (uiMessage) { case WM_CREATE: tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams; @@ -1141,7 +1142,7 @@ xerror = err->error_code; ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror); - running=0; + running = 0; return 0; /* ignore the error */ } @@ -1248,7 +1249,7 @@ if (status != Success || format_ret != 32 || nitems_ret != 1) { SkypiaxHandles->skype_win = (Window) - 1; DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); - running =0; + running = 0; SkypiaxHandles->api_connected = 0; return 0; } From mikej at freeswitch.org Wed Mar 4 12:35:51 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:35:51 -0600 Subject: [Freeswitch-svn] [commit] r12417 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Wed Mar 4 14:35:51 2009 New Revision: 12417 Log: Wed Mar 4 12:22:20 CST 2009 Pekka Pessi * nta: fix timer N3 Ignore-this: 4018f3a32723692153389c2109b72296 Try UDP instead of TCP if TCP server does not respond quick enough. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:35:51 2009 @@ -1 +1 @@ -Tue Mar 3 16:01:38 CST 2009 +Wed Mar 4 14:35:03 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Wed Mar 4 14:35:51 2009 @@ -7021,7 +7021,7 @@ static void outgoing_send_via(nta_outgoing_t *orq, tport_t *tp); static void outgoing_send(nta_outgoing_t *orq, int retransmit); static void outgoing_try_tcp_instead(nta_outgoing_t *orq); -static void outgoing_try_udp_instead(nta_outgoing_t *orq); +static void outgoing_try_udp_instead(nta_outgoing_t *orq, int timeout); static void outgoing_tport_error(nta_agent_t *agent, nta_outgoing_t *orq, tport_t *tp, msg_t *msg, int error); static void outgoing_print_tport_error(nta_outgoing_t *orq, @@ -8024,7 +8024,7 @@ } else if (err == ECONNREFUSED && orq->orq_try_tcp_instead) { if (su_casematch(tpn->tpn_proto, "tcp") && msg_size(msg) <= 65535) { - outgoing_try_udp_instead(orq); + outgoing_try_udp_instead(orq, 0); continue; } } @@ -8138,7 +8138,7 @@ } static void -outgoing_try_udp_instead(nta_outgoing_t *orq) +outgoing_try_udp_instead(nta_outgoing_t *orq, int timeout) { tport_t *tp; tp_name_t tpn[1]; @@ -8160,8 +8160,9 @@ sip_fragment_clear(sip->sip_via->v_common); sip->sip_via->v_protocol = sip_transport_udp; - SU_DEBUG_5(("nta: %s (%u) TCP refused, trying UDP\n", - orq->orq_method_name, orq->orq_cseq->cs_seq)); + SU_DEBUG_5(("nta: %s (%u) TCP %s, trying UDP\n", + orq->orq_method_name, orq->orq_cseq->cs_seq, + timeout ? "times out" : "refused")); orq->orq_tpn->tpn_proto = "udp"; tport_decref(&orq->orq_tport); @@ -8196,7 +8197,7 @@ if (su_casematch(tpn->tpn_proto, "tcp") && msg_size(msg) <= 65535) { outgoing_print_tport_error(orq, 5, "retrying with UDP after ", tpn, msg, error); - outgoing_try_udp_instead(orq); + outgoing_try_udp_instead(orq, 0); outgoing_remove(orq); /* Reset state - this is no resend! */ outgoing_send(orq, 0); /* Send */ return; @@ -8601,8 +8602,11 @@ * but no connection is established within SIP T4 */ SU_DEBUG_5(("nta: timer %s fired, %s %s (%u)\n", "N3", - "try UDP instead", orq->orq_method_name, orq->orq_cseq->cs_seq)); - outgoing_try_udp_instead(orq); + "try UDP instead for", + orq->orq_method_name, orq->orq_cseq->cs_seq)); + outgoing_try_udp_instead(orq, 1); + outgoing_remove(orq); /* Reset state - this is no resend! */ + outgoing_send(orq, 0); /* Send */ } continue; } From mikej at freeswitch.org Wed Mar 4 12:37:00 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:37:00 -0600 Subject: [Freeswitch-svn] [commit] r12418 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Wed Mar 4 14:37:00 2009 New Revision: 12418 Log: Wed Mar 4 12:28:12 CST 2009 Pekka Pessi * run_test_nta: run tests without named if named refuses to start Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:37:00 2009 @@ -1 +1 @@ -Wed Mar 4 14:35:03 CST 2009 +Wed Mar 4 14:36:40 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta Wed Mar 4 14:37:00 2009 @@ -205,7 +205,7 @@ exit $exit else echo "$0: cannot start named (check apparmor/selinux)" - exit 77 + exec ipv6=$ipv6 $VALGRIND ./test_nta "$@" fi else # not having BIND and portbind From mikej at freeswitch.org Wed Mar 4 12:37:55 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:37:55 -0600 Subject: [Freeswitch-svn] [commit] r12419 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Wed Mar 4 14:37:55 2009 New Revision: 12419 Log: Wed Mar 4 12:31:05 CST 2009 Pekka Pessi * s2_dns_domain(): more flexible selection of transports by URI parameters Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:37:55 2009 @@ -1 +1 @@ -Wed Mar 4 14:36:40 CST 2009 +Wed Mar 4 14:37:34 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c Wed Mar 4 14:37:55 2009 @@ -97,14 +97,16 @@ } /* Set filter function */ -void s2_dns_set_filter(int (*filter)(void *data, size_t len, void *userdata), +void +s2_dns_set_filter(int (*filter)(void *data, size_t len, void *userdata), void *userdata) { s2dns.filter = filter; s2dns.userdata = userdata; } -void s2_dns_teardown(void) +void +s2_dns_teardown(void) { struct s2_dns_response *r, *next; su_root_deregister(s2dns.root, s2dns.reg), s2dns.reg = -1; @@ -442,7 +444,7 @@ } } -/** Set up DNS domain */ +/** Set up records for SIP server */ void s2_dns_domain(char const *domain, int use_naptr, /* char *prefix, int priority, url_t const *uri, */ ...) @@ -471,7 +473,9 @@ char *services = NULL; priority = va_arg(va, int); - uri = va_arg(va, url_t *); assert(uri); + uri = va_arg(va, url_t *); + if (uri == NULL) + continue; if (uri->url_type == url_sips) { services = "SIPS+D2T"; @@ -499,7 +503,9 @@ for (;(prefix = va_arg(va, char *));) { priority = va_arg(va, int); - uri = va_arg(va, url_t *); assert(uri); + uri = va_arg(va, url_t *); + if (uri == NULL) + continue; make_server(server, prefix, domain); @@ -518,7 +524,9 @@ va_copy(va, va0); for (;(prefix = va_arg(va, char *));) { priority = va_arg(va, int); - uri = va_arg(va, url_t *); assert(uri); + uri = va_arg(va, url_t *); + if (uri == NULL) + continue; make_server(server, prefix, domain); @@ -539,7 +547,8 @@ va_copy(va, va0); for (;(prefix = va_arg(va, char *));) { (void)va_arg(va, int); - (void)va_arg(va, url_t *); + if (va_arg(va, url_t *) == NULL) + continue; memset(m, 0, sizeof m); make_server(server, prefix, domain); From mikej at freeswitch.org Wed Mar 4 12:39:24 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:39:24 -0600 Subject: [Freeswitch-svn] [commit] r12420 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Wed Mar 4 14:39:24 2009 New Revision: 12420 Log: Wed Mar 4 12:29:06 CST 2009 Pekka Pessi * s2sip: removed nua dependency Ignore-this: d32f68be34d4628129aff2afad3c99f1 Fixed CK_FORK=no case. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:39:24 2009 @@ -1 +1 @@ -Wed Mar 4 14:37:34 CST 2009 +Wed Mar 4 14:38:54 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2sip.c Wed Mar 4 14:39:24 2009 @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -269,8 +270,8 @@ struct message * s2_sip_respond_to(struct message *m, struct dialog *d, - int status, char const *phrase, - tag_type_t tag, tag_value_t value, ...) + int status, char const *phrase, + tag_type_t tag, tag_value_t value, ...) { ta_list ta; msg_t *reply; @@ -395,9 +396,9 @@ */ int s2_sip_request_to(struct dialog *d, - sip_method_t method, char const *name, - tport_t *tport, - tag_type_t tag, tag_value_t value, ...) + sip_method_t method, char const *name, + tport_t *tport, + tag_type_t tag, tag_value_t value, ...) { ta_list ta; tagi_t const *tags; @@ -811,5 +812,7 @@ if (s2sip) { tport_destroy(s2sip->master), s2sip->master = NULL; su_root_destroy(s2sip->root), s2sip->root = NULL; + su_home_unref(s2sip->home); + s2sip = NULL; } } Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2sip.h Wed Mar 4 14:39:24 2009 @@ -27,7 +27,6 @@ #include #include #include -#include #include "s2util.h" From mikej at freeswitch.org Wed Mar 4 12:40:07 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:40:07 -0600 Subject: [Freeswitch-svn] [commit] r12421 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Wed Mar 4 14:40:06 2009 New Revision: 12421 Log: Wed Mar 4 12:31:26 CST 2009 Pekka Pessi * s2base: removed s2_setup_logs() Ignore-this: ea4848902b3be9c966b4f7e114f2a5b6 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2base.c freeswitch/trunk/libs/sofia-sip/s2check/s2base.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:40:06 2009 @@ -1 +1 @@ -Wed Mar 4 14:38:54 CST 2009 +Wed Mar 4 14:39:41 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2base.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2base.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.c Wed Mar 4 14:40:06 2009 @@ -135,26 +135,6 @@ printf("%s - starting %s/%s-%s\n", s2_tester, _s2_suite, _s2_case, title); } -SOFIAPUBVAR su_log_t nua_log[]; -SOFIAPUBVAR su_log_t soa_log[]; -SOFIAPUBVAR su_log_t nea_log[]; -SOFIAPUBVAR su_log_t nta_log[]; -SOFIAPUBVAR su_log_t tport_log[]; -SOFIAPUBVAR su_log_t su_log_default[]; - -void -s2_setup_logs(int level) -{ - assert(s2base); - - su_log_soft_set_level(nua_log, level); - su_log_soft_set_level(soa_log, level); - su_log_soft_set_level(su_log_default, level); - su_log_soft_set_level(nea_log, level); - su_log_soft_set_level(nta_log, level); - su_log_soft_set_level(tport_log, level); -} - void s2_step(void) { su_root_step(s2base->root, 10); Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2base.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2base.h (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.h Wed Mar 4 14:40:06 2009 @@ -40,8 +40,6 @@ void s2_suite(char const *label); void s2_setup(char const *label); -void s2_setup_logs(int level); - void s2_step(void); void s2_case(char const *tag, From mikej at freeswitch.org Wed Mar 4 12:41:38 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:41:38 -0600 Subject: [Freeswitch-svn] [commit] r12422 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Wed Mar 4 14:41:38 2009 New Revision: 12422 Log: Wed Mar 4 12:37:47 CST 2009 Pekka Pessi * nua: moved contents of test_s2.[hc] to check_nua.[hc] Ignore-this: f53929b29092e2d62e661fc40397492e Removed: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:41:38 2009 @@ -1 +1 @@ -Wed Mar 4 14:39:41 CST 2009 +Wed Mar 4 14:40:17 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am Wed Mar 4 14:41:38 2009 @@ -49,8 +49,7 @@ check_nua_SOURCES = check_nua.c check_nua.h \ check_session.c check_register.c \ - check_etsi.c check_simple.c \ - test_s2.h test_s2.c + check_etsi.c check_simple.c check_nua_LDADD = $(nua_libs) ${top_builddir}/s2check/libs2.a \ @CHECK_LIBS@ Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c Wed Mar 4 14:41:38 2009 @@ -34,9 +34,9 @@ #include "config.h" -#include "check_nua.h" +#undef NDEBUG -#include "test_s2.h" +#include "check_nua.h" #include #include Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Wed Mar 4 14:41:38 2009 @@ -22,7 +22,7 @@ * */ -/**@CFILE check2_sofia.c +/**@CFILE check_nua.c * * @brief Check-driven tester for Sofia SIP User Agent library * @@ -33,16 +33,26 @@ #include "config.h" -#include "test_s2.h" +#undef NDEBUG + #include "check_nua.h" +#include "s2dns.h" + +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include - -#if HAVE_FNMATCH_H -#include -#endif +#include +#include +#include static void usage(int exitcode) { @@ -111,3 +121,384 @@ exit(failed ? EXIT_FAILURE : EXIT_SUCCESS); } + +/* ---------------------------------------------------------------------- */ + +/* -- Globals -------------------------------------------------------------- */ + +struct s2nua *s2; + +int s2_nua_thread = 0; + +unsigned s2_default_registration_duration = 3600; + +char const s2_auth_digest_str[] = + "Digest realm=\"s2test\", " + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + "qop=\"auth\", " + "algorithm=\"MD5\""; + +char const s2_auth_credentials[] = "Digest:\"s2test\":abc:abc"; + +char const s2_auth2_digest_str[] = + "Digest realm=\"s2test2\", " + "nonce=\"fb0c093dcd98b7102dd2f0e8b11d0f600b\", " + "qop=\"auth\", " + "algorithm=\"MD5\""; + +char const s2_auth2_credentials[] = "Digest:\"s2test2\":abc:abc"; + +char const s2_auth3_digest_str[] = + "Digest realm=\"s2test3\", " + "nonce=\"e8b11d0f600bfb0c093dcd98b7102dd2f0\", " + "qop=\"auth-int\", " + "algorithm=\"MD5-sess\""; + +char const s2_auth3_credentials[] = "Digest:\"s2test3\":abc:abc"; + +/* -- NUA events -------------------------------------------------------- */ + +struct event *s2_remove_event(struct event *e) +{ + if ((*e->prev = e->next)) + e->next->prev = e->prev; + + e->prev = NULL, e->next = NULL; + + return e; +} + +void s2_free_event(struct event *e) +{ + if (e) { + if (e->prev) { + if ((*e->prev = e->next)) + e->next->prev = e->prev; + } + nua_destroy_event(e->event); + nua_handle_unref(e->nh); + free(e); + } +} + +void s2_flush_events(void) +{ + while (s2->events) { + s2_free_event(s2->events); + } +} + +struct event *s2_next_event(void) +{ + for (;;) { + if (s2->events) + return s2_remove_event(s2->events); + + su_root_step(s2base->root, 100); + } +} + +struct event *s2_wait_for_event(nua_event_t event, int status) +{ + struct event *e; + + for (;;) { + for (e = s2->events; e; e = e->next) { + if (event != nua_i_none && event != e->data->e_event) + continue; + if (status && e->data->e_status != status) + continue; + return s2_remove_event(e); + } + + su_root_step(s2base->root, 100); + } +} + +int s2_check_event(nua_event_t event, int status) +{ + struct event *e = s2_wait_for_event(event, status); + s2_free_event(e); + return e != NULL; +} + +int s2_check_callstate(enum nua_callstate state) +{ + int retval = 0; + tagi_t const *tagi; + struct event *e; + + e = s2_wait_for_event(nua_i_state, 0); + if (e) { + tagi = tl_find(e->data->e_tags, nutag_callstate); + if (tagi) { + retval = (tag_value_t)state == tagi->t_value; + } + } + s2_free_event(e); + return retval; +} + +int s2_check_substate(struct event *e, enum nua_substate state) +{ + int retval = 0; + tagi_t const *tagi; + + tagi = tl_find(e->data->e_tags, nutag_substate); + if (tagi) { + retval = (tag_value_t)state == tagi->t_value; + } + + return retval; +} + +static void +s2_nua_callback(nua_event_t event, + int status, char const *phrase, + nua_t *nua, nua_magic_t *_t, + nua_handle_t *nh, nua_hmagic_t *hmagic, + sip_t const *sip, + tagi_t tags[]) +{ + struct event *e, **prev; + + if (event == nua_i_active || event == nua_i_terminated) + return; + + e = calloc(1, sizeof *e); + nua_save_event(nua, e->event); + e->nh = nua_handle_ref(nh); + e->data = nua_event_data(e->event); + + for (prev = &s2->events; *prev; prev = &(*prev)->next) + ; + + *prev = e, e->prev = prev; +} + + +/* ====================================================================== */ + +SOFIAPUBVAR su_log_t nua_log[]; +SOFIAPUBVAR su_log_t soa_log[]; +SOFIAPUBVAR su_log_t nea_log[]; +SOFIAPUBVAR su_log_t nta_log[]; +SOFIAPUBVAR su_log_t tport_log[]; +SOFIAPUBVAR su_log_t su_log_default[]; + +void +s2_setup_logs(int level) +{ + su_log_soft_set_level(nua_log, level); + su_log_soft_set_level(soa_log, level); + su_log_soft_set_level(su_log_default, level); + su_log_soft_set_level(nea_log, level); + su_log_soft_set_level(nta_log, level); + su_log_soft_set_level(tport_log, level); +} + +nua_t *s2_nua_setup(char const *label, + tag_type_t tag, tag_value_t value, ...) +{ + ta_list ta; + + s2_setup(label); + + s2 = su_home_new(sizeof *s2); + + s2_dns_setup(s2base->root); + + s2_setup_logs(0); + s2_sip_setup("example.org", NULL, TAG_END()); + assert(s2sip->contact); + + s2_dns_domain("example.org", 1, + "s2", 1, s2sip->udp.contact->m_url, + "s2", 1, s2sip->tcp.contact->m_url, + NULL); + + /* enable/disable multithreading */ + su_root_threading(s2base->root, s2_nua_thread); + + ta_start(ta, tag, value); + s2->nua = + nua_create(s2base->root, + s2_nua_callback, + s2, + SIPTAG_FROM_STR("Alice "), + /* NUTAG_PROXY((url_string_t *)s2sip->contact->m_url), */ + /* Use internal DNS server */ + NUTAG_PROXY("sip:example.org"), + /* Force sresolv to use localhost and s2dns as DNS server */ +#if HAVE_WIN32 + SRESTAG_RESOLV_CONF("NUL"), +#else + SRESTAG_RESOLV_CONF("/dev/null"), +#endif + ta_tags(ta)); + ta_end(ta); + + return s2->nua; +} + +void +s2_nua_fast_forward(unsigned long seconds, + su_root_t *steproot) +{ + s2_fast_forward(seconds, NULL); + + if (s2_nua_thread) + /* Wake up nua thread */ + nua_handle_by_call_id(s2->nua, NULL); + + if (steproot) + su_root_step(steproot, 0); +} + +void s2_nua_teardown(void) +{ + if (s2) { + struct s2nua *zap = s2; + nua_destroy(s2->nua), s2->nua = NULL; + s2 = NULL; + su_home_unref(zap->home); + } + + s2_dns_teardown(); + s2_sip_teardown(); + s2_teardown(); + +} + +/* ====================================================================== */ + +/** Register NUA user. + * + *
+ *  A                  B
+ *  |-----REGISTER---->|
+ *  |<-----200 OK------|
+ *  |                  |
+ * 
+ */ +void s2_register_setup(void) +{ + nua_handle_t *nh; + struct message *m; + + assert(s2 && s2->nua); + assert(!s2->registration->nh); + + nh = nua_handle(s2->nua, NULL, TAG_END()); + + nua_register(nh, TAG_END()); + + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); + assert(m); + + s2_save_register(m); + + s2_sip_respond_to(m, NULL, + SIP_200_OK, + SIPTAG_CONTACT(s2->registration->contact), + TAG_END()); + s2_sip_free_message(m); + + assert(s2->registration->contact != NULL); + s2_check_event(nua_r_register, 200); + + s2->registration->nh = nh; +} + +/** Un-register NUA user. + * + *
+ *  A                  B
+ *  |-----REGISTER---->|
+ *  |<-----200 OK------|
+ *  |                  |
+ * 
+ */ +void s2_register_teardown(void) +{ + if (s2 && s2->registration->nh) { + nua_handle_t *nh = s2->registration->nh; + struct message *m; + + nua_unregister(nh, TAG_END()); + + m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); assert(m); + s2_save_register(m); + s2_sip_respond_to(m, NULL, + SIP_200_OK, + SIPTAG_CONTACT(s2->registration->contact), + TAG_END()); + assert(s2->registration->contact == NULL); + + s2_sip_free_message(m); + + s2_check_event(nua_r_unregister, 200); + + nua_handle_destroy(nh); + s2->registration->nh = NULL; + } +} + +int +s2_save_register(struct message *rm) +{ + sip_contact_t *contact, *m, **m_prev; + sip_expires_t const *ex; + sip_date_t const *date; + sip_time_t now = rm->when.tv_sec, expires; + + msg_header_free_all(s2->home, (msg_header_t *)s2->registration->aor); + msg_header_free_all(s2->home, (msg_header_t *)s2->registration->contact); + tport_unref(s2->registration->tport); + + s2->registration->aor = NULL; + s2->registration->contact = NULL; + s2->registration->tport = NULL; + + if (rm == NULL) + return 0; + + assert(rm && rm->sip && rm->sip->sip_request); + assert(rm->sip->sip_request->rq_method == sip_method_register); + + ex = rm->sip->sip_expires; + date = rm->sip->sip_date; + + contact = sip_contact_dup(s2->home, rm->sip->sip_contact); + + for (m_prev = &contact; *m_prev;) { + m = *m_prev; + + expires = sip_contact_expires(m, ex, date, + s2_default_registration_duration, + now); + if (expires) { + char *p = su_sprintf(s2->home, "expires=%lu", (unsigned long)expires); + msg_header_add_param(s2->home, m->m_common, p); + m_prev = &m->m_next; + } + else { + *m_prev = m->m_next; + m->m_next = NULL; + msg_header_free(s2->home, (msg_header_t *)m); + } + } + + if (contact == NULL) + return 0; + + s2->registration->aor = sip_to_dup(s2->home, rm->sip->sip_to); + s2->registration->contact = contact; + s2->registration->tport = tport_ref(rm->tport); + + s2sip->sut.aor = s2->registration->aor; + s2sip->sut.contact = s2->registration->contact; + s2sip->sut.tport = s2->registration->tport; + + return 0; +} Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h Wed Mar 4 14:41:38 2009 @@ -1,5 +1,104 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + #ifndef CHECK_NUA_H +#include +#include +#include +#include +#include + +#include "s2base.h" +#include "s2util.h" +#include "s2sip.h" + +struct s2nua +{ + su_home_t home[1]; + + nua_t *nua; + + int shutdown; + + struct event { + struct event *next, **prev; + nua_saved_event_t event[1]; + nua_handle_t *nh; + nua_event_data_t const *data; + su_time_t when; + } *events; + + struct { + nua_handle_t *nh; + sip_to_t *aor; + sip_contact_t *contact; + tport_t *tport; + } registration[1]; +}; + +extern unsigned s2_default_registration_duration; +extern char const s2_auth_digest_str[]; +extern char const s2_auth_credentials[]; + +extern char const s2_auth2_digest_str[]; +extern char const s2_auth2_credentials[]; + +extern char const s2_auth3_digest_str[]; +extern char const s2_auth3_credentials[]; + +extern int s2_nua_thread; + +extern struct s2nua *s2; + +void s2_setup_logs(int level); + +struct event *s2_remove_event(struct event *); +void s2_free_event(struct event *); +void s2_flush_events(void); + +struct event *s2_next_event(void); +struct event *s2_wait_for_event(nua_event_t event, int status); +int s2_check_event(nua_event_t event, int status); +int s2_check_callstate(enum nua_callstate state); +int s2_check_substate(struct event *e, enum nua_substate state); + +#define SIP_METHOD_UNKNOWN sip_method_unknown, NULL + +void s2_flush_all(void); + +nua_t *s2_nua_setup(char const *label, tag_type_t tag, tag_value_t value, ...); + +void s2_nua_teardown(void); + +void s2_nua_fast_forward(unsigned long seconds, + su_root_t *steproot); + +int s2_save_register(struct message *m); + +void s2_register_setup(void); +void s2_register_teardown(void); + #include void check_session_cases(Suite *suite, int threading); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c Wed Mar 4 14:41:38 2009 @@ -33,9 +33,9 @@ #include "config.h" -#include "check_nua.h" +#undef NDEBUG -#include "test_s2.h" +#include "check_nua.h" #include #include Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Wed Mar 4 14:41:38 2009 @@ -33,9 +33,9 @@ #include "config.h" -#include "check_nua.h" +#undef NDEBUG -#include "test_s2.h" +#include "check_nua.h" #include #include @@ -1131,7 +1131,11 @@ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(cancel); - s2_register_teardown(); + /* emulate network gone bad below + zap registration handle here + so that s2_register_teardown() does not hang + */ + s2->registration->nh = NULL; nua_set_params(s2->nua, NUTAG_SHUTDOWN_EVENTS(1), TAG_END()); fail_unless(s2_check_event(nua_r_set_params, 200)); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Wed Mar 4 14:41:38 2009 @@ -33,9 +33,9 @@ #include "config.h" -#include "check_nua.h" +#undef NDEBUG -#include "test_s2.h" +#include "check_nua.h" #include #include From mikej at freeswitch.org Wed Mar 4 12:42:54 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 14:42:54 -0600 Subject: [Freeswitch-svn] [commit] r12423 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua-glib/su-glib m4 Message-ID: Author: mikej Date: Wed Mar 4 14:42:53 2009 New Revision: 12423 Log: Wed Mar 4 13:12:17 CST 2009 Pekka Pessi * configure: SOFIA_GLIB_CFLAGS added Ignore-this: f70baad5a9f61b6fcbe44ec1aa4c2c22 GLib behaves badly with -Wall -Werror. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4 Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Wed Mar 4 14:42:53 2009 @@ -1 +1 @@ -Wed Mar 4 14:40:17 CST 2009 +Wed Mar 4 14:42:12 CST 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am Wed Mar 4 14:42:53 2009 @@ -12,7 +12,8 @@ S_BASE = $(top_srcdir)/libsofia-sip-ua B_BASE = $(top_builddir)/libsofia-sip-ua -INCLUDES = -I$(S_BASE)/su -I$(B_BASE)/su $(GLIB_CFLAGS) +INCLUDES = -I$(S_BASE)/su -I$(B_BASE)/su $(GLIB_CFLAGS) \ + $(SOFIA_GLIB_CFLAGS) # ---------------------------------------------------------------------- # Build targets Modified: freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4 ============================================================================== --- freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4 (original) +++ freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4 Wed Mar 4 14:42:53 2009 @@ -122,6 +122,7 @@ AC_SUBST([CWFLAG], [$ac_cv_cwflag]) AC_ARG_VAR([SOFIA_CFLAGS], [CFLAGS not used during configure]) +AC_ARG_VAR([SOFIA_GLIB_CFLAGS], [Extra CFLAGS for libsofia-sip-ua-glib]) SAC_COVERAGE ]) From anthm at freeswitch.org Wed Mar 4 13:22:41 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 15:22:41 -0600 Subject: [Freeswitch-svn] [commit] r12424 - freeswitch/trunk/src/mod/applications/mod_dptools Message-ID: Author: anthm Date: Wed Mar 4 15:22:41 2009 New Revision: 12424 Log: make yes no on and off all work in privacy app Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Wed Mar 4 15:22:41 2009 @@ -968,17 +968,18 @@ } else { switch_set_flag(caller_profile, SWITCH_CPF_SCREEN); - if (!strcasecmp(data, "no")) { - switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME); - switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER); - } else if (!strcasecmp(data, "yes")) { - switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER); - } else if (!strcasecmp(data, "full")) { + + if (!strcasecmp(data, "full")) { switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER); } else if (!strcasecmp(data, "name")) { switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME); } else if (!strcasecmp(data, "number")) { switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER); + } else if (switch_true(data)) { + switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER); + } else if (switch_false(data)) { + switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME); + switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n"); } From mrene at freeswitch.org Wed Mar 4 14:22:30 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 16:22:30 -0600 Subject: [Freeswitch-svn] [commit] r12425 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Wed Mar 4 16:22:30 2009 New Revision: 12425 Log: Missed one doc line Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 4 16:22:30 2009 @@ -2240,7 +2240,7 @@ const char *usage_string = "USAGE:\n" "--------------------------------------------------------------------------------\n" "sofia help\n" - "sofia profile [[start|stop|restart|rescan] [reloadxml]|flush_inbound_reg [] [reboot]|[register|unregister] [|all]|killgw |[stun-auto-disable|stun-enabled] [true|false]]\n" + "sofia profile [[start|stop|restart|rescan] [reloadxml]|flush_inbound_reg [] [reboot]|[register|unregister] [|all]|killgw |[stun-auto-disable|stun-enabled] [true|false]]|siptrace [on|off]\n" "sofia status profile [ reg ] | [ pres ]\n" "sofia status gateway \n" "sofia loglevel [0-9]\n" From anthm at freeswitch.org Wed Mar 4 14:39:47 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 16:39:47 -0600 Subject: [Freeswitch-svn] [commit] r12426 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 4 16:39:47 2009 New Revision: 12426 Log: FSCORE-310 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Wed Mar 4 16:39:47 2009 @@ -57,10 +57,14 @@ sofia_profile_t *profile = NULL; char *ffrom = NULL; nua_handle_t *msg_nh; - char *contact; + char *contact = NULL; char *dup = NULL; switch_status_t status = SWITCH_STATUS_FALSE; const char *ct = "text/html"; + char *clean_to = NULL; + char *route = NULL; + char *route_uri = NULL; + char *ptr = NULL; if (!to) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n"); @@ -135,19 +139,55 @@ switch_safe_free(fp); } - status = SWITCH_STATUS_SUCCESS; contact = sofia_glue_get_url_from_contact(buf, 1); + + if (contact && (ptr = strstr(contact, ";fs_path=")) && (route = strdup(ptr + 9))) { + char *p; + for (p = route; p && *p ; p++) { + if (*p == '>' || *p == ';') { + *p = '\0'; + break; + } + } + switch_url_decode(route); + route_uri = strdup(route); + if ((p = strchr(route_uri, ','))) { + while ((p > route_uri) && *(p-1) == ' ') { + p--; + } + if (*p) { + *p = '\0'; + } + } + *ptr++ = '>'; + *ptr++ = '\0'; + } + + clean_to = strdup(buf); + if ((ptr = strstr(clean_to, ";fs_path="))) { + *ptr++ = '>'; + *ptr++ = '\0'; + } + + /* sofia_glue is running sofia_overcome_sip_uri_weakness we do not, not sure if it matters */ + + status = SWITCH_STATUS_SUCCESS; /* if this cries, add contact here too, change the 1 to 0 and omit the safe_free */ - msg_nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(buf), - SIPTAG_CONTACT_STR(profile->url), TAG_END()); + msg_nh = nua_handle(profile->nua, NULL, TAG_IF(route, NUTAG_PROXY(route_uri)), TAG_IF(route, SIPTAG_ROUTE_STR(route)), + SIPTAG_FROM_STR(from), NUTAG_URL(contact), + SIPTAG_TO_STR(clean_to), SIPTAG_CONTACT_STR(profile->url), + TAG_END()); - switch_safe_free(contact); nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), TAG_END()); end: + switch_safe_free(contact); + switch_safe_free(route); + switch_safe_free(route_uri); switch_safe_free(ffrom); switch_safe_free(dup); + switch_safe_free(clean_to); if (profile) { switch_thread_rwlock_unlock(profile->rwlock); From anthm at freeswitch.org Wed Mar 4 15:03:25 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 17:03:25 -0600 Subject: [Freeswitch-svn] [commit] r12427 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 4 17:03:25 2009 New Revision: 12427 Log: add configurable outgoing cid types Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 4 17:03:25 2009 @@ -2579,6 +2579,7 @@ switch_ivr_transfer_variable(session, nsession, "sip_video_fmtp"); switch_ivr_transfer_variable(session, nsession, "sip-force-contact"); switch_ivr_transfer_variable(session, nsession, "sip_sticky_contact"); + switch_ivr_transfer_variable(session, nsession, "sip_cid_type"); if (switch_core_session_compare(session, nsession)) { /* It's another sofia channel! so lets cache what they use as a pt for telephone event so Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Wed Mar 4 17:03:25 2009 @@ -105,6 +105,7 @@ #include #include #include +#include #include "nua_stack.h" typedef enum { @@ -371,6 +372,12 @@ MEDIA_OPT_BYPASS_AFTER_ATT_XFER = (1 << 1) } sofia_media_options_t; +typedef enum { + CID_TYPE_RPID, + CID_TYPE_PID, + CID_TYPE_NONE +} sofia_cid_type_t; + struct sofia_profile { int debug; char *name; @@ -403,6 +410,7 @@ char *record_template; char *presence_hosts; char *challenge_realm; + sofia_cid_type_t cid_type; sofia_dtmf_t dtmf_type; int auto_restart; int sip_port; @@ -493,6 +501,9 @@ char *contact_url; char *from_str; char *rpid; + char *asserted_id; + char *preferred_id; + char *privacy; char *gateway_from_str; char *rm_encoding; char *iananame; @@ -825,3 +836,4 @@ * \return the component's loglevel, or -1 if the component isn't valid */ int sofia_get_loglevel(const char *name); +sofia_cid_type_t sofia_cid_name2type(const char *name); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 4 17:03:25 2009 @@ -1453,6 +1453,8 @@ if (switch_true(val)) { profile->rport_level = 2; } + } else if (!strcasecmp(var, "caller-id-type")) { + profile->cid_type = sofia_cid_name2type(val); } else if (!strcasecmp(var, "record-template")) { profile->record_template = switch_core_strdup(profile->pool, val);; } else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media"))) { @@ -1920,6 +1922,8 @@ profile->dbname = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "presence-hosts")) { profile->presence_hosts = switch_core_strdup(profile->pool, val); + } else if (!strcasecmp(var, "caller-id-type")) { + profile->cid_type = sofia_cid_name2type(val); } else if (!strcasecmp(var, "record-template")) { profile->record_template = switch_core_strdup(profile->pool, val); } else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media")) && switch_true(val)) { @@ -4195,6 +4199,7 @@ if (!switch_strlen_zero(rpid->rpid_display)) { displayname = rpid->rpid_display; } + switch_channel_set_variable(channel, "sip_cid_type", "rpid"); } if ((passerted = sip_p_asserted_identity(sip))) { @@ -4204,6 +4209,7 @@ if (!switch_strlen_zero(passerted->paid_display)) { displayname = passerted->paid_display; } + switch_channel_set_variable(channel, "sip_cid_type", "pid"); } if ((ppreferred = sip_p_preferred_identity(sip))) { @@ -4213,6 +4219,7 @@ if (!switch_strlen_zero(ppreferred->ppid_display)) { displayname = ppreferred->ppid_display; } + switch_channel_set_variable(channel, "sip_cid_type", "pid"); } if (from_user) { Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 4 17:03:25 2009 @@ -36,6 +36,7 @@ #include "mod_sofia.h" #include + void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options) { char buf[2048]; @@ -1112,6 +1113,7 @@ char *route = NULL; char *route_uri = NULL; char *sendto = NULL; + sofia_cid_type_t cid_type = tech_pvt->profile->cid_type; rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER); @@ -1300,23 +1302,54 @@ switch_channel_set_variable(channel, "sip_nat_detected", "true"); } - /* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */ - if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) { - priv = "name"; + if ((val = switch_channel_get_variable(channel, "sip_cid_type"))) { + cid_type = sofia_cid_name2type(val); + } + switch (cid_type) { + case CID_TYPE_PID: + if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) { + tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"", + tech_pvt->caller_profile->caller_id_name, + tech_pvt->caller_profile->caller_id_number, + rpid_domain); + } else { + tech_pvt->preferred_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"", + tech_pvt->caller_profile->caller_id_name, + tech_pvt->caller_profile->caller_id_number, + rpid_domain); + } + if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) { - priv = "full"; + tech_pvt->privacy = "id"; + } else { + tech_pvt->privacy = "none"; } - } else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) { - priv = "full"; - } - if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) { - screen = "yes"; + break; + case CID_TYPE_RPID: + { + if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) { + priv = "name"; + if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) { + priv = "full"; + } + } else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) { + priv = "full"; + } + + if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) { + screen = "yes"; + } + + tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "\"%s\";party=calling;screen=%s;privacy=%s", + tech_pvt->caller_profile->caller_id_name, + tech_pvt->caller_profile->caller_id_number, rpid_domain, screen, priv); + } + break; + default: + break; } - tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "Remote-Party-ID: \"%s\";party=calling;screen=%s;privacy=%s", - tech_pvt->caller_profile->caller_id_name, - tech_pvt->caller_profile->caller_id_number, rpid_domain, screen, priv); switch_safe_free(d_url); @@ -1438,7 +1471,10 @@ NUTAG_AUTOANSWER(0), NUTAG_SESSION_TIMER(session_timeout), TAG_IF(!switch_strlen_zero(sendto), NTATAG_DEFAULT_PROXY(sendto)), - TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_HEADER_STR(tech_pvt->rpid)), + TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)), + TAG_IF(!switch_strlen_zero(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)), + TAG_IF(!switch_strlen_zero(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)), + TAG_IF(!switch_strlen_zero(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->preferred_id)), TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)), TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), @@ -3557,6 +3593,20 @@ return uri; } +sofia_cid_type_t sofia_cid_name2type(const char *name) +{ + if (!strcasecmp(name, "rpid")) { + return CID_TYPE_RPID; + } + + if (!strcasecmp(name, "pid")) { + return CID_TYPE_PID; + } + + return CID_TYPE_NONE; + +} + /* For Emacs: * Local Variables: From anthm at freeswitch.org Wed Mar 4 15:15:13 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 17:15:13 -0600 Subject: [Freeswitch-svn] [commit] r12428 - freeswitch/trunk/src Message-ID: Author: anthm Date: Wed Mar 4 17:15:13 2009 New Revision: 12428 Log: FSCORE-320 Modified: freeswitch/trunk/src/switch_core_media_bug.c Modified: freeswitch/trunk/src/switch_core_media_bug.c ============================================================================== --- freeswitch/trunk/src/switch_core_media_bug.c (original) +++ freeswitch/trunk/src/switch_core_media_bug.c Wed Mar 4 17:15:13 2009 @@ -122,7 +122,7 @@ return SWITCH_STATUS_FALSE; } - if (!(bug->raw_read_buffer && bug->raw_write_buffer)) { + if (!(bug->raw_read_buffer && (bug->raw_write_buffer || !switch_test_flag(bug, SMBF_WRITE_STREAM)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%sBuffer Error\n", switch_channel_get_name(bug->session->channel)); } @@ -136,13 +136,15 @@ } switch_mutex_unlock(bug->read_mutex); - switch_mutex_lock(bug->write_mutex); - datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer, bug->data, bytes); - if (datalen < bytes) { - memset(((unsigned char *)bug->data) + datalen, 0, bytes - datalen); - datalen = bytes; + if (switch_test_flag(bug, SMBF_WRITE_STREAM)) { + switch_mutex_lock(bug->write_mutex); + datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer, bug->data, bytes); + if (datalen < bytes) { + memset(((unsigned char *)bug->data) + datalen, 0, bytes - datalen); + datalen = bytes; + } + switch_mutex_unlock(bug->write_mutex); } - switch_mutex_unlock(bug->write_mutex); tp = bug->tmp; dp = (int16_t *) bug->data; From anthm at freeswitch.org Wed Mar 4 17:15:17 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 19:15:17 -0600 Subject: [Freeswitch-svn] [commit] r12429 - in freeswitch/trunk/src: . include Message-ID: Author: anthm Date: Wed Mar 4 19:15:17 2009 New Revision: 12429 Log: FSCORE-319 Modified: freeswitch/trunk/src/include/switch_core.h freeswitch/trunk/src/switch_core_media_bug.c freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/include/switch_core.h ============================================================================== --- freeswitch/trunk/src/include/switch_core.h (original) +++ freeswitch/trunk/src/include/switch_core.h Wed Mar 4 19:15:17 2009 @@ -196,6 +196,8 @@ */ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(_In_ switch_core_session_t *session, _Inout_ switch_media_bug_t **bug); +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_callback(switch_core_session_t *session, switch_media_bug_callback_t callback); + /*! \brief Close and destroy a media bug \param bug bug to remove Modified: freeswitch/trunk/src/switch_core_media_bug.c ============================================================================== --- freeswitch/trunk/src/switch_core_media_bug.c (original) +++ freeswitch/trunk/src/switch_core_media_bug.c Wed Mar 4 19:15:17 2009 @@ -370,15 +370,7 @@ if (session->bugs) { switch_thread_rwlock_wrlock(session->bug_rwlock); for (bp = session->bugs; bp; bp = bp->next) { - if (bp->thread_id && bp->thread_id != switch_thread_self()) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BUG is thread locked skipping.\n"); - continue; - } - - if (!bp->ready) { - continue; - } - if (bp == *bug) { + if ((!bp->thread_id || bp->thread_id == switch_thread_self()) && bp->ready && bp == *bug) { if (last) { last->next = bp->next; } else { @@ -386,6 +378,7 @@ } break; } + last = bp; } switch_thread_rwlock_unlock(session->bug_rwlock); @@ -402,6 +395,44 @@ return status; } + +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_callback(switch_core_session_t *session, switch_media_bug_callback_t callback) +{ + switch_media_bug_t *cur = NULL, *bp = NULL, *last = NULL; + int total = 0; + + if (session->bugs) { + switch_thread_rwlock_wrlock(session->bug_rwlock); + + bp = session->bugs; + while (bp) { + cur = bp; + bp = bp->next; + + if ((!cur->thread_id || cur->thread_id == switch_thread_self()) && cur->ready && cur->callback == callback) { + if (last) { + last->next = cur->next; + } else { + session->bugs = cur->next; + } + if (switch_core_media_bug_close(&cur) == SWITCH_STATUS_SUCCESS) { + total++; + } + } else { + last = cur; + } + } + switch_thread_rwlock_unlock(session->bug_rwlock); + } + + if (!session->bugs && session->bug_codec.implementation) { + switch_core_codec_destroy(&session->bug_codec); + memset(&session->bug_codec, 0, sizeof(session->bug_codec)); + } + + return total ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; +} + /* For Emacs: * Local Variables: * mode:c Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Wed Mar 4 19:15:17 2009 @@ -424,23 +424,31 @@ return SWITCH_STATUS_SUCCESS; } +struct record_helper { + char *file; + switch_file_handle_t *fh; +}; + static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) { - switch_file_handle_t *fh = (switch_file_handle_t *) user_data; + switch_core_session_t *session = switch_core_media_bug_get_session(bug); + switch_channel_t *channel = switch_core_session_get_channel(session); + struct record_helper *rh = (struct record_helper *) user_data; switch (type) { case SWITCH_ABC_TYPE_INIT: break; case SWITCH_ABC_TYPE_CLOSE: - if (fh) { - switch_core_file_close(fh); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stop recording file %s\n", rh->file); + switch_channel_set_private(channel, rh->file, NULL); + + if (rh->fh) { + switch_core_file_close(rh->fh); } break; case SWITCH_ABC_TYPE_READ_PING: - if (fh) { + if (rh->fh) { switch_size_t len; - switch_core_session_t *session = switch_core_media_bug_get_session(bug); - switch_channel_t *channel = switch_core_session_get_channel(session); uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; switch_frame_t frame = { 0 }; @@ -455,7 +463,7 @@ if (doit) { len = (switch_size_t) frame.datalen / 2; - switch_core_file_write(fh, data, &len); + switch_core_file_write(rh->fh, data, &len); } } } @@ -473,8 +481,9 @@ switch_media_bug_t *bug; switch_channel_t *channel = switch_core_session_get_channel(session); - if ((bug = switch_channel_get_private(channel, file))) { - switch_channel_set_private(channel, file, NULL); + if (!strcasecmp(file, "all")) { + return switch_core_media_bug_remove_callback(session, record_callback); + } else if ((bug = switch_channel_get_private(channel, file))) { switch_core_media_bug_remove(session, &bug); return SWITCH_STATUS_SUCCESS; } @@ -838,6 +847,8 @@ switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING; uint8_t channels; switch_codec_implementation_t read_impl = {0}; + struct record_helper *rh = NULL; + switch_core_session_get_read_impl(session, &read_impl); if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) { @@ -925,7 +936,11 @@ to = switch_epoch_time_now(NULL) + limit; } - if ((status = switch_core_media_bug_add(session, record_callback, fh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) { + rh = switch_core_session_alloc(session, sizeof(*rh)); + rh->fh = fh; + rh->file = switch_core_session_strdup(session, file); + + if ((status = switch_core_media_bug_add(session, record_callback, rh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding media bug for file %s\n", file); switch_core_file_close(fh); return status; From mrene at freeswitch.org Wed Mar 4 18:46:00 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 20:46:00 -0600 Subject: [Freeswitch-svn] [commit] r12430 - freeswitch/trunk/src Message-ID: Author: mrene Date: Wed Mar 4 20:46:00 2009 New Revision: 12430 Log: Don't crash in the odd event you have no modules loaded Modified: freeswitch/trunk/src/switch_loadable_module.c Modified: freeswitch/trunk/src/switch_loadable_module.c ============================================================================== --- freeswitch/trunk/src/switch_loadable_module.c (original) +++ freeswitch/trunk/src/switch_loadable_module.c Wed Mar 4 20:46:00 2009 @@ -1266,6 +1266,10 @@ switch_hash_index_t *hi; void *val; switch_loadable_module_t *module; + + if (!loadable_modules.module_hash) { + return; + } for (hi = switch_hash_first(NULL, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); From anthm at freeswitch.org Wed Mar 4 19:08:15 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 21:08:15 -0600 Subject: [Freeswitch-svn] [commit] r12431 - freeswitch/trunk/src Message-ID: Author: anthm Date: Wed Mar 4 21:08:15 2009 New Revision: 12431 Log: MODLANG-100 Modified: freeswitch/trunk/src/switch_ivr_play_say.c Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Wed Mar 4 21:08:15 2009 @@ -1446,7 +1446,7 @@ switch_input_args_t args = { 0 }; switch_status_t status = SWITCH_STATUS_SUCCESS; char terminator; - size_t len; + size_t len = 0; switch_assert(session); @@ -1510,6 +1510,10 @@ end: + if (max_digits == 1 && len == 1 && valid_terminators && strchr(valid_terminators, *digit_buffer)) { + *digit_buffer = '\0'; + } + if (var_name && !switch_strlen_zero(digit_buffer)) { switch_channel_set_variable(channel, var_name, digit_buffer); } From mrene at freeswitch.org Wed Mar 4 19:09:31 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 21:09:31 -0600 Subject: [Freeswitch-svn] [commit] r12432 - in freeswitch/trunk: . src src/include Message-ID: Author: mrene Date: Wed Mar 4 21:09:31 2009 New Revision: 12432 Log: Generic config parser Added: freeswitch/trunk/src/include/switch_xml_config.h freeswitch/trunk/src/switch_xml_config.c Modified: freeswitch/trunk/Makefile.am Modified: freeswitch/trunk/Makefile.am ============================================================================== --- freeswitch/trunk/Makefile.am (original) +++ freeswitch/trunk/Makefile.am Wed Mar 4 21:09:31 2009 @@ -91,6 +91,7 @@ src/switch_stun.c\ src/switch_log.c\ src/switch_xml.c\ +src/switch_xml_config.c\ src/switch_config.c\ src/switch_time.c\ libs/stfu/stfu.c\ @@ -132,6 +133,7 @@ src/include/switch_stun.h\ src/include/switch_log.h\ src/include/switch_xml.h\ +src/include/switch_xml_config.h\ src/include/switch_cpp.h\ libs/libteletone/src/libteletone_detect.h\ libs/libteletone/src/libteletone_generate.h\ Added: freeswitch/trunk/src/include/switch_xml_config.h ============================================================================== --- (empty file) +++ freeswitch/trunk/src/include/switch_xml_config.h Wed Mar 4 21:09:31 2009 @@ -0,0 +1,85 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2009, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Mathieu Rene + * + * + * switch_xml_config.h - Generic configuration parser + * + */ + +#ifndef SWITCH_XML_CONFIG_H +#define SWITCH_XML_CONFIG_H + +/*! \brief Type of value to parse */ +typedef enum { + SWITCH_CONFIG_INT, /*< (ptr=int* default=int data=NULL) Integer */ + SWITCH_CONFIG_STRING, /*< (ptr=[char* or char ** (for alloc)] default=char* data=switch_xml_config_string_options_t*) Zero-terminated C-string */ + SWITCH_CONFIG_YESNO, /*< (ptr=switch_bool_t* default=switch_bool_t data=NULL) Yes and no */ + SWITCH_CONFIG_CUSTOM, /*< (ptr= default= data=switch_xml_config_callback_t) Custom, get value through function pointer */ + SWITCH_CONFIG_ENUM, /*< (ptr=int* default=int data=switch_xml_config_enum_item_t*) */ + SWITCH_CONFIG_FLAG, /*< (ptr=int32_t* default=switch_bool_t data=int (flag index) */ + SWITCH_CONFIG_FLAGARRAY,/*< (ptr=int8_t* default=switch_bool_t data=int (flag index) */ + + /* No more past that line */ + SWITCH_CONFIG_LAST +} switch_xml_config_type_t; + +typedef struct { + char *key; /*< The item's key or NULL if this is the last one in the list */ + int value; /*< The item's value */ +} switch_xml_config_enum_item_t; + +typedef struct { + switch_memory_pool_t *pool; /*< If set, the string will be allocated on the pool (unless the length param is > 0, then you misread this file)*/ + int length; /*< Length of the char array, or 0 if memory has to be allocated dynamically*/ +} switch_xml_config_string_options_t; + +/*! + * \brief A configuration instruction read by switch_xml_config_parse +*/ +typedef struct { + char *key; /*< The key of the element, or NULL to indicate the end of the list */ + switch_xml_config_type_t type; /*< The type of variable */ + switch_bool_t reloadable; /*< True if the var can be changed on reload */ + void *ptr; /*< Ptr to the var to be changed */ + void *defaultvalue; /*< Default value */ + void *data; /*< Custom data (depending on the type) */ +} switch_xml_config_item_t; + +typedef switch_status_t (*switch_xml_config_callback_t)(switch_xml_config_item_t *data); + +#define SWITCH_CONFIG_END { NULL, SWITCH_CONFIG_LAST, 0, NULL ,NULL, NULL } + +/*! + * \brief Parses all the xml elements, following a ruleset defined by an array of switch_xml_config_item_t + * \param xml The first element of the list to parse + * \param reload true to skip all non-reloadable options + * \param options instrutions on how to parse the elements + * \see switch_xml_config_item_t + */ +switch_status_t switch_xml_config_parse(switch_xml_t xml, int reload, switch_xml_config_item_t *options); + +#endif /* !defined(SWITCH_XML_CONFIG_H) */ \ No newline at end of file Added: freeswitch/trunk/src/switch_xml_config.c ============================================================================== --- (empty file) +++ freeswitch/trunk/src/switch_xml_config.c Wed Mar 4 21:09:31 2009 @@ -0,0 +1,221 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2009, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Mathieu Rene + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Mathieu Rene + * + * + * switch_xml_config.c - Generic configuration parser + * + */ + +#include +#include + +switch_status_t switch_xml_config_parse(switch_xml_t xml, int reload, switch_xml_config_item_t *options) +{ + switch_xml_config_item_t *item; + switch_xml_t node; + switch_event_t *event; + switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS); + switch_assert(event); + int file_count = 0, + + for (node = xml; node; node = node->next) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, switch_xml_attr_soft(node, "name"); switch_xml_attr_soft(node, "value")); + } + + for (item = options; item->key; item++) { + const char *value = switch_event_get_header(event, item->key); + + if (reload && !item->reloadable) { + continue; + } + + switch(item->type) { + case SWITCH_CONFIG_INT: + { + int *dest = (int*)item->ptr; + if (value) { + if (switch_is_number(value)) { + *dest = atoi(value); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s]\n", + value, item->key); + *dest = (int)item->defaultvalue; + } + } else { + *dest = (int)item->defaultvalue; + } + } + break; + case SWITCH_CONFIG_STRING: + { + switch_xml_config_string_options_t *options = (switch_xml_config_string_options_t*)item->data; + if (options->length > 0) { + /* We have a preallocated buffer */ + char *dest = (char*)item->ptr; + strncpy(dest, value, options->length); + } else { + char **dest = (char**)item->ptr; + if (options->pool) { + *dest = switch_core_strdup(options->pool, value); + } else { + switch_safe_free(*dest); /* Free the destination if its not NULL */ + *dest = strdup(value); + } + } + } + break; + case SWITCH_CONFIG_YESNO: + { + switch_bool_t *dest = (switch_bool_t*)item->ptr; + if (value) { + *dest = !!switch_true(value); + } else { + *dest = (switch_bool_t)item->defaultvalue; + } + } + break; + case SWITCH_CONFIG_CUSTOM: + { + switch_xml_config_callback_t callback = (switch_xml_config_callback_t)item->data; + callback(item); + } + break; + case SWITCH_CONFIG_ENUM: + { + switch_xml_config_enum_item_t *options = (switch_xml_config_enum_item_t*)item->data; + int *dest = (int*)item->ptr; + + if (value) { + for (;options->key; options++) { + if (!strcasecmp(value, options->key)) { + *dest = options->value; + break; + } + } + + if (!options->key) { /* if (!found) */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s]\n", + value, item->key); + } + } else { + *dest = (int)item->defaultvalue; + } + } + break; + case SWITCH_CONFIG_FLAG: + { + int32_t *dest = (int32_t*)item->ptr; + int index = (int)item->data; + if (value) { + if (switch_true(value)) { + *dest |= (1 << index); + } else { + *dest &= ~(1 << index); + } + } else { + if ((switch_bool_t)item->defaultvalue) { + *dest |= (1 << index); + } else { + *dest &= ~(1 << index); + } + } + } + break; + case SWITCH_CONFIG_FLAGARRAY: + { + int8_t *dest = (int8_t*)item->ptr; + int index = (int)item->data; + if (value) { + dest[index] = !!switch_true(value); + } else { + dest[index] = (int8_t)((int32_t)item->defaultvalue); + } + } + break; + case SWITCH_CONFIG_LAST: + break; + } + } + + switch_event_destroy(&event); + + return SWITCH_STATUS_SUCCESS; +} + + +#if 0 +typedef enum { + MYENUM_TEST1 = 1, + MYENUM_TEST2 = 2, + MYENUM_TEST3 = 3 +} myenum_t; + +static struct { + char *stringalloc; + char string[50]; + myenum_t enumm; + int yesno; + +} globals; + + +void switch_xml_config_test() +{ + char *cf = "test.conf"; + switch_xml_t cfg, xml, settings; + switch_xml_config_string_options_t config_opt_stringalloc = { NULL, 0 }; /* No pool, use strdup */ + switch_xml_config_string_options_t config_opt_buffer = { NULL, 50 }; /* No pool, use current var as buffer */ + switch_xml_config_enum_item_t enumm_options[] = { + { "test1", MYENUM_TEST1 }, + { "test2", MYENUM_TEST2 }, + { "test3", MYENUM_TEST3 }, + { NULL, 0 } + }; + + switch_xml_config_item_t instructions[] = { + { "db_host", SWITCH_CONFIG_STRING, SWITCH_TRUE, &globals.stringalloc, "blah", &config_opt_stringalloc }, + { "db_user", SWITCH_CONFIG_STRING, SWITCH_TRUE, globals.string, "dflt", &config_opt_buffer }, + { "test", SWITCH_CONFIG_ENUM, SWITCH_FALSE, &globals.enumm, (void*)MYENUM_TEST1, enumm_options }, + SWITCH_CONFIG_END + }; + + if (!(xml = switch_xml_open_cfg("blaster.conf", &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open %s\n", cf); + return; + } + + if ((settings = switch_xml_child(cfg, "settings"))) { + if (switch_xml_config_parse(switch_xml_child(settings, "param"), 0, instructions) == SWITCH_STATUS_SUCCESS) { + printf("YAY!\n"); + } + } + + if (cfg) { + switch_xml_free(cfg); + } +} +#endif From brian at freeswitch.org Wed Mar 4 19:12:28 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 21:12:28 -0600 Subject: [Freeswitch-svn] [commit] r12433 - in freeswitch/trunk/src: . include Message-ID: Author: brian Date: Wed Mar 4 21:12:28 2009 New Revision: 12433 Log: me being all OCD Modified: freeswitch/trunk/src/include/switch_xml_config.h freeswitch/trunk/src/switch_xml_config.c Modified: freeswitch/trunk/src/include/switch_xml_config.h ============================================================================== --- freeswitch/trunk/src/include/switch_xml_config.h (original) +++ freeswitch/trunk/src/include/switch_xml_config.h Wed Mar 4 21:12:28 2009 @@ -82,4 +82,15 @@ */ switch_status_t switch_xml_config_parse(switch_xml_t xml, int reload, switch_xml_config_item_t *options); -#endif /* !defined(SWITCH_XML_CONFIG_H) */ \ No newline at end of file +#endif /* !defined(SWITCH_XML_CONFIG_H) */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ Modified: freeswitch/trunk/src/switch_xml_config.c ============================================================================== --- freeswitch/trunk/src/switch_xml_config.c (original) +++ freeswitch/trunk/src/switch_xml_config.c Wed Mar 4 21:12:28 2009 @@ -219,3 +219,14 @@ } } #endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ From mrene at freeswitch.org Wed Mar 4 19:24:29 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 21:24:29 -0600 Subject: [Freeswitch-svn] [commit] r12434 - in freeswitch/trunk/src: . include Message-ID: Author: mrene Date: Wed Mar 4 21:24:29 2009 New Revision: 12434 Log: Immediate Post-Commit Omission Finding Syndrome Modified: freeswitch/trunk/src/include/switch.h freeswitch/trunk/src/switch_xml_config.c Modified: freeswitch/trunk/src/include/switch.h ============================================================================== --- freeswitch/trunk/src/include/switch.h (original) +++ freeswitch/trunk/src/include/switch.h Wed Mar 4 21:24:29 2009 @@ -115,6 +115,7 @@ #include "switch_rtp.h" #include "switch_log.h" #include "switch_xml.h" +#include "switch_xml_config.h" #include "switch_core_event_hook.h" #include "switch_scheduler.h" #include "switch_config.h" Modified: freeswitch/trunk/src/switch_xml_config.c ============================================================================== --- freeswitch/trunk/src/switch_xml_config.c (original) +++ freeswitch/trunk/src/switch_xml_config.c Wed Mar 4 21:24:29 2009 @@ -30,7 +30,6 @@ * */ -#include #include switch_status_t switch_xml_config_parse(switch_xml_t xml, int reload, switch_xml_config_item_t *options) From mrene at freeswitch.org Wed Mar 4 19:30:48 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 21:30:48 -0600 Subject: [Freeswitch-svn] [commit] r12435 - freeswitch/trunk/src Message-ID: Author: mrene Date: Wed Mar 4 21:30:48 2009 New Revision: 12435 Log: oops Modified: freeswitch/trunk/src/switch_xml_config.c Modified: freeswitch/trunk/src/switch_xml_config.c ============================================================================== --- freeswitch/trunk/src/switch_xml_config.c (original) +++ freeswitch/trunk/src/switch_xml_config.c Wed Mar 4 21:30:48 2009 @@ -39,10 +39,11 @@ switch_event_t *event; switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(event); - int file_count = 0, + int file_count = 0, matched_count = 0; for (node = xml; node; node = node->next) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, switch_xml_attr_soft(node, "name"); switch_xml_attr_soft(node, "value")); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, switch_xml_attr_soft(node, "name"), switch_xml_attr_soft(node, "value")); + file_count++; } for (item = options; item->key; item++) { @@ -98,10 +99,13 @@ } break; case SWITCH_CONFIG_CUSTOM: +#if 0 { + switch_xml_config_callback_t callback = (switch_xml_config_callback_t)item->data; callback(item); } +#endif break; case SWITCH_CONFIG_ENUM: { @@ -160,6 +164,10 @@ } } + if (file_count > matched_count) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Config file had %d params but only %d were valid\n", file_count, matched_count); + } + switch_event_destroy(&event); return SWITCH_STATUS_SUCCESS; From brian at freeswitch.org Wed Mar 4 20:04:41 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Mar 2009 22:04:41 -0600 Subject: [Freeswitch-svn] [commit] r12436 - freeswitch/trunk/src Message-ID: Author: brian Date: Wed Mar 4 22:04:41 2009 New Revision: 12436 Log: wanna talk about OCD Modified: freeswitch/trunk/src/switch_xml.c Modified: freeswitch/trunk/src/switch_xml.c ============================================================================== --- freeswitch/trunk/src/switch_xml.c (original) +++ freeswitch/trunk/src/switch_xml.c Wed Mar 4 22:04:41 2009 @@ -73,27 +73,27 @@ } glob_t; /* Believed to have been introduced in 1003.2-1992 */ -#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ -#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ -#define GLOB_ERR 0x0004 /* Return on error. */ -#define GLOB_MARK 0x0008 /* Append / to matching directories. */ +#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ +#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ +#define GLOB_ERR 0x0004 /* Return on error. */ +#define GLOB_MARK 0x0008 /* Append / to matching directories. */ #define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ -#define GLOB_NOSORT 0x0020 /* Don't sort. */ +#define GLOB_NOSORT 0x0020 /* Don't sort. */ /* Error values returned by glob(3) */ #define GLOB_NOSPACE (-1) /* Malloc call failed. */ #define GLOB_ABORTED (-2) /* Unignored error. */ #define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */ -#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */ +#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */ #define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ #define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ #define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ -#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ -#define GLOB_LIMIT 0x1000 /* limit number of returned paths */ +#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ +#define GLOB_LIMIT 0x1000 /* limit number of returned paths */ int glob(const char *, int, int (*)(const char *, int), glob_t *); -void globfree(glob_t *); +void globfree(glob_t *); #endif #undef HAVE_MMAP @@ -104,29 +104,29 @@ #endif #endif -#define SWITCH_XML_WS "\t\r\n " // whitespace -#define SWITCH_XML_ERRL 128 // maximum error string length +#define SWITCH_XML_WS "\t\r\n " /* whitespace */ +#define SWITCH_XML_ERRL 128 /* maximum error string length */ static int preprocess(const char *cwd, const char *file, int write_fd, int rlevel); typedef struct switch_xml_root *switch_xml_root_t; -struct switch_xml_root { // additional data for the root tag - struct switch_xml xml; // is a super-struct built on top of switch_xml struct - switch_xml_t cur; // current xml tree insertion point - char *m; // original xml string - switch_size_t len; // length of allocated memory for mmap +struct switch_xml_root { /* additional data for the root tag */ + struct switch_xml xml; /* is a super-struct built on top of switch_xml struct */ + switch_xml_t cur; /* current xml tree insertion point */ + char *m; /* original xml string */ + switch_size_t len; /* length of allocated memory for mmap */ uint8_t dynamic; - char *u; // UTF-8 conversion of string if original was UTF-16 - char *s; // start of work area - char *e; // end of work area - char **ent; // general entities (ampersand sequences) - char ***attr; // default attributes - char ***pi; // processing instructions - short standalone; // non-zero if - char err[SWITCH_XML_ERRL]; // error string + char *u; /* UTF-8 conversion of string if original was UTF-16 */ + char *s; /* start of work area */ + char *e; /* end of work area */ + char **ent; /* general entities (ampersand sequences) */ + char ***attr; /* default attributes */ + char ***pi; /* processing instructions */ + short standalone; /* non-zero if */ + char err[SWITCH_XML_ERRL]; /* error string */ }; -char *SWITCH_XML_NIL[] = { NULL }; // empty, null terminated array of strings +char *SWITCH_XML_NIL[] = { NULL }; /* empty, null terminated array of strings */ struct switch_xml_binding { switch_xml_search_function_t function; @@ -147,7 +147,7 @@ struct xml_section_t { const char *name; - //switch_xml_section_t section; + /* switch_xml_section_t section; */ uint32_t section; }; @@ -164,7 +164,7 @@ { size_t x; char buf[1024] = ""; - //switch_xml_section_t sections = SWITCH_XML_SECTION_RESULT; + /*switch_xml_section_t sections = SWITCH_XML_SECTION_RESULT; */ uint32_t sections = SWITCH_XML_SECTION_RESULT; if (str) { @@ -251,8 +251,9 @@ return binding->user_data; } - -SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function_ret(switch_xml_search_function_t function, switch_xml_section_t sections, void *user_data, switch_xml_binding_t **ret_binding) +SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function_ret(switch_xml_search_function_t function, + switch_xml_section_t sections, void *user_data, + switch_xml_binding_t **ret_binding) { switch_xml_binding_t *binding = NULL, *ptr = NULL; assert(function != NULL); @@ -357,7 +358,7 @@ return p; } -// returns the first child tag with the given name or NULL if not found +/* returns the first child tag with the given name or NULL if not found */ SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name) { xml = (xml) ? xml->child : NULL; @@ -366,8 +367,7 @@ return xml; } -// returns the Nth tag with the same name in the same subsection or NULL if not -// found +/* returns the Nth tag with the same name in the same subsection or NULL if not found */ switch_xml_t switch_xml_idx(switch_xml_t xml, int idx) { for (; xml && idx; idx--) @@ -375,7 +375,7 @@ return xml; } -// returns the value of the requested tag attribute or "" if not found +/* returns the value of the requested tag attribute or "" if not found */ SWITCH_DECLARE(const char *) switch_xml_attr_soft(switch_xml_t xml, const char *attr) { const char *ret = switch_xml_attr(xml, attr); @@ -383,7 +383,7 @@ return ret ? ret : ""; } -// returns the value of the requested tag attribute or NULL if not found +/* returns the value of the requested tag attribute or NULL if not found */ SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr) { int i = 0, j = 1; @@ -394,19 +394,19 @@ while (xml->attr[i] && strcmp(attr, xml->attr[i])) i += 2; if (xml->attr[i]) - return xml->attr[i + 1]; // found attribute + return xml->attr[i + 1]; /* found attribute */ while (root->xml.parent) - root = (switch_xml_root_t) root->xml.parent; // root tag + root = (switch_xml_root_t) root->xml.parent; /* root tag */ for (i = 0; root->attr[i] && strcmp(xml->name, root->attr[i][0]); i++); if (!root->attr[i]) - return NULL; // no matching default attributes + return NULL; /* no matching default attributes */ while (root->attr[i][j] && strcmp(attr, root->attr[i][j])) j += 3; - return (root->attr[i][j]) ? root->attr[i][j + 1] : NULL; // found default + return (root->attr[i][j]) ? root->attr[i][j + 1] : NULL; /* found default */ } -// same as switch_xml_get but takes an already initialized va_list +/* same as switch_xml_get but takes an already initialized va_list */ static switch_xml_t switch_xml_vget(switch_xml_t xml, va_list ap) { char *name = va_arg(ap, char *); @@ -419,12 +419,12 @@ return (idx < 0) ? xml : switch_xml_vget(switch_xml_idx(xml, idx), ap); } -// Traverses the xml tree to retrieve a specific subtag. Takes a variable -// length list of tag names and indexes. The argument list must be terminated -// by either an index of -1 or an empty string tag name. Example: -// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1); -// This retrieves the title of the 3rd book on the 1st shelf of library. -// Returns NULL if not found. +/* Traverses the xml tree to retrieve a specific subtag. Takes a variable + length list of tag names and indexes. The argument list must be terminated + by either an index of -1 or an empty string tag name. Example: + title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1); + This retrieves the title of the 3rd book on the 1st shelf of library. + Returns NULL if not found. */ SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml,...) { va_list ap; @@ -436,8 +436,7 @@ return r; } -// returns a null terminated array of processing instructions for the given -// target +/* returns a null terminated array of processing instructions for the given target */ SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target) { switch_xml_root_t root = (switch_xml_root_t) xml; @@ -446,13 +445,13 @@ if (!root) return (const char **) SWITCH_XML_NIL; while (root->xml.parent) - root = (switch_xml_root_t) root->xml.parent; // root tag + root = (switch_xml_root_t) root->xml.parent; /* root tag */ while (root->pi[i] && strcmp(target, root->pi[i][0])) - i++; // find target + i++; /* find target */ return (const char **) ((root->pi[i]) ? root->pi[i] + 1 : SWITCH_XML_NIL); } -// set an error string and return root +/* set an error string and return root */ static switch_xml_t switch_xml_err(switch_xml_root_t root, char *s, const char *err, ...) { va_list ap; @@ -471,18 +470,18 @@ return &root->xml; } -// Recursively decodes entity and character references and normalizes new lines -// ent is a null terminated array of alternating entity names and values. set t -// to '&' for general entity decoding, '%' for parameter entity decoding, 'c' -// for cdata sections, ' ' for attribute normalization, or '*' for non-cdata -// attribute normalization. Returns s, or if the decoded string is longer than -// s, returns a malloced string that must be freed. +/* Recursively decodes entity and character references and normalizes new lines + ent is a null terminated array of alternating entity names and values. set t + to '&' for general entity decoding, '%' for parameter entity decoding, 'c' + for cdata sections, ' ' for attribute normalization, or '*' for non-cdata + attribute normalization. Returns s, or if the decoded string is longer than + s, returns a malloced string that must be freed. */ static char *switch_xml_decode(char *s, char **ent, char t) { char *e, *r = s, *m = s; long b, c, d, l; - for (; *s; s++) { // normalize line endings + for (; *s; s++) { /* normalize line endings */ while (*s == '\r') { *(s++) = '\n'; if (*s == '\n') @@ -496,34 +495,34 @@ if (!*s) break; - else if (t != 'c' && !strncmp(s, "&#", 2)) { // character reference + else if (t != 'c' && !strncmp(s, "&#", 2)) { /* character reference */ if (s[2] == 'x') - c = strtol(s + 3, &e, 16); // base 16 + c = strtol(s + 3, &e, 16); /* base 16 */ else - c = strtol(s + 2, &e, 10); // base 10 + c = strtol(s + 2, &e, 10); /* base 10 */ if (!c || *e != ';') { s++; continue; - } // not a character ref + } /* not a character ref */ if (c < 0x80) - *(s++) = (char) c; // US-ASCII subset - else { // multi-byte UTF-8 sequence + *(s++) = (char) c; /* US-ASCII subset */ + else { /* multi-byte UTF-8 sequence */ for (b = 0, d = c; d; d /= 2) - b++; // number of bits in c - b = (b - 2) / 5; // number of bytes in payload - *(s++) = (char) ((0xFF << (7 - b)) | (c >> (6 * b))); // head + b++; /* number of bits in c */ + b = (b - 2) / 5; /* number of bytes in payload */ + *(s++) = (char) ((0xFF << (7 - b)) | (c >> (6 * b))); /* head */ while (b) - *(s++) = (char) (0x80 | ((c >> (6 * --b)) & 0x3F)); // payload + *(s++) = (char) (0x80 | ((c >> (6 * --b)) & 0x3F)); /* payload */ } memmove(s, strchr(s, ';') + 1, strlen(strchr(s, ';'))); - } else if ((*s == '&' && (t == '&' || t == ' ' || t == '*')) || (*s == '%' && t == '%')) { // entity reference - for (b = 0; ent[b] && strncmp(s + 1, ent[b], strlen(ent[b])); b += 2); // find entity in entity list + } else if ((*s == '&' && (t == '&' || t == ' ' || t == '*')) || (*s == '%' && t == '%')) { /* entity reference */ + for (b = 0; ent[b] && strncmp(s + 1, ent[b], strlen(ent[b])); b += 2); /* find entity in entity list */ - if (ent[b++]) { // found a match + if (ent[b++]) { /* found a match */ if ((c = (long) strlen(ent[b])) - 1 > (e = strchr(s, ';')) - s) { - l = (d = (long) (s - r)) + c + (long) strlen(e); // new length + l = (d = (long) (s - r)) + c + (long) strlen(e); /* new length */ if (l) { if (r == m) { char *tmp = (char *)malloc(l); @@ -543,20 +542,20 @@ } } } - e = strchr((s = r + d), ';'); // fix up pointers + e = strchr((s = r + d), ';'); /* fix up pointers */ } - memmove(s + c, e + 1, strlen(e)); // shift rest of string - strncpy(s, ent[b], c); // copy in replacement text + memmove(s + c, e + 1, strlen(e)); /* shift rest of string */ + strncpy(s, ent[b], c); /* copy in replacement text */ } else - s++; // not a known entity + s++; /* not a known entity */ } else if ((t == ' ' || t == '*') && isspace((int) (*s))) *(s++) = ' '; else - s++; // no decoding needed + s++; /* no decoding needed */ } - if (t == '*') { // normalize spaces for non-cdata attributes + if (t == '*') { /* normalize spaces for non-cdata attributes */ for (s = r; *s; s++) { if ((l = (long) strspn(s, " "))) memmove(s, s + l, strlen(s + l) + 1); @@ -564,12 +563,12 @@ s++; } if (--s >= r && *s == ' ') - *s = '\0'; // trim any trailing space + *s = '\0'; /* trim any trailing space */ } return r; } -// called when parser finds start of new tag +/* called when parser finds start of new tag */ static void switch_xml_open_tag(switch_xml_root_t root, char *name, char **attr) { switch_xml_t xml = root->cur; @@ -577,13 +576,13 @@ if (xml->name) xml = switch_xml_add_child(xml, name, strlen(xml->txt)); else - xml->name = name; // first open tag + xml->name = name; /* first open tag */ xml->attr = attr; - root->cur = xml; // update tag insertion point + root->cur = xml; /* update tag insertion point */ } -// called when parser finds character content between open and closing tag +/* called when parser finds character content between open and closing tag */ static void switch_xml_char_content(switch_xml_root_t root, char *s, switch_size_t len, char t) { switch_xml_t xml = root->cur; @@ -591,15 +590,15 @@ switch_size_t l; if (!xml || !xml->name || !len) - return; // sanity check + return; /* sanity check */ - s[len] = '\0'; // null terminate text (calling functions anticipate this) + s[len] = '\0'; /* null terminate text (calling functions anticipate this) */ len = strlen(s = switch_xml_decode(s, root->ent, t)) + 1; if (!*(xml->txt)) - xml->txt = s; // initial character content - else { // allocate our own memory and make a copy - if ((xml->flags & SWITCH_XML_TXTM)) { // allocate some space + xml->txt = s; /* initial character content */ + else { /* allocate our own memory and make a copy */ + if ((xml->flags & SWITCH_XML_TXTM)) { /* allocate some space */ char *tmp = (char *)realloc(xml->txt, (l = strlen(xml->txt)) + len); if (tmp) { xml->txt = tmp; @@ -614,16 +613,16 @@ return; } } - strcpy(xml->txt + l, s); // add new char content + strcpy(xml->txt + l, s); /* add new char content */ if (s != m) - free(s); // free s if it was malloced by switch_xml_decode() + free(s); /* free s if it was malloced by switch_xml_decode() */ } if (xml->txt != m) switch_xml_set_flag(xml, SWITCH_XML_TXTM); } -// called when parser finds closing tag +/* called when parser finds closing tag */ static switch_xml_t switch_xml_close_tag(switch_xml_root_t root, char *name, char *s) { if (!root->cur || !root->cur->name || strcmp(name, root->cur->name)) @@ -633,26 +632,26 @@ return NULL; } -// checks for circular entity references, returns non-zero if no circular -// references are found, zero otherwise +/* checks for circular entity references, returns non-zero if no circular + references are found, zero otherwise */ static int switch_xml_ent_ok(char *name, char *s, char **ent) { int i; for (;; s++) { while (*s && *s != '&') - s++; // find next entity reference + s++; /* find next entity reference */ if (!*s) return 1; if (!strncmp(s + 1, name, strlen(name))) - return 0; // circular ref. + return 0; /* circular ref. */ for (i = 0; ent[i] && strncmp(ent[i], s + 1, strlen(ent[i])); i += 2); if (ent[i] && !switch_xml_ent_ok(name, ent[i + 1], ent)) return 0; } } -// called when the parser finds a processing instruction +/* called when the parser finds a processing instruction */ static void switch_xml_proc_inst(switch_xml_root_t root, char *s, switch_size_t len) { int i = 0, j = 1; @@ -660,15 +659,15 @@ char **sstmp; char *stmp; - s[len] = '\0'; // null terminate instruction + s[len] = '\0'; /* null terminate instruction */ if (*(s += strcspn(s, SWITCH_XML_WS))) { - *s = '\0'; // null terminate target - s += strspn(s + 1, SWITCH_XML_WS) + 1; // skip whitespace after target + *s = '\0'; /* null terminate target */ + s += strspn(s + 1, SWITCH_XML_WS) + 1; /* skip whitespace after target */ } if (!root) return; - if (!strcmp(target, "xml")) { // + if (!strcmp(target, "xml")) { /* */ if ((s = strstr(s, "standalone")) && !strncmp(s + strspn(s + 10, SWITCH_XML_WS "='\"") + 10, "yes", 3)) root->standalone = 1; return; @@ -677,12 +676,12 @@ if (!root->pi[0]) { root->pi = (char ***)malloc(sizeof(char **)); if (!root->pi) return; - *(root->pi) = NULL; //first pi + *(root->pi) = NULL; /* first pi */ } while (root->pi[i] && strcmp(target, root->pi[i][0])) - i++; // find target - if (!root->pi[i]) { // new target + i++; /* find target */ + if (!root->pi[i]) { /* new target */ char ***ssstmp = (char ***)realloc(root->pi, sizeof(char **) * (i + 2)); if (!ssstmp) return; root->pi = ssstmp; @@ -690,12 +689,12 @@ root->pi[i] = (char **)malloc(sizeof(char *) * 3); if (!root->pi[i]) return; root->pi[i][0] = target; - root->pi[i][1] = (char *) (root->pi[i + 1] = NULL); // terminate pi list - root->pi[i][2] = strdup(""); // empty document position list + root->pi[i][1] = (char *) (root->pi[i + 1] = NULL); /* terminate pi list */ + root->pi[i][2] = strdup(""); /* empty document position list */ } while (root->pi[i][j]) - j++; // find end of instruction list for this target + j++; /* find end of instruction list for this target */ sstmp = (char **)realloc(root->pi[i], sizeof(char *) * (j + 3)); if (!sstmp) return; root->pi[i] = sstmp; @@ -703,11 +702,11 @@ if (!stmp) return; root->pi[i][j + 2] = stmp; strcpy(root->pi[i][j + 2] + j - 1, (root->xml.name) ? ">" : "<"); - root->pi[i][j + 1] = NULL; // null terminate pi list for this target - root->pi[i][j] = s; // set instruction + root->pi[i][j + 1] = NULL; /* null terminate pi list for this target */ + root->pi[i][j] = s; /* set instruction */ } -// called when the parser finds an internal doctype subset +/* called when the parser finds an internal doctype subset */ static short switch_xml_internal_dtd(switch_xml_root_t root, char *s, switch_size_t len) { char q, *c, *t, *n = NULL, *v, **ent, **pe; @@ -718,23 +717,23 @@ for (s[len] = '\0'; s;) { while (*s && *s != '<' && *s != '%') - s++; // find next declaration + s++; /* find next declaration */ if (!*s) break; - else if (!strncmp(s, "'); continue; } for (i = 0, ent = (*c == '%') ? pe : root->ent; ent[i]; i++); - sstmp = (char **)realloc(ent, (i + 3) * sizeof(char *)); // space for next ent + sstmp = (char **)realloc(ent, (i + 3) * sizeof(char *)); /* space for next ent */ if (!sstmp) { switch_xml_err(root, v, "Allocation Error!"); break; @@ -745,20 +744,20 @@ else root->ent = ent; - *(++s) = '\0'; // null terminate name + *(++s) = '\0'; /* null terminate name */ if ((s = strchr(v, q))) - *(s++) = '\0'; // null terminate value - ent[i + 1] = switch_xml_decode(v, pe, '%'); // set value - ent[i + 2] = NULL; // null terminate entity list - if (!switch_xml_ent_ok(n, ent[i + 1], ent)) { // circular reference + *(s++) = '\0'; /* null terminate value */ + ent[i + 1] = switch_xml_decode(v, pe, '%'); /* set value */ + ent[i + 2] = NULL; /* null terminate entity list */ + if (!switch_xml_ent_ok(n, ent[i + 1], ent)) { /* circular reference */ if (ent[i + 1] != v) free(ent[i + 1]); switch_xml_err(root, v, "circular entity declaration &%s", n); break; } else - ent[i] = n; // set entity name - } else if (!strncmp(s, "")) == '>') continue; else - *s = '\0'; // null terminate tag name + *s = '\0'; /* null terminate tag name */ for (i = 0; root->attr[i] && strcmp(n, root->attr[i][0]); i++); while (*(n = ++s + strspn(s, SWITCH_XML_WS)) && *n != '>') { if (*(s = n + strcspn(n, SWITCH_XML_WS))) - *s = '\0'; // attr name + *s = '\0'; /* attr name */ else { switch_xml_err(root, t, "malformed ") - 1; if (*c == ' ') - continue; // cdata is default, nothing to do + continue; /* cdata is default, nothing to do */ v = NULL; - } else if ((*s == '"' || *s == '\'') && // default value + } else if ((*s == '"' || *s == '\'') && /* default value */ (s = strchr(v = s + 1, *s))) *s = '\0'; else { @@ -803,15 +802,15 @@ break; } - if (!root->attr[i]) { // new tag name + if (!root->attr[i]) { /* new tag name */ root->attr = (!i) ? (char ***)malloc(2 * sizeof(char **)) : (char ***)realloc(root->attr, (i + 2) * sizeof(char **)); root->attr[i] = (char **)malloc(2 * sizeof(char *)); - root->attr[i][0] = t; // set tag name + root->attr[i][0] = t; /* set tag name */ root->attr[i][1] = (char *) (root->attr[i + 1] = NULL); } - for (j = 1; root->attr[i][j]; j += 3); // find end of list + for (j = 1; root->attr[i][j]; j += 3); /* find end of list */ sstmp = (char **)realloc(root->attr[i], (j + 4) * sizeof(char *)); if (!sstmp) { @@ -820,19 +819,18 @@ } root->attr[i] = sstmp; - root->attr[i][j + 3] = NULL; // null terminate list - root->attr[i][j + 2] = c; // is it cdata? - root->attr[i][j + 1] = (v) ? switch_xml_decode(v, root->ent, *c) - : NULL; - root->attr[i][j] = n; // attribute name + root->attr[i][j + 3] = NULL; /* null terminate list */ + root->attr[i][j + 2] = c; /* is it cdata? */ + root->attr[i][j + 1] = (v) ? switch_xml_decode(v, root->ent, *c) : NULL; + root->attr[i][j] = n; /* attribute name */ } } else if (!strncmp(s, ""); // comments - else if (!strncmp(s, ""); /* comments */ + else if (!strncmp(s, ""))) switch_xml_proc_inst(root, c, s++ - c); } else if (*s == '<') - s = strchr(s, '>'); // skip other declarations + s = strchr(s, '>'); /* skip other declarations */ else if (*(s++) == '%' && !root->standalone) break; } @@ -841,8 +839,8 @@ return !*root->err; } -// Converts a UTF-16 string to UTF-8. Returns a new string that must be freed -// or NULL if no conversion was needed. +/* Converts a UTF-16 string to UTF-8. Returns a new string that must be freed + or NULL if no conversion was needed. */ static char *switch_xml_str2utf8(char **s, switch_size_t *len) { char *u; @@ -851,13 +849,13 @@ int b, be = (**s == '\xFE') ? 1 : (**s == '\xFF') ? 0 : -1; if (be == -1) - return NULL; // not UTF-16 + return NULL; /* not UTF-16 */ u = (char *)malloc(max); for (sl = 2; sl < *len - 1; sl += 2) { - c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) //UTF-16BE - : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF); //UTF-16LE - if (c >= 0xD800 && c <= 0xDFFF && (sl += 2) < *len - 1) { // high-half + c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) /* UTF-16BE */ + : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF); /* UTF-16LE */ + if (c >= 0xD800 && c <= 0xDFFF && (sl += 2) < *len - 1) { /* high-half */ d = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF); c = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000; @@ -870,30 +868,30 @@ u = tmp; } if (c < 0x80) - u[l++] = (char) c; // US-ASCII subset - else { // multi-byte UTF-8 sequence + u[l++] = (char) c; /* US-ASCII subset */ + else { /* multi-byte UTF-8 sequence */ for (b = 0, d = c; d; d /= 2) - b++; // bits in c - b = (b - 2) / 5; // bytes in payload - u[l++] = (char) ((0xFF << (7 - b)) | (c >> (6 * b))); // head + b++; /* bits in c */ + b = (b - 2) / 5; /* bytes in payload */ + u[l++] = (char) ((0xFF << (7 - b)) | (c >> (6 * b))); /* head */ while (b) - u[l++] = (char) (0x80 | ((c >> (6 * --b)) & 0x3F)); // payload + u[l++] = (char) (0x80 | ((c >> (6 * --b)) & 0x3F)); /* payload */ } } return *s = (char *)realloc(u, *len = l); } -// frees a tag attribute list +/* frees a tag attribute list */ static void switch_xml_free_attr(char **attr) { int i = 0; char *m; if (!attr || attr == SWITCH_XML_NIL) - return; // nothing to free + return; /* nothing to free */ while (attr[i]) - i += 2; // find end of attribute list - m = attr[i + 1]; // list of which names and values are malloced + i += 2; /* find end of attribute list */ + m = attr[i + 1]; /* list of which names and values are malloced */ for (i = 0; m[i]; i++) { if (m[i] & SWITCH_XML_NAMEM) free(attr[i * 2]); @@ -904,24 +902,24 @@ free(attr); } -// parse the given xml string and return an switch_xml structure +/* parse the given xml string and return an switch_xml structure */ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len) { switch_xml_root_t root = (switch_xml_root_t) switch_xml_new(NULL); - char q, e, *d, **attr, **a = NULL; // initialize a to avoid compile warning + char q, e, *d, **attr, **a = NULL; /* initialize a to avoid compile warning */ int l, i, j; root->m = s; if (!len) return switch_xml_err(root, s, "root tag missing"); - root->u = switch_xml_str2utf8(&s, &len); // convert utf-16 to utf-8 - root->e = (root->s = s) + len; // record start and end of work area + root->u = switch_xml_str2utf8(&s, &len); /* convert utf-16 to utf-8 */ + root->e = (root->s = s) + len; /* record start and end of work area */ - e = s[len - 1]; // save end char - s[len - 1] = '\0'; // turn end char into null terminator + e = s[len - 1]; /* save end char */ + s[len - 1] = '\0'; /* turn end char into null terminator */ while (*s && *s != '<') - s++; // find first tag + s++; /* find first tag */ if (!*s) return switch_xml_err(root, s, "root tag missing"); @@ -929,37 +927,37 @@ attr = (char **) SWITCH_XML_NIL; d = ++s; - if (isalpha((int) (*s)) || *s == '_' || *s == ':' || (int8_t) *s < '\0') { // new tag + if (isalpha((int) (*s)) || *s == '_' || *s == ':' || (int8_t) *s < '\0') { /* new tag */ if (!root->cur) return switch_xml_err(root, d, "markup outside of root element"); s += strcspn(s, SWITCH_XML_WS "/>"); while (isspace((int) (*s))) - *(s++) = '\0'; // null terminate tag name + *(s++) = '\0'; /* null terminate tag name */ - if (*s && *s != '/' && *s != '>') // find tag in default attr list + if (*s && *s != '/' && *s != '>') /* find tag in default attr list */ for (i = 0; (a = root->attr[i]) && strcmp(a[0], d); i++); - for (l = 0; *s && *s != '/' && *s != '>'; l += 2) { // new attrib + for (l = 0; *s && *s != '/' && *s != '>'; l += 2) { /* new attrib */ attr = (l) ? (char **)realloc(attr, (l + 4) * sizeof(char *)) - : (char **)malloc(4 * sizeof(char *)); // allocate space + : (char **)malloc(4 * sizeof(char *)); /* allocate space */ attr[l + 3] = (l) ? (char *)realloc(attr[l + 1], (l / 2) + 2) - : (char *)malloc(2); // mem for list of maloced vals - strcpy(attr[l + 3] + (l / 2), " "); // value is not malloced - attr[l + 2] = NULL; // null terminate list - attr[l + 1] = (char *)""; // temporary attribute value - attr[l] = s; // set attribute name + : (char *)malloc(2); /* mem for list of maloced vals */ + strcpy(attr[l + 3] + (l / 2), " "); /* value is not malloced */ + attr[l + 2] = NULL; /* null terminate list */ + attr[l + 1] = (char *)""; /* temporary attribute value */ + attr[l] = s; /* set attribute name */ s += strcspn(s, SWITCH_XML_WS "=/>"); if (*s == '=' || isspace((int) (*s))) { - *(s++) = '\0'; // null terminate tag attribute name + *(s++) = '\0'; /* null terminate tag attribute name */ q = *(s += strspn(s, SWITCH_XML_WS "=")); - if (q == '"' || q == '\'') { // attribute value + if (q == '"' || q == '\'') { /* attribute value */ attr[l + 1] = ++s; while (*s && *s != q) s++; if (*s) - *(s++) = '\0'; // null terminate attribute val + *(s++) = '\0'; /* null terminate attribute val */ else { switch_xml_free_attr(attr); return switch_xml_err(root, d, "missing %c", q); @@ -968,14 +966,14 @@ for (j = 1; a && a[j] && strcmp(a[j], attr[l]); j += 3); attr[l + 1] = switch_xml_decode(attr[l + 1], root->ent, (a && a[j]) ? *a[j + 2] : ' '); if (attr[l + 1] < d || attr[l + 1] > s) - attr[l + 3][l / 2] = SWITCH_XML_TXTM; // value malloced + attr[l + 3][l / 2] = SWITCH_XML_TXTM; /* value malloced */ } } while (isspace((int) (*s))) s++; } - if (*s == '/') { // self closing tag + if (*s == '/') { /* self closing tag */ *(s++) = '\0'; if ((*s && *s != '>') || (!*s && e != '>')) { if (l) @@ -984,8 +982,8 @@ } switch_xml_open_tag(root, d, attr); switch_xml_close_tag(root, d, s); - } else if ((q = *s) == '>' || (!*s && e == '>')) { // open tag - *s = '\0'; // temporarily null terminate tag name + } else if ((q = *s) == '>' || (!*s && e == '>')) { /* open tag */ + *s = '\0'; /* temporarily null terminate tag name */ switch_xml_open_tag(root, d, attr); *s = q; } else { @@ -993,24 +991,24 @@ switch_xml_free_attr(attr); return switch_xml_err(root, d, "missing >"); } - } else if (*s == '/') { // close tag + } else if (*s == '/') { /* close tag */ s += strcspn(d = s + 1, SWITCH_XML_WS ">") + 1; if (!(q = *s) && e != '>') return switch_xml_err(root, d, "missing >"); - *s = '\0'; // temporarily null terminate tag name + *s = '\0'; /* temporarily null terminate tag name */ if (switch_xml_close_tag(root, d, s)) return &root->xml; if (isspace((int) (*s = q))) s += strspn(s, SWITCH_XML_WS); - } else if (!strncmp(s, "!--", 3)) { // xml comment + } else if (!strncmp(s, "!--", 3)) { /* xml comment */ if (!(s = strstr(s + 3, "--")) || (*(s += 2) != '>' && *s) || (!*s && e != '>')) return switch_xml_err(root, d, "unclosed + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/AC_OETags.js ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/AC_OETags.js Sat Mar 7 07:12:38 2009 @@ -0,0 +1,276 @@ +// Flash Player Version Detection - Rev 1.6 +// Detect Client Browser type +// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. +var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; +var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; +var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; + +function ControlVersion() +{ + var version; + var axo; + var e; + + // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry + + try { + // version will be set for 7.X or greater players + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); + version = axo.GetVariable("$version"); + } catch (e) { + } + + if (!version) + { + try { + // version will be set for 6.X players only + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); + + // installed player is some revision of 6.0 + // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, + // so we have to be careful. + + // default to the first public version + version = "WIN 6,0,21,0"; + + // throws if AllowScripAccess does not exist (introduced in 6.0r47) + axo.AllowScriptAccess = "always"; + + // safe to call for 6.0r47 or greater + version = axo.GetVariable("$version"); + + } catch (e) { + } + } + + if (!version) + { + try { + // version will be set for 4.X or 5.X player + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); + version = axo.GetVariable("$version"); + } catch (e) { + } + } + + if (!version) + { + try { + // version will be set for 3.X player + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); + version = "WIN 3,0,18,0"; + } catch (e) { + } + } + + if (!version) + { + try { + // version will be set for 2.X player + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); + version = "WIN 2,0,0,11"; + } catch (e) { + version = -1; + } + } + + return version; +} + +// JavaScript helper required to detect Flash Player PlugIn version information +function GetSwfVer(){ + // NS/Opera version >= 3 check for Flash plugin in plugin array + var flashVer = -1; + + if (navigator.plugins != null && navigator.plugins.length > 0) { + if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { + var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; + var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; + var descArray = flashDescription.split(" "); + var tempArrayMajor = descArray[2].split("."); + var versionMajor = tempArrayMajor[0]; + var versionMinor = tempArrayMajor[1]; + var versionRevision = descArray[3]; + if (versionRevision == "") { + versionRevision = descArray[4]; + } + if (versionRevision[0] == "d") { + versionRevision = versionRevision.substring(1); + } else if (versionRevision[0] == "r") { + versionRevision = versionRevision.substring(1); + if (versionRevision.indexOf("d") > 0) { + versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); + } + } + var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; + } + } + // MSN/WebTV 2.6 supports Flash 4 + else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; + // WebTV 2.5 supports Flash 3 + else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; + // older WebTV supports Flash 2 + else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; + else if ( isIE && isWin && !isOpera ) { + flashVer = ControlVersion(); + } + return flashVer; +} + +// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available +function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) +{ + versionStr = GetSwfVer(); + if (versionStr == -1 ) { + return false; + } else if (versionStr != 0) { + if(isIE && isWin && !isOpera) { + // Given "WIN 2,0,0,11" + tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] + tempString = tempArray[1]; // "2,0,0,11" + versionArray = tempString.split(","); // ['2', '0', '0', '11'] + } else { + versionArray = versionStr.split("."); + } + var versionMajor = versionArray[0]; + var versionMinor = versionArray[1]; + var versionRevision = versionArray[2]; + + // is the major.revision >= requested major.revision AND the minor version >= requested minor + if (versionMajor > parseFloat(reqMajorVer)) { + return true; + } else if (versionMajor == parseFloat(reqMajorVer)) { + if (versionMinor > parseFloat(reqMinorVer)) + return true; + else if (versionMinor == parseFloat(reqMinorVer)) { + if (versionRevision >= parseFloat(reqRevision)) + return true; + } + } + return false; + } +} + +function AC_AddExtension(src, ext) +{ + if (src.indexOf('?') != -1) + return src.replace(/\?/, ext+'?'); + else + return src + ext; +} + +function AC_Generateobj(objAttrs, params, embedAttrs) +{ + var str = ''; + if (isIE && isWin && !isOpera) + { + str += ' '; + str += ''; + } else { + str += '= 2 && hash.charAt(0) == "?") { + hash = hash.substring(1); + } + return hash; + } + + /* Get the current location hash excluding the '#' symbol. */ + function getHash() { + // It would be nice if we could use document.location.hash here, + // but it's faulty sometimes. + var idx = document.location.href.indexOf('#'); + return (idx >= 0) ? document.location.href.substr(idx+1) : ''; + } + + /* Get the current location hash excluding the '#' symbol. */ + function setHash(hash) { + // It would be nice if we could use document.location.hash here, + // but it's faulty sometimes. + if (hash == '') hash = '#' + document.location.hash = hash; + } + + function createState(baseUrl, newUrl, flexAppUrl) { + return { 'baseUrl': baseUrl, 'newUrl': newUrl, 'flexAppUrl': flexAppUrl, 'title': null }; + } + + /* Add a history entry to the browser. + * baseUrl: the portion of the location prior to the '#' + * newUrl: the entire new URL, including '#' and following fragment + * flexAppUrl: the portion of the location following the '#' only + */ + function addHistoryEntry(baseUrl, newUrl, flexAppUrl) { + + //delete all the history entries + forwardStack = []; + + if (browser.ie) { + //Check to see if we are being asked to do a navigate for the first + //history entry, and if so ignore, because it's coming from the creation + //of the history iframe + if (flexAppUrl == defaultHash && document.location.href == initialHref && window['_ie_firstload']) { + currentHref = initialHref; + return; + } + if ((!flexAppUrl || flexAppUrl == defaultHash) && window['_ie_firstload']) { + newUrl = baseUrl + '#' + defaultHash; + flexAppUrl = defaultHash; + } else { + // for IE, tell the history frame to go somewhere without a '#' + // in order to get this entry into the browser history. + getHistoryFrame().src = historyFrameSourcePrefix + flexAppUrl; + } + setHash(flexAppUrl); + } else { + + //ADR + if (backStack.length == 0 && initialState.flexAppUrl == flexAppUrl) { + initialState = createState(baseUrl, newUrl, flexAppUrl); + } else if(backStack.length > 0 && backStack[backStack.length - 1].flexAppUrl == flexAppUrl) { + backStack[backStack.length - 1] = createState(baseUrl, newUrl, flexAppUrl); + } + + if (browser.safari) { + // for Safari, submit a form whose action points to the desired URL + if (browser.version <= 419.3) { + var file = window.location.pathname.toString(); + file = file.substring(file.lastIndexOf("/")+1); + getFormElement().innerHTML = '
'; + //get the current elements and add them to the form + var qs = window.location.search.substring(1); + var qs_arr = qs.split("&"); + for (var i = 0; i < qs_arr.length; i++) { + var tmp = qs_arr[i].split("="); + var elem = document.createElement("input"); + elem.type = "hidden"; + elem.name = tmp[0]; + elem.value = tmp[1]; + document.forms.historyForm.appendChild(elem); + } + document.forms.historyForm.submit(); + } else { + top.location.hash = flexAppUrl; + } + // We also have to maintain the history by hand for Safari + historyHash[history.length] = flexAppUrl; + _storeStates(); + } else { + // Otherwise, write an anchor into the page and tell the browser to go there + addAnchor(flexAppUrl); + setHash(flexAppUrl); + } + } + backStack.push(createState(baseUrl, newUrl, flexAppUrl)); + } + + function _storeStates() { + if (browser.safari) { + getRememberElement().value = historyHash.join(","); + } + } + + function handleBackButton() { + //The "current" page is always at the top of the history stack. + var current = backStack.pop(); + if (!current) { return; } + var last = backStack[backStack.length - 1]; + if (!last && backStack.length == 0){ + last = initialState; + } + forwardStack.push(current); + } + + function handleForwardButton() { + //summary: private method. Do not call this directly. + + var last = forwardStack.pop(); + if (!last) { return; } + backStack.push(last); + } + + function handleArbitraryUrl() { + //delete all the history entries + forwardStack = []; + } + + /* Called periodically to poll to see if we need to detect navigation that has occurred */ + function checkForUrlChange() { + + if (browser.ie) { + if (currentHref != document.location.href && currentHref + '#' != document.location.href) { + //This occurs when the user has navigated to a specific URL + //within the app, and didn't use browser back/forward + //IE seems to have a bug where it stops updating the URL it + //shows the end-user at this point, but programatically it + //appears to be correct. Do a full app reload to get around + //this issue. + if (browser.version < 7) { + currentHref = document.location.href; + document.location.reload(); + } else { + if (getHash() != getIframeHash()) { + // this.iframe.src = this.blankURL + hash; + var sourceToSet = historyFrameSourcePrefix + getHash(); + getHistoryFrame().src = sourceToSet; + } + } + } + } + + if (browser.safari) { + // For Safari, we have to check to see if history.length changed. + if (currentHistoryLength >= 0 && history.length != currentHistoryLength) { + //alert("did change: " + history.length + ", " + historyHash.length + "|" + historyHash[history.length] + "|>" + historyHash.join("|")); + // If it did change, then we have to look the old state up + // in our hand-maintained array since document.location.hash + // won't have changed, then call back into BrowserManager. + currentHistoryLength = history.length; + var flexAppUrl = historyHash[currentHistoryLength]; + if (flexAppUrl == '') { + //flexAppUrl = defaultHash; + } + //ADR: to fix multiple + if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { + var pl = getPlayers(); + for (var i = 0; i < pl.length; i++) { + pl[i].browserURLChange(flexAppUrl); + } + } else { + getPlayer().browserURLChange(flexAppUrl); + } + _storeStates(); + } + } + if (browser.firefox) { + if (currentHref != document.location.href) { + var bsl = backStack.length; + + var urlActions = { + back: false, + forward: false, + set: false + } + + if ((window.location.hash == initialHash || window.location.href == initialHref) && (bsl == 1)) { + urlActions.back = true; + // FIXME: could this ever be a forward button? + // we can't clear it because we still need to check for forwards. Ugg. + // clearInterval(this.locationTimer); + handleBackButton(); + } + + // first check to see if we could have gone forward. We always halt on + // a no-hash item. + if (forwardStack.length > 0) { + if (forwardStack[forwardStack.length-1].flexAppUrl == getHash()) { + urlActions.forward = true; + handleForwardButton(); + } + } + + // ok, that didn't work, try someplace back in the history stack + if ((bsl >= 2) && (backStack[bsl - 2])) { + if (backStack[bsl - 2].flexAppUrl == getHash()) { + urlActions.back = true; + handleBackButton(); + } + } + + if (!urlActions.back && !urlActions.forward) { + var foundInStacks = { + back: -1, + forward: -1 + } + + for (var i = 0; i < backStack.length; i++) { + if (backStack[i].flexAppUrl == getHash() && i != (bsl - 2)) { + arbitraryUrl = true; + foundInStacks.back = i; + } + } + for (var i = 0; i < forwardStack.length; i++) { + if (forwardStack[i].flexAppUrl == getHash() && i != (bsl - 2)) { + arbitraryUrl = true; + foundInStacks.forward = i; + } + } + handleArbitraryUrl(); + } + + // Firefox changed; do a callback into BrowserManager to tell it. + currentHref = document.location.href; + var flexAppUrl = getHash(); + if (flexAppUrl == '') { + //flexAppUrl = defaultHash; + } + //ADR: to fix multiple + if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { + var pl = getPlayers(); + for (var i = 0; i < pl.length; i++) { + pl[i].browserURLChange(flexAppUrl); + } + } else { + getPlayer().browserURLChange(flexAppUrl); + } + } + } + //setTimeout(checkForUrlChange, 50); + } + + /* Write an anchor into the page to legitimize it as a URL for Firefox et al. */ + function addAnchor(flexAppUrl) + { + if (document.getElementsByName(flexAppUrl).length == 0) { + getAnchorElement().innerHTML += "" + flexAppUrl + ""; + } + } + + var _initialize = function () { + if (browser.ie) + { + var scripts = document.getElementsByTagName('script'); + for (var i = 0, s; s = scripts[i]; i++) { + if (s.src.indexOf("history.js") > -1) { + var iframe_location = (new String(s.src)).replace("history.js", "historyFrame.html"); + } + } + historyFrameSourcePrefix = iframe_location + "?"; + var src = historyFrameSourcePrefix; + + var iframe = document.createElement("iframe"); + iframe.id = 'ie_historyFrame'; + iframe.name = 'ie_historyFrame'; + //iframe.src = historyFrameSourcePrefix; + try { + document.body.appendChild(iframe); + } catch(e) { + setTimeout(function() { + document.body.appendChild(iframe); + }, 0); + } + } + + if (browser.safari) + { + var rememberDiv = document.createElement("div"); + rememberDiv.id = 'safari_rememberDiv'; + document.body.appendChild(rememberDiv); + rememberDiv.innerHTML = ''; + + var formDiv = document.createElement("div"); + formDiv.id = 'safari_formDiv'; + document.body.appendChild(formDiv); + + var reloader_content = document.createElement('div'); + reloader_content.id = 'safarireloader'; + var scripts = document.getElementsByTagName('script'); + for (var i = 0, s; s = scripts[i]; i++) { + if (s.src.indexOf("history.js") > -1) { + html = (new String(s.src)).replace(".js", ".html"); + } + } + reloader_content.innerHTML = ''; + document.body.appendChild(reloader_content); + reloader_content.style.position = 'absolute'; + reloader_content.style.left = reloader_content.style.top = '-9999px'; + iframe = reloader_content.getElementsByTagName('iframe')[0]; + + if (document.getElementById("safari_remember_field").value != "" ) { + historyHash = document.getElementById("safari_remember_field").value.split(","); + } + + } + + if (browser.firefox) + { + var anchorDiv = document.createElement("div"); + anchorDiv.id = 'firefox_anchorDiv'; + document.body.appendChild(anchorDiv); + } + + //setTimeout(checkForUrlChange, 50); + } + + return { + historyHash: historyHash, + backStack: function() { return backStack; }, + forwardStack: function() { return forwardStack }, + getPlayer: getPlayer, + initialize: function(src) { + _initialize(src); + }, + setURL: function(url) { + document.location.href = url; + }, + getURL: function() { + return document.location.href; + }, + getTitle: function() { + return document.title; + }, + setTitle: function(title) { + try { + backStack[backStack.length - 1].title = title; + } catch(e) { } + //if on safari, set the title to be the empty string. + if (browser.safari) { + if (title == "") { + try { + var tmp = window.location.href.toString(); + title = tmp.substring((tmp.lastIndexOf("/")+1), tmp.lastIndexOf("#")); + } catch(e) { + title = ""; + } + } + } + document.title = title; + }, + setDefaultURL: function(def) + { + defaultHash = def; + def = getHash(); + //trailing ? is important else an extra frame gets added to the history + //when navigating back to the first page. Alternatively could check + //in history frame navigation to compare # and ?. + if (browser.ie) + { + window['_ie_firstload'] = true; + var sourceToSet = historyFrameSourcePrefix + def; + var func = function() { + getHistoryFrame().src = sourceToSet; + window.location.replace("#" + def); + setInterval(checkForUrlChange, 50); + } + try { + func(); + } catch(e) { + window.setTimeout(function() { func(); }, 0); + } + } + + if (browser.safari) + { + currentHistoryLength = history.length; + if (historyHash.length == 0) { + historyHash[currentHistoryLength] = def; + var newloc = "#" + def; + window.location.replace(newloc); + } else { + //alert(historyHash[historyHash.length-1]); + } + //setHash(def); + setInterval(checkForUrlChange, 50); + } + + + if (browser.firefox || browser.opera) + { + var reg = new RegExp("#" + def + "$"); + if (window.location.toString().match(reg)) { + } else { + var newloc ="#" + def; + window.location.replace(newloc); + } + setInterval(checkForUrlChange, 50); + //setHash(def); + } + + }, + + /* Set the current browser URL; called from inside BrowserManager to propagate + * the application state out to the container. + */ + setBrowserURL: function(flexAppUrl, objectId) { + if (browser.ie && typeof objectId != "undefined") { + currentObjectId = objectId; + } + //fromIframe = fromIframe || false; + //fromFlex = fromFlex || false; + //alert("setBrowserURL: " + flexAppUrl); + //flexAppUrl = (flexAppUrl == "") ? defaultHash : flexAppUrl ; + + var pos = document.location.href.indexOf('#'); + var baseUrl = pos != -1 ? document.location.href.substr(0, pos) : document.location.href; + var newUrl = baseUrl + '#' + flexAppUrl; + + if (document.location.href != newUrl && document.location.href + '#' != newUrl) { + currentHref = newUrl; + addHistoryEntry(baseUrl, newUrl, flexAppUrl); + currentHistoryLength = history.length; + } + + return false; + }, + + browserURLChange: function(flexAppUrl) { + var objectId = null; + if (browser.ie && currentObjectId != null) { + objectId = currentObjectId; + } + pendingURL = ''; + + if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { + var pl = getPlayers(); + for (var i = 0; i < pl.length; i++) { + try { + pl[i].browserURLChange(flexAppUrl); + } catch(e) { } + } + } else { + try { + getPlayer(objectId).browserURLChange(flexAppUrl); + } catch(e) { } + } + + currentObjectId = null; + } + + } + +})(); + +// Initialization + +// Automated unit testing and other diagnostics + +function setURL(url) +{ + document.location.href = url; +} + +function backButton() +{ + history.back(); +} + +function forwardButton() +{ + history.forward(); +} + +function goForwardOrBackInHistory(step) +{ + history.go(step); +} + +//BrowserHistoryUtils.addEvent(window, "load", function() { BrowserHistory.initialize(); }); +(function(i) { + var u =navigator.userAgent;var e=/*@cc_on!@*/false; + var st = setTimeout; + if(/webkit/i.test(u)){ + st(function(){ + var dr=document.readyState; + if(dr=="loaded"||dr=="complete"){i()} + else{st(arguments.callee,10);}},10); + } else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){ + document.addEventListener("DOMContentLoaded",i,false); + } else if(e){ + (function(){ + var t=document.createElement('doc:rdy'); + try{t.doScroll('left'); + i();t=null; + }catch(e){st(arguments.callee,0);}})(); + } else{ + window.onload=i; + } +})( function() {BrowserHistory.initialize();} ); Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/history/historyFrame.html ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/history/historyFrame.html Sat Mar 7 07:12:38 2009 @@ -0,0 +1,29 @@ + + + + + + + + Hidden frame for Browser History support. + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/index.template.html ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/index.template.html Sat Mar 7 07:12:38 2009 @@ -0,0 +1,121 @@ + + + + + + + + + + + + +${title} + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/html-template/playerProductInstall.swf ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/tollfreegateway/freeswitch.as ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/tollfreegateway/freeswitch.as Sat Mar 7 07:12:38 2009 @@ -0,0 +1,17 @@ +package com.tollfreegateway +{ + public class freeswitch + { + [RemoteClass(alias="com.tollfreegateway.freeswitch")] + [Bindable] + + public function freeswitch() + { + public var id_aut:int; + public var fname_aut:String; + public var lname_aut:String; + + } + + } +} \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sat Mar 7 07:12:38 2009 @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From anthm at freeswitch.org Sat Mar 7 06:07:48 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 08:07:48 -0600 Subject: [Freeswitch-svn] [commit] r12509 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sat Mar 7 08:07:48 2009 New Revision: 12509 Log: FSCORE-323 Modified: freeswitch/trunk/src/switch.c Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Sat Mar 7 08:07:48 2009 @@ -621,13 +621,23 @@ memset(&rlp, 0, sizeof(rlp)); getrlimit(RLIMIT_STACK, &rlp); if (rlp.rlim_max > SWITCH_THREAD_STACKSIZE) { + char buf[1024] = ""; + int i = 0; memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; rlp.rlim_max = SWITCH_THREAD_STACKSIZE; setrlimit(RLIMIT_STACK, &rlp); - fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance....\n", - SWITCH_THREAD_STACKSIZE / 1024, SWITCH_THREAD_STACKSIZE / 1024, argv[0]); - return (int)execv(argv[0], argv); + fprintf(stderr, "Error: stacksize %ld is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance....\n", + rlp.rlim_max / 1024, SWITCH_THREAD_STACKSIZE / 1024, argv[0]); + apr_terminate(); + ret = (int)execv(argv[0], argv); + + for(i = 0; i < argc; i++) { + switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s ", argv[i]); + } + + return system(buf); + } } #endif From anthm at freeswitch.org Sat Mar 7 07:59:01 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 09:59:01 -0600 Subject: [Freeswitch-svn] [commit] r12510 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Sat Mar 7 09:59:01 2009 New Revision: 12510 Log: add contact_user param for rare cases when provider makes you say a certian contact user 'LAME' Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sat Mar 7 09:59:01 2009 @@ -1085,6 +1085,7 @@ *extension = NULL, *proxy = NULL, *context = profile->context, + *contact_user = NULL, *expire_seconds = "3600", *retry_seconds = "30", *from_user = "", *from_domain = "", *register_proxy = NULL, *contact_params = NULL, *params = NULL, *register_transport = NULL; @@ -1164,6 +1165,8 @@ realm = val; } else if (!strcmp(var, "username")) { username = val; + } else if (!strcmp(var, "contact-username")) { + contact_user = val; } else if (!strcmp(var, "auth-username")) { auth_username = val; } else if (!strcmp(var, "password")) { @@ -1294,12 +1297,21 @@ gateway->register_from = switch_core_sprintf(gateway->pool, "", from_user, from_domain, register_transport); sipip = profile->extsipip ? profile->extsipip : profile->sipip; - format = strchr(sipip, ':') ? "" : ""; + if (contact_user) { + format = strchr(sipip, ':') ? "" : ""; + gateway->register_contact = switch_core_sprintf(gateway->pool, format, contact_user, + sipip, + sofia_glue_transport_has_tls(gateway->register_transport) ? + profile->tls_sip_port : profile->sip_port, params); + } else { + format = strchr(sipip, ':') ? "" : ""; + gateway->register_contact = switch_core_sprintf(gateway->pool, format, gateway->name, + sipip, + sofia_glue_transport_has_tls(gateway->register_transport) ? + profile->tls_sip_port : profile->sip_port, params); + } gateway->extension = switch_core_strdup(gateway->pool, extension); - gateway->register_contact = switch_core_sprintf(gateway->pool, format, gateway->name, - sipip, - sofia_glue_transport_has_tls(gateway->register_transport) ? - profile->tls_sip_port : profile->sip_port, params); + if (!strncasecmp(proxy, "sip:", 4)) { gateway->register_proxy = switch_core_strdup(gateway->pool, proxy); From anthm at freeswitch.org Sat Mar 7 08:03:44 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 10:03:44 -0600 Subject: [Freeswitch-svn] [commit] r12511 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Sat Mar 7 10:03:44 2009 New Revision: 12511 Log: nevermind contact_user param make it extension-in-contact for rare cases when provider makes you say a certian contact user 'LAME' Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sat Mar 7 10:03:44 2009 @@ -1075,7 +1075,7 @@ if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) { const char *sipip, *format; switch_uuid_t uuid; - uint32_t ping_freq = 0; + uint32_t ping_freq = 0, extension_in_contact = 0; char *register_str = "true", *scheme = "Digest", *realm = NULL, *username = NULL, @@ -1085,7 +1085,6 @@ *extension = NULL, *proxy = NULL, *context = profile->context, - *contact_user = NULL, *expire_seconds = "3600", *retry_seconds = "30", *from_user = "", *from_domain = "", *register_proxy = NULL, *contact_params = NULL, *params = NULL, *register_transport = NULL; @@ -1165,8 +1164,8 @@ realm = val; } else if (!strcmp(var, "username")) { username = val; - } else if (!strcmp(var, "contact-username")) { - contact_user = val; + } else if (!strcmp(var, "extension-in-contact")) { + extension_in_contact = switch_true(val); } else if (!strcmp(var, "auth-username")) { auth_username = val; } else if (!strcmp(var, "password")) { @@ -1297,9 +1296,9 @@ gateway->register_from = switch_core_sprintf(gateway->pool, "", from_user, from_domain, register_transport); sipip = profile->extsipip ? profile->extsipip : profile->sipip; - if (contact_user) { + if (extension_in_contact) { format = strchr(sipip, ':') ? "" : ""; - gateway->register_contact = switch_core_sprintf(gateway->pool, format, contact_user, + gateway->register_contact = switch_core_sprintf(gateway->pool, format, extension, sipip, sofia_glue_transport_has_tls(gateway->register_transport) ? profile->tls_sip_port : profile->sip_port, params); From anthm at freeswitch.org Sat Mar 7 08:39:19 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 10:39:19 -0600 Subject: [Freeswitch-svn] [commit] r12512 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sat Mar 7 10:39:18 2009 New Revision: 12512 Log: tweak Modified: freeswitch/trunk/src/switch_core_memory.c Modified: freeswitch/trunk/src/switch_core_memory.c ============================================================================== --- freeswitch/trunk/src/switch_core_memory.c (original) +++ freeswitch/trunk/src/switch_core_memory.c Sat Mar 7 10:39:18 2009 @@ -368,9 +368,7 @@ SWITCH_DECLARE(void) switch_core_memory_reclaim(void) { -#ifdef INSTANTLY_DESTROY_POOLS - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Recycled memory pool(s) disabled.\n"); -#else +#if !defined(PER_POOL_LOCK) && !defined(INSTANTLY_DESTROY_POOLS) switch_memory_pool_t *pool; void *pop = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled memory pool(s)\n", @@ -384,6 +382,7 @@ apr_pool_destroy(pool); } #endif + return; } static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t *thread, void *obj) From anthm at freeswitch.org Sat Mar 7 09:00:48 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 11:00:48 -0600 Subject: [Freeswitch-svn] [commit] r12513 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Sat Mar 7 11:00:48 2009 New Revision: 12513 Log: fix include Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Sat Mar 7 11:00:48 2009 @@ -36,7 +36,7 @@ /* Best viewed in a 160 x 60 VT100 Terminal or so the line below at least fits across your screen*/ /*************************************************************************************************************************************************************/ #include "mod_sofia.h" - +#include "sofia-sip/sip_extra.h" SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown); SWITCH_MODULE_DEFINITION(mod_sofia, mod_sofia_load, mod_sofia_shutdown, NULL); From mikej at freeswitch.org Sat Mar 7 09:35:39 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 11:35:39 -0600 Subject: [Freeswitch-svn] [commit] r12514 - in freeswitch/trunk/libs/spandsp/src: . spandsp Message-ID: Author: mikej Date: Sat Mar 7 11:35:39 2009 New Revision: 12514 Log: update to snapshot spandsp-20090308 Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_local.h freeswitch/trunk/libs/spandsp/src/spandsp/adsi.h freeswitch/trunk/libs/spandsp/src/spandsp/version.h Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_local.h ============================================================================== --- freeswitch/trunk/libs/spandsp/src/gsm0610_local.h (original) +++ freeswitch/trunk/libs/spandsp/src/gsm0610_local.h Sat Mar 7 11:35:39 2009 @@ -25,7 +25,7 @@ * This code is based on the widely used GSM 06.10 code available from * http://kbs.cs.tu-berlin.de/~jutta/toast.html * - * $Id: gsm0610_local.h,v 1.13 2009/01/16 15:49:59 steveu Exp $ + * $Id: gsm0610_local.h,v 1.14 2009/03/07 16:47:30 steveu Exp $ */ #if !defined(_GSM0610_LOCAL_H_) @@ -216,8 +216,6 @@ #if defined(__GNUC__) && defined(__i386__) -void gsm0610_vec_vsraw(const int16_t *p, int n, int bits); - int32_t gsm0610_vec_iprod(const int16_t *p, const int16_t *q, int n); int32_t gsm0610_vec_maxmin(const int16_t *p, int n, int16_t *out); Modified: freeswitch/trunk/libs/spandsp/src/spandsp/adsi.h ============================================================================== --- freeswitch/trunk/libs/spandsp/src/spandsp/adsi.h (original) +++ freeswitch/trunk/libs/spandsp/src/spandsp/adsi.h Sat Mar 7 11:35:39 2009 @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: adsi.h,v 1.36 2009/02/10 13:06:47 steveu Exp $ + * $Id: adsi.h,v 1.37 2009/03/04 12:15:15 steveu Exp $ */ /*! \file */ @@ -249,7 +249,7 @@ /*! Message waiting/not waiting */ #define MCLASS_VISUAL_INDICATOR 0x0B -/*! Definitions for CLIP (Calling Line Identity Presentation) */ +/*! Definitions for CLIP (Calling Line Identity Presentation) (from ETS 300 659-1) */ enum { /*! Multiple data message caller ID */ @@ -262,31 +262,37 @@ CLIP_MDMF_SMS = 0x89 }; -/*! CLIP message IDs */ +/*! CLIP message IDs (from ETS 300 659-1) */ enum { /*! Date and time (MMDDHHMM) */ CLIP_DATETIME = 0x01, - /*! Caller number */ + /*! Caller number (AKA calling line identity) */ CLIP_CALLER_NUMBER = 0x02, - /*! Dialed number */ + /*! Dialed number (AKA called line identity) */ CLIP_DIALED_NUMBER = 0x03, - /*! Caller number absent: 'O' or 'P' */ + /*! Caller number absent: 'O' or 'P' (AKA reason for absence of calling line identity) */ CLIP_ABSENCE1 = 0x04, - /*! Caller's name */ + /*! Caller's name (AKA calling party name) */ CLIP_CALLER_NAME = 0x07, - /*! Caller's name absent: 'O' or 'P' */ + /*! Caller's name absent: 'O' or 'P' (AKA reason for absence of calling party name) */ CLIP_ABSENCE2 = 0x08, /*! Visual indicator */ CLIP_VISUAL_INDICATOR = 0x0B, /*! Message ID */ CLIP_MESSAGE_ID = 0x0D, - /*! Voice call, ring-back-when-free call, or msg waiting call */ + /*! Complementary calling line identity */ + CLIP_COMPLEMENTARY_CALLER_NUMBER = 0x10, + /*! Call type - voice call (1), ring-back-when-free call (2), calling name delivery (3) or msg waiting call(0x81) */ CLIP_CALLTYPE = 0x11, /*! Number of messages */ CLIP_NUM_MSG = 0x13, + /*! Type of forwarded call */ + CLIP_TYPE_OF_FORWARDED_CALL = 0x15, + /*! Type of calling user */ + CLIP_TYPE_OF_CALLING_USER = 0x16, /*! Redirecting number */ - CLIP_REDIR_NUMBER = 0x03, + CLIP_REDIR_NUMBER = 0x1A, /*! Charge */ CLIP_CHARGE = 0x20, /*! Duration of the call */ Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h ============================================================================== --- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original) +++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Sat Mar 7 11:35:39 2009 @@ -30,9 +30,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20090301 -#define SPANDSP_RELEASE_TIME 125126 -#define SPANDSP_RELEASE_DATETIME_STRING "20090301 125126" +#define SPANDSP_RELEASE_DATE 20090307 +#define SPANDSP_RELEASE_TIME 165620 +#define SPANDSP_RELEASE_DATETIME_STRING "20090307 165620" #endif /*- End of file ------------------------------------------------------------*/ From anthm at freeswitch.org Sat Mar 7 09:45:37 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 11:45:37 -0600 Subject: [Freeswitch-svn] [commit] r12515 - in freeswitch/trunk/src: . include/private Message-ID: Author: anthm Date: Sat Mar 7 11:45:37 2009 New Revision: 12515 Log: separate throttle mutex from session hash mutex Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h freeswitch/trunk/src/switch_core.c freeswitch/trunk/src/switch_core_session.c Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h ============================================================================== --- freeswitch/trunk/src/include/private/switch_core_pvt.h (original) +++ freeswitch/trunk/src/include/private/switch_core_pvt.h Sat Mar 7 11:45:37 2009 @@ -190,6 +190,7 @@ uint32_t flags; switch_time_t timestamp; switch_mutex_t *throttle_mutex; + switch_mutex_t *session_hash_mutex; switch_mutex_t *global_mutex; switch_mutex_t *global_var_mutex; uint32_t sps_total; Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Sat Mar 7 11:45:37 2009 @@ -1064,6 +1064,7 @@ switch_mutex_init(&runtime.throttle_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool); + switch_mutex_init(&runtime.session_hash_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool); switch_mutex_init(&runtime.global_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool); switch_mutex_init(&runtime.global_var_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool); switch_core_set_globals(); Modified: freeswitch/trunk/src/switch_core_session.c ============================================================================== --- freeswitch/trunk/src/switch_core_session.c (original) +++ freeswitch/trunk/src/switch_core_session.c Sat Mar 7 11:45:37 2009 @@ -53,7 +53,7 @@ switch_core_session_t *session = NULL; if (uuid_str) { - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) { /* Acquire a read lock on the session */ #ifdef SWITCH_DEBUG_RWLOCKS @@ -68,7 +68,7 @@ session = NULL; } } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); } /* if its not NULL, now it's up to you to rwunlock this */ @@ -84,7 +84,7 @@ if (!var_val) return; - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); if (val) { @@ -99,7 +99,7 @@ } } } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); } SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause) @@ -108,7 +108,7 @@ void *val; switch_core_session_t *session; - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); if (val) { @@ -121,7 +121,7 @@ } } } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); } SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause) @@ -132,7 +132,7 @@ uint32_t loops = 0; while (session_manager.session_count > 0) { - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); if (val) { @@ -143,7 +143,7 @@ } } } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); switch_yield(1000000); if (++loops == 30) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Giving up with %d session%s remaining\n", @@ -159,7 +159,7 @@ switch_core_session_t *session = NULL; switch_status_t status = SWITCH_STATUS_FALSE; - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); if ((session = switch_core_hash_find(session_manager.session_table, uuid_str)) != 0) { /* Acquire a read lock on the session or forget it the channel is dead */ if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { @@ -169,7 +169,7 @@ switch_core_session_rwunlock(session); } } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); return status; } @@ -179,7 +179,7 @@ switch_core_session_t *session = NULL; switch_status_t status = SWITCH_STATUS_FALSE; - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); if ((session = switch_core_hash_find(session_manager.session_table, uuid_str)) != 0) { /* Acquire a read lock on the session or forget it the channel is dead */ if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { @@ -189,7 +189,7 @@ switch_core_session_rwunlock(session); } } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); return status; } @@ -847,12 +847,12 @@ switch_scheduler_del_task_group((*session)->uuid_str); - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); switch_core_hash_delete(session_manager.session_table, (*session)->uuid_str); if (session_manager.session_count) { session_manager.session_count--; } - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data((*session)->channel, event); @@ -1030,11 +1030,11 @@ switch_event_create(&event, SWITCH_EVENT_CHANNEL_UUID); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Old-Unique-ID", session->uuid_str); - switch_mutex_lock(runtime.throttle_mutex); + switch_mutex_lock(runtime.session_hash_mutex); switch_core_hash_delete(session_manager.session_table, session->uuid_str); switch_set_string(session->uuid_str, use_uuid); switch_core_hash_insert(session_manager.session_table, session->uuid_str, session); - switch_mutex_unlock(runtime.throttle_mutex); + switch_mutex_unlock(runtime.session_hash_mutex); switch_channel_event_set_data(session->channel, event); switch_event_fire(&event); @@ -1136,12 +1136,13 @@ switch_queue_create(&session->message_queue, SWITCH_MESSAGE_QUEUE_LEN, session->pool); switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool); switch_queue_create(&session->private_event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool); - switch_mutex_lock(runtime.throttle_mutex); - session->id = session_manager.session_id++; + + switch_mutex_lock(runtime.session_hash_mutex); switch_core_hash_insert(session_manager.session_table, session->uuid_str, session); + session->id = session_manager.session_id++; session_manager.session_count++; - switch_mutex_unlock(runtime.throttle_mutex); - + switch_mutex_unlock(runtime.session_hash_mutex); + return session; } From nicholas at freeswitch.org Sat Mar 7 10:45:27 2009 From: nicholas at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 12:45:27 -0600 Subject: [Freeswitch-svn] [commit] r12516 - freeswitch/trunk/debian Message-ID: Author: nicholas Date: Sat Mar 7 12:45:27 2009 New Revision: 12516 Log: openzap issue related in the issue FSBUILD-127 fixed Modified: freeswitch/trunk/debian/freeswitch.install Modified: freeswitch/trunk/debian/freeswitch.install ============================================================================== --- freeswitch/trunk/debian/freeswitch.install (original) +++ freeswitch/trunk/debian/freeswitch.install Sat Mar 7 12:45:27 2009 @@ -32,12 +32,12 @@ opt/freeswitch/mod/mod_portaudio.so* opt/freeswitch/mod/mod_sofia.so* opt/freeswitch/mod/mod_openzap.so -opt/freeswitch/mod/ozmod_analog_em.so -opt/freeswitch/mod/ozmod_analog.so -opt/freeswitch/mod/ozmod_isdn.so +opt/freeswitch/mod/ozmod_analog_em.so* +opt/freeswitch/mod/ozmod_analog.so* +opt/freeswitch/mod/ozmod_isdn.so* opt/freeswitch/mod/ozmod_ss7_boost.so -opt/freeswitch/mod/ozmod_wanpipe.so -opt/freeswitch/mod/ozmod_zt.so +opt/freeswitch/mod/ozmod_wanpipe.so* +opt/freeswitch/mod/ozmod_zt.so* opt/freeswitch/mod/mod_event_*.so* opt/freeswitch/mod/mod_native_file.so* opt/freeswitch/mod/mod_sndfile.so* @@ -53,6 +53,7 @@ opt/freeswitch/conf/tetris.ttml opt/freeswitch/conf/fur_elise.ttml opt/freeswitch/conf/openzap.conf +opt/freeswitch/conf/wanpipe.conf opt/freeswitch/conf/dialplan/public.xml opt/freeswitch/conf/dialplan/default.xml opt/freeswitch/conf/dialplan/features.xml @@ -89,6 +90,7 @@ opt/freeswitch/conf/voicemail.tpl opt/freeswitch/conf/freeswitch.xml opt/freeswitch/conf/extensions.conf +opt/freeswitch/conf/autoload_configs/openzap.conf.xml opt/freeswitch/conf/autoload_configs/ivr.conf.xml opt/freeswitch/conf/autoload_configs/shout.conf.xml opt/freeswitch/conf/autoload_configs/voicemail.conf.xml From silik0n at freeswitch.org Sat Mar 7 21:36:39 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 23:36:39 -0600 Subject: [Freeswitch-svn] [commit] r12517 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Sat Mar 7 23:36:39 2009 New Revision: 12517 Log: make the conference data more prettier and easier to use Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sat Mar 7 23:36:39 2009 @@ -76,11 +76,31 @@ $y=0; foreach($data as $row){ if ($row!="" && substr($row, 0, 10) != "Conference"){ - $conf_data[$y] = explode(";", $row); + $temp_data = explode(";", $row); + $conf_data[$y]['id'] = $temp_data[0]; + $conf_data[$y]['channel'] = $temp_data[1]; + $conf_data[$y]['uuid'] = $temp_data[2]; + $conf_data[$y]['caller_name'] = $temp_data[3]; + $conf_data[$y]['caller_number'] = $temp_data[4]; + $conf_data[$y]['flags'] = $temp_data[5]; + $conf_data[$y]['gain'] = $temp_data[6]; + $conf_data[$y]['volume'] = $temp_data[7]; + $conf_data[$y]['noise'] = $temp_data[8]; + $conf_data[$y]['hear'] = 0; + $conf_data[$y]['speak'] = 0; + $conf_data[$y]['talk'] = 0; + $conf_data[$y]['video'] = 0; + $temp_flags = explode("|", $temp_data[5]); + foreach ($temp_flags as $flag){ + if ($flag == "hear") $conf_data[$y]['hear'] = 1; + if ($flag == "speak") $conf_data[$y]['speak'] = 1; + if ($flag == "talk") $conf_data[$y]['talk'] = 1; + if ($flag == "video") $conf_data[$y]['video'] = 1; + } + $y++; } } - return $conf_data; } From silik0n at freeswitch.org Sat Mar 7 21:37:11 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 23:37:11 -0600 Subject: [Freeswitch-svn] [commit] r12518 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com Message-ID: Author: silik0n Date: Sat Mar 7 23:37:10 2009 New Revision: 12518 Log: get rid of unused code Removed: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/ From silik0n at freeswitch.org Sat Mar 7 21:39:39 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 23:39:39 -0600 Subject: [Freeswitch-svn] [commit] r12519 - in freeswitch/trunk/scripts/contrib/swk/flex/amf-test1: bin-debug src Message-ID: Author: silik0n Date: Sat Mar 7 23:39:39 2009 New Revision: 12519 Log: add working auto refreshing conference monitor, add originate form and make it work, add a few buttons for future use Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/playerProductInstall.swf (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/originateForm.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/playerProductInstall.swf ============================================================================== Binary file. No diff available. Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sat Mar 7 23:39:39 2009 @@ -3,32 +3,60 @@ @@ -36,12 +64,10 @@ - - + - - + @@ -55,11 +81,15 @@ - - - + + + + + + + - + @@ -69,37 +99,42 @@ - + - - - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/originateForm.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/originateForm.mxml Sat Mar 7 23:39:39 2009 @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From silik0n at freeswitch.org Sat Mar 7 21:43:37 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 23:43:37 -0600 Subject: [Freeswitch-svn] [commit] r12520 - freeswitch/trunk/scripts/contrib/swk Message-ID: Author: silik0n Date: Sat Mar 7 23:43:37 2009 New Revision: 12520 Log: Start A README File Added: freeswitch/trunk/scripts/contrib/swk/README Added: freeswitch/trunk/scripts/contrib/swk/README ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/README Sat Mar 7 23:43:37 2009 @@ -0,0 +1,3 @@ +for the Flex stuff you need the amf-php lib and the thing amf-php/freeswitch.php module + +more stuff coming in here soon From mrene at freeswitch.org Sat Mar 7 21:43:51 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Mar 2009 23:43:51 -0600 Subject: [Freeswitch-svn] [commit] r12521 - freeswitch/trunk/src Message-ID: Author: mrene Date: Sat Mar 7 23:43:51 2009 New Revision: 12521 Log: RLIMIT_RTPID isnt defined on OSX Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Sat Mar 7 23:43:51 2009 @@ -809,7 +809,10 @@ setrlimit(RLIMIT_DATA, &rlp); setrlimit(RLIMIT_FSIZE, &rlp); setrlimit(RLIMIT_NPROC, &rlp); +#ifdef RLIMIT_RTPRIO setrlimit(RLIMIT_RTPRIO, &rlp); +#endif + #if !defined(__OpenBSD__) && !defined(__NetBSD__) setrlimit(RLIMIT_AS, &rlp); #endif From silik0n at freeswitch.org Sun Mar 8 00:36:02 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 03:36:02 -0500 Subject: [Freeswitch-svn] [commit] r12522 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src Message-ID: Author: silik0n Date: Sun Mar 8 03:36:02 2009 New Revision: 12522 Log: dont specify the full URL and we will use the same HTTP server the flex was loaded from. This prevents running off the file system Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sun Mar 8 03:36:02 2009 @@ -62,7 +62,7 @@ + endpoint="/feeder/gateway.php" showBusyCursor="true"/> From silik0n at freeswitch.org Sun Mar 8 01:30:41 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 04:30:41 -0500 Subject: [Freeswitch-svn] [commit] r12523 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src Message-ID: Author: silik0n Date: Sun Mar 8 04:30:41 2009 New Revision: 12523 Log: make some buttons works, add a switch status popup form. Ok boys and Girls I am pretty much done with this outside of implementing the rest of the buttons on conference tab. Anyone have any suggestions or patches they want to send my way on it? Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/statusForm.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sun Mar 8 04:30:41 2009 @@ -56,6 +56,12 @@ var origWindow:IFlexDisplayObject = PopUpManager.createPopUp(this, originateForm, false); } + public function doStatusForm():void { + var origWindow:IFlexDisplayObject = + PopUpManager.createPopUp(this, statusForm, false); + } + + ]]> @@ -66,9 +72,9 @@ - - - + + + @@ -79,15 +85,17 @@ - + + + + - - - + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/statusForm.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/statusForm.mxml Sun Mar 8 04:30:41 2009 @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + \ No newline at end of file From gmaruzz at freeswitch.org Sun Mar 8 08:31:45 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 10:31:45 -0500 Subject: [Freeswitch-svn] [commit] r12524 - freeswitch/trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Mar 8 10:31:45 2009 New Revision: 12524 Log: skypiax: don't warns about TRANSFERRING and TRANSFERRED states Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Sun Mar 8 10:31:45 2009 @@ -341,6 +341,10 @@ /* we're here because were us that refused an incoming call */ DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id); } + } else if (!strcasecmp(value, "TRANSFERRING")) { + DEBUGA_SKYPE("skype_call %s is transferring\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "TRANSFERRED")) { + DEBUGA_SKYPE("skype_call %s has been transferred\n", SKYPIAX_P_LOG, id); } else if (!strcasecmp(value, "ROUTING")) { tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; tech_pvt->interface_state = SKYPIAX_STATE_DIALING; From mrene at freeswitch.org Sun Mar 8 13:29:33 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 15:29:33 -0500 Subject: [Freeswitch-svn] [commit] r12525 - freeswitch/trunk/libs/esl/src Message-ID: Author: mrene Date: Sun Mar 8 15:29:32 2009 New Revision: 12525 Log: ESL-5 Modified: freeswitch/trunk/libs/esl/src/esl.c Modified: freeswitch/trunk/libs/esl/src/esl.c ============================================================================== --- freeswitch/trunk/libs/esl/src/esl.c (original) +++ freeswitch/trunk/libs/esl/src/esl.c Sun Mar 8 15:29:32 2009 @@ -912,7 +912,7 @@ esl_event_del_header(handle->last_ievent, "event-name"); } esl_event_add_header_string(handle->last_ievent, ESL_STACK_BOTTOM, hname, hval); - esl_name_event(hval, &handle->last_event->event_id); + esl_name_event(hval, &handle->last_ievent->event_id); } beg = c + 1; From mrene at freeswitch.org Sun Mar 8 13:43:23 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 15:43:23 -0500 Subject: [Freeswitch-svn] [commit] r12526 - in freeswitch/trunk/libs/esl/src: . include Message-ID: Author: mrene Date: Sun Mar 8 15:43:22 2009 New Revision: 12526 Log: add const spec to Event::getHeader()'s param Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp freeswitch/trunk/libs/esl/src/include/esl_oop.h Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Sun Mar 8 15:43:22 2009 @@ -327,7 +327,7 @@ return false; } -const char *ESLevent::getHeader(char *header_name) +const char *ESLevent::getHeader(const char *header_name) { this_check(""); Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Sun Mar 8 15:43:22 2009 @@ -57,7 +57,7 @@ virtual ~ESLevent(); const char *serialize(const char *format = NULL); bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL); - const char *getHeader(char *header_name); + const char *getHeader(const char *header_name); char *getBody(void); const char *getType(void); bool addBody(const char *value); From mrene at freeswitch.org Sun Mar 8 13:45:18 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 15:45:18 -0500 Subject: [Freeswitch-svn] [commit] r12527 - in freeswitch/trunk/libs/esl: . src Message-ID: Author: mrene Date: Sun Mar 8 15:45:18 2009 New Revision: 12527 Log: remove unused var Modified: freeswitch/trunk/libs/esl/Makefile freeswitch/trunk/libs/esl/src/esl_oop.cpp Modified: freeswitch/trunk/libs/esl/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/Makefile (original) +++ freeswitch/trunk/libs/esl/Makefile Sun Mar 8 15:45:18 2009 @@ -5,7 +5,7 @@ BASE_FLAGS=$(INCS) -DHAVE_EDITLINE $(DEBUG) -I$(LIBEDIT_DIR)/src/ -fPIC PICKY=-O2 -ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes CFLAGS=$(BASE_FLAGS) $(PICKY) -CXXFLAGS=$(BASE_FLAGS) +CXXFLAGS=$(BASE_FLAGS) -Wall -Werror MYLIB=libesl.a LIBS=-lncurses -lpthread -lesl LDFLAGS=-L. Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Sun Mar 8 15:45:18 2009 @@ -296,8 +296,6 @@ const char *ESLevent::serialize(const char *format) { - int isxml = 0; - this_check(""); esl_safe_free(serialized_string); From mrene at freeswitch.org Sun Mar 8 14:53:02 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 16:53:02 -0500 Subject: [Freeswitch-svn] [commit] r12528 - freeswitch/trunk/src/mod/applications/mod_skel Message-ID: Author: mrene Date: Sun Mar 8 16:53:02 2009 New Revision: 12528 Log: update mod_skel config example Modified: freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c Modified: freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c (original) +++ freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c Sun Mar 8 16:53:02 2009 @@ -83,10 +83,14 @@ static switch_xml_config_item_t instructions[] = { /* parameter name type reloadable pointer default value options structure */ - SWITCH_CONFIG_ITEM("codec-negotiation-str", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.codec_negotiation_str, "greedy", &config_opt_codec_negotiation), - SWITCH_CONFIG_ITEM("codec-negotiation", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.codec_negotiation, (void*)CODEC_NEGOTIATION_GREEDY, &config_opt_codec_negotiation_enum), - SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void*)SWITCH_FALSE, config_callback_siptrace, NULL ), - SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE | CONFIG_REQUIRED, &globals.integer, (void*)100, &config_opt_integer), + SWITCH_CONFIG_ITEM("codec-negotiation-str", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.codec_negotiation_str, "greedy", &config_opt_codec_negotiation, \ + "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."), + SWITCH_CONFIG_ITEM("codec-negotiation", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.codec_negotiation, (void*)CODEC_NEGOTIATION_GREEDY, &config_opt_codec_negotiation_enum, + "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."), + SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void*)SWITCH_FALSE, config_callback_siptrace, NULL , + "yes|no", "If enabled, print out sip messages on the console."), + SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE | CONFIG_REQUIRED, &globals.integer, (void*)100, &config_opt_integer, + NULL, NULL), SWITCH_CONFIG_ITEM_END() }; From intralanman at freeswitch.org Sun Mar 8 17:36:03 2009 From: intralanman at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Mar 2009 19:36:03 -0500 Subject: [Freeswitch-svn] [commit] r12529 - freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv Message-ID: Author: intralanman Date: Sun Mar 8 19:36:03 2009 New Revision: 12529 Log: adding cdr importer... Added: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/ freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer Added: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer Sun Mar 8 19:36:03 2009 @@ -0,0 +1,90 @@ +#!/usr/bin/perl + +use DBI; +use Data::Dumper; + +$config->{connect_string} = 'DBI:mysql:freeswitch'; +$config->{username} = 'root'; +$config->{password} = ''; +$config->{table} = "cdrs"; +$config->{fields} = [ + "caller_id_name", + "caller_id_number", + "destination_number", + "context", + "start_stamp", + "answer_stamp", + "end_stamp", + "duration", + "billsec", + "hangup_cause", + "uuid", + "bleg_uuid", + "accountcode", + "read_codec", + "write_codec", + ]; + +sub create_table { + my $db = shift; + my $sql = "CREATE TABLE IF NOT EXISTS`cdrs` ( + `id` int(11) NOT NULL auto_increment, + `caller_id_name` varchar(255) NOT NULL default '', + `caller_id_number` varchar(255) NOT NULL default '', + `destination_number` varchar(255) NOT NULL default '', + `context` varchar(255) NOT NULL default '', + `start_stamp` varchar(255) NOT NULL default '', + `answer_stamp` varchar(255) NOT NULL default '', + `end_stamp` varchar(255) NOT NULL default '', + `duration` varchar(255) NOT NULL default '', + `billsec` varchar(255) NOT NULL default '', + `hangup_cause` varchar(255) NOT NULL default '', + `uuid` varchar(255) NOT NULL default '', + `bleg_uuid` varchar(255) NOT NULL default '', + `accountcode` varchar(255) NOT NULL default '', + `read_codec` varchar(255) NOT NULL default '', + `write_codec` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE KEY `uuid` (`uuid`) +) ENGINE=InnoDB"; + $db->do($sql); + if (!$db->{Executed}) { + die("We couldn't CREATE the DB table\n"); + } +} + +sub connect_db { + return DBI->connect($config->{connect_string}, $config->{username}, $config->{password}); +} + +sub is_db_connected { + $query = $db->prepare("SELECT CURRENT_TIMESTAMP;"); + $query->execute(); +} + +my $db = &connect_db; +&create_table($db); +$field_count = @{$config->{fields}}; +my $values = '?'; +my $fields = $config->{fields}[0]; +for ($i=1; $i<$field_count; $i++) { + $fields = sprintf('%s, %s', $fields, $config->{fields}[$i]); + $values = sprintf('%s, ?', $values); +} +#print "$field_count - $fields $values\n"; + + +my $query = sprintf( + "INSERT INTO %s (%s) VALUES (%s);", + $config->{table}, join(',', @{$config->{fields}}), $values + ); +#print "$query\n"; + +my $query_handle = $db->prepare($query); +while () { + print $_; + chomp; + @values = split(/,/); + #print Dumper @values; + $query_handle->execute(@values); +} From intralanman at freeswitch.org Sun Mar 8 22:38:45 2009 From: intralanman at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 00:38:45 -0500 Subject: [Freeswitch-svn] [commit] r12530 - freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv Message-ID: Author: intralanman Date: Mon Mar 9 00:38:45 2009 New Revision: 12530 Log: adding config file to hold configurables and logging to syslog now Added: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer.ini Modified: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer Modified: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer (original) +++ freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer Mon Mar 9 00:38:45 2009 @@ -2,32 +2,37 @@ use DBI; use Data::Dumper; +use Sys::Syslog; -$config->{connect_string} = 'DBI:mysql:freeswitch'; -$config->{username} = 'root'; -$config->{password} = ''; -$config->{table} = "cdrs"; -$config->{fields} = [ - "caller_id_name", - "caller_id_number", - "destination_number", - "context", - "start_stamp", - "answer_stamp", - "end_stamp", - "duration", - "billsec", - "hangup_cause", - "uuid", - "bleg_uuid", - "accountcode", - "read_codec", - "write_codec", - ]; +my $config={}; +my $db; +my $identifier = 'cdr-csv-importer'; + +sub parse_config { + open(CONFIG, ") { + #print $_; + chomp; #kill whitespaces + + next if !(m/^[[:alnum:]]/); #skip lines that don't start right + next if m/^\s*$/; #skip lines with only whitespace + next if m/^;/; #skip ini comments + next if m(/^\[.*\]/); # skip the start of a section + + my ($key, $val) = split(/\s+=\s+/, $_, 2); + #print "'$key' = '$val'\n"; + if($key eq "fields") { + @{$config->{fields}} = split(/,/, $val); + } else { + $config->{$key} = $val; + } + } + close(CONFIG); +} sub create_table { - my $db = shift; - my $sql = "CREATE TABLE IF NOT EXISTS`cdrs` ( +# my $db = shift; + my $sql = "CREATE TABLE IF NOT EXISTS `$config->{table}` ( `id` int(11) NOT NULL auto_increment, `caller_id_name` varchar(255) NOT NULL default '', `caller_id_number` varchar(255) NOT NULL default '', @@ -62,7 +67,14 @@ $query->execute(); } -my $db = &connect_db; +openlog($identifier, 'ndelay,pid', LOG_USER); +open(STDERR,"|logger -t \"${identifier}[$$]: \"") or die "Error: Unable to redirect STDERR to logger!"; +open(STDOUT,"|logger -t \"${identifier}[$$]: \"") or die "Error: Unable to redirect STDOUT to logger!"; +&parse_config; +#print Dumper $config; +open(PID, ">$config->{pid_file}"); +print PID $$; +$db = &connect_db; &create_table($db); $field_count = @{$config->{fields}}; my $values = '?'; @@ -71,18 +83,23 @@ $fields = sprintf('%s, %s', $fields, $config->{fields}[$i]); $values = sprintf('%s, ?', $values); } -#print "$field_count - $fields $values\n"; my $query = sprintf( "INSERT INTO %s (%s) VALUES (%s);", $config->{table}, join(',', @{$config->{fields}}), $values ); -#print "$query\n"; +syslog(LOG_INFO, "$query"); + +sub mylog { + $log = shift; + syslog(LOG_INFO, "$log"); +} +print Dumper @ARGV; my $query_handle = $db->prepare($query); while () { - print $_; + syslog(LOG_INFO, $_); chomp; @values = split(/,/); #print Dumper @values; Added: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer.ini ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/cdr-csv-importer.ini Mon Mar 9 00:38:45 2009 @@ -0,0 +1,7 @@ +[default] +table = cdrs +username = freeswitch +password = Fr33Sw1tch +connect_string = DBI:mysql:freeswitch +pid_file = /var/run/cdr-csv-importer.pid +fields = caller_id_name,caller_id_number,destination_number,context,start_stamp,answer_stamp,end_stamp,duration,billsec,hangup_cause,uuid,bleg_uuid,accountcode,read_codec,write_codec From anthm at freeswitch.org Mon Mar 9 08:02:04 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 10:02:04 -0500 Subject: [Freeswitch-svn] [commit] r12531 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Mon Mar 9 10:02:04 2009 New Revision: 12531 Log: add contact-host param to gateways Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Mar 9 10:02:04 2009 @@ -1087,7 +1087,8 @@ *context = profile->context, *expire_seconds = "3600", *retry_seconds = "30", - *from_user = "", *from_domain = "", *register_proxy = NULL, *contact_params = NULL, *params = NULL, *register_transport = NULL; + *from_user = "", *from_domain = "", *register_proxy = NULL, *contact_host = NULL, + *contact_params = NULL, *params = NULL, *register_transport = NULL; if (!context) { context = "default"; @@ -1190,6 +1191,8 @@ from_user = val; } else if (!strcmp(var, "from-domain")) { from_domain = val; + } else if (!strcmp(var, "contact-host")) { + contact_host = val; } else if (!strcmp(var, "register-proxy")) { register_proxy = val; } else if (!strcmp(var, "contact-params")) { @@ -1295,7 +1298,7 @@ gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s;transport=%s", proxy, register_transport); gateway->register_from = switch_core_sprintf(gateway->pool, "", from_user, from_domain, register_transport); - sipip = profile->extsipip ? profile->extsipip : profile->sipip; + sipip = contact_host ? contact_host : profile->extsipip ? profile->extsipip : profile->sipip; if (extension_in_contact) { format = strchr(sipip, ':') ? "" : ""; gateway->register_contact = switch_core_sprintf(gateway->pool, format, extension, From mrene at freeswitch.org Mon Mar 9 08:25:06 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 10:25:06 -0500 Subject: [Freeswitch-svn] [commit] r12532 - freeswitch/trunk/src/mod/applications/mod_limit Message-ID: Author: mrene Date: Mon Mar 9 10:25:05 2009 New Revision: 12532 Log: why didnt that work Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Mon Mar 9 10:25:05 2009 @@ -169,7 +169,7 @@ return ret; } -static switch_xml_config_string_options_t limit_config_dsn = { NULL, 0, "(.+?):(.+?):(.+)" }; +static switch_xml_config_string_options_t limit_config_dsn = { NULL, 0, "[^:]+:[^:]+:[^:]+" }; static switch_xml_config_item_t config_settings[] = { SWITCH_CONFIG_ITEM("odbc-dsn", SWITCH_CONFIG_STRING, 0, &globals.odbc_dsn, NULL, &limit_config_dsn, @@ -203,7 +203,7 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); #endif } - + if (switch_strlen_zero(globals.odbc_dsn) || switch_strlen_zero(odbc_user) || switch_strlen_zero(odbc_pass)) { globals.dbname = "call_limit"; From anthm at freeswitch.org Mon Mar 9 09:11:03 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 11:11:03 -0500 Subject: [Freeswitch-svn] [commit] r12533 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 9 11:11:03 2009 New Revision: 12533 Log: FSCORE-325 Modified: freeswitch/trunk/src/switch.c Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Mon Mar 9 11:11:03 2009 @@ -628,7 +628,7 @@ rlp.rlim_max = SWITCH_THREAD_STACKSIZE; setrlimit(RLIMIT_STACK, &rlp); fprintf(stderr, "Error: stacksize %ld is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance....\n", - rlp.rlim_max / 1024, SWITCH_THREAD_STACKSIZE / 1024, argv[0]); + (int)(rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, argv[0]); apr_terminate(); ret = (int)execv(argv[0], argv); From anthm at freeswitch.org Mon Mar 9 09:17:01 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 11:17:01 -0500 Subject: [Freeswitch-svn] [commit] r12534 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 9 11:17:01 2009 New Revision: 12534 Log: FSCORE-326 Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Mon Mar 9 11:17:01 2009 @@ -808,7 +808,9 @@ setrlimit(RLIMIT_CPU, &rlp); setrlimit(RLIMIT_DATA, &rlp); setrlimit(RLIMIT_FSIZE, &rlp); +#ifdef RLIMIT_NPROC setrlimit(RLIMIT_NPROC, &rlp); +#endif #ifdef RLIMIT_RTPRIO setrlimit(RLIMIT_RTPRIO, &rlp); #endif From brian at freeswitch.org Mon Mar 9 09:36:57 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 11:36:57 -0500 Subject: [Freeswitch-svn] [commit] r12535 - freeswitch/trunk/src Message-ID: Author: brian Date: Mon Mar 9 11:36:56 2009 New Revision: 12535 Log: fix MODENDP-196 Modified: freeswitch/trunk/src/switch_loadable_module.c Modified: freeswitch/trunk/src/switch_loadable_module.c ============================================================================== --- freeswitch/trunk/src/switch_loadable_module.c (original) +++ freeswitch/trunk/src/switch_loadable_module.c Mon Mar 9 11:36:56 2009 @@ -433,6 +433,11 @@ } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleting Endpoint '%s'\n", ptr->interface_name); + if (switch_event_create(&event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "endpoint"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "name", ptr->interface_name); + switch_event_fire(&event); + } switch_core_hash_delete(loadable_modules.endpoint_hash, ptr->interface_name); } } From mrene at freeswitch.org Mon Mar 9 10:25:52 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 12:25:52 -0500 Subject: [Freeswitch-svn] [commit] r12536 - freeswitch/trunk/src/mod/applications/mod_limit Message-ID: Author: mrene Date: Mon Mar 9 12:25:52 2009 New Revision: 12536 Log: tweak Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Mon Mar 9 12:25:52 2009 @@ -169,7 +169,7 @@ return ret; } -static switch_xml_config_string_options_t limit_config_dsn = { NULL, 0, "[^:]+:[^:]+:[^:]+" }; +static switch_xml_config_string_options_t limit_config_dsn = { NULL, 0, "[^:]+:[^:]+:.+" }; static switch_xml_config_item_t config_settings[] = { SWITCH_CONFIG_ITEM("odbc-dsn", SWITCH_CONFIG_STRING, 0, &globals.odbc_dsn, NULL, &limit_config_dsn, From anthm at freeswitch.org Mon Mar 9 10:47:42 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 12:47:42 -0500 Subject: [Freeswitch-svn] [commit] r12537 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 9 12:47:42 2009 New Revision: 12537 Log: update Modified: freeswitch/trunk/src/switch.c Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Mon Mar 9 12:47:42 2009 @@ -627,7 +627,7 @@ rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; rlp.rlim_max = SWITCH_THREAD_STACKSIZE; setrlimit(RLIMIT_STACK, &rlp); - fprintf(stderr, "Error: stacksize %ld is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance....\n", + fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance....\n", (int)(rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, argv[0]); apr_terminate(); ret = (int)execv(argv[0], argv); From anthm at freeswitch.org Mon Mar 9 11:43:17 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 13:43:17 -0500 Subject: [Freeswitch-svn] [commit] r12538 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 9 13:43:17 2009 New Revision: 12538 Log: I guess we have to leave this for lusers Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Mon Mar 9 13:43:17 2009 @@ -792,7 +792,7 @@ #ifndef __FreeBSD__ memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlp.rlim_max = SWITCH_THREAD_STACKSIZE; + rlp.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; setrlimit(RLIMIT_STACK, &rlp); #endif From brian at freeswitch.org Mon Mar 9 11:47:37 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 13:47:37 -0500 Subject: [Freeswitch-svn] [commit] r12539 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Mon Mar 9 13:47:37 2009 New Revision: 12539 Log: fix dialog to skip cs_reporting Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Mon Mar 9 13:47:37 2009 @@ -1103,7 +1103,7 @@ dft_state = "confirmed"; } - if (!strcasecmp(state, "cs_execute") && !strstr(event_status, "hold")) { + if ((!strcasecmp(state, "cs_execute") && !strstr(event_status, "hold")) || !strcasecmp(state, "cs_reporting")) { goto end; } From mikej at freeswitch.org Mon Mar 9 12:42:41 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 14:42:41 -0500 Subject: [Freeswitch-svn] [commit] r12540 - freeswitch/trunk/libs/win32/flite Message-ID: Author: mikej Date: Mon Mar 9 14:42:41 2009 New Revision: 12540 Log: build: removal of file reference for flite (FSBUILD-139) Modified: freeswitch/trunk/libs/win32/flite/flite.2008.vcproj Modified: freeswitch/trunk/libs/win32/flite/flite.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/win32/flite/flite.2008.vcproj (original) +++ freeswitch/trunk/libs/win32/flite/flite.2008.vcproj Mon Mar 9 14:42:41 2009 @@ -888,10 +888,6 @@ > - - From mikej at freeswitch.org Mon Mar 9 12:45:30 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 14:45:30 -0500 Subject: [Freeswitch-svn] [commit] r12541 - in freeswitch/trunk/libs/win32: . pocketsphinx Message-ID: Author: mikej Date: Mon Mar 9 14:45:30 2009 New Revision: 12541 Log: build: re-work windows build for latest pocketsphinx 5.1 (MODASRTTS-13) Modified: freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj freeswitch/trunk/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj Modified: freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj (original) +++ freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj Mon Mar 9 14:45:30 2009 @@ -75,7 +75,7 @@ Modified: freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj (original) +++ freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj Mon Mar 9 14:45:30 2009 @@ -75,7 +75,7 @@ Modified: freeswitch/trunk/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj (original) +++ freeswitch/trunk/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj Mon Mar 9 14:45:30 2009 @@ -485,6 +485,10 @@ > + + @@ -1009,6 +1013,10 @@ > + + Author: anthm Date: Mon Mar 9 14:48:17 2009 New Revision: 12542 Log: dont fire presence event for the reporting state Modified: freeswitch/trunk/src/switch_channel.c Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Mon Mar 9 14:48:17 2009 @@ -968,7 +968,7 @@ switch_channel_clear_flag(channel, CF_TAGGED); - if (channel->state >= CS_ROUTING) { + if (channel->state >= CS_ROUTING && channel->state <= CS_HANGUP) { switch_channel_presence(channel, "unknown", (char *) state_names[state], NULL); } From andrew at freeswitch.org Mon Mar 9 13:22:42 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 15:22:42 -0500 Subject: [Freeswitch-svn] [commit] r12543 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 9 15:22:42 2009 New Revision: 12543 Log: Some more memory management tweaks Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Mon Mar 9 15:22:42 2009 @@ -165,20 +165,47 @@ static switch_status_t handle_msg_fetch_reply(listener_t *listener, ei_x_buff *buf, ei_x_buff *rbuf) { char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; + void *p; if (ei_decode_string_or_binary(buf->buff, &buf->index, SWITCH_UUID_FORMATTED_LENGTH, uuid_str)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); } else { - ei_x_buff *nbuf = switch_core_alloc(listener->pool, sizeof(nbuf)); - nbuf->buff = switch_core_alloc(listener->pool, buf->buffsz); + ei_x_buff *nbuf = malloc(sizeof(nbuf)); + nbuf->buff = malloc(buf->buffsz); memcpy(nbuf->buff, buf->buff, buf->buffsz); nbuf->index = buf->index; nbuf->buffsz = buf->buffsz; - - switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf); - ei_x_encode_atom(rbuf, "ok"); + + if ((p = switch_core_hash_find(listener->fetch_reply_hash, uuid_str))) { + if (p == &globals.TIMEOUT) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handler for %s timed out\n", uuid_str); + switch_core_hash_delete(listener->fetch_reply_hash, uuid_str); + ei_x_encode_tuple_header(rbuf, 2); + ei_x_encode_atom(rbuf, "error"); + ei_x_encode_atom(rbuf, "timeout"); + } else if (p == &globals.WAITING) { + /* update the key to point at a pid */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found waiting slot for %s\n", uuid_str); + switch_core_hash_delete(listener->fetch_reply_hash, uuid_str); + switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf); + ei_x_encode_atom(rbuf, "ok"); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found filled slot for %s\n", uuid_str); + ei_x_encode_tuple_header(rbuf, 2); + ei_x_encode_atom(rbuf, "error"); + ei_x_encode_atom(rbuf, "duplicate_response"); + } + } else { + /* nothin in the hash */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Empty slot for %s\n", uuid_str); + ei_x_encode_tuple_header(rbuf, 2); + ei_x_encode_atom(rbuf, "error"); + ei_x_encode_atom(rbuf, "invalid_uuid"); + } + + /*switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf);*/ } return SWITCH_STATUS_SUCCESS; } @@ -700,7 +727,7 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf) { erlang_ref ref; - erlang_pid *pid;/* = switch_core_alloc(listener->pool, sizeof(erlang_pid));*/ + erlang_pid *pid; void *p; char hash[100]; int arity; Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 9 15:22:42 2009 @@ -388,7 +388,7 @@ _ei_x_encode_string(&buf, uuid_str); ei_encode_switch_event_headers(&buf, params); - /*switch_core_hash_insert(ptr->reply_hash, uuid_str, );*/ + switch_core_hash_insert(ptr->listener->fetch_reply_hash, uuid_str, &globals.WAITING); switch_mutex_lock(ptr->listener->sock_mutex); ei_sendto(ptr->listener->ec, ptr->listener->sockfd, &ptr->process, &buf); @@ -396,16 +396,19 @@ int i = 0; ei_x_buff *rep; - /*int index = 3;*/ - while (!(rep = (ei_x_buff *) switch_core_hash_find(ptr->listener->fetch_reply_hash, uuid_str))) { + void *p = NULL; + + while (!(p = switch_core_hash_find(ptr->listener->fetch_reply_hash, uuid_str)) || p == &globals.WAITING) { if (i > 50) { /* half a second timeout */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for XML fetch response!\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for XML fetch response\n"); + switch_core_hash_insert(ptr->listener->fetch_reply_hash, uuid_str, &globals.TIMEOUT); /* TODO lock this? */ return NULL; } i++; switch_yield(10000); /* 10ms */ } + rep = (ei_x_buff *) p; int type, size; ei_get_type(rep->buff, &rep->index, &type, &size); @@ -432,10 +435,10 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XML parsed OK!\n"); } + /* cleanup */ switch_core_hash_delete(ptr->listener->fetch_reply_hash, uuid_str); - - /*switch_safe_free(rep->buff);*/ - /*switch_safe_free(rep);*/ + free(rep->buff); + free(rep); free(xmlstr); return xml; From anthm at freeswitch.org Mon Mar 9 15:51:31 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 17:51:31 -0500 Subject: [Freeswitch-svn] [commit] r12544 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 9 17:51:31 2009 New Revision: 12544 Log: declinatio mortuus obfirmo in fsctl hupall Modified: freeswitch/trunk/src/switch_core_session.c Modified: freeswitch/trunk/src/switch_core_session.c ============================================================================== --- freeswitch/trunk/src/switch_core_session.c (original) +++ freeswitch/trunk/src/switch_core_session.c Mon Mar 9 17:51:31 2009 @@ -81,6 +81,12 @@ switch_hash_index_t *hi; void *val; switch_core_session_t *session; + switch_memory_pool_t *pool; + switch_queue_t *queue; + void *pop; + + switch_core_new_memory_pool(&pool); + switch_queue_create(&queue, 250000, pool); if (!var_val) return; @@ -93,13 +99,25 @@ if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { if (switch_channel_up(session->channel) && (this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) { - switch_channel_hangup(session->channel, cause); + switch_queue_push(queue, switch_core_strdup(pool, session->uuid_str)); } switch_core_session_rwunlock(session); } } } switch_mutex_unlock(runtime.session_hash_mutex); + + while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { + char *uuid = (char *) pop; + + if ((session = switch_core_session_locate(uuid))) { + switch_channel_hangup(session->channel, cause); + switch_core_session_rwunlock(session); + } + } + + switch_core_destroy_memory_pool(&pool); + } SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause) @@ -107,6 +125,12 @@ switch_hash_index_t *hi; void *val; switch_core_session_t *session; + switch_memory_pool_t *pool; + switch_queue_t *queue; + void *pop; + + switch_core_new_memory_pool(&pool); + switch_queue_create(&queue, 250000, pool); switch_mutex_lock(runtime.session_hash_mutex); for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { @@ -115,13 +139,25 @@ session = (switch_core_session_t *) val; if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { if (session->endpoint_interface == endpoint_interface) { - switch_channel_hangup(switch_core_session_get_channel(session), cause); + switch_queue_push(queue, switch_core_strdup(pool, session->uuid_str)); } switch_core_session_rwunlock(session); } } } switch_mutex_unlock(runtime.session_hash_mutex); + + while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { + char *uuid = (char *) pop; + + if ((session = switch_core_session_locate(uuid))) { + switch_channel_hangup(session->channel, cause); + switch_core_session_rwunlock(session); + } + } + + switch_core_destroy_memory_pool(&pool); + } SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause) @@ -129,28 +165,37 @@ switch_hash_index_t *hi; void *val; switch_core_session_t *session; - uint32_t loops = 0; + switch_memory_pool_t *pool; + switch_queue_t *queue; + void *pop; - while (session_manager.session_count > 0) { - switch_mutex_lock(runtime.session_hash_mutex); - for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, NULL, NULL, &val); - if (val) { - session = (switch_core_session_t *) val; - if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(switch_core_session_get_channel(session), cause); - switch_core_session_rwunlock(session); - } + switch_core_new_memory_pool(&pool); + switch_queue_create(&queue, 250000, pool); + + switch_mutex_lock(runtime.session_hash_mutex); + for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, NULL, NULL, &val); + if (val) { + session = (switch_core_session_t *) val; + if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { + switch_queue_push(queue, switch_core_strdup(pool, session->uuid_str)); + switch_core_session_rwunlock(session); } } - switch_mutex_unlock(runtime.session_hash_mutex); - switch_yield(1000000); - if (++loops == 30) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Giving up with %d session%s remaining\n", - session_manager.session_count, session_manager.session_count == 1 ? "" : "s"); - break; + } + switch_mutex_unlock(runtime.session_hash_mutex); + + while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { + char *uuid = (char *) pop; + + if ((session = switch_core_session_locate(uuid))) { + switch_channel_hangup(session->channel, cause); + switch_core_session_rwunlock(session); } } + + switch_core_destroy_memory_pool(&pool); + } From seven at freeswitch.org Mon Mar 9 20:53:20 2009 From: seven at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Mar 2009 22:53:20 -0500 Subject: [Freeswitch-svn] [commit] r12545 - freeswitch/trunk/scripts/contrib/seven/sip Message-ID: Author: seven Date: Mon Mar 9 22:53:19 2009 New Revision: 12545 Log: script to parse sip messages and insert to Mysql Added: freeswitch/trunk/scripts/contrib/seven/sip/ freeswitch/trunk/scripts/contrib/seven/sip/sip2db.rb Added: freeswitch/trunk/scripts/contrib/seven/sip/sip2db.rb ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/seven/sip/sip2db.rb Mon Mar 9 22:53:19 2009 @@ -0,0 +1,207 @@ +#!/usr/bin/env ruby + +# read SIP messages from a plain text file(FreeSWITCH with TPORT_DUMP=/tmp/xxxx.log), +# and write to a Mysql database +# +# There are lots of ways to monitor sip messages. However, not all of them are convinient +# as we want. Let's say a simple example: +# +# FreeSWITCH :> originate sofia/gateways/carrier1/5550000|sofia/gateways/carrier2/5550000|sofia/carrier3... +# +# It's hard to tell what happend if the call fails. Because it's different sip sessions. +# The idea is to group them in one super session and see what happend. I do this by +# adding an arbitary sip header to do cross reference. And by parse the sip messages to +# a DB we can easily show it as html. I even can build a simple graph based on the DB data: +# +# http://skitch.com/seven1240/b8xj2/voip-master-idapted +# +# You can easily add a sip header to INVITE by(I use x_interaction): +# FreeSWITCH :> originate {sip_h_x_interaction=TEST0001}sofia/gateways/..... +# +# And I can get all the messages from DB: +# SELECT * FROM `sip_messages` WHERE (call_id IN +# (SELECT distinct call_id FROM sip_messages WHERE x_interaction = 'TEST0001')) ORDER BY created_at; +# +# There are two aproches to get sip packets: +# 1) tcpdump/tshark +# 2) FreeSWITCH +# +# I use the second. Note, there is no way to actually get sip messages from FS currently, but sofia-sip +# has the ability to log all sip messages to a disk file by using TPORT_DUMP +# +# And you can use this script to parse them to a DB. I know it hurt performance, +# but we don't have tons of traffic and you know there are only 5-10 messages for each +# sip call. While we get about 1G bytes each day in the sip log, most of them are OPTIONS/NOTIFY etc. +# I filtered them before inserting to DB, but it will be better if sofia-sip can filter that :) +# +# The script will monitor the log file and parse and insert to DB in real time. It's written in +# the Ruby on Rails framework, however, I think it can run out of Rails with or without +# modification. But you still need ruby and rubygems if you want to use it. +# +# on Ubuntu/Debian +# # apt-get install ruby rubygems +# # gem install mysql file-tail yaml +# +# It's just an idea, you may like to write your own tools to parse the sip log file. Also +# the log file need to be rotated regularly. And I think it maybe possible to store the log +# file on a memory disk, whatever... :) +# +# By default, it will go to the end of a log file and follow(like tail), +# if you want to parse the existing part, comment line: f.backward(0) +# +# Sample mysql DB DDL: +# CREATE TABLE `sip_messages` ( +# `id` int(11) NOT NULL auto_increment, +# `message_type` varchar(255) default NULL, +# `sip_to` varchar(255) default NULL, +# `call_id` varchar(255) default NULL, +# `message_bytes` int(11) default NULL, +# `content_length` int(11) default NULL, +# `message_body` text, +# `created_at` datetime default NULL, +# `x_interaction` varchar(255) default NULL, +# PRIMARY KEY (`id`), +# KEY `index_sip_messages_on_x_interaction` (`x_interaction`) +# ) ENGINE=InnoDB; +# +# Author: seven_at_idapted.com +# Lisense: Free of use + +require 'rubygems' +require "file/tail" +require "mysql" +require "yaml" + + +RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) +# Uncomment the following line and comment the above to make it work withouth rails framework +# RAILS_ROOT = "." +DB_CONFIG_FILENAME = File.join(RAILS_ROOT, "config/database.yml") +LOG_FILE = File.join(RAILS_ROOT, 'log/sip2db.log') +# FILENAME="/tmp/tport_sip.log" +FILENAME="/usr/local/freeswitch/log/tport_sip.log" + at debug = true + +if File.writable?(LOG_FILE) + @log_file = File.open(LOG_FILE, "a+") + puts "Writing logs to #{LOG_FILE}" +else + @log_file = STDOUT +end + +def log(msg) + @log_file.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}: #{msg}" +end + +def db_config + if File.readable?(DB_CONFIG_FILENAME) + conf = YAML.load_file(DB_CONFIG_FILENAME) + return conf["production"] + else + conf["host"] = "localhost" + conf["username"] = "root" + conf["password"] = "" + conf["database"] = "freeswitch_sip_db" + end +end + +#connect to Mysql + at dbh = nil + at debug = true + at call_id_array = [] #use as a queue to filter related messages + +def mysql_connect + Mysql.real_connect(db_config["host"] || db_config["server"], db_config["username"], db_config["password"], db_config["database"]) +end + +def ignore_message?(call_id, message_type) + #we do not care about certain types of messages and it's related ones + + # log @call_id_array.size.to_s + @call_id_array.shift if @call_id_array.size > 10000 + return true if @call_id_array.include?(call_id) + if message_type =~ /(REGISTER|OPTIONS|NOTIFY)/ + @call_id_array << call_id + return true + end + return false +end + +def insert_to_db(message_body) + + # puts message_body + message_body =~ /(recv|sent) (\d+)[^\n]*\n(\S+).*To: ([^\n]+).*Call-ID: (\S+).*Content-Length: (\d+)[^(x_int)]*(x_interaction: ([A-Z0-9]+))*/m + message_bytes, message_type, sip_to, call_id, content_length, x_interaction = $2, $3, $4, $5, $6, $8 + sip_to.sub!(/^.*<([^;>]+).*/, '\1') unless sip_to.nil? + + return if call_id.nil? + + call_id = call_id[0,100] + "_TRUNCATED" if call_id.length > 100 + return if ignore_message?(call_id, message_type) + + message_body = @dbh.escape_string(message_body) + sql = "INSERT INTO sip_messages (message_type, sip_to, call_id, message_bytes, x_interaction, content_length, message_body, created_at) + VALUES('#{message_type}', '#{sip_to}', '#{call_id}', '#{message_bytes}', '#{x_interaction}', #{content_length || 0 }, '#{message_body}', now())" + log sql if @debug + + begin + @dbh.query(sql) + rescue Mysql::Error => e + log "Error code #{e.errno}" + log "Error message: #{e.error}" + log "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate") + end +end + + +#start here +begin + # connect to the MySQL server + # get server version string and display it + @dbh = mysql_connect + log "Server version: " + @dbh.get_server_info +rescue Mysql::Error => e + log "Error code: #{e.errno}" + log "Error message: #{e.error}" + log "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate") +ensure + # disconnect from server + # @dbh.close if @dbh +end + + + +File.open(FILENAME) do |f| + message_type_expecting = true + message_body = '' + message_started = false + call_id = nil + line_count = 0 + + f.extend(File::Tail) + f.interval = 10 + f.backward(0) + f.tail do |line| + + if line_count > 1000 # crazy? + line_count = 0 + message_started = false + end + + if !message_started && line =~ /^(recv|sent) (\d+)/ + message_started = true + end + + if line =~ /\013/ # \v - seperator in dump file + insert_to_db message_body + message_body = '' + message_started = false + else + message_body << line + end + + end +end + + + From anthm at freeswitch.org Tue Mar 10 06:16:14 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 08:16:14 -0500 Subject: [Freeswitch-svn] [commit] r12546 - in freeswitch/trunk/src: . include Message-ID: Author: anthm Date: Tue Mar 10 08:16:14 2009 New Revision: 12546 Log: add origination_pricacy var to originate api Modified: freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Tue Mar 10 08:16:14 2009 @@ -381,6 +381,7 @@ #define SWITCH_ACCEPTABLE_INTERVAL(_i) (_i && _i <= SWITCH_MAX_INTERVAL && (_i % 10) == 0) typedef enum { + SWITCH_CPF_NONE = 0, SWITCH_CPF_SCREEN = (1 << 0), SWITCH_CPF_HIDE_NAME = (1 << 1), SWITCH_CPF_HIDE_NUMBER = (1 << 2) Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Tue Mar 10 08:16:14 2009 @@ -916,7 +916,6 @@ const char *cid_tmp; originate_global_t oglobals = { 0 }; - oglobals.idx = IDX_NADA; oglobals.early_ok = 1; oglobals.session = session; @@ -1422,6 +1421,35 @@ new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_uuid", tmp); } + + + if (vdata && (var_begin = switch_stristr("origination_privacy=", vdata))) { + char tmp[512] = ""; + var_begin += strlen("origination_privacy="); + var_end = strchr(var_begin, '|'); + if (var_end) { + strncpy(tmp, var_begin, var_end-var_begin); + } else { + strncpy(tmp, var_begin, strlen(var_begin)); + } + + new_profile->flags = SWITCH_CPF_NONE; + + if (switch_stristr(tmp, "screen")) { + switch_set_flag(new_profile, SWITCH_CPF_SCREEN); + } + + if (switch_stristr(tmp, "hide_name")) { + switch_set_flag(new_profile, SWITCH_CPF_HIDE_NAME); + } + + if (switch_stristr(tmp, "hide_number")) { + switch_set_flag(new_profile, SWITCH_CPF_HIDE_NUMBER); + } + + new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_privacy", tmp); + } switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); From mikej at freeswitch.org Tue Mar 10 08:45:30 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 10:45:30 -0500 Subject: [Freeswitch-svn] [commit] r12547 - in freeswitch/trunk/libs/libteletone: . src Message-ID: Author: mikej Date: Tue Mar 10 10:45:29 2009 New Revision: 12547 Log: update api visibility macros for windows Modified: freeswitch/trunk/libs/libteletone/libteletone.2008.vcproj freeswitch/trunk/libs/libteletone/libteletone.vcproj freeswitch/trunk/libs/libteletone/src/libteletone.h freeswitch/trunk/libs/libteletone/src/libteletone_detect.c freeswitch/trunk/libs/libteletone/src/libteletone_detect.h freeswitch/trunk/libs/libteletone/src/libteletone_generate.c freeswitch/trunk/libs/libteletone/src/libteletone_generate.h Modified: freeswitch/trunk/libs/libteletone/libteletone.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/libteletone/libteletone.2008.vcproj (original) +++ freeswitch/trunk/libs/libteletone/libteletone.2008.vcproj Tue Mar 10 10:45:29 2009 @@ -45,7 +45,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="src" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;TELETONE_EXPORTS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -122,7 +122,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="src" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;TELETONE_EXPORTS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -199,7 +199,7 @@ Modified: freeswitch/trunk/libs/libteletone/src/libteletone_detect.c ============================================================================== --- freeswitch/trunk/libs/libteletone/src/libteletone_detect.c (original) +++ freeswitch/trunk/libs/libteletone/src/libteletone_detect.c Tue Mar 10 10:45:29 2009 @@ -116,7 +116,7 @@ goertzel_state->fac = tdesc->fac; } -TELETONE_API void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, +TELETONE_API(void) teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, int16_t sample_buffer[], int samples) { @@ -135,7 +135,7 @@ #define teletone_goertzel_result(gs) (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)) -TELETONE_API void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate) +TELETONE_API(void) teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate) { int i; float theta; @@ -169,7 +169,7 @@ dtmf_detect_state->mhit = 0; } -TELETONE_API void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map) +TELETONE_API(void) teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map) { float theta = 0; int x = 0; @@ -209,7 +209,7 @@ } -TELETONE_API int teletone_multi_tone_detect (teletone_multi_tone_t *mt, +TELETONE_API(int) teletone_multi_tone_detect (teletone_multi_tone_t *mt, int16_t sample_buffer[], int samples) { @@ -299,7 +299,7 @@ } -TELETONE_API int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, +TELETONE_API(int) teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, int16_t sample_buffer[], int samples) { @@ -430,7 +430,7 @@ } -TELETONE_API int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, +TELETONE_API(int) teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, char *buf, int max) { Modified: freeswitch/trunk/libs/libteletone/src/libteletone_detect.h ============================================================================== --- freeswitch/trunk/libs/libteletone/src/libteletone_detect.h (original) +++ freeswitch/trunk/libs/libteletone/src/libteletone_detect.h Tue Mar 10 10:45:29 2009 @@ -202,7 +202,7 @@ \param mt the multi-frequency tone descriptor \param map a representation of the multi-frequency tone */ -TELETONE_API void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map); +TELETONE_API(void) teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map); /*! \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt @@ -211,7 +211,7 @@ \param samples the number of samples present in sample_buffer \return true when the tone was detected or false when it is not */ -TELETONE_API int teletone_multi_tone_detect (teletone_multi_tone_t *mt, +TELETONE_API(int) teletone_multi_tone_detect (teletone_multi_tone_t *mt, int16_t sample_buffer[], int samples); @@ -220,7 +220,7 @@ \param dtmf_detect_state the DTMF detection state to initilize \param sample_rate the desired sample rate */ -TELETONE_API void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate); +TELETONE_API(void) teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate); /*! \brief Check a sample buffer for the presence of DTMF digits @@ -229,7 +229,7 @@ \param samples the number of samples present in sample_buffer \return true when DTMF was detected or false when it is not */ -TELETONE_API int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, +TELETONE_API(int) teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, int16_t sample_buffer[], int samples); /*! @@ -239,7 +239,7 @@ \param max the maximum length of buf \return the number of characters written to buf */ -TELETONE_API int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, +TELETONE_API(int) teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, char *buf, int max); @@ -249,7 +249,7 @@ \param sample_buffer an array aof 16 bit signed linear samples \param samples the number of samples present in sample_buffer */ -TELETONE_API void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, +TELETONE_API(void) teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, int16_t sample_buffer[], int samples); Modified: freeswitch/trunk/libs/libteletone/src/libteletone_generate.c ============================================================================== --- freeswitch/trunk/libs/libteletone/src/libteletone_generate.c (original) +++ freeswitch/trunk/libs/libteletone/src/libteletone_generate.c Tue Mar 10 10:45:29 2009 @@ -79,7 +79,7 @@ #pragma warning(disable:4706) #endif -TELETONE_API int16_t TELETONE_SINES[SINE_TABLE_MAX] = { +TELETONE_API_DATA int16_t TELETONE_SINES[SINE_TABLE_MAX] = { 0x00c9, 0x025b, 0x03ed, 0x057f, 0x0711, 0x08a2, 0x0a33, 0x0bc4, 0x0d54, 0x0ee4, 0x1073, 0x1201, 0x138f, 0x151c, 0x16a8, 0x1833, 0x19be, 0x1b47, 0x1cd0, 0x1e57, 0x1fdd, 0x2162, 0x22e5, 0x2467, @@ -99,7 +99,7 @@ }; -TELETONE_API int teletone_set_tone(teletone_generation_session_t *ts, int index, ...) +TELETONE_API(int) teletone_set_tone(teletone_generation_session_t *ts, int index, ...) { va_list ap; int i = 0; @@ -115,7 +115,7 @@ } -TELETONE_API int teletone_set_map(teletone_tone_map_t *map, ...) +TELETONE_API(int) teletone_set_map(teletone_tone_map_t *map, ...) { va_list ap; int i = 0; @@ -131,7 +131,7 @@ } -TELETONE_API int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data) +TELETONE_API(int) teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data) { memset(ts, 0, sizeof(*ts)); ts->rate = 8000; @@ -174,7 +174,7 @@ return 0; } -TELETONE_API int teletone_destroy_session(teletone_generation_session_t *ts) +TELETONE_API(int) teletone_destroy_session(teletone_generation_session_t *ts) { if (ts->buffer) { free(ts->buffer); @@ -203,7 +203,7 @@ return 0; } -TELETONE_API int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map) +TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map) { /*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/ int i, c; @@ -318,7 +318,7 @@ return (char *) memcpy (new, s, len); } -TELETONE_API int teletone_run(teletone_generation_session_t *ts, const char *cmd) +TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd) { char *data = NULL, *cur = NULL, *end = NULL; int var = 0, LOOPING = 0; Modified: freeswitch/trunk/libs/libteletone/src/libteletone_generate.h ============================================================================== --- freeswitch/trunk/libs/libteletone/src/libteletone_generate.h (original) +++ freeswitch/trunk/libs/libteletone/src/libteletone_generate.h Tue Mar 10 10:45:29 2009 @@ -137,7 +137,7 @@ /* 3.02 represents twice the power */ #define DBM0_MAX_POWER (3.14f + 3.02f) -TELETONE_API extern int16_t TELETONE_SINES[SINE_TABLE_MAX]; +TELETONE_API_DATA extern int16_t TELETONE_SINES[SINE_TABLE_MAX]; static __inline__ int32_t teletone_dds_phase_rate(teletone_process_t tone, uint32_t rate) { @@ -255,7 +255,7 @@ \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0 \return 0 */ -TELETONE_API int teletone_set_tone(teletone_generation_session_t *ts, int index, ...); +TELETONE_API(int) teletone_set_tone(teletone_generation_session_t *ts, int index, ...); /*! \brief Assign a set of tones to a single tone map @@ -263,7 +263,7 @@ \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0 \return 0 */ -TELETONE_API int teletone_set_map(teletone_tone_map_t *map, ...); +TELETONE_API(int) teletone_set_map(teletone_tone_map_t *map, ...); /*! \brief Initilize a tone generation session @@ -273,14 +273,14 @@ \param user_data optional user data to send \return 0 */ -TELETONE_API int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data); +TELETONE_API(int) teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data); /*! \brief Free the buffer allocated by a tone generation session \param ts the tone generation session to destroy \return 0 */ -TELETONE_API int teletone_destroy_session(teletone_generation_session_t *ts); +TELETONE_API(int) teletone_destroy_session(teletone_generation_session_t *ts); /*! \brief Execute a single tone generation instruction @@ -288,7 +288,7 @@ \param map the tone mapping to use for the frequencies \return 0 */ -TELETONE_API int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map); +TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map); /*! \brief Execute a tone generation script and call callbacks after each instruction @@ -296,7 +296,7 @@ \param cmd the script to execute \return 0 */ -TELETONE_API int teletone_run(teletone_generation_session_t *ts, const char *cmd); +TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd); #ifdef __cplusplus } From andrew at freeswitch.org Tue Mar 10 10:47:35 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 12:47:35 -0500 Subject: [Freeswitch-svn] [commit] r12548 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Tue Mar 10 12:47:35 2009 New Revision: 12548 Log: oops Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Tue Mar 10 12:47:35 2009 @@ -191,6 +191,7 @@ switch_core_hash_delete(listener->fetch_reply_hash, uuid_str); switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf); ei_x_encode_atom(rbuf, "ok"); + return SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found filled slot for %s\n", uuid_str); ei_x_encode_tuple_header(rbuf, 2); @@ -206,6 +207,8 @@ } /*switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf);*/ + free(nbuf->buff); + free(nbuf); } return SWITCH_STATUS_SUCCESS; } From andrew at freeswitch.org Tue Mar 10 12:06:20 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:06:20 -0500 Subject: [Freeswitch-svn] [commit] r12549 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Tue Mar 10 14:06:19 2009 New Revision: 12549 Log: Move some variable declarations to a more correct place Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Tue Mar 10 14:06:19 2009 @@ -353,6 +353,11 @@ struct erlang_binding *ptr; switch_uuid_t uuid; char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]; + int type, size; + int i = 0; + void *p = NULL; + char *xmlstr; + ei_x_buff *rep; ei_x_buff buf; ei_x_new_with_version(&buf); @@ -394,10 +399,6 @@ ei_sendto(ptr->listener->ec, ptr->listener->sockfd, &ptr->process, &buf); switch_mutex_unlock(ptr->listener->sock_mutex); - int i = 0; - ei_x_buff *rep; - void *p = NULL; - while (!(p = switch_core_hash_find(ptr->listener->fetch_reply_hash, uuid_str)) || p == &globals.WAITING) { if (i > 50) { /* half a second timeout */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for XML fetch response\n"); @@ -409,14 +410,12 @@ } rep = (ei_x_buff *) p; - int type, size; ei_get_type(rep->buff, &rep->index, &type, &size); if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) /* XXX no unicode or character codes > 255 */ return NULL; - char *xmlstr; if (!(xmlstr = malloc(size + 1))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error\n"); From mikej at freeswitch.org Tue Mar 10 12:50:47 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:50:47 -0500 Subject: [Freeswitch-svn] [commit] r12550 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/msg libsofia-sip-ua/msg/sofia-sip Message-ID: Author: mikej Date: Tue Mar 10 14:50:46 2009 New Revision: 12550 Log: Wed Mar 4 13:35:37 CST 2009 Fabio Margarido * msg: allow compact headers inside multipart payload Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_mime.h freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/test_msg.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:50:46 2009 @@ -1 +1 @@ -Wed Mar 4 14:42:12 CST 2009 +Tue Mar 10 14:49:50 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am Tue Mar 10 14:50:46 2009 @@ -87,7 +87,7 @@ AWK_MSG_AWK = LC_ALL=C $(AWK) -f $(MSG_PARSER_AWK) -${GENERATED_HC}: ${MSG_PARSER_AWK} +${GENERATED_HC}: ${MSG_PARSER_AWK} Makefile.am TEST_CLASS_H = ${srcdir}/test_class.h Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_mime.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_mime.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_mime.h Tue Mar 10 14:50:46 2009 @@ -168,13 +168,13 @@ msg_error_t *mp_error; /* === Headers start here */ - msg_content_type_t *mp_content_type; /**< Content-Type */ + msg_content_type_t *mp_content_type; /**< Content-Type (c) */ msg_content_disposition_t *mp_content_disposition; /**< Content-Disposition */ msg_content_location_t *mp_content_location; /**< Content-Location */ msg_content_id_t *mp_content_id; /**< Content-ID */ msg_content_language_t *mp_content_language; /**< Content-Language */ - msg_content_encoding_t *mp_content_encoding; /**< Content-Encoding */ + msg_content_encoding_t *mp_content_encoding; /**< Content-Encoding (e) */ msg_content_transfer_encoding_t *mp_content_transfer_encoding; /**< Content-Transfer-Encoding */ #if 0 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/test_msg.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/test_msg.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/test_msg.c Tue Mar 10 14:50:46 2009 @@ -1193,8 +1193,15 @@ CRLF /* 13 */ #define BODY3 "part 3" CRLF BODY3 /* 14 */ - CRLF /* 15 */ - "--LaGqGt4BI6Ho--" CRLF; + CRLF "--LaGqGt4BI6Ho" /* 15 */ + "c: text/html" CRLF /* 16 */ + "l: 9" CRLF /* 17 */ + "e: identity" CRLF /* 18 */ + CRLF /* 19 */ +#define BODY4 "" CRLF + BODY4 /* 20 */ + CRLF "--LaGqGt4BI6Ho--" /* 21 */ + CRLF; BEGIN(); @@ -1275,6 +1282,18 @@ TEST_SIZE(strlen(BODY3), pl->pl_len); TEST(memcmp(pl->pl_data, BODY3, pl->pl_len), 0); + TEST_1(mp = mp->mp_next); + + TEST_1(mp->mp_data); + TEST_M(mp->mp_data, CRLF "--" "LaGqGt4BI6Ho" CRLF, mp->mp_len); + + TEST_1(mp->mp_content_encoding); + TEST_1(mp->mp_content_type); + + TEST_1(pl = mp->mp_payload); TEST_1(pl->pl_data); + TEST_SIZE(strlen(BODY4), pl->pl_len); + TEST(memcmp(pl->pl_data, BODY4, pl->pl_len), 0); + mpX = mp; TEST_1(!(mp = mp->mp_next)); @@ -1293,7 +1312,7 @@ h->sh_succ = NULL; } - TEST(n, 15); + TEST(n, 21); head = NULL; TEST_1(h = msg_multipart_serialize(&head, mp0)); @@ -1304,7 +1323,7 @@ h_succ = h->sh_succ; } - TEST(n, 15); + TEST(n, 21); /* Add a new part to multipart */ mpnew = su_zalloc(home, sizeof(*mpnew)); TEST_1(mpnew); @@ -1324,7 +1343,7 @@ TEST_1(h != removed); } - TEST(n, 19); + TEST(n, 21 + 4); #define remove(h) \ (((*((msg_header_t*)(h))->sh_prev = ((msg_header_t*)(h))->sh_succ) ? \ @@ -1336,7 +1355,7 @@ remove(mp0->mp_separator); remove(mp0->mp_next->mp_payload); remove(mp0->mp_next->mp_next->mp_content_type); - remove(mp0->mp_next->mp_next->mp_next->mp_close_delim); + remove(mp0->mp_next->mp_next->mp_next->mp_next->mp_close_delim); TEST_1(!msg_chain_errors((msg_header_t *)mp0)); @@ -1352,7 +1371,7 @@ TEST_1(h != removed); } - TEST(n, 19); + TEST(n, 21 + 4); /* Add an recursive multipart */ mpnew = su_zalloc(home, sizeof(*mpnew)); TEST_1(mpnew); @@ -1371,7 +1390,7 @@ for (h = (msg_header_t *)mp0, n = 0; h; h = h_succ, n++) h_succ = h->sh_succ; - TEST(n, 24); + TEST(n, 21 + 9); su_home_check(home); su_home_zap(home); From mikej at freeswitch.org Tue Mar 10 12:52:07 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:52:07 -0500 Subject: [Freeswitch-svn] [commit] r12551 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 10 14:52:07 2009 New Revision: 12551 Log: Wed Mar 4 12:27:19 CST 2009 Pekka Pessi * nta.c: removed spurios SOFIAPUBFUNs Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:52:07 2009 @@ -1 +1 @@ -Tue Mar 10 14:49:50 CDT 2009 +Tue Mar 10 14:50:56 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 10 14:52:07 2009 @@ -4542,10 +4542,10 @@ * * @since New in @VERSION_1_12_2. */ -SOFIAPUBFUN -sip_replaces_t *nta_leg_make_replaces(nta_leg_t *leg, - su_home_t *home, - int early_only) +sip_replaces_t * +nta_leg_make_replaces(nta_leg_t *leg, + su_home_t *home, + int early_only) { char const *from_tag, *to_tag; @@ -4566,8 +4566,8 @@ * * @since New in @VERSION_1_12_2. */ -SOFIAPUBFUN -nta_leg_t *nta_leg_by_replaces(nta_agent_t *sa, sip_replaces_t const *rp) +nta_leg_t * +nta_leg_by_replaces(nta_agent_t *sa, sip_replaces_t const *rp) { nta_leg_t *leg = NULL; @@ -4593,9 +4593,9 @@ * Find a leg corresponding to the request message. * */ -static -nta_leg_t *leg_find_call_id(nta_agent_t const *sa, - sip_call_id_t const *i) +static nta_leg_t * +leg_find_call_id(nta_agent_t const *sa, + sip_call_id_t const *i) { hash_value_t hash = i->i_hash; leg_htable_t const *lht = sa->sa_dialogs; @@ -4625,8 +4625,8 @@ * * @since New in @VERSION_1_12_9. */ -SOFIAPUBFUN -nta_leg_t *nta_leg_by_call_id(nta_agent_t *sa, const char *call_id) +nta_leg_t * +nta_leg_by_call_id(nta_agent_t *sa, const char *call_id) { nta_leg_t *leg = NULL; @@ -7390,7 +7390,7 @@ return NULL; } -/**Bind callback and application context to an client transaction. +/**Bind callback and application context to a client transaction. * * @param orq outgoing client transaction * @param callback callback function (may be NULL) @@ -7399,9 +7399,10 @@ * * @NEW_1_12_9 */ -SOFIAPUBFUN int nta_outgoing_bind(nta_outgoing_t *orq, - nta_response_f *callback, - nta_outgoing_magic_t *magic) +int +nta_outgoing_bind(nta_outgoing_t *orq, + nta_response_f *callback, + nta_outgoing_magic_t *magic) { if (orq && !orq->orq_destroyed) { if (callback == NULL) From mikej at freeswitch.org Tue Mar 10 12:52:53 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:52:53 -0500 Subject: [Freeswitch-svn] [commit] r12552 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta libsofia-sip-ua/nta/sofia-sip Message-ID: Author: mikej Date: Tue Mar 10 14:52:52 2009 New Revision: 12552 Log: Wed Mar 4 12:27:36 CST 2009 Pekka Pessi * nta: added nta_agent_tports() Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tport.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:52:52 2009 @@ -1 +1 @@ -Tue Mar 10 14:50:56 CDT 2009 +Tue Mar 10 14:51:57 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 10 14:52:52 2009 @@ -11378,6 +11378,16 @@ #include +/** Return the master transport for the agent. + * + * @NEW_1_12_11 + */ +tport_t * +nta_agent_tports(nta_agent_t *agent) +{ + return agent ? agent->sa_tports : NULL; +} + su_inline tport_t * nta_transport_(nta_agent_t *agent, nta_incoming_t *irq, Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tport.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tport.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tport.h Tue Mar 10 14:52:52 2009 @@ -59,6 +59,8 @@ #define nta_transport nta_incoming_transport +SOFIAPUBFUN tport_t *nta_agent_tports(nta_agent_t *agent); + SOFIAPUBFUN tport_t *nta_incoming_transport(nta_agent_t *, nta_incoming_t *, msg_t *msg); From mikej at freeswitch.org Tue Mar 10 12:53:44 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:53:44 -0500 Subject: [Freeswitch-svn] [commit] r12553 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 10 14:53:44 2009 New Revision: 12553 Log: Thu Mar 5 07:59:34 CST 2009 Pekka Pessi * s2check/exit77.c: added Added: freeswitch/trunk/libs/sofia-sip/s2check/exit77.c Modified: freeswitch/trunk/libs/sofia-sip/.update Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:53:44 2009 @@ -1 +1 @@ -Tue Mar 10 14:51:57 CDT 2009 +Tue Mar 10 14:52:49 CDT 2009 Added: freeswitch/trunk/libs/sofia-sip/s2check/exit77.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/s2check/exit77.c Tue Mar 10 14:53:44 2009 @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 77; /* exit code indicating make check that test has been SKIPped */ +} From mikej at freeswitch.org Tue Mar 10 12:55:00 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:55:00 -0500 Subject: [Freeswitch-svn] [commit] r12554 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 10 14:55:00 2009 New Revision: 12554 Log: Thu Mar 5 08:00:45 CST 2009 Pekka Pessi * nta: added check-based test program check_nta Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta.h freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_api.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_check_nta Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:55:00 2009 @@ -1 +1 @@ -Tue Mar 10 14:52:49 CDT 2009 +Tue Mar 10 14:53:54 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am Tue Mar 10 14:55:00 2009 @@ -16,17 +16,20 @@ -I$(srcdir)/../tport -I../tport \ -I$(srcdir)/../url -I../url \ -I$(srcdir)/../features -I../features \ - -I$(srcdir)/../su -I../su + -I$(srcdir)/../su -I../su \ + -I$(top_srcdir)/s2check \ + -I$(srcdir)/../stun -I ../stun # ---------------------------------------------------------------------- # Build targets noinst_LTLIBRARIES = libnta.la -check_PROGRAMS = test_nta_api test_nta portbind +check_PROGRAMS = check_nta test_nta_api test_nta portbind dist_noinst_SCRIPTS = run_test_nta_api run_test_nta -TESTS = run_test_nta_api run_test_nta +TESTS = run_check_nta run_test_nta_api run_test_nta + TESTS_ENVIRONMENT = $(SHELL) # ---------------------------------------------------------------------- @@ -63,6 +66,19 @@ MOSTLYCLEANFILES += .test[0-9]* +if HAVE_CHECK + +check_nta_SOURCES = check_nta.c check_nta.h \ + check_nta_api.c \ + check_nta_client.c + +check_nta_LDADD = ${LDADD} ${top_builddir}/s2check/libs2.a \ + @CHECK_LIBS@ + +else +check_nta_SOURCES = $(top_srcdir)/s2check/exit77.c +endif + # ---------------------------------------------------------------------- # Install and distribution rules Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta.c Tue Mar 10 14:55:00 2009 @@ -0,0 +1,482 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE check_nta.c + * @brief 2nd test Suite for Sofia SIP Transaction Engine + * + * @author Pekka Pessi + * + * @date Created: Wed Apr 30 12:48:27 EEST 2008 ppessi + */ + +#include "config.h" + +#undef NDEBUG + +#include "check_nta.h" + +#include "s2dns.h" +#include "s2base.h" +#include "s2sip.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/* -- Globals -------------------------------------------------------------- */ + +struct s2nta *s2; + +/* -- main ----------------------------------------------------------------- */ + +static void usage(int exitcode) +{ + fprintf(exitcode ? stderr : stdout, + "usage: %s [--xml=logfile] case,...\n", s2_tester); + exit(exitcode); +} + +int main(int argc, char *argv[]) +{ + int i, failed = 0, selected = 0; + char const *xml = NULL; + Suite *suite; + SRunner *runner; + + s2_tester = "check_nta"; + s2_suite("NTA"); + + if (getenv("CHECK_NTA_VERBOSE")) + s2_start_stop = strtoul(getenv("CHECK_NTA_VERBOSE"), NULL, 10); + + for (i = 1; argv[i]; i++) { + if (su_strnmatch(argv[i], "--xml=", strlen("--xml="))) { + xml = argv[i] + strlen("--xml="); + } + else if (su_strmatch(argv[i], "--xml")) { + if (!(xml = argv[++i])) + usage(2); + } + else if (su_strmatch(argv[i], "-v")) { + s2_start_stop = 1; + } + else if (su_strmatch(argv[i], "-?") || + su_strmatch(argv[i], "-h") || + su_strmatch(argv[i], "--help")) + usage(0); + else { + s2_select_tests(argv[i]); + selected = 1; + } + } + + if (!selected) + s2_select_tests(getenv("CHECK_NTA_CASES")); + + suite = suite_create("Unit tests for nta (Sofia-SIP Transaction Engine)"); + + suite_add_tcase(suite, check_nta_api_1_0()); + suite_add_tcase(suite, check_nta_client_2_0()); + suite_add_tcase(suite, check_nta_client_2_1()); + + runner = srunner_create(suite); + + if (xml) + srunner_set_xml(runner, argv[1]); + + srunner_run_all(runner, CK_ENV); + failed = srunner_ntests_failed(runner); + srunner_free(runner); + + exit(failed ? EXIT_FAILURE : EXIT_SUCCESS); +} + + +/* -- NTA callbacks -------------------------------------------------------- */ + +struct event * +s2_nta_remove_event(struct event *e) +{ + if ((*e->prev = e->next)) + e->next->prev = e->prev; + e->prev = NULL, e->next = NULL; + return e; +} + +void +s2_nta_free_event(struct event *e) +{ + if (e) { + if (e->prev) { + if ((*e->prev = e->next)) + e->next->prev = e->prev; + } + if (e->msg) + msg_destroy(e->msg); + free(e); + } +} + +void +s2_nta_flush_events(void) +{ + while (s2->events) { + s2_nta_free_event(s2->events); + } +} + +struct event * +s2_nta_next_event(void) +{ + for (;;) { + if (s2->events) + return s2_nta_remove_event(s2->events); + su_root_step(s2->root, 1); + } +} + +struct event * +s2_nta_vwait_for(enum wait_for wait_for0, + void const *value0, + va_list va0) +{ + struct event *e; + + for (;;) { + for (e = s2->events; e; e = e->next) { + va_list va; + enum wait_for wait_for; + void const *value; + + va_copy(va, va0); + + for (wait_for = wait_for0, value = value0; + wait_for; + wait_for = va_arg(va, enum wait_for), + value = va_arg(va, void const *)) { + switch (wait_for) { + case wait_for_amagic: + if (value != e->amagic) + goto next; + break; + case wait_for_omagic: + if (value != e->omagic) + goto next; + break; + case wait_for_orq: + if (value != e->orq) + goto next; + break; + case wait_for_lmagic: + if (value != e->lmagic) + goto next; + break; + case wait_for_leg: + if (value != e->leg) + goto next; + break; + case wait_for_imagic: + if (value != e->imagic) + goto next; + break; + case wait_for_irq: + if (value != e->irq) + goto next; + break; + case wait_for_method: + if ((sip_method_t)value != e->method) + goto next; + break; + case wait_for_method_name: + if (!su_strmatch(value, e->method_name)) + goto next; + break; + case wait_for_status: + if ((int)value != e->status) + goto next; + break; + case wait_for_phrase: + if (!su_casematch(value, e->phrase)) + goto next; + break; + } + } + + next: + va_end(va); + + if (!wait_for) + return s2_nta_remove_event(e); + } + su_root_step(s2->root, 1); + } +} + +struct event * +s2_nta_wait_for(enum wait_for wait_for, + void const *value, + ...) +{ + struct event *e; + va_list va; + + va_start(va, value); + e = s2_nta_vwait_for(wait_for, value, va); + va_end(va); + + return e; +} + +int +s2_nta_check_request(enum wait_for wait_for, + void const *value, + ...) +{ + struct event *e; + va_list va; + + va_start(va, value); + e = s2_nta_vwait_for(wait_for, value, va); + va_end(va); + + s2_nta_free_event(e); + return e != NULL; +} + +int +s2_nta_msg_callback(nta_agent_magic_t *magic, + nta_agent_t *nta, + msg_t *msg, + sip_t *sip) +{ + struct event *e, **prev; + + e = calloc(1, sizeof *e); + + e->amagic = magic; + e->msg = msg; + e->sip = sip; + + if (sip->sip_request) { + e->method = sip->sip_request->rq_method; + e->method_name = sip->sip_request->rq_method_name; + } + else { + e->status = sip->sip_status->st_status; + e->phrase = sip->sip_status->st_phrase; + } + + for (prev = &s2->events; *prev; prev = &(*prev)->next) + ; + *prev = e, e->prev = prev; + + return 0; +} + +int +s2_nta_orq_callback(nta_outgoing_magic_t *magic, + nta_outgoing_t *orq, + sip_t const *sip) +{ + struct event *e, **prev; + + e = calloc(1, sizeof *e); + + e->omagic = magic; + e->orq = orq; + e->msg = nta_outgoing_getresponse(orq); + e->sip = sip_object(e->msg); + + e->status = nta_outgoing_status(orq); + e->phrase = sip ? sip->sip_status->st_phrase : ""; + + for (prev = &s2->events; *prev; prev = &(*prev)->next) + ; + *prev = e, e->prev = prev; + + return 0; +} + +int +s2_nta_leg_callback(nta_leg_magic_t *magic, + nta_leg_t *leg, + nta_incoming_t *irq, + sip_t const *sip) +{ + struct event *e, **prev; + + e = calloc(1, sizeof *e); + + e->lmagic = magic; + e->leg = leg; + e->irq = irq; + + e->msg = nta_incoming_getrequest(irq); + e->sip = sip_object(e->msg); + + e->method = e->sip->sip_request->rq_method; + e->method_name = e->sip->sip_request->rq_method_name; + + for (prev = &s2->events; *prev; prev = &(*prev)->next) + ; + *prev = e, e->prev = prev; + + return 0; +} + +int +s2_nta_irq_callback(nta_incoming_magic_t *magic, + nta_incoming_t *irq, + sip_t const *sip) +{ + struct event *e, **prev; + + e = calloc(1, sizeof *e); + + e->imagic = magic; + e->irq = irq; + e->msg = nta_incoming_getrequest_ackcancel(irq); + e->sip = sip_object(e->msg); + + e->method = e->sip ? e->sip->sip_request->rq_method : 0; + e->method_name = e->sip ? e->sip->sip_request->rq_method_name : NULL; + + for (prev = &s2->events; *prev; prev = &(*prev)->next) + ; + *prev = e, e->prev = prev; + + return 0; +} + +/* ====================================================================== */ + +SOFIAPUBVAR su_log_t nta_log[]; +SOFIAPUBVAR su_log_t sresolv_log[]; +SOFIAPUBVAR su_log_t tport_log[]; +SOFIAPUBVAR su_log_t su_log_default[]; + +void +s2_nta_setup_logs(int level) +{ + su_log_soft_set_level(su_log_default, level); + su_log_soft_set_level(tport_log, level); + su_log_soft_set_level(nta_log, level); + su_log_soft_set_level(sresolv_log, level); + + if (getenv("TPORT_LOG") == NULL && getenv("S2_TPORT_LOG") == NULL) { + if (s2sip) + tport_set_params(s2sip->master, TPTAG_LOG(level > 1), TAG_END()); + } +} + +void +s2_nta_setup(char const *label, + char const * const *transports, + tag_type_t tag, tag_value_t value, ...) +{ + ta_list ta; + + s2_setup(label); + s2_nta_setup_logs(0); + s2_dns_setup(s2base->root); + ta_start(ta, tag, value); + s2_sip_setup("example.org", transports, ta_tags(ta)); + ta_end(ta); + assert(s2sip->contact); + + s2_dns_domain("example.org", 1, + "s2", 1, s2sip->udp.contact ? s2sip->udp.contact->m_url : NULL, + "s2", 1, s2sip->tcp.contact ? s2sip->tcp.contact->m_url : NULL, + "s2", 1, s2sip->tls.contact ? s2sip->tls.contact->m_url : NULL, + NULL); +} + +nta_agent_t * +s2_nta_agent_setup(url_string_t const *bind_url, + nta_message_f *callback, + nta_agent_magic_t *magic, + tag_type_t tag, tag_value_t value, ...) +{ + ta_list ta; + + assert(s2base); + + s2 = su_home_new(sizeof *s2); assert(s2); + s2->root = su_root_clone(s2base->root, s2); assert(s2->root); + fail_unless(s2->root != NULL); + + ta_start(ta, tag, value); + s2->nta = + nta_agent_create(s2->root, + bind_url ? bind_url : URL_STRING_MAKE("sip:*:*"), + callback, + magic, + /* Use internal DNS server */ + /* Force sresolv to use localhost and s2dns as DNS server */ +#if HAVE_WIN32 + SRESTAG_RESOLV_CONF("NUL"), +#else + SRESTAG_RESOLV_CONF("/dev/null"), +#endif + ta_tags(ta)); + ta_end(ta); + + assert(s2->nta); + + if (callback == NULL) + s2->default_leg = nta_leg_tcreate(s2->nta, s2_nta_leg_callback, NULL, + NTATAG_NO_DIALOG(1), + TAG_END()); + + return s2->nta; +} + +void s2_nta_teardown(void) +{ + if (s2) { + s2_nta_flush_events(); + + if (s2->default_leg) + nta_leg_destroy(s2->default_leg), s2->default_leg = NULL; + nta_agent_destroy(s2->nta), s2->nta = NULL; + su_root_destroy(s2->root), s2->root = NULL; + su_home_unref(s2->home); + s2 = NULL; + } + + s2_dns_teardown(); + s2_sip_teardown(); + s2_teardown(); +} Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta.h ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta.h Tue Mar 10 14:55:00 2009 @@ -0,0 +1,132 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef CHECK_NTA_H +#define CHECK_NTA_H + +#include + +#include +#include +#include + +#include + +#include "s2sip.h" + +extern struct s2nta { + su_home_t home[1]; + + nta_agent_t *nta; + + su_root_t *root; + + nta_leg_t *default_leg; + + struct event { + struct event *next, **prev; + + nta_agent_magic_t *amagic; + + nta_outgoing_magic_t *omagic; + nta_outgoing_t *orq; + + nta_leg_magic_t *lmagic; + nta_leg_t *leg; + + nta_incoming_magic_t *imagic; + nta_incoming_t *irq; + + sip_method_t method; + char const *method_name; + + int status; + char const *phrase; + + msg_t *msg; + sip_t *sip; + } *events; +} *s2; + +struct event *s2_nta_remove_event(struct event *e); +void s2_nta_free_event(struct event *e); +void s2_nta_flush_events(void); +struct event *s2_nta_next_event(void); + +enum wait_for { + wait_for_amagic = 1, + wait_for_omagic, + wait_for_orq, + wait_for_lmagic, + wait_for_leg, + wait_for_imagic, + wait_for_irq, + wait_for_method, + wait_for_method_name, + wait_for_status, + wait_for_phrase +}; + +struct event *s2_nta_vwait_for(enum wait_for, + void const *value, + va_list va); + +struct event *s2_nta_wait_for(enum wait_for, + void const *value, + ...); + +int s2_nta_check_for(enum wait_for, + void const *value, + ...); + +int s2_nta_msg_callback(nta_agent_magic_t *magic, + nta_agent_t *nta, + msg_t *msg, + sip_t *sip); +int s2_nta_orq_callback(nta_outgoing_magic_t *magic, + nta_outgoing_t *orq, + sip_t const *sip); +int s2_nta_leg_callback(nta_leg_magic_t *magic, + nta_leg_t *leg, + nta_incoming_t *irq, + sip_t const *sip); +int s2_nta_irq_callback(nta_incoming_magic_t *magic, + nta_incoming_t *irq, + sip_t const *sip); + +void s2_nta_setup_logs(int level); +void s2_nta_setup(char const *label, + char const * const *transports, + tag_type_t tag, tag_value_t value, ...); + +nta_agent_t *s2_nta_agent_setup(url_string_t const *bind_url, + nta_message_f *callback, + nta_agent_magic_t *magic, + tag_type_t tag, tag_value_t value, ...); +void s2_nta_teardown(void); + +TCase *check_nta_api_1_0(void); +TCase *check_nta_client_2_0(void); +TCase *check_nta_client_2_1(void); + +#endif Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_api.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_api.c Tue Mar 10 14:55:00 2009 @@ -0,0 +1,268 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE check_nta_api.c + * + * @brief Check-driven tester for NTA API + * + * @author Pekka Pessi + * + * @copyright (C) 2009 Nokia Corporation. + */ + +#include "config.h" + +#include "check_nta.h" +#include "s2base.h" +#include "nta_internal.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define NONE ((void *)-1) + +static void +api_setup(void) +{ + s2_nta_setup("NTA", NULL, TAG_END()); +} + +static void +api_teardown(void) +{ + mark_point(); + s2_nta_teardown(); +} + +START_TEST(api_1_0_0) +{ + su_root_t *root = s2base->root; + nta_agent_t *nta; + su_home_t home[1]; + su_nanotime_t nano; + nta_agent_magic_t *amagic = (void *)(home + 1); + nta_outgoing_magic_t *omagic = (void *)(home + 2); + msg_t *msg; + + memset(home, 0, sizeof home); home->suh_size = (sizeof home); + su_home_init(home); + + fail_unless(nta_agent_create(NULL, + (url_string_t *)"sip:*:*", + NULL, + NULL, + TAG_END()) == NULL); + + fail_unless(nta_agent_create(root, + (url_string_t *)"http://localhost:*/invalid/bind/url", + NULL, + NULL, + TAG_END()) == NULL); + + fail_unless(nta_agent_create(root, + (url_string_t *)"sip:*:*;transport=XXX", + NULL, + NULL, + TAG_END()) == NULL); + mark_point(); + nta = nta_agent_create(root, + (url_string_t *)"sip:*:*", + NULL, + NULL, + TAG_END()); + fail_unless(nta != NULL); + + mark_point(); + nta_agent_destroy(NULL); + mark_point(); + nta_agent_destroy(nta); + + mark_point(); + nta = nta_agent_create(root, + (url_string_t *)"sip:*:*", + s2_nta_msg_callback, + amagic, + TAG_END()); + fail_unless(nta != NULL); + + fail_unless(nta_agent_contact(NULL) == NULL); + fail_unless(nta_agent_via(NULL) == NULL); + fail_if(strcmp(nta_agent_version(nta), nta_agent_version(NULL))); + fail_unless(nta_agent_magic(NULL) == NULL); + fail_unless(nta_agent_magic(nta) == amagic); + fail_unless(nta_agent_add_tport(NULL, NULL, TAG_END()) == -1); + fail_unless(nta_agent_newtag(home, "tag=%s", NULL) == NULL); + fail_unless(nta_agent_newtag(home, "tag=%s", nta) != NULL); + + fail_unless(nta_msg_create(NULL, 0) == NULL); + fail_unless(nta_msg_complete(NULL) == -1); + + fail_unless((msg = nta_msg_create(nta, 0)) != NULL); + fail_unless(nta_msg_complete(msg) == -1); + fail_unless( + nta_msg_request_complete(msg, NULL, SIP_METHOD(FOO), NULL) == -1); + fail_unless(nta_is_internal_msg(NULL) == 0); + fail_unless(nta_is_internal_msg(msg) == 0); + fail_unless(msg_set_flags(msg, NTA_INTERNAL_MSG)); + fail_unless(nta_is_internal_msg(msg) == 1); + mark_point(); msg_destroy(msg); mark_point(); + + fail_unless(nta_leg_tcreate(NULL, NULL, NULL, TAG_END()) == NULL); + mark_point(); nta_leg_destroy(NULL); mark_point(); + fail_unless(nta_leg_magic(NULL, NULL) == NULL); + mark_point(); nta_leg_bind(NULL, NULL, NULL); mark_point(); + fail_unless(nta_leg_tag(NULL, "fidsafsa") == NULL); + fail_unless(nta_leg_rtag(NULL, "fidsafsa") == NULL); + fail_unless(nta_leg_get_tag(NULL) == NULL); + fail_unless(nta_leg_client_route(NULL, NULL, NULL) == -1); + fail_unless(nta_leg_client_reroute(NULL, NULL, NULL, 0) == -1); + fail_unless(nta_leg_server_route(NULL, NULL, NULL) == -1); + fail_unless(nta_leg_by_uri(NULL, NULL) == NULL); + fail_unless( + nta_leg_by_dialog(NULL, NULL, NULL, NULL, NULL, NULL, NULL) == NULL); + fail_unless( + nta_leg_by_dialog(nta, NULL, NULL, NULL, NULL, NULL, NULL) == NULL); + + fail_unless(nta_leg_make_replaces(NULL, NULL, 1) == NULL); + fail_unless(nta_leg_by_replaces(NULL, NULL) == NULL); + + fail_unless(nta_incoming_create(NULL, NULL, NULL, NULL, TAG_END()) == NULL); + fail_unless(nta_incoming_create(nta, NULL, NULL, NULL, TAG_END()) == NULL); + + mark_point(); nta_incoming_bind(NULL, NULL, NULL); mark_point(); + fail_unless(nta_incoming_magic(NULL, NULL) == NULL); + + fail_unless(nta_incoming_find(NULL, NULL, NULL) == NULL); + fail_unless(nta_incoming_find(nta, NULL, NULL) == NULL); + + fail_unless(nta_incoming_tag(NULL, NULL) == NULL); + fail_unless(nta_incoming_gettag(NULL) == NULL); + + fail_unless(nta_incoming_status(NULL) == 400); + fail_unless(nta_incoming_method(NULL) == sip_method_invalid); + fail_unless(nta_incoming_method_name(NULL) == NULL); + fail_unless(nta_incoming_url(NULL) == NULL); + fail_unless(nta_incoming_cseq(NULL) == 0); + fail_unless(nta_incoming_received(NULL, &nano) == 0); + fail_unless(nano == 0); + + fail_unless(nta_incoming_set_params(NULL, TAG_END()) == -1); + + fail_unless(nta_incoming_getrequest(NULL) == NULL); + fail_unless(nta_incoming_getrequest_ackcancel(NULL) == NULL); + fail_unless(nta_incoming_getresponse(NULL) == NULL); + + fail_unless( + nta_incoming_complete_response(NULL, NULL, 800, "foo", TAG_END()) == -1); + + fail_unless(nta_incoming_treply(NULL, SIP_200_OK, TAG_END()) == -1); + fail_unless(nta_incoming_mreply(NULL, NULL) == -1); + + mark_point(); nta_incoming_destroy(NULL); mark_point(); + + fail_unless( + nta_outgoing_tcreate(NULL, s2_nta_orq_callback, omagic, + URL_STRING_MAKE("sip:localhost"), + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:localhost"), + TAG_END()) == NULL); + + fail_unless( + nta_outgoing_mcreate(NULL, s2_nta_orq_callback, omagic, + URL_STRING_MAKE("sip:localhost"), + NULL, + TAG_END()) == NULL); + + fail_unless(nta_outgoing_default(NULL, NULL, NULL) == NULL); + + fail_unless(nta_outgoing_bind(NULL, NULL, NULL) == -1); + fail_unless(nta_outgoing_magic(NULL, NULL) == NULL); + + fail_unless(nta_outgoing_status(NULL) == 500); + fail_unless(nta_outgoing_method(NULL) == sip_method_invalid); + fail_unless(nta_outgoing_method_name(NULL) == NULL); + fail_unless(nta_outgoing_cseq(NULL) == 0); + + fail_unless(nta_outgoing_delay(NULL) == UINT_MAX); + fail_unless(nta_outgoing_request_uri(NULL) == NULL); + fail_unless(nta_outgoing_route_uri(NULL) == NULL); + + fail_unless(nta_outgoing_getresponse(NULL) == NULL); + fail_unless(nta_outgoing_getrequest(NULL) == NULL); + + fail_unless(nta_outgoing_tagged(NULL, NULL, NULL, NULL, NULL) == NULL); + fail_unless(nta_outgoing_cancel(NULL) == -1); + fail_unless(nta_outgoing_tcancel(NULL, NULL, NULL, TAG_END()) == NULL); + mark_point(); nta_outgoing_destroy(NULL); mark_point(); + + fail_unless(nta_outgoing_find(NULL, NULL, NULL, NULL) == NULL); + fail_unless(nta_outgoing_find(nta, NULL, NULL, NULL) == NULL); + + fail_unless(nta_outgoing_status(NONE) == 500); + fail_unless(nta_outgoing_method(NONE) == sip_method_invalid); + fail_unless(nta_outgoing_method_name(NONE) == NULL); + fail_unless(nta_outgoing_cseq(NONE) == 0); + + fail_unless(nta_outgoing_delay(NONE) == UINT_MAX); + fail_unless(nta_outgoing_request_uri(NONE) == NULL); + fail_unless(nta_outgoing_route_uri(NONE) == NULL); + + fail_unless(nta_outgoing_getresponse(NONE) == NULL); + fail_unless(nta_outgoing_getrequest(NONE) == NULL); + + fail_unless(nta_outgoing_tagged(NONE, NULL, NULL, NULL, NULL) == NULL); + fail_unless(nta_outgoing_cancel(NONE) == -1); + fail_unless(nta_outgoing_tcancel(NONE, NULL, NULL, TAG_END()) == NULL); + mark_point(); nta_outgoing_destroy(NONE); mark_point(); + + fail_unless(nta_reliable_treply(NULL, NULL, NULL, 0, NULL, TAG_END()) == NULL); + fail_unless(nta_reliable_mreply(NULL, NULL, NULL, NULL) == NULL); + mark_point(); nta_reliable_destroy(NULL); mark_point(); + + mark_point(); nta_agent_destroy(nta); mark_point(); + mark_point(); su_home_deinit(home); mark_point(); +} +END_TEST + +/* ---------------------------------------------------------------------- */ + +TCase *check_nta_api_1_0(void) +{ + TCase *tc = tcase_create("NTA 1 - API"); + + tcase_add_checked_fixture(tc, api_setup, api_teardown); + + tcase_set_timeout(tc, 10); + + tcase_add_test(tc, api_1_0_0); + + return tc; +} Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c Tue Mar 10 14:55:00 2009 @@ -0,0 +1,388 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2008 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE check_nta_client.c + * + * @brief Check-driven tester for NTA client transactions + * + * @author Pekka Pessi + * + * @copyright (C) 2009 Nokia Corporation. + */ + +#include "config.h" + +#include "check_nta.h" +#include "s2base.h" +#include "s2dns.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define NONE ((void *)-1) + +static void +client_setup(void) +{ + s2_nta_setup("NTA", NULL, TAG_END()); + s2_nta_agent_setup(URL_STRING_MAKE("sip:0.0.0.0:*"), NULL, NULL, + NTATAG_DEFAULT_PROXY("sip:example.org"), + TAG_END()); +} + +static void +client_setup_udp_only_server(void) +{ + char const * const transports[] = { "udp", NULL }; + + s2_nta_setup("NTA", transports, TAG_END()); + s2_nta_agent_setup(URL_STRING_MAKE("sip:0.0.0.0:*"), NULL, NULL, + NTATAG_DEFAULT_PROXY(s2sip->contact->m_url), + TAG_END()); +} + +static void +client_setup_tcp_only_server(void) +{ + char const * const transports[] = { "tcp", NULL }; + + s2_nta_setup("NTA", transports, TAG_END()); + s2_nta_agent_setup(URL_STRING_MAKE("sip:0.0.0.0:*"), NULL, NULL, + NTATAG_DEFAULT_PROXY(s2sip->contact->m_url), + TAG_END()); +} + +static void +client_teardown(void) +{ + mark_point(); + s2_nta_teardown(); +} + +START_TEST(client_2_0_0) +{ + nta_outgoing_t *orq; + struct message *request; + struct event *response; + + s2_case("2.0.0", "Send MESSAGE", + "Basic non-INVITE transaction with outbound proxy"); + + orq = nta_outgoing_tcreate(s2->default_leg, + s2_nta_orq_callback, NULL, NULL, + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:test2.0.example.org"), + SIPTAG_FROM_STR(""), + TAG_END()); + fail_unless(orq != NULL); + request = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); + fail_unless(request != NULL); + s2_sip_respond_to(request, NULL, 200, "2.0.0", TAG_END()); + response = s2_nta_wait_for(wait_for_orq, orq, + wait_for_status, 200, + 0); + s2_sip_free_message(request); + s2_nta_free_event(response); + nta_outgoing_destroy(orq); +} +END_TEST + +START_TEST(client_2_0_1) +{ + nta_outgoing_t *orq; + struct message *request; + struct event *response; + + s2_case("2.0.0", "Send MESSAGE", + "Basic non-INVITE transaction with " + "numeric per-transaction outbound proxy"); + + orq = nta_outgoing_tcreate(s2->default_leg, + s2_nta_orq_callback, NULL, + (url_string_t *)s2sip->contact->m_url, + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:test2.0.example.org"), + SIPTAG_FROM_STR(""), + TAG_END()); + fail_unless(orq != NULL); + request = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); + fail_unless(request != NULL); + s2_sip_respond_to(request, NULL, 200, "OK 2.0.1", TAG_END()); + response = s2_nta_wait_for(wait_for_orq, orq, + wait_for_status, 200, + 0); + s2_sip_free_message(request); + s2_nta_free_event(response); + nta_outgoing_destroy(orq); +} +END_TEST + +START_TEST(client_2_0_2) +{ + nta_outgoing_t *orq; + struct message *request; + struct event *response; + + char payload[2048]; + + s2_case("2.0.2", "Send MESSAGE", + "Basic non-INVITE transaction exceeding " + "default path MTU (1300 bytes)"); + + memset(payload, 'x', sizeof payload); + payload[(sizeof payload) - 1] = '\0'; + + orq = nta_outgoing_tcreate(s2->default_leg, + s2_nta_orq_callback, NULL, NULL, + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:test2.0.example.org"), + SIPTAG_FROM_STR(""), + SIPTAG_PAYLOAD_STR(payload), + TAG_END()); + fail_unless(orq != NULL); + request = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); + fail_unless(request != NULL); + fail_unless(request->sip->sip_via->v_protocol == sip_transport_tcp); + + s2_sip_respond_to(request, NULL, 200, "OK 2.0.2", TAG_END()); + response = s2_nta_wait_for(wait_for_orq, orq, + wait_for_status, 200, + 0); + s2_nta_free_event(response); + nta_outgoing_destroy(orq); +} +END_TEST + +/* ---------------------------------------------------------------------- */ + +TCase *check_nta_client_2_0(void) +{ + TCase *tc = tcase_create("NTA 2.0 - Client"); + + tcase_add_checked_fixture(tc, client_setup, client_teardown); + + tcase_set_timeout(tc, 2); + + tcase_add_test(tc, client_2_0_0); + tcase_add_test(tc, client_2_0_1); + tcase_add_test(tc, client_2_0_2); + + return tc; +} + +/* ---------------------------------------------------------------------- */ + +START_TEST(client_2_1_0) +{ + nta_outgoing_t *orq; + struct message *request; + struct event *response; + + char payload[2048]; + + s2_case("2.1.0", "Try UDP after trying with TCP", + "TCP connect() is refused"); + + memset(payload, 'x', sizeof payload); + payload[(sizeof payload) - 1] = '\0'; + + client_setup_udp_only_server(); + + orq = nta_outgoing_tcreate(s2->default_leg, + s2_nta_orq_callback, NULL, NULL, + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:test2.0.example.org"), + SIPTAG_FROM_STR(""), + SIPTAG_PAYLOAD_STR(payload), + TAG_END()); + fail_unless(orq != NULL); + + request = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); + fail_unless(request != NULL); + fail_unless(request->sip->sip_via->v_protocol == sip_transport_udp); + s2_sip_respond_to(request, NULL, 200, "OK", TAG_END()); + s2_sip_free_message(request); + + response = s2_nta_wait_for(wait_for_orq, orq, + wait_for_status, 200, + 0); + s2_nta_free_event(response); + nta_outgoing_destroy(orq); +} +END_TEST + +#undef SU_LOG + +#include "tport_internal.h" + +tport_vtable_t hacked_tcp_vtable; + +/* Make TCP connection to 192.168.255.2:9999 */ +static tport_t * +hacked_tcp_connect(tport_primary_t *pri, + su_addrinfo_t *ai, + tp_name_t const *tpn) +{ + su_addrinfo_t fake_ai[1]; + su_sockaddr_t fake_addr[1]; + uint32_t fake_ip = htonl(0xc0a8ff02); /* 192.168.255.2 */ + + *fake_ai = *ai; + assert(ai->ai_addrlen <= (sizeof fake_addr)); + fake_ai->ai_addr = memcpy(fake_addr, ai->ai_addr, ai->ai_addrlen); + + fake_ai->ai_family = AF_INET; + fake_addr->su_family = AF_INET; + memcpy(&fake_addr->su_sin.sin_addr, &fake_ip, sizeof fake_ip); + fake_addr->su_sin.sin_port = htons(9999); + + return tport_base_connect(pri, fake_ai, ai, tpn); +} + +START_TEST(client_2_1_1) +{ + tport_t *tp; + + nta_outgoing_t *orq; + struct message *request; + struct event *response; + + char payload[2048]; + + s2_case("2.1.1", "Try UDP after trying with TCP", + "TCP connect() times out"); + + memset(payload, 'x', sizeof payload); + payload[(sizeof payload) - 1] = '\0'; + + client_setup_udp_only_server(); + + hacked_tcp_vtable = tport_tcp_vtable; + hacked_tcp_vtable.vtp_connect = hacked_tcp_connect; + fail_unless(tport_tcp_vtable.vtp_connect == NULL); + + for (tp = tport_primaries(nta_agent_tports(s2->nta)); + tp; + tp = tport_next(tp)) { + if (tport_is_tcp(tp)) { + tp->tp_pri->pri_vtable = &hacked_tcp_vtable; + break; + } + } + + orq = nta_outgoing_tcreate(s2->default_leg, + s2_nta_orq_callback, NULL, + NULL, + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:test2.0.example.org"), + SIPTAG_FROM_STR(""), + SIPTAG_PAYLOAD_STR(payload), + TAG_END()); + fail_unless(orq != NULL); + + s2_fast_forward(1, s2->root); + s2_fast_forward(1, s2->root); + s2_fast_forward(1, s2->root); + s2_fast_forward(1, s2->root); + s2_fast_forward(1, s2->root); + + request = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); + fail_unless(request != NULL); + fail_unless(request->sip->sip_via->v_protocol == sip_transport_udp); + s2_sip_respond_to(request, NULL, 200, "OK", TAG_END()); + s2_sip_free_message(request); + + response = s2_nta_wait_for(wait_for_orq, orq, + wait_for_status, 200, + 0); + s2_nta_free_event(response); + nta_outgoing_destroy(orq); +} +END_TEST + +START_TEST(client_2_1_2) +{ + nta_outgoing_t *orq; + struct message *request; + struct event *response; + url_t udpurl[1]; + + s2_case("2.1.2", "Send MESSAGE", + "Non-INVITE transaction to TCP-only server"); + + client_setup_tcp_only_server(); + + *udpurl = *s2sip->tcp.contact->m_url; + udpurl->url_params = "transport=udp"; + + /* Create DNS records for both UDP and TCP */ + s2_dns_domain("udptcp.org", 1, + "s2", 1, udpurl, + "s2", 1, s2sip->tcp.contact->m_url, + NULL); + + orq = nta_outgoing_tcreate(s2->default_leg, + s2_nta_orq_callback, NULL, + URL_STRING_MAKE("sip:udptcp.org"), + SIP_METHOD_MESSAGE, + URL_STRING_MAKE("sip:test2.0.example.org"), + SIPTAG_FROM_STR(""), + TAG_END()); + fail_unless(orq != NULL); + request = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); + fail_unless(request != NULL); + s2_sip_respond_to(request, NULL, 200, "2.0.0", TAG_END()); + s2_sip_free_message(request); + response = s2_nta_wait_for(wait_for_orq, orq, + wait_for_status, 200, + 0); + s2_nta_free_event(response); + nta_outgoing_destroy(orq); +} +END_TEST + + +TCase *check_nta_client_2_1(void) +{ + TCase *tc = tcase_create("NTA 2.1 - Client"); + + tcase_add_checked_fixture(tc, NULL, client_teardown); + + tcase_set_timeout(tc, 20); + + tcase_add_test(tc, client_2_1_0); + tcase_add_test(tc, client_2_1_1); + tcase_add_test(tc, client_2_1_2); + + return tc; +} Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_check_nta ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_check_nta Tue Mar 10 14:55:00 2009 @@ -0,0 +1,2 @@ +#!/bin/sh +$VALGRIND exec ./check_nta "$@" \ No newline at end of file From mikej at freeswitch.org Tue Mar 10 12:56:27 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:56:27 -0500 Subject: [Freeswitch-svn] [commit] r12555 - freeswitch/trunk/libs/sofia-sip Message-ID: Author: mikej Date: Tue Mar 10 14:56:27 2009 New Revision: 12555 Log: Thu Mar 5 08:22:19 CST 2009 Pekka Pessi * configure.ac: added AC_CONFIG_MACRO_DIR([m4]) Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/configure.ac Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:56:27 2009 @@ -1 +1 @@ -Tue Mar 10 14:53:54 CDT 2009 +Tue Mar 10 14:55:35 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/configure.ac ============================================================================== --- freeswitch/trunk/libs/sofia-sip/configure.ac (original) +++ freeswitch/trunk/libs/sofia-sip/configure.ac Tue Mar 10 14:56:27 2009 @@ -13,6 +13,7 @@ dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR AC_INIT([sofia-sip], [1.12.10devel]) AC_CONFIG_SRCDIR([libsofia-sip-ua/sip/sofia-sip/sip.h]) +AC_CONFIG_MACRO_DIR([m4]) AC_SUBST(VER_LIBSOFIA_SIP_UA_MAJOR_MINOR, [1.12]) dnl Includedir specific to this sofia version AC_SUBST(include_sofiadir, '${includedir}/sofia-sip-1.12') From mikej at freeswitch.org Tue Mar 10 12:57:32 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:57:32 -0500 Subject: [Freeswitch-svn] [commit] r12556 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta libsofia-sip-ua/nta/sofia-sip Message-ID: Author: mikej Date: Tue Mar 10 14:57:32 2009 New Revision: 12556 Log: Wed Mar 4 12:22:52 CST 2009 Pekka Pessi * nta: add nta_outgoing_magic() Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:57:32 2009 @@ -1 +1 @@ -Tue Mar 10 14:55:35 CDT 2009 +Tue Mar 10 14:56:15 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 10 14:57:32 2009 @@ -7414,6 +7414,28 @@ return -1; } +/**Get application context bound to a client transaction. + * + * @param orq outgoing client transaction + * @param callback callback function (may be NULL) + * + * Return the application context bound to a client transaction. If the @a + * callback function pointer is given, return application context only if + * the callback matches with the callback bound to the client transaction. + * + * @NEW_1_12_11 + */ +nta_outgoing_magic_t * +nta_outgoing_magic(nta_outgoing_t const *orq, + nta_response_f *callback) +{ + if (orq && (callback == NULL || callback == orq->orq_callback)) + return orq->orq_magic; + else + return NULL; +} + + /** * Destroy a request object. * Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h Tue Mar 10 14:57:32 2009 @@ -393,6 +393,8 @@ SOFIAPUBFUN int nta_outgoing_bind(nta_outgoing_t *orq, nta_response_f *callback, nta_outgoing_magic_t *magic); +SOFIAPUBFUN nta_outgoing_magic_t *nta_outgoing_magic(nta_outgoing_t const *orq, + nta_response_f *callback); SOFIAPUBFUN int nta_outgoing_status(nta_outgoing_t const *orq); SOFIAPUBFUN sip_method_t nta_outgoing_method(nta_outgoing_t const *orq); SOFIAPUBFUN char const *nta_outgoing_method_name(nta_outgoing_t const *orq); From mikej at freeswitch.org Tue Mar 10 12:58:34 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 14:58:34 -0500 Subject: [Freeswitch-svn] [commit] r12557 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 10 14:58:34 2009 New Revision: 12557 Log: Wed Mar 4 12:24:57 CST 2009 Pekka Pessi * nta_incoming_magic(): if callback is NULL, return any magic Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 10 14:58:34 2009 @@ -1 +1 @@ -Tue Mar 10 14:56:15 CDT 2009 +Tue Mar 10 14:57:43 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 10 14:58:34 2009 @@ -5828,11 +5828,21 @@ return irq ? irq->irq_status : 400; } -/** Get context pointer for an incoming transaction */ +/** Get application context for a server transaction. + * + * @param irq server transaction + * @param callback callback pointer + * + * Return the application context bound to the server transaction. If the @a + * callback function pointer is given, return application context only if + * the callback matches with the callback bound to the server transaction. + * + */ nta_incoming_magic_t *nta_incoming_magic(nta_incoming_t *irq, nta_ack_cancel_f *callback) { - return irq && irq->irq_callback == callback ? irq->irq_magic : NULL; + return irq && (callback == NULL || irq->irq_callback == callback) + ? irq->irq_magic : NULL; } /** When received. From mikej at freeswitch.org Tue Mar 10 14:38:46 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 16:38:46 -0500 Subject: [Freeswitch-svn] [commit] r12558 - in freeswitch/trunk/src/mod/languages/mod_managed: . managed Message-ID: Author: mikej Date: Tue Mar 10 16:38:45 2009 New Revision: 12558 Log: swigall Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx (original) +++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx Tue Mar 10 16:38:45 2009 @@ -3824,6 +3824,26 @@ } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_vmprintf(char * jarg1, void * jarg2) { + char * jresult ; + char *arg1 = (char *) 0 ; + va_list arg2 ; + char *result = 0 ; + va_list *argp2 ; + + arg1 = (char *)jarg1; + argp2 = (va_list *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null va_list", 0); + return 0; + } + arg2 = *argp2; + result = (char *)switch_vmprintf((char const *)arg1,arg2); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_regex_compile(char * jarg1, int jarg2, void * jarg3, void * jarg4, void * jarg5) { void * jresult ; char *arg1 = (char *) 0 ; @@ -5010,6 +5030,20 @@ } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_remove_callback(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_media_bug_callback_t arg2 = (switch_media_bug_callback_t) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_media_bug_callback_t)jarg2; + result = (switch_status_t)switch_core_media_bug_remove_callback(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_close(void * jarg1) { int jresult ; switch_media_bug_t **arg1 = (switch_media_bug_t **) 0 ; @@ -10617,6 +10651,29 @@ } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_on_reporting_set(void * jarg1, void * jarg2) { + switch_state_handler_table *arg1 = (switch_state_handler_table *) 0 ; + switch_state_handler_t arg2 = (switch_state_handler_t) 0 ; + + arg1 = (switch_state_handler_table *)jarg1; + arg2 = (switch_state_handler_t)jarg2; + if (arg1) (arg1)->on_reporting = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_state_handler_table_on_reporting_get(void * jarg1) { + void * jresult ; + switch_state_handler_table *arg1 = (switch_state_handler_table *) 0 ; + switch_state_handler_t result; + + arg1 = (switch_state_handler_table *)jarg1; + result = (switch_state_handler_t) ((arg1)->on_reporting); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_state_handler_table_padding_set(void * jarg1, void * jarg2) { switch_state_handler_table *arg1 = (switch_state_handler_table *) 0 ; void **arg2 ; Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs (original) +++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs Tue Mar 10 16:38:45 2009 @@ -817,6 +817,12 @@ return ret; } + public static string switch_vmprintf(string zFormat, SWIGTYPE_p_va_list ap) { + string ret = freeswitchPINVOKE.switch_vmprintf(zFormat, SWIGTYPE_p_va_list.getCPtr(ap)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static SWIGTYPE_p_real_pcre switch_regex_compile(string pattern, int options, ref string errorptr, SWIGTYPE_p_int erroroffset, SWIGTYPE_p_unsigned_char tables) { IntPtr cPtr = freeswitchPINVOKE.switch_regex_compile(pattern, options, ref errorptr, SWIGTYPE_p_int.getCPtr(erroroffset), SWIGTYPE_p_unsigned_char.getCPtr(tables)); SWIGTYPE_p_real_pcre ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_real_pcre(cPtr, false); @@ -924,6 +930,11 @@ return ret; } + public static switch_status_t switch_core_media_bug_remove_callback(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t callback) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_remove_callback(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t.getCPtr(callback)); + return ret; + } + public static switch_status_t switch_core_media_bug_close(SWIGTYPE_p_p_switch_media_bug bug) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_close(SWIGTYPE_p_p_switch_media_bug.getCPtr(bug)); return ret; @@ -5340,6 +5351,9 @@ [DllImport("mod_managed", EntryPoint="CSharp_switch_mprintf")] public static extern string switch_mprintf(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_vmprintf")] + public static extern string switch_vmprintf(string jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_regex_compile")] public static extern IntPtr switch_regex_compile(string jarg1, int jarg2, ref string jarg3, HandleRef jarg4, HandleRef jarg5); @@ -5622,6 +5636,9 @@ [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_remove")] public static extern int switch_core_media_bug_remove(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_remove_callback")] + public static extern int switch_core_media_bug_remove_callback(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_close")] public static extern int switch_core_media_bug_close(HandleRef jarg1); @@ -6873,6 +6890,12 @@ [DllImport("mod_managed", EntryPoint="CSharp_switch_state_handler_table_on_park_get")] public static extern IntPtr switch_state_handler_table_on_park_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_state_handler_table_on_reporting_set")] + public static extern void switch_state_handler_table_on_reporting_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_state_handler_table_on_reporting_get")] + public static extern IntPtr switch_state_handler_table_on_reporting_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_state_handler_table_padding_set")] public static extern void switch_state_handler_table_padding_set(HandleRef jarg1, HandleRef jarg2); @@ -15384,6 +15407,36 @@ using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_va_list { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_va_list(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_va_list() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_va_list obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.35 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_void { private HandleRef swigCPtr; @@ -17230,6 +17283,7 @@ namespace FreeSWITCH.Native { [System.Flags] public enum switch_caller_profile_flag_enum_t { + SWITCH_CPF_NONE = 0, SWITCH_CPF_SCREEN = (1 << 0), SWITCH_CPF_HIDE_NAME = (1 << 1), SWITCH_CPF_HIDE_NUMBER = (1 << 2) @@ -17294,6 +17348,7 @@ CF_VERBOSE_EVENTS, CF_PAUSE_BUGS, CF_DIVERT_EVENTS, + CF_BLOCK_STATE, CF_FLAG_MAX } @@ -17320,6 +17375,7 @@ CS_HIBERNATE, CS_RESET, CS_HANGUP, + CS_REPORTING, CS_DONE, CS_NONE } @@ -20058,6 +20114,7 @@ public enum switch_event_types_t { SWITCH_EVENT_CUSTOM, + SWITCH_EVENT_CLONE, SWITCH_EVENT_CHANNEL_CREATE, SWITCH_EVENT_CHANNEL_DESTROY, SWITCH_EVENT_CHANNEL_STATE, @@ -24071,7 +24128,8 @@ SWITCH_SHN_ON_CONSUME_MEDIA, SWITCH_SHN_ON_HIBERNATE, SWITCH_SHN_ON_RESET, - SWITCH_SHN_ON_PARK + SWITCH_SHN_ON_PARK, + SWITCH_SHN_ON_REPORTING } } @@ -24226,6 +24284,17 @@ } } + public SWIGTYPE_p_f_p_switch_core_session__switch_status_t on_reporting { + set { + freeswitchPINVOKE.switch_state_handler_table_on_reporting_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_state_handler_table_on_reporting_get(swigCPtr); + SWIGTYPE_p_f_p_switch_core_session__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session__switch_status_t(cPtr, false); + return ret; + } + } + public SWIGTYPE_p_p_void padding { set { freeswitchPINVOKE.switch_state_handler_table_padding_set(swigCPtr, SWIGTYPE_p_p_void.getCPtr(value)); From mrene at freeswitch.org Tue Mar 10 14:42:10 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 16:42:10 -0500 Subject: [Freeswitch-svn] [commit] r12559 - in freeswitch/trunk/scripts/contrib/mrene/textmate: . FreeSWITCH.tmbundle FreeSWITCH.tmbundle/Snippets Message-ID: Author: mrene Date: Tue Mar 10 16:42:10 2009 New Revision: 12559 Log: TextMate bundle Added: freeswitch/trunk/scripts/contrib/mrene/textmate/ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_ADD_API.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_ADD_APP.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_core_session_locate.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_log_printf.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_mutex_lock.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_mutex_unlock.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_rdlock.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_tryrdlock.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_unlock.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_wrlock.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/untitled.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/info.plist Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_ADD_API.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_ADD_API.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,15 @@ + + + + + content + SWITCH_ADD_API(api_interface, "${1:app name}", "${2:description}",${3:function ptr}, "${4:syntax}"); + + name + SWITCH_ADD_API + tabTrigger + addapi + uuid + 63A39832-470E-4839-8098-4CC537FAA46D + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_ADD_APP.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_ADD_APP.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,15 @@ + + + + + content + SWITCH_ADD_APP(app_interface, "${1:name}", "${2:short description}", "${3:long description}", ${4:function}, "${5:syntax}", ${6:SAF_NONE}); + + name + SWITCH_ADD_APP + tabTrigger + addapp + uuid + 1D16269D-A544-4909-867E-70028ED7961B + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_core_session_locate.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_core_session_locate.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,17 @@ + + + + + content + if ((${1:session} = switch_core_session_locate($2)) { + $0 + switch_core_session_rwunlock($1); +} + name + switch_core_session_locate + tabTrigger + slocate + uuid + 8940F795-2A0A-411F-AB98-48DEAB07AD69 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_log_printf.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_log_printf.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,15 @@ + + + + + content + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_${1:DEBUG}, "$2"$3); + + name + switch_log_printf + tabTrigger + log + uuid + CCE4CE1C-2E71-4EDB-9733-1CDE38FA831E + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_mutex_lock.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_mutex_lock.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,14 @@ + + + + + content + switch_mutex_lock($1); + name + switch_mutex_lock + tabTrigger + mlock + uuid + BC5BFA60-002A-40F2-A6FE-72CEE4AAE330 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_mutex_unlock.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_mutex_unlock.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,14 @@ + + + + + content + switch_mutex_unlock($1); + name + switch_mutex_unlock + tabTrigger + munlock + uuid + C41EC675-F09C-4596-8C14-662403B27D54 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_rdlock.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_rdlock.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,14 @@ + + + + + content + switch_thread_rwlock_rdlock($1); + name + switch_thread_rwlock_rdlock + tabTrigger + rdlock + uuid + FB9588B8-3540-41F6-BC2D-7A6F3083BDA4 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_tryrdlock.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_tryrdlock.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,17 @@ + + + + + content + if (switch_thread_rwlock_tryrdlock($1) != SWITCH_STATUS_SUCCESS) { + $2 +} +$0 + name + switch_thread_rwlock_tryrdlock + tabTrigger + tryrdlock + uuid + 091C4224-A49A-4C68-AEA1-A25FEEAB0DE8 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_unlock.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_unlock.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,14 @@ + + + + + content + switch_thread_rwlock_unlock($1); + name + switch_thread_rwlock_unlock + tabTrigger + rwunlock + uuid + D7C796FB-389A-4D1B-A64B-BCAE45B4CEAF + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_wrlock.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_thread_rwlock_wrlock.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,14 @@ + + + + + content + switch_thread_rwlock_wrlock($1); + name + switch_thread_rwlock_wrlock + tabTrigger + wrlock + uuid + 86B6BF3F-C2C5-413C-A2FD-58D02D4B0AC0 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/untitled.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/untitled.tmSnippet Tue Mar 10 16:42:10 2009 @@ -0,0 +1,17 @@ + + + + + content + if (switch_thread_rwlock_trywrlock($1) != SWITCH_STATUS_SUCCESS) { + $2 +} +$0 + name + switch_thread_rwlock_trywrlock + tabTrigger + trywrlock + uuid + 40D09664-79B0-4983-84FB-8007DD80E0D5 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/info.plist ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/info.plist Tue Mar 10 16:42:10 2009 @@ -0,0 +1,23 @@ + + + + + name + FreeSWITCH + ordering + + CCE4CE1C-2E71-4EDB-9733-1CDE38FA831E + 40D09664-79B0-4983-84FB-8007DD80E0D5 + BC5BFA60-002A-40F2-A6FE-72CEE4AAE330 + C41EC675-F09C-4596-8C14-662403B27D54 + 8940F795-2A0A-411F-AB98-48DEAB07AD69 + 63A39832-470E-4839-8098-4CC537FAA46D + 091C4224-A49A-4C68-AEA1-A25FEEAB0DE8 + D7C796FB-389A-4D1B-A64B-BCAE45B4CEAF + 86B6BF3F-C2C5-413C-A2FD-58D02D4B0AC0 + FB9588B8-3540-41F6-BC2D-7A6F3083BDA4 + + uuid + 5A009C17-72DB-453A-8BF9-02AFD085B5B8 + + From mrene at freeswitch.org Tue Mar 10 15:07:44 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Mar 2009 17:07:44 -0500 Subject: [Freeswitch-svn] [commit] r12560 - freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets Message-ID: Author: mrene Date: Tue Mar 10 17:07:44 2009 New Revision: 12560 Log: More textmate snippets Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_CONFIG_ITEM.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_STATUS_FALSE.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_STATUS_SUCCESS.tmSnippet freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_core_session_get_channel.tmSnippet Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_CONFIG_ITEM.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_CONFIG_ITEM.tmSnippet Tue Mar 10 17:07:44 2009 @@ -0,0 +1,14 @@ + + + + + content + SWITCH_CONFIG_ITEM("${1:key}", SWITCH_CONFIG_${2:}, 0, &${3:globals.item}, (void*)$4, ${5:NULL}, "${6:syntax}", "${7:documentation}") + name + SWITCH_CONFIG_ITEM + tabTrigger + configitem + uuid + 154CD9B8-6383-41C1-9F6E-A574AC6867D2 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_STATUS_FALSE.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_STATUS_FALSE.tmSnippet Tue Mar 10 17:07:44 2009 @@ -0,0 +1,14 @@ + + + + + content + SWITCH_STATUS_FALSE + name + SWITCH_STATUS_FALSE + tabTrigger + ssf + uuid + 19295878-37A1-4234-8035-38DA07E17CAA + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_STATUS_SUCCESS.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/SWITCH_STATUS_SUCCESS.tmSnippet Tue Mar 10 17:07:44 2009 @@ -0,0 +1,14 @@ + + + + + content + SWITCH_STATUS_SUCCESS + name + SWITCH_STATUS_SUCCESS + tabTrigger + sss + uuid + 3F544B00-2D0B-4C60-804E-EF63C609E7D8 + + Added: freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_core_session_get_channel.tmSnippet ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/mrene/textmate/FreeSWITCH.tmbundle/Snippets/switch_core_session_get_channel.tmSnippet Tue Mar 10 17:07:44 2009 @@ -0,0 +1,16 @@ + + + + + content + if ((${1:channel} = switch_core_session_get_channel(${2:session})) { + $0 +} + name + switch_core_session_get_channel + tabTrigger + getchan + uuid + 8107A427-59E7-4FB0-AA1B-28F4A15A2B63 + + From mrene at freeswitch.org Wed Mar 11 05:39:37 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 07:39:37 -0500 Subject: [Freeswitch-svn] [commit] r12561 - freeswitch/trunk/src/mod/languages/mod_spidermonkey Message-ID: Author: mrene Date: Wed Mar 11 07:39:37 2009 New Revision: 12561 Log: FSCORE-327 Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Wed Mar 11 07:39:37 2009 @@ -1146,8 +1146,21 @@ switch_dtmf_t *dtmf = (switch_dtmf_t *) input; if (dtmf) { - if ((Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) { - argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf")); + JSString *str = NULL; + /* FSCORE-327 - If a javascript garbage collection is in progress, + JS_NewStringCopyZ returns NULL */ + int try = 100; + while (try-- && !str) { + if ((str = JS_NewStringCopyZ(cb_state->cx, "dtmf"))) break; + switch_yield(10000); + } + + if (!str) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Javascript memory allocation failed\n"); + } + + if (str && (Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) { + argv[argc++] = STRING_TO_JSVAL(str); argv[argc++] = OBJECT_TO_JSVAL(Event); } else { jss->stack_depth--; From anthm at freeswitch.org Wed Mar 11 06:14:18 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 08:14:18 -0500 Subject: [Freeswitch-svn] [commit] r12562 - freeswitch/trunk/support-d Message-ID: Author: anthm Date: Wed Mar 11 08:14:18 2009 New Revision: 12562 Log: tweak .emacs Modified: freeswitch/trunk/support-d/.emacs Modified: freeswitch/trunk/support-d/.emacs ============================================================================== --- freeswitch/trunk/support-d/.emacs (original) +++ freeswitch/trunk/support-d/.emacs Wed Mar 11 08:14:18 2009 @@ -7,7 +7,7 @@ ;(setq cperl-hairy t) (global-unset-key "\C-h") (global-set-key "\C-h" 'delete-backward-char) -;(load "/usr/share/emacs/site-lisp/rng-auto.el") +(load "/usr/share/emacs/site-lisp/rng-auto.el") (require 'cc-mode) (defun my-build-tab-stop-list (width) @@ -171,6 +171,7 @@ (font-lock-function-name-face "limegreen") (font-lock-variable-name-face "Yellow") (font-lock-type-face "Yellow") + (font-lock-reference-face "Purple") )) ;; Load the font-lock package. (require 'font-lock) From anthm at freeswitch.org Wed Mar 11 06:15:03 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 08:15:03 -0500 Subject: [Freeswitch-svn] [commit] r12563 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 11 08:15:02 2009 New Revision: 12563 Log: still use intended caller id domain in rpid even when from uri is overridden Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 11 08:15:02 2009 @@ -1202,7 +1202,12 @@ use_from_str = tech_pvt->from_str; } - rpid_domain = switch_core_session_strdup(session, use_from_str); + if (!switch_strlen_zero(tech_pvt->gateway_from_str)) { + rpid_domain = switch_core_session_strdup(session, tech_pvt->gateway_from_str); + } else if (!switch_strlen_zero(tech_pvt->from_str)) { + rpid_domain = switch_core_session_strdup(session, tech_pvt->from_str); + } + sofia_glue_get_url_from_contact(rpid_domain, 0); if ((rpid_domain = strrchr(rpid_domain, '@'))) { rpid_domain++; From mrene at freeswitch.org Wed Mar 11 06:15:41 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 08:15:41 -0500 Subject: [Freeswitch-svn] [commit] r12564 - freeswitch/trunk/src/mod/languages/mod_spidermonkey Message-ID: Author: mrene Date: Wed Mar 11 08:15:41 2009 New Revision: 12564 Log: Revert 12561 Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Wed Mar 11 08:15:41 2009 @@ -1146,21 +1146,8 @@ switch_dtmf_t *dtmf = (switch_dtmf_t *) input; if (dtmf) { - JSString *str = NULL; - /* FSCORE-327 - If a javascript garbage collection is in progress, - JS_NewStringCopyZ returns NULL */ - int try = 100; - while (try-- && !str) { - if ((str = JS_NewStringCopyZ(cb_state->cx, "dtmf"))) break; - switch_yield(10000); - } - - if (!str) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Javascript memory allocation failed\n"); - } - - if (str && (Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) { - argv[argc++] = STRING_TO_JSVAL(str); + if ((Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) { + argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf")); argv[argc++] = OBJECT_TO_JSVAL(Event); } else { jss->stack_depth--; From anthm at freeswitch.org Wed Mar 11 07:49:37 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 09:49:37 -0500 Subject: [Freeswitch-svn] [commit] r12565 - freeswitch/trunk/src Message-ID: Author: anthm Date: Wed Mar 11 09:49:37 2009 New Revision: 12565 Log: silence err Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Wed Mar 11 09:49:37 2009 @@ -1613,9 +1613,12 @@ rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + + /** if (setrlimit(RLIMIT_STACK, &rlim) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); } + **/ #endif if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { @@ -1643,10 +1646,12 @@ #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + /** if (setrlimit(RLIMIT_STACK, &rlim) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); } + **/ #endif if (wait) { From anthm at freeswitch.org Wed Mar 11 08:14:24 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 10:14:24 -0500 Subject: [Freeswitch-svn] [commit] r12566 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 11 10:14:24 2009 New Revision: 12566 Log: add sip_from_display var and fix backwards switch_strisr calls Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 11 10:14:24 2009 @@ -1176,6 +1176,7 @@ const char *invite_contact_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_contact_params"); const char *invite_from_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_params"); const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri"); + const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display"); if (switch_strlen_zero(tech_pvt->dest)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error!\n"); @@ -1277,10 +1278,11 @@ or did he just suggest it to make our lives miserable? */ use_from_str = from_str; - if (!strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) { + if (!from_display && !strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) { from_str = switch_core_session_sprintf(session, "<%s>", use_from_str); } else { - from_str = switch_core_session_sprintf(session, "\"%s\" <%s>", tech_pvt->caller_profile->caller_id_name, use_from_str); + from_str = switch_core_session_sprintf(session, "\"%s\" <%s>", from_display ? from_display : + tech_pvt->caller_profile->caller_id_name, use_from_str); } if (!(call_id = switch_channel_get_variable(channel, "sip_outgoing_call_id"))) { Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Wed Mar 11 10:14:24 2009 @@ -1435,15 +1435,15 @@ new_profile->flags = SWITCH_CPF_NONE; - if (switch_stristr(tmp, "screen")) { + if (switch_stristr("screen", tmp)) { switch_set_flag(new_profile, SWITCH_CPF_SCREEN); } - if (switch_stristr(tmp, "hide_name")) { + if (switch_stristr("hide_name", tmp)) { switch_set_flag(new_profile, SWITCH_CPF_HIDE_NAME); } - if (switch_stristr(tmp, "hide_number")) { + if (switch_stristr("hide_number", tmp)) { switch_set_flag(new_profile, SWITCH_CPF_HIDE_NUMBER); } From anthm at freeswitch.org Wed Mar 11 08:29:50 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 10:29:50 -0500 Subject: [Freeswitch-svn] [commit] r12567 - freeswitch/trunk/src Message-ID: Author: anthm Date: Wed Mar 11 10:29:50 2009 New Revision: 12567 Log: FSCORE-328 Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Wed Mar 11 10:29:50 2009 @@ -42,6 +42,7 @@ #include #endif #endif +#include SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 }; @@ -792,7 +793,7 @@ #ifndef __FreeBSD__ memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlp.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + rlp.rlim_max = SWITCH_THREAD_STACKSIZE; setrlimit(RLIMIT_STACK, &rlp); #endif @@ -1589,9 +1590,27 @@ static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj) { struct system_thread_handle *sth = (struct system_thread_handle *)obj; +#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) + struct rlimit rlim; + + rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + if (setrlimit(RLIMIT_STACK, &rlim) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); + } +#endif sth->ret = system(sth->cmd); +#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) + rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + if (setrlimit(RLIMIT_STACK, &rlim) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); + } + +#endif + switch_mutex_lock(sth->mutex); switch_thread_cond_signal(sth->cond); switch_mutex_unlock(sth->mutex); @@ -1608,18 +1627,6 @@ int ret = 0; struct system_thread_handle *sth; switch_memory_pool_t *pool; -#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) - struct rlimit rlim; - - rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; - - /** - if (setrlimit(RLIMIT_STACK, &rlim) < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); - } - **/ -#endif if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); @@ -1643,17 +1650,6 @@ switch_threadattr_detach_set(thd_attr, 1); switch_thread_create(&thread, thd_attr, system_thread, sth, sth->pool); - -#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) - rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; - /** - if (setrlimit(RLIMIT_STACK, &rlim) < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); - } - **/ -#endif - if (wait) { switch_thread_cond_wait(sth->cond, sth->mutex); ret = sth->ret; From anthm at freeswitch.org Wed Mar 11 08:57:42 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 10:57:42 -0500 Subject: [Freeswitch-svn] [commit] r12568 - freeswitch/trunk/src Message-ID: Author: anthm Date: Wed Mar 11 10:57:42 2009 New Revision: 12568 Log: revert Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Wed Mar 11 10:57:42 2009 @@ -42,7 +42,6 @@ #include #endif #endif -#include SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 }; @@ -793,7 +792,7 @@ #ifndef __FreeBSD__ memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlp.rlim_max = SWITCH_THREAD_STACKSIZE; + rlp.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; setrlimit(RLIMIT_STACK, &rlp); #endif @@ -1590,27 +1589,9 @@ static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj) { struct system_thread_handle *sth = (struct system_thread_handle *)obj; -#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) - struct rlimit rlim; - - rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; - if (setrlimit(RLIMIT_STACK, &rlim) < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); - } -#endif sth->ret = system(sth->cmd); -#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) - rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; - if (setrlimit(RLIMIT_STACK, &rlim) < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); - } - -#endif - switch_mutex_lock(sth->mutex); switch_thread_cond_signal(sth->cond); switch_mutex_unlock(sth->mutex); @@ -1627,6 +1608,15 @@ int ret = 0; struct system_thread_handle *sth; switch_memory_pool_t *pool; +#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) + struct rlimit rlim; + + rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + if (setrlimit(RLIMIT_STACK, &rlim) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); + } +#endif if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); @@ -1650,6 +1640,15 @@ switch_threadattr_detach_set(thd_attr, 1); switch_thread_create(&thread, thd_attr, system_thread, sth, sth->pool); + +#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) + rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_THREAD_STACKSIZE; + if (setrlimit(RLIMIT_STACK, &rlim) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); + } +#endif + if (wait) { switch_thread_cond_wait(sth->cond, sth->mutex); ret = sth->ret; From anthm at freeswitch.org Wed Mar 11 08:58:11 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 10:58:11 -0500 Subject: [Freeswitch-svn] [commit] r12569 - freeswitch/trunk/src Message-ID: Author: anthm Date: Wed Mar 11 10:58:11 2009 New Revision: 12569 Log: FSCORE-328 Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Wed Mar 11 10:58:11 2009 @@ -42,6 +42,7 @@ #include #endif #endif +#include SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 }; @@ -1589,9 +1590,27 @@ static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj) { struct system_thread_handle *sth = (struct system_thread_handle *)obj; +#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) + struct rlimit rlim; + + rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + if (setrlimit(RLIMIT_STACK, &rlim) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); + } +#endif sth->ret = system(sth->cmd); +#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) + rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; + rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; + if (setrlimit(RLIMIT_STACK, &rlim) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); + } + +#endif + switch_mutex_lock(sth->mutex); switch_thread_cond_signal(sth->cond); switch_mutex_unlock(sth->mutex); @@ -1608,15 +1627,6 @@ int ret = 0; struct system_thread_handle *sth; switch_memory_pool_t *pool; -#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) - struct rlimit rlim; - - rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; - if (setrlimit(RLIMIT_STACK, &rlim) < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); - } -#endif if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); @@ -1640,15 +1650,6 @@ switch_threadattr_detach_set(thd_attr, 1); switch_thread_create(&thread, thd_attr, system_thread, sth, sth->pool); - -#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) - rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlim.rlim_max = SWITCH_THREAD_STACKSIZE; - if (setrlimit(RLIMIT_STACK, &rlim) < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n"); - } -#endif - if (wait) { switch_thread_cond_wait(sth->cond, sth->mutex); ret = sth->ret; From anthm at freeswitch.org Wed Mar 11 09:54:39 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 11:54:39 -0500 Subject: [Freeswitch-svn] [commit] r12570 - freeswitch/trunk/src/mod/xml_int/mod_xml_curl Message-ID: Author: anthm Date: Wed Mar 11 11:54:38 2009 New Revision: 12570 Log: limit bytes read by xml_curl to 1 meg Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c ============================================================================== --- freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c (original) +++ freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Wed Mar 11 11:54:38 2009 @@ -54,9 +54,14 @@ typedef struct xml_binding xml_binding_t; +#define XML_CURL_MAX_BYTES 1024 * 1024 + struct config_data { char *name; int fd; + switch_size_t bytes; + switch_size_t max_bytes; + int err; }; typedef struct hash_node { @@ -102,6 +107,15 @@ register unsigned int realsize = (unsigned int) (size * nmemb); struct config_data *config_data = data; int x; + + config_data->bytes += realsize; + + if (config_data->bytes > config_data->max_bytes) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%ld bytes]\n", config_data->bytes); + config_data->err = 1; + return 0; + } + x = write(config_data->fd, ptr, realsize); if (x != (int) realsize) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write! %d out of %d\n", x, realsize); @@ -185,6 +199,7 @@ } config_data.name = filename; + config_data.max_bytes = XML_CURL_MAX_BYTES; if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) { if (!switch_strlen_zero(binding->cred)) { curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); @@ -222,13 +237,18 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening temp file!\n"); } - if (httpRes == 200) { - if (!(xml = switch_xml_parse_file(filename))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result!\n"); - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url, data); + if (config_data.err) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error encountered!\n"); xml = NULL; + } else { + if (httpRes == 200) { + if (!(xml = switch_xml_parse_file(filename))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result!\n"); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url, data); + xml = NULL; + } } /* Debug by leaving the file behind for review */ From anthm at freeswitch.org Wed Mar 11 10:26:37 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 12:26:37 -0500 Subject: [Freeswitch-svn] [commit] r12571 - freeswitch/trunk/src/mod/xml_int/mod_xml_curl Message-ID: Author: anthm Date: Wed Mar 11 12:26:37 2009 New Revision: 12571 Log: sigh Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c ============================================================================== --- freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c (original) +++ freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Wed Mar 11 12:26:37 2009 @@ -111,7 +111,7 @@ config_data->bytes += realsize; if (config_data->bytes > config_data->max_bytes) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%ld bytes]\n", config_data->bytes); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)config_data->bytes); config_data->err = 1; return 0; } From mikej at freeswitch.org Wed Mar 11 13:25:22 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 15:25:22 -0500 Subject: [Freeswitch-svn] [commit] r12572 - freeswitch/trunk/libs/esl/src/include Message-ID: Author: mikej Date: Wed Mar 11 15:25:21 2009 New Revision: 12572 Log: fix build Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Wed Mar 11 15:25:21 2009 @@ -31,9 +31,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define EXTERN_C extern "C" { #ifndef _ESL_OOP_H_ #define _ESL_OOP_H_ +#ifndef EXTERN_C +#define EXTERN_C extern "C" { +#endif #include #ifdef __cplusplus EXTERN_C From mikej at freeswitch.org Wed Mar 11 13:51:44 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 15:51:44 -0500 Subject: [Freeswitch-svn] [commit] r12573 - in freeswitch/trunk/libs/esl: . perl php src/include Message-ID: Author: mikej Date: Wed Mar 11 15:51:44 2009 New Revision: 12573 Log: fix build failures Modified: freeswitch/trunk/libs/esl/Makefile freeswitch/trunk/libs/esl/perl/Makefile freeswitch/trunk/libs/esl/php/Makefile freeswitch/trunk/libs/esl/src/include/esl_oop.h Modified: freeswitch/trunk/libs/esl/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/Makefile (original) +++ freeswitch/trunk/libs/esl/Makefile Wed Mar 11 15:51:44 2009 @@ -5,7 +5,7 @@ BASE_FLAGS=$(INCS) -DHAVE_EDITLINE $(DEBUG) -I$(LIBEDIT_DIR)/src/ -fPIC PICKY=-O2 -ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes CFLAGS=$(BASE_FLAGS) $(PICKY) -CXXFLAGS=$(BASE_FLAGS) -Wall -Werror +CXXFLAGS=$(BASE_FLAGS) -Wall -Werror -Wno-unused-variable MYLIB=libesl.a LIBS=-lncurses -lpthread -lesl LDFLAGS=-L. Modified: freeswitch/trunk/libs/esl/perl/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/perl/Makefile (original) +++ freeswitch/trunk/libs/esl/perl/Makefile Wed Mar 11 15:51:44 2009 @@ -3,7 +3,7 @@ PERL_LIBS =$(shell perl -MConfig -e 'print $$Config{libs}') LOCAL_CFLAGS= -w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL LOCAL_LDFLAGS=$(shell $(PERL) -MExtUtils::Embed -e ldopts) $(shell $(PERL) -MConfig -e 'print $$Config{libs}') - +PERL_INC=$(shell $(PERL) -MExtUtils::Embed -e perl_inc) all: ESL.so esl_wrap.cpp: @@ -16,7 +16,7 @@ $(CC) $(CC_CFLAGS) $(CFLAGS) $(LOCAL_CFLAGS) -c perlxsi.c -o perlxsi.o esl_wrap.o: esl_wrap.cpp - $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o + $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(PERL_INC) -c esl_wrap.cpp -o esl_wrap.o ESL.so: esl_wrap.o perlxsi.o $(CXX) $(SOLINK) esl_wrap.o perlxsi.o $(MYLIB) $(LOCAL_LDFLAGS) -o ESL.so -L. $(LIBS) Modified: freeswitch/trunk/libs/esl/php/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/php/Makefile (original) +++ freeswitch/trunk/libs/esl/php/Makefile Wed Mar 11 15:51:44 2009 @@ -1,5 +1,6 @@ LOCAL_CFLAGS=$(shell php-config --includes) LOCAL_LDFLAGS=$(shell php-config --ldflags --libs) +WRAP_GCC_WARNING_SILENCE=-Wno-unused-label -Wno-unused-function all: ESL.so @@ -7,7 +8,7 @@ swig -module ESL -php5 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i esl_wrap.o: esl_wrap.cpp - $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o + $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) $(WRAP_GCC_WARNING_SILENCE) -c esl_wrap.cpp -o esl_wrap.o ESL.so: esl_wrap.o $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o ESL.so -L. $(LIBS) Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Wed Mar 11 15:51:44 2009 @@ -33,12 +33,9 @@ #ifndef _ESL_OOP_H_ #define _ESL_OOP_H_ -#ifndef EXTERN_C -#define EXTERN_C extern "C" { -#endif #include #ifdef __cplusplus -EXTERN_C +extern "C" { #endif #define this_check(x) do { if (!this) { esl_log(ESL_LOG_ERROR, "object is not initalized\n"); return x;}} while(0) From mikej at freeswitch.org Wed Mar 11 14:12:29 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 16:12:29 -0500 Subject: [Freeswitch-svn] [commit] r12574 - freeswitch/trunk/libs/esl/lua Message-ID: Author: mikej Date: Wed Mar 11 16:12:29 2009 New Revision: 12574 Log: fix build Modified: freeswitch/trunk/libs/esl/lua/Makefile Modified: freeswitch/trunk/libs/esl/lua/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/lua/Makefile (original) +++ freeswitch/trunk/libs/esl/lua/Makefile Wed Mar 11 16:12:29 2009 @@ -1,5 +1,6 @@ LOCAL_CFLAGS= LOCAL_LDFLAGS=-llua +WRAP_GCC_WARNING_SILENCE=-Wno-unused-function all: ESL.so @@ -7,7 +8,7 @@ swig -module ESL -lua -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i esl_wrap.o: esl_wrap.cpp - $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o + $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) $(WRAP_GCC_WARNING_SILENCE) -c esl_wrap.cpp -o esl_wrap.o ESL.so: esl_wrap.o $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o ESL.so -L. $(LIBS) From anthm at freeswitch.org Wed Mar 11 14:22:14 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 16:22:14 -0500 Subject: [Freeswitch-svn] [commit] r12575 - in freeswitch/trunk: conf/autoload_configs libs/iksemel/src libs/libdingaling/src Message-ID: Author: anthm Date: Wed Mar 11 16:22:14 2009 New Revision: 12575 Log: hijack gcrypt init call to fix threadsafe race in dingaling and fix buffer overrun in iksemel Modified: freeswitch/trunk/conf/autoload_configs/modules.conf.xml freeswitch/trunk/libs/iksemel/src/io-posix.c freeswitch/trunk/libs/iksemel/src/stream.c freeswitch/trunk/libs/libdingaling/src/libdingaling.c Modified: freeswitch/trunk/conf/autoload_configs/modules.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/modules.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/modules.conf.xml Wed Mar 11 16:22:14 2009 @@ -27,7 +27,7 @@ - + Modified: freeswitch/trunk/libs/iksemel/src/io-posix.c ============================================================================== --- freeswitch/trunk/libs/iksemel/src/io-posix.c (original) +++ freeswitch/trunk/libs/iksemel/src/io-posix.c Wed Mar 11 16:22:14 2009 @@ -108,6 +108,7 @@ fd_set fds; struct timeval tv, *tvptr; int len; + char *bound; tv.tv_sec = 0; tv.tv_usec = 0; @@ -115,20 +116,22 @@ FD_ZERO (&fds); FD_SET (sock, &fds); tv.tv_sec = timeout; + if (timeout != -1) tvptr = &tv; else tvptr = NULL; if (select (sock + 1, &fds, NULL, NULL, tvptr) > 0) { len = recv (sock, buffer, buf_len, 0); if (len > 0) { char *p, *e = NULL, *t = NULL; - *(buffer+buf_len+1) = '\0'; - for (p = buffer; p && *p; p++) { + bound = buffer + (len -1); + + for (p = buffer; p < bound; p++) { if (*p == '>') { e = p; t = p+1; if (*t == '<') { continue; } - while(t && *t) { + while(p < bound && t < bound) { if (*t != ' ' && *t != '<') { t = e = NULL; break; Modified: freeswitch/trunk/libs/iksemel/src/stream.c ============================================================================== --- freeswitch/trunk/libs/iksemel/src/stream.c (original) +++ freeswitch/trunk/libs/iksemel/src/stream.c Wed Mar 11 16:22:14 2009 @@ -45,17 +45,15 @@ }; #ifdef HAVE_GNUTLS -static pthread_mutex_t tls_send_mutex; -static pthread_mutex_t tls_recv_mutex; +#include +GCRY_THREAD_OPTION_PTHREAD_IMPL; static size_t tls_push (iksparser *prs, const char *buffer, size_t len) { struct stream_data *data = iks_user_data (prs); int ret; - pthread_mutex_lock(&tls_send_mutex); ret = data->trans->send (data->sock, buffer, len); - pthread_mutex_unlock(&tls_send_mutex); if (ret) return (size_t) -1; return len; } @@ -65,9 +63,7 @@ { struct stream_data *data = iks_user_data (prs); int ret; - pthread_mutex_lock(&tls_recv_mutex); ret = data->trans->recv (data->sock, buffer, len, -1); - pthread_mutex_unlock(&tls_recv_mutex); if (ret == -1) return (size_t) -1; return ret; } @@ -82,6 +78,8 @@ const int mac_priority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 }; int ret; + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); + if (gnutls_global_init () != 0) return IKS_NOMEM; @@ -99,8 +97,10 @@ gnutls_mac_set_priority(data->sess, mac_priority); gnutls_credentials_set (data->sess, GNUTLS_CRD_CERTIFICATE, data->cred); + gnutls_transport_set_push_function (data->sess, (gnutls_push_func) tls_push); gnutls_transport_set_pull_function (data->sess, (gnutls_pull_func) tls_pull); + gnutls_transport_set_ptr (data->sess, data->prs); ret = gnutls_handshake (data->sess); @@ -487,9 +487,15 @@ int iks_fd (iksparser *prs) { - struct stream_data *data = iks_user_data (prs); + struct stream_data *data; - return (int) data->sock; + if (prs) { + data = iks_user_data (prs); + if (data) { + return (int) data->sock; + } + } + return -1; } int @@ -603,24 +609,11 @@ iks_init(void) { int ok = 0; - pthread_mutexattr_t attr; - - if (pthread_mutexattr_init(&attr)) - return -1; - - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) - ok = -1; - if (ok == 0 && pthread_mutex_init(&tls_send_mutex, &attr)) - ok = -1; + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); - if (ok == 0 && pthread_mutex_init(&tls_recv_mutex, &attr)) { - pthread_mutex_destroy(&tls_send_mutex); - ok = -1; - } - - - pthread_mutexattr_destroy(&attr); + if (gnutls_global_init () != 0) + return IKS_NOMEM; return ok; Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Wed Mar 11 16:22:14 2009 @@ -1566,8 +1566,7 @@ } fail: - iks_disconnect(handle->parser); - iks_parser_delete(handle->parser); + ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED); ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED); handle->state = CS_NEW; @@ -1575,6 +1574,9 @@ while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) { microsleep(100); } + + iks_disconnect(handle->parser); + iks_parser_delete(handle->parser); } ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); if (!ldl_test_flag(handle, LDL_FLAG_TLS)) { From brian at freeswitch.org Wed Mar 11 15:13:26 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 17:13:26 -0500 Subject: [Freeswitch-svn] [commit] r12576 - freeswitch/trunk/conf/autoload_configs Message-ID: Author: brian Date: Wed Mar 11 17:13:26 2009 New Revision: 12576 Log: revert Modified: freeswitch/trunk/conf/autoload_configs/modules.conf.xml Modified: freeswitch/trunk/conf/autoload_configs/modules.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/modules.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/modules.conf.xml Wed Mar 11 17:13:26 2009 @@ -27,7 +27,7 @@ - + From mikej at freeswitch.org Wed Mar 11 15:46:46 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 17:46:46 -0500 Subject: [Freeswitch-svn] [commit] r12577 - freeswitch/trunk/src/mod/languages/mod_spidermonkey Message-ID: Author: mikej Date: Wed Mar 11 17:46:46 2009 New Revision: 12577 Log: mod_spidermonkey: fix segfaults on dtmf callback (FSCORE-327) Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Wed Mar 11 17:46:46 2009 @@ -1104,11 +1104,17 @@ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; char var_name[SWITCH_UUID_FORMATTED_LENGTH + 25]; char *p; + switch_status_t status = SWITCH_STATUS_FALSE; - METHOD_SANITY_CHECK(); - - jss->stack_depth++; + if (!jss || !jss->session) { + return SWITCH_STATUS_FALSE; + } + if (++jss->stack_depth > MAX_STACK_DEPTH) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Maximum recursive callback limit %d reached.\n", MAX_STACK_DEPTH); + jss->stack_depth--; + return SWITCH_STATUS_FALSE; + } switch_uuid_get(&uuid); switch_uuid_format(uuid_str, &uuid); @@ -1120,6 +1126,9 @@ } } + JS_ResumeRequest(cb_state->cx, cb_state->saveDepth); + METHOD_SANITY_CHECK(); + if (cb_state->jss_a && cb_state->jss_a->session && cb_state->jss_a->session == session) { argv[argc++] = OBJECT_TO_JSVAL(cb_state->session_obj_a); } else if (cb_state->jss_b && cb_state->jss_b->session && cb_state->jss_b->session == session) { @@ -1137,8 +1146,7 @@ } } if (!Event) { - jss->stack_depth--; - return SWITCH_STATUS_FALSE; + goto done; } break; case SWITCH_INPUT_TYPE_DTMF: @@ -1150,8 +1158,7 @@ argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf")); argv[argc++] = OBJECT_TO_JSVAL(Event); } else { - jss->stack_depth--; - return SWITCH_STATUS_FALSE; + goto done; } } } @@ -1162,24 +1169,17 @@ argv[argc++] = cb_state->arg; } - if (jss->stack_depth > MAX_STACK_DEPTH) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Maximum recursive callback limit %d reached.\n", MAX_STACK_DEPTH); - jss->stack_depth--; - return SWITCH_STATUS_FALSE; - } - - JS_ResumeRequest(cb_state->cx, cb_state->saveDepth); check_hangup_hook(jss, &ret); - cb_state->saveDepth = JS_SuspendRequest(cb_state->cx); if (ret == JS_TRUE) { - JS_ResumeRequest(cb_state->cx, cb_state->saveDepth); JS_CallFunction(cb_state->cx, cb_state->obj, cb_state->function, argc, argv, &cb_state->ret); - cb_state->saveDepth = JS_SuspendRequest(cb_state->cx); - jss->stack_depth--; } - return SWITCH_STATUS_SUCCESS; + status = SWITCH_STATUS_SUCCESS; +done: + cb_state->saveDepth = JS_SuspendRequest(cb_state->cx); + jss->stack_depth--; + return status; } static switch_status_t js_stream_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) From andrew at freeswitch.org Wed Mar 11 17:43:07 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 19:43:07 -0500 Subject: [Freeswitch-svn] [commit] r12578 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Wed Mar 11 19:43:07 2009 New Revision: 12578 Log: Add a Makefile.in for mod_erlang_event in preparation for when my configure patch gets merged Added: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/Makefile.in Added: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/Makefile.in ============================================================================== --- (empty file) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/Makefile.in Wed Mar 11 19:43:07 2009 @@ -0,0 +1,9 @@ +LOCAL_SOURCES=handle_msg.c ei_helpers.c +LOCAL_OBJS=handle_msg.o ei_helpers.o +LOCAL_CFLAGS= @ERLANG_CFLAGS@ -D_REENTRANT +LOCAL_LDFLAGS= @ERLANG_LDFLAGS@ + +include ../../../../build/modmake.rules + + + From mrene at freeswitch.org Wed Mar 11 19:24:24 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 21:24:24 -0500 Subject: [Freeswitch-svn] [commit] r12579 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Wed Mar 11 21:24:24 2009 New Revision: 12579 Log: declinatio mortuus obfirmo Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 11 21:24:24 2009 @@ -2845,7 +2845,7 @@ } } } - + switch_mutex_unlock(mod_sofia_globals.hash_mutex); sofia_glue_restart_all_profiles(); } From andrew at freeswitch.org Wed Mar 11 19:37:30 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Mar 2009 21:37:30 -0500 Subject: [Freeswitch-svn] [commit] r12580 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Wed Mar 11 21:37:30 2009 New Revision: 12580 Log: fixin' a segfault Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Wed Mar 11 21:37:30 2009 @@ -950,7 +950,7 @@ } if (!prefs.nodename) { - prefs.nodename = "freeswitch"; + set_pref_nodename("freeswitch"); } return 0; From mrene at freeswitch.org Thu Mar 12 07:59:51 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 09:59:51 -0500 Subject: [Freeswitch-svn] [commit] r12581 - freeswitch/trunk/src/mod/applications/mod_limit Message-ID: Author: mrene Date: Thu Mar 12 09:59:51 2009 New Revision: 12581 Log: tweak Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Thu Mar 12 09:59:51 2009 @@ -322,7 +322,7 @@ switch_safe_free(sql); switch_core_event_hook_remove_state_change(session, db_state_handler); /* Remove limit_realm variable so we register another hook if limit is called again */ - switch_channel_set_variable(channel, "limit_realm", ""); + switch_channel_set_variable(channel, "limit_realm", NULL); } return SWITCH_STATUS_SUCCESS; } From anthm at freeswitch.org Thu Mar 12 08:09:31 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 10:09:31 -0500 Subject: [Freeswitch-svn] [commit] r12582 - freeswitch/trunk/src/mod/applications/mod_conference Message-ID: Author: anthm Date: Thu Mar 12 10:09:31 2009 New Revision: 12582 Log: MODAPP-233 (recording members should be invisible to commands Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Mar 12 10:09:31 2009 @@ -2274,7 +2274,7 @@ if (switch_test_flag((&fh), SWITCH_FILE_OPEN)) { switch_core_file_close(&fh); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recording Stopped\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recording of %s Stopped\n", rec->path); if (rec->pool) { switch_memory_pool_t *pool = rec->pool; @@ -2728,7 +2728,9 @@ switch_mutex_lock(conference->member_mutex); for (member = conference->members; member; member = member->next) { - pfncallback(member, stream, data); + if (member->session && !switch_test_flag(member, MFLAG_NOCHANNEL)) { + pfncallback(member, stream, data); + } } switch_mutex_unlock(conference->member_mutex); } @@ -2926,6 +2928,7 @@ switch_mutex_lock(member->control_mutex); switch_clear_flag(member, MFLAG_RUNNING); switch_set_flag_locked(member, MFLAG_KICKED); + switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK); switch_mutex_unlock(member->control_mutex); if (stream != NULL) { @@ -3907,7 +3910,7 @@ } /* exec functio on last (oldest) member */ - if (last_member != NULL) { + if (last_member != NULL && last_member->session && !switch_test_flag(last_member, MFLAG_NOCHANNEL)) { conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd; pfn(last_member, stream, argv[argn + 2]); } From anthm at freeswitch.org Thu Mar 12 09:06:31 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 11:06:31 -0500 Subject: [Freeswitch-svn] [commit] r12583 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Thu Mar 12 11:06:31 2009 New Revision: 12583 Log: MODENDP-197 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Mar 12 11:06:31 2009 @@ -1477,7 +1477,6 @@ nua_invite(tech_pvt->nh, NUTAG_AUTOANSWER(0), NUTAG_SESSION_TIMER(session_timeout), - TAG_IF(!switch_strlen_zero(sendto), NTATAG_DEFAULT_PROXY(sendto)), TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)), TAG_IF(!switch_strlen_zero(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)), TAG_IF(!switch_strlen_zero(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)), @@ -1487,7 +1486,7 @@ TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_IF(route_uri, NUTAG_PROXY(route_uri)), TAG_IF(route, SIPTAG_ROUTE_STR(route)), - TAG_IF(!switch_strlen_zero(sendto), NTATAG_DEFAULT_PROXY(sendto)), + TAG_IF(!switch_strlen_zero(sendto), NUTAG_PROXY(sendto)), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), From mikej at freeswitch.org Thu Mar 12 09:10:38 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 11:10:38 -0500 Subject: [Freeswitch-svn] [commit] r12584 - in freeswitch/trunk/libs/esl: . perl Message-ID: Author: mikej Date: Thu Mar 12 11:10:37 2009 New Revision: 12584 Log: fix gmake on bsd build Modified: freeswitch/trunk/libs/esl/Makefile freeswitch/trunk/libs/esl/perl/Makefile Modified: freeswitch/trunk/libs/esl/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/Makefile (original) +++ freeswitch/trunk/libs/esl/Makefile Thu Mar 12 11:10:37 2009 @@ -39,42 +39,42 @@ clean: rm -f *.o src/*.o testclient testserver fs_cli libesl.a *~ src/*~ src/include/*~ - make -C perl clean - make -C php clean - make -C lua clean - make -C python clean - make -C ruby clean + $(MAKE) -C perl clean + $(MAKE) -C php clean + $(MAKE) -C lua clean + $(MAKE) -C python clean + $(MAKE) -C ruby clean reswig: swigclean - make -C perl reswig - make -C php reswig - make -C lua reswig - make -C python reswig - make -C ruby reswig + $(MAKE) -C perl reswig + $(MAKE) -C php reswig + $(MAKE) -C lua reswig + $(MAKE) -C python reswig + $(MAKE) -C ruby reswig swigclean: clean - make -C perl swigclean - make -C php swigclean - make -C lua swigclean - make -C python swigclean - make -C ruby swigclean + $(MAKE) -C perl swigclean + $(MAKE) -C php swigclean + $(MAKE) -C lua swigclean + $(MAKE) -C python swigclean + $(MAKE) -C ruby swigclean perlmod: $(MYLIB) - make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C perl + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C perl phpmod: $(MYLIB) - make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C php + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C php luamod: $(MYLIB) - make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C lua + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C lua pymod: $(MYLIB) - make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python rubymod: $(MYLIB) - make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C ruby + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C ruby phpmod-install: phpmod - make -C php install + $(MAKE) -C php install everymod: perlmod phpmod luamod pymod rubymod Modified: freeswitch/trunk/libs/esl/perl/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/perl/Makefile (original) +++ freeswitch/trunk/libs/esl/perl/Makefile Thu Mar 12 11:10:37 2009 @@ -1,7 +1,7 @@ -PERL = $(shell which perl) -PERL_LIBDIR =-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE -PERL_LIBS =$(shell perl -MConfig -e 'print $$Config{libs}') -LOCAL_CFLAGS= -w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL +PERL=$(shell which perl) +PERL_LIBDIR=-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE +PERL_LIBS=$(shell perl -MConfig -e 'print $$Config{libs}') +LOCAL_CFLAGS=-w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL LOCAL_LDFLAGS=$(shell $(PERL) -MExtUtils::Embed -e ldopts) $(shell $(PERL) -MConfig -e 'print $$Config{libs}') PERL_INC=$(shell $(PERL) -MExtUtils::Embed -e perl_inc) all: ESL.so From anthm at freeswitch.org Thu Mar 12 09:47:47 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 11:47:47 -0500 Subject: [Freeswitch-svn] [commit] r12585 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 12 11:47:47 2009 New Revision: 12585 Log: FSCORE-331 Modified: freeswitch/trunk/src/switch_core_session.c freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_core_session.c ============================================================================== --- freeswitch/trunk/src/switch_core_session.c (original) +++ freeswitch/trunk/src/switch_core_session.c Thu Mar 12 11:47:47 2009 @@ -463,7 +463,7 @@ } } - if (peer_profile) { + if (peer_profile && !(flags & SOF_FORKED_DIAL)) { if ((cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) { switch_channel_set_originatee_caller_profile(channel, cloned_profile); } Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Thu Mar 12 11:47:47 2009 @@ -2118,6 +2118,16 @@ } if (*bleg) { + if (caller_channel && !switch_channel_get_originatee_caller_profile(caller_channel)) { + switch_caller_profile_t *cloned_profile, *peer_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(*bleg)); + + if (peer_profile) { + if ((cloned_profile = switch_caller_profile_clone(*bleg, peer_profile)) != 0) { + switch_channel_set_originatee_caller_profile(caller_channel, cloned_profile); + } + } + } + switch_ivr_sleep(*bleg, 0, SWITCH_TRUE, NULL); } From mrene at freeswitch.org Thu Mar 12 11:51:36 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 13:51:36 -0500 Subject: [Freeswitch-svn] [commit] r12586 - freeswitch/trunk/src/mod/xml_int/mod_xml_curl Message-ID: Author: mrene Date: Thu Mar 12 13:51:36 2009 New Revision: 12586 Log: MDXMLINT-48 Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c ============================================================================== --- freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c (original) +++ freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Thu Mar 12 13:51:36 2009 @@ -198,8 +198,11 @@ curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); } + memset(&config_data, 0, sizeof(config_data)); + config_data.name = filename; config_data.max_bytes = XML_CURL_MAX_BYTES; + if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) { if (!switch_strlen_zero(binding->cred)) { curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); From andrew at freeswitch.org Thu Mar 12 12:54:20 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 14:54:20 -0500 Subject: [Freeswitch-svn] [commit] r12587 - in freeswitch/trunk: . build build/config Message-ID: Author: andrew Date: Thu Mar 12 14:54:20 2009 New Revision: 12587 Log: FSBUILD-142 (with approval from MikeJ) Added: freeswitch/trunk/build/config/erlang.m4 Modified: freeswitch/trunk/acinclude.m4 freeswitch/trunk/build/modules.conf.in freeswitch/trunk/configure.in Modified: freeswitch/trunk/acinclude.m4 ============================================================================== --- freeswitch/trunk/acinclude.m4 (original) +++ freeswitch/trunk/acinclude.m4 Thu Mar 12 14:54:20 2009 @@ -6,6 +6,7 @@ m4_include([build/config/ac_gcc_x86_cpuid.m4]) m4_include([build/config/ax_lib_mysql.m4]) m4_include([build/config/ax_check_java.m4]) +m4_include([build/config/erlang.m4]) m4_include([build/config/odbc.m4]) m4_include([libs/apr/build/apr_common.m4]) m4_include([build/config/libcurl.m4]) Added: freeswitch/trunk/build/config/erlang.m4 ============================================================================== --- (empty file) +++ freeswitch/trunk/build/config/erlang.m4 Thu Mar 12 14:54:20 2009 @@ -0,0 +1,96 @@ +AC_DEFUN([CHECK_ERLANG], [ +# +# Erlang checks for mod_erlang_event +# +AC_ARG_WITH( + [erlang], + [AS_HELP_STRING([--with-erlang], [Use system provided version of erlang (default: try)])], + [with_erlang="$withval"], + [with_erlang="try"] +) + +if test "$with_erlang" != "no" +then + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + + if test "$with_erlang" != "yes" -a "$with_erlang" != "try" ; then + AC_MSG_CHECKING([for erlang]) + if test ! -x "$with_erlang" ; then + AC_MSG_ERROR([Specified erlang does not exist or is not executable: $with_erlang]) + fi + AC_MSG_RESULT([$with_erlang]) + AC_SUBST([ERLANG], ["$with_erlang"]) + else + AC_PATH_PROG([ERLANG], ["erl"], ["no"], ["$PATH:/usr/bin:/usr/local/bin"]) + fi + + if test "$ERLANG" != "no" ; then + AC_MSG_CHECKING([erlang version]) + ERLANG_VER="`$ERLANG -version 2>&1 | cut -d' ' -f6`" + + if test -z "$ERLANG_VER" ; then + AC_MSG_ERROR([Unable to detect erlang version]) + fi + AC_MSG_RESULT([$ERLANG_VER]) + + ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` + AC_MSG_CHECKING([erlang libdir]) + if test -z "`echo $ERLANG_LIBDIR`" ; then + AC_MSG_ERROR([failed]) + else + ERLANG_LDFLAGS="-L$ERLANG_LIBDIR $ERLANG_LDFLAGS" + LIBS="-L$ERLANG_LIBDIR $LIBS" + fi + AC_MSG_RESULT([$ERLANG_LIBDIR]) + + ERLANG_INCDIR=`$ERLANG -noshell -eval 'io:format("~s/include~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` + AC_MSG_CHECKING([erlang incdir]) + if test -z "`echo $ERLANG_INCDIR`" ; then + AC_MSG_ERROR([failed]) + else + ERLANG_CFLAGS="-I$ERLANG_INCDIR $ERLANG_CFLAGS" + CFLAGS="-I$ERLANG_INCDIR $CFLAGS" + fi + AC_MSG_RESULT([$ERLANG_INCDIR]) + + AC_CHECK_HEADERS([ei.h], [has_ei_h="yes"], [has_ei_h="no"]) + + ERLANG_LIB="ei" + + # check liei + AC_CHECK_LIB([$ERLANG_LIB], [ei_encode_version], [has_libei="yes"], [has_libei="no"]) + # maybe someday ei will actually expose this? + AC_CHECK_LIB([$ERLANG_LIB], [ei_link_unlink], [ERLANG_CFLAGS="$ERLANG_CFLAGS -DEI_LINK_UNLINK"]) + + if test "$has_libei" = "no" ; then + AS_IF([test "$with_erlang" = "try"], + [AC_MSG_WARN([$ERLANG_LIB is unusable])], + [AC_MSG_ERROR([$ERLANG_LIB is unusable])] + ) + elif test "$has_ei_h" = "no"; then + AS_IF([test "$with_erlang" = "try"], + [AC_MSG_WARN([ei.h is unusable - are the erlang development headers installed?])], + [AC_MSG_ERROR([ei.h is unusable - are the erlang development headers installed?])] + ) + else + ERLANG_LDFLAGS="$ERLANG_LDFLAGS -lei" + AC_MSG_NOTICE([Your erlang seems OK, do not forget to enable mod_erlang_event in modules.conf]) + AC_SUBST([ERLANG_CFLAGS], [$ERLANG_CFLAGS]) + AC_SUBST([ERLANG_LDFLAGS], [$ERLANG_LDFLAGS]) + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + else + AS_IF([test "$with_erlang" = "try"], + [AC_MSG_WARN([Could not find erlang, mod_erlang_event will not build, use --with-erlang to specify the location])], + [AC_MSG_ERROR([Could not find erlang, use --with-erlang to specify the location])] + ) + fi +else + AC_MSG_WARN([erlang support disabled, building mod_erlang_event will fail!]) +fi + +]) Modified: freeswitch/trunk/build/modules.conf.in ============================================================================== --- freeswitch/trunk/build/modules.conf.in (original) +++ freeswitch/trunk/build/modules.conf.in Thu Mar 12 14:54:20 2009 @@ -50,6 +50,7 @@ event_handlers/mod_event_socket event_handlers/mod_cdr_csv #event_handlers/mod_radius_cdr +#event_handlers/mod_erlang_event formats/mod_native_file formats/mod_sndfile #formats/mod_shout Modified: freeswitch/trunk/configure.in ============================================================================== --- freeswitch/trunk/configure.in (original) +++ freeswitch/trunk/configure.in Thu Mar 12 14:54:20 2009 @@ -692,6 +692,8 @@ AC_MSG_WARN([python support disabled, building mod_python will fail!]) fi +CHECK_ERLANG + AC_CONFIG_FILES([Makefile src/Makefile src/mod/Makefile @@ -699,6 +701,7 @@ src/mod/event_handlers/mod_radius_cdr/Makefile src/mod/languages/mod_java/Makefile src/mod/languages/mod_python/Makefile + src/mod/event_handlers/mod_erlang_event/Makefile src/include/switch_am_config.h build/getsounds.sh build/getlib.sh From andrew at freeswitch.org Thu Mar 12 12:57:22 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 14:57:22 -0500 Subject: [Freeswitch-svn] [commit] r12588 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Thu Mar 12 14:57:22 2009 New Revision: 12588 Log: Remove old hardcoded makefile now that we can check for erlang stuff in configure Removed: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/Makefile From intralanman at freeswitch.org Thu Mar 12 14:47:44 2009 From: intralanman at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 16:47:44 -0500 Subject: [Freeswitch-svn] [commit] r12589 - in freeswitch/trunk/scripts/contrib/intralanman/perl: cdr cdr-csv Message-ID: Author: intralanman Date: Thu Mar 12 16:47:43 2009 New Revision: 12589 Log: new sample cdr goodies Added: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr/ (props changed) - copied from r12588, /freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/ Removed: freeswitch/trunk/scripts/contrib/intralanman/perl/cdr-csv/ From brian at freeswitch.org Thu Mar 12 18:57:10 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Mar 2009 20:57:10 -0500 Subject: [Freeswitch-svn] [commit] r12590 - freeswitch/trunk/src Message-ID: Author: brian Date: Thu Mar 12 20:57:10 2009 New Revision: 12590 Log: FSCORE-332 Modified: freeswitch/trunk/src/switch_core_session.c Modified: freeswitch/trunk/src/switch_core_session.c ============================================================================== --- freeswitch/trunk/src/switch_core_session.c (original) +++ freeswitch/trunk/src/switch_core_session.c Thu Mar 12 20:57:10 2009 @@ -379,6 +379,7 @@ peer_profile = switch_channel_get_caller_profile(peer_channel); if ((use_uuid = switch_event_get_header(var_event, "origination_uuid"))) { + use_uuid = switch_core_session_strdup(*new_session, use_uuid); if (switch_core_session_set_uuid(*new_session, use_uuid) == SWITCH_STATUS_SUCCESS) { switch_event_del_header(var_event, "origination_uuid"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s set UUID=%s\n", switch_channel_get_name(peer_channel), use_uuid); @@ -1068,14 +1069,15 @@ switch_assert(use_uuid); + switch_mutex_lock(runtime.session_hash_mutex); if (switch_core_hash_find(session_manager.session_table, use_uuid)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Duplicate UUID!\n"); + switch_mutex_unlock(runtime.session_hash_mutex); return SWITCH_STATUS_FALSE; } switch_event_create(&event, SWITCH_EVENT_CHANNEL_UUID); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Old-Unique-ID", session->uuid_str); - switch_mutex_lock(runtime.session_hash_mutex); switch_core_hash_delete(session_manager.session_table, session->uuid_str); switch_set_string(session->uuid_str, use_uuid); switch_core_hash_insert(session_manager.session_table, session->uuid_str, session); From mrene at freeswitch.org Fri Mar 13 08:13:18 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Fri, 13 Mar 2009 10:13:18 -0500 Subject: [Freeswitch-svn] [commit] r12591 - freeswitch/trunk/src Message-ID: Author: mrene Date: Fri Mar 13 10:13:18 2009 New Revision: 12591 Log: tweak Modified: freeswitch/trunk/src/switch_xml_config.c Modified: freeswitch/trunk/src/switch_xml_config.c ============================================================================== --- freeswitch/trunk/src/switch_xml_config.c (original) +++ freeswitch/trunk/src/switch_xml_config.c Fri Mar 13 10:13:18 2009 @@ -143,6 +143,8 @@ switch_bool_t changed = SWITCH_FALSE; switch_xml_config_callback_t callback = (switch_xml_config_callback_t)item->function; + switch_assert(item->ptr); + if (value) { matched_count++; } @@ -236,7 +238,7 @@ /* We have a preallocated buffer */ char *dest = (char*)item->ptr; - if (!dest || strncasecmp(dest, newstring, string_options->length)) { + if (strncasecmp(dest, newstring, string_options->length)) { switch_copy_string(dest, newstring, string_options->length); changed = SWITCH_TRUE; } From andrew at freeswitch.org Fri Mar 13 10:33:17 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Fri, 13 Mar 2009 12:33:17 -0500 Subject: [Freeswitch-svn] [commit] r12592 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Fri Mar 13 12:33:17 2009 New Revision: 12592 Log: Make handlecall return more correct errors; sync freeswitch.erl with git version Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/freeswitch.erl freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/freeswitch.erl ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/freeswitch.erl (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/freeswitch.erl Fri Mar 13 12:33:17 2009 @@ -14,13 +14,13 @@ -module(freeswitch). --export([send/2, api/3, bgapi/3, event/2, +-export([send/2, api/3, api/2, bgapi/3, bgapi/4, event/2, nixevent/2, noevents/1, close/1, get_event_header/2, get_event_body/1, get_event_name/1, getpid/1, sendmsg/3, - sendevent/3, handlecall/2, start_fetch_handler/4, + sendevent/3, handlecall/2, handlecall/3, start_fetch_handler/4, start_log_handler/3, start_event_handler/3]). --define(TIMEOUT, 10000). +-define(TIMEOUT, 5000). %% @doc Return the value for a specific header in an event or `{error,notfound}'. get_event_header([], _Needle) -> @@ -63,11 +63,18 @@ api(Node, Cmd, Args) -> {api, Node} ! {api, Cmd, Args}, receive - X -> X + {ok, X} -> + {ok, X}; + {error, X} -> + {error, X} after ?TIMEOUT -> timeout end. +%% @doc Same as @link{api/3} except there's no additional arguments. +api(Node, Cmd) -> + api(Node, Cmd, ""). + %% @doc Make a backgrounded API call to FreeSWITCH. The asynchronous reply is %% sent to calling process after it is received. This function %% returns the result of the initial bgapi call or `timeout' if FreeSWITCH fails @@ -104,11 +111,48 @@ {api, X} -> X end. +%% @doc Make a backgrounded API call to FreeSWITCH. The asynchronous reply is +%% passed as the argument to `Fun' after it is received. This function +%% returns the result of the initial bgapi call or `timeout' if FreeSWITCH fails +%% to respond. +bgapi(Node, Cmd, Args, Fun) -> + Self = self(), + % spawn a new process so that both responses go here instead of directly to + % the calling process. + spawn(fun() -> + {bgapi, Node} ! {bgapi, Cmd, Args}, + receive + {error, Reason} -> + % send the error condition to the calling process + Self ! {api, {error, Reason}}; + {ok, JobID} -> + % send the reply to the calling process + Self ! {api, ok}, + receive % wait for the job's reply + {bgok, JobID, Reply} -> + % Call the function with the reply + Fun(ok, Reply); + {bgerror, JobID, Reply} -> + Fun(error, Reply) + end + after ?TIMEOUT -> + % send a timeout to the calling process + Self ! {api, timeout} + end + end), + + % get the initial result of the command, NOT the asynchronous response, and + % return it + receive + {api, X} -> X + end. + %% @doc Request to receive any events in the list `List'. event(Node, Events) when is_list(Events) -> {event, Node} ! list_to_tuple(lists:append([event], Events)), receive - X -> X + ok -> ok; + {error, Reason} -> {error, Reason} after ?TIMEOUT -> timeout end; @@ -130,7 +174,8 @@ noevents(Node) -> {noevents, Node} ! noevents, receive - X -> X + ok -> ok; + {error, Reason} -> {error, Reason} after ?TIMEOUT -> timeout end. @@ -139,7 +184,7 @@ close(Node) -> {close, Node} ! exit, receive - X -> X + ok -> ok after ?TIMEOUT -> timeout end. @@ -150,7 +195,8 @@ sendevent(Node, EventName, Headers) -> {sendevent, Node} ! {sendevent, EventName, Headers}, receive - X -> X + ok -> ok; + {error, Reason} -> {error, Reason} after ?TIMEOUT -> timeout end. @@ -160,7 +206,8 @@ sendmsg(Node, UUID, Headers) -> {sendmsg, Node} ! {sendmsg, UUID, Headers}, receive - X -> X + ok -> ok; + {error, Reason} -> {error, Reason} after ?TIMEOUT -> timeout end. @@ -171,17 +218,29 @@ getpid(Node) -> {getpid, Node} ! getpid, receive - X -> X + {ok, Pid} when is_pid(Pid) -> {ok, Pid} after ?TIMEOUT -> timeout end. %% @doc Request that FreeSWITCH send any events pertaining to call `UUID' to %% `Process' where process is a registered process name. -handlecall(Node, Process) -> - {handlecall, Node} ! {handlecall, Process}, +handlecall(Node, UUID, Process) -> + {handlecall, Node} ! {handlecall, UUID, Process}, receive - X -> X + ok -> ok; + {error, Reason} -> {error, Reason} + after ?TIMEOUT -> + timeout + end. + +%% @doc Request that FreeSWITCH send any events pertaining to call `UUID' to +%% the calling process. +handlecall(Node, UUID) -> + {handlecall, Node} ! {handlecall, UUID}, + receive + ok -> ok; + {error, Reason} -> {error, Reason} after ?TIMEOUT -> timeout end. Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Fri Mar 13 12:33:17 2009 @@ -568,11 +568,17 @@ ei_x_encode_atom(rbuf, "badarg"); } else { switch_core_session_t *session; - if (!switch_strlen_zero_buf(uuid_str) && (session = switch_core_session_locate(uuid_str))) { - /* create a new session list element and attach it to this listener */ - if ((arity==2 && attach_call_to_pid(listener, &msg->from, session)) || - (arity==3 && attach_call_to_registered_process(listener, reg_name, session))) { - ei_x_encode_atom(rbuf, "ok"); + if (!switch_strlen_zero_buf(uuid_str) && SWITCH_UUID_FORMATTED_LENGTH == strlen(uuid_str)) { + if ((session = switch_core_session_locate(uuid_str))) { + /* create a new session list element and attach it to this listener */ + if ((arity==2 && attach_call_to_pid(listener, &msg->from, session)) || + (arity==3 && attach_call_to_registered_process(listener, reg_name, session))) { + ei_x_encode_atom(rbuf, "ok"); + } else { + ei_x_encode_tuple_header(rbuf, 2); + ei_x_encode_atom(rbuf, "error"); + ei_x_encode_atom(rbuf, "session_attach_failed"); + } } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); From anthm at freeswitch.org Fri Mar 13 12:18:05 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 13 Mar 2009 14:18:05 -0500 Subject: [Freeswitch-svn] [commit] r12593 - freeswitch/trunk/libs/esl/src Message-ID: Author: anthm Date: Fri Mar 13 14:18:05 2009 New Revision: 12593 Log: pad buffer Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Fri Mar 13 14:18:05 2009 @@ -63,7 +63,7 @@ return NULL; } - len = strlen(cmd) + (arg ? strlen(arg) : 0) + 5; + len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10; cmd_buf = (char *) malloc(len); assert(cmd_buf); @@ -92,7 +92,7 @@ return NULL; } - len = strlen(cmd) + (arg ? strlen(arg) : 0) + 8; + len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10; cmd_buf = (char *) malloc(len); assert(cmd_buf); From andrew at freeswitch.org Fri Mar 13 12:55:55 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Fri, 13 Mar 2009 14:55:55 -0500 Subject: [Freeswitch-svn] [commit] r12594 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Fri Mar 13 14:55:55 2009 New Revision: 12594 Log: Unlock the session like we should be doing Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Fri Mar 13 14:55:55 2009 @@ -584,6 +584,9 @@ ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badsession"); } + /* release the lock returned by switch_core_locate_session */ + switch_core_session_rwunlock(session); + } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); From anthm at freeswitch.org Fri Mar 13 15:01:39 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 13 Mar 2009 17:01:39 -0500 Subject: [Freeswitch-svn] [commit] r12595 - freeswitch/trunk/src Message-ID: Author: anthm Date: Fri Mar 13 17:01:39 2009 New Revision: 12595 Log: avoiding sillyness Modified: freeswitch/trunk/src/switch_ivr_bridge.c Modified: freeswitch/trunk/src/switch_ivr_bridge.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_bridge.c (original) +++ freeswitch/trunk/src/switch_ivr_bridge.c Fri Mar 13 17:01:39 2009 @@ -320,6 +320,19 @@ continue; } } + + if (!ans_a && !ans_b) { + switch_channel_t *un = ans_a ? chan_b : chan_a; + + if (switch_channel_answer(un) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(un)); + goto end_of_bridge_loop; + } + + if (ans_a) ans_b++; else ans_a++; + } + + #ifndef SWITCH_VIDEO_IN_THREADS if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO)) { /* read video from 1 channel and write it to the other */ From brian at freeswitch.org Fri Mar 13 15:31:25 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Fri, 13 Mar 2009 17:31:25 -0500 Subject: [Freeswitch-svn] [commit] r12596 - freeswitch/trunk/conf/dialplan Message-ID: Author: brian Date: Fri Mar 13 17:31:25 2009 New Revision: 12596 Log: sigh Modified: freeswitch/trunk/conf/dialplan/default.xml Modified: freeswitch/trunk/conf/dialplan/default.xml ============================================================================== --- freeswitch/trunk/conf/dialplan/default.xml (original) +++ freeswitch/trunk/conf/dialplan/default.xml Fri Mar 13 17:31:25 2009 @@ -193,11 +193,9 @@
From silik0n at freeswitch.org Sat Mar 14 00:47:11 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 02:47:11 -0500 Subject: [Freeswitch-svn] [commit] r12597 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Sat Mar 14 02:47:11 2009 New Revision: 12597 Log: get the Conf monitor/controller mostly working, can now playback soundfiles, (un)lock, (un)mute, and kick members Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sat Mar 14 02:47:11 2009 @@ -51,57 +51,11 @@ return $body; } - public function getConferenceList() { - $e = $this->esl->sendRecv("api conference list"); + public function killUuid($uuid) { + $e = $this->esl->sendRecv("api uuid_kill $uuid"); $body = $e->getBody(); - $data=explode("\n", $body); - $y=0; - foreach($data as $row){ - if(substr($row, 0, 10)=="Conference"){ - $temp_data = explode(" ", $row); - $conf_data[$y] = $temp_data[1]; - $y++; - } - } - - return $conf_data; - } - - public function getConferenceUsers($conference_name) { - $e = $this->esl->sendRecv("api conference $conference_name list"); - $body = $e->getBody(); - - $data=explode("\n", $body); - $y=0; - foreach($data as $row){ - if ($row!="" && substr($row, 0, 10) != "Conference"){ - $temp_data = explode(";", $row); - $conf_data[$y]['id'] = $temp_data[0]; - $conf_data[$y]['channel'] = $temp_data[1]; - $conf_data[$y]['uuid'] = $temp_data[2]; - $conf_data[$y]['caller_name'] = $temp_data[3]; - $conf_data[$y]['caller_number'] = $temp_data[4]; - $conf_data[$y]['flags'] = $temp_data[5]; - $conf_data[$y]['gain'] = $temp_data[6]; - $conf_data[$y]['volume'] = $temp_data[7]; - $conf_data[$y]['noise'] = $temp_data[8]; - $conf_data[$y]['hear'] = 0; - $conf_data[$y]['speak'] = 0; - $conf_data[$y]['talk'] = 0; - $conf_data[$y]['video'] = 0; - $temp_flags = explode("|", $temp_data[5]); - foreach ($temp_flags as $flag){ - if ($flag == "hear") $conf_data[$y]['hear'] = 1; - if ($flag == "speak") $conf_data[$y]['speak'] = 1; - if ($flag == "talk") $conf_data[$y]['talk'] = 1; - if ($flag == "video") $conf_data[$y]['video'] = 1; - } - - $y++; - } - } - return $conf_data; + return $body; } public function getChannels() { @@ -161,8 +115,131 @@ $e = $this->esl->sendRecv($dialstring); $body = $e->getBody(); - return $dialstring . "\n" . $body; + return $body; + } + + public function kickConferenceUser($conference, $member) { + $e = $this->esl->sendRecv("api conference $conference kick $member"); + $body = $e->getBody(); + return $body; + } + + public function getConferenceList() { + $e = $this->esl->sendRecv("api conference list"); + $body = $e->getBody(); + + $data=explode("\n", $body); + $y=0; + foreach($data as $row){ + if(substr($row, 0, 10)=="Conference"){ + $temp_data = explode(" ", $row); + $conf_data[$y] = $temp_data[1]; + $y++; + } + } + return $conf_data; + } + + public function getConferenceUsers($conference_name) { + $e = $this->esl->sendRecv("api conference $conference_name list"); + $body = $e->getBody(); + + $data=explode("\n", $body); + $y=0; + foreach($data as $row){ + if ($row!="" && substr($row, 0, 10) != "Conference"){ + $temp_data = explode(";", $row); + $conf_data[$y]['id'] = $temp_data[0]; + $conf_data[$y]['channel'] = $temp_data[1]; + $conf_data[$y]['uuid'] = $temp_data[2]; + $conf_data[$y]['caller_name'] = $temp_data[3]; + $conf_data[$y]['caller_number'] = $temp_data[4]; + $conf_data[$y]['flags'] = $temp_data[5]; + $conf_data[$y]['gain'] = $temp_data[6]; + $conf_data[$y]['volume'] = $temp_data[7]; + $conf_data[$y]['noise'] = $temp_data[8]; + $conf_data[$y]['hear'] = 0; + $conf_data[$y]['speak'] = 0; + $conf_data[$y]['talk'] = 0; + $conf_data[$y]['video'] = 0; + $conf_data[$y]['floor'] = 0; + $temp_flags = explode("|", $temp_data[5]); + foreach ($temp_flags as $flag){ + if ($flag == "hear") $conf_data[$y]['hear'] = 1; + if ($flag == "speak") $conf_data[$y]['speak'] = 1; + if ($flag == "talk") $conf_data[$y]['talk'] = 1; + if ($flag == "video") $conf_data[$y]['video'] = 1; + if ($flag == "floor") $conf_data[$y]['floor'] = 1; + } + $y++; + } + } + return $conf_data; + } + + public function getConfPlayfiles($list_dir) { + if($list_dir != "") { + $templist = glob($list_dir); + } else { + $templist = glob("/usr/local/freeswitch/sounds/en/us/callie/*/*/*"); + } + + $x=0; + foreach($templist as $file){ + $temp_file = explode("/", $file); + $filelist[$x]['label'] = $temp_file[count($temp_file)-1]; + $filelist[$x]['data'] = $file; + // $filelist[$x] = $file; + $x++; + } + + return $filelist; + } + + public function confPlayfile($conference, $file_path){ + $playfile = "api conference $conference play " . $file_path['data']; + $e = $this->esl->sendRecv($playfile); + $body = $e->getBody(); + return $body; + } + + public function confLock($conference){ + $playfile = "api conference $conference lock"; + $e = $this->esl->sendRecv($playfile); + $body = $e->getBody(); + return $body; + } + + public function confUnlock($conference){ + $playfile = "api conference $conference unlock"; + $e = $this->esl->sendRecv($playfile); + $body = $e->getBody(); + return $body; + } + + public function confMute($conference, $member){ + $playfile = "api conference $conference mute $member"; + $e = $this->esl->sendRecv($playfile); + $body = $e->getBody(); + return $body; + } + + public function confUnmute($conference, $member){ + $playfile = "api conference $conference unmute $member"; + $e = $this->esl->sendRecv($playfile); + $body = $e->getBody(); + return $body; } } +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + */ ?> From silik0n at freeswitch.org Sat Mar 14 00:49:07 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 02:49:07 -0500 Subject: [Freeswitch-svn] [commit] r12598 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src Message-ID: Author: silik0n Date: Sat Mar 14 02:49:07 2009 New Revision: 12598 Log: get the Conf monitor/controller mostly working, can now playback soundfiles, (un)lock, (un)mute, and kick members Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sat Mar 14 02:49:07 2009 @@ -7,25 +7,26 @@ import flash.utils.Timer; import flash.events.TimerEvent; - import mx.controls.dataGridClasses.DataGridColumn; - import mx.events.DataGridEvent; - import mx.controls.Alert; - import mx.rpc.events.FaultEvent; - import mx.rpc.events.ResultEvent; - import mx.collections.ArrayCollection; - import mx.managers.PopUpManager; - import mx.core.IFlexDisplayObject; - private var confTimer:Timer; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.events.DataGridEvent; + import mx.controls.Alert; + import mx.rpc.events.FaultEvent; + import mx.rpc.events.ResultEvent; + import mx.collections.ArrayCollection; + import mx.managers.PopUpManager; + import mx.core.IFlexDisplayObject; + private var confTimer:Timer; private function initConfTab():void{ + freeswitch.getConfPlayfiles(null); freeswitch.getConferenceList(); freeswitch.getConferenceUsers(confPicker.selectedItem ); - confTimerLabel.text="Init..."; - confTimer = new Timer(10000, 0); - confTimer.addEventListener(TimerEvent.TIMER, onConfRefresh); - confTimer.start(); - confTimerLabel.text = confTimer.running.toString(); - } + confTimerLabel.text="Init..."; + confTimer = new Timer(10000, 0); + confTimer.addEventListener(TimerEvent.TIMER, onConfRefresh); + confTimer.start(); + confTimerLabel.text = confTimer.running.toString(); + } private function onConfRefresh(evt:TimerEvent):void { confTimerLabel.text="Refreshing"; @@ -60,8 +61,6 @@ var origWindow:IFlexDisplayObject = PopUpManager.createPopUp(this, statusForm, false); } - - ]]> @@ -125,24 +124,27 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + - + + From silik0n at freeswitch.org Sat Mar 14 01:13:56 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 03:13:56 -0500 Subject: [Freeswitch-svn] [commit] r12599 - in freeswitch/trunk/scripts/contrib/swk: . flex/amf-test1/bin-debug Message-ID: Author: silik0n Date: Sat Mar 14 03:13:56 2009 New Revision: 12599 Log: lets add a little instructions and a working swf for those that want to test. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf (contents, props changed) Modified: freeswitch/trunk/scripts/contrib/swk/README Modified: freeswitch/trunk/scripts/contrib/swk/README ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/README (original) +++ freeswitch/trunk/scripts/contrib/swk/README Sat Mar 14 03:13:56 2009 @@ -1,3 +1,30 @@ -for the Flex stuff you need the amf-php lib and the thing amf-php/freeswitch.php module +This Software is licensed under the MPL. + +REQUIREMENTS: + +To Use: +Flash9 or Flash10 +PHP 5 +AMFPHP http://www.amfphp.org/ +FreeSWITCH ESL PHP Extensions +And of course a WebServer + +To Develop: +All of the Above +Adobe Flex Development Environment. (This is available from Adobe's website in both paid and free formats.) + + +To Install: + +Install AMFPHP as per http://www.amfphp.org/docs/installingamfphp.html +Rename the 'amfphp' directory to feeder. This is done to avoid robot scanners, bu I am sure that eventually they'll start looking for that. + +copy the freeswitch.php file into the AMFPHP services directory. + +make the files in amf-test1/bin-debug available on your webserver and point a browser at it. + +If you are developing in flex you need to load the swf from your development webserver so that it can properly locate the service. + +Any questions, feel free to find me as SwK via IRC at #freeswitch on irc.freenode.net + -more stuff coming in here soon Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf ============================================================================== Binary file. No diff available. From silik0n at freeswitch.org Sat Mar 14 03:39:08 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 05:39:08 -0500 Subject: [Freeswitch-svn] [commit] r12600 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src Message-ID: Author: silik0n Date: Sat Mar 14 05:39:08 2009 New Revision: 12600 Log: ok getting ready for domain user and group manager to feed the data into a DB then server up with xml_curl Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sat Mar 14 05:39:08 2009 @@ -126,18 +126,16 @@ - - - + + + - - - + - - + + @@ -146,6 +144,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From silik0n at freeswitch.org Sat Mar 14 05:45:46 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 07:45:46 -0500 Subject: [Freeswitch-svn] [commit] r12601 - in freeswitch/trunk/scripts/contrib/swk: flex/amf-test1/src php/amfphp sql Message-ID: Author: silik0n Date: Sat Mar 14 07:45:46 2009 New Revision: 12601 Log: Initial MySQL dump, some sample data (anyone wanna help getting the rest of the user directory into the DB?) starting to display the domains data and actually getting somewhere Added: freeswitch/trunk/scripts/contrib/swk/sql/ freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sat Mar 14 07:45:46 2009 @@ -61,7 +61,8 @@ var origWindow:IFlexDisplayObject = PopUpManager.createPopUp(this, statusForm, false); } - + + ]]> @@ -124,7 +125,7 @@ - + @@ -149,30 +150,47 @@ - + - + - - + + + + + + + + + + + + + + + + + - - + + - + - - + + Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sat Mar 14 07:45:46 2009 @@ -38,12 +38,32 @@ require_once "ESL.php"; class FreeSWITCH { - var $esl; + var $esl; + var $dbh; + + private function getDbh(){ + $dbtype='mysql'; /* Set the Database type */ + $db_hostname = 'localhost'; /* Database Server hostname */ + $db_username = 'root'; /* Database Server username */ + $db_password = 'password'; /* Database Server password */ + $db_database = 'shipment'; /* DataBase Name */ + + $dbh = new PDO("$dbtype:host=$db_hostname;dbname=$db_database", $db_username, $db_password, array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,)); + + return $dbh; + } public function __construct() { - $this->esl = new eslConnection('127.0.0.1', '8021', 'ClueCon'); + + $esl_server = "127.0.0.1"; /* ESL Server */ + $esl_port = "8021"; /* ESL Port */ + $esl_secret = "ClueCon"; /* ESL Secret */ + + $this->esl = new eslConnection($esl_server, $esl_port, $esl_secret); } - + + /*** General Whats happening Methods ***/ + public function getStatus() { $e = $this->esl->sendRecv("api status"); $body = $e->getBody(); @@ -51,13 +71,6 @@ return $body; } - public function killUuid($uuid) { - $e = $this->esl->sendRecv("api uuid_kill $uuid"); - $body = $e->getBody(); - - return $body; - } - public function getChannels() { $e = $this->esl->sendRecv("api show channels"); $body = $e->getBody(); @@ -110,6 +123,8 @@ return $data; } + /*** General API Command Methods ***/ + public function originate($call_url, $exten, $dialplan = "XML", $context= "default", $cid_name = "amf_php", $cid_number = "888", $timeout="30"){ $dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout"; $e = $this->esl->sendRecv($dialstring); @@ -117,6 +132,14 @@ return $body; } + + public function killUuid($uuid) { + $e = $this->esl->sendRecv("api uuid_kill $uuid"); + $body = $e->getBody(); + return $body; + } + + /*** Conference Methods ***/ public function kickConferenceUser($conference, $member) { $e = $this->esl->sendRecv("api conference $conference kick $member"); @@ -230,7 +253,67 @@ $body = $e->getBody(); return $body; } + + /*** Directory Methods ***/ + + public function getDirDomains(){ + $dbh = $this->getDbh(); + + $query = sprintf("select * from domains"); + $stmt = $dbh->query($query); + $results = $stmt->fetchAll(); + + return $results; + } + + public function getDirDomain($domain_uid){ + + $dbh = $this->getDbh(); + + $query = sprintf("select * from domain_params where domains_uid = $domain_uid"); + $stmt = $dbh->query($query); + $results['params'] = $stmt->fetchAll(); + + $query = sprintf("select * from domain_variables where domains_uid = $domain_uid"); + $stmt = $dbh->query($query); + $results['variables'] = $stmt->fetchAll(); + + return $results; + } + + public function addDirDomain($domain_name){ + $dbh = $this->getDbh(); + + $query = sprintf('insert into domains (name) values ("%s")', $domain_name); + + return $dbh->exec($query); + } + + public function getDirUsers($domain_uid){ + $dbh = $this->getDbh(); + + $query = sprintf("select * from users where domain_uid = $domain_uid"); + $stmt = $dbh->query($query); + $results = $stmt->fetchAll(); + + return $results; + } + + public function getDirGroups($domain_uid){ + $dbh = $this->getDbh(); + + $query = sprintf("select * from groups where domain_uid = $domain_uid"); + $stmt = $dbh->query($query); + $results = $stmt->fetchAll(); + + return $results; + } + + +} +/* For Emacs: + } /* For Emacs: * Local Variables: Added: freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql Sat Mar 14 07:45:46 2009 @@ -0,0 +1,245 @@ +-- +-- Initial Table with Sample Data for Project Shipment +-- (Or atleast I'm calling it Shipment until I get a better name +-- + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + +-- +-- Database: `shipment` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `domains` +-- + +CREATE TABLE IF NOT EXISTS `domains` ( + `uid` int(11) NOT NULL auto_increment COMMENT 'UID for the table Auto Assigned', + `name` varchar(128) NOT NULL COMMENT 'domaine name', + `enabled` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`uid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; + +-- +-- Dumping data for table `domains` +-- + +INSERT INTO `domains` (`uid`, `name`, `enabled`) VALUES +(1, '192.168.1.140', 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `domain_params` +-- + +CREATE TABLE IF NOT EXISTS `domain_params` ( + `uid` int(11) NOT NULL auto_increment, + `domains_uid` int(11) NOT NULL, + `name` varchar(64) NOT NULL, + `value` varchar(256) NOT NULL, + PRIMARY KEY (`uid`), + KEY `domain_uid` (`domains_uid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; + +-- +-- Dumping data for table `domain_params` +-- + +INSERT INTO `domain_params` (`uid`, `domains_uid`, `name`, `value`) VALUES +(1, 1, 'dial-string', '{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `domain_variables` +-- + +CREATE TABLE IF NOT EXISTS `domain_variables` ( + `uid` int(11) NOT NULL auto_increment, + `domains_uid` int(11) NOT NULL, + `name` varchar(64) NOT NULL, + `value` varchar(128) NOT NULL, + PRIMARY KEY (`uid`), + KEY `domain_uid` (`domains_uid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; + +-- +-- Dumping data for table `domain_variables` +-- + +INSERT INTO `domain_variables` (`uid`, `domains_uid`, `name`, `value`) VALUES +(1, 1, 'record_stereo', 'true'), +(2, 1, 'default_gateway', '$${default_provider}'), +(3, 1, 'default_areacode', '$${default_areacode}'), +(4, 1, 'transfer_fallback_extension', 'operator'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `groups` +-- + +CREATE TABLE IF NOT EXISTS `groups` ( + `uid` int(11) NOT NULL auto_increment, + `domains_uid` int(11) NOT NULL, + `name` varchar(64) NOT NULL, + PRIMARY KEY (`uid`), + KEY `domain_uid` (`domains_uid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; + +-- +-- Dumping data for table `groups` +-- + +INSERT INTO `groups` (`uid`, `domains_uid`, `name`) VALUES +(1, 1, 'sales'), +(2, 1, 'billing'), +(3, 1, 'support'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_members` +-- + +CREATE TABLE IF NOT EXISTS `group_members` ( + `uid` int(11) NOT NULL auto_increment, + `domains_uid` int(11) NOT NULL, + `groups_uid` int(11) NOT NULL, + `users_uid` int(11) NOT NULL, + `type` varchar(32) NOT NULL, + PRIMARY KEY (`uid`), + KEY `domain_uid` (`domains_uid`,`groups_uid`,`users_uid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `group_members` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE IF NOT EXISTS `users` ( + `uid` int(11) NOT NULL auto_increment, + `domain_uid` int(11) NOT NULL, + `username` varchar(64) NOT NULL, + `mailbox` varchar(64) default NULL, + `cidr` varchar(32) default NULL, + `enabled` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`uid`), + KEY `domain_uid` (`domain_uid`,`username`,`mailbox`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`uid`, `domain_uid`, `username`, `mailbox`, `cidr`, `enabled`) VALUES +(1, 1, '1000', '1000', NULL, 1), +(2, 1, '1001', '1001', NULL, 1), +(3, 1, '1002', '1002', NULL, 1), +(4, 1, '1003', '1003', NULL, 1), +(5, 1, '1004', '1004', NULL, 1), +(6, 1, '1005', '1005', NULL, 1), +(7, 1, '1006', '1006', NULL, 1), +(8, 1, '1007', '1007', NULL, 1), +(9, 1, '1008', '1008', NULL, 1), +(10, 1, '1009', '1009', NULL, 1), +(11, 1, '1000', '1000', NULL, 1), +(12, 1, '1011', '1011', NULL, 1), +(13, 1, '1012', '1012', NULL, 1), +(14, 1, '1013', '1013', NULL, 1), +(15, 1, '1014', '1014', NULL, 1), +(16, 1, '1015', '1015', NULL, 1), +(17, 1, '1016', '1016', NULL, 1), +(18, 1, '1017', '1017', NULL, 1), +(19, 1, '1018', '1018', NULL, 1), +(20, 1, '1019', '1019', NULL, 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_params` +-- + +CREATE TABLE IF NOT EXISTS `user_params` ( + `uid` int(11) NOT NULL auto_increment, + `users_uid` int(11) NOT NULL, + `name` varchar(64) NOT NULL, + `value` varchar(128) NOT NULL, + PRIMARY KEY (`uid`), + KEY `user_uid` (`users_uid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ; + +-- +-- Dumping data for table `user_params` +-- + +INSERT INTO `user_params` (`uid`, `users_uid`, `name`, `value`) VALUES +(1, 1, 'password', '1234'), +(2, 1, 'vm-password', '1000'), +(3, 2, 'password', '1234'), +(4, 2, 'vm-password', '1002'), +(5, 3, 'password', '1234'), +(6, 3, 'vm-password', '1003'), +(7, 4, 'password', '1234'), +(8, 4, 'vm-password', '1004'), +(9, 5, 'password', '1234'), +(10, 5, 'vm-password', '1005'), +(11, 6, 'password', '1234'), +(12, 6, 'vm-password', '1006'), +(13, 7, 'password', '1234'), +(14, 7, 'vm-password', '1007'), +(15, 8, 'password', '1234'), +(16, 8, 'vm-password', '1008'), +(17, 9, 'password', '1234'), +(18, 9, 'vm-password', '1009'), +(19, 10, 'password', '1234'), +(20, 10, 'vm-password', '1010'), +(21, 11, 'password', '1234'), +(22, 11, 'vm-password', '1011'), +(23, 12, 'password', '1234'), +(24, 12, 'vm-password', '1012'), +(25, 13, 'password', '1234'), +(26, 13, 'vm-password', '1013'), +(27, 14, 'password', '1234'), +(28, 14, 'vm-password', '1014'), +(29, 15, 'password', '1234'), +(30, 15, 'vm-password', '1015'), +(31, 16, 'password', '1234'), +(32, 16, 'vm-password', '1016'), +(33, 17, 'password', '1234'), +(34, 17, 'vm-password', '1017'), +(35, 18, 'password', '1234'), +(36, 18, 'vm-password', '1018'), +(37, 19, 'password', '1234'), +(38, 19, 'vm-password', '1019'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_variables` +-- + +CREATE TABLE IF NOT EXISTS `user_variables` ( + `uid` int(11) NOT NULL auto_increment, + `users_uid` int(11) NOT NULL, + `name` varchar(64) NOT NULL, + `value` varchar(128) NOT NULL, + PRIMARY KEY (`uid`), + KEY `user_uid` (`users_uid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +-- +-- Dumping data for table `user_variables` +-- + + From anthm at freeswitch.org Sat Mar 14 06:56:45 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 08:56:45 -0500 Subject: [Freeswitch-svn] [commit] r12602 - freeswitch/trunk/src/mod/applications/mod_voicemail Message-ID: Author: anthm Date: Sat Mar 14 08:56:45 2009 New Revision: 12602 Log: MODAPP-236 Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Sat Mar 14 08:56:45 2009 @@ -1928,10 +1928,13 @@ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "change-password"); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-User-Password", buf); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-User", myid); + if (actual_id) { + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Actual-User", actual_id); + } switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Domain", domain_name); switch_channel_event_set_data(channel, params); - if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"), + if (switch_xml_locate_user("id", actual_id ? actual_id : myid, domain_name, switch_channel_get_variable(channel, "network_addr"), &xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) { switch_xml_free(xx_domain_root); } From anthm at freeswitch.org Sat Mar 14 07:14:51 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 09:14:51 -0500 Subject: [Freeswitch-svn] [commit] r12603 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sat Mar 14 09:14:51 2009 New Revision: 12603 Log: fix origination_privacy var Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Sat Mar 14 09:14:51 2009 @@ -1305,7 +1305,8 @@ char *vdata; end = NULL; chan_type = peer_names[i]; - + const char *privacy_str = NULL; + while (chan_type && *chan_type && *chan_type == ' ') { chan_type++; } @@ -1432,28 +1433,28 @@ } else { strncpy(tmp, var_begin, strlen(var_begin)); } - + + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_privacy", tmp); + } + + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); + + if ((privacy_str = switch_event_get_header(var_event, "origination_privacy"))) { new_profile->flags = SWITCH_CPF_NONE; - - if (switch_stristr("screen", tmp)) { + + if (switch_stristr("screen", privacy_str)) { switch_set_flag(new_profile, SWITCH_CPF_SCREEN); } - if (switch_stristr("hide_name", tmp)) { + if (switch_stristr("hide_name", privacy_str)) { switch_set_flag(new_profile, SWITCH_CPF_HIDE_NAME); } - if (switch_stristr("hide_number", tmp)) { + if (switch_stristr("hide_number", privacy_str)) { switch_set_flag(new_profile, SWITCH_CPF_HIDE_NUMBER); } - - new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_privacy", tmp); } - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); - - if ((reason = switch_core_session_outgoing_channel(oglobals.session, var_event, chan_type, new_profile, &new_session, &pool, myflags)) != SWITCH_CAUSE_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n", From brian at freeswitch.org Sat Mar 14 07:30:37 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 09:30:37 -0500 Subject: [Freeswitch-svn] [commit] r12604 - freeswitch/trunk/src Message-ID: Author: brian Date: Sat Mar 14 09:30:37 2009 New Revision: 12604 Log: refactor Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Sat Mar 14 09:30:37 2009 @@ -1305,7 +1305,8 @@ char *vdata; end = NULL; chan_type = peer_names[i]; - const char *privacy_str = NULL; + const char *current_variable; + char variable_buffer[512] = ""; while (chan_type && *chan_type && *chan_type == ' ') { chan_type++; @@ -1383,78 +1384,100 @@ myflags |= SOF_FORKED_DIAL; } } + + /* only valid in [] since it's unique to each channel leg */ - if (vdata && (var_begin = switch_stristr("origination_caller_id_number=", vdata))) { + if (vdata && (var_begin = switch_stristr("origination_uuid=", vdata))) { char tmp[512] = ""; - var_begin += strlen("origination_caller_id_number="); + var_begin += strlen("origination_uuid="); var_end = strchr(var_begin, '|'); + if (var_end) { strncpy(tmp, var_begin, var_end-var_begin); } else { strncpy(tmp, var_begin, strlen(var_begin)); } - new_profile->caller_id_number = switch_core_strdup(new_profile->pool, tmp); - myflags |= SOF_NO_EFFECTIVE_CID_NUM; + + new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_uuid", tmp); } - if (vdata && (var_begin = switch_stristr("origination_caller_id_name=", vdata))) { - char tmp[512] = ""; - var_begin += strlen("origination_caller_id_name="); + /* The rest are valid in both {} and [] with [] taking precedence */ + + current_variable = NULL; + + if (vdata && (var_begin = switch_stristr("origination_caller_id_number=", vdata))) { + var_begin += strlen("origination_caller_id_number="); var_end = strchr(var_begin, '|'); + if (var_end) { - strncpy(tmp, var_begin, var_end-var_begin); + strncpy(variable_buffer, var_begin, var_end-var_begin); } else { - strncpy(tmp, var_begin, strlen(var_begin)); + strncpy(variable_buffer, var_begin, strlen(var_begin)); } - new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); - myflags |= SOF_NO_EFFECTIVE_CID_NAME; + + current_variable = variable_buffer; + } + + if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_caller_id_number"))) { + new_profile->caller_id_number = switch_core_strdup(new_profile->pool, current_variable); + myflags |= SOF_NO_EFFECTIVE_CID_NUM; } - if (vdata && (var_begin = switch_stristr("origination_uuid=", vdata))) { - char tmp[512] = ""; - var_begin += strlen("origination_uuid="); + current_variable = NULL; + + if (vdata && (var_begin = switch_stristr("origination_caller_id_name=", vdata))) { + var_begin += strlen("origination_caller_id_name="); var_end = strchr(var_begin, '|'); + if (var_end) { - strncpy(tmp, var_begin, var_end-var_begin); + strncpy(variable_buffer, var_begin, var_end-var_begin); } else { - strncpy(tmp, var_begin, strlen(var_begin)); + strncpy(variable_buffer, var_begin, strlen(var_begin)); } - new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_uuid", tmp); - } - + current_variable = variable_buffer; + } + + if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_caller_id_name"))) { + new_profile->caller_id_number = switch_core_strdup(new_profile->pool, current_variable); + myflags |= SOF_NO_EFFECTIVE_CID_NAME; + } + + current_variable = NULL; + if (vdata && (var_begin = switch_stristr("origination_privacy=", vdata))) { - char tmp[512] = ""; var_begin += strlen("origination_privacy="); var_end = strchr(var_begin, '|'); + if (var_end) { - strncpy(tmp, var_begin, var_end-var_begin); + strncpy(variable_buffer, var_begin, var_end-var_begin); } else { - strncpy(tmp, var_begin, strlen(var_begin)); + strncpy(variable_buffer, var_begin, strlen(var_begin)); } - - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_privacy", tmp); + + current_variable = variable_buffer; } - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); - - if ((privacy_str = switch_event_get_header(var_event, "origination_privacy"))) { + if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_privacy"))) { new_profile->flags = SWITCH_CPF_NONE; - if (switch_stristr("screen", privacy_str)) { + if (switch_stristr("screen", current_variable)) { switch_set_flag(new_profile, SWITCH_CPF_SCREEN); } - if (switch_stristr("hide_name", privacy_str)) { + if (switch_stristr("hide_name", current_variable)) { switch_set_flag(new_profile, SWITCH_CPF_HIDE_NAME); } - if (switch_stristr("hide_number", privacy_str)) { + if (switch_stristr("hide_number", current_variable)) { switch_set_flag(new_profile, SWITCH_CPF_HIDE_NUMBER); } } - + + current_variable = NULL; + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); + if ((reason = switch_core_session_outgoing_channel(oglobals.session, var_event, chan_type, new_profile, &new_session, &pool, myflags)) != SWITCH_CAUSE_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n", From anthm at freeswitch.org Sat Mar 14 12:23:08 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 14:23:08 -0500 Subject: [Freeswitch-svn] [commit] r12605 - in freeswitch/trunk/libs/esl: . src src/include Message-ID: Author: anthm Date: Sat Mar 14 14:23:07 2009 New Revision: 12605 Log: fix socket race Modified: freeswitch/trunk/libs/esl/fs_cli.c freeswitch/trunk/libs/esl/src/esl.c freeswitch/trunk/libs/esl/src/esl_event.c freeswitch/trunk/libs/esl/src/esl_oop.cpp freeswitch/trunk/libs/esl/src/include/esl.h Modified: freeswitch/trunk/libs/esl/fs_cli.c ============================================================================== --- freeswitch/trunk/libs/esl/fs_cli.c (original) +++ freeswitch/trunk/libs/esl/fs_cli.c Sat Mar 14 14:23:07 2009 @@ -193,8 +193,7 @@ thread_running = 1; while(thread_running && handle->connected) { - esl_status_t status = esl_recv_timed(handle, 10); - + esl_status_t status = esl_recv_event_timed(handle, 10, 1, NULL); if (status == ESL_FAIL) { esl_log(ESL_LOG_WARNING, "Disconnected.\n"); running = thread_running = 0; @@ -240,7 +239,11 @@ } if (!known) { - printf("INCOMING DATA [%s]\n%s", type, handle->last_event->body); + printf("INCOMING DATA [%s]\n%s\n", type, handle->last_event->body ? handle->last_event->body : ""); + char *foo; + esl_event_serialize(handle->last_event, &foo, ESL_FALSE); + printf("RECV EVENT\n%s\n", foo); + free(foo); } } } @@ -724,6 +727,7 @@ print_banner(stdout); esl_log(ESL_LOG_INFO, "FS CLI Ready.\nenter /help for a list of commands.\n"); + printf("%s\n", handle.last_sr_reply); while (running) { Modified: freeswitch/trunk/libs/esl/src/esl.c ============================================================================== --- freeswitch/trunk/libs/esl/src/esl.c (original) +++ freeswitch/trunk/libs/esl/src/esl.c Sat Mar 14 14:23:07 2009 @@ -683,6 +683,7 @@ esl_mutex_lock(mutex); } + esl_event_safe_destroy(&handle->race_event); esl_event_safe_destroy(&handle->last_event); esl_event_safe_destroy(&handle->last_sr_event); esl_event_safe_destroy(&handle->last_ievent); @@ -705,20 +706,29 @@ return status; } -ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, esl_event_t **save_event) +ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, int check_q, esl_event_t **save_event) { fd_set rfds, efds; struct timeval tv = { 0 }; int max, activity; esl_status_t status = ESL_SUCCESS; + if (check_q) { + esl_mutex_lock(handle->mutex); + if (handle->race_event) { + esl_mutex_unlock(handle->mutex); + return esl_recv_event(handle, check_q, save_event); + } + esl_mutex_unlock(handle->mutex); + } + if (!handle || !handle->connected || handle->sock == -1) { return ESL_FAIL; } tv.tv_usec = ms * 1000; - esl_mutex_lock(handle->mutex); + FD_ZERO(&rfds); FD_ZERO(&efds); @@ -736,21 +746,21 @@ max = handle->sock + 1; if ((activity = select(max, &rfds, NULL, &efds, &tv)) < 0) { - status = ESL_FAIL; - goto done; + return ESL_FAIL; + } + + if (esl_mutex_trylock(handle->mutex) != ESL_SUCCESS) { + return ESL_BREAK; } if (activity && FD_ISSET(handle->sock, &rfds)) { - if (esl_recv_event(handle, save_event)) { + if (esl_recv_event(handle, check_q, save_event)) { status = ESL_FAIL; - goto done; } } else { status = ESL_BREAK; } - done: - if (handle->mutex) esl_mutex_unlock(handle->mutex); return status; @@ -758,26 +768,41 @@ } -ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **save_event) +ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_event_t **save_event) { char *c; esl_ssize_t rrval; int crc = 0; - esl_event_t *revent = NULL; + esl_event_t *revent = NULL, *qevent = NULL; char *beg; char *hname, *hval; char *col; char *cl; esl_ssize_t len; int zc = 0; - if (!handle->connected) { return ESL_FAIL; } - + esl_mutex_lock(handle->mutex); + if (check_q && handle->race_event) { + qevent = handle->race_event; + handle->race_event = handle->race_event->next; + qevent->next = NULL; + + if (save_event) { + *save_event = qevent; + qevent = NULL; + } else { + handle->last_event = qevent; + } + + esl_mutex_unlock(handle->mutex); + return ESL_SUCCESS; + } + esl_event_safe_destroy(&handle->last_event); memset(handle->header_buf, 0, sizeof(handle->header_buf)); @@ -834,7 +859,7 @@ c++; } } - + if (!revent) { goto fail; } @@ -862,6 +887,7 @@ if (save_event) { *save_event = revent; + revent = NULL; } else { handle->last_event = revent; } @@ -992,19 +1018,50 @@ return ESL_FAIL; } + esl_mutex_lock(handle->mutex); + esl_event_safe_destroy(&handle->last_event); + esl_event_safe_destroy(&handle->last_sr_event); + + *handle->last_sr_reply = '\0'; + if ((status = esl_send(handle, cmd))) { + esl_mutex_unlock(handle->mutex); return status; } - status = esl_recv_event(handle, &handle->last_sr_event); - + recv: + + status = esl_recv_event(handle, 0, &handle->last_sr_event); + if (handle->last_sr_event) { - hval = esl_event_get_header(handle->last_sr_event, "reply-text"); + char *ct = esl_event_get_header(handle->last_sr_event,"content-type"); - if (!esl_strlen_zero(hval)) { - strncpy(handle->last_sr_reply, hval, sizeof(handle->last_sr_reply)); + if (strcasecmp(ct, "api/response") && strcasecmp(ct, "command/reply")) { + esl_event_t *ep; + + for(ep = handle->race_event; ep && ep->next; ep = ep->next); + + if (ep) { + ep->next = handle->last_sr_event; + } else { + handle->race_event = handle->last_sr_event; + } + + handle->last_sr_event = NULL; + + esl_mutex_unlock(handle->mutex); + esl_mutex_lock(handle->mutex); + goto recv; + } + + if (handle->last_sr_event) { + hval = esl_event_get_header(handle->last_sr_event, "reply-text"); + + if (!esl_strlen_zero(hval)) { + strncpy(handle->last_sr_reply, hval, sizeof(handle->last_sr_reply)); + } } } Modified: freeswitch/trunk/libs/esl/src/esl_event.c ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_event.c (original) +++ freeswitch/trunk/libs/esl/src/esl_event.c Sat Mar 14 14:23:07 2009 @@ -367,22 +367,25 @@ ESL_DECLARE(void) esl_event_destroy(esl_event_t **event) { - esl_event_t *ep = *event; - esl_event_header_t *hp, *this; + esl_event_t *ep = *event, *this_event; + esl_event_header_t *hp, *this_header; - if (ep) { - for (hp = ep->headers; hp;) { - this = hp; + for (ep = *event ; ep ;) { + this_event = ep; + ep = ep->next; + + for (hp = this_event->headers; hp;) { + this_header = hp; hp = hp->next; - FREE(this->name); - FREE(this->value); - memset(this, 0, sizeof(*this)); - FREE(this); - } - FREE(ep->body); - FREE(ep->subclass_name); - memset(ep, 0, sizeof(*ep)); - FREE(ep); + FREE(this_header->name); + FREE(this_header->value); + memset(this_header, 0, sizeof(*this_header)); + FREE(this_header); + } + FREE(this_event->body); + FREE(this_event->subclass_name); + memset(this_event, 0, sizeof(*this_event)); + FREE(this_event); } *event = NULL; } Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Sat Mar 14 14:23:07 2009 @@ -154,7 +154,7 @@ delete last_event_obj; } - if (esl_recv_event(&handle, NULL) == ESL_SUCCESS) { + if (esl_recv_event(&handle, 1, NULL) == ESL_SUCCESS) { esl_event_t *e = handle.last_ievent ? handle.last_ievent : handle.last_event; if (e) { esl_event_t *event; @@ -176,7 +176,7 @@ last_event_obj = NULL; } - if (esl_recv_event_timed(&handle, ms, NULL) == ESL_SUCCESS) { + if (esl_recv_event_timed(&handle, ms, 1, NULL) == ESL_SUCCESS) { esl_event_t *e = handle.last_ievent ? handle.last_ievent : handle.last_event; if (e) { esl_event_t *event; Modified: freeswitch/trunk/libs/esl/src/include/esl.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl.h Sat Mar 14 14:23:07 2009 @@ -266,6 +266,7 @@ char last_sr_reply[1024]; esl_event_t *last_event; esl_event_t *last_sr_event; + esl_event_t *race_event; esl_event_t *last_ievent; esl_event_t *info_event; int connected; @@ -334,14 +335,14 @@ ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, esl_port_t port, const char *password); ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle); ESL_DECLARE(esl_status_t) esl_send(esl_handle_t *handle, const char *cmd); -ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **save_event); -ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, esl_event_t **save_event); +ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_event_t **save_event); +ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, int check_q, esl_event_t **save_event); ESL_DECLARE(esl_status_t) esl_send_recv(esl_handle_t *handle, const char *cmd); ESL_DECLARE(esl_status_t) esl_filter(esl_handle_t *handle, const char *header, const char *value); ESL_DECLARE(esl_status_t) esl_events(esl_handle_t *handle, esl_event_type_t etype, const char *value); -#define esl_recv(_h) esl_recv_event(_h, NULL) -#define esl_recv_timed(_h, _ms) esl_recv_event_timed(_h, _ms, NULL) +#define esl_recv(_h) esl_recv_event(_h, 0, NULL) +#define esl_recv_timed(_h, _ms) esl_recv_event_timed(_h, _ms, 0, NULL) static __inline__ int esl_safe_strcasecmp(const char *s1, const char *s2) { From andrew at freeswitch.org Sat Mar 14 16:53:32 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 18:53:32 -0500 Subject: [Freeswitch-svn] [commit] r12606 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Sat Mar 14 18:53:32 2009 New Revision: 12606 Log: Whoops Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Sat Mar 14 18:53:32 2009 @@ -490,7 +490,7 @@ } } - /* release the lock returned by switch_core_locate_session */ + /* release the lock returned by switch_core_session_locate */ switch_core_session_rwunlock(session); } else { @@ -579,14 +579,13 @@ ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "session_attach_failed"); } + /* release the lock returned by switch_core_session_locate */ + switch_core_session_rwunlock(session); } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badsession"); } - /* release the lock returned by switch_core_locate_session */ - switch_core_session_rwunlock(session); - } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); From anthm at freeswitch.org Sat Mar 14 18:21:34 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 14 Mar 2009 20:21:34 -0500 Subject: [Freeswitch-svn] [commit] r12607 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sat Mar 14 20:21:34 2009 New Revision: 12607 Log: move stop up a bit Modified: freeswitch/trunk/src/switch.c Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Sat Mar 14 20:21:34 2009 @@ -270,7 +270,6 @@ int nc = 0; /* TRUE if we are running in noconsole mode */ pid_t pid = 0; int x; - int die = 0; char *usageDesc; int alt_dirs = 0; int known_opt; @@ -470,8 +469,7 @@ } if (argv[x] && !strcmp(argv[x], "-stop")) { - die++; - known_opt++; + return freeswitch_kill_background(); } if (argv[x] && !strcmp(argv[x], "-nc")) { @@ -594,10 +592,6 @@ return 255; } - if (die) { - return freeswitch_kill_background(); - } - if (alt_dirs && alt_dirs != 3) { fprintf(stderr, "You must specify all or none of -conf, -log, and -db\n"); return 255; From silik0n at freeswitch.org Sat Mar 14 22:24:32 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 00:24:32 -0500 Subject: [Freeswitch-svn] [commit] r12608 - in freeswitch/trunk/scripts/contrib/swk: flex/amf-test1/src php/amfphp Message-ID: Author: silik0n Date: Sun Mar 15 00:24:32 2009 New Revision: 12608 Log: getting closer to something worth looking at DB is getting pretty close to being required (some functions will now fail if you dont have the DB setup) Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sun Mar 15 00:24:32 2009 @@ -62,6 +62,45 @@ PopUpManager.createPopUp(this, statusForm, false); } + public function addDomainParam():void { + freeswitch.addDirDomainParam(gridDomainsDomain.selectedItem.uid, inputDomainParamName.text, inputDomainParamValue.text); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function addDomainVar():void { + freeswitch.addDirDomainVar(gridDomainsDomain.selectedItem.uid, inputDomainVarName.text, inputDomainVarValue.text); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function dgChangeDomainParam():void { + freeswitch.updateDirDomainParam(dgDomainParam.selectedItem.uid, dgDomainParam.selectedItem.name, dgDomainParam.value); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function dgChangeDomainVars():void { + freeswitch.updateDirDomainVar(dgDomainVars.selectedItem.uid, dgDomainVars.selectedItem.name, dgDomainVars.value); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function addDomainUserParam():void { + freeswitch.addDirDomainUserParam(gridDomainsDomain.selectedItem.uid, inputDomainParamName.text, inputDomainParamValue.text); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function addDomainUserVar():void { + freeswitch.addDirDomainUserVar(gridDomainsDomain.selectedItem.uid, inputDomainVarName.text, inputDomainVarValue.text); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function dgChangeDomainUserParam():void { + freeswitch.updateDirDomainUserParam(dgDomainParam.selectedItem.uid, dgDomainParam.selectedItem.name, dgDomainParam.value); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } + + public function dgChangeDomainUserVars():void { + freeswitch.updateDirDomainUserParam(dgDomainVars.selectedItem.uid, dgDomainVars.selectedItem.name, dgDomainVars.value); + freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + } ]]> @@ -165,18 +204,32 @@ - + - + + + + + + + + + + + + + @@ -184,7 +237,8 @@ - + @@ -193,8 +247,37 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -221,7 +304,7 @@ - + Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sun Mar 15 00:24:32 2009 @@ -281,12 +281,19 @@ return $results; } - public function addDirDomain($domain_name){ + public function getDirUser($user_uid){ + $dbh = $this->getDbh(); - $query = sprintf('insert into domains (name) values ("%s")', $domain_name); + $query = sprintf("select * from user_params where users_uid = $user_uid"); + $stmt = $dbh->query($query); + $results['params'] = $stmt->fetchAll(); - return $dbh->exec($query); + $query = sprintf("select * from user_variables where users_uid = $user_uid"); + $stmt = $dbh->query($query); + $results['variables'] = $stmt->fetchAll(); + + return $results; } public function getDirUsers($domain_uid){ @@ -309,10 +316,35 @@ return $results; } - + public function addDirDomain($domain_name){ + $dbh = $this->getDbh(); + $query = sprintf('insert into domains (name) values ("%s")', $domain_name); + return $dbh->exec($query); + } -} -/* For Emacs: + public function addDirDomainParam($domain_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('insert into domain_params (domain_uid, name, value) values (%s, "%s", "%s")', $domain_uid, $name, $value); + return $dbh->exec($query); + } + + public function addDirDomainVar($domain_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('insert into domain_variables (domain_uid, name, value) values (%s, "%s", "%s")', $domain_uid, $name, $value); + return $dbh->exec($query); + } + + public function updateDirDomainParam($param_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('update domain_params set name = "%s", value = "%s" where uid=%s', $param_uid, $name, $value); + return $dbh->exec($query); + } + + public function updateDirDomainVar($var_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('update domain_variables set name = "%s", value = "%s" where uid=%s', $var_uid, $name, $value); + return $dbh->exec($query); + } } /* For Emacs: From silik0n at freeswitch.org Sun Mar 15 02:37:47 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 04:37:47 -0500 Subject: [Freeswitch-svn] [commit] r12609 - freeswitch/trunk/conf/autoload_configs Message-ID: Author: silik0n Date: Sun Mar 15 04:37:47 2009 New Revision: 12609 Log: format fixing Modified: freeswitch/trunk/conf/autoload_configs/ivr.conf.xml Modified: freeswitch/trunk/conf/autoload_configs/ivr.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/ivr.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/ivr.conf.xml Sun Mar 15 04:37:47 2009 @@ -49,10 +49,7 @@ max-failures="3"> - + --> From silik0n at freeswitch.org Sun Mar 15 02:38:27 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 04:38:27 -0500 Subject: [Freeswitch-svn] [commit] r12610 - freeswitch/trunk/scripts/contrib/swk/sql Message-ID: Author: silik0n Date: Sun Mar 15 04:38:27 2009 New Revision: 12610 Log: update SQL schema getting ready to add menus, and add some sample data Modified: freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql Modified: freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql (original) +++ freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql Sun Mar 15 04:38:27 2009 @@ -1,112 +1,97 @@ --- --- Initial Table with Sample Data for Project Shipment --- (Or atleast I'm calling it Shipment until I get a better name --- - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - --- --- Database: `shipment` +-- MySQL dump 10.11 -- - --- -------------------------------------------------------- - --- --- Table structure for table `domains` --- - -CREATE TABLE IF NOT EXISTS `domains` ( - `uid` int(11) NOT NULL auto_increment COMMENT 'UID for the table Auto Assigned', - `name` varchar(128) NOT NULL COMMENT 'domaine name', - `enabled` tinyint(1) NOT NULL default '1', - PRIMARY KEY (`uid`), - UNIQUE KEY `name` (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; - --- --- Dumping data for table `domains` --- - -INSERT INTO `domains` (`uid`, `name`, `enabled`) VALUES -(1, '192.168.1.140', 1); - --- -------------------------------------------------------- +-- Host: localhost Database: shipment +-- ------------------------------------------------------ +-- Server version 5.0.45 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `domain_params` -- -CREATE TABLE IF NOT EXISTS `domain_params` ( +DROP TABLE IF EXISTS `domain_params`; +CREATE TABLE `domain_params` ( `uid` int(11) NOT NULL auto_increment, `domains_uid` int(11) NOT NULL, `name` varchar(64) NOT NULL, `value` varchar(256) NOT NULL, PRIMARY KEY (`uid`), KEY `domain_uid` (`domains_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -- -- Dumping data for table `domain_params` -- -INSERT INTO `domain_params` (`uid`, `domains_uid`, `name`, `value`) VALUES -(1, 1, 'dial-string', '{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}'); - --- -------------------------------------------------------- +LOCK TABLES `domain_params` WRITE; +/*!40000 ALTER TABLE `domain_params` DISABLE KEYS */; +INSERT INTO `domain_params` VALUES (1,1,'dial-string','{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}'); +/*!40000 ALTER TABLE `domain_params` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `domain_variables` -- -CREATE TABLE IF NOT EXISTS `domain_variables` ( +DROP TABLE IF EXISTS `domain_variables`; +CREATE TABLE `domain_variables` ( `uid` int(11) NOT NULL auto_increment, `domains_uid` int(11) NOT NULL, `name` varchar(64) NOT NULL, `value` varchar(128) NOT NULL, PRIMARY KEY (`uid`), KEY `domain_uid` (`domains_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -- -- Dumping data for table `domain_variables` -- -INSERT INTO `domain_variables` (`uid`, `domains_uid`, `name`, `value`) VALUES -(1, 1, 'record_stereo', 'true'), -(2, 1, 'default_gateway', '$${default_provider}'), -(3, 1, 'default_areacode', '$${default_areacode}'), -(4, 1, 'transfer_fallback_extension', 'operator'); - --- -------------------------------------------------------- +LOCK TABLES `domain_variables` WRITE; +/*!40000 ALTER TABLE `domain_variables` DISABLE KEYS */; +INSERT INTO `domain_variables` VALUES (1,1,'record_stereo','true'),(2,1,'default_gateway','$${default_provider}'),(3,1,'default_areacode','$${default_areacode}'),(4,1,'transfer_fallback_extension','operator'); +/*!40000 ALTER TABLE `domain_variables` ENABLE KEYS */; +UNLOCK TABLES; -- --- Table structure for table `groups` +-- Table structure for table `domains` -- -CREATE TABLE IF NOT EXISTS `groups` ( - `uid` int(11) NOT NULL auto_increment, - `domains_uid` int(11) NOT NULL, - `name` varchar(64) NOT NULL, +DROP TABLE IF EXISTS `domains`; +CREATE TABLE `domains` ( + `uid` int(11) NOT NULL auto_increment COMMENT 'UID for the table Auto Assigned', + `name` varchar(128) NOT NULL COMMENT 'domaine name', + `enabled` tinyint(1) NOT NULL default '1', PRIMARY KEY (`uid`), - KEY `domain_uid` (`domains_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -- --- Dumping data for table `groups` +-- Dumping data for table `domains` -- -INSERT INTO `groups` (`uid`, `domains_uid`, `name`) VALUES -(1, 1, 'sales'), -(2, 1, 'billing'), -(3, 1, 'support'); - --- -------------------------------------------------------- +LOCK TABLES `domains` WRITE; +/*!40000 ALTER TABLE `domains` DISABLE KEYS */; +INSERT INTO `domains` VALUES (1,'192.168.1.140',1); +/*!40000 ALTER TABLE `domains` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `group_members` -- -CREATE TABLE IF NOT EXISTS `group_members` ( +DROP TABLE IF EXISTS `group_members`; +CREATE TABLE `group_members` ( `uid` int(11) NOT NULL auto_increment, `domains_uid` int(11) NOT NULL, `groups_uid` int(11) NOT NULL, @@ -114,132 +99,176 @@ `type` varchar(32) NOT NULL, PRIMARY KEY (`uid`), KEY `domain_uid` (`domains_uid`,`groups_uid`,`users_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1; -- -- Dumping data for table `group_members` -- - --- -------------------------------------------------------- +LOCK TABLES `group_members` WRITE; +/*!40000 ALTER TABLE `group_members` DISABLE KEYS */; +INSERT INTO `group_members` VALUES (1,1,1,1,'pointer'),(2,1,1,2,'pointer'),(3,1,1,3,'pointer'),(4,1,1,4,'pointer'),(5,1,2,5,'pointer'),(6,1,2,6,'pointer'),(7,1,2,7,'pointer'),(8,1,2,8,'pointer'),(9,1,3,9,'pointer'),(10,1,3,10,'pointer'),(11,1,3,11,'pointer'),(12,1,3,12,'pointer'); +/*!40000 ALTER TABLE `group_members` ENABLE KEYS */; +UNLOCK TABLES; -- --- Table structure for table `users` +-- Table structure for table `groups` -- -CREATE TABLE IF NOT EXISTS `users` ( +DROP TABLE IF EXISTS `groups`; +CREATE TABLE `groups` ( `uid` int(11) NOT NULL auto_increment, - `domain_uid` int(11) NOT NULL, - `username` varchar(64) NOT NULL, - `mailbox` varchar(64) default NULL, - `cidr` varchar(32) default NULL, - `enabled` tinyint(1) NOT NULL default '1', + `domains_uid` int(11) NOT NULL, + `name` varchar(64) NOT NULL, PRIMARY KEY (`uid`), - KEY `domain_uid` (`domain_uid`,`username`,`mailbox`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; + KEY `domain_uid` (`domains_uid`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -- --- Dumping data for table `users` +-- Dumping data for table `groups` -- -INSERT INTO `users` (`uid`, `domain_uid`, `username`, `mailbox`, `cidr`, `enabled`) VALUES -(1, 1, '1000', '1000', NULL, 1), -(2, 1, '1001', '1001', NULL, 1), -(3, 1, '1002', '1002', NULL, 1), -(4, 1, '1003', '1003', NULL, 1), -(5, 1, '1004', '1004', NULL, 1), -(6, 1, '1005', '1005', NULL, 1), -(7, 1, '1006', '1006', NULL, 1), -(8, 1, '1007', '1007', NULL, 1), -(9, 1, '1008', '1008', NULL, 1), -(10, 1, '1009', '1009', NULL, 1), -(11, 1, '1000', '1000', NULL, 1), -(12, 1, '1011', '1011', NULL, 1), -(13, 1, '1012', '1012', NULL, 1), -(14, 1, '1013', '1013', NULL, 1), -(15, 1, '1014', '1014', NULL, 1), -(16, 1, '1015', '1015', NULL, 1), -(17, 1, '1016', '1016', NULL, 1), -(18, 1, '1017', '1017', NULL, 1), -(19, 1, '1018', '1018', NULL, 1), -(20, 1, '1019', '1019', NULL, 1); +LOCK TABLES `groups` WRITE; +/*!40000 ALTER TABLE `groups` DISABLE KEYS */; +INSERT INTO `groups` VALUES (1,1,'sales'),(2,1,'billing'),(3,1,'support'); +/*!40000 ALTER TABLE `groups` ENABLE KEYS */; +UNLOCK TABLES; --- -------------------------------------------------------- +-- +-- Table structure for table `menu_entries` +-- + +DROP TABLE IF EXISTS `menu_entries`; +CREATE TABLE `menu_entries` ( + `uid` int(11) NOT NULL auto_increment, + `menu_uid` int(11) NOT NULL, + `action` varchar(32) NOT NULL, + `digits` varchar(16) NOT NULL, + `param` varchar(256) default NULL, + PRIMARY KEY (`uid`) +) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `menu_entries` +-- + +LOCK TABLES `menu_entries` WRITE; +/*!40000 ALTER TABLE `menu_entries` DISABLE KEYS */; +INSERT INTO `menu_entries` VALUES (1,1,'menu-exec-app','1','bridge sofia/$${domain}/888 at conference.freeswitch.org'),(2,1,'menu-exec-app','2','transfer 9996 XML default'),(3,1,'menu-exec-app','3','transfer 9999 XML default'),(4,1,'menu-sub','4','demo_ivr_submenu'),(5,1,'menu-exec-app','5','transfer 1234*256 enum'),(6,1,'menu-exec-app','/^(10[01][0-9])$','transfer $1 XML features'),(7,1,'menu-top','9',NULL),(8,2,'menu-top','*',NULL); +/*!40000 ALTER TABLE `menu_entries` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `menus` +-- + +DROP TABLE IF EXISTS `menus`; +CREATE TABLE `menus` ( + `uid` int(11) NOT NULL auto_increment, + `name` varchar(64) NOT NULL, + `greet_long` varchar(256) default NULL, + `greet_short` varchar(256) default NULL, + `invalid_sound` varchar(256) default NULL, + `exit_sound` varchar(256) default NULL, + `timeout` int(11) default NULL, + `inter_digit_timeout` int(11) default NULL, + `max_failures` int(11) default NULL, + `max_timeouts` int(11) default NULL, + `digit_len` int(11) default NULL, + PRIMARY KEY (`uid`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `menus` +-- + +LOCK TABLES `menus` WRITE; +/*!40000 ALTER TABLE `menus` DISABLE KEYS */; +INSERT INTO `menus` VALUES (1,'demo_ivr','phrase:demo_ivr_main_menu','phrase:demo_ivr_main_menu_short','ivr/ivr-that_was_an_invalid_entry.wav','voicemail/vm-goodbye.wav',10000,2000,3,3,4),(2,'demo_ivr_submenu','phrase:demo_ivr_sub_menu','phrase:demo_ivr_sub_menu_short','ivr/ivr-that_was_an_invalid_entry.wav','voicemail/vm-goodbye.wav',15000,NULL,3,3,NULL); +/*!40000 ALTER TABLE `menus` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `user_params` -- -CREATE TABLE IF NOT EXISTS `user_params` ( +DROP TABLE IF EXISTS `user_params`; +CREATE TABLE `user_params` ( `uid` int(11) NOT NULL auto_increment, `users_uid` int(11) NOT NULL, `name` varchar(64) NOT NULL, `value` varchar(128) NOT NULL, PRIMARY KEY (`uid`), KEY `user_uid` (`users_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ; +) ENGINE=MyISAM AUTO_INCREMENT=39 DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_params` -- -INSERT INTO `user_params` (`uid`, `users_uid`, `name`, `value`) VALUES -(1, 1, 'password', '1234'), -(2, 1, 'vm-password', '1000'), -(3, 2, 'password', '1234'), -(4, 2, 'vm-password', '1002'), -(5, 3, 'password', '1234'), -(6, 3, 'vm-password', '1003'), -(7, 4, 'password', '1234'), -(8, 4, 'vm-password', '1004'), -(9, 5, 'password', '1234'), -(10, 5, 'vm-password', '1005'), -(11, 6, 'password', '1234'), -(12, 6, 'vm-password', '1006'), -(13, 7, 'password', '1234'), -(14, 7, 'vm-password', '1007'), -(15, 8, 'password', '1234'), -(16, 8, 'vm-password', '1008'), -(17, 9, 'password', '1234'), -(18, 9, 'vm-password', '1009'), -(19, 10, 'password', '1234'), -(20, 10, 'vm-password', '1010'), -(21, 11, 'password', '1234'), -(22, 11, 'vm-password', '1011'), -(23, 12, 'password', '1234'), -(24, 12, 'vm-password', '1012'), -(25, 13, 'password', '1234'), -(26, 13, 'vm-password', '1013'), -(27, 14, 'password', '1234'), -(28, 14, 'vm-password', '1014'), -(29, 15, 'password', '1234'), -(30, 15, 'vm-password', '1015'), -(31, 16, 'password', '1234'), -(32, 16, 'vm-password', '1016'), -(33, 17, 'password', '1234'), -(34, 17, 'vm-password', '1017'), -(35, 18, 'password', '1234'), -(36, 18, 'vm-password', '1018'), -(37, 19, 'password', '1234'), -(38, 19, 'vm-password', '1019'); - --- -------------------------------------------------------- +LOCK TABLES `user_params` WRITE; +/*!40000 ALTER TABLE `user_params` DISABLE KEYS */; +INSERT INTO `user_params` VALUES (1,1,'password','1234'),(2,1,'vm-password','1000'),(3,2,'password','1234'),(4,2,'vm-password','1002'),(5,3,'password','1234'),(6,3,'vm-password','1003'),(7,4,'password','1234'),(8,4,'vm-password','1004'),(9,5,'password','1234'),(10,5,'vm-password','1005'),(11,6,'password','1234'),(12,6,'vm-password','1006'),(13,7,'password','1234'),(14,7,'vm-password','1007'),(15,8,'password','1234'),(16,8,'vm-password','1008'),(17,9,'password','1234'),(18,9,'vm-password','1009'),(19,10,'password','1234'),(20,10,'vm-password','1010'),(21,11,'password','1234'),(22,11,'vm-password','1011'),(23,12,'password','1234'),(24,12,'vm-password','1012'),(25,13,'password','1234'),(26,13,'vm-password','1013'),(27,14,'password','1234'),(28,14,'vm-password','1014'),(29,15,'password','1234'),(30,15,'vm-password','1015'),(31,16,'password','1234'),(32,16,'vm-password','1016'),(33,17,'password','1234'),(34,17,'vm-password','1017'),(35,18,'password','1234'),(36,18,'vm-password','1018'),(37,19,'password','1234'),(38,19,'vm-password','1019'); +/*!40000 ALTER TABLE `user_params` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `user_variables` -- -CREATE TABLE IF NOT EXISTS `user_variables` ( +DROP TABLE IF EXISTS `user_variables`; +CREATE TABLE `user_variables` ( `uid` int(11) NOT NULL auto_increment, `users_uid` int(11) NOT NULL, `name` varchar(64) NOT NULL, `value` varchar(128) NOT NULL, PRIMARY KEY (`uid`), KEY `user_uid` (`users_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_variables` -- +LOCK TABLES `user_variables` WRITE; +/*!40000 ALTER TABLE `user_variables` DISABLE KEYS */; +INSERT INTO `user_variables` VALUES (1,1,'toll_allow','domestic,international,local'),(2,1,'accountcode','1000'),(3,1,'user_context','default'),(4,1,'effective_caller_id_name','Extension 1000'),(5,1,'effective_caller_id_number','1000'),(6,1,'outbound_caller_id_name','$${outbound_caller_name}'),(7,1,'outbound_caller_id_number','$${outbound_caller_id}'),(8,1,'callgroup','techsupport'); +/*!40000 ALTER TABLE `user_variables` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +CREATE TABLE `users` ( + `uid` int(11) NOT NULL auto_increment, + `domain_uid` int(11) NOT NULL, + `username` varchar(64) NOT NULL, + `mailbox` varchar(64) default NULL, + `cidr` varchar(32) default NULL, + `enabled` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`uid`), + KEY `domain_uid` (`domain_uid`,`username`,`mailbox`) +) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `users` +-- + +LOCK TABLES `users` WRITE; +/*!40000 ALTER TABLE `users` DISABLE KEYS */; +INSERT INTO `users` VALUES (1,1,'1000','1000',NULL,1),(2,1,'1001','1001',NULL,1),(3,1,'1002','1002',NULL,1),(4,1,'1003','1003',NULL,1),(5,1,'1004','1004',NULL,1),(6,1,'1005','1005',NULL,1),(7,1,'1006','1006',NULL,1),(8,1,'1007','1007',NULL,1),(9,1,'1008','1008',NULL,1),(10,1,'1009','1009',NULL,1),(11,1,'1010','1010',NULL,1),(12,1,'1011','1011',NULL,1),(13,1,'1012','1012',NULL,1),(14,1,'1013','1013',NULL,1),(15,1,'1014','1014',NULL,1),(16,1,'1015','1015',NULL,1),(17,1,'1016','1016',NULL,1),(18,1,'1017','1017',NULL,1),(19,1,'1018','1018',NULL,1),(20,1,'1019','1019',NULL,1); +/*!40000 ALTER TABLE `users` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +-- Dump completed on 2009-03-15 9:30:01 From silik0n at freeswitch.org Sun Mar 15 03:16:40 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 05:16:40 -0500 Subject: [Freeswitch-svn] [commit] r12611 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src Message-ID: Author: silik0n Date: Sun Mar 15 05:16:40 2009 New Revision: 12611 Log: Add forms for creating new users and domains no backend scripts for these yet Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newDomainForm.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sun Mar 15 05:16:40 2009 @@ -62,6 +62,16 @@ PopUpManager.createPopUp(this, statusForm, false); } + public function doNewUserForm():void { + var origWindow:IFlexDisplayObject = + PopUpManager.createPopUp(this, newUserForm, false); + } + + public function doNewDomainForm():void { + var origWindow:IFlexDisplayObject = + PopUpManager.createPopUp(this, newDomainForm, false); + } + public function addDomainParam():void { freeswitch.addDirDomainParam(gridDomainsDomain.selectedItem.uid, inputDomainParamName.text, inputDomainParamValue.text); freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); @@ -221,7 +231,7 @@ - + @@ -266,10 +276,10 @@ - + - + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newDomainForm.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newDomainForm.mxml Sun Mar 15 05:16:40 2009 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml Sun Mar 15 05:16:40 2009 @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From anthm at freeswitch.org Sun Mar 15 09:56:15 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 11:56:15 -0500 Subject: [Freeswitch-svn] [commit] r12612 - in freeswitch/trunk: libs/esl/python libs/libdingaling/src src/mod/endpoints/mod_dingaling Message-ID: Author: anthm Date: Sun Mar 15 11:56:15 2009 New Revision: 12612 Log: LIBDING-13 Modified: freeswitch/trunk/libs/esl/python/events.py freeswitch/trunk/libs/esl/python/single_command.py freeswitch/trunk/libs/libdingaling/src/libdingaling.c freeswitch/trunk/libs/libdingaling/src/libdingaling.h freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Modified: freeswitch/trunk/libs/esl/python/events.py ============================================================================== --- freeswitch/trunk/libs/esl/python/events.py (original) +++ freeswitch/trunk/libs/esl/python/events.py Sun Mar 15 11:56:15 2009 @@ -5,7 +5,7 @@ from ESL import * -con = ESLconnection("localhost","8021","ClueCon") +con = ESLconnection("localhost","8021","rad1ance") #are we connected? if con.connected: Modified: freeswitch/trunk/libs/esl/python/single_command.py ============================================================================== --- freeswitch/trunk/libs/esl/python/single_command.py (original) +++ freeswitch/trunk/libs/esl/python/single_command.py Sun Mar 15 11:56:15 2009 @@ -4,7 +4,7 @@ import sys from ESL import * -con = ESLconnection("localhost","8021","ClueCon") +con = ESLconnection("localhost","8021","rad1ance") #are we connected? if con.connected: Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Sun Mar 15 11:56:15 2009 @@ -1432,7 +1432,7 @@ ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING); - while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { + while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { ldl_flush_queue(handle, 0); if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) { @@ -1467,7 +1467,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) { - while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { + while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { int e; char tmp[512], *sl; @@ -1522,7 +1522,7 @@ launch_queue_thread(handle); } - while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { + while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { e = iks_recv(handle->parser, 1); if (!ldl_test_flag(handle, LDL_FLAG_TLS) && handle->loop_callback) { if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) { @@ -2166,6 +2166,12 @@ } } +ldl_status ldl_global_terminate(void) +{ + ldl_clear_flag_locked((&globals), LDL_FLAG_READY); + return LDL_STATUS_SUCCESS; +} + ldl_status ldl_global_init(int debug) { if (ldl_test_flag((&globals), LDL_FLAG_INIT)) { @@ -2191,6 +2197,7 @@ globals.logger = default_logger; globals.avatar_hash = apr_hash_make(globals.memory_pool); ldl_set_flag_locked((&globals), LDL_FLAG_INIT); + ldl_set_flag_locked((&globals), LDL_FLAG_READY); return LDL_STATUS_SUCCESS; } Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.h ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.h (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.h Sun Mar 15 11:56:15 2009 @@ -603,6 +603,9 @@ \param log_stream the new log stream */ void ldl_handle_set_log_stream(ldl_handle_t *handle, FILE *log_stream); + +ldl_status ldl_global_terminate(void); + ///\} Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Sun Mar 15 11:56:15 2009 @@ -1868,10 +1868,11 @@ if (globals.running) { int x = 0; globals.running = 0; + ldl_global_terminate(); while (globals.handles > 0) { switch_yield(100000); x++; - if (x > 10) { + if (x > 100) { break; } } From silik0n at freeswitch.org Sun Mar 15 10:47:57 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 12:47:57 -0500 Subject: [Freeswitch-svn] [commit] r12613 - freeswitch/trunk/libs/esl/python Message-ID: Author: silik0n Date: Sun Mar 15 12:47:57 2009 New Revision: 12613 Log: tweak Modified: freeswitch/trunk/libs/esl/python/events.py freeswitch/trunk/libs/esl/python/single_command.py Modified: freeswitch/trunk/libs/esl/python/events.py ============================================================================== --- freeswitch/trunk/libs/esl/python/events.py (original) +++ freeswitch/trunk/libs/esl/python/events.py Sun Mar 15 12:47:57 2009 @@ -5,7 +5,7 @@ from ESL import * -con = ESLconnection("localhost","8021","rad1ance") +con = ESLconnection("localhost","8021","ClueCon") #are we connected? if con.connected: Modified: freeswitch/trunk/libs/esl/python/single_command.py ============================================================================== --- freeswitch/trunk/libs/esl/python/single_command.py (original) +++ freeswitch/trunk/libs/esl/python/single_command.py Sun Mar 15 12:47:57 2009 @@ -4,7 +4,7 @@ import sys from ESL import * -con = ESLconnection("localhost","8021","rad1ance") +con = ESLconnection("localhost","8021","ClueCon") #are we connected? if con.connected: From anthm at freeswitch.org Sun Mar 15 17:28:19 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 19:28:19 -0500 Subject: [Freeswitch-svn] [commit] r12614 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sun Mar 15 19:28:18 2009 New Revision: 12614 Log: fix regression Modified: freeswitch/trunk/src/switch_ivr_bridge.c Modified: freeswitch/trunk/src/switch_ivr_bridge.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_bridge.c (original) +++ freeswitch/trunk/src/switch_ivr_bridge.c Sun Mar 15 19:28:18 2009 @@ -307,13 +307,13 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(chan_a)); goto end_of_bridge_loop; } - ans_a++; + ans_a = 1; } else if (!pre_b && switch_channel_test_flag(chan_b, CF_EARLY_MEDIA)) { if (switch_channel_pre_answer(chan_a) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(chan_a)); goto end_of_bridge_loop; } - pre_b++; + pre_b = 1; } if (!pre_b) { switch_yield(10000); @@ -321,7 +321,7 @@ } } - if (!ans_a && !ans_b) { + if (ans_a != ans_b) { switch_channel_t *un = ans_a ? chan_b : chan_a; if (switch_channel_answer(un) != SWITCH_STATUS_SUCCESS) { @@ -329,7 +329,7 @@ goto end_of_bridge_loop; } - if (ans_a) ans_b++; else ans_a++; + if (ans_a) ans_b = 1; else ans_a = 1; } From silik0n at freeswitch.org Sun Mar 15 18:12:05 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 20:12:05 -0500 Subject: [Freeswitch-svn] [commit] r12615 - in freeswitch/trunk/scripts/contrib/swk: flex/amf-test1/src php/amfphp Message-ID: Author: silik0n Date: Sun Mar 15 20:12:05 2009 New Revision: 12615 Log: Looks like we have most of the data retrival done... still needs some work on pushing data updates Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Sun Mar 15 20:12:05 2009 @@ -217,14 +217,14 @@ - + - + @@ -265,14 +265,14 @@ - + - + @@ -294,27 +294,30 @@ - - + + - + - - + + - + - + - + - + - + Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sun Mar 15 20:12:05 2009 @@ -47,18 +47,17 @@ $db_username = 'root'; /* Database Server username */ $db_password = 'password'; /* Database Server password */ $db_database = 'shipment'; /* DataBase Name */ - - $dbh = new PDO("$dbtype:host=$db_hostname;dbname=$db_database", $db_username, $db_password, array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,)); - + if ($dbtype == 'mysql') { + $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,); + } + $dbh = new PDO("$dbtype:host=$db_hostname;dbname=$db_database", $db_username, $db_password, $pdo_flags); return $dbh; } public function __construct() { - $esl_server = "127.0.0.1"; /* ESL Server */ $esl_port = "8021"; /* ESL Port */ $esl_secret = "ClueCon"; /* ESL Secret */ - $this->esl = new eslConnection($esl_server, $esl_port, $esl_secret); } @@ -67,14 +66,12 @@ public function getStatus() { $e = $this->esl->sendRecv("api status"); $body = $e->getBody(); - return $body; } public function getChannels() { $e = $this->esl->sendRecv("api show channels"); $body = $e->getBody(); - $temp = explode ("\n", $body); $total_count = sizeof($temp); $i = -1; @@ -100,7 +97,6 @@ public function getCalls() { $e = $this->esl->sendRecv("api show calls"); $body = $e->getBody(); - $temp = explode ("\n", $body); $total_count = sizeof($temp); $i = -1; @@ -129,7 +125,6 @@ $dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout"; $e = $this->esl->sendRecv($dialstring); $body = $e->getBody(); - return $body; } @@ -150,7 +145,6 @@ public function getConferenceList() { $e = $this->esl->sendRecv("api conference list"); $body = $e->getBody(); - $data=explode("\n", $body); $y=0; foreach($data as $row){ @@ -166,7 +160,6 @@ public function getConferenceUsers($conference_name) { $e = $this->esl->sendRecv("api conference $conference_name list"); $body = $e->getBody(); - $data=explode("\n", $body); $y=0; foreach($data as $row){ @@ -206,7 +199,6 @@ } else { $templist = glob("/usr/local/freeswitch/sounds/en/us/callie/*/*/*"); } - $x=0; foreach($templist as $file){ $temp_file = explode("/", $file); @@ -215,7 +207,6 @@ // $filelist[$x] = $file; $x++; } - return $filelist; } @@ -255,67 +246,27 @@ } /*** Directory Methods ***/ - + + /* Directory Domain Methods */ public function getDirDomains(){ $dbh = $this->getDbh(); - $query = sprintf("select * from domains"); $stmt = $dbh->query($query); $results = $stmt->fetchAll(); - return $results; } public function getDirDomain($domain_uid){ - $dbh = $this->getDbh(); - $query = sprintf("select * from domain_params where domains_uid = $domain_uid"); $stmt = $dbh->query($query); $results['params'] = $stmt->fetchAll(); - $query = sprintf("select * from domain_variables where domains_uid = $domain_uid"); $stmt = $dbh->query($query); $results['variables'] = $stmt->fetchAll(); - return $results; } - public function getDirUser($user_uid){ - - $dbh = $this->getDbh(); - - $query = sprintf("select * from user_params where users_uid = $user_uid"); - $stmt = $dbh->query($query); - $results['params'] = $stmt->fetchAll(); - - $query = sprintf("select * from user_variables where users_uid = $user_uid"); - $stmt = $dbh->query($query); - $results['variables'] = $stmt->fetchAll(); - - return $results; - } - - public function getDirUsers($domain_uid){ - $dbh = $this->getDbh(); - - $query = sprintf("select * from users where domain_uid = $domain_uid"); - $stmt = $dbh->query($query); - $results = $stmt->fetchAll(); - - return $results; - } - - public function getDirGroups($domain_uid){ - $dbh = $this->getDbh(); - - $query = sprintf("select * from groups where domain_uid = $domain_uid"); - $stmt = $dbh->query($query); - $results = $stmt->fetchAll(); - - return $results; - } - public function addDirDomain($domain_name){ $dbh = $this->getDbh(); $query = sprintf('insert into domains (name) values ("%s")', $domain_name); @@ -346,6 +297,47 @@ return $dbh->exec($query); } + + /* Directory User Methods */ + public function getDirUser($user_uid){ + $dbh = $this->getDbh(); + $query = sprintf("select * from user_params where users_uid = $user_uid"); + $stmt = $dbh->query($query); + $results['params'] = $stmt->fetchAll(); + $query = sprintf("select * from user_variables where users_uid = $user_uid"); + $stmt = $dbh->query($query); + $results['variables'] = $stmt->fetchAll(); + return $results; + } + + public function getDirUsers($domain_uid){ + $dbh = $this->getDbh(); + $query = sprintf("select * from users where domain_uid = $domain_uid"); + $stmt = $dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + + /* Directory Group Methods */ + public function getDirGroups($domain_uid){ + $dbh = $this->getDbh(); + $query = sprintf("select * from groups where domains_uid = $domain_uid"); + $stmt = $dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + + public function getDirGroup($groups_uid){ + $dbh = $this->getDbh(); + $query = sprintf("select a.uid as groupMemberUid, a.users_uid as usersUid, b.username as usersUsername from group_members as a, users as b where a.groups_uid = $groups_uid and a.users_uid = b.uid") ; + $stmt = $dbh->query($query); + $results['members'] = $stmt->fetchAll(); + $query = sprintf("select uid as usersUid, username as usersUsername from users where uid not in (select users_uid from group_members where groups_uid = $groups_uid) and domain_uid = (select domains_uid from groups where uid = $groups_uid)"); + $stmt = $dbh->query($query); + $results['nonmembers'] = $stmt->fetchAll(); + return $results; + } + } /* For Emacs: * Local Variables: From mikej at freeswitch.org Sun Mar 15 18:37:18 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 20:37:18 -0500 Subject: [Freeswitch-svn] [commit] r12616 - freeswitch/trunk/src Message-ID: Author: mikej Date: Sun Mar 15 20:37:18 2009 New Revision: 12616 Log: fix group_confirm regression from svn r12403 Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Sun Mar 15 20:37:18 2009 @@ -178,7 +178,7 @@ goto wbreak; } - if (switch_channel_up(channel)) { + if (!switch_channel_up(channel)) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); goto wbreak; } From brian at freeswitch.org Sun Mar 15 19:15:12 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Sun, 15 Mar 2009 21:15:12 -0500 Subject: [Freeswitch-svn] [commit] r12617 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Sun Mar 15 21:15:12 2009 New Revision: 12617 Log: reset rtp timer on unhold op Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Sun Mar 15 21:15:12 2009 @@ -2297,6 +2297,7 @@ switch_yield(250000); if (tech_pvt->max_missed_packets) { + switch_rtp_reset_media_timer(tech_pvt->rtp_session); switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets); } From silik0n at freeswitch.org Mon Mar 16 04:33:35 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 06:33:35 -0500 Subject: [Freeswitch-svn] [commit] r12618 - in freeswitch/trunk/scripts/contrib/swk: flex/amf-test1/bin-debug flex/amf-test1/libs flex/amf-test1/src flex/amf-test1/src/assets flex/amf-test1/src/assets/css flex/amf-test1/src/assets/fonts flex/amf-test1/src/assets/icons flex/amf-test1/src/assets/images flex/amf-test1/src/assets/skins flex/amf-test1/src/assets/xml flex/amf-test1/src/com flex/amf-test1/src/com/views php/amfphp Message-ID: Author: silik0n Date: Mon Mar 16 06:33:34 2009 New Revision: 12618 Log: look for a tarball soon Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/libs/CSSPlus.swc (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/libs/Degrafa_.2.11.swc (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/css/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/css/Main.css freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/fonts/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/fonts/lucidaGrande.swf (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/ai.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/air.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/fl.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/fw.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/fx.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/ps.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_left.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_left_disabled.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_left_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_middle.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_middle_disabled.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_middle_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_right.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_right_disabled.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_right_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/checkBox_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/checkBox_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/checkBox_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/comboBox_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/comboBox_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/glass_btn_disable.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/glass_btn_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/glass_btn_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/header_bg.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/main_bg.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/panel_bg.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/radio_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/radio_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/radio_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_down_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_down_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_up_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_up_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/search_input.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/slider_thumb_up.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_first.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_first_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_first_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_last.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_last_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_last_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_middle.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_middle_over.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_middle_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/thum_skin.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/track_skin.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tree_folder.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tree_folder_open.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/BaseSkin.as freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/PanelBackgroundSkin.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/PanelContentSkin.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/SmartPanelSkin.as freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/xml/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/xml/listData.xml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/SampleTitleWindow.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Controls.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/List2.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Lists.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Navigation.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Text.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf ============================================================================== Binary files. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/libs/CSSPlus.swc ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/libs/Degrafa_.2.11.swc ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/css/Main.css ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/css/Main.css Mon Mar 16 06:33:34 2009 @@ -0,0 +1,325 @@ +/* CSS file */ +Application +{ + backgroundColor:#f9f6d9; + borderSkin: ClassReference("com.degrafa.skins.CSSSkin"); + background-repeat:repeat; + background-image: Embed(source='assets/images/main_bg.png'); + fontFamily: "Lucida Grande"; + color: #000000; + fontSize: 12; + themeColor:#288bca; +} +MenuBar +{ + background-skin: ClassReference("com.degrafa.skins.CSSSkin"); + background-image: Embed(source='assets/images/header_bg.png'); + background-repeat:repeat-x; + menuStyleName: menuStyleName; + selectionColor:#4385d9; + rollOverColor:#4385d9; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; +} + +.menuStyleName +{ + +} +Panel{ + titleStyleName: "panelTitle"; + contentStyleName: contentStyleName; + headerHeight:35; + + border-skin:ClassReference("assets.skins.SmartPanelSkin"); + background-skin: ClassReference("assets.skins.PanelBackgroundSkin"); + backgroundRepeat:repeat; + border-background-image:Embed(source='assets/images/panel_bg.png'); + cornerRadius:8; + bottomCornerRadius: 3; + filters:dropShadow; + borderColor:#dddddd; + border-style: none; + paddingTop:20; + paddingLeft:20; + paddingRight:20; + paddingBottom:20; +} +.panelTitle{ + textAlign:center; + fontSize:13; +} +.contentStyleName +{ + skin: ClassReference("assets.skins.PanelContentSkin"); + filters: contentDropShadow; + cornerRadius: 0; +} + +Alert +{ + color:#333333; + paddingBottom: 10; +} +Button +{ + upSkin:Embed(source='assets/images/glass_btn_up.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11); + downSkin:Embed(source='assets/images/glass_btn_over.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11); + overSkin:Embed(source='assets/images/glass_btn_over.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11); + selectedUpSkin:Embed(source='assets/images/glass_btn_over.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11); + selectedOverSkin:Embed(source='assets/images/glass_btn_over.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11); + disabledSkin:Embed(source='assets/images/glass_btn_disable.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11); + color:#000000; + textRollOverColor:#000000; +} + + +ScrollBar{ + trackSkin:Embed(source='assets/images/track_skin.png'); + thumbUpSkin:Embed(source='assets/images/thum_skin.png', scaleGridLeft=8, scaleGridRight=9, scaleGridTop=11,scaleGridBottom=12); + thumbOverSkin:Embed(source='assets/images/thum_skin.png', scaleGridLeft=8, scaleGridRight=9, scaleGridTop=11,scaleGridBottom=12); + thumbDownSkin:Embed(source='assets/images/thum_skin.png', scaleGridLeft=8, scaleGridRight=9, scaleGridTop=11,scaleGridBottom=12); + upArrowUpSkin:Embed(source='assets/images/scroll_arrow_up_up.png'); + upArrowDownSkin:Embed(source='assets/images/scroll_arrow_up_over.png'); + upArrowOverSkin:Embed(source='assets/images/scroll_arrow_up_over.png'); + downArrowUpSkin:Embed(source='assets/images/scroll_arrow_down_up.png'); + downArrowDownSkin:Embed(source='assets/images/scroll_arrow_down_over.png'); + downArrowOverSkin:Embed(source='assets/images/scroll_arrow_down_over.png'); +} + +DataGrid{ + headerColors:#7ab8ef,#c6fdff; + selectionColor:#4385d9; + rollOverColor:#4385d9; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; +} +.searchInput{ + borderSkin:Embed(source='assets/images/search_input.png', scaleGridLeft=22, scaleGridRight=65, scaleGridTop=18,scaleGridBottom=19); + cornerRadius:12; + textIndent:18; + fontSize:12; + fontFamily:Verdana; + borderThikness:1; + borderStyle:solid; +} +TabNavigator, TabBar +{ + tabStyleName: tabStyleName; + firstTabStyleName: firstTab; + lastTabStyleName: lastTab; + fontSize: 12; +} +.tabStyleName +{ + upSkin:Embed(source='assets/images/tab_middle.png', scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + downSkin: Embed(source='assets/images/tab_middle_over.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + overSkin: Embed(source='assets/images/tab_middle_over.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + selectedUpSkin: Embed(source='assets/images/tab_middle_selected.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + selectedOverSkin: Embed(source='assets/images/tab_middle_selected.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + paddingBottom: 3; + paddingTop: 5; + paddingLeft: 9; + paddingRight: 9; +} + +.firstTab { + upSkin:Embed(source='assets/images/tab_first.png', scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + downSkin:Embed(source='assets/images/tab_first_over.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + overSkin:Embed(source='assets/images/tab_first_over.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + selectedUpSkin:Embed(source='assets/images/tab_first_selected.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + selectedOverSkin:Embed(source='assets/images/tab_first_selected.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + paddingBottom: 3; + paddingTop: 5; + paddingLeft: 9; + paddingRight: 9; +} + +.lastTab { + upSkin:Embed(source='assets/images/tab_last.png', scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + downSkin:Embed(source='assets/images/tab_last_over.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + overSkin:Embed(source='assets/images/tab_last_over.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + selectedUpSkin:Embed(source='assets/images/tab_last_selected.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + selectedOverSkin:Embed(source='assets/images/tab_last_selected.png', + scaleGridLeft=9, scaleGridRight=37, scaleGridTop=13,scaleGridBottom=14); + paddingBottom: 3; + paddingTop: 5; + paddingLeft: 9; + paddingRight: 9; +} + +RadioButton +{ + upIcon: Embed(source='assets/images/radio_up.png'); + downIcon:Embed(source='assets/images/radio_over.png'); + overIcon:Embed(source='assets/images/radio_over.png'); + selectedUpIcon:Embed(source='assets/images/radio_selected.png'); + selectedOverIcon:Embed(source='assets/images/radio_selected.png'); + selectedDownIcon:Embed(source='assets/images/radio_selected.png'); +} +Slider, VSlider +{ + thumbUpSkin: Embed(source='assets/images/slider_thumb_up.png', scaleGridLeft=6, scaleGridRight=7, scaleGridTop=7,scaleGridBottom=8); + thumbOverSkin: Embed(source='assets/images/slider_thumb_up.png', scaleGridLeft=6, scaleGridRight=7, scaleGridTop=7,scaleGridBottom=8); + thumbDownSkin: Embed(source='assets/images/slider_thumb_up.png', scaleGridLeft=6, scaleGridRight=7, scaleGridTop=7,scaleGridBottom=8); +} + ComboBox{ + upSkin: Embed(source='assets/images/comboBox_up.png',scaleGridLeft=10, scaleGridRight=160, scaleGridTop=10,scaleGridBottom=11); + overSkin:Embed(source='assets/images/comboBox_over.png',scaleGridLeft=10, scaleGridRight=160, scaleGridTop=10,scaleGridBottom=11); + downSkin:Embed(source='assets/images/comboBox_over.png',scaleGridLeft=10, scaleGridRight=160, scaleGridTop=10,scaleGridBottom=11); + selectedUpSkin:Embed(source='assets/images/comboBox_up.png',scaleGridLeft=10, scaleGridRight=160, scaleGridTop=10,scaleGridBottom=11); + selectedOverSkin:Embed(source='assets/images/comboBox_up.png',scaleGridLeft=10, scaleGridRight=160, scaleGridTop=10,scaleGridBottom=11); +} +ComboBox, Tree, List +{ + selectionColor:#4385d9; + rollOverColor:#4385d9; + textRollOverColor:#ffffff; + textSelectedColor:#ffffff; +} + +DateChooser { + headerColors: #C9C9C9, #C9C9C9; +} + +Tree { + folderClosedIcon: Embed(source='assets/images/tree_folder.png'); + folderOpenIcon: Embed(source='assets/images/tree_folder_open.png'); +} + +CheckBox +{ + upIcon: Embed(source='assets/images/checkBox_up.png'); + downIcon:Embed(source='assets/images/checkBox_selected.png'); + overIcon:Embed(source='assets/images/checkBox_over.png'); + selectedUpIcon:Embed(source='assets/images/checkBox_selected.png'); + selectedOverIcon:Embed(source='assets/images/checkBox_selected.png'); + selectedDownIcon:Embed(source='assets/images/checkBox_selected.png'); +} + +Accordion { + headerStyleName: accordionHeader; +} + +.accordionHeader { + fontSize: 11; + fillColors: #FFFFFF, #EEEEEE; + fillAlphas: 1, 1; + paddingTop: 7; + paddingLeft: 10; + paddingBottom: 4; + paddingRight: 10; + +} + +ButtonBar { + buttonStyleName: buttonBarButton; + firstButtonStyleName: firstButtonBarButton; + lastButtonStyleName: lastButtonBarButton; + fontSize: 11; +} + +.buttonBarButton { + upSkin:Embed(source='assets/images/button_bar_middle.png', + scaleGridLeft=4, scaleGridRight=16, scaleGridTop=11,scaleGridBottom=12); + downSkin:Embed(source='assets/images/button_bar_middle_selected.png', + scaleGridLeft=4, scaleGridRight=16, scaleGridTop=11,scaleGridBottom=12); + overSkin:Embed(source='assets/images/button_bar_middle_selected.png', + scaleGridLeft=4, scaleGridRight=16, scaleGridTop=11,scaleGridBottom=12); + selectedUpSkin:Embed(source='assets/images/button_bar_middle_selected.png', + scaleGridLeft=4, scaleGridRight=16, scaleGridTop=11,scaleGridBottom=12); + selectedOverSkin:Embed(source='assets/images/button_bar_middle_selected.png', + scaleGridLeft=4, scaleGridRight=16, scaleGridTop=11,scaleGridBottom=12); + disabledSkin:Embed(source='assets/images/button_bar_middle_disabled.png', + scaleGridLeft=4, scaleGridRight=16, scaleGridTop=11,scaleGridBottom=12); + + paddingTop: 5; + paddingBottom: 4; +} + +.firstButtonBarButton { + upSkin:Embed(source='assets/images/button_bar_left.png', + scaleGridLeft=10, scaleGridRight=11, scaleGridTop=11,scaleGridBottom=12); + downSkin:Embed(source='assets/images/button_bar_left_selected.png', + scaleGridLeft=10, scaleGridRight=11, scaleGridTop=11,scaleGridBottom=12); + overSkin:Embed(source='assets/images/button_bar_left_selected.png', + scaleGridLeft=10, scaleGridRight=11, scaleGridTop=11,scaleGridBottom=12); + selectedUpSkin:Embed(source='assets/images/button_bar_left_selected.png', + scaleGridLeft=10, scaleGridRight=11, scaleGridTop=11,scaleGridBottom=12); + selectedOverSkin:Embed(source='assets/images/button_bar_left_selected.png', + scaleGridLeft=10, scaleGridRight=11, scaleGridTop=11,scaleGridBottom=12); + disabledSkin:Embed(source='assets/images/button_bar_left_disabled.png', + scaleGridLeft=10, scaleGridRight=11, scaleGridTop=11,scaleGridBottom=12); + + paddingTop: 5; + paddingBottom: 4; +} + +.lastButtonBarButton { + upSkin:Embed(source='assets/images/button_bar_right.png', + scaleGridLeft=10, scaleGridRight=14, scaleGridTop=11,scaleGridBottom=12); + downSkin:Embed(source='assets/images/button_bar_right_selected.png', + scaleGridLeft=10, scaleGridRight=14, scaleGridTop=11,scaleGridBottom=12); + overSkin:Embed(source='assets/images/button_bar_right_selected.png', + scaleGridLeft=10, scaleGridRight=14, scaleGridTop=11,scaleGridBottom=12); + selectedUpSkin:Embed(source='assets/images/button_bar_right_selected.png', + scaleGridLeft=10, scaleGridRight=14, scaleGridTop=11,scaleGridBottom=12); + selectedOverSkin:Embed(source='assets/images/button_bar_right_selected.png', + scaleGridLeft=10, scaleGridRight=14, scaleGridTop=11,scaleGridBottom=12); + disabledSkin:Embed(source='assets/images/button_bar_right_disabled.png', + scaleGridLeft=10, scaleGridRight=14, scaleGridTop=11,scaleGridBottom=12); + + paddingTop: 5; + paddingBottom: 4; + paddingRight: 7; +} + + +/**************************************************************************************************************** + FILTERS * +***************************************************************************************************************** +*/ +.dropShadow +{ + filterClass:ClassReference('com.asfusion.skins.filters.CSSDropShadowFilter'); + distance:5; + blurX:32; + blurY:32; + quality:3; + alpha:0.6; +} +.contentDropShadow +{ + filterClass:ClassReference('com.asfusion.skins.filters.CSSDropShadowFilter'); + distance: 0; + blurX: 4; + blurY: 4; + quality:3; + alpha: 0.5; + inner: true; +} + +/**************************************************************************************************************** + FONTS * +***************************************************************************************************************** +*/ + at font-face { + src:url("assets/fonts/lucidaGrande.swf"); + fontFamily: "Lucida Grande"; +} + at font-face { + src:url("assets/fonts/lucidaGrande.swf"); + fontFamily: "Lucida Grande"; + fontWeight:bold; +} \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/fonts/lucidaGrande.swf ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/ai.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/air.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/fl.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/fw.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/fx.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/icons/ps.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_left.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_left_disabled.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_left_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_middle.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_middle_disabled.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_middle_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_right.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_right_disabled.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/button_bar_right_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/checkBox_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/checkBox_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/checkBox_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/comboBox_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/comboBox_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/glass_btn_disable.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/glass_btn_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/glass_btn_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/header_bg.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/main_bg.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/panel_bg.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/radio_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/radio_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/radio_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_down_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_down_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_up_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/scroll_arrow_up_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/search_input.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/slider_thumb_up.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_first.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_first_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_first_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_last.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_last_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_last_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_middle.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_middle_over.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_middle_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tab_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/thum_skin.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/track_skin.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tree_folder.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/images/tree_folder_open.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/BaseSkin.as ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/BaseSkin.as Mon Mar 16 06:33:34 2009 @@ -0,0 +1,91 @@ +package assets.skins +{ + import com.asfusion.skins.filters.ICSSFilter; + import com.degrafa.Surface; + + import flash.events.Event; + import flash.filters.BitmapFilter; + + import mx.styles.CSSStyleDeclaration; + import mx.styles.IStyleClient; + import mx.styles.StyleManager; + + public class BaseSkin extends Surface + { + [Bindable (event="skinSizeChange")] + protected var skinWidth:int; + + [Bindable (event="skinSizeChange")] + protected var skinHeight:int; + + //.........................................BaseSkin Contructor........................................ + public function BaseSkin() + { + super(); + } + + //.........................................updateDisplayList.......................................... + override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void + { + super.updateDisplayList(unscaledWidth, unscaledHeight); + if(unscaledWidth || unscaledHeight) + { + skinWidth = unscaledWidth; + skinHeight = unscaledHeight; + dispatchEvent( new Event("skinSizeChange")); + } + } + + //.........................................styleName.......................................... + override public function set styleName(value:Object):void + { + super.styleName = value; + if(!value is IStyleClient) return; + + var bitmapFilters:Array = new Array(); + var CSSfilters:Object; + if(value is IStyleClient) + { + CSSfilters = IStyleClient(value).getStyle('filters'); + } + else if(value is CSSStyleDeclaration) + { + CSSfilters = CSSStyleDeclaration(value).getStyle('filters'); + } + if(CSSfilters is String) + { + bitmapFilters.push(createFilter(CSSfilters as String)); + } + else + { + for each( var filterStyleName:String in bitmapFilters) + { + bitmapFilters.push(createFilter(filterStyleName)); + } + } + filters = bitmapFilters; + } + + //.........................................createFilter.......................................... + protected function createFilter(styleName:String):BitmapFilter + { + var CSSfilter:CSSStyleDeclaration = StyleManager.getStyleDeclaration("."+styleName); + var filterClass:Class = CSSfilter.getStyle('filterClass'); + var filter:ICSSFilter = new filterClass(); + filter.styleName = CSSfilter; + return filter.filter; + } + + //.........................................getBottomCornerRadius.......................................... + protected function getBottomCornerRadius():int + { + var bottomCornerRadius:* = getStyle('bottomCornerRadius'); + var bottomCorners:int = 0; + if(bottomCornerRadius !== 0) + { + bottomCorners = bottomCornerRadius; + } + return bottomCorners; + } + } +} \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/PanelBackgroundSkin.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/PanelBackgroundSkin.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/PanelContentSkin.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/PanelContentSkin.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/SmartPanelSkin.as ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/skins/SmartPanelSkin.as Mon Mar 16 06:33:34 2009 @@ -0,0 +1,72 @@ +package assets.skins +{ + import flash.display.DisplayObject; + + import mx.containers.Panel; + import mx.core.EdgeMetrics; + import mx.core.mx_internal; + import mx.skins.halo.PanelSkin; + import mx.styles.CSSStyleDeclaration; + import mx.styles.IStyleClient; + import mx.styles.StyleManager; + use namespace mx_internal; + + public class SmartPanelSkin extends PanelSkin + { + private var backgroundComplete:Boolean; + private var contentComplete:Boolean; + + public function SmartPanelSkin() + { + super(); + } + override mx_internal function drawBorder(w:Number, h:Number):void + { + if(!parent || contentComplete) return; + + contentComplete = true; + var contentStyleName:* = getStyle("contentStyleName"); + if(contentStyleName) + { + var contentCSS:CSSStyleDeclaration = StyleManager.getStyleDeclaration("." + contentStyleName); + var contentSkin:Class = contentCSS.getStyle("skin"); + if(contentSkin && parent is Panel) + { + var contentInstance:DisplayObject = new contentSkin(); + if(contentInstance is IStyleClient) IStyleClient(contentInstance).styleName = contentCSS; + var metrics:EdgeMetrics = borderMetrics; + contentInstance.width = w - metrics.left - metrics.right; + contentInstance.height = h - metrics.bottom - metrics.top; + contentInstance.x = metrics.left; + contentInstance.y = metrics.top; + var panel:Panel = Panel(parent); + panel.rawChildren.addChildAt(contentInstance,1); + } + } + else + { + super.drawBorder(w,h); + } + } + override mx_internal function drawBackground(w:Number, h:Number):void + { + if(!parent || backgroundComplete) return; + + backgroundComplete = true; + var backgroundSkin:Class = getStyle("backgroundSkin"); + if(backgroundSkin && parent is Panel) + { + var backgroundInstance:DisplayObject = new backgroundSkin(); + if(backgroundInstance is IStyleClient) IStyleClient(backgroundInstance).styleName = parent; + backgroundInstance.width = w; + backgroundInstance.height = h; + var panel:Panel = Panel(parent); + panel.rawChildren.addChildAt(backgroundInstance,0); + } + else + { + super.drawBackground(w,h); + } + } + } +} \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/xml/listData.xml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/assets/xml/listData.xml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,21 @@ + + + + assets/icons/fx.jpg + + + assets/icons/ai.jpg + + + assets/icons/ps.jpg + + + assets/icons/fw.jpg + + + assets/icons/fl.jpg + + + assets/icons/air.jpg + + \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/SampleTitleWindow.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/SampleTitleWindow.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,24 @@ + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Controls.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Controls.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/List2.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/List2.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + Christina Coenraets + 555-219-2270 + ccoenraets at fictitious.com + true + + + Joanne Wall + 555-219-2012 + jwall at fictitious.com + true + + + Maurice Smith + 555-219-2012 + maurice at fictitious.com + false + + + Mary Jones + 555-219-2000 + mjones at fictitious.com + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Lists.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Lists.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,52 @@ + + + + + + Christina Coenraets + 555-219-2270 + ccoenraets at fictitious.com + true + + + Joanne Wall + 555-219-2012 + jwall at fictitious.com + true + + + Maurice Smith + 555-219-2012 + maurice at fictitious.com + false + + + Mary Jones + 555-219-2000 + mjones at fictitious.com + true + + + + + + + + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Navigation.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Navigation.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Text.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/com/views/Text.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,9 @@ + + + + + + + + + Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Mon Mar 16 06:33:34 2009 @@ -1,5 +1,6 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml Mon Mar 16 06:33:34 2009 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Mon Mar 16 06:33:34 2009 @@ -43,14 +43,16 @@ private function getDbh(){ $dbtype='mysql'; /* Set the Database type */ - $db_hostname = 'localhost'; /* Database Server hostname */ + // $db_hostname = 'localhost'; /* Database Server hostname */ + $db_hostname = '192.168.1.140'; /* Database Server hostname */ + $db_port = '3306'; /* Database Server Port */ $db_username = 'root'; /* Database Server username */ $db_password = 'password'; /* Database Server password */ $db_database = 'shipment'; /* DataBase Name */ if ($dbtype == 'mysql') { $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,); } - $dbh = new PDO("$dbtype:host=$db_hostname;dbname=$db_database", $db_username, $db_password, $pdo_flags); + $dbh = new PDO("$dbtype:host=$db_hostname;port=$db_port;dbname=$db_database", $db_username, $db_password, $pdo_flags); return $dbh; } @@ -256,12 +258,12 @@ return $results; } - public function getDirDomain($domain_uid){ + public function getDirDomain($domains_uid){ $dbh = $this->getDbh(); - $query = sprintf("select * from domain_params where domains_uid = $domain_uid"); + $query = sprintf("select * from domain_params where domains_uid = $domains_uid"); $stmt = $dbh->query($query); $results['params'] = $stmt->fetchAll(); - $query = sprintf("select * from domain_variables where domains_uid = $domain_uid"); + $query = sprintf("select * from domain_variables where domains_uid = $domains_uid"); $stmt = $dbh->query($query); $results['variables'] = $stmt->fetchAll(); return $results; @@ -273,16 +275,16 @@ return $dbh->exec($query); } - public function addDirDomainParam($domain_uid, $name, $value) { + public function addDirDomainParam($domains_uid, $name, $value) { $dbh = $this->getDbh(); - $query = sprintf('insert into domain_params (domain_uid, name, value) values (%s, "%s", "%s")', $domain_uid, $name, $value); + $query = sprintf('insert into domain_params (domains_uid, name, value) values (%s, "%s", "%s")', $domains_uid, $name, $value); return $dbh->exec($query); } - public function addDirDomainVar($domain_uid, $name, $value) { + public function addDirDomainVar($domains_uid, $name, $value) { $dbh = $this->getDbh(); - $query = sprintf('insert into domain_variables (domain_uid, name, value) values (%s, "%s", "%s")', $domain_uid, $name, $value); - return $dbh->exec($query); + $query = sprintf('insert into domain_variables (domains_uid, name, value) values (%s, "%s", "%s")', $domains_uid, $name, $value); + $dbh->exec($query); } public function updateDirDomainParam($param_uid, $name, $value) { @@ -310,18 +312,42 @@ return $results; } - public function getDirUsers($domain_uid){ + public function getDirUsers($domains_uid){ $dbh = $this->getDbh(); - $query = sprintf("select * from users where domain_uid = $domain_uid"); + $query = sprintf("select * from users where domains_uid = $domains_uid"); $stmt = $dbh->query($query); $results = $stmt->fetchAll(); return $results; } + public function addDirDomainUserParam($users_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('insert into user_params (users_uid, name, value) values (%s, "%s", "%s")', $users_uid, $name, $value); + return $dbh->exec($query); + } + + public function addDirDomainUserVar($users_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('insert into user_variables (users_uid, name, value) values (%s, "%s", "%s")', $users_uid, $name, $value); + $dbh->exec($query); + } + + public function updateDirDomainUserParam($param_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('update user_params set name = "%s", value = "%s" where uid=%s', $param_uid, $name, $value); + return $dbh->exec($query); + } + + public function updateDirDomainUserVar($var_uid, $name, $value) { + $dbh = $this->getDbh(); + $query = sprintf('update user_variables set name = "%s", value = "%s" where uid=%s', $var_uid, $name, $value); + return $dbh->exec($query); + } + /* Directory Group Methods */ - public function getDirGroups($domain_uid){ + public function getDirGroups($domains_uid){ $dbh = $this->getDbh(); - $query = sprintf("select * from groups where domains_uid = $domain_uid"); + $query = sprintf("select * from groups where domains_uid = $domains_uid"); $stmt = $dbh->query($query); $results = $stmt->fetchAll(); return $results; @@ -332,12 +358,23 @@ $query = sprintf("select a.uid as groupMemberUid, a.users_uid as usersUid, b.username as usersUsername from group_members as a, users as b where a.groups_uid = $groups_uid and a.users_uid = b.uid") ; $stmt = $dbh->query($query); $results['members'] = $stmt->fetchAll(); - $query = sprintf("select uid as usersUid, username as usersUsername from users where uid not in (select users_uid from group_members where groups_uid = $groups_uid) and domain_uid = (select domains_uid from groups where uid = $groups_uid)"); + $query = sprintf("select uid as usersUid, username as usersUsername from users where uid not in (select users_uid from group_members where groups_uid = $groups_uid) and domains_uid = (select domains_uid from groups where uid = $groups_uid)"); $stmt = $dbh->query($query); $results['nonmembers'] = $stmt->fetchAll(); return $results; } + public function addDirGroup($domains_uid, $new_groupname){ + $dbh = $this->getDbh(); + $query = sprintf("insert into groups (domains_uid, name) values (%s, '%s')", $domains_uid, $new_groupname); + + if ($dbh->exec($query) > 0){ + return "INSERTED"; + } else { + return "FAILED $query"; + } + } + } /* For Emacs: * Local Variables: From rupa at freeswitch.org Mon Mar 16 08:35:10 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 10:35:10 -0500 Subject: [Freeswitch-svn] [commit] r12619 - freeswitch/trunk/src/mod/applications/mod_lcr Message-ID: Author: rupa Date: Mon Mar 16 10:35:10 2009 New Revision: 12619 Log: reduce random/rand tsts to absolute minimum stmnt required Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Mon Mar 16 10:35:10 2009 @@ -247,13 +247,13 @@ { char *sql = NULL; if (globals.odbc_dsn) { - sql = "SELECT * FROM lcr ORDER BY rand() LIMIT 1"; + sql = "SELECT rand()"; if (switch_odbc_handle_exec(globals.master_odbc, sql, NULL) == SWITCH_ODBC_SUCCESS) { db_random = "rand()"; return SWITCH_TRUE; } - sql = "SELECT * FROM lcr ORDER BY random() LIMIT 1"; + sql = "SELECT random()"; if (switch_odbc_handle_exec(globals.master_odbc, sql, NULL) == SWITCH_ODBC_SUCCESS) { db_random = "random()"; From rupa at freeswitch.org Mon Mar 16 08:54:44 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 10:54:44 -0500 Subject: [Freeswitch-svn] [commit] r12620 - freeswitch/trunk/src/mod/applications/mod_lcr Message-ID: Author: rupa Date: Mon Mar 16 10:54:44 2009 New Revision: 12620 Log: parameter to say whether to quote the in list or not Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Mon Mar 16 10:54:44 2009 @@ -114,6 +114,7 @@ switch_bool_t custom_sql_has_vars; switch_bool_t reorder_by_rate; + switch_bool_t quote_in_list; }; typedef struct profile_obj profile_t; @@ -296,7 +297,7 @@ #endif /* expand the digits */ -static char *expand_digits(switch_memory_pool_t *pool, char *digits) +static char *expand_digits(switch_memory_pool_t *pool, char *digits, switch_bool_t quote) { switch_stream_handle_t dig_stream = { 0 }; char *ret; @@ -304,13 +305,17 @@ int n; int digit_len; SWITCH_STANDARD_STREAM(dig_stream); - + digit_len = strlen(digits); digits_copy = switch_core_strdup(pool, digits); for (n = digit_len; n > 0; n--) { digits_copy[n] = '\0'; - dig_stream.write_function(&dig_stream, "%s%s", (n==digit_len ? "" : ", "), digits_copy); + dig_stream.write_function(&dig_stream, "%s%s%s%s", + (n==digit_len ? "" : ", "), + (quote ? "'" : ""), + digits_copy, + (quote ? "'" : "")); } ret = switch_core_strdup(pool, dig_stream.data); @@ -494,7 +499,6 @@ { /* instantiate the object/struct we defined earlier */ switch_stream_handle_t sql_stream = { 0 }; - size_t n, digit_len = strlen(digits); char *digits_copy; char *digits_expanded; profile_t *profile = cb_struct->profile; @@ -516,7 +520,7 @@ /* SWITCH_STANDARD_STREAM doesn't use pools. but we only have to free sql_stream.data */ SWITCH_STANDARD_STREAM(sql_stream); - digits_expanded = expand_digits(cb_struct->pool, digits_copy); + digits_expanded = expand_digits(cb_struct->pool, digits_copy, cb_struct->profile->quote_in_list); /* set some channel vars if we have a session */ if (cb_struct->session) { @@ -534,10 +538,7 @@ "SELECT l.digits, c.carrier_name, l.rate, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix " ); sql_stream.write_function(&sql_stream, "FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN ("); - for (n = digit_len; n > 0; n--) { - digits_copy[n] = '\0'; - sql_stream.write_function(&sql_stream, "%s%s", (n==digit_len ? "" : ", "), digits_copy); - } + sql_stream.write_function(&sql_stream, "%s", digits_expanded); sql_stream.write_function(&sql_stream, ") AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end "); if (profile->id > 0) { sql_stream.write_function(&sql_stream, "AND lcr_profile=%d ", profile->id); @@ -647,6 +648,7 @@ switch_stream_handle_t pre_order = { 0 }; switch_stream_handle_t *thisorder = NULL; char *reorder_by_rate = NULL; + char *quote_in_list = NULL; char *id_s = NULL; char *custom_sql = NULL; int argc, x = 0; @@ -699,6 +701,8 @@ custom_sql = val; } else if (!strcasecmp(var, "reorder_by_rate") && !switch_strlen_zero(val)) { reorder_by_rate = val; + } else if (!strcasecmp(var, "quote_in_list") && !switch_strlen_zero(val)) { + quote_in_list = val; } } @@ -740,6 +744,10 @@ profile->reorder_by_rate = switch_true(reorder_by_rate); } + if (!switch_strlen_zero(quote_in_list)) { + profile->quote_in_list = switch_true(quote_in_list); + } + switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded lcr profile %s.\n", profile->name); } @@ -1040,6 +1048,8 @@ } stream->write_function(stream, " Reorder rate:\t%s\n", profile->reorder_by_rate ? "enabled" : "disabled"); + stream->write_function(stream, " Quote IN() List:\t%s\n", + profile->quote_in_list ? "enabled" : "disabled"); stream->write_function(stream, "\n"); } } else { From rupa at freeswitch.org Mon Mar 16 09:07:11 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 11:07:11 -0500 Subject: [Freeswitch-svn] [commit] r12621 - freeswitch/trunk/conf/autoload_configs Message-ID: Author: rupa Date: Mon Mar 16 11:07:11 2009 New Revision: 12621 Log: update sample config with custom_sql example Modified: freeswitch/trunk/conf/autoload_configs/lcr.conf.xml Modified: freeswitch/trunk/conf/autoload_configs/lcr.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/lcr.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/lcr.conf.xml Mon Mar 16 11:07:11 2009 @@ -16,5 +16,45 @@ + From rupa at freeswitch.org Mon Mar 16 09:31:24 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 11:31:24 -0500 Subject: [Freeswitch-svn] [commit] r12622 - freeswitch/trunk/src/mod/applications/mod_lcr Message-ID: Author: rupa Date: Mon Mar 16 11:31:23 2009 New Revision: 12622 Log: allow profile named "default" to be the default Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Mon Mar 16 11:31:23 2009 @@ -631,14 +631,6 @@ } } - /* define default profile */ - profile = switch_core_alloc(globals.pool, sizeof(*profile)); - memset(profile, 0, sizeof(profile_t)); - profile->name = "global_default"; - profile->order_by = ", rate"; - profile->pre_order = ""; - globals.default_profile = profile; - switch_core_hash_init(&globals.profile_hash, globals.pool); if ((x_profiles = switch_xml_child(cfg, "profiles"))) { for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { @@ -750,6 +742,11 @@ switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded lcr profile %s.\n", profile->name); + + if (!strcasecmp(profile->name, "default")) { + globals.default_profile = profile; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting user defined default profile: %s.\n", profile->name); + } } switch_safe_free(order_by.data); switch_safe_free(pre_order.data); @@ -758,7 +755,18 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No lcr profiles defined.\n"); } - done: + /* define default profile */ + if (!globals.default_profile) { + profile = switch_core_alloc(globals.pool, sizeof(*profile)); + memset(profile, 0, sizeof(profile_t)); + profile->name = "global_default"; + profile->order_by = ", rate"; + profile->pre_order = ""; + globals.default_profile = profile; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting system defined default profile."); + } + + done: switch_xml_free(xml); return status; } From mrene at freeswitch.org Mon Mar 16 11:35:31 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 13:35:31 -0500 Subject: [Freeswitch-svn] [commit] r12623 - freeswitch/trunk/libs/esl/src Message-ID: Author: mrene Date: Mon Mar 16 13:35:31 2009 New Revision: 12623 Log: ESL-8 Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Mon Mar 16 13:35:31 2009 @@ -65,11 +65,11 @@ len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10; - cmd_buf = (char *) malloc(len); + cmd_buf = (char *) malloc(len + 1); assert(cmd_buf); snprintf(cmd_buf, len, "api %s %s", cmd, arg ? arg : ""); - *(cmd_buf + (len + 1)) = '\0'; + *(cmd_buf + (len)) = '\0'; if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) { @@ -94,11 +94,11 @@ len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10; - cmd_buf = (char *) malloc(len); + cmd_buf = (char *) malloc(len + 1); assert(cmd_buf); snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg ? arg : ""); - *(cmd_buf + (len + 1)) = '\0'; + *(cmd_buf + (len)) = '\0'; if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) { esl_event_t *event; From mrene at freeswitch.org Mon Mar 16 11:49:58 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 13:49:58 -0500 Subject: [Freeswitch-svn] [commit] r12624 - freeswitch/trunk/src Message-ID: Author: mrene Date: Mon Mar 16 13:49:58 2009 New Revision: 12624 Log: dont leak the xml structure if answer fails Modified: freeswitch/trunk/src/switch_ivr_play_say.c Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Mon Mar 16 13:49:58 2009 @@ -216,7 +216,8 @@ } if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_FALSE; + status = SWITCH_STATUS_FALSE; + goto done; } while (input && !done) { From mrene at freeswitch.org Mon Mar 16 12:24:12 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 14:24:12 -0500 Subject: [Freeswitch-svn] [commit] r12625 - freeswitch/trunk/src Message-ID: Author: mrene Date: Mon Mar 16 14:24:12 2009 New Revision: 12625 Log: FIx nasty leak Modified: freeswitch/trunk/src/switch_xml.c Modified: freeswitch/trunk/src/switch_xml.c ============================================================================== --- freeswitch/trunk/src/switch_xml.c (original) +++ freeswitch/trunk/src/switch_xml.c Mon Mar 16 14:24:12 2009 @@ -115,7 +115,7 @@ switch_xml_t cur; /* current xml tree insertion point */ char *m; /* original xml string */ switch_size_t len; /* length of allocated memory for mmap */ - uint8_t dynamic; + uint8_t dynamic; /* Free the original string when calling switch_xml_free */ char *u; /* UTF-8 conversion of string if original was UTF-16 */ char *s; /* start of work area */ char *e; /* end of work area */ @@ -1551,9 +1551,12 @@ if ((conf = switch_xml_find_child(xml, "section", "name", section)) && (tag = switch_xml_find_child(conf, tag_name, key_name, key_value))) { if (clone) { char *x; + switch_xml_root_t xmlroot = NULL; x = switch_xml_toxml(tag, SWITCH_FALSE); switch_assert(x); - *root = switch_xml_parse_str(x, strlen(x)); + xmlroot = (switch_xml_root_t)switch_xml_parse_str(x, strlen(x)); + xmlroot->dynamic = 1; /* free the memory in switch_xml_free */ + *root = (switch_xml_t)xmlroot; *node = *root; switch_xml_free(xml); } else { From mikej at freeswitch.org Mon Mar 16 12:53:17 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 14:53:17 -0500 Subject: [Freeswitch-svn] [commit] r12626 - freeswitch/trunk/src Message-ID: Author: mikej Date: Mon Mar 16 14:53:17 2009 New Revision: 12626 Log: fix windows build Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Mon Mar 16 14:53:17 2009 @@ -1303,10 +1303,10 @@ for (i = 0; i < and_argc; i++) { char *vdata; - end = NULL; - chan_type = peer_names[i]; const char *current_variable; char variable_buffer[512] = ""; + end = NULL; + chan_type = peer_names[i]; while (chan_type && *chan_type && *chan_type == ' ') { chan_type++; From mikej at freeswitch.org Mon Mar 16 13:14:36 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 15:14:36 -0500 Subject: [Freeswitch-svn] [commit] r12627 - freeswitch/trunk/src Message-ID: Author: mikej Date: Mon Mar 16 15:14:36 2009 New Revision: 12627 Log: these seem to be causing issues on solaris Modified: freeswitch/trunk/src/switch.c Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Mon Mar 16 15:14:36 2009 @@ -610,7 +610,7 @@ #endif } -#ifdef HAVE_SETRLIMIT +#if defined(HAVE_SETRLIMIT) && !defined(__sun) if (!waste) { memset(&rlp, 0, sizeof(rlp)); getrlimit(RLIMIT_STACK, &rlp); From mrene at freeswitch.org Mon Mar 16 13:28:23 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 15:28:23 -0500 Subject: [Freeswitch-svn] [commit] r12628 - in freeswitch/trunk/src: . mod/applications/mod_conference mod/codecs/mod_g729 mod/endpoints/mod_reference mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Mon Mar 16 15:28:22 2009 New Revision: 12628 Log: Fix off-by-1 read err in switch_xml Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c freeswitch/trunk/src/mod/codecs/mod_g729/Makefile freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_xml.c Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Mar 16 15:28:22 2009 @@ -2922,7 +2922,7 @@ { switch_event_t *event; - if (member == NULL) + if (member == NULL || switch_test_flag(member, MFLAG_NOCHANNEL)) return SWITCH_STATUS_GENERR; switch_mutex_lock(member->control_mutex); Modified: freeswitch/trunk/src/mod/codecs/mod_g729/Makefile ============================================================================== --- freeswitch/trunk/src/mod/codecs/mod_g729/Makefile (original) +++ freeswitch/trunk/src/mod/codecs/mod_g729/Makefile Mon Mar 16 15:28:22 2009 @@ -1,7 +1,7 @@ BASE=../../../.. -DIR=$(BASE)/libs/libg729 -A=$(DIR)/.libs/libg729.a +DIR=./g729abc +A=$(DIR)/libg729ab.a -LOCAL_INSERT_CFLAGS=if test -f $(A); then echo "-I$(DIR)/src/include" ; else echo "-DG729_PASSTHROUGH" ; fi ; +LOCAL_INSERT_CFLAGS=if test -f $(A); then echo "-I$(DIR)" ; else echo "-DG729_PASSTHROUGH" ; fi ; LOCAL_INSERT_LDFLAGS=test ! -f $(A) || echo $(A) include $(BASE)/build/modmake.rules Modified: freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c ============================================================================== --- freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c (original) +++ freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c Mon Mar 16 15:28:22 2009 @@ -38,7 +38,7 @@ SWITCH_MODULE_DEFINITION(mod_g729, mod_g729_load, NULL, NULL); #ifndef G729_PASSTHROUGH -#include "g729.h" +#include "g729ab.h" struct g729_context { struct dec_state decoder_object; @@ -112,7 +112,7 @@ if (decoded_data_len % 160 == 0) { uint32_t new_len = 0; INT16 *ddp = decoded_data; - char *edp = encoded_data; + unsigned char *edp = encoded_data; int x; int loops = (int) decoded_data_len / 160; @@ -170,7 +170,7 @@ if (encoded_data_len % divisor == 0) { uint8_t *test; int loops = (int) encoded_data_len / divisor; - char *edp = encoded_data; + unsigned char *edp = encoded_data; short *ddp = decoded_data; int x; uint32_t new_len = 0; Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c Mon Mar 16 15:28:22 2009 @@ -272,8 +272,6 @@ { switch_channel_t *channel = NULL; private_t *tech_pvt = NULL; - switch_time_t started = switch_time_now(); - unsigned int elapsed; switch_byte_t *data; channel = switch_core_session_get_channel(session); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Mar 16 15:28:22 2009 @@ -2691,7 +2691,7 @@ } } - if (channel && sip && (status >= 300 || status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { + if (channel && sip && (status >= 300 && status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { sip_contact_t * p_contact = sip->sip_contact; int i = 0; char var_name[80]; Modified: freeswitch/trunk/src/switch_xml.c ============================================================================== --- freeswitch/trunk/src/switch_xml.c (original) +++ freeswitch/trunk/src/switch_xml.c Mon Mar 16 15:28:22 2009 @@ -2035,7 +2035,7 @@ *s = tmp; } - if (*(*s + (*len) - 1) == '>') { + if (*len && *(*s + (*len) - 1) == '>') { *len += sprintf(*s + *len, "\n"); /* indent */ } for (lcount = 0; lcount < *count; lcount++) { From mrene at freeswitch.org Mon Mar 16 13:30:53 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 15:30:53 -0500 Subject: [Freeswitch-svn] [commit] r12629 - in freeswitch/trunk/src/mod: applications/mod_conference codecs/mod_g729 endpoints/mod_reference endpoints/mod_sofia Message-ID: Author: mrene Date: Mon Mar 16 15:30:53 2009 New Revision: 12629 Log: Revert unwanted changes Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c freeswitch/trunk/src/mod/codecs/mod_g729/Makefile freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Mar 16 15:30:53 2009 @@ -2922,7 +2922,7 @@ { switch_event_t *event; - if (member == NULL || switch_test_flag(member, MFLAG_NOCHANNEL)) + if (member == NULL) return SWITCH_STATUS_GENERR; switch_mutex_lock(member->control_mutex); Modified: freeswitch/trunk/src/mod/codecs/mod_g729/Makefile ============================================================================== --- freeswitch/trunk/src/mod/codecs/mod_g729/Makefile (original) +++ freeswitch/trunk/src/mod/codecs/mod_g729/Makefile Mon Mar 16 15:30:53 2009 @@ -1,7 +1,7 @@ BASE=../../../.. -DIR=./g729abc -A=$(DIR)/libg729ab.a +DIR=$(BASE)/libs/libg729 +A=$(DIR)/.libs/libg729.a -LOCAL_INSERT_CFLAGS=if test -f $(A); then echo "-I$(DIR)" ; else echo "-DG729_PASSTHROUGH" ; fi ; +LOCAL_INSERT_CFLAGS=if test -f $(A); then echo "-I$(DIR)/src/include" ; else echo "-DG729_PASSTHROUGH" ; fi ; LOCAL_INSERT_LDFLAGS=test ! -f $(A) || echo $(A) include $(BASE)/build/modmake.rules Modified: freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c ============================================================================== --- freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c (original) +++ freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c Mon Mar 16 15:30:53 2009 @@ -38,7 +38,7 @@ SWITCH_MODULE_DEFINITION(mod_g729, mod_g729_load, NULL, NULL); #ifndef G729_PASSTHROUGH -#include "g729ab.h" +#include "g729.h" struct g729_context { struct dec_state decoder_object; @@ -112,7 +112,7 @@ if (decoded_data_len % 160 == 0) { uint32_t new_len = 0; INT16 *ddp = decoded_data; - unsigned char *edp = encoded_data; + char *edp = encoded_data; int x; int loops = (int) decoded_data_len / 160; @@ -170,7 +170,7 @@ if (encoded_data_len % divisor == 0) { uint8_t *test; int loops = (int) encoded_data_len / divisor; - unsigned char *edp = encoded_data; + char *edp = encoded_data; short *ddp = decoded_data; int x; uint32_t new_len = 0; Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c Mon Mar 16 15:30:53 2009 @@ -272,6 +272,8 @@ { switch_channel_t *channel = NULL; private_t *tech_pvt = NULL; + switch_time_t started = switch_time_now(); + unsigned int elapsed; switch_byte_t *data; channel = switch_core_session_get_channel(session); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Mar 16 15:30:53 2009 @@ -2691,7 +2691,7 @@ } } - if (channel && sip && (status >= 300 && status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { + if (channel && sip && (status >= 300 || status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { sip_contact_t * p_contact = sip->sip_contact; int i = 0; char var_name[80]; From andrew at freeswitch.org Mon Mar 16 15:14:31 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 17:14:31 -0500 Subject: [Freeswitch-svn] [commit] r12630 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 16 17:14:31 2009 New Revision: 12630 Log: Improved the 'erlang' console application; added the UUID to some debug messages Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 16 17:14:31 2009 @@ -152,7 +152,7 @@ for (s = listener->session_list; s; s = s->next) { /* check the event uuid against the uuid of each session */ if (!strcmp(uuid, switch_core_session_get_uuid(s->session))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending event to attached session\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending event to attached session for %s\n", switch_core_session_get_uuid(s->session)); if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) { /* add the event to the queue for this session */ if (switch_queue_trypush(s->event_queue, clone) != SWITCH_STATUS_SUCCESS) { @@ -525,7 +525,7 @@ /* event is a hangup, so this session can be removed */ if (pevent->event_id == SWITCH_EVENT_CHANNEL_HANGUP) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup event for attached session\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup event for attached session for %s\n", switch_core_session_get_uuid(sp->session)); /* remove session from list */ if (last) @@ -1269,7 +1269,11 @@ char *mycmd = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; - const char *usage_string = "Supply some arguments, maybe?"; + const char *usage_string = "USAGE:\n" + "--------------------------------------------------------------------------------\n" + "erlang listeners\n" + "erlang sessions \n" + "--------------------------------------------------------------------------------\n"; if (switch_strlen_zero(cmd)) { stream->write_function(stream, "%s", usage_string); @@ -1292,11 +1296,43 @@ listener_t *l; switch_mutex_lock(globals.listener_mutex); - for (l = listen_list.listeners; l; l = l->next) { - stream->write_function(stream, "Listener to %s with %d outbound sessions\n", l->peer_nodename, count_listener_sessions(l)); + if (listen_list.listeners) { + for (l = listen_list.listeners; l; l = l->next) { + stream->write_function(stream, "Listener to %s with %d outbound sessions\n", l->peer_nodename, count_listener_sessions(l)); + } + } else { + stream->write_function(stream, "No active listeners\n"); } switch_mutex_unlock(globals.listener_mutex); + } else if (!strcasecmp(argv[0], "sessions") && argc == 2) { + listener_t *l; + int found = 0; + + switch_mutex_lock(globals.listener_mutex); + for (l = listen_list.listeners; l; l = l->next) { + if (!strcasecmp(l->peer_nodename, argv[1])) { + session_elem_t *sp; + + found = 1; + switch_mutex_lock(l->session_mutex); + if ((sp = l->session_list)) { + while(sp) { + stream->write_function(stream, "Outbound session for %s\n", switch_core_session_get_uuid(sp->session)); + sp = sp->next; + } + switch_mutex_unlock(l->session_mutex); + } else { + stream->write_function(stream, "No active sessions for %s\n", argv[1]); + } + break; + } + } + switch_mutex_unlock(globals.listener_mutex); + + if (!found) + stream->write_function(stream, "Could not find a listener for %s\n", argv[1]); + } else { stream->write_function(stream, "I don't care for those arguments at all, sorry"); goto done; From mrene at freeswitch.org Mon Mar 16 15:25:05 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 17:25:05 -0500 Subject: [Freeswitch-svn] [commit] r12631 - freeswitch/trunk/src/mod/languages/mod_spidermonkey Message-ID: Author: mrene Date: Mon Mar 16 17:25:05 2009 New Revision: 12631 Log: Properly shutdown the JS runtime on unload Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Mon Mar 16 17:25:05 2009 @@ -3746,6 +3746,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown) { + JS_DestroyRuntime(globals.rt); + curl_global_cleanup(); switch_event_unbind(&globals.node); switch_core_hash_destroy(&module_manager.mod_hash); From mrene at freeswitch.org Mon Mar 16 15:44:14 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 17:44:14 -0500 Subject: [Freeswitch-svn] [commit] r12632 - freeswitch/trunk/src/mod/applications/mod_limit Message-ID: Author: mrene Date: Mon Mar 16 17:44:14 2009 New Revision: 12632 Log: mod_limit: close odbc handle Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original) +++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Mon Mar 16 17:44:14 2009 @@ -1106,6 +1106,13 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_limit_shutdown) { + + #ifdef SWITCH_HAVE_ODBC + if (globals.master_odbc) { + switch_odbc_handle_destroy(&globals.master_odbc); + } + #endif + switch_event_free_subclass(LIMIT_EVENT_USAGE); switch_xml_config_cleanup(config_settings); From mrene at freeswitch.org Mon Mar 16 15:44:27 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 17:44:27 -0500 Subject: [Freeswitch-svn] [commit] r12633 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Mon Mar 16 17:44:27 2009 New Revision: 12633 Log: tweak Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Mon Mar 16 17:44:27 2009 @@ -3332,14 +3332,13 @@ void sofia_glue_sql_close(sofia_profile_t *profile) { #ifdef SWITCH_HAVE_ODBC - if (profile->odbc_dsn) { + if (profile->master_odbc) { switch_odbc_handle_destroy(&profile->master_odbc); - return; } -#endif - +#else switch_core_db_close(profile->master_db); profile->master_db = NULL; +#endif } From andrew at freeswitch.org Mon Mar 16 15:58:36 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 17:58:36 -0500 Subject: [Freeswitch-svn] [commit] r12634 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 16 17:58:36 2009 New Revision: 12634 Log: Fix removing sessions from linked list; fix a deadlock added in previous commit Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 16 17:58:36 2009 @@ -487,6 +487,7 @@ session_elem_t *last,*sp; switch_status_t status = SWITCH_STATUS_SUCCESS; void *pop; + int removed = 0; /* check up on all the attached sessions - if they have not yet sent an initial call event to the associated erlang process then do so if they have pending events in their queues then send them @@ -496,6 +497,7 @@ sp = listener->session_list; last = NULL; while(sp) { + removed = 0; if (switch_test_flag(sp, LFLAG_WAITING_FOR_PID)) { break; } @@ -538,6 +540,7 @@ /* this allows the application threads to exit */ switch_clear_flag_locked(sp, LFLAG_SESSION_ALIVE); switch_core_session_rwunlock(sp->session); + removed = 1; /* TODO if this listener was created outbound, and the last session has been detached @@ -548,7 +551,8 @@ ei_x_free(&ebuf); switch_event_destroy(&pevent); } - last = sp; + if (!removed) + last = sp; sp = sp->next; } switch_mutex_unlock(listener->session_mutex); @@ -1321,10 +1325,10 @@ stream->write_function(stream, "Outbound session for %s\n", switch_core_session_get_uuid(sp->session)); sp = sp->next; } - switch_mutex_unlock(l->session_mutex); } else { stream->write_function(stream, "No active sessions for %s\n", argv[1]); } + switch_mutex_unlock(l->session_mutex); break; } } From andrew at freeswitch.org Mon Mar 16 16:31:55 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 18:31:55 -0500 Subject: [Freeswitch-svn] [commit] r12635 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 16 18:31:55 2009 New Revision: 12635 Log: Send a "call_hangup" to outbound/handlecall sessions when the relevant channel is hungup Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 16 18:31:55 2009 @@ -516,7 +516,7 @@ to distinguish them from normal events (if they are sent to the same process) */ ei_x_buff ebuf; - ei_x_new_with_version(&ebuf); + ei_x_new_with_version(&ebuf); ei_x_encode_tuple_header(&ebuf, 2); ei_x_encode_atom(&ebuf, "call_event"); ei_encode_switch_event(&ebuf, pevent); @@ -524,6 +524,7 @@ switch_mutex_lock(listener->sock_mutex); ei_sendto(listener->ec, listener->sockfd, &sp->process, &ebuf); switch_mutex_unlock(listener->sock_mutex); + ei_x_free(&ebuf); /* event is a hangup, so this session can be removed */ if (pevent->event_id == SWITCH_EVENT_CHANNEL_HANGUP) { @@ -534,7 +535,6 @@ last->next = sp->next; else listener->session_list = sp->next; - switch_channel_clear_flag(switch_core_session_get_channel(sp->session), CF_CONTROLLED); /* this allows the application threads to exit */ @@ -542,13 +542,18 @@ switch_core_session_rwunlock(sp->session); removed = 1; + ei_x_new_with_version(&ebuf); + ei_x_encode_atom(&ebuf, "call_hangup"); + switch_mutex_lock(listener->sock_mutex); + ei_sendto(listener->ec, listener->sockfd, &sp->process, &ebuf); + switch_mutex_unlock(listener->sock_mutex); + ei_x_free(&ebuf); + /* TODO if this listener was created outbound, and the last session has been detached should the listener also exit? Does it matter? */ } - - ei_x_free(&ebuf); switch_event_destroy(&pevent); } if (!removed) From mrene at freeswitch.org Mon Mar 16 16:52:28 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 18:52:28 -0500 Subject: [Freeswitch-svn] [commit] r12636 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mrene Date: Mon Mar 16 18:52:28 2009 New Revision: 12636 Log: tweak Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Mar 16 18:52:28 2009 @@ -2691,7 +2691,7 @@ } } - if (channel && sip && (status >= 300 || status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { + if (channel && sip && (status >= 300 && status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { sip_contact_t * p_contact = sip->sip_contact; int i = 0; char var_name[80]; From andrew at freeswitch.org Mon Mar 16 17:05:17 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 19:05:17 -0500 Subject: [Freeswitch-svn] [commit] r12637 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 16 19:05:17 2009 New Revision: 12637 Log: Don't hold a pointer to the session, store the uuid instead and use switch_core_session_locate/switch_core_session_rwunlock Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 16 19:05:17 2009 @@ -151,8 +151,8 @@ switch_mutex_lock(listener->session_mutex); for (s = listener->session_list; s; s = s->next) { /* check the event uuid against the uuid of each session */ - if (!strcmp(uuid, switch_core_session_get_uuid(s->session))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending event to attached session for %s\n", switch_core_session_get_uuid(s->session)); + if (!strcmp(uuid, s->uuid_str)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending event to attached session for %s\n", s->uuid_str); if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) { /* add the event to the queue for this session */ if (switch_queue_trypush(s->event_queue, clone) != SWITCH_STATUS_SUCCESS) { @@ -303,26 +303,32 @@ switch_mutex_unlock(listener->session_mutex); } -static void remove_session_elem_from_listener(listener_t *listener, session_elem_t *session) +static void remove_session_elem_from_listener(listener_t *listener, session_elem_t *session_element) { session_elem_t *s, *last = NULL; + switch_core_session_t *session; - if (!session) + if (!session_element) + return; + return; switch_mutex_lock(listener->session_mutex); for(s = listener->session_list; s; s = s->next) { - if (s == session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removing session\n"); + if (s == session_element) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removing session element\n"); if (last) { last->next = s->next; } else { listener->session_list = s->next; } - switch_channel_clear_flag(switch_core_session_get_channel(s->session), CF_CONTROLLED); - /* this allows the application threads to exit */ - switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); - switch_core_session_rwunlock(s->session); + if (!(session = switch_core_session_locate(session_element->uuid_str))) { + switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); + /* this allows the application threads to exit */ + switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); + switch_core_session_rwunlock(session); + } + break; } last = s; } @@ -444,16 +450,21 @@ } -static switch_status_t notify_new_session(listener_t *listener, switch_core_session_t *session, struct erlang_process process) +static switch_status_t notify_new_session(listener_t *listener, session_elem_t *session_element) { int result; + switch_core_session_t *session; switch_event_t *call_event=NULL; switch_channel_t *channel=NULL; /* Send a message to the associated registered process to let it know there is a call. Message is a tuple of the form {call, } */ + if (!(session = switch_core_session_locate(session_element->uuid_str))) + return SWITCH_STATUS_FALSE; + channel = switch_core_session_get_channel(session); + switch_core_session_rwunlock(session); if (switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); return SWITCH_STATUS_MEMERR; @@ -470,7 +481,7 @@ ei_encode_switch_event(&lbuf, call_event); switch_mutex_lock(listener->sock_mutex); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending initial call event\n"); - result = ei_sendto(listener->ec, listener->sockfd, &process, &lbuf); + result = ei_sendto(listener->ec, listener->sockfd, &session_element->process, &lbuf); switch_mutex_unlock(listener->sock_mutex); @@ -503,7 +514,7 @@ } if (!switch_test_flag(sp, LFLAG_OUTBOUND_INIT)) { - status = notify_new_session(listener, sp->session, sp->process); + status = notify_new_session(listener, sp); if (status != SWITCH_STATUS_SUCCESS) break; switch_set_flag(sp, LFLAG_OUTBOUND_INIT); @@ -516,6 +527,7 @@ to distinguish them from normal events (if they are sent to the same process) */ ei_x_buff ebuf; + ei_x_new_with_version(&ebuf); ei_x_encode_tuple_header(&ebuf, 2); ei_x_encode_atom(&ebuf, "call_event"); @@ -528,7 +540,9 @@ /* event is a hangup, so this session can be removed */ if (pevent->event_id == SWITCH_EVENT_CHANNEL_HANGUP) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup event for attached session for %s\n", switch_core_session_get_uuid(sp->session)); + switch_core_session_t *session; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup event for attached session for %s\n", sp->uuid_str); /* remove session from list */ if (last) @@ -536,10 +550,12 @@ else listener->session_list = sp->next; - switch_channel_clear_flag(switch_core_session_get_channel(sp->session), CF_CONTROLLED); - /* this allows the application threads to exit */ - switch_clear_flag_locked(sp, LFLAG_SESSION_ALIVE); - switch_core_session_rwunlock(sp->session); + if ((session = switch_core_session_locate(sp->uuid_str))) { + switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); + /* this allows the application threads to exit */ + switch_clear_flag_locked(sp, LFLAG_SESSION_ALIVE); + switch_core_session_rwunlock(session); + } removed = 1; ei_x_new_with_version(&ebuf); @@ -650,7 +666,7 @@ remove_binding(NULL, pid); /* TODO - why don't we pass the listener as the first argument? */ if ((s = find_session_elem_by_pid(listener, pid))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Outbound session for %s exited unexpectedly!\n", - switch_core_session_get_uuid(s->session)); + s->uuid_str); /* TODO - if a spawned process that was handling an outbound call fails.. what do we do with the call? */ remove_session_elem_from_listener(listener, s); } @@ -821,6 +837,7 @@ { listener_t *listener = (listener_t *) obj; session_elem_t* s; + switch_core_session_t *session; switch_mutex_lock(globals.listener_mutex); prefs.threads++; @@ -863,11 +880,12 @@ /* clean up all the attached sessions */ switch_mutex_lock(listener->session_mutex); for (s = listener->session_list; s; s = s->next) { - switch_channel_clear_flag(switch_core_session_get_channel(s->session), CF_CONTROLLED); - /* this allows the application threads to exit */ - switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); - /* */ - switch_core_session_rwunlock(s->session); + if ((session = switch_core_session_locate(s->uuid_str))) { + switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); + /* this allows the application threads to exit */ + switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); + switch_core_session_rwunlock(session); + } } switch_mutex_unlock(listener->session_mutex); @@ -1030,7 +1048,6 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get session read lock\n"); } else { - session_element->session = session; session_element->process.type = ERLANG_REG_PROCESS; session_element->process.reg_name = switch_core_strdup(switch_core_session_get_pool(session),reg_name); switch_set_flag(session_element, LFLAG_SESSION_ALIVE); @@ -1056,7 +1073,7 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get session read lock\n"); } else { - session_element->session = session; + memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); session_element->process.type = ERLANG_PID; memcpy(&session_element->process.pid, pid, sizeof(erlang_pid)); switch_set_flag(session_element, LFLAG_SESSION_ALIVE); @@ -1078,8 +1095,7 @@ session_elem_t* session_element=NULL; if (!(session_element = switch_core_alloc(switch_core_session_get_pool(session), sizeof(*session_element)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate session element\n"); - } - else { + } else { if (SWITCH_STATUS_SUCCESS != switch_core_session_read_lock(session)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get session read lock\n"); } @@ -1087,7 +1103,8 @@ char hash[100]; int i = 0; void *p = NULL; - session_element->session = session; + + memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); erlang_pid *pid; erlang_ref ref; @@ -1131,7 +1148,7 @@ while (!(p = switch_core_hash_find(listener->spawn_pid_hash, hash)) || p == &globals.WAITING) { if (i > 50) { /* half a second timeout */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid\n"); - switch_core_session_rwunlock(session); + /*switch_core_session_rwunlock(session);*/ remove_session_elem_from_listener(listener,session_element); switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.TIMEOUT); /* TODO lock this? */ return NULL; @@ -1152,8 +1169,7 @@ switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); switch_clear_flag(session_element, LFLAG_WAITING_FOR_PID); - /* this hangs because it can never get hold of the socket mutex */ - ei_link(listener, ei_self(listener->ec), pid); + ei_link(listener, ei_self(listener->ec), pid); } } return session_element; @@ -1327,7 +1343,7 @@ switch_mutex_lock(l->session_mutex); if ((sp = l->session_list)) { while(sp) { - stream->write_function(stream, "Outbound session for %s\n", switch_core_session_get_uuid(sp->session)); + stream->write_function(stream, "Outbound session for %s\n", sp->uuid_str); sp = sp->next; } } else { Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h Mon Mar 16 19:05:17 2009 @@ -55,7 +55,7 @@ }; struct session_elem { - switch_core_session_t *session; + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; switch_mutex_t *flag_mutex; uint32_t flags; struct erlang_process process; From andrew at freeswitch.org Mon Mar 16 19:35:06 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Mar 2009 21:35:06 -0500 Subject: [Freeswitch-svn] [commit] r12638 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 16 21:35:06 2009 New Revision: 12638 Log: Cleanups/fixes while tracking down stuck channels Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c Mon Mar 16 21:35:06 2009 @@ -490,7 +490,7 @@ } } - /* release the lock returned by switch_core_session_locate */ + /* release the lock returned by session locate */ switch_core_session_rwunlock(session); } else { @@ -579,7 +579,7 @@ ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "session_attach_failed"); } - /* release the lock returned by switch_core_session_locate */ + /* release the lock returned by session locate */ switch_core_session_rwunlock(session); } else { ei_x_encode_tuple_header(rbuf, 2); Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 16 21:35:06 2009 @@ -311,8 +311,6 @@ if (!session_element) return; - return; - switch_mutex_lock(listener->session_mutex); for(s = listener->session_list; s; s = s->next) { if (s == session_element) { @@ -322,12 +320,12 @@ } else { listener->session_list = s->next; } - if (!(session = switch_core_session_locate(session_element->uuid_str))) { + if ((session = switch_core_session_locate(session_element->uuid_str))) { switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); - /* this allows the application threads to exit */ - switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); switch_core_session_rwunlock(session); } + /* this allows the application threads to exit */ + switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); break; } last = s; @@ -460,17 +458,20 @@ /* Send a message to the associated registered process to let it know there is a call. Message is a tuple of the form {call, } */ - if (!(session = switch_core_session_locate(session_element->uuid_str))) - return SWITCH_STATUS_FALSE; - - channel = switch_core_session_get_channel(session); - switch_core_session_rwunlock(session); + if (switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); return SWITCH_STATUS_MEMERR; } + + if (!(session = switch_core_session_locate(session_element->uuid_str))) + return SWITCH_STATUS_FALSE; + + channel = switch_core_session_get_channel(session); + switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event); switch_channel_event_set_data(channel, call_event); + switch_core_session_rwunlock(session); switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply"); switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Reply-Text", "+OK\n"); @@ -538,11 +539,11 @@ switch_mutex_unlock(listener->sock_mutex); ei_x_free(&ebuf); - /* event is a hangup, so this session can be removed */ - if (pevent->event_id == SWITCH_EVENT_CHANNEL_HANGUP) { + /* event is a channel destroy, so this session can be removed */ + if (pevent->event_id == SWITCH_EVENT_CHANNEL_DESTROY) { switch_core_session_t *session; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup event for attached session for %s\n", sp->uuid_str); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy event for attached session for %s\n", sp->uuid_str); /* remove session from list */ if (last) @@ -552,10 +553,10 @@ if ((session = switch_core_session_locate(sp->uuid_str))) { switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); - /* this allows the application threads to exit */ - switch_clear_flag_locked(sp, LFLAG_SESSION_ALIVE); switch_core_session_rwunlock(session); } + /* this allows the application threads to exit */ + switch_clear_flag_locked(sp, LFLAG_SESSION_ALIVE); removed = 1; ei_x_new_with_version(&ebuf); @@ -882,10 +883,10 @@ for (s = listener->session_list; s; s = s->next) { if ((session = switch_core_session_locate(s->uuid_str))) { switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); - /* this allows the application threads to exit */ - switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); switch_core_session_rwunlock(session); } + /* this allows the application threads to exit */ + switch_clear_flag_locked(s, LFLAG_SESSION_ALIVE); } switch_mutex_unlock(listener->session_mutex); @@ -1148,7 +1149,6 @@ while (!(p = switch_core_hash_find(listener->spawn_pid_hash, hash)) || p == &globals.WAITING) { if (i > 50) { /* half a second timeout */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid\n"); - /*switch_core_session_rwunlock(session);*/ remove_session_elem_from_listener(listener,session_element); switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.TIMEOUT); /* TODO lock this? */ return NULL; From silik0n at freeswitch.org Tue Mar 17 04:13:30 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 06:13:30 -0500 Subject: [Freeswitch-svn] [commit] r12639 - in freeswitch/trunk/scripts/contrib/swk: flex/amf-test1/bin-debug flex/amf-test1/bin-debug/assets flex/amf-test1/bin-debug/assets/icons flex/amf-test1/bin-debug/assets/images flex/amf-test1/bin-debug/assets/xml flex/amf-test1/bin-debug/images flex/amf-test1/bin-debug/map flex/amf-test1/src php/amfphp Message-ID: Author: silik0n Date: Tue Mar 17 06:13:30 2009 New Revision: 12639 Log: Ok Have at it boys... the UI is working, you can add/delete/modify Domains and Users, groups still needs work, and we need a script to feed that Data into something that xml_curl can handle as well as example configs... this is coming soon Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/ai.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/air.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/fl.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/fw.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/fx.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/ps.jpg (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/images/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/images/tab.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/images/tab_selected.png (contents, props changed) freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/xml/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/xml/listData.xml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/images/ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/map/ Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/ai.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/air.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/fl.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/fw.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/fx.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/icons/ps.jpg ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/images/tab.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/images/tab_selected.png ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/xml/listData.xml ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/assets/xml/listData.xml Tue Mar 17 06:13:30 2009 @@ -0,0 +1,21 @@ + + + + assets/icons/fx.jpg + + + assets/icons/ai.jpg + + + assets/icons/ps.jpg + + + assets/icons/fw.jpg + + + assets/icons/fl.jpg + + + assets/icons/air.jpg + + \ No newline at end of file Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf ============================================================================== Binary files. No diff available. Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Tue Mar 17 06:13:30 2009 @@ -10,6 +10,7 @@ import mx.controls.dataGridClasses.DataGridColumn; import mx.events.DataGridEvent; + import mx.events.ListEvent; import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; @@ -88,34 +89,56 @@ freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); } - public function dgChangeDomainParam():void { - freeswitch.updateDirDomainParam(dgDomainParam.selectedItem.uid, dgDomainParam.selectedItem.name, dgDomainParam.value); + public function dgChangeDomainParam(event:DataGridEvent):void { + freeswitch.updateDirDomainParam(dgDomainParam.selectedItem.uid, dgDomainParam.selectedItem.name, TextInput(event.currentTarget.itemEditorInstance).text); freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); } - public function dgChangeDomainVars():void { - freeswitch.updateDirDomainVar(dgDomainVars.selectedItem.uid, dgDomainVars.selectedItem.name, dgDomainVars.value); + public function dgChangeDomainVars(event:DataGridEvent):void { + freeswitch.updateDirDomainVar(dgDomainVars.selectedItem.uid, dgDomainVars.selectedItem.name, TextInput(event.currentTarget.itemEditorInstance).text); freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); } - public function addDomainUserParam():void { - freeswitch.addDirDomainUserParam(gridDomainsDomain.selectedItem.uid, inputDomainUserParamName.text, inputDomainUserParamValue.text); + public function dgDeleteDomainParam():void { + freeswitch.deleteDirDomainParam(dgDomainParam.selectedItem.uid); freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); } - public function addDomainUserVar():void { - freeswitch.addDirDomainUserVar(gridDomainsDomain.selectedItem.uid, inputDomainUserVarName.text, inputDomainUserVarValue.text); + public function dgDeleteDomainVars():void { + freeswitch.deleteDirDomainVar(dgDomainVars.selectedItem.uid); freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); } - public function dgChangeDomainUserParam():void { - freeswitch.updateDirDomainUserParam(dgDomainParam.selectedItem.uid, dgDomainParam.selectedItem.name, dgDomainParam.value); - freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + public function addDomainUserParam():void { + freeswitch.addDirDomainUserParam(dgDomainUsers.selectedItem.uid, inputDomainUserParamName.text, inputDomainUserParamValue.text); + freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); } - public function dgChangeDomainUserVars():void { - freeswitch.updateDirDomainUserParam(dgDomainVars.selectedItem.uid, dgDomainVars.selectedItem.name, dgDomainVars.value); - freeswitch.getDirDomain(gridDomainsDomain.selectedItem.uid); + public function addDomainUserVar():void { + freeswitch.addDirDomainUserVar(dgDomainUsers.selectedItem.uid, inputDomainUserVarName.text, inputDomainUserVarValue.text); + freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); + } + + public function dgChangeDomainUserParam(event:DataGridEvent):void { + freeswitch.updateDirDomainUserParam(dgDomainUsers.selectedItem.uid, dgDomainParam.selectedItem.name, TextInput(event.currentTarget.itemEditorInstance).text); + freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); + } + + public function dgChangeDomainUserVars(event:DataGridEvent):void { + var _rowIndex:Number=event.rowIndex; + var _columnIndex:Number= event.columnIndex; + freeswitch.updateDirDomainUserParam(dgDomainUserVars.selectedItem.uid, dgDomainUserVars.selectedItem.name, TextInput(event.currentTarget.itemEditorInstance).text); + freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); + } + + public function dgDeleteDomainUserParam():void { + freeswitch.deleteDirDomainUserParam(dgDomainUserParam.selectedItem.uid); + freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); + } + + public function dgdeleteDomainUserVars():void { + freeswitch.deleteDirDomainUserVar(dgDomainUserVars.selectedItem.uid); + freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); } public function doGroupAdd():void { @@ -227,7 +250,7 @@ - + @@ -244,45 +267,46 @@ - - - - - - + + + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + @@ -299,16 +323,16 @@ - + + itemEditEnd="dgChangeDomainUserParam(event);" editable="true" id="dgDomainUserParam"> + itemEditEnd="dgChangeDomainUserVars(event);" editable="true" id="dgDomainUserVars"> @@ -316,7 +340,7 @@ - + @@ -326,11 +350,11 @@ - + - + @@ -344,22 +368,26 @@ - - - - - - + + + + + + + + Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newGroupForm.mxml Tue Mar 17 06:13:30 2009 @@ -1,5 +1,5 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/newUserForm.mxml Tue Mar 17 06:13:30 2009 @@ -1,5 +1,5 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Tue Mar 17 06:13:30 2009 @@ -89,11 +89,15 @@ } } $i++; - if ($i == $total_count - 4){ + if ($i == $total_count - 3){ break; } } - return $data; + if ($none != 1) { + return $data; + } else { + return "OK: No Calls"; + } } public function getCalls() { @@ -289,13 +293,25 @@ public function updateDirDomainParam($param_uid, $name, $value) { $dbh = $this->getDbh(); - $query = sprintf('update domain_params set name = "%s", value = "%s" where uid=%s', $param_uid, $name, $value); + $query = sprintf('update domain_params set name = "%s", value = "%s" where uid=%s', $name, $value, $param_uid); return $dbh->exec($query); } public function updateDirDomainVar($var_uid, $name, $value) { $dbh = $this->getDbh(); - $query = sprintf('update domain_variables set name = "%s", value = "%s" where uid=%s', $var_uid, $name, $value); + $query = sprintf('update domain_variables set name = "%s", value = "%s" where uid=%s', $name, $value, $var_uid); + return $dbh->exec($query); + } + + public function deleteDirDomainParam($param_uid) { + $dbh = $this->getDbh(); + $query = sprintf('delete from domain_params where uid=%s', $param_uid); + return $dbh->exec($query); + } + + public function deleteDirDomainVar($var_uid) { + $dbh = $this->getDbh(); + $query = sprintf('delete from domain_variables where uid=%s', $var_uid); return $dbh->exec($query); } @@ -334,16 +350,36 @@ public function updateDirDomainUserParam($param_uid, $name, $value) { $dbh = $this->getDbh(); - $query = sprintf('update user_params set name = "%s", value = "%s" where uid=%s', $param_uid, $name, $value); + $query = sprintf('update user_params set name = "%s", value = "%s" where uid=%s', $name, $value, $param_uid); return $dbh->exec($query); } public function updateDirDomainUserVar($var_uid, $name, $value) { $dbh = $this->getDbh(); - $query = sprintf('update user_variables set name = "%s", value = "%s" where uid=%s', $var_uid, $name, $value); + $query = sprintf('update user_variables set name = "%s", value = "%s" where uid=%s', $name, $value, $var_uid); return $dbh->exec($query); } + public function deleteDirDomainUserParam($param_uid) { + $dbh = $this->getDbh(); + $query = sprintf('delete from user_params where uid=%s', $param_uid); + if ($dbh->exec($query) < 1) { + return "FAILED " . $query; + } else { + return "SUCESS"; + } + } + + public function deleteDirDomainUserVar($var_uid) { + $dbh = $this->getDbh(); + $query = sprintf('delete from user_variables where uid=%s', $var_uid); + if ($dbh->exec($query) < 1) { + return "FAILED " . $query; + } else { + return "SUCESS"; + } + } + /* Directory Group Methods */ public function getDirGroups($domains_uid){ $dbh = $this->getDbh(); From mrene at freeswitch.org Tue Mar 17 06:25:02 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 08:25:02 -0500 Subject: [Freeswitch-svn] [commit] r12640 - in freeswitch/trunk/src: . include Message-ID: Author: mrene Date: Tue Mar 17 08:25:02 2009 New Revision: 12640 Log: Fix a bunch of const (-Wcast-qual checking start) Modified: freeswitch/trunk/src/include/switch_event.h freeswitch/trunk/src/switch_apr.c freeswitch/trunk/src/switch_channel.c Modified: freeswitch/trunk/src/include/switch_event.h ============================================================================== --- freeswitch/trunk/src/include/switch_event.h (original) +++ freeswitch/trunk/src/include/switch_event.h Tue Mar 17 08:25:02 2009 @@ -124,7 +124,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_subclass_detailed(const char *file, const char *func, int line, switch_event_t **event, switch_event_types_t event_id, const char *subclass_name); -#define switch_event_create_subclass(_e, _eid, _sn) switch_event_create_subclass_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, _e, _eid, _sn) +#define switch_event_create_subclass(_e, _eid, _sn) switch_event_create_subclass_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, _e, _eid, _sn) /*! \brief Set the priority of an event @@ -202,7 +202,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, const char *func, int line, switch_event_t **event, void *user_data); SWITCH_DECLARE(void) switch_event_prep_for_delivery_detailed(const char *file, const char *func, int line, switch_event_t *event); -#define switch_event_prep_for_delivery(_event) switch_event_prep_for_delivery_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, _event) +#define switch_event_prep_for_delivery(_event) switch_event_prep_for_delivery_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, _event) /*! @@ -310,7 +310,7 @@ _In_z_ const char *alt_event_type, _In_ int event_count, _In_z_ const char *unique_id, _In_z_ const char *channel_state, _In_z_ const char *answer_state, _In_z_ const char *call_direction); -#define switch_event_create_pres_in(event) switch_event_create_pres_in_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \ +#define switch_event_create_pres_in(event) switch_event_create_pres_in_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, \ proto, login, from, from_domain, status, event_type, alt_event_type, event_count, \ unique_id, channel_state, answer_state, call_direction) @@ -345,7 +345,7 @@ \return SWITCH_STATUS_SUCCESS if the operation was successful \note the body supplied by this function will supersede an existing body the event may have */ -#define switch_event_fire(event) switch_event_fire_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, event, NULL) +#define switch_event_fire(event) switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, NULL) /*! \brief Fire an event filling in most of the arguements with obvious values and allowing user_data to be sent @@ -354,7 +354,7 @@ \return SWITCH_STATUS_SUCCESS if the operation was successful \note the body supplied by this function will supersede an existing body the event may have */ -#define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, event, data) +#define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, data) SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t *vars_map); Modified: freeswitch/trunk/src/switch_apr.c ============================================================================== --- freeswitch/trunk/src/switch_apr.c (original) +++ freeswitch/trunk/src/switch_apr.c Tue Mar 17 08:25:02 2009 @@ -786,7 +786,7 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor) { - return apr_pollset_add((apr_pollset_t *)pollset, (apr_pollfd_t *)descriptor); + return apr_pollset_add((apr_pollset_t *)pollset, (const apr_pollfd_t *)descriptor); } SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout) Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Tue Mar 17 08:25:02 2009 @@ -489,7 +489,7 @@ switch_assert(channel != NULL); switch_mutex_lock(channel->profile_mutex); - if (!channel->variables || !(v = switch_event_get_header(channel->variables, (char *) varname))) { + if (!channel->variables || !(v = switch_event_get_header(channel->variables, varname))) { switch_caller_profile_t *cp = channel->caller_profile; if (cp) { @@ -969,7 +969,7 @@ switch_channel_clear_flag(channel, CF_TAGGED); if (channel->state >= CS_ROUTING && channel->state <= CS_HANGUP) { - switch_channel_presence(channel, "unknown", (char *) state_names[state], NULL); + switch_channel_presence(channel, "unknown", (const char *) state_names[state], NULL); } if (state < CS_HANGUP) { @@ -978,10 +978,8 @@ if (state == CS_ROUTING) { switch_channel_event_set_data(channel, event); } else { - char state_num[25]; - switch_snprintf(state_num, sizeof(state_num), "%d", state); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(state)); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", (char *) state_num); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-State", switch_channel_state_name(state)); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%d", state); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Name", channel->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-Direction", From anthm at freeswitch.org Tue Mar 17 08:24:47 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 10:24:47 -0500 Subject: [Freeswitch-svn] [commit] r12641 - in freeswitch/trunk: libs/libdingaling/src src/mod/endpoints/mod_dingaling Message-ID: Author: anthm Date: Tue Mar 17 10:24:47 2009 New Revision: 12641 Log: MODENDP-198 MODENDP-199 Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Tue Mar 17 10:24:47 2009 @@ -389,6 +389,7 @@ if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) { dl_signal = LDL_SIGNAL_INITIATE; + if (!strcasecmp(type, "accept")) { msg = "accept"; } @@ -1432,10 +1433,10 @@ ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING); - while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { + while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { ldl_flush_queue(handle, 0); - if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) { + if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS || !ldl_test_flag((&globals), LDL_FLAG_READY)) { int fd; if ((fd = iks_fd(handle->parser)) > -1) { @@ -1470,6 +1471,7 @@ while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { int e; char tmp[512], *sl; + int fd; handle->parser = iks_stream_new(ldl_test_flag(handle, LDL_FLAG_COMPONENT) ? IKS_NS_COMPONENT : IKS_NS_CLIENT, handle, @@ -1570,6 +1572,10 @@ ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED); ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED); handle->state = CS_NEW; + + if ((fd = iks_fd(handle->parser)) > -1) { + shutdown(fd, 0x02); + } while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) { microsleep(100); @@ -2224,7 +2230,7 @@ int8_t ldl_handle_ready(ldl_handle_t *handle) { - return (int8_t)ldl_test_flag(handle, LDL_FLAG_READY); + return (int8_t) (ldl_test_flag(handle, LDL_FLAG_READY) && ldl_test_flag((&globals), LDL_FLAG_READY)); } ldl_status ldl_handle_init(ldl_handle_t **handle, Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Tue Mar 17 10:24:47 2009 @@ -873,11 +873,16 @@ tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port); flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG; + if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) { flags |= SWITCH_RTP_FLAG_USE_TIMER; } + if (switch_true(switch_channel_get_variable(channel, "disable_rtp_auto_adjust"))) { + flags &= ~SWITCH_RTP_FLAG_AUTOADJ; + } + if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip, tech_pvt->local_port, tech_pvt->remote_ip, @@ -1131,7 +1136,9 @@ if (!do_candidates(tech_pvt, 0)) { goto out; } - switch_channel_answer(channel); + if (switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT)) { + switch_channel_answer(channel); + } } ret = SWITCH_STATUS_SUCCESS; @@ -2549,7 +2556,7 @@ status = LDL_STATUS_FALSE; goto done; } - + } else { if (dl_signal != LDL_SIGNAL_INITIATE && !msg) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n"); @@ -2746,6 +2753,7 @@ if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { if (!strcasecmp(msg, "accept")) { switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); + switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); if (!do_candidates(tech_pvt, 0)) { terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); status = LDL_STATUS_FALSE; @@ -2909,7 +2917,7 @@ } if (!strcasecmp(subject, "candidates")) { - switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); + //switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); } From anthm at freeswitch.org Tue Mar 17 09:02:19 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 11:02:19 -0500 Subject: [Freeswitch-svn] [commit] r12642 - freeswitch/trunk/src/mod/languages/mod_spidermonkey Message-ID: Author: anthm Date: Tue Mar 17 11:02:18 2009 New Revision: 12642 Log: comment out shutdown command that causes crash on unload Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Tue Mar 17 11:02:18 2009 @@ -3746,7 +3746,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown) { - JS_DestroyRuntime(globals.rt); + // this causes a crash + //JS_DestroyRuntime(globals.rt); curl_global_cleanup(); switch_event_unbind(&globals.node); From anthm at freeswitch.org Tue Mar 17 09:23:33 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 11:23:33 -0500 Subject: [Freeswitch-svn] [commit] r12643 - freeswitch/trunk/src Message-ID: Author: anthm Date: Tue Mar 17 11:23:32 2009 New Revision: 12643 Log: FSCORE-336 Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Tue Mar 17 11:23:32 2009 @@ -1440,7 +1440,7 @@ } if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_caller_id_name"))) { - new_profile->caller_id_number = switch_core_strdup(new_profile->pool, current_variable); + new_profile->caller_id_name = switch_core_strdup(new_profile->pool, current_variable); myflags |= SOF_NO_EFFECTIVE_CID_NAME; } From mikej at freeswitch.org Tue Mar 17 09:28:16 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 11:28:16 -0500 Subject: [Freeswitch-svn] [commit] r12644 - freeswitch/trunk/src/mod/applications/mod_voicemail Message-ID: Author: mikej Date: Tue Mar 17 11:28:16 2009 New Revision: 12644 Log: mod_voicemail: fix password check (MODAPP-234) Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Tue Mar 17 11:28:16 2009 @@ -2075,20 +2075,20 @@ const char *val = switch_xml_attr_soft(x_param, "value"); if (!strcasecmp(var, "a1-hash")) { - thehash = val; + thehash = switch_core_session_strdup(session, val); } else if (!strcasecmp(var, "vm-a1-hash")) { - vmhash = val; + vmhash = switch_core_session_strdup(session, val); } else if (!auth && !thepass && !strcasecmp(var, "password")) { - thepass = val; + thepass = switch_core_session_strdup(session, val); } else if (!auth && !strcasecmp(var, "vm-password")) { if (!switch_strlen_zero(val) && !strcasecmp(val, "user-choose")) { if (switch_strlen_zero(cbt.password)) { auth = 1; } else { - thepass = val; + thepass = switch_core_session_strdup(session, val); } } else { - thepass = val; + thepass = switch_core_session_strdup(session, val); } } else if (!strcasecmp(var, "vm-mailto")) { vm_email = switch_core_session_strdup(session, val); From mikej at freeswitch.org Tue Mar 17 09:32:29 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 11:32:29 -0500 Subject: [Freeswitch-svn] [commit] r12645 - freeswitch/trunk/libs/esl Message-ID: Author: mikej Date: Tue Mar 17 11:32:29 2009 New Revision: 12645 Log: fix windows build error Modified: freeswitch/trunk/libs/esl/fs_cli.c Modified: freeswitch/trunk/libs/esl/fs_cli.c ============================================================================== --- freeswitch/trunk/libs/esl/fs_cli.c (original) +++ freeswitch/trunk/libs/esl/fs_cli.c Tue Mar 17 11:32:29 2009 @@ -239,11 +239,11 @@ } if (!known) { + char *foo; printf("INCOMING DATA [%s]\n%s\n", type, handle->last_event->body ? handle->last_event->body : ""); - char *foo; - esl_event_serialize(handle->last_event, &foo, ESL_FALSE); - printf("RECV EVENT\n%s\n", foo); - free(foo); + esl_event_serialize(handle->last_event, &foo, ESL_FALSE); + printf("RECV EVENT\n%s\n", foo); + free(foo); } } } From mikej at freeswitch.org Tue Mar 17 09:32:57 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 11:32:57 -0500 Subject: [Freeswitch-svn] [commit] r12646 - in freeswitch/trunk/src: . include Message-ID: Author: mikej Date: Tue Mar 17 11:32:57 2009 New Revision: 12646 Log: add code analysis tagging Modified: freeswitch/trunk/src/include/switch_core.h freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/include/switch_core.h ============================================================================== --- freeswitch/trunk/src/include/switch_core.h (original) +++ freeswitch/trunk/src/include/switch_core.h Tue Mar 17 11:32:57 2009 @@ -566,7 +566,7 @@ _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid); #define switch_core_session_request(_ep, _d, _p) switch_core_session_request_uuid(_ep, _d, _p, NULL) -SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(switch_core_session_t *session, const char *use_uuid); +SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(_In_ switch_core_session_t *session, _In_z_ const char *use_uuid); SWITCH_DECLARE(void) switch_core_session_perform_destroy(_Inout_ switch_core_session_t **session, _In_z_ const char *file, _In_z_ const char *func, _In_ int line); @@ -584,7 +584,7 @@ */ SWITCH_DECLARE(uint32_t) switch_core_session_count(void); -SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(switch_core_session_t *session); +SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(_In_ switch_core_session_t *session); /*! \brief Provide the current session_id Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Tue Mar 17 11:32:57 2009 @@ -298,8 +298,8 @@ switch_channel_t *channel; switch_frame_t *read_frame; - switch_assert(thread != NULL); - switch_assert(session != NULL); +// switch_assert(thread != NULL); +// switch_assert(session != NULL); if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) { return NULL; From anthm at freeswitch.org Tue Mar 17 09:39:12 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 11:39:12 -0500 Subject: [Freeswitch-svn] [commit] r12647 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Tue Mar 17 11:39:12 2009 New Revision: 12647 Log: FSCORE-337 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Mar 17 11:39:12 2009 @@ -735,6 +735,14 @@ int rtp_timeout_sec = 0; int rtp_hold_timeout_sec = 0; + if (codec_ms > 120) { /* yeah right */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "Your phone is trying to send timestamps that suggest an increment of %dms per packet\n" + "That seems hard to believe so I am going to go on ahead and um ignore that, mmkay?", (int)codec_ms); + tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES; + goto skip; + } + tech_pvt->read_frame.datalen = 0; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We were told to use ptime %d but what they meant to say was %d\n" From brian at freeswitch.org Tue Mar 17 10:23:01 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 12:23:01 -0500 Subject: [Freeswitch-svn] [commit] r12648 - freeswitch/trunk/src/mod/languages/mod_python Message-ID: Author: brian Date: Tue Mar 17 12:23:01 2009 New Revision: 12648 Log: MODLANG-106 Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/mod_python.c (original) +++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.c Tue Mar 17 12:23:01 2009 @@ -388,9 +388,6 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Python Framework Loading...\n"); - globals.pool = pool; - do_config(); - if (!Py_IsInitialized()) { // initialize python system @@ -411,6 +408,8 @@ PyEval_ReleaseLock(); } + globals.pool = pool; + do_config(); /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); From anthm at freeswitch.org Tue Mar 17 10:54:34 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 12:54:34 -0500 Subject: [Freeswitch-svn] [commit] r12649 - freeswitch/trunk/src/mod/applications/mod_dptools Message-ID: Author: anthm Date: Tue Mar 17 12:54:34 2009 New Revision: 12649 Log: FSCORE-334 Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Mar 17 12:54:34 2009 @@ -1569,7 +1569,7 @@ switch_channel_clear_flag(peer_channel, CF_INNER_BRIDGE); switch_channel_clear_flag(channel, CF_INNER_BRIDGE); - if (!switch_channel_down(peer_channel)) { + if (switch_channel_down(peer_channel)) { switch_core_session_rwunlock(peer_session); goto end; } From silik0n at freeswitch.org Tue Mar 17 11:12:12 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 13:12:12 -0500 Subject: [Freeswitch-svn] [commit] r12650 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Tue Mar 17 13:12:12 2009 New Revision: 12650 Log: how about send something more then / for the filepath Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Tue Mar 17 13:12:12 2009 @@ -217,7 +217,7 @@ } public function confPlayfile($conference, $file_path){ - $playfile = "api conference $conference play " . $file_path['data']; + $playfile = "api conference $conference play " . $file_path; $e = $this->esl->sendRecv($playfile); $body = $e->getBody(); return $body; From andrew at freeswitch.org Tue Mar 17 12:51:49 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 14:51:49 -0500 Subject: [Freeswitch-svn] [commit] r12651 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Tue Mar 17 14:51:49 2009 New Revision: 12651 Log: Remove some unnecessary code that was holding locks on the session Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Tue Mar 17 14:51:49 2009 @@ -541,8 +541,6 @@ /* event is a channel destroy, so this session can be removed */ if (pevent->event_id == SWITCH_EVENT_CHANNEL_DESTROY) { - switch_core_session_t *session; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy event for attached session for %s\n", sp->uuid_str); /* remove session from list */ @@ -551,10 +549,6 @@ else listener->session_list = sp->next; - if ((session = switch_core_session_locate(sp->uuid_str))) { - switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); - switch_core_session_rwunlock(session); - } /* this allows the application threads to exit */ switch_clear_flag_locked(sp, LFLAG_SESSION_ALIVE); removed = 1; @@ -1041,23 +1035,17 @@ { /* create a session list element */ session_elem_t* session_element = NULL; - if (!(session_element = switch_core_alloc(switch_core_session_get_pool(session), sizeof(*session_element)))) { + if (!(session_element = switch_core_session_alloc(session, sizeof(*session_element)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate session element\n"); - } - else { - if (SWITCH_STATUS_SUCCESS != switch_core_session_read_lock(session)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get session read lock\n"); - } - else { - session_element->process.type = ERLANG_REG_PROCESS; - session_element->process.reg_name = switch_core_strdup(switch_core_session_get_pool(session),reg_name); - switch_set_flag(session_element, LFLAG_SESSION_ALIVE); - switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); - switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session)); - switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - /* attach the session to the listener */ - add_session_elem_to_listener(listener,session_element); - } + } else { + session_element->process.type = ERLANG_REG_PROCESS; + session_element->process.reg_name = switch_core_strdup(switch_core_session_get_pool(session),reg_name); + switch_set_flag(session_element, LFLAG_SESSION_ALIVE); + switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); + switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session)); + switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); + /* attach the session to the listener */ + add_session_elem_to_listener(listener,session_element); } return session_element; } @@ -1066,26 +1054,20 @@ { /* create a session list element */ session_elem_t* session_element = NULL; - if (!(session_element = switch_core_alloc(switch_core_session_get_pool(session), sizeof(*session_element)))) { + if (!(session_element = switch_core_session_alloc(session, sizeof(*session_element)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate session element\n"); - } - else { - if (SWITCH_STATUS_SUCCESS != switch_core_session_read_lock(session)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get session read lock\n"); - } - else { - memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); - session_element->process.type = ERLANG_PID; - memcpy(&session_element->process.pid, pid, sizeof(erlang_pid)); - switch_set_flag(session_element, LFLAG_SESSION_ALIVE); - switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); - switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session)); - switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - /* attach the session to the listener */ - add_session_elem_to_listener(listener,session_element); + } else { + memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); + session_element->process.type = ERLANG_PID; + memcpy(&session_element->process.pid, pid, sizeof(erlang_pid)); + switch_set_flag(session_element, LFLAG_SESSION_ALIVE); + switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); + switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session)); + switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); + /* attach the session to the listener */ + add_session_elem_to_listener(listener,session_element); - ei_link(listener, ei_self(listener->ec), pid); - } + ei_link(listener, ei_self(listener->ec), pid); } return session_element; } @@ -1094,83 +1076,78 @@ { /* create a session list element */ session_elem_t* session_element=NULL; - if (!(session_element = switch_core_alloc(switch_core_session_get_pool(session), sizeof(*session_element)))) { + if (!(session_element = switch_core_session_alloc(session, sizeof(*session_element)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate session element\n"); } else { - if (SWITCH_STATUS_SUCCESS != switch_core_session_read_lock(session)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get session read lock\n"); - } - else { - char hash[100]; - int i = 0; - void *p = NULL; - - memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); - erlang_pid *pid; - erlang_ref ref; - - switch_set_flag(session_element, LFLAG_WAITING_FOR_PID); - switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session)); - switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - /* attach the session to the listener */ - add_session_elem_to_listener(listener,session_element); - - ei_init_ref(listener->ec, &ref); - ei_hash_ref(&ref, hash); - /* insert the waiting marker */ - switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.WAITING); - - if (!strcmp(function, "!")) { - /* send a message to request a pid */ - ei_x_buff rbuf; - ei_x_new_with_version(&rbuf); - - ei_x_encode_tuple_header(&rbuf, 3); - ei_x_encode_atom(&rbuf, "new_pid"); - ei_x_encode_ref(&rbuf, &ref); - ei_x_encode_pid(&rbuf, ei_self(listener->ec)); - /* should lock with mutex? */ - ei_reg_send(listener->ec, listener->sockfd, module, rbuf.buff, rbuf.index); + char hash[100]; + int i = 0; + void *p = NULL; + + memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); + erlang_pid *pid; + erlang_ref ref; + + switch_set_flag(session_element, LFLAG_WAITING_FOR_PID); + switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(session)); + switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); + /* attach the session to the listener */ + add_session_elem_to_listener(listener,session_element); + + ei_init_ref(listener->ec, &ref); + ei_hash_ref(&ref, hash); + /* insert the waiting marker */ + switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.WAITING); + + if (!strcmp(function, "!")) { + /* send a message to request a pid */ + ei_x_buff rbuf; + ei_x_new_with_version(&rbuf); + + ei_x_encode_tuple_header(&rbuf, 3); + ei_x_encode_atom(&rbuf, "new_pid"); + ei_x_encode_ref(&rbuf, &ref); + ei_x_encode_pid(&rbuf, ei_self(listener->ec)); + /* should lock with mutex? */ + ei_reg_send(listener->ec, listener->sockfd, module, rbuf.buff, rbuf.index); #ifdef EI_DEBUG - ei_x_print_reg_msg(&rbuf, module, 1); + ei_x_print_reg_msg(&rbuf, module, 1); #endif - ei_x_free(&rbuf); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rpc call: %s:%s(Ref)\n", module, function); - /* should lock with mutex? */ - ei_pid_from_rpc(listener->ec, listener->sockfd, &ref, module, function); - /* - char *argv[1]; - ei_spawn(listener->ec, listener->sockfd, &ref, module, function, 0, argv); - */ - } - - /* loop until either we timeout or we get a value that's not the waiting marker */ - while (!(p = switch_core_hash_find(listener->spawn_pid_hash, hash)) || p == &globals.WAITING) { - if (i > 50) { /* half a second timeout */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid\n"); - remove_session_elem_from_listener(listener,session_element); - switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.TIMEOUT); /* TODO lock this? */ - return NULL; - } - i++; - switch_yield(10000); /* 10ms */ + ei_x_free(&rbuf); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rpc call: %s:%s(Ref)\n", module, function); + /* should lock with mutex? */ + ei_pid_from_rpc(listener->ec, listener->sockfd, &ref, module, function); + /* + char *argv[1]; + ei_spawn(listener->ec, listener->sockfd, &ref, module, function, 0, argv); + */ + } + + /* loop until either we timeout or we get a value that's not the waiting marker */ + while (!(p = switch_core_hash_find(listener->spawn_pid_hash, hash)) || p == &globals.WAITING) { + if (i > 50) { /* half a second timeout */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid\n"); + remove_session_elem_from_listener(listener,session_element); + switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.TIMEOUT); /* TODO lock this? */ + return NULL; } + i++; + switch_yield(10000); /* 10ms */ + } - switch_core_hash_delete(listener->spawn_pid_hash, hash); + switch_core_hash_delete(listener->spawn_pid_hash, hash); - pid = (erlang_pid *) p; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got pid!\n"); + pid = (erlang_pid *) p; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got pid!\n"); - session_element->process.type = ERLANG_PID; - memcpy(&session_element->process.pid, pid, sizeof(erlang_pid)); - free(pid); /* malloced in handle_ref_tuple */ - switch_set_flag(session_element, LFLAG_SESSION_ALIVE); - switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); - switch_clear_flag(session_element, LFLAG_WAITING_FOR_PID); + session_element->process.type = ERLANG_PID; + memcpy(&session_element->process.pid, pid, sizeof(erlang_pid)); + free(pid); /* malloced in handle_ref_tuple */ + switch_set_flag(session_element, LFLAG_SESSION_ALIVE); + switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); + switch_clear_flag(session_element, LFLAG_WAITING_FOR_PID); - ei_link(listener, ei_self(listener->ec), pid); - } + ei_link(listener, ei_self(listener->ec), pid); } return session_element; } @@ -1276,9 +1253,8 @@ /* keep app thread running for lifetime of session */ if (switch_channel_down(switch_core_session_get_channel(session))) { - while (switch_test_flag(session_element, LFLAG_SESSION_ALIVE)) { - switch_yield(100000); - } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "outbound session all done\n"); + switch_clear_flag_locked(session_element, LFLAG_SESSION_ALIVE); } } } From anthm at freeswitch.org Tue Mar 17 13:56:28 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 15:56:28 -0500 Subject: [Freeswitch-svn] [commit] r12652 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Tue Mar 17 15:56:28 2009 New Revision: 12652 Log: fix from irc Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 17 15:56:28 2009 @@ -2877,6 +2877,9 @@ if (r_sdp) { if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { + switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA"); + } sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); switch_channel_mark_pre_answered(channel); sofia_set_flag(tech_pvt, TFLAG_SDP); @@ -2897,9 +2900,7 @@ } goto done; } else { - if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { - switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA"); - } else if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { + if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "DELAYED NEGOTIATION"); } else { if (sofia_glue_tech_media(tech_pvt, (char *) r_sdp) != SWITCH_STATUS_SUCCESS) { From silik0n at freeswitch.org Tue Mar 17 14:09:12 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Tue, 17 Mar 2009 16:09:12 -0500 Subject: [Freeswitch-svn] [commit] r12653 - freeswitch/trunk/scripts/contrib/swk/php/esl_cdr Message-ID: Author: silik0n Date: Tue Mar 17 16:09:12 2009 New Revision: 12653 Log: just a little something for an example of how to do CDRs from ESL with PHP Added: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/ freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.postgres.sql Added: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php Tue Mar 17 16:09:12 2009 @@ -0,0 +1,92 @@ +getMessage()); +} + +/* set up the ESL Connection */ +$esl = new eslConnection('204.8.45.218', '8021', 'disasterisk-sucks'); +$e = $esl->sendRecv("api status"); +print $e->getBody(); +$esl->events("plain", "channel_hangup"); +for(;;) { + print "foo - 1\n"; + $e = $esl->recvEvent(); + if ($e) { + $lines = explode("\n", $e->serialize()); + foreach ($lines as $line){ + $temp_data = explode(": ", $line); + + if ($temp_data[0]){ + if ($temp_data[0] == 'variable_easy_acctcode'){ + $data['acctcode'] = $temp_data[1]; + } elseif ($temp_data[0] == 'variable_acctcode'){ + $data['acctcode'] = $temp_data[1]; + } elseif ($temp_data[0] == 'variable_accountcode'){ + $data['acctcode'] = $temp_data[1]; + } elseif ($temp_data[0] == 'variable_account_code'){ + $data['acctcode'] = $temp_data[1]; + } else { + $data[$temp_data[0]] = $temp_data[1]; + } + } + } + + $insert = sprintf("INSERT into cdr (uuid, acctcode, ani, e164_ani, dnis, translated_dnis, e164_dnis, src_host, read_codec, write_codec, clid_name, ". + "clid_number, src_sdp, dest_sdp, originate_disposition, bridge_to_uuid, endpoint_disposition, sip_hangup_disposition, term_cause, ". + "hangup_cause, start_stamp, answer_stamp, progress_media_stamp, end_stamp, duration, billsec, progress_mediasec, billmin, ". + "carrier_id, cust_cost, carrier_cost)". + "VALUES". + "('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s, '%s', '%s',". + "%s, %s, %s, %s, %s, %s, %s)", + $data['Unique-ID'], + $data['acctcode'], + $data['Caller-Caller-ID-Number'], + $data['Caller-Caller-ID-Number'], + urldecode($data['Caller-Destination-Number']), + urldecode($data['Caller-Destination-Number']), + urldecode($data['Caller-Destination-Number']), + $data['Caller-Network-Addr'], + $data['Channel-Read-Codec-Name']."-". $data['Channel-Read-Codec-Rate'], + $data['Channel-Write-Codec-Name']."-". $data['Channel-Write-Codec-Rate'], + urlencode($data['Caller-Caller-ID-Name']), + $data['Caller-Caller-ID-Number'], + $data['variable_switch_r_sdp'], + $data['variable_switch_m_sdp'], + $data['variable_originate_disposition'], + $data['variable_bridge_to'], + $data['variable_endpoint_disposition'], + $data['variable_sip_hangup_disposition'], + $data['variable_sip_term_cause'], + $data['variable_hangup_cause'], + urldecode($data['variable_start_stamp']) . '-05', + isset($data['variable_answer_stamp'])?'\''. urldecode($data['variable_answer_stamp']) . '-05\'':'null', + urldecode($data['variable_progress_media_stamp']) . '-05', + urldecode($data['variable_end_stamp']) . '-05', + $data['variable_duration'], + $data['variable_billsec'], + $data['variable_progress_mediasec'], + $data['variable_billsec'], + "0", + "0", + "0" + ); + + $result = $con->query($insert); + if(PEAR::isError($result)) { + echo "$insert\n"; + die(); + } + } +} +?> Added: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.postgres.sql ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.postgres.sql Tue Mar 17 16:09:12 2009 @@ -0,0 +1,71 @@ +-- +-- PostgreSQL database dump +-- + +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = off; +SET check_function_bodies = false; +SET client_min_messages = warning; +SET escape_string_warning = off; + +SET search_path = public, pg_catalog; + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- Name: cdr; Type: TABLE; Schema: public; Owner: root; Tablespace: +-- + +CREATE TABLE cdr ( + uuid character varying, + acctcode character varying, + ani character varying, + e164_ani character varying, + dnis character varying, + translated_dnis character varying, + e164_dnis character varying, + src_host character varying, + read_codec character varying, + write_codec character varying, + clid_name character varying, + clid_number character varying, + src_sdp character varying, + dest_sdp character varying, + originate_disposition character varying, + bridge_to_uuid character varying, + endpoint_disposition character varying, + sip_hangup_disposition character varying, + term_cause character varying, + hangup_cause character varying, + start_stamp timestamp with time zone, + answer_stamp timestamp with time zone, + progress_media_stamp timestamp with time zone, + end_stamp timestamp with time zone, + duration integer, + billsec integer, + progress_mediasec integer, + billmin numeric(8,2), + carrier_id integer, + cust_cost numeric(7,4), + carrier_cost numeric(7,4) +); + + +ALTER TABLE public.cdr OWNER TO root; + +-- +-- Name: public; Type: ACL; Schema: -; Owner: postgres +-- + +REVOKE ALL ON SCHEMA public FROM PUBLIC; +REVOKE ALL ON SCHEMA public FROM postgres; +GRANT ALL ON SCHEMA public TO postgres; +GRANT ALL ON SCHEMA public TO PUBLIC; + + +-- +-- PostgreSQL database dump complete +-- + From silik0n at freeswitch.org Wed Mar 18 02:38:18 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 04:38:18 -0500 Subject: [Freeswitch-svn] [commit] r12654 - in freeswitch/trunk/scripts/contrib/swk: . php/xml_curl Message-ID: Author: silik0n Date: Wed Mar 18 04:38:18 2009 New Revision: 12654 Log: xml_curl of the directory is now working... this means you can manage the users from the UI see the README for installation instructions Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Modified: freeswitch/trunk/scripts/contrib/swk/README Modified: freeswitch/trunk/scripts/contrib/swk/README ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/README (original) +++ freeswitch/trunk/scripts/contrib/swk/README Wed Mar 18 04:38:18 2009 @@ -23,8 +23,30 @@ make the files in amf-test1/bin-debug available on your webserver and point a browser at it. +copy the php/xml_curl directory to your webserver + +make sure you have mod_xml_curl built and installed and enabled + uncomment it in the modules.conf in your source tree + uncomment it in your modules.conf.xml in the conf/autoload_configs/modules.conf.xml + + +edit the gateway_url param in conf/autoload_configs/xml_curl.conf.xml to enabale the directory binding +EXAMPLE: + + + +rename conf/directory/default.xml to conf/directory/default.xml.NOLOAD + this is no longer required as we are now loading the directory using xml_curl + + If you are developing in flex you need to load the swf from your development webserver so that it can properly locate the service. -Any questions, feel free to find me as SwK via IRC at #freeswitch on irc.freenode.net +Any questions, feel free to find me as SwK via IRC at #freeswitch on irc.freenode.net or krice AT freeswitch DOT org + +TODO: +Fix Groups and Group Editing +Fix Conference Controls +Rework PHP Class Files for both the amfphp service and the xml_curl there is no need to maintain these seperately as they share a fair ammount of code +anything else I can come up with Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php Wed Mar 18 04:38:18 2009 @@ -0,0 +1,156 @@ + + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Ken Rice + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Ken Rice + * + * freeswitch.php -- Initial Class file for XML_CURL responses for Codename: SHIPMENT + * + *************************************************************************************************** + * + * This Requires the FreeSWITCH ESL Extension to be installed properly on your system. + * + */ + +// require_once "ESL.php"; + +class FSDirectory { + // var $esl; + + var $dbh; + + public function __construct(){ + $dbtype='mysql'; /* Set the Database type */ + // $db_hostname = 'localhost'; /* Database Server hostname */ + $db_hostname = '192.168.1.140'; /* Database Server hostname */ + $db_port = '3306'; /* Database Server Port */ + $db_username = 'root'; /* Database Server username */ + $db_password = 'password'; /* Database Server password */ + $db_database = 'shipment'; /* DataBase Name */ + if ($dbtype == 'mysql') { + $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,); + } + $this->dbh = new PDO("$dbtype:host=$db_hostname;port=$db_port;dbname=$db_database", $db_username, $db_password, $pdo_flags); + + } + + private function getESL() { + $esl_server = "127.0.0.1"; /* ESL Server */ + $esl_port = "8021"; /* ESL Port */ + $esl_secret = "ClueCon"; /* ESL Secret */ + $this->esl = new eslConnection($esl_server, $esl_port, $esl_secret); + } + + /* + public function getStatus() { + $e = $this->esl->sendRecv("api status"); + $body = $e->getBody(); + return $body; + } + */ + + /*** Directory Methods ***/ + + /* Directory Domain Methods */ + public function getDirDomains(){ + $query = sprintf("select * from domains"); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + + public function getDirDomainbyName($domain_name){ + $query = sprintf("select * from domains where name = '%s'", $domain_name); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results[0]; + } + + public function getDirDomain($domains_uid){ + $query = sprintf("select * from domain_params where domains_uid = $domains_uid"); + $stmt = $this->dbh->query($query); + $results['params'] = $stmt->fetchAll(); + $query = sprintf("select * from domain_variables where domains_uid = $domains_uid"); + $stmt = $this->dbh->query($query); + $results['variables'] = $stmt->fetchAll(); + return $results; + } + + /* Directory User Methods */ + public function getDirUser($user_uid){ + $query = sprintf("select * from user_params where users_uid = $user_uid"); + $stmt = $this->dbh->query($query); + $results['params'] = $stmt->fetchAll(); + $query = sprintf("select * from user_variables where users_uid = $user_uid"); + $stmt = $this->dbh->query($query); + $results['variables'] = $stmt->fetchAll(); + return $results; + } + + public function getDirUsers($domains_uid){ + $query = sprintf("select * from users where domains_uid = $domains_uid"); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + + public function getDirUsersByDomainUidByUsername($domain_uid, $user_name){ + $query = sprintf("select * from users where domains_uid = '%s' and username = '%s'", $domain_uid, $user_name); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results[0]; + } + + /* Directory Group Methods */ + public function getDirGroups($domains_uid){ + $query = sprintf("select * from groups where domains_uid = $domains_uid"); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + + public function getDirGroup($groups_uid){ + $query = sprintf("select a.uid as groupMemberUid, a.users_uid as usersUid, b.username as usersUsername from group_members as a, users as b where a.groups_uid = $groups_uid and a.users_uid = b.uid") ; + $stmt = $this->dbh->query($query); + $results['members'] = $stmt->fetchAll(); + $query = sprintf("select uid as usersUid, username as usersUsername from users where uid not in (select users_uid from group_members where groups_uid = $groups_uid) and domains_uid = (select domains_uid from groups where uid = $groups_uid)"); + $stmt = $this->dbh->query($query); + $results['nonmembers'] = $stmt->fetchAll(); + return $results; + } + +} +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + */ +?> Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Wed Mar 18 04:38:18 2009 @@ -0,0 +1,73 @@ + $value) { + $$key = $value; +} + +$fsd = new FSDirectory(); + +/* Uncomment and edit for debugging */ +/* +$section = "directory"; +$tag_name= "domain"; +$key_name ="name"; +$key_value="192.168.1.140"; +$user="1000"; +*/ +if ($section == "directory" && $tag_name == "domain" && $key_name == "name") { + $db_domain = $fsd->getDirDomainbyName($key_value); +} else { + printf("\n\n
\n". + "\n
\n
"); + die(); +} + +$db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user); + +$db_user_settings = $fsd->getDirUser($db_user['uid']); + +$db_groups = $fsd->getDirGroups($db_domain['uid']); + +printf(" \n"); +printf(" \n"); +printf("
\n"); +printf(" \n", $db_domain['name']); +printf(" \n"); +printf(" \n"); +printf(" \n"); +printf(" \n", $db_user['username'], $db_user['mailbox']); +printf(" \n"); +foreach($db_user_settings['params'] as $db_params) { + printf(" \n", $db_params['name'], $db_params['value']); +} +printf(" \n"); +printf(" \n"); +foreach($db_user_settings['variables'] as $db_variables) { + printf(" \n", $db_variables['name'], $db_variables['value']); +} +printf(" \n"); +printf(" \n"); +printf(" \n"); +printf(" \n"); +/* This is Broken need to talk to someone about this part... maybe I should load this at boot time instead +foreach($db_groups as $db_group){ + $db_members = $fsd->getDirGroup($db_group['uid']); + printf(" \n", $db_group['name']); + printf(" \n"); + foreach($db_members['members'] as $db_member){ + printf(" \n", $db_member['usersUsername']); + } + printf(" \n"); + printf(" \n"); +} +*/ +printf(" \n"); +printf(" \n"); +printf("
\n"); +printf("
\n"); +?> From brian at freeswitch.org Wed Mar 18 09:02:51 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 11:02:51 -0500 Subject: [Freeswitch-svn] [commit] r12655 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Wed Mar 18 11:02:50 2009 New Revision: 12655 Log: We get status of 100 on a 302. This will fix a bug reported from IRC. Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 18 11:02:50 2009 @@ -2691,7 +2691,7 @@ } } - if (channel && sip && (status >= 300 && status < 399) && switch_channel_test_flag(channel, CF_OUTBOUND)) { + if (channel && sip && status == 100 && switch_channel_test_flag(channel, CF_OUTBOUND)) { sip_contact_t * p_contact = sip->sip_contact; int i = 0; char var_name[80]; From anthm at freeswitch.org Wed Mar 18 11:45:39 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 13:45:39 -0500 Subject: [Freeswitch-svn] [commit] r12656 - freeswitch/trunk/patches Message-ID: Author: anthm Date: Wed Mar 18 13:45:39 2009 New Revision: 12656 Log: add Added: freeswitch/trunk/patches/pa.diff Added: freeswitch/trunk/patches/pa.diff ============================================================================== --- (empty file) +++ freeswitch/trunk/patches/pa.diff Wed Mar 18 13:45:39 2009 @@ -0,0 +1,254 @@ +Index: src/mod/endpoints/mod_portaudio/mod_portaudio.c +=================================================================== +--- src/mod/endpoints/mod_portaudio/mod_portaudio.c (revision 12655) ++++ src/mod/endpoints/mod_portaudio/mod_portaudio.c (working copy) +@@ -124,7 +124,8 @@ + private_t *call_list; + int ring_interval; + GFLAGS flags; +- switch_timer_t timer; ++ switch_timer_t read_timer; ++ switch_timer_t write_timer; + switch_timer_t hold_timer; + int dual_streams; + time_t deactivate_timer; +@@ -249,7 +250,7 @@ + } + + while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { +- switch_size_t olen = globals.timer.samples; ++ switch_size_t olen = globals.read_timer.samples; + + if (switch_micro_time_now() - last >= waitsec) { + char buf[512]; +@@ -268,7 +269,7 @@ + } + + if (ring_file) { +- if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) { ++ if (switch_core_timer_next(&globals.read_timer) != SWITCH_STATUS_SUCCESS) { + switch_core_file_close(&fh); + break; + } +@@ -279,7 +280,7 @@ + } + + if (globals.ring_stream) { +- WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.timer); ++ WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.write_timer); + } + } else { + switch_yield(10000); +@@ -355,10 +356,14 @@ + switch_core_codec_destroy(&globals.write_codec); + } + +- if (globals.timer.timer_interface) { +- switch_core_timer_destroy(&globals.timer); ++ if (globals.read_timer.timer_interface) { ++ switch_core_timer_destroy(&globals.read_timer); + } + ++ if (globals.write_timer.timer_interface) { ++ switch_core_timer_destroy(&globals.write_timer); ++ } ++ + if (globals.hold_timer.timer_interface) { + switch_core_timer_destroy(&globals.hold_timer); + } +@@ -597,14 +602,13 @@ + + switch_mutex_lock(globals.device_lock); + samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, +- globals.read_codec.implementation->samples_per_packet, &globals.timer); ++ globals.read_codec.implementation->samples_per_packet, &globals.read_timer); + switch_mutex_unlock(globals.device_lock); + + if (samples) { + globals.read_frame.datalen = samples * 2; + globals.read_frame.samples = samples; + +- //switch_core_timer_check(&globals.timer, SWITCH_TRUE); + *frame = &globals.read_frame; + + if (!switch_test_flag((&globals), GFLAG_MOUTH)) { +@@ -649,7 +653,7 @@ + + if (globals.audio_stream) { + if (switch_test_flag((&globals), GFLAG_EAR)) { +- WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &globals.timer); ++ WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &globals.write_timer); + } + status = SWITCH_STATUS_SUCCESS; + } +@@ -1278,10 +1282,14 @@ + destroy_codecs(); + } + +- if (globals.timer.timer_interface) { +- switch_core_timer_sync(&globals.timer); ++ if (globals.read_timer.timer_interface) { ++ switch_core_timer_sync(&globals.read_timer); + } + ++ if (globals.write_timer.timer_interface) { ++ switch_core_timer_sync(&globals.write_timer); ++ } ++ + if (globals.audio_stream) { + return SWITCH_STATUS_SUCCESS; + } +@@ -1310,8 +1318,8 @@ + } + } + +- if (!globals.timer.timer_interface) { +- if (switch_core_timer_init(&globals.timer, ++ if (!globals.read_timer.timer_interface) { ++ if (switch_core_timer_init(&globals.read_timer, + globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, + module_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); +@@ -1321,6 +1329,19 @@ + } + } + ++ ++ if (!globals.write_timer.timer_interface) { ++ if (switch_core_timer_init(&globals.write_timer, ++ globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, ++ module_pool) != SWITCH_STATUS_SUCCESS) { ++ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); ++ switch_core_codec_destroy(&globals.read_codec); ++ switch_core_codec_destroy(&globals.write_codec); ++ switch_core_timer_destroy(&globals.read_timer); ++ return SWITCH_STATUS_FALSE; ++ } ++ } ++ + if (!globals.hold_timer.timer_interface) { + if (switch_core_timer_init(&globals.hold_timer, + globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, +@@ -1328,7 +1349,8 @@ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); +- switch_core_timer_destroy(&globals.timer); ++ switch_core_timer_destroy(&globals.read_timer); ++ switch_core_timer_destroy(&globals.write_timer); + return SWITCH_STATUS_FALSE; + } + } +@@ -1366,7 +1388,8 @@ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); +- switch_core_timer_destroy(&globals.timer); ++ switch_core_timer_destroy(&globals.read_timer); ++ switch_core_timer_destroy(&globals.write_timer); + switch_core_timer_destroy(&globals.hold_timer); + return SWITCH_STATUS_FALSE; + } +@@ -1963,8 +1986,8 @@ + playfile, seconds, samples, globals.read_codec.implementation->actual_samples_per_second); + + while (switch_core_file_read(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) { +- WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.timer); +- switch_core_timer_next(&globals.timer); ++ WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.read_timer); ++ switch_core_timer_next(&globals.read_timer); + samples -= (int) olen; + if (samples <= 0) { + break; +@@ -1993,8 +2016,8 @@ + int i; + for(i = 0; i < 400; i++) { + if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, +- globals.read_codec.implementation->samples_per_packet, &globals.timer))) { +- WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &globals.timer); ++ globals.read_codec.implementation->samples_per_packet, &globals.read_timer))) { ++ WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &globals.write_timer); + success = 1; + } + switch_yield(10000); +Index: src/mod/endpoints/mod_portaudio/pablio.c +=================================================================== +--- src/mod/endpoints/mod_portaudio/pablio.c (revision 12655) ++++ src/mod/endpoints/mod_portaudio/pablio.c (working copy) +@@ -146,17 +146,15 @@ + char *p = (char *) data; + long numBytes = aStream->bytesPerFrame * numFrames; + +- while (numBytes > 0) { +- bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes); +- numBytes -= bytesWritten; +- p += bytesWritten; +- if (numBytes > 0) { +- if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { +- PaUtil_FlushRingBuffer(&aStream->outFIFO); +- return 0; +- } +- switch_cond_next(); +- } ++ switch_core_timer_next(timer); ++ ++ bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes); ++ numBytes -= bytesWritten; ++ p += bytesWritten; ++ ++ if (numBytes > 0) { ++ PaUtil_FlushRingBuffer(&aStream->outFIFO); ++ return 0; + } + return numFrames; + } +@@ -171,32 +169,28 @@ + char *p = (char *) data; + long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames; + +- for (;;) { +- avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); ++ switch_core_timer_next(timer); ++ ++ avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); + +- if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { +- break; +- } ++ if (avail >= neededBytes * 6) { ++ PaUtil_FlushRingBuffer(&aStream->inFIFO); ++ avail = 0; ++ } + +- if (avail >= neededBytes * 6) { +- PaUtil_FlushRingBuffer(&aStream->inFIFO); +- avail = 0; +- } ++ bytesRead = 0; + +- bytesRead = 0; +- +- if (totalBytes < neededBytes && avail >= neededBytes) { +- bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); +- totalBytes += bytesRead; +- } +- +- if (bytesRead) { +- p += bytesRead; +- } else { +- switch_cond_next(); +- } ++ if (totalBytes < neededBytes && avail >= neededBytes) { ++ bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); ++ totalBytes += bytesRead; + } + ++ if (bytesRead) { ++ p += bytesRead; ++ } else { ++ switch_cond_next(); ++ } ++ + return totalBytes / aStream->bytesPerFrame; + } + From brian at freeswitch.org Wed Mar 18 11:54:16 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 13:54:16 -0500 Subject: [Freeswitch-svn] [commit] r12657 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Wed Mar 18 13:54:16 2009 New Revision: 12657 Log: MODENDP-201 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Wed Mar 18 13:54:16 2009 @@ -1737,7 +1737,7 @@ nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta + SUB_OVERLAP, exp_delta + SUB_OVERLAP); } - nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(contact_str), NUTAG_WITH_THIS(nua), + nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(contactstr), NUTAG_WITH_THIS(nua), SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EXPIRES_STR(exp_delta_str), TAG_IF(sticky, NUTAG_PROXY(sticky)), TAG_END()); From brian at freeswitch.org Wed Mar 18 11:56:36 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 13:56:36 -0500 Subject: [Freeswitch-svn] [commit] r12658 - in freeswitch/trunk: conf/autoload_configs src/mod/languages/mod_python Message-ID: Author: brian Date: Wed Mar 18 13:56:36 2009 New Revision: 12658 Log: MODLANG-105 Modified: freeswitch/trunk/conf/autoload_configs/python.conf.xml freeswitch/trunk/src/mod/languages/mod_python/mod_python.c Modified: freeswitch/trunk/conf/autoload_configs/python.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/python.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/python.conf.xml Wed Mar 18 13:56:36 2009 @@ -4,13 +4,13 @@ - - + + Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/mod_python.c (original) +++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.c Wed Mar 18 13:56:36 2009 @@ -388,6 +388,8 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Python Framework Loading...\n"); + globals.pool = pool; + if (!Py_IsInitialized()) { // initialize python system @@ -408,7 +410,6 @@ PyEval_ReleaseLock(); } - globals.pool = pool; do_config(); /* connect my internal structure to the blank pointer passed to me */ From brian at freeswitch.org Wed Mar 18 12:17:31 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 14:17:31 -0500 Subject: [Freeswitch-svn] [commit] r12659 - freeswitch/trunk/conf/sip_profiles Message-ID: Author: brian Date: Wed Mar 18 14:17:31 2009 New Revision: 12659 Log: add undocumented features to the config file example someone wiki this please Modified: freeswitch/trunk/conf/sip_profiles/internal.xml Modified: freeswitch/trunk/conf/sip_profiles/internal.xml ============================================================================== --- freeswitch/trunk/conf/sip_profiles/internal.xml (original) +++ freeswitch/trunk/conf/sip_profiles/internal.xml Wed Mar 18 14:17:31 2009 @@ -124,6 +124,10 @@ + + + + From brian at freeswitch.org Wed Mar 18 13:36:30 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 15:36:30 -0500 Subject: [Freeswitch-svn] [commit] r12660 - freeswitch/trunk/src Message-ID: Author: brian Date: Wed Mar 18 15:36:30 2009 New Revision: 12660 Log: FSRTP-1 Modified: freeswitch/trunk/src/switch_rtp.c Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Wed Mar 18 15:36:30 2009 @@ -624,6 +624,11 @@ SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max) { + if (rtp_session->missed_count >= max) + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "new max missed packets(%d->%d) greater than current missed packets(%d). RTP will timeout.\n", + rtp_session->missed_count, max, rtp_session->missed_count); + rtp_session->max_missed_packets = max; } From silik0n at freeswitch.org Wed Mar 18 16:39:48 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 18:39:48 -0500 Subject: [Freeswitch-svn] [commit] r12661 - freeswitch/trunk/scripts/contrib/swk/php/esl_cdr Message-ID: Author: silik0n Date: Wed Mar 18 18:39:48 2009 New Revision: 12661 Log: mysql schema for this script Added: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.mysql.sql Added: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.mysql.sql ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.mysql.sql Wed Mar 18 18:39:48 2009 @@ -0,0 +1,33 @@ +CREATE TABLE IF NOT EXISTS `cdr` ( + `uuid` varchar(100) NOT NULL, + `acctcode` varchar(100) NOT NULL, + `ani` varchar(100) NOT NULL, + `e164_ani` varchar(100) NOT NULL, + `dnis` varchar(100) NOT NULL, + `e164_dnis` varchar(100) NOT NULL, + `translated_dnis` varchar(100) NOT NULL, + `src_host` varchar(100) NOT NULL, + `read_codec` varchar(100) NOT NULL, + `write_codec` varchar(100) NOT NULL, + `clid_name` varchar(100) NOT NULL, + `clid_number` varchar(100) NOT NULL, + `src_sdp` varchar(100) NOT NULL, + `dest_sdp` varchar(100) NOT NULL, + `originate_disposition` varchar(100) NOT NULL, + `bridge_to_uuid` varchar(100) NOT NULL, + `endpoint_disposition` varchar(100) NOT NULL, + `sip_hangup_disposition` varchar(100) NOT NULL, + `term_cause` varchar(100) NOT NULL, + `hangup_cause` varchar(100) NOT NULL, + `start_stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `answer_stamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `progress_media_stamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `end_stamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `duration` int(11) NOT NULL, + `billsec` int(11) NOT NULL, + `progress_mediasec` int(11) NOT NULL, + `billmin` varchar(100) NOT NULL, + `carrier_id` varchar(100) NOT NULL, + `cust_cost` varchar(100) NOT NULL, + `carrier_cost` varchar(100) NOT NULL +) From brian at freeswitch.org Wed Mar 18 18:06:21 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 20:06:21 -0500 Subject: [Freeswitch-svn] [commit] r12662 - freeswitch/trunk/src Message-ID: Author: brian Date: Wed Mar 18 20:06:21 2009 New Revision: 12662 Log: bracketless if's are not allowed doh Modified: freeswitch/trunk/src/switch_rtp.c Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Wed Mar 18 20:06:21 2009 @@ -624,10 +624,11 @@ SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max) { - if (rtp_session->missed_count >= max) + if (rtp_session->missed_count >= max) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "new max missed packets(%d->%d) greater than current missed packets(%d). RTP will timeout.\n", - rtp_session->missed_count, max, rtp_session->missed_count); + "new max missed packets(%d->%d) greater than current missed packets(%d). RTP will timeout.\n", + rtp_session->missed_count, max, rtp_session->missed_count); + } rtp_session->max_missed_packets = max; } From silik0n at freeswitch.org Wed Mar 18 18:55:58 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 20:55:58 -0500 Subject: [Freeswitch-svn] [commit] r12663 - freeswitch/trunk/scripts/contrib/swk/php/xml_curl Message-ID: Author: silik0n Date: Wed Mar 18 20:55:58 2009 New Revision: 12663 Log: fix user groups Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php Wed Mar 18 20:55:58 2009 @@ -142,6 +142,13 @@ return $results; } + public function getDirGroupsByDomianUidByUserUid($domain_uid, $user_uid){ + $query = sprintf("select a.uid as groupUid, a.name as groupName, b.uid as usersUid from groups as a, group_members as b where a.uid = b.groups_uid and b.domains_uid = %s and b.users_uid = %s", $domain_uid, $user_uid) ; + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + } /* For Emacs: * Local Variables: Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Wed Mar 18 20:55:58 2009 @@ -19,6 +19,7 @@ $key_value="192.168.1.140"; $user="1000"; */ + if ($section == "directory" && $tag_name == "domain" && $key_name == "name") { $db_domain = $fsd->getDirDomainbyName($key_value); } else { @@ -31,7 +32,7 @@ $db_user_settings = $fsd->getDirUser($db_user['uid']); -$db_groups = $fsd->getDirGroups($db_domain['uid']); +$db_groups = $fsd->getDirGroupsByDomianUidByUserUid($db_domain['uid'], $db_user['uid']); printf(" \n"); printf(" \n"); @@ -54,18 +55,14 @@ printf(" \n"); printf(" \n"); printf(" \n"); -/* This is Broken need to talk to someone about this part... maybe I should load this at boot time instead foreach($db_groups as $db_group){ - $db_members = $fsd->getDirGroup($db_group['uid']); - printf(" \n", $db_group['name']); + printf(" \n", $db_group['groupName']); printf(" \n"); - foreach($db_members['members'] as $db_member){ - printf(" \n", $db_member['usersUsername']); - } + printf(" \n", $user); printf(" \n"); printf(" \n"); } -*/ + printf(" \n"); printf(" \n"); printf(" \n"); From silik0n at freeswitch.org Wed Mar 18 19:31:03 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 21:31:03 -0500 Subject: [Freeswitch-svn] [commit] r12664 - freeswitch/trunk/scripts/contrib/swk/sql Message-ID: Author: silik0n Date: Wed Mar 18 21:31:03 2009 New Revision: 12664 Log: consistancy Modified: freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql Modified: freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql (original) +++ freeswitch/trunk/scripts/contrib/swk/sql/shipment.mysql.sql Wed Mar 18 21:31:03 2009 @@ -243,13 +243,13 @@ DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `uid` int(11) NOT NULL auto_increment, - `domain_uid` int(11) NOT NULL, + `domains_uid` int(11) NOT NULL, `username` varchar(64) NOT NULL, `mailbox` varchar(64) default NULL, `cidr` varchar(32) default NULL, `enabled` tinyint(1) NOT NULL default '1', PRIMARY KEY (`uid`), - KEY `domain_uid` (`domain_uid`,`username`,`mailbox`) + KEY `domain_uid` (`domains_uid`,`username`,`mailbox`) ) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1; -- From silik0n at freeswitch.org Wed Mar 18 19:34:55 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 21:34:55 -0500 Subject: [Freeswitch-svn] [commit] r12665 - freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src Message-ID: Author: silik0n Date: Wed Mar 18 21:34:55 2009 New Revision: 12665 Log: unscrew a couple of events hitting the wrong methods, fix non-working refresh buttons Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Wed Mar 18 21:34:55 2009 @@ -4,6 +4,7 @@ @@ -286,7 +292,7 @@ - + @@ -338,7 +344,7 @@ - + @@ -368,21 +374,21 @@
- - + - - + + From mrene at freeswitch.org Wed Mar 18 21:11:52 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 23:11:52 -0500 Subject: [Freeswitch-svn] [commit] r12666 - freeswitch/trunk/src/mod/applications/mod_dptools Message-ID: Author: mrene Date: Wed Mar 18 23:11:51 2009 New Revision: 12666 Log: Add Menu-Name param to ivr menu xml_locate function Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Wed Mar 18 23:11:51 2009 @@ -1156,18 +1156,20 @@ { switch_channel_t *channel = switch_core_session_get_channel(session); switch_event_t *params; + const char *name = (const char*)data; if (channel) { switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL; /* Open the config from the xml registry */ switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Menu-Name", name); switch_assert(params); switch_channel_event_set_data(channel, params); if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, params)) != NULL) { if ((xml_menus = switch_xml_child(cfg, "menus"))) { - xml_menu = switch_xml_find_child(xml_menus, "menu", "name", (char *) data); + xml_menu = switch_xml_find_child(xml_menus, "menu", "name", name); /* if the menu was found */ if (xml_menu != NULL) { @@ -1182,7 +1184,7 @@ && switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus, xml_menu) == SWITCH_STATUS_SUCCESS) { switch_xml_free(cxml); cxml = NULL; - switch_ivr_menu_execute(session, menu_stack, (char *) data, NULL); + switch_ivr_menu_execute(session, menu_stack, (char*)name, NULL); switch_ivr_menu_stack_free(menu_stack); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu\n"); From mrene at freeswitch.org Wed Mar 18 21:15:14 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Wed, 18 Mar 2009 23:15:14 -0500 Subject: [Freeswitch-svn] [commit] r12667 - freeswitch/trunk/src/mod/applications/mod_dptools Message-ID: Author: mrene Date: Wed Mar 18 23:15:14 2009 New Revision: 12667 Log: tweaqk Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Wed Mar 18 23:15:14 2009 @@ -1163,8 +1163,8 @@ /* Open the config from the xml registry */ switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); - switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Menu-Name", name); switch_assert(params); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Menu-Name", name); switch_channel_event_set_data(channel, params); if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, params)) != NULL) { From anthm at freeswitch.org Thu Mar 19 09:20:43 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 11:20:43 -0500 Subject: [Freeswitch-svn] [commit] r12668 - freeswitch/trunk/patches Message-ID: Author: anthm Date: Thu Mar 19 11:20:43 2009 New Revision: 12668 Log: update Modified: freeswitch/trunk/patches/pa.diff Modified: freeswitch/trunk/patches/pa.diff ============================================================================== --- freeswitch/trunk/patches/pa.diff (original) +++ freeswitch/trunk/patches/pa.diff Thu Mar 19 11:20:43 2009 @@ -195,60 +195,60 @@ + bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes); + numBytes -= bytesWritten; + p += bytesWritten; -+ ++ + if (numBytes > 0) { + PaUtil_FlushRingBuffer(&aStream->outFIFO); + return 0; } return numFrames; } -@@ -171,32 +169,28 @@ +@@ -170,31 +168,32 @@ + long bytesRead = 0; char *p = (char *) data; long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames; ++ int max = 5000; - for (;;) { - avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); -+ switch_core_timer_next(timer); -+ -+ avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); - +- - if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { - break; - } -+ if (avail >= neededBytes * 6) { -+ PaUtil_FlushRingBuffer(&aStream->inFIFO); -+ avail = 0; -+ } ++ switch_core_timer_next(timer); -- if (avail >= neededBytes * 6) { -- PaUtil_FlushRingBuffer(&aStream->inFIFO); -- avail = 0; ++ while(totalBytes < neededBytes && --max > 0) { ++ ++ avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); ++ //printf("AVAILABLE BYTES %ld pass %d\n", avail, 5000 - max); + if (avail >= neededBytes * 6) { + PaUtil_FlushRingBuffer(&aStream->inFIFO); + avail = 0; - } -+ bytesRead = 0; ++ } else { - bytesRead = 0; -- ++ bytesRead = 0; ++ ++ if (totalBytes < neededBytes && avail >= neededBytes) { ++ bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); ++ totalBytes += bytesRead; ++ } + - if (totalBytes < neededBytes && avail >= neededBytes) { - bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); - totalBytes += bytesRead; -- } ++ if (bytesRead) { ++ p += bytesRead; ++ } else { ++ switch_cond_next(); ++ } + } - - if (bytesRead) { - p += bytesRead; - } else { - switch_cond_next(); - } -+ if (totalBytes < neededBytes && avail >= neededBytes) { -+ bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); -+ totalBytes += bytesRead; } -+ if (bytesRead) { -+ p += bytesRead; -+ } else { -+ switch_cond_next(); -+ } -+ return totalBytes / aStream->bytesPerFrame; - } - From anthm at freeswitch.org Thu Mar 19 11:30:56 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 13:30:56 -0500 Subject: [Freeswitch-svn] [commit] r12669 - in freeswitch/trunk/src: . mod/endpoints/mod_portaudio Message-ID: Author: anthm Date: Thu Mar 19 13:30:56 2009 New Revision: 12669 Log: fix audio issue in portaudio Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c freeswitch/trunk/src/switch_rtp.c Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Thu Mar 19 13:30:56 2009 @@ -124,7 +124,8 @@ private_t *call_list; int ring_interval; GFLAGS flags; - switch_timer_t timer; + switch_timer_t read_timer; + switch_timer_t write_timer; switch_timer_t hold_timer; int dual_streams; time_t deactivate_timer; @@ -249,7 +250,7 @@ } while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { - switch_size_t olen = globals.timer.samples; + switch_size_t olen = globals.read_timer.samples; if (switch_micro_time_now() - last >= waitsec) { char buf[512]; @@ -268,7 +269,7 @@ } if (ring_file) { - if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) { + if (switch_core_timer_next(&globals.read_timer) != SWITCH_STATUS_SUCCESS) { switch_core_file_close(&fh); break; } @@ -279,7 +280,7 @@ } if (globals.ring_stream) { - WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.timer); + WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.write_timer); } } else { switch_yield(10000); @@ -355,8 +356,12 @@ switch_core_codec_destroy(&globals.write_codec); } - if (globals.timer.timer_interface) { - switch_core_timer_destroy(&globals.timer); + if (globals.read_timer.timer_interface) { + switch_core_timer_destroy(&globals.read_timer); + } + + if (globals.write_timer.timer_interface) { + switch_core_timer_destroy(&globals.write_timer); } if (globals.hold_timer.timer_interface) { @@ -597,14 +602,13 @@ switch_mutex_lock(globals.device_lock); samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, - globals.read_codec.implementation->samples_per_packet, &globals.timer); + globals.read_codec.implementation->samples_per_packet, &globals.read_timer); switch_mutex_unlock(globals.device_lock); if (samples) { globals.read_frame.datalen = samples * 2; globals.read_frame.samples = samples; - //switch_core_timer_check(&globals.timer, SWITCH_TRUE); *frame = &globals.read_frame; if (!switch_test_flag((&globals), GFLAG_MOUTH)) { @@ -649,7 +653,7 @@ if (globals.audio_stream) { if (switch_test_flag((&globals), GFLAG_EAR)) { - WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &globals.timer); + WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &globals.write_timer); } status = SWITCH_STATUS_SUCCESS; } @@ -1278,8 +1282,12 @@ destroy_codecs(); } - if (globals.timer.timer_interface) { - switch_core_timer_sync(&globals.timer); + if (globals.read_timer.timer_interface) { + switch_core_timer_sync(&globals.read_timer); + } + + if (globals.write_timer.timer_interface) { + switch_core_timer_sync(&globals.write_timer); } if (globals.audio_stream) { @@ -1310,13 +1318,26 @@ } } - if (!globals.timer.timer_interface) { - if (switch_core_timer_init(&globals.timer, + if (!globals.read_timer.timer_interface) { + if (switch_core_timer_init(&globals.read_timer, + globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, + module_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); + return SWITCH_STATUS_FALSE; + } + } + + + if (!globals.write_timer.timer_interface) { + if (switch_core_timer_init(&globals.write_timer, globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, module_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); switch_core_codec_destroy(&globals.read_codec); switch_core_codec_destroy(&globals.write_codec); + switch_core_timer_destroy(&globals.read_timer); return SWITCH_STATUS_FALSE; } } @@ -1328,7 +1349,8 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n"); switch_core_codec_destroy(&globals.read_codec); switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); + switch_core_timer_destroy(&globals.read_timer); + switch_core_timer_destroy(&globals.write_timer); return SWITCH_STATUS_FALSE; } } @@ -1366,7 +1388,8 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device\n"); switch_core_codec_destroy(&globals.read_codec); switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); + switch_core_timer_destroy(&globals.read_timer); + switch_core_timer_destroy(&globals.write_timer); switch_core_timer_destroy(&globals.hold_timer); return SWITCH_STATUS_FALSE; } @@ -1963,8 +1986,8 @@ playfile, seconds, samples, globals.read_codec.implementation->actual_samples_per_second); while (switch_core_file_read(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) { - WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.timer); - switch_core_timer_next(&globals.timer); + WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.read_timer); + switch_core_timer_next(&globals.read_timer); samples -= (int) olen; if (samples <= 0) { break; @@ -1993,8 +2016,8 @@ int i; for(i = 0; i < 400; i++) { if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, - globals.read_codec.implementation->samples_per_packet, &globals.timer))) { - WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &globals.timer); + globals.read_codec.implementation->samples_per_packet, &globals.read_timer))) { + WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &globals.write_timer); success = 1; } switch_yield(10000); Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c Thu Mar 19 13:30:56 2009 @@ -146,17 +146,15 @@ char *p = (char *) data; long numBytes = aStream->bytesPerFrame * numFrames; - while (numBytes > 0) { - bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes); - numBytes -= bytesWritten; - p += bytesWritten; - if (numBytes > 0) { - if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { - PaUtil_FlushRingBuffer(&aStream->outFIFO); - return 0; - } - switch_cond_next(); - } + switch_core_timer_next(timer); + + bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes); + numBytes -= bytesWritten; + p += bytesWritten; + + if (numBytes > 0) { + PaUtil_FlushRingBuffer(&aStream->outFIFO); + return 0; } return numFrames; } @@ -170,30 +168,31 @@ long bytesRead = 0; char *p = (char *) data; long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames; + int max = 5000; - for (;;) { - avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); - - if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { - break; - } + switch_core_timer_next(timer); + + while(totalBytes < neededBytes && --max > 0) { + avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); + //printf("AVAILABLE BYTES %ld pass %d\n", avail, 5000 - max); if (avail >= neededBytes * 6) { PaUtil_FlushRingBuffer(&aStream->inFIFO); avail = 0; - } - - bytesRead = 0; + } else { - if (totalBytes < neededBytes && avail >= neededBytes) { - bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); - totalBytes += bytesRead; - } + bytesRead = 0; + + if (totalBytes < neededBytes && avail >= neededBytes) { + bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); + totalBytes += bytesRead; + } - if (bytesRead) { - p += bytesRead; - } else { - switch_cond_next(); + if (bytesRead) { + p += bytesRead; + } else { + switch_cond_next(); + } } } Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Thu Mar 19 13:30:56 2009 @@ -1990,12 +1990,12 @@ } if (rtp_session->timer.interval && - (rtp_session->timer.samplecount - rtp_session->last_write_samplecount) > rtp_session->samples_per_interval * 2) { + (rtp_session->timer.samplecount - rtp_session->last_write_samplecount) > rtp_session->samples_per_interval * 10) { m++; } if (!rtp_session->timer.interval && - ((unsigned)((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet *2)) { + ((unsigned)((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet * 10)) { m++; } From anthm at freeswitch.org Thu Mar 19 18:22:40 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:22:40 -0500 Subject: [Freeswitch-svn] [commit] r12670 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 19 20:22:40 2009 New Revision: 12670 Log: make -vg imply -waste so valgrind runs won't re-exec Modified: freeswitch/trunk/src/switch.c Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Thu Mar 19 20:22:40 2009 @@ -611,7 +611,7 @@ } #if defined(HAVE_SETRLIMIT) && !defined(__sun) - if (!waste) { + if (!waste && !(flags & SCF_VG)) { memset(&rlp, 0, sizeof(rlp)); getrlimit(RLIMIT_STACK, &rlp); if (rlp.rlim_max > SWITCH_THREAD_STACKSIZE) { From anthm at freeswitch.org Thu Mar 19 18:23:38 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:23:38 -0500 Subject: [Freeswitch-svn] [commit] r12671 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 19 20:23:38 2009 New Revision: 12671 Log: refactor signal_bridge Modified: freeswitch/trunk/src/switch_ivr_bridge.c Modified: freeswitch/trunk/src/switch_ivr_bridge.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_bridge.c (original) +++ freeswitch/trunk/src/switch_ivr_bridge.c Thu Mar 19 20:23:38 2009 @@ -687,6 +687,29 @@ switch_core_session_t *other_session; switch_event_t *event; + if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))) { + switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL); + } + + switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL); + + if (uuid && (other_session = switch_core_session_locate(uuid))) { + switch_channel_t *other_channel = switch_core_session_get_channel(other_session); + const char *sbv = switch_channel_get_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE); + + if (!switch_strlen_zero(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) { + + switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL); + switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL); + + if (switch_channel_up(other_channel)) { + switch_channel_hangup(other_channel, switch_channel_get_cause(channel)); + } + } + + switch_core_session_rwunlock(other_session); + } + if (switch_channel_test_flag(channel, CF_ORIGINATOR)) { switch_channel_clear_flag(channel, CF_ORIGINATOR); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) { @@ -694,29 +717,7 @@ switch_event_fire(&event); } } - - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { - switch_channel_t *other_channel = switch_core_session_get_channel(other_session); - const char *sbv = switch_channel_get_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE); - - if (!switch_strlen_zero(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) { - - switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL); - - switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL); - switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL); - - if (switch_channel_up(other_channel)) { - switch_channel_hangup(other_channel, switch_channel_get_cause(channel)); - } - } - - switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL); - - switch_core_session_rwunlock(other_session); - } - + return SWITCH_STATUS_SUCCESS; } From anthm at freeswitch.org Thu Mar 19 18:24:45 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:24:45 -0500 Subject: [Freeswitch-svn] [commit] r12672 - in freeswitch/trunk/libs/apr: include memory/unix Message-ID: Author: anthm Date: Thu Mar 19 20:24:45 2009 New Revision: 12672 Log: add apr_pool_mutex_set() to our apr to fix thread-saftey issue Modified: freeswitch/trunk/libs/apr/include/apr_pools.h freeswitch/trunk/libs/apr/memory/unix/apr_pools.c Modified: freeswitch/trunk/libs/apr/include/apr_pools.h ============================================================================== --- freeswitch/trunk/libs/apr/include/apr_pools.h (original) +++ freeswitch/trunk/libs/apr/include/apr_pools.h Thu Mar 19 20:24:45 2009 @@ -411,6 +411,17 @@ */ APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag); +#if APR_HAS_THREADS +/** + * Add a mutex to a pool to make it suitable to use from multiple threads. + * @param pool The pool to add the mutex to + * @param mutex The mutex + * @remark The mutex does not protect the destroy operation just the low level allocs. + */ +APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, + apr_thread_mutex_t *mutex); +#endif + /* * User data management @@ -435,6 +446,7 @@ * key names is a typical way to help ensure this uniqueness. * */ + APR_DECLARE(apr_status_t) apr_pool_userdata_set( const void *data, const char *key, Modified: freeswitch/trunk/libs/apr/memory/unix/apr_pools.c ============================================================================== --- freeswitch/trunk/libs/apr/memory/unix/apr_pools.c (original) +++ freeswitch/trunk/libs/apr/memory/unix/apr_pools.c Thu Mar 19 20:24:45 2009 @@ -449,7 +449,9 @@ apr_abortfunc_t abort_fn; apr_hash_t *user_data; const char *tag; - +#if APR_HAS_THREADS + apr_thread_mutex_t *user_mutex; +#endif #if !APR_POOL_DEBUG apr_memnode_t *active; apr_memnode_t *self; /* The node containing the pool itself */ @@ -471,6 +473,7 @@ #endif /* APR_POOL_DEBUG */ #ifdef NETWARE apr_os_proc_t owner_proc; + #endif /* defined(NETWARE) */ }; @@ -594,9 +597,11 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) { apr_memnode_t *active, *node; - void *mem; + void *mem = NULL; apr_size_t free_index; - +#if APR_HAS_THREADS + if (pool->user_mutex) apr_thread_mutex_lock(pool->user_mutex); +#endif size = APR_ALIGN_DEFAULT(size); active = pool->active; @@ -605,7 +610,7 @@ mem = active->first_avail; active->first_avail += size; - return mem; + goto end; } node = active->next; @@ -617,7 +622,8 @@ if (pool->abort_fn) pool->abort_fn(APR_ENOMEM); - return NULL; + mem = NULL; + goto end; } } @@ -636,7 +642,7 @@ active->free_index = (APR_UINT32_TRUNC_CAST)free_index; node = active->next; if (free_index >= node->free_index) - return mem; + goto end; do { node = node->next; @@ -646,6 +652,10 @@ list_remove(active); list_insert(active, node); + end: +#if APR_HAS_THREADS + if (pool->user_mutex) apr_thread_mutex_unlock(pool->user_mutex); +#endif return mem; } @@ -678,7 +688,9 @@ APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) { apr_memnode_t *active; - +#if APR_HAS_THREADS + if (pool->user_mutex) apr_thread_mutex_lock(pool->user_mutex); +#endif /* Destroy the subpools. The subpools will detach themselves from * this pool thus this loop is safe and easy. */ @@ -704,14 +716,27 @@ active->first_avail = pool->self_first_avail; if (active->next == active) - return; + goto end; *active->ref = NULL; allocator_free(pool->allocator, active->next); active->next = active; active->ref = &active->next; + + end: +#if APR_HAS_THREADS + if (pool->user_mutex) apr_thread_mutex_unlock(pool->user_mutex); +#endif } +#if APR_HAS_THREADS +APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, + apr_thread_mutex_t *mutex) +{ + pool->user_mutex = mutex; +} +#endif + APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) { apr_memnode_t *active; @@ -820,7 +845,9 @@ pool->subprocesses = NULL; pool->user_data = NULL; pool->tag = NULL; - +#if APR_HAS_THREADS + pool->user_mutex = NULL; +#endif #ifdef NETWARE pool->owner_proc = (apr_os_proc_t)getnlmhandle(); #endif /* defined(NETWARE) */ @@ -963,6 +990,10 @@ apr_memnode_t *active, *node; apr_size_t free_index; +#if APR_HAS_THREADS + if (pool->user_mutex) apr_thread_mutex_lock(pool->user_mutex); +#endif + ps.node = active = pool->active; ps.pool = pool; ps.vbuff.curpos = ps.node->first_avail; @@ -981,7 +1012,8 @@ pool->abort_fn(APR_ENOMEM); } - return NULL; + strp = NULL; + goto end; } } @@ -989,7 +1021,8 @@ if (pool->abort_fn) pool->abort_fn(APR_ENOMEM); - return NULL; + strp = NULL; + goto end; } strp = ps.vbuff.curpos; @@ -1006,8 +1039,8 @@ /* * Link the node in if it's a new one */ - if (!ps.got_a_new_node) - return strp; + if (!ps.got_a_new_node) + goto end; active = pool->active; node = ps.node; @@ -1025,7 +1058,7 @@ node = active->next; if (free_index >= node->free_index) - return strp; + goto end; do { node = node->next; @@ -1035,6 +1068,12 @@ list_remove(active); list_insert(active, node); + end: + +#if APR_HAS_THREADS + if (pool->user_mutex) apr_thread_mutex_unlock(pool->user_mutex); +#endif + return strp; } From anthm at freeswitch.org Thu Mar 19 18:48:30 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:48:30 -0500 Subject: [Freeswitch-svn] [commit] r12673 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 19 20:48:30 2009 New Revision: 12673 Log: make port allocator more random Modified: freeswitch/trunk/src/switch_core_port_allocator.c Modified: freeswitch/trunk/src/switch_core_port_allocator.c ============================================================================== --- freeswitch/trunk/src/switch_core_port_allocator.c (original) +++ freeswitch/trunk/src/switch_core_port_allocator.c Thu Mar 19 20:48:30 2009 @@ -39,7 +39,7 @@ switch_port_t start; switch_port_t end; switch_port_t next; - switch_byte_t *track; + int8_t *track; uint32_t track_len; uint32_t track_used; switch_port_flag_t flags; @@ -118,12 +118,12 @@ int odd = switch_test_flag(alloc, SPF_ODD); switch_mutex_lock(alloc->mutex); - srand(getpid() + (unsigned) switch_epoch_time_now(NULL)); + srand((unsigned)(intptr_t)port_ptr + switch_thread_self() + switch_micro_time_now()); while (alloc->track_used < alloc->track_len) { uint32_t index; uint32_t tries = 0; - + /* randomly pick a port */ index = rand() % alloc->track_len; @@ -131,6 +131,9 @@ while (alloc->track[index] && tries < alloc->track_len) { tries++; + if (alloc->track[index] < 0) { + alloc->track[index]++; + } if (++index >= alloc->track_len) { index = 0; } @@ -179,8 +182,8 @@ } switch_mutex_lock(alloc->mutex); - if (alloc->track[index]) { - alloc->track[index] = 0; + if (alloc->track[index] > 0) { + alloc->track[index] = -4; alloc->track_used--; status = SWITCH_STATUS_SUCCESS; } From anthm at freeswitch.org Thu Mar 19 18:50:50 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:50:50 -0500 Subject: [Freeswitch-svn] [commit] r12674 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 19 20:50:50 2009 New Revision: 12674 Log: make switch_channel_get_variable strdup so the pointer returned is safe and clean up the state locking Modified: freeswitch/trunk/src/switch_channel.c Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Thu Mar 19 20:50:50 2009 @@ -506,6 +506,9 @@ v = switch_core_get_variable(varname); } } + + if (v) v = switch_core_session_strdup(channel->session, v); + switch_mutex_unlock(channel->profile_mutex); return v; @@ -528,6 +531,8 @@ } } + if (val) val = switch_core_session_strdup(channel->session, val); + return val; } @@ -870,9 +875,7 @@ switch_channel_state_t state; switch_assert(channel != NULL); - switch_mutex_lock(channel->state_mutex); state = channel->state; - switch_mutex_unlock(channel->state_mutex); return state; } @@ -882,9 +885,7 @@ switch_channel_state_t state; switch_assert(channel != NULL); - switch_mutex_lock(channel->state_mutex); state = channel->running_state; - switch_mutex_unlock(channel->state_mutex); return state; } @@ -1201,9 +1202,8 @@ if (ok) { switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "(%s) State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]); - switch_mutex_lock(channel->state_mutex); + channel->state = state; - switch_mutex_unlock(channel->state_mutex); if (state == CS_HANGUP && !channel->hangup_cause) { channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING; @@ -1228,7 +1228,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *channel, switch_event_t *event) { switch_caller_profile_t *caller_profile, *originator_caller_profile = NULL, *originatee_caller_profile = NULL; - switch_codec_t *codec; + switch_codec_implementation_t impl = {0}; char state_num[25]; switch_mutex_lock(channel->profile_mutex); @@ -1258,14 +1258,18 @@ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Answer-State", "ringing"); } - if ((codec = switch_core_session_get_read_codec(channel->session)) && codec->implementation) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", switch_str_nil(codec->implementation->iananame)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", codec->implementation->actual_samples_per_second); + switch_core_session_get_read_impl(channel->session, &impl); + + if (impl.iananame) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", impl.iananame); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", impl.actual_samples_per_second); } - if ((codec = switch_core_session_get_write_codec(channel->session)) && codec->implementation) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Name", switch_str_nil(codec->implementation->iananame)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Rate", "%u", codec->implementation->actual_samples_per_second); + switch_core_session_get_write_impl(channel->session, &impl); + + if (impl.iananame) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Name", impl.iananame); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Rate", "%u", impl.actual_samples_per_second); } /* Index Caller's Profile */ @@ -1584,22 +1588,23 @@ switch_assert(channel != NULL); switch_channel_clear_flag(channel, CF_BLOCK_STATE); - - switch_mutex_lock(channel->state_mutex); - - if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { - switch_mutex_lock(channel->profile_mutex); - channel->caller_profile->times->hungup = switch_micro_time_now(); - switch_mutex_unlock(channel->profile_mutex); - } - - switch_channel_stop_broadcast(channel); - + if (channel->state < CS_HANGUP) { switch_event_t *event; switch_channel_state_t last_state = channel->state; + if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { + switch_mutex_lock(channel->profile_mutex); + channel->caller_profile->times->hungup = switch_micro_time_now(); + switch_mutex_unlock(channel->profile_mutex); + } + + switch_channel_stop_broadcast(channel); + + switch_mutex_lock(channel->state_mutex); channel->state = CS_HANGUP; + switch_mutex_unlock(channel->state_mutex); + channel->hangup_cause = hangup_cause; switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause)); @@ -1620,8 +1625,6 @@ } - switch_mutex_unlock(channel->state_mutex); - return channel->state; } From anthm at freeswitch.org Thu Mar 19 18:51:50 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:51:50 -0500 Subject: [Freeswitch-svn] [commit] r12675 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 19 20:51:50 2009 New Revision: 12675 Log: use apr_pool_mutex_set to make pools thread safe Modified: freeswitch/trunk/src/switch_core_memory.c Modified: freeswitch/trunk/src/switch_core_memory.c ============================================================================== --- freeswitch/trunk/src/switch_core_memory.c (original) +++ freeswitch/trunk/src/switch_core_memory.c Thu Mar 19 20:51:50 2009 @@ -39,13 +39,17 @@ //#define DEBUG_ALLOC2 //#define DESTROY_POOLS //#define INSTANTLY_DESTROY_POOLS -/*#define LOCK_MORE*/ +//#define LOCK_MORE +//#define USE_MEM_LOCK +//#define SWITCH_POOL_RECYCLE #ifndef SWITCH_POOL_RECYCLE #define PER_POOL_LOCK 1 #endif static struct { +#ifdef USE_MEM_LOCK switch_mutex_t *mem_lock; +#endif switch_queue_t *pool_queue; /* 8 ball break */ switch_queue_t *pool_recycle_queue; switch_memory_pool_t *memory_pool; @@ -69,8 +73,10 @@ switch_assert(session->pool != NULL); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif #ifdef DEBUG_ALLOC if (memory > 500) @@ -83,8 +89,10 @@ memset(ptr, 0, memory); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return ptr; } @@ -98,8 +106,10 @@ switch_assert(memory_manager.memory_pool != NULL); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif #ifdef DEBUG_ALLOC switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %d\n", (int) memory); @@ -111,8 +121,10 @@ memset(ptr, 0, memory); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return ptr; } @@ -127,8 +139,10 @@ return NULL; #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif len = strlen(todup) + 1; duped = apr_pstrmemdup(memory_manager.memory_pool, todup, len); @@ -139,8 +153,10 @@ #endif #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return duped; } @@ -151,8 +167,10 @@ char *result = NULL; #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif switch_assert(session != NULL); switch_assert(session->pool != NULL); @@ -163,8 +181,10 @@ va_end(ap); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return result; } @@ -177,8 +197,10 @@ switch_assert(pool != NULL); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif va_start(ap, fmt); @@ -187,8 +209,10 @@ va_end(ap); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return result; } @@ -196,31 +220,37 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t *session, const char *todup, const char *file, const char *func, int line) { char *duped = NULL; - switch_size_t len; switch_assert(session != NULL); switch_assert(session->pool != NULL); +#ifdef DEBUG_ALLOC + switch_size_t len; +#endif if (!todup) { return NULL; } #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif - len = strlen(todup) + 1; + #ifdef DEBUG_ALLOC + len = strlen(todup); if (len > 500) switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %d\n", (int) len); #endif - duped = apr_pstrmemdup(session->pool, todup, len); + duped = strdup(todup); switch_assert(duped != NULL); - - + #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return duped; } @@ -235,8 +265,10 @@ return NULL; } #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif len = strlen(todup) + 1; @@ -249,8 +281,10 @@ switch_assert(duped != NULL); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return duped; } @@ -275,7 +309,9 @@ void *pop = NULL; #endif +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); +#endif switch_assert(pool != NULL); #ifndef PER_POOL_LOCK @@ -286,21 +322,22 @@ #ifdef PER_POOL_LOCK if ((apr_allocator_create(&my_allocator)) != APR_SUCCESS) { - return SWITCH_STATUS_MEMERR; + abort(); } if ((apr_pool_create_ex(pool, NULL, NULL, my_allocator)) != APR_SUCCESS) { - apr_allocator_destroy(my_allocator); - my_allocator = NULL; - return SWITCH_STATUS_MEMERR; + abort(); } - if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_DEFAULT, *pool)) != APR_SUCCESS) { - return SWITCH_STATUS_MEMERR; + if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED, *pool)) != APR_SUCCESS) { + abort(); } apr_allocator_mutex_set(my_allocator, my_mutex); apr_allocator_owner_set(my_allocator, *pool); + + apr_pool_mutex_set(*pool, my_mutex); + #else apr_pool_create(pool, NULL); switch_assert(*pool != NULL); @@ -313,7 +350,11 @@ #endif tmp = switch_core_sprintf(*pool, "%s:%d", func, line); apr_pool_tag(*pool, tmp); + + +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); +#endif return SWITCH_STATUS_SUCCESS; } @@ -327,10 +368,22 @@ #endif #ifdef INSTANTLY_DESTROY_POOLS +#ifdef USE_MEM_LOCK + switch_mutex_lock(memory_manager.mem_lock); +#endif apr_pool_destroy(*pool); +#ifdef USE_MEM_LOCK + switch_mutex_unlock(memory_manager.mem_lock); +#endif #else if ((memory_manager.pool_thread_running != 1) || (switch_queue_push(memory_manager.pool_queue, *pool) != SWITCH_STATUS_SUCCESS)) { +#ifdef USE_MEM_LOCK + switch_mutex_lock(memory_manager.mem_lock); +#endif apr_pool_destroy(*pool); +#ifdef USE_MEM_LOCK + switch_mutex_unlock(memory_manager.mem_lock); +#endif } #endif @@ -346,8 +399,10 @@ switch_assert(pool != NULL); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); #endif +#endif #ifdef DEBUG_ALLOC if (memory > 500) @@ -360,8 +415,10 @@ memset(ptr, 0, memory); #ifdef LOCK_MORE +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); #endif +#endif return ptr; } @@ -379,7 +436,13 @@ if (!pool) { break; } +#ifdef USE_MEM_LOCK + switch_mutex_lock(memory_manager.mem_lock); +#endif apr_pool_destroy(pool); +#ifdef USE_MEM_LOCK + switch_mutex_unlock(memory_manager.mem_lock); +#endif } #endif return; @@ -396,7 +459,9 @@ int x = len, done = 0; switch_yield(1000000); +#ifdef USE_MEM_LOCK switch_mutex_lock(memory_manager.mem_lock); +#endif while (x > 0) { void *pop = NULL; if (switch_queue_pop(memory_manager.pool_queue, &pop) != SWITCH_STATUS_SUCCESS || !pop) { @@ -405,16 +470,31 @@ } #if defined(PER_POOL_LOCK) || defined(DESTROY_POOLS) +#ifdef USE_MEM_LOCK + switch_mutex_lock(memory_manager.mem_lock); +#endif apr_pool_destroy(pop); +#ifdef USE_MEM_LOCK + switch_mutex_unlock(memory_manager.mem_lock); +#endif #else apr_pool_clear(pop); if (switch_queue_trypush(memory_manager.pool_recycle_queue, pop) != SWITCH_STATUS_SUCCESS) { +#ifdef USE_MEM_LOCK + switch_mutex_lock(memory_manager.mem_lock); +#endif apr_pool_destroy(pop); +#ifdef USE_MEM_LOCK + switch_mutex_unlock(memory_manager.mem_lock); +#endif + } #endif x--; } +#ifdef USE_MEM_LOCK switch_mutex_unlock(memory_manager.mem_lock); +#endif if (done) { goto done; } @@ -429,8 +509,15 @@ { void *pop = NULL; while (switch_queue_trypop(memory_manager.pool_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { +#ifdef USE_MEM_LOCK + switch_mutex_lock(memory_manager.mem_lock); +#endif apr_pool_destroy(pop); pop = NULL; +#ifdef USE_MEM_LOCK + switch_mutex_unlock(memory_manager.mem_lock); +#endif + } } @@ -439,14 +526,17 @@ return NULL; } +#ifndef INSTANTLY_DESTROY_POOLS static switch_thread_t *pool_thread_p = NULL; +#endif void switch_core_memory_stop(void) { +#ifndef INSTANTLY_DESTROY_POOLS switch_status_t st; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n"); -#ifndef INSTANTLY_DESTROY_POOLS + memory_manager.pool_thread_running = -1; switch_thread_join(&st, pool_thread_p); @@ -490,7 +580,9 @@ switch_assert(memory_manager.memory_pool != NULL); #endif +#ifdef USE_MEM_LOCK switch_mutex_init(&memory_manager.mem_lock, SWITCH_MUTEX_NESTED, memory_manager.memory_pool); +#endif #ifdef INSTANTLY_DESTROY_POOLS { From anthm at freeswitch.org Thu Mar 19 18:52:53 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 20:52:53 -0500 Subject: [Freeswitch-svn] [commit] r12676 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Thu Mar 19 20:52:53 2009 New Revision: 12676 Log: FSCORE-322 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Mar 19 20:52:53 2009 @@ -303,14 +303,14 @@ switch_core_session_rwunlock(a_session); } - - if (tech_pvt->nh && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { char reason[128] = ""; switch_stream_handle_t stream = { 0 }; switch_event_header_t *hi; char *bye_headers = NULL; + sofia_set_flag_locked(tech_pvt, TFLAG_BYE); + SWITCH_STANDARD_STREAM(stream); if ((hi = switch_channel_variable_first(channel))) { for (; hi; hi = hi->next) { @@ -337,7 +337,7 @@ switch_snprintf(reason, sizeof(reason), "FreeSWITCH;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause)); } - if (sofia_test_flag(tech_pvt, TFLAG_ANS)) { + if (switch_channel_test_flag(channel, CF_ANSWERED)) { if (!tech_pvt->got_bye) { switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye"); } @@ -347,11 +347,12 @@ TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END()); } else { - if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND)) { + if (switch_channel_test_flag(channel, CF_OUTBOUND)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel)); if (!tech_pvt->got_bye) { switch_channel_set_variable(channel, "sip_hangup_disposition", "send_cancel"); } + nua_cancel(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), @@ -362,14 +363,16 @@ if (!tech_pvt->got_bye) { switch_channel_set_variable(channel, "sip_hangup_disposition", "send_refuse"); } - nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), - SIPTAG_REASON_STR(reason), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), - TAG_END()); + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), + SIPTAG_REASON_STR(reason), + TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_END()); + } } } - sofia_set_flag(tech_pvt, TFLAG_BYE); + switch_safe_free(stream.data); } @@ -431,7 +434,7 @@ is_proxy = (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)); if (b_sdp && is_proxy) { - tech_pvt->local_sdp_str = switch_core_session_strdup(session, b_sdp); + sofia_glue_tech_set_local_sdp(tech_pvt, b_sdp, SWITCH_TRUE); if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { sofia_glue_tech_patch_sdp(tech_pvt); @@ -443,13 +446,16 @@ /* This if statement check and handles the 3pcc proxy mode */ if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) { /* Send the 200 OK */ - nua_respond(tech_pvt->nh, SIP_200_OK, - SIPTAG_CONTACT_STR(tech_pvt->profile->url), - SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), - SOATAG_REUSE_REJECTED(1), - SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n"); - + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_respond(tech_pvt->nh, SIP_200_OK, + SIPTAG_CONTACT_STR(tech_pvt->profile->url), + SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), + SOATAG_REUSE_REJECTED(1), + SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n"); + } + /* Unlock the session signal to allow the ack to make it in */ // Maybe we should timeout? switch_mutex_unlock(tech_pvt->sofia_mutex); @@ -520,15 +526,16 @@ switch_channel_set_variable(channel, "sip_nat_detected", "true"); } - - nua_respond(tech_pvt->nh, SIP_200_OK, - NUTAG_AUTOANSWER(0), - TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)), - NUTAG_SESSION_TIMER(session_timeout), - SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), - SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); - sofia_set_flag_locked(tech_pvt, TFLAG_ANS); + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_respond(tech_pvt->nh, SIP_200_OK, + NUTAG_AUTOANSWER(0), + TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)), + NUTAG_SESSION_TIMER(session_timeout), + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), + SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); + sofia_set_flag_locked(tech_pvt, TFLAG_ANS); + } return SWITCH_STATUS_SUCCESS; } @@ -976,7 +983,7 @@ private_object_t *tech_pvt = switch_core_session_get_private(session); switch_status_t status = SWITCH_STATUS_SUCCESS; - if (switch_channel_down(channel) || !tech_pvt) { + if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) { status = SWITCH_STATUS_FALSE; goto end; } @@ -1010,11 +1017,11 @@ default: break; } - + /* ones that do need to lock sofia mutex */ switch_mutex_lock(tech_pvt->sofia_mutex); - if (switch_channel_down(channel) || !tech_pvt) { + if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) { status = SWITCH_STATUS_FALSE; goto end_lock; } @@ -1046,11 +1053,13 @@ sofia_glue_set_local_sdp(tech_pvt, ip, atoi(port), msg->string_arg, 1); } - nua_respond(tech_pvt->nh, SIP_200_OK, - SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), - SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); - switch_channel_mark_answered(channel); + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_respond(tech_pvt->nh, SIP_200_OK, + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), + SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); + switch_channel_mark_answered(channel); + } } break; case SWITCH_MESSAGE_INDICATE_NOMEDIA: @@ -1061,7 +1070,8 @@ const char *ip = NULL, *port = NULL; switch_channel_set_flag(channel, CF_PROXY_MODE); - tech_pvt->local_sdp_str = NULL; + sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE); + if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { other_channel = switch_core_session_get_channel(other_session); @@ -1085,7 +1095,8 @@ { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n", switch_channel_get_name(channel), msg->string_arg); - tech_pvt->local_sdp_str = switch_core_session_strdup(session, msg->string_arg); + sofia_glue_tech_set_local_sdp(tech_pvt, msg->string_arg, SWITCH_TRUE); + sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE); sofia_glue_do_invite(session); } @@ -1112,7 +1123,7 @@ uint32_t send_invite = 1; switch_channel_clear_flag(channel, CF_PROXY_MODE); - tech_pvt->local_sdp_str = NULL; + sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE); if (!switch_channel_media_ready(channel)) { if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { @@ -1175,7 +1186,7 @@ break; case SWITCH_MESSAGE_INDICATE_REDIRECT: if (!switch_strlen_zero(msg->string_arg)) { - if (!switch_channel_test_flag(channel, CF_ANSWERED)) { + if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting to %s\n", msg->string_arg); nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END()); sofia_set_flag_locked(tech_pvt, TFLAG_BYE); @@ -1212,7 +1223,7 @@ if (msg->numeric_arg || msg->string_arg) { int code = msg->numeric_arg; const char *reason = NULL; - + if (code) { reason = msg->string_arg; } else { @@ -1229,6 +1240,12 @@ code = 488; } + if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) { + if (sofia_test_flag(tech_pvt, TFLAG_BYE)) { + goto end_lock; + } + } + if (switch_strlen_zero(reason) && code != 407 && code != 302) { reason = sip_status_phrase(code); if (switch_strlen_zero(reason)) { @@ -1260,11 +1277,12 @@ } } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason); - nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), - SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL), - TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); - if (!switch_channel_test_flag(channel, CF_ANSWERED)) { + if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason); + nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), + SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL), + TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); + sofia_set_flag_locked(tech_pvt, TFLAG_BYE); } } else if (code == 302 && !switch_strlen_zero(msg->string_arg)) { @@ -1274,31 +1292,30 @@ msg->string_arg = p; switch_core_session_receive_message(session, msg); goto end_lock; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason); - - if (!switch_strlen_zero(((char *) msg->pointer_arg))) { - tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, (char *) msg->pointer_arg); - if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { - sofia_glue_tech_patch_sdp(tech_pvt); - sofia_glue_tech_proxy_remote_addr(tech_pvt); + } else if (!switch_channel_test_flag(channel, CF_ANSWERED)) { + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason); + if (!switch_strlen_zero(((char *) msg->pointer_arg))) { + sofia_glue_tech_set_local_sdp(tech_pvt, (char *) msg->pointer_arg, SWITCH_TRUE); + + if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + sofia_glue_tech_patch_sdp(tech_pvt); + sofia_glue_tech_proxy_remote_addr(tech_pvt); + } + nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), + SOATAG_REUSE_REJECTED(1), + SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); + } else { + nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END()); } - nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), - SOATAG_REUSE_REJECTED(1), - SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); - } else { - nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END()); - } - if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) { - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); } } } break; case SWITCH_MESSAGE_INDICATE_RINGING: - if (!switch_channel_test_flag(channel, CF_RING_READY) && + if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) { nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END()); switch_channel_mark_ring_ready(channel); @@ -1321,10 +1338,12 @@ if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { const char *sdp = NULL; if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) { - tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp); + sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE); } if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + sofia_glue_tech_patch_sdp(tech_pvt); + if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { status = SWITCH_STATUS_FALSE; goto end_lock; @@ -1369,16 +1388,17 @@ switch_channel_set_variable(channel, "sip_nat_detected", "true"); } - - nua_respond(tech_pvt->nh, - SIP_183_SESSION_PROGRESS, - NUTAG_AUTOANSWER(0), - TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)), - SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_REUSE_REJECTED(1), - SOATAG_ORDERED_USER(1), - SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), - SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_END()); + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_respond(tech_pvt->nh, + SIP_183_SESSION_PROGRESS, + NUTAG_AUTOANSWER(0), + TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)), + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_REUSE_REJECTED(1), + SOATAG_ORDERED_USER(1), + SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), + SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_END()); + } } } break; @@ -1392,6 +1412,10 @@ end: + if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) { + status = SWITCH_STATUS_FALSE; + } + return status; } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Thu Mar 19 20:52:53 2009 @@ -510,8 +510,13 @@ char *rm_fmtp; char *fmtp_out; char *remote_sdp_str; + int crypto_tag; + unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN]; + unsigned char remote_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN]; + switch_rtp_crypto_key_type_t crypto_send_type; + switch_rtp_crypto_key_type_t crypto_recv_type; + switch_rtp_crypto_key_type_t crypto_type; char *local_sdp_str; - char *orig_local_sdp_str; char *dest; char *dest_to; char *key; @@ -533,12 +538,6 @@ char *stun_ip; switch_port_t stun_port; uint32_t stun_flags; - int crypto_tag; - unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN]; - unsigned char remote_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN]; - switch_rtp_crypto_key_type_t crypto_send_type; - switch_rtp_crypto_key_type_t crypto_recv_type; - switch_rtp_crypto_key_type_t crypto_type; unsigned long rm_rate; switch_payload_t pt; switch_mutex_t *flag_mutex; @@ -837,3 +836,4 @@ */ int sofia_get_loglevel(const char *name); sofia_cid_type_t sofia_cid_name2type(const char *name); +void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu Mar 19 20:52:53 2009 @@ -342,8 +342,21 @@ } else if (!switch_strlen_zero(sofia_private->uuid)) { if ((session = switch_core_session_locate(sofia_private->uuid))) { tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt); - channel = switch_core_session_get_channel(tech_pvt->session); + channel = switch_core_session_get_channel(session); + if (tech_pvt) { + + if (status >= 300) { + sofia_set_flag_locked(tech_pvt, TFLAG_BYE); + } + + switch_mutex_lock(tech_pvt->sofia_mutex); + locked = 1; + } else { + switch_core_session_rwunlock(session); + return; + } + + if (status >= 180 && !*sofia_private->auth_gateway_name) { const char *gwname = switch_channel_get_variable(channel, "sip_use_gateway"); if (!switch_strlen_zero(gwname)) { @@ -369,11 +382,6 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already hungup.\n"); goto done; } - - if (tech_pvt) { - switch_mutex_lock(tech_pvt->sofia_mutex); - locked = 1; - } } else if (sofia_private && sofia_private->is_call) { sofia_private->destroy_me = 22; } @@ -542,13 +550,13 @@ sofia_reg_release_gateway(gateway); } + if (locked && tech_pvt) { + switch_mutex_unlock(tech_pvt->sofia_mutex); + } + if (session) { switch_core_session_rwunlock(session); } - - if (tech_pvt && locked) { - switch_mutex_unlock(tech_pvt->sofia_mutex); - } } void event_handler(switch_event_t *event) @@ -697,6 +705,8 @@ switch_thread_t *worker_thread; switch_status_t st; + + switch_mutex_lock(mod_sofia_globals.mutex); mod_sofia_globals.threads++; switch_mutex_unlock(mod_sofia_globals.mutex); @@ -2798,13 +2808,13 @@ if (session) { channel = switch_core_session_get_channel(session); tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - if (!tech_pvt->nh) { + + if (!tech_pvt || !tech_pvt->nh) { goto done; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n", - switch_channel_get_name(channel), nua_callstate_name(ss_state)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s][%d]\n", + switch_channel_get_name(channel), nua_callstate_name(ss_state), status); if (r_sdp) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp); @@ -2894,7 +2904,6 @@ if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) { switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp); } - switch_channel_pre_answer(other_channel); switch_core_session_rwunlock(other_session); } @@ -3071,13 +3080,13 @@ if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { switch_core_session_message_t msg = { 0 }; - + if (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) { tech_pvt->hold_laps = 1; switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp); switch_channel_clear_flag(channel, CF_PROXY_MODE); - tech_pvt->local_sdp_str = NULL; - + sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE); + if (!switch_channel_media_ready(channel)) { if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { //const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); @@ -3329,44 +3338,44 @@ tech_pvt->q850_cause = SWITCH_CAUSE_MANDATORY_IE_MISSING; } case nua_callstate_terminated: - if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); - if (sofia_test_flag(tech_pvt, TFLAG_NOHUP)) { - sofia_clear_flag_locked(tech_pvt, TFLAG_NOHUP); + if (sofia_test_flag(tech_pvt, TFLAG_NOHUP)) { + sofia_clear_flag_locked(tech_pvt, TFLAG_NOHUP); + } else if (switch_channel_up(channel)) { + int cause; + if (tech_pvt->q850_cause) { + cause = tech_pvt->q850_cause; } else { - int cause; - if (tech_pvt->q850_cause) { - cause = tech_pvt->q850_cause; - } else { - cause = sofia_glue_sip_cause_to_freeswitch(status); - } - if (status) { - switch_snprintf(st, sizeof(st), "%d", status); - switch_channel_set_variable(channel, "sip_term_status", st); - switch_snprintf(st, sizeof(st), "sip:%d", status); - switch_channel_set_variable_partner(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st); - switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st); - if (phrase) { - switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase); - } + cause = sofia_glue_sip_cause_to_freeswitch(status); + } + if (status) { + switch_snprintf(st, sizeof(st), "%d", status); + switch_channel_set_variable(channel, "sip_term_status", st); + switch_snprintf(st, sizeof(st), "sip:%d", status); + switch_channel_set_variable_partner(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st); + switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st); + if (phrase) { + switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase); } - switch_snprintf(st, sizeof(st), "%d", cause); - switch_channel_set_variable(channel, "sip_term_cause", st); - switch_channel_hangup(channel, cause); } + switch_snprintf(st, sizeof(st), "%d", cause); + switch_channel_set_variable(channel, "sip_term_cause", st); + switch_channel_hangup(channel, cause); } + + if (ss_state == nua_callstate_terminated) { if (tech_pvt->sofia_private) { tech_pvt->sofia_private = NULL; } tech_pvt->nh = NULL; - + if (nh) { nua_handle_bind(nh, NULL); nua_handle_destroy(nh); } } + break; } @@ -4616,7 +4625,7 @@ switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); } - + if (!(sofia_private = malloc(sizeof(*sofia_private)))) { abort(); } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Mar 19 20:52:53 2009 @@ -103,8 +103,7 @@ t38_options->T38VendorInfo ); - - tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf); + sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE); } void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32_t port, const char *sr, int force) @@ -392,8 +391,7 @@ } } } - - tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf); + sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE); } void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt) @@ -862,16 +860,17 @@ return new_uri; } +#define RA_PTR_LEN 512 switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt) { const char *err; - char rip[128] = ""; - char rp[128] = ""; - char rvp[128] = ""; - char *p, *ip_ptr = NULL, *port_ptr = NULL, *vid_port_ptr = NULL; + char rip[RA_PTR_LEN] = ""; + char rp[RA_PTR_LEN] = ""; + char rvp[RA_PTR_LEN] = ""; + char *p, *ip_ptr = NULL, *port_ptr = NULL, *vid_port_ptr = NULL, *pe; int x; const char *val; - + if (switch_strlen_zero(tech_pvt->remote_sdp_str)) { return SWITCH_STATUS_FALSE; } @@ -898,24 +897,34 @@ } p = ip_ptr; + pe = p + strlen(p); x = 0; - while (x < sizeof(rip) && p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'))) { + while (x < sizeof(rip) - 1 && p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'))) { rip[x++] = *p; p++; + if (p >= pe) { + return SWITCH_STATUS_FALSE; + } } p = port_ptr; x = 0; - while (x < sizeof(rp) && p && *p && (*p >= '0' && *p <= '9')) { + while (x < sizeof(rp) - 1 && p && *p && (*p >= '0' && *p <= '9')) { rp[x++] = *p; p++; + if (p >= pe) { + return SWITCH_STATUS_FALSE; + } } p = vid_port_ptr; x = 0; - while (x < sizeof(rvp) && p && *p && (*p >= '0' && *p <= '9')) { + while (x < sizeof(rvp) - 1 && p && *p && (*p >= '0' && *p <= '9')) { rvp[x++] = *p; p++; + if (p >= pe) { + return SWITCH_STATUS_FALSE; + } } if (!(*rip && *rp)) { @@ -965,12 +974,9 @@ tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port); return SWITCH_STATUS_SUCCESS; } - - } - - if (switch_rtp_ready(tech_pvt->rtp_session)) { - if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) != - SWITCH_STATUS_SUCCESS) { + + if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, + tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n", @@ -990,17 +996,19 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt) { switch_size_t len; - char *p, *q; + char *p, *q, *pe , *qe; int has_video=0,has_audio=0,has_ip=0; char port_buf[25] = ""; char vport_buf[25] = ""; + char *new_sdp; + int bad = 0; if (switch_strlen_zero(tech_pvt->local_sdp_str)) { return; } - len = strlen(tech_pvt->local_sdp_str) + 384; - + len = strlen(tech_pvt->local_sdp_str) * 2; + if (switch_stristr("sendonly", tech_pvt->local_sdp_str) || switch_stristr("0.0.0.0", tech_pvt->local_sdp_str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Skip patch on hold SDP\n"); return; @@ -1016,14 +1024,26 @@ tech_pvt->codec_ms = 20; } + new_sdp = switch_core_session_alloc(tech_pvt->session, len); switch_snprintf(port_buf, sizeof(port_buf), "%u", tech_pvt->adv_sdp_audio_port); - tech_pvt->orig_local_sdp_str = tech_pvt->local_sdp_str; - tech_pvt->local_sdp_str = switch_core_session_alloc(tech_pvt->session, len); + - p = tech_pvt->orig_local_sdp_str; - q = tech_pvt->local_sdp_str; + p = tech_pvt->local_sdp_str; + q = new_sdp; + pe = p + strlen(p); + qe = q + len - 1; while(p && *p) { + if (p >= pe) { + bad = 1; + goto end; + } + + if (q >= qe) { + bad = 2; + goto end; + } + if (tech_pvt->adv_sdp_audio_ip && !strncmp("c=IN IP", p, 7)) { strncpy(q, p, 9); p += 9; @@ -1032,19 +1052,46 @@ q += strlen(tech_pvt->adv_sdp_audio_ip); while(p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'A' && *p <= 'F') || (*p >= 'a' && *p <= 'f'))) { + if (p >= pe) { + bad = 3; + goto end; + } p++; } has_ip++; } else if (!strncmp("m=audio ", p, 8) || (!strncmp("m=image ", p, 8))) { - strncpy(q,p,8); + strncpy(q, p, 8); p += 8; + + if (p >= pe) { + bad = 4; + goto end; + } + + q += 8; + + if (q >= qe) { + bad = 5; + goto end; + } + + strncpy(q, port_buf, strlen(port_buf)); q += strlen(port_buf); + if (q >= qe) { + bad = 6; + goto end; + } + while (p && *p && (*p >= '0' && *p <= '9')) { + if (p >= pe) { + bad = 7; + goto end; + } p++; } @@ -1061,33 +1108,102 @@ strncpy(q, p, 8); p += 8; + + if (p >= pe) { + bad = 8; + goto end; + } + q += 8; + + if (q >= qe) { + bad = 9; + goto end; + } + strncpy(q, vport_buf, strlen(vport_buf)); q += strlen(vport_buf); + if (q >= qe) { + bad = 10; + goto end; + } + while (p && *p && (*p >= '0' && *p <= '9')) { + + if (p >= pe) { + bad = 11; + goto end; + } + p++; } - + has_video++; } while (p && *p && *p != '\n') { + + if (p >= pe) { + bad = 12; + goto end; + } + + if (q >= qe) { + bad = 13; + goto end; + } + *q++ = *p++; } + + if (p >= pe) { + bad = 14; + goto end; + } + + if (q >= qe) { + bad = 15; + goto end; + } *q++ = *p++; + } + end: + + if (bad) { + return; + } + + + if (switch_channel_down(tech_pvt->channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s too late.\n", switch_channel_get_name(tech_pvt->channel)); + return; + } + + if (!has_ip && !has_audio) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SDP has no audio in it.\n%s\n", switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_str); - tech_pvt->local_sdp_str = tech_pvt->orig_local_sdp_str; return; } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Patched SDP\n---\n%s\n+++\n%s\n", - switch_channel_get_name(tech_pvt->channel), tech_pvt->orig_local_sdp_str, tech_pvt->local_sdp_str); + switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_str, new_sdp); + + sofia_glue_tech_set_local_sdp(tech_pvt, new_sdp, SWITCH_FALSE); + +} + + +void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup) +{ + switch_mutex_lock(tech_pvt->sofia_mutex); + tech_pvt->local_sdp_str = dup ? switch_core_session_strdup(tech_pvt->session, sdp_str) : (char *)sdp_str; + switch_mutex_unlock(tech_pvt->sofia_mutex); } @@ -1298,7 +1414,6 @@ SIPTAG_FROM_STR(from_str), SIPTAG_CONTACT_STR(invite_contact), TAG_END()); - if (tech_pvt->dest && (strstr(tech_pvt->dest, ";fs_nat") || strstr(tech_pvt->dest, ";received") || ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val)))) { @@ -1570,7 +1685,7 @@ } sdp_parser_free(parser); } - tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, sdp_str); + sofia_glue_tech_set_local_sdp(tech_pvt, sdp_str, SWITCH_TRUE); } } @@ -1883,6 +1998,11 @@ const char *var; switch_assert(tech_pvt != NULL); + + if (switch_channel_down(tech_pvt->channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) { + return SWITCH_STATUS_FALSE; + } + switch_mutex_lock(tech_pvt->sofia_mutex); if (switch_rtp_ready(tech_pvt->rtp_session)) { @@ -1893,7 +2013,6 @@ sofia_set_flag_locked(tech_pvt, TFLAG_SECURE); } - if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE)) { status = SWITCH_STATUS_SUCCESS; goto end; @@ -1997,6 +2116,7 @@ if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt)) != SWITCH_STATUS_SUCCESS) { goto end; } + if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) { flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT); @@ -2005,7 +2125,8 @@ } timer_name = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PROXY AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "PROXY AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n", switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_audio_ip, tech_pvt->local_sdp_audio_port, @@ -2014,20 +2135,23 @@ } else { timer_name = tech_pvt->profile->timer_name; - } - if ((var = switch_channel_get_variable(tech_pvt->channel, "rtp_timer_name"))) { - timer_name = (char *) var; + if ((var = switch_channel_get_variable(tech_pvt->channel, "rtp_timer_name"))) { + timer_name = (char *) var; + } } - tech_pvt->rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip, - tech_pvt->local_sdp_audio_port, - tech_pvt->remote_sdp_audio_ip, - tech_pvt->remote_sdp_audio_port, - tech_pvt->agreed_pt, - tech_pvt->read_impl.samples_per_packet, - tech_pvt->codec_ms * 1000, - (switch_rtp_flag_t) flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session)); + if (switch_channel_up(tech_pvt->channel) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { + tech_pvt->rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip, + tech_pvt->local_sdp_audio_port, + tech_pvt->remote_sdp_audio_ip, + tech_pvt->remote_sdp_audio_port, + tech_pvt->agreed_pt, + tech_pvt->read_impl.samples_per_packet, + tech_pvt->codec_ms * 1000, + (switch_rtp_flag_t) flags, timer_name, &err, + switch_core_session_get_pool(tech_pvt->session)); + } if (switch_rtp_ready(tech_pvt->rtp_session)) { uint8_t vad_in = sofia_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0; @@ -2223,19 +2347,18 @@ switch_assert(tech_pvt != NULL); switch_assert(r_sdp != NULL); - parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0); - if (switch_strlen_zero(r_sdp)) { return SWITCH_STATUS_FALSE; } - if (tech_pvt->num_codecs) { - if ((sdp = sdp_session(parser))) { - match = sofia_glue_negotiate_sdp(tech_pvt->session, sdp); + if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) { + + if (tech_pvt->num_codecs) { + if ((sdp = sdp_session(parser))) { + match = sofia_glue_negotiate_sdp(tech_pvt->session, sdp); + } } - } - - if (parser) { + sdp_parser_free(parser); } From anthm at freeswitch.org Thu Mar 19 19:08:18 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 21:08:18 -0500 Subject: [Freeswitch-svn] [commit] r12677 - freeswitch/trunk/libs/apr Message-ID: Author: anthm Date: Thu Mar 19 21:08:18 2009 New Revision: 12677 Log: update Modified: freeswitch/trunk/libs/apr/.update Modified: freeswitch/trunk/libs/apr/.update ============================================================================== --- freeswitch/trunk/libs/apr/.update (original) +++ freeswitch/trunk/libs/apr/.update Thu Mar 19 21:08:18 2009 @@ -1 +1 @@ -Fri Mar 16 17:12:07 EDT 2007 +Thu Mar 19 21:08:11 CDT 2009 From mrene at freeswitch.org Thu Mar 19 20:28:11 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 22:28:11 -0500 Subject: [Freeswitch-svn] [commit] r12678 - freeswitch/trunk/src Message-ID: Author: mrene Date: Thu Mar 19 22:28:11 2009 New Revision: 12678 Log: Fix FreeBSD build Modified: freeswitch/trunk/src/switch_core_port_allocator.c Modified: freeswitch/trunk/src/switch_core_port_allocator.c ============================================================================== --- freeswitch/trunk/src/switch_core_port_allocator.c (original) +++ freeswitch/trunk/src/switch_core_port_allocator.c Thu Mar 19 22:28:11 2009 @@ -118,7 +118,7 @@ int odd = switch_test_flag(alloc, SPF_ODD); switch_mutex_lock(alloc->mutex); - srand((unsigned)(intptr_t)port_ptr + switch_thread_self() + switch_micro_time_now()); + srand((unsigned)(intptr_t)port_ptr + (uint32_t)switch_thread_self() + switch_micro_time_now()); while (alloc->track_used < alloc->track_len) { uint32_t index; From mrene at freeswitch.org Thu Mar 19 20:41:49 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Mar 2009 22:41:49 -0500 Subject: [Freeswitch-svn] [commit] r12679 - freeswitch/trunk/src Message-ID: Author: mrene Date: Thu Mar 19 22:41:49 2009 New Revision: 12679 Log: tweak Modified: freeswitch/trunk/src/switch_core_port_allocator.c Modified: freeswitch/trunk/src/switch_core_port_allocator.c ============================================================================== --- freeswitch/trunk/src/switch_core_port_allocator.c (original) +++ freeswitch/trunk/src/switch_core_port_allocator.c Thu Mar 19 22:41:49 2009 @@ -118,7 +118,7 @@ int odd = switch_test_flag(alloc, SPF_ODD); switch_mutex_lock(alloc->mutex); - srand((unsigned)(intptr_t)port_ptr + (uint32_t)switch_thread_self() + switch_micro_time_now()); + srand((unsigned)(intptr_t)port_ptr + (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now()); while (alloc->track_used < alloc->track_len) { uint32_t index; From anthm at freeswitch.org Fri Mar 20 05:58:05 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 07:58:05 -0500 Subject: [Freeswitch-svn] [commit] r12680 - in freeswitch/trunk: . libs/libdingaling/src src/mod/endpoints/mod_dingaling Message-ID: Author: anthm Date: Fri Mar 20 07:58:04 2009 New Revision: 12680 Log: MODENDP-202 and MODENDP-204 Modified: freeswitch/trunk/Makefile.am freeswitch/trunk/libs/libdingaling/src/libdingaling.c freeswitch/trunk/libs/libdingaling/src/libdingaling.h freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Modified: freeswitch/trunk/Makefile.am ============================================================================== --- freeswitch/trunk/Makefile.am (original) +++ freeswitch/trunk/Makefile.am Fri Mar 20 07:58:04 2009 @@ -321,7 +321,7 @@ core-install: core_install clean_core: clean-libLTLIBRARIES - + rm -f $(libfreeswitch_la_OBJECTS) install_core: install-libLTLIBRARIES core_install: install_core Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Fri Mar 20 07:58:04 2009 @@ -1593,6 +1593,7 @@ microsleep(100); } + ldl_set_flag_locked(handle, LDL_FLAG_STOPPED); } @@ -2324,6 +2325,7 @@ void ldl_handle_run(ldl_handle_t *handle) { + ldl_clear_flag_locked(handle, LDL_FLAG_STOPPED); ldl_set_flag_locked(handle, LDL_FLAG_RUNNING); xmpp_connect(handle, handle->login, handle->password); ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); @@ -2332,12 +2334,24 @@ void ldl_handle_stop(ldl_handle_t *handle) { ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); + if (ldl_test_flag(handle, LDL_FLAG_TLS)) { + int fd; + if ((fd = iks_fd(handle->parser)) > -1) { + shutdown(fd, 0x02); + } + } + + while(!ldl_test_flag(handle, LDL_FLAG_STOPPED)) { + microsleep(100); + } + } ldl_status ldl_handle_destroy(ldl_handle_t **handle) { apr_pool_t *pool = (*handle)->pool; + ldl_handle_stop(*handle); ldl_flush_queue(*handle, 1); Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.h ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.h (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.h Fri Mar 20 07:58:04 2009 @@ -119,7 +119,8 @@ LDL_FLAG_AUTHORIZED = (1 << 2), LDL_FLAG_READY = (1 << 3), LDL_FLAG_CONNECTED = (1 << 4), - LDL_FLAG_QUEUE_RUNNING = (1 << 5) + LDL_FLAG_QUEUE_RUNNING = (1 << 5), + LDL_FLAG_STOPPED = (1 << 6) } ldl_flag_t; typedef enum { Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Fri Mar 20 07:58:04 2009 @@ -1805,7 +1805,7 @@ #define PRES_SYNTAX "dl_pres " #define LOGOUT_SYNTAX "dl_logout " -#define LOGIN_SYNTAX "dl_login " +#define LOGIN_SYNTAX "Existing Profile:\ndl_login profile=\nDynamic Profile:\ndl_login var1=val1;var2=val2;varN=valN\n" #define DEBUG_SYNTAX "dl_debug [true|false]" SWITCH_ADD_API(api_interface, "dl_debug", "DingaLing Debug", dl_debug, DEBUG_SYNTAX); From anthm at freeswitch.org Fri Mar 20 06:51:46 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 08:51:46 -0500 Subject: [Freeswitch-svn] [commit] r12681 - freeswitch/trunk/src/mod/endpoints/mod_dingaling Message-ID: Author: anthm Date: Fri Mar 20 08:51:46 2009 New Revision: 12681 Log: add switch_str_nil to avoid printing (null) Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Fri Mar 20 08:51:46 2009 @@ -1839,7 +1839,13 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid Profile\n" "login[%s]\n" "pass[%s]\n" "dialplan[%s]\n" "message[%s]\n" "rtp-ip[%s]\n" "name[%s]\n" "exten[%s]\n", - profile->login, profile->password, profile->dialplan, profile->message, profile->ip, profile->name, profile->exten); + switch_str_nil(profile->login), + switch_str_nil(profile->password), + switch_str_nil(profile->dialplan), + switch_str_nil(profile->message), + switch_str_nil(profile->ip), + switch_str_nil(profile->name), + switch_str_nil(profile->exten)); return SWITCH_STATUS_FALSE; } From anthm at freeswitch.org Fri Mar 20 06:58:45 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 08:58:45 -0500 Subject: [Freeswitch-svn] [commit] r12682 - in freeswitch/trunk/src: . include Message-ID: Author: anthm Date: Fri Mar 20 08:58:45 2009 New Revision: 12682 Log: FSCORE-339 Modified: freeswitch/trunk/src/include/switch_module_interfaces.h freeswitch/trunk/src/switch_core_file.c freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/include/switch_module_interfaces.h ============================================================================== --- freeswitch/trunk/src/include/switch_module_interfaces.h (original) +++ freeswitch/trunk/src/include/switch_module_interfaces.h Fri Mar 20 08:58:45 2009 @@ -317,7 +317,8 @@ uint32_t thresh; uint32_t silence_hits; uint32_t offset_pos; - //uint32_t last_pos; + switch_size_t samples_in; + switch_size_t samples_out; int32_t vol; switch_audio_resampler_t *resampler; switch_buffer_t *buffer; Modified: freeswitch/trunk/src/switch_core_file.c ============================================================================== --- freeswitch/trunk/src/switch_core_file.c (original) +++ freeswitch/trunk/src/switch_core_file.c Fri Mar 20 08:58:45 2009 @@ -177,6 +177,7 @@ if ((status = fh->file_interface->file_read(fh, fh->pre_buffer_data, &rlen)) != SWITCH_STATUS_SUCCESS || !rlen) { switch_set_flag(fh, SWITCH_FILE_BUFFER_DONE); } else { + fh->samples_in += rlen; if (fh->channels > 1) { switch_mux_channels((int16_t *)fh->pre_buffer_data, rlen, fh->channels); } @@ -202,6 +203,8 @@ goto top; } + fh->samples_in += *len; + if (fh->channels > 1) { switch_mux_channels((int16_t *)data, *len, fh->channels); } @@ -317,11 +320,16 @@ if ((status = fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen)) != SWITCH_STATUS_SUCCESS) { *len = 0; } + fh->samples_out += blen; } return status; } else { - return fh->file_interface->file_write(fh, data, len); + switch_status_t status; + if ((status = fh->file_interface->file_write(fh, data, len)) == SWITCH_STATUS_SUCCESS) { + fh->samples_out += *len; + } + return status; } } Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Fri Mar 20 08:58:45 2009 @@ -439,12 +439,23 @@ case SWITCH_ABC_TYPE_INIT: break; case SWITCH_ABC_TYPE_CLOSE: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stop recording file %s\n", rh->file); - switch_channel_set_private(channel, rh->file, NULL); + { + switch_codec_implementation_t read_impl = {0}; + switch_core_session_get_read_impl(session, &read_impl); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stop recording file %s\n", rh->file); + switch_channel_set_private(channel, rh->file, NULL); + + if (rh->fh) { + switch_core_file_close(rh->fh); + } - if (rh->fh) { - switch_core_file_close(rh->fh); + if (rh->fh->samples_out < read_impl.samples_per_second * 3) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file); + switch_file_remove(rh->file, switch_core_session_get_pool(session)); + } } + break; case SWITCH_ABC_TYPE_READ_PING: if (rh->fh) { From anthm at freeswitch.org Fri Mar 20 07:28:37 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 09:28:37 -0500 Subject: [Freeswitch-svn] [commit] r12683 - freeswitch/trunk/src Message-ID: Author: anthm Date: Fri Mar 20 09:28:36 2009 New Revision: 12683 Log: doh Modified: freeswitch/trunk/src/switch_core_memory.c Modified: freeswitch/trunk/src/switch_core_memory.c ============================================================================== --- freeswitch/trunk/src/switch_core_memory.c (original) +++ freeswitch/trunk/src/switch_core_memory.c Fri Mar 20 09:28:36 2009 @@ -243,7 +243,7 @@ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %d\n", (int) len); #endif - duped = strdup(todup); + duped = apr_pstrdup(session->pool, todup); switch_assert(duped != NULL); #ifdef LOCK_MORE From brian at freeswitch.org Fri Mar 20 07:31:15 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 09:31:15 -0500 Subject: [Freeswitch-svn] [commit] r12684 - freeswitch/trunk/src Message-ID: Author: brian Date: Fri Mar 20 09:31:15 2009 New Revision: 12684 Log: FSCORE-333 Modified: freeswitch/trunk/src/switch_xml.c Modified: freeswitch/trunk/src/switch_xml.c ============================================================================== --- freeswitch/trunk/src/switch_xml.c (original) +++ freeswitch/trunk/src/switch_xml.c Fri Mar 20 09:31:15 2009 @@ -2022,9 +2022,14 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max, switch_size_t start, char ***attr, uint32_t * count) { int i, j; - char *txt = (char *)(xml->parent) ? xml->parent->txt : (char *)""; - switch_size_t off = 0; - uint32_t lcount = 0; + char *txt; + switch_size_t off; + uint32_t lcount; + +tailrecurse: + off = 0; + lcount = 0; + txt = (char *)(xml->parent) ? xml->parent->txt : (char *)""; /* parent character content up to this tag */ *s = switch_xml_ampencode(txt + start, xml->off - start, s, len, max, 0); @@ -2101,8 +2106,12 @@ off++; /* make sure off is within bounds */ if (xml->ordered) { + xml = xml->ordered; + start = off; + goto tailrecurse; +/* return switch_xml_toxml_r(xml->ordered, s, len, max, off, attr, count); - +*/ } else { if (*count > 0) (*count)--; @@ -2197,11 +2206,13 @@ /* free the memory allocated for the switch_xml structure */ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml) { - switch_xml_root_t root = (switch_xml_root_t) xml; + switch_xml_root_t root; int i, j; char **a, *s; + switch_xml_t orig_xml; - +tailrecurse: + root = (switch_xml_root_t) xml; if (!xml) { return; } @@ -2221,7 +2232,7 @@ } switch_xml_free(xml->child); - switch_xml_free(xml->ordered); + /*switch_xml_free(xml->ordered);*/ if (!xml->parent) { /* free root tag allocations */ for (i = 10; root->ent[i]; i += 2) /* 0 - 9 are default entities (<>&"') */ @@ -2261,6 +2272,12 @@ free(xml->txt); /* character content */ if ((xml->flags & SWITCH_XML_NAMEM)) free(xml->name); /* tag name */ + if (xml->ordered) { + orig_xml = xml; + xml = xml->ordered; + free(orig_xml); + goto tailrecurse; + } free(xml); } From anthm at freeswitch.org Fri Mar 20 08:28:50 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 10:28:50 -0500 Subject: [Freeswitch-svn] [commit] r12685 - in freeswitch/trunk: conf/autoload_configs src/mod/applications/mod_fifo Message-ID: Author: anthm Date: Fri Mar 20 10:28:50 2009 New Revision: 12685 Log: MODAPP-237 Modified: freeswitch/trunk/conf/autoload_configs/fifo.conf.xml freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Modified: freeswitch/trunk/conf/autoload_configs/fifo.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/fifo.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/fifo.conf.xml Fri Mar 20 10:28:50 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original) +++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Fri Mar 20 10:28:50 2009 @@ -449,6 +449,7 @@ switch_caller_extension_t *extension = NULL; char *app_name, *arg = NULL; char sql[256] = ""; + const char *member_wait = NULL; switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count+1 where uuid='%s'", h->uuid); fifo_execute_sql(sql, globals.sql_mutex); @@ -462,10 +463,17 @@ channel = switch_core_session_get_channel(session); + + if ((member_wait = switch_channel_get_variable(channel, "member_wait"))) { + if (strcasecmp(member_wait, "wait") && strcasecmp(member_wait, "nowait")) { + member_wait = NULL; + } + } + switch_channel_set_variable(channel, "fifo_outbound_uuid", h->uuid); switch_core_event_hook_add_state_change(session, hanguphook); app_name = "fifo"; - arg = switch_core_session_sprintf(session, "%s out wait", h->node_name); + arg = switch_core_session_sprintf(session, "%s out %s", h->node_name, member_wait ? member_wait : "wait"); extension = switch_caller_extension_new(session, app_name, arg); switch_caller_extension_add_application(session, extension, app_name, arg); switch_channel_set_caller_extension(channel, extension); From anthm at freeswitch.org Fri Mar 20 10:03:46 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 12:03:46 -0500 Subject: [Freeswitch-svn] [commit] r12686 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Fri Mar 20 12:03:46 2009 New Revision: 12686 Log: fix regression Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Mar 20 12:03:46 2009 @@ -344,19 +344,13 @@ tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); if (tech_pvt) { - - if (status >= 300) { - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); - } - switch_mutex_lock(tech_pvt->sofia_mutex); locked = 1; } else { switch_core_session_rwunlock(session); return; } - - + if (status >= 180 && !*sofia_private->auth_gateway_name) { const char *gwname = switch_channel_get_variable(channel, "sip_use_gateway"); if (!switch_strlen_zero(gwname)) { @@ -3338,6 +3332,7 @@ tech_pvt->q850_cause = SWITCH_CAUSE_MANDATORY_IE_MISSING; } case nua_callstate_terminated: + sofia_set_flag_locked(tech_pvt, TFLAG_BYE); if (sofia_test_flag(tech_pvt, TFLAG_NOHUP)) { sofia_clear_flag_locked(tech_pvt, TFLAG_NOHUP); } else if (switch_channel_up(channel)) { Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Mar 20 12:03:46 2009 @@ -2375,6 +2375,7 @@ return SWITCH_STATUS_SUCCESS; } + return SWITCH_STATUS_FALSE; } From mrene at freeswitch.org Fri Mar 20 12:36:43 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 14:36:43 -0500 Subject: [Freeswitch-svn] [commit] r12687 - freeswitch/trunk/support-d Message-ID: Author: mrene Date: Fri Mar 20 14:36:43 2009 New Revision: 12687 Log: Add print_list gdb macro Modified: freeswitch/trunk/support-d/.gdbinit Modified: freeswitch/trunk/support-d/.gdbinit ============================================================================== --- freeswitch/trunk/support-d/.gdbinit (original) +++ freeswitch/trunk/support-d/.gdbinit Fri Mar 20 14:36:43 2009 @@ -59,4 +59,17 @@ document event_dump Usage: event_dump [switch_event_t*] Print an event's headers and values -end \ No newline at end of file +end + +define print_list + dont-repeat + set $x = $arg0 + while ($x != 0x0) + print *$x + set $x = $x->next + end +end +document print_list +Usage print_list [symbol] +Prints all the remaining elements of a linked list +end From rupa at freeswitch.org Fri Mar 20 13:15:39 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 15:15:39 -0500 Subject: [Freeswitch-svn] [commit] r12688 - freeswitch/trunk/src/mod/applications/mod_lcr Message-ID: Author: rupa Date: Fri Mar 20 15:15:39 2009 New Revision: 12688 Log: Add support for specifying codec in carrier_gateway table Add ability to test ${} queries even when no session is available (abuse events for this) Test sql at startup, refuse to load invalid profile Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Fri Mar 20 15:15:39 2009 @@ -47,8 +47,10 @@ #define LCR_TSTRIP_PLACE 6 #define LCR_PREFIX_PLACE 7 #define LCR_SUFFIX_PLACE 8 +#define LCR_CODEC_PLACE 9 -#define LCR_QUERY_COLS 9 +#define LCR_QUERY_COLS_REQUIRED 9 +#define LCR_QUERY_COLS 10 #define LCR_DIALSTRING_PLACE 3 #define LCR_HEADERS_COUNT 4 @@ -84,6 +86,7 @@ size_t lstrip; size_t tstrip; size_t digit_len; + char *codec; struct lcr_obj *prev; struct lcr_obj *next; }; @@ -126,6 +129,7 @@ char *lookup_number; profile_t *profile; switch_core_session_t *session; + switch_event_t *event; }; typedef struct callback_obj callback_t; @@ -153,6 +157,7 @@ char *data = NULL; char *destination_number = NULL; char *orig_destination_number = NULL; + char *codec = NULL; orig_destination_number = destination_number = switch_core_strdup(pool, dialed_number); @@ -166,8 +171,14 @@ destination_number += lstrip; } - data = switch_core_sprintf(pool, "[lcr_carrier=%s,lcr_rate=%s]%s%s%s%s%s" + codec = ""; + if (!switch_strlen_zero(cur_route->codec)) { + codec = switch_core_sprintf(pool, ",absolute_codec_string=%s", cur_route->codec); + } + + data = switch_core_sprintf(pool, "[lcr_carrier=%s,lcr_rate=%s%s]%s%s%s%s%s" , cur_route->carrier_name, cur_route->rate_str + , codec , cur_route->gw_prefix, cur_route->prefix , destination_number, cur_route->suffix, cur_route->gw_suffix); @@ -243,24 +254,29 @@ return SWITCH_STATUS_SUCCESS; } -/* try each type of random until we suceed */ -static switch_bool_t set_db_random() +static switch_bool_t db_check(char *sql) { - char *sql = NULL; if (globals.odbc_dsn) { - sql = "SELECT rand()"; - if (switch_odbc_handle_exec(globals.master_odbc, sql, NULL) - == SWITCH_ODBC_SUCCESS) { - db_random = "rand()"; - return SWITCH_TRUE; - } - sql = "SELECT random()"; - if (switch_odbc_handle_exec(globals.master_odbc, sql, NULL) - == SWITCH_ODBC_SUCCESS) { - db_random = "random()"; + if (switch_odbc_handle_exec(globals.master_odbc, sql, NULL) == SWITCH_ODBC_SUCCESS) { return SWITCH_TRUE; } } + + return SWITCH_FALSE; +} + +/* try each type of random until we suceed */ +static switch_bool_t set_db_random() +{ + if (db_check("SELECT rand();") == SWITCH_TRUE) { + db_random = "rand()"; + return SWITCH_TRUE; + } + if(db_check("SELECT random();") == SWITCH_TRUE) { + db_random = "random()"; + return SWITCH_TRUE; + } + return SWITCH_FALSE; } @@ -348,6 +364,10 @@ */ newSQL = switch_channel_expand_variables(channel, tmpSQL ? tmpSQL : custom_sql); + } else if (cb_struct->event) { + /* use event system to expand vars */ + newSQL = switch_event_expand_headers(cb_struct->event, tmpSQL ? tmpSQL : custom_sql); + } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "mod_lcr called without a valid session while using a custom_sql that has channel variables.\n"); @@ -392,9 +412,9 @@ switch_memory_pool_t *pool = cbt->pool; - if (argc != LCR_QUERY_COLS) { + if (argc < LCR_QUERY_COLS_REQUIRED) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "Unexpected number of columns returned for SQL. Returned columns are: %d. " + "Unexpected number of columns returned for SQL. Returned column count: %d. " "If using a custom sql for this profile, verify it is correct. Otherwise file a bug report.\n", argc); return SWITCH_STATUS_GENERR; @@ -422,6 +442,9 @@ additional->gw_suffix = switch_core_strdup(pool, switch_str_nil(argv[LCR_GW_SUFFIX_PLACE])); additional->lstrip = atoi(switch_str_nil(argv[LCR_LSTRIP_PLACE])); additional->tstrip = atoi(switch_str_nil(argv[LCR_TSTRIP_PLACE])); + if (argc > LCR_CODEC_PLACE) { + additional->codec = switch_core_strdup(pool, switch_str_nil(argv[LCR_CODEC_PLACE])); + } additional->dialstring = get_bridge_data(pool, cbt->lookup_number, additional); if (cbt->head == NULL) { @@ -497,7 +520,6 @@ switch_status_t lcr_do_lookup(callback_t *cb_struct, char *digits) { - /* instantiate the object/struct we defined earlier */ switch_stream_handle_t sql_stream = { 0 }; char *digits_copy; char *digits_expanded; @@ -517,9 +539,6 @@ return SWITCH_STATUS_FALSE; } - /* SWITCH_STANDARD_STREAM doesn't use pools. but we only have to free sql_stream.data */ - SWITCH_STANDARD_STREAM(sql_stream); - digits_expanded = expand_digits(cb_struct->pool, digits_copy, cb_struct->profile->quote_in_list); /* set some channel vars if we have a session */ @@ -531,39 +550,26 @@ switch_channel_set_variable_var_check(channel, "lcr_query_expanded_digits", digits_expanded, SWITCH_FALSE); } } + if (cb_struct->event) { + switch_event_add_header_string(cb_struct->event, SWITCH_STACK_BOTTOM, "lcr_query_digits", digits_copy); + id_str = switch_core_sprintf(cb_struct->pool, "%d", cb_struct->profile->id); + switch_event_add_header_string(cb_struct->event, SWITCH_STACK_BOTTOM, "lcr_query_profile", id_str); + switch_event_add_header_string(cb_struct->event, SWITCH_STACK_BOTTOM, "lcr_query_expanded_digits", digits_expanded); + } /* set up the query to be executed */ - if (switch_strlen_zero(profile->custom_sql)) { - sql_stream.write_function(&sql_stream, - "SELECT l.digits, c.carrier_name, l.rate, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix " - ); - sql_stream.write_function(&sql_stream, "FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN ("); - sql_stream.write_function(&sql_stream, "%s", digits_expanded); - sql_stream.write_function(&sql_stream, ") AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end "); - if (profile->id > 0) { - sql_stream.write_function(&sql_stream, "AND lcr_profile=%d ", profile->id); - } - sql_stream.write_function(&sql_stream, "ORDER BY %s%s digits DESC%s", - profile->pre_order, - switch_strlen_zero(profile->pre_order)? "" : ",", - profile->order_by); - if (db_random) { - sql_stream.write_function(&sql_stream, ", %s", db_random); - } - sql_stream.write_function(&sql_stream, ";"); - } else { - char *safe_sql; + char *safe_sql; - /* format the custom_sql */ - safe_sql = format_custom_sql(profile->custom_sql, cb_struct, digits_copy); - if (!safe_sql) { - return SWITCH_STATUS_GENERR; - } - sql_stream.write_function(&sql_stream, safe_sql); - if (safe_sql != profile->custom_sql) { - /* channel_expand_variables returned the same string to us, no need to free */ - switch_safe_free(safe_sql); - } + /* format the custom_sql */ + safe_sql = format_custom_sql(profile->custom_sql, cb_struct, digits_copy); + if (!safe_sql) { + return SWITCH_STATUS_GENERR; + } + SWITCH_STANDARD_STREAM(sql_stream); + sql_stream.write_function(&sql_stream, safe_sql); + if (safe_sql != profile->custom_sql) { + /* channel_expand_variables returned the same string to us, no need to free */ + switch_safe_free(safe_sql); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL: %s\n", (char *)sql_stream.data); @@ -580,9 +586,30 @@ } } +switch_status_t test_profile(char *lcr_profile) +{ + callback_t routes = { 0 }; + switch_memory_pool_t *pool = NULL; + switch_event_t *event = NULL; + + switch_core_new_memory_pool(&pool); + switch_event_create(&event, SWITCH_EVENT_MESSAGE); + routes.event = event; + routes.pool = pool; + + if (!(routes.profile = locate_profile(lcr_profile))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown profile: %s\n", lcr_profile); + return SWITCH_FALSE; + } + + routes.lookup_number = "15555551212"; + return lcr_do_lookup(&routes, routes.lookup_number); +} + static switch_status_t lcr_load_config() { char *cf = "lcr.conf"; + switch_stream_handle_t sql_stream = { 0 }; switch_xml_t cfg, xml, settings, param, x_profile, x_profiles; switch_status_t status = SWITCH_STATUS_SUCCESS; char *odbc_user = NULL; @@ -631,6 +658,12 @@ } } + if (set_db_random() == SWITCH_TRUE) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Database RANDOM function set to %s\n", db_random); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to determine database RANDOM function\n"); + }; + switch_core_hash_init(&globals.profile_hash, globals.pool); if ((x_profiles = switch_xml_child(cfg, "profiles"))) { for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { @@ -722,16 +755,45 @@ profile->id = (uint16_t)atoi(id_s); } - if (!switch_strlen_zero(custom_sql)) { - if (switch_string_var_check_const(custom_sql)) { - profile->custom_sql_has_vars = SWITCH_TRUE; + /* SWITCH_STANDARD_STREAM doesn't use pools. but we only have to free sql_stream.data */ + SWITCH_STANDARD_STREAM(sql_stream); + if (switch_strlen_zero(custom_sql)) { + /* use default sql */ + sql_stream.write_function(&sql_stream, + "SELECT l.digits, c.carrier_name, l.rate, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix " + ); + if (db_check("SELECT codec from carrier_gateway limit 1") == SWITCH_TRUE) { + sql_stream.write_function(&sql_stream, ", cg.codec "); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "codec field defined.\n"); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "codec field not defined, please update your lcr database schema.\n"); + } + sql_stream.write_function(&sql_stream, "FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN ("); + sql_stream.write_function(&sql_stream, "${lcr_query_expanded_digits}"); + sql_stream.write_function(&sql_stream, ") AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end "); + if (profile->id > 0) { + sql_stream.write_function(&sql_stream, "AND lcr_profile=%d ", profile->id); } - if (strstr(custom_sql, "%")) { - profile->custom_sql_has_percent = SWITCH_TRUE; + sql_stream.write_function(&sql_stream, "ORDER BY %s%s digits DESC%s", + profile->pre_order, + switch_strlen_zero(profile->pre_order)? "" : ",", + profile->order_by); + if (db_random) { + sql_stream.write_function(&sql_stream, ", %s", db_random); } - profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql); + sql_stream.write_function(&sql_stream, ";"); + + custom_sql = sql_stream.data; } + if (switch_string_var_check_const(custom_sql)) { + profile->custom_sql_has_vars = SWITCH_TRUE; + } + if (strstr(custom_sql, "%")) { + profile->custom_sql_has_percent = SWITCH_TRUE; + } + profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql); + if (!switch_strlen_zero(reorder_by_rate)) { profile->reorder_by_rate = switch_true(reorder_by_rate); } @@ -742,14 +804,20 @@ switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded lcr profile %s.\n", profile->name); - - if (!strcasecmp(profile->name, "default")) { - globals.default_profile = profile; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting user defined default profile: %s.\n", profile->name); + /* test the profile */ + if (test_profile(profile->name) != SWITCH_TRUE) { + if (!strcasecmp(profile->name, "default")) { + globals.default_profile = profile; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting user defined default profile: %s.\n", profile->name); + } + } else { + switch_core_hash_delete(globals.profile_hash, profile->name); } + } switch_safe_free(order_by.data); switch_safe_free(pre_order.data); + switch_safe_free(sql_stream.data); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No lcr profiles defined.\n"); @@ -779,12 +847,15 @@ lcr_route cur_route = { 0 }; char *lcr_profile = NULL; switch_memory_pool_t *pool = NULL; + switch_event_t *event = NULL; if (session) { pool = switch_core_session_get_pool(session); routes.session = session; } else { switch_core_new_memory_pool(&pool); + switch_event_create(&event, SWITCH_EVENT_MESSAGE); + routes.event = event; } routes.pool = pool; if (!(routes.profile = locate_profile(lcr_profile))) { @@ -850,6 +921,7 @@ callback_t routes = { 0 }; lcr_route cur_route = { 0 }; switch_memory_pool_t *pool; + switch_event_t *event; if (!(mydata = switch_core_session_strdup(session, data))) { return; @@ -860,6 +932,8 @@ routes.session = session; } else { switch_core_new_memory_pool(&pool); + switch_event_create(&event, SWITCH_EVENT_MESSAGE); + routes.event = event; } routes.pool = pool; @@ -913,6 +987,7 @@ max_obj_t maximum_lengths = { 0 }; callback_t cb_struct = { 0 }; switch_memory_pool_t *pool; + switch_event_t *event; switch_status_t lookup_status = SWITCH_STATUS_SUCCESS; if (switch_strlen_zero(cmd)) { @@ -924,6 +999,8 @@ cb_struct.session = session; } else { switch_core_new_memory_pool(&pool); + switch_event_create(&event, SWITCH_EVENT_MESSAGE); + cb_struct.event = event; } cb_struct.pool = pool; @@ -1090,11 +1167,6 @@ globals.pool = pool; - if (lcr_load_config() != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load lcr config file\n"); - return SWITCH_STATUS_FALSE; - } - if (switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to initialize mutex\n"); } @@ -1102,12 +1174,10 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to initialize db_mutex\n"); } - - if (set_db_random() == SWITCH_TRUE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Database RANDOM function set to %s\n", db_random); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to determine database RANDOM function\n"); - }; + if (lcr_load_config() != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load lcr config file\n"); + return SWITCH_STATUS_FALSE; + } SWITCH_ADD_API(dialplan_lcr_api_interface, "lcr", "Least Cost Routing Module", dialplan_lcr_function, LCR_SYNTAX); SWITCH_ADD_API(dialplan_lcr_api_admin_interface, "lcr_admin", "Least Cost Routing Module Admin", dialplan_lcr_admin_function, LCR_ADMIN_SYNTAX); From rupa at freeswitch.org Fri Mar 20 13:23:32 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 15:23:32 -0500 Subject: [Freeswitch-svn] [commit] r12689 - freeswitch/trunk/src/mod/applications/mod_lcr Message-ID: Author: rupa Date: Fri Mar 20 15:23:32 2009 New Revision: 12689 Log: oops, fix test for invalid profile Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Fri Mar 20 15:23:32 2009 @@ -530,13 +530,13 @@ digits_copy = string_digitsonly(cb_struct->pool, digits); if (switch_strlen_zero(digits_copy)) { - return SWITCH_FALSE; + return SWITCH_STATUS_GENERR; } /* allocate the dedup hash */ if (switch_core_hash_init(&cb_struct->dedup_hash, cb_struct->pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error initializing the dedup hash\n"); - return SWITCH_STATUS_FALSE; + return SWITCH_STATUS_GENERR; } digits_expanded = expand_digits(cb_struct->pool, digits_copy, cb_struct->profile->quote_in_list); @@ -586,7 +586,7 @@ } } -switch_status_t test_profile(char *lcr_profile) +switch_bool_t test_profile(char *lcr_profile) { callback_t routes = { 0 }; switch_memory_pool_t *pool = NULL; @@ -603,7 +603,8 @@ } routes.lookup_number = "15555551212"; - return lcr_do_lookup(&routes, routes.lookup_number); + return (lcr_do_lookup(&routes, routes.lookup_number) == SWITCH_STATUS_SUCCESS) ? + SWITCH_TRUE : SWITCH_FALSE; } static switch_status_t lcr_load_config() @@ -805,12 +806,13 @@ switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded lcr profile %s.\n", profile->name); /* test the profile */ - if (test_profile(profile->name) != SWITCH_TRUE) { + if (test_profile(profile->name) == SWITCH_TRUE) { if (!strcasecmp(profile->name, "default")) { globals.default_profile = profile; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting user defined default profile: %s.\n", profile->name); } } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Removing INAVLID Profile %s.\n", profile->name); switch_core_hash_delete(globals.profile_hash, profile->name); } From rupa at freeswitch.org Fri Mar 20 13:31:05 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 15:31:05 -0500 Subject: [Freeswitch-svn] [commit] r12690 - freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql Message-ID: Author: rupa Date: Fri Mar 20 15:31:05 2009 New Revision: 12690 Log: add codec Modified: freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/mysql-5.0.sql freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/postgres-8.3.sql Modified: freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/mysql-5.0.sql ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/mysql-5.0.sql (original) +++ freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/mysql-5.0.sql Fri Mar 20 15:31:05 2009 @@ -66,6 +66,7 @@ `carrier_id` int(11) default NULL, `prefix` varchar(255) NOT NULL, `suffix` varchar(255) NOT NULL, + `codec` varchar(255) NOT NULL, `enabled` boolean NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `carrier_id` (`carrier_id`) Modified: freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/postgres-8.3.sql ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/postgres-8.3.sql (original) +++ freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/postgres-8.3.sql Fri Mar 20 15:31:05 2009 @@ -20,6 +20,7 @@ carrier_id integer REFERENCES carriers(id), prefix VARCHAR(128) NOT NULL DEFAULT '', suffix VARCHAR(128) NOT NULL DEFAULT '', + codec VARCHAR(128) NOT NULL DEFAULT '', enabled boolean NOT NULL DEFAULT 'true', CONSTRAINT carrier_gateway_pkey PRIMARY KEY (id) ); From anthm at freeswitch.org Fri Mar 20 13:40:30 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 15:40:30 -0500 Subject: [Freeswitch-svn] [commit] r12691 - in freeswitch/trunk/src: . include Message-ID: Author: anthm Date: Fri Mar 20 15:40:30 2009 New Revision: 12691 Log: add transfer_after_bridge magic var Modified: freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/switch_ivr_bridge.c Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Fri Mar 20 15:40:30 2009 @@ -160,6 +160,7 @@ #define SWITCH_LOCAL_VIDEO_PORT_VARIABLE "local_video_port" #define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE "hangup_after_bridge" #define SWITCH_PARK_AFTER_BRIDGE_VARIABLE "park_after_bridge" +#define SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE "transfer_after_bridge" #define SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE "exec_after_bridge_app" #define SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE "exec_after_bridge_arg" #define SWITCH_MAX_FORWARDS_VARIABLE "max_forwards" Modified: freeswitch/trunk/src/switch_ivr_bridge.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_bridge.c (original) +++ freeswitch/trunk/src/switch_ivr_bridge.c Fri Mar 20 15:40:30 2009 @@ -456,11 +456,27 @@ return NULL; } +static void transfer_after_bridge(switch_core_session_t *session, const char *where) +{ + int argc; + char *argv[4] = { 0 }; + char *mydata; + + if (!switch_strlen_zero(where) && (mydata = switch_core_session_strdup(session, where))) { + if ((argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { + switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No extension specified.\n"); + } + } +} + static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); switch_ivr_bridge_data_t *bd = switch_channel_get_private(channel, "_bridge_"); switch_channel_state_t state; + const char *var; if (bd) { switch_channel_set_private(channel, "_bridge_", NULL); @@ -479,6 +495,8 @@ if (state < CS_HANGUP && switch_true(switch_channel_get_variable(channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) { switch_ivr_park_session(session); + } else if (state < CS_HANGUP && (var = switch_channel_get_variable(channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) { + transfer_after_bridge(session, var); } else { if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && bd && !bd->clean_exit && state != CS_PARK && state != CS_ROUTING && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) { @@ -808,6 +826,7 @@ switch_event_t *event; int br = 0; int inner_bridge = switch_channel_test_flag(caller_channel, CF_INNER_BRIDGE); + const char *var; switch_channel_set_flag(caller_channel, CF_ORIGINATOR); @@ -971,6 +990,8 @@ (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) { if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) { switch_ivr_park_session(session); + } else if ((var = switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) { + transfer_after_bridge(session, var); } else if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) { switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel)); } From anthm at freeswitch.org Fri Mar 20 13:41:30 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 15:41:30 -0500 Subject: [Freeswitch-svn] [commit] r12692 - in freeswitch/trunk/src: . mod/applications/mod_commands Message-ID: Author: anthm Date: Fri Mar 20 15:41:30 2009 New Revision: 12692 Log: fix xml code to dup the values instead of store direct pointers (scope issue) Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c freeswitch/trunk/src/switch_ivr.c Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original) +++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Fri Mar 20 15:41:30 2009 @@ -2420,8 +2420,8 @@ } switch_snprintf(id, sizeof(id), "%d", holder->rows); - - switch_xml_set_attr(switch_xml_set_flag(row, SWITCH_XML_DUP), strdup("row_id"), strdup(id)); + + switch_xml_set_attr_d(holder->xml, "row_id", id); for (x = 0; x < argc; x++) { char *name = columnNames[x]; @@ -2687,7 +2687,7 @@ char *xmlstr; switch_snprintf(count, sizeof(count), "%d", holder.count); - switch_xml_set_attr(switch_xml_set_flag(holder.xml, SWITCH_XML_DUP), strdup("row_count"), strdup(count)); + switch_xml_set_attr_d(holder.xml, "row_count", count); xmlstr = switch_xml_toxml(holder.xml, SWITCH_FALSE); if (xmlstr) { Modified: freeswitch/trunk/src/switch_ivr.c ============================================================================== --- freeswitch/trunk/src/switch_ivr.c (original) +++ freeswitch/trunk/src/switch_ivr.c Fri Mar 20 15:41:30 2009 @@ -1634,67 +1634,67 @@ if (!(param = switch_xml_add_child_d(xml, "username", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->username); + switch_xml_set_txt_d(param, caller_profile->username); if (!(param = switch_xml_add_child_d(xml, "dialplan", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->dialplan); + switch_xml_set_txt_d(param, caller_profile->dialplan); if (!(param = switch_xml_add_child_d(xml, "caller_id_name", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->caller_id_name); + switch_xml_set_txt_d(param, caller_profile->caller_id_name); if (!(param = switch_xml_add_child_d(xml, "ani", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->ani); + switch_xml_set_txt_d(param, caller_profile->ani); if (!(param = switch_xml_add_child_d(xml, "aniii", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->aniii); + switch_xml_set_txt_d(param, caller_profile->aniii); if (!(param = switch_xml_add_child_d(xml, "caller_id_number", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->caller_id_number); + switch_xml_set_txt_d(param, caller_profile->caller_id_number); if (!(param = switch_xml_add_child_d(xml, "network_addr", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->network_addr); + switch_xml_set_txt_d(param, caller_profile->network_addr); if (!(param = switch_xml_add_child_d(xml, "rdnis", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->rdnis); + switch_xml_set_txt_d(param, caller_profile->rdnis); if (!(param = switch_xml_add_child_d(xml, "destination_number", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->destination_number); + switch_xml_set_txt_d(param, caller_profile->destination_number); if (!(param = switch_xml_add_child_d(xml, "uuid", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->uuid); + switch_xml_set_txt_d(param, caller_profile->uuid); if (!(param = switch_xml_add_child_d(xml, "source", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->source); + switch_xml_set_txt_d(param, caller_profile->source); if (!(param = switch_xml_add_child_d(xml, "context", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->context); + switch_xml_set_txt_d(param, caller_profile->context); if (!(param = switch_xml_add_child_d(xml, "chan_name", off++))) { return -1; } - switch_xml_set_txt(param, caller_profile->chan_name); + switch_xml_set_txt_d(param, caller_profile->chan_name); return off; } From anthm at freeswitch.org Fri Mar 20 13:51:19 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 15:51:19 -0500 Subject: [Freeswitch-svn] [commit] r12693 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Fri Mar 20 15:51:19 2009 New Revision: 12693 Log: another regression Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Fri Mar 20 15:51:19 2009 @@ -309,8 +309,6 @@ switch_event_header_t *hi; char *bye_headers = NULL; - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); - SWITCH_STANDARD_STREAM(stream); if ((hi = switch_channel_variable_first(channel))) { for (; hi; hi = hi->next) { @@ -342,22 +340,25 @@ switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye"); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel)); - nua_bye(tech_pvt->nh, - SIPTAG_REASON_STR(reason), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), - TAG_END()); + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_bye(tech_pvt->nh, + SIPTAG_REASON_STR(reason), + TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_END()); + } } else { if (switch_channel_test_flag(channel, CF_OUTBOUND)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel)); if (!tech_pvt->got_bye) { switch_channel_set_variable(channel, "sip_hangup_disposition", "send_cancel"); } - - nua_cancel(tech_pvt->nh, - SIPTAG_REASON_STR(reason), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), - TAG_END()); + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + nua_cancel(tech_pvt->nh, + SIPTAG_REASON_STR(reason), + TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_END()); + } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause); if (!tech_pvt->got_bye) { @@ -372,7 +373,7 @@ } } - + sofia_set_flag_locked(tech_pvt, TFLAG_BYE); switch_safe_free(stream.data); } From brian at freeswitch.org Fri Mar 20 14:31:04 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 16:31:04 -0500 Subject: [Freeswitch-svn] [commit] r12694 - freeswitch/trunk/src/mod/applications/mod_commands Message-ID: Author: brian Date: Fri Mar 20 16:31:04 2009 New Revision: 12694 Log: gcc sux today Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original) +++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Fri Mar 20 16:31:04 2009 @@ -2420,8 +2420,8 @@ } switch_snprintf(id, sizeof(id), "%d", holder->rows); - - switch_xml_set_attr_d(holder->xml, "row_id", id); + + switch_xml_set_attr(switch_xml_set_flag(row, SWITCH_XML_DUP), strdup("row_id"), strdup(id)); for (x = 0; x < argc; x++) { char *name = columnNames[x]; @@ -2687,7 +2687,7 @@ char *xmlstr; switch_snprintf(count, sizeof(count), "%d", holder.count); - switch_xml_set_attr_d(holder.xml, "row_count", count); + switch_xml_set_attr(switch_xml_set_flag(holder.xml, SWITCH_XML_DUP), strdup("row_count"), strdup(count)); xmlstr = switch_xml_toxml(holder.xml, SWITCH_FALSE); if (xmlstr) { From anthm at freeswitch.org Fri Mar 20 15:03:43 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 17:03:43 -0500 Subject: [Freeswitch-svn] [commit] r12695 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Fri Mar 20 17:03:43 2009 New Revision: 12695 Log: fix itty bitty leak Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Mar 20 17:03:43 2009 @@ -3984,7 +3984,7 @@ su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua)); int network_port = 0; char *is_nat = NULL; - char *acl_token = NULL; + char acl_token[512] = ""; if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING)) { nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); @@ -4060,11 +4060,11 @@ if (ok) { if (token) { - acl_token = strdup(token); + switch_set_string(acl_token, token); } if (sofia_test_pflag(profile, PFLAG_AUTH_CALLS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s Approved by acl \"%s[%s]\". Access Granted.\n", - network_ip, switch_str_nil(last_acl), switch_str_nil(acl_token)); + network_ip, switch_str_nil(last_acl), acl_token); is_auth = 1; } } else { @@ -4123,7 +4123,7 @@ channel = tech_pvt->channel = switch_core_session_get_channel(session); - if (acl_token) { + if (*acl_token) { switch_channel_set_variable(channel, "acl_token", acl_token); if (strchr(acl_token, '@')) { if (switch_ivr_set_user(session, acl_token) == SWITCH_STATUS_SUCCESS) { @@ -4132,8 +4132,6 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Authenticating user %s\n", acl_token); } } - free(acl_token); - acl_token = NULL; } if (sip->sip_contact && sip->sip_contact->m_url) { From mikej at freeswitch.org Fri Mar 20 15:38:38 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 17:38:38 -0500 Subject: [Freeswitch-svn] [commit] r12696 - in freeswitch/trunk/src: . mod/applications/mod_lcr Message-ID: Author: mikej Date: Fri Mar 20 17:38:38 2009 New Revision: 12696 Log: fix windows build Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c freeswitch/trunk/src/switch_core_port_allocator.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Fri Mar 20 17:38:38 2009 @@ -527,6 +527,7 @@ switch_bool_t lookup_status; switch_channel_t *channel; char *id_str; + char *safe_sql; digits_copy = string_digitsonly(cb_struct->pool, digits); if (switch_strlen_zero(digits_copy)) { @@ -558,7 +559,6 @@ } /* set up the query to be executed */ - char *safe_sql; /* format the custom_sql */ safe_sql = format_custom_sql(profile->custom_sql, cb_struct, digits_copy); Modified: freeswitch/trunk/src/switch_core_port_allocator.c ============================================================================== --- freeswitch/trunk/src/switch_core_port_allocator.c (original) +++ freeswitch/trunk/src/switch_core_port_allocator.c Fri Mar 20 17:38:38 2009 @@ -118,7 +118,7 @@ int odd = switch_test_flag(alloc, SPF_ODD); switch_mutex_lock(alloc->mutex); - srand((unsigned)(intptr_t)port_ptr + (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now()); + srand((unsigned)((unsigned)(intptr_t)port_ptr + (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now())); while (alloc->track_used < alloc->track_len) { uint32_t index; From mikej at freeswitch.org Fri Mar 20 15:49:01 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 17:49:01 -0500 Subject: [Freeswitch-svn] [commit] r12697 - freeswitch/trunk/src Message-ID: Author: mikej Date: Fri Mar 20 17:49:01 2009 New Revision: 12697 Log: fix edge case segfault Modified: freeswitch/trunk/src/switch_ivr_async.c Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Fri Mar 20 17:49:01 2009 @@ -448,11 +448,10 @@ if (rh->fh) { switch_core_file_close(rh->fh); - } - - if (rh->fh->samples_out < read_impl.samples_per_second * 3) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file); - switch_file_remove(rh->file, switch_core_session_get_pool(session)); + if (rh->fh->samples_out < read_impl.samples_per_second * 3) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file); + switch_file_remove(rh->file, switch_core_session_get_pool(session)); + } } } From mikej at freeswitch.org Fri Mar 20 16:01:20 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 18:01:20 -0500 Subject: [Freeswitch-svn] [commit] r12698 - freeswitch/trunk/src/include Message-ID: Author: mikej Date: Fri Mar 20 18:01:20 2009 New Revision: 12698 Log: fix macros with missing ( ) Modified: freeswitch/trunk/src/include/switch_utils.h Modified: freeswitch/trunk/src/include/switch_utils.h ============================================================================== --- freeswitch/trunk/src/include/switch_utils.h (original) +++ freeswitch/trunk/src/include/switch_utils.h Fri Mar 20 18:01:20 2009 @@ -114,22 +114,22 @@ \return true or false */ #define switch_true(expr)\ -(expr && ( !strcasecmp(expr, "yes") ||\ +((expr && ( !strcasecmp(expr, "yes") ||\ !strcasecmp(expr, "on") ||\ !strcasecmp(expr, "true") ||\ !strcasecmp(expr, "enabled") ||\ !strcasecmp(expr, "active") ||\ !strcasecmp(expr, "allow") ||\ -atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE +atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE) #define switch_true_buf(expr)\ -(( !strcasecmp(expr, "yes") ||\ +((( !strcasecmp(expr, "yes") ||\ !strcasecmp(expr, "on") ||\ !strcasecmp(expr, "true") ||\ !strcasecmp(expr, "enabled") ||\ !strcasecmp(expr, "active") ||\ !strcasecmp(expr, "allow") ||\ -atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE +atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE) /*! \brief Evaluate the falsefullness of a string expression @@ -137,13 +137,13 @@ \return true or false */ #define switch_false(expr)\ -(expr && ( !strcasecmp(expr, "no") ||\ +((expr && ( !strcasecmp(expr, "no") ||\ !strcasecmp(expr, "off") ||\ !strcasecmp(expr, "false") ||\ !strcasecmp(expr, "disabled") ||\ !strcasecmp(expr, "inactive") ||\ !strcasecmp(expr, "disallow") ||\ -!atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE +!atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE) /*! From anthm at freeswitch.org Fri Mar 20 19:30:05 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 21:30:05 -0500 Subject: [Freeswitch-svn] [commit] r12699 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Fri Mar 20 21:30:05 2009 New Revision: 12699 Log: MODENDP-205 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Mar 20 21:30:05 2009 @@ -396,7 +396,8 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt) { - const char *abs, *codec_string = NULL; + const char *abs, *codec_string, *uuid; + switch_core_session_t *b_session = NULL; const char *ocodec = NULL; if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { @@ -409,7 +410,17 @@ switch_assert(tech_pvt->session != NULL); - if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { + if ((abs = switch_channel_get_variable(tech_pvt->channel, "inherit_codec")) && (switch_true(abs)) && (uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) != NULL && (b_session = switch_core_session_locate(uuid)) != NULL) { + switch_codec_implementation_t impl = {0}; + switch_core_session_get_read_impl(b_session, &impl); + if (impl.iananame == NULL || !(abs = switch_core_session_sprintf(tech_pvt->session, "%s@%uh", impl.iananame, impl.actual_samples_per_second))) { + abs = NULL; + } + } else { + abs = NULL; + } + + if (abs || (abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { codec_string = abs; } else { if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) { From anthm at freeswitch.org Fri Mar 20 19:31:15 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 21:31:15 -0500 Subject: [Freeswitch-svn] [commit] r12700 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Fri Mar 20 21:31:15 2009 New Revision: 12700 Log: MODENDP-205 revert Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Mar 20 21:31:15 2009 @@ -396,8 +396,7 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt) { - const char *abs, *codec_string, *uuid; - switch_core_session_t *b_session = NULL; + const char *abs, *codec_string = NULL; const char *ocodec = NULL; if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { @@ -410,17 +409,7 @@ switch_assert(tech_pvt->session != NULL); - if ((abs = switch_channel_get_variable(tech_pvt->channel, "inherit_codec")) && (switch_true(abs)) && (uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) != NULL && (b_session = switch_core_session_locate(uuid)) != NULL) { - switch_codec_implementation_t impl = {0}; - switch_core_session_get_read_impl(b_session, &impl); - if (impl.iananame == NULL || !(abs = switch_core_session_sprintf(tech_pvt->session, "%s@%uh", impl.iananame, impl.actual_samples_per_second))) { - abs = NULL; - } - } else { - abs = NULL; - } - - if (abs || (abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { + if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { codec_string = abs; } else { if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) { From brian at freeswitch.org Fri Mar 20 19:34:37 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Fri, 20 Mar 2009 21:34:37 -0500 Subject: [Freeswitch-svn] [commit] r12701 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: brian Date: Fri Mar 20 21:34:37 2009 New Revision: 12701 Log: free handles in error and failure conditions Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Mar 20 21:34:37 2009 @@ -333,6 +333,14 @@ int locked = 0; int check_destroy = 1; + if (nh && sofia_private == &mod_sofia_globals.keep_private) { + if (status >= 300) { + nua_handle_bind(nh, NULL); + nua_handle_destroy(nh); + return; + } + } + if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) { if ((gateway = sofia_private->gateway)) { if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) { Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Fri Mar 20 21:34:37 2009 @@ -1405,6 +1405,7 @@ } nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(h->profile->url), TAG_END()); + nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_notify(nh, NUTAG_NEWSUB(1), From silik0n at freeswitch.org Sat Mar 21 04:54:11 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 21 Mar 2009 06:54:11 -0500 Subject: [Freeswitch-svn] [commit] r12702 - freeswitch/trunk/scripts/contrib/swk/php/esl_cdr Message-ID: Author: silik0n Date: Sat Mar 21 06:54:11 2009 New Revision: 12702 Log: add auto-reconnection to ESL, change DB stuff to PDO for more better DB stuffs Modified: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php Modified: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php Sat Mar 21 06:54:11 2009 @@ -7,7 +7,17 @@ $esl_password = 'ClueCon'; -$db_url ="pgsql://root at localhost/esl_cdr"; +$dbtype='mysql'; /* Set the Database type */ +$db_hostname = 'localhost'; /* Database Server hostname */ +$db_port = '3306'; /* Database Server Port */ +$db_username = 'root'; /* Database Server username */ +$db_password = 'password'; /* Database Server password */ +$db_database = 'esl_cdr'; /* DataBase Name */ +if ($dbtype == 'mysql') { + $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,); +} + +$dbh = new PDO("$dbtype:host=$db_hostname;port=$db_port;dbname=$db_database", $db_username, $db_password, $pdo_flags); $con = MDB2::factory($db_url); if(PEAR::isError($con)) { @@ -15,12 +25,18 @@ } /* set up the ESL Connection */ -$esl = new eslConnection('204.8.45.218', '8021', 'disasterisk-sucks'); +$esl = new eslConnection($esl_host, $esl_port, $esl_password); $e = $esl->sendRecv("api status"); print $e->getBody(); $esl->events("plain", "channel_hangup"); for(;;) { - print "foo - 1\n"; + while (!$esl->connected()) { + // if the connection is down, loop until we're able to reconnect + $esl = new eslConnection($esl_host, $esl_port, $esl_password); + $esl->events("plain", "channel_hangup"); + + sleep (1); + } $e = $esl->recvEvent(); if ($e) { $lines = explode("\n", $e->serialize()); @@ -82,11 +98,6 @@ "0" ); - $result = $con->query($insert); - if(PEAR::isError($result)) { - echo "$insert\n"; - die(); - } - } + $dbh->exec($insert) or die($db->errorInfo()); } ?> From silik0n at freeswitch.org Sat Mar 21 05:18:54 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 21 Mar 2009 07:18:54 -0500 Subject: [Freeswitch-svn] [commit] r12703 - freeswitch/trunk/scripts/contrib/swk/php/esl_cdr Message-ID: Author: silik0n Date: Sat Mar 21 07:18:54 2009 New Revision: 12703 Log: oops Modified: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php Modified: freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/esl_cdr/esl_cdr.php Sat Mar 21 07:18:54 2009 @@ -98,6 +98,9 @@ "0" ); - $dbh->exec($insert) or die($db->errorInfo()); + $inserted = $dbh->exec($insert); + if ($inserted < 1){ + die($db->errorInfo()); + } } ?> From anthm at freeswitch.org Sat Mar 21 09:47:16 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 21 Mar 2009 11:47:16 -0500 Subject: [Freeswitch-svn] [commit] r12704 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sat Mar 21 11:47:16 2009 New Revision: 12704 Log: fix regression from r12585 FSCORE-331 Modified: freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Sat Mar 21 11:47:16 2009 @@ -2142,11 +2142,11 @@ } if (*bleg) { - if (caller_channel && !switch_channel_get_originatee_caller_profile(caller_channel)) { + if (session && caller_channel && !switch_channel_get_originatee_caller_profile(caller_channel)) { switch_caller_profile_t *cloned_profile, *peer_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(*bleg)); if (peer_profile) { - if ((cloned_profile = switch_caller_profile_clone(*bleg, peer_profile)) != 0) { + if ((cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) { switch_channel_set_originatee_caller_profile(caller_channel, cloned_profile); } } From anthm at freeswitch.org Sat Mar 21 09:47:58 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sat, 21 Mar 2009 11:47:58 -0500 Subject: [Freeswitch-svn] [commit] r12705 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sat Mar 21 11:47:57 2009 New Revision: 12705 Log: add mutex to global mem pool and tweak var code Modified: freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_core_memory.c Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Sat Mar 21 11:47:57 2009 @@ -485,7 +485,7 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname) { - const char *v = NULL; + const char *v = NULL, *r = NULL; switch_assert(channel != NULL); switch_mutex_lock(channel->profile_mutex); @@ -507,17 +507,17 @@ } } - if (v) v = switch_core_session_strdup(channel->session, v); + if (v) r = switch_core_session_strdup(channel->session, v); switch_mutex_unlock(channel->profile_mutex); - return v; + return r; } SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname) { const char *uuid; - const char *val = NULL; + const char *val = NULL, *r = NULL; switch_assert(channel != NULL); if (!switch_strlen_zero(varname)) { @@ -531,9 +531,9 @@ } } - if (val) val = switch_core_session_strdup(channel->session, val); + if (val) r = switch_core_session_strdup(channel->session, val); - return val; + return r; } Modified: freeswitch/trunk/src/switch_core_memory.c ============================================================================== --- freeswitch/trunk/src/switch_core_memory.c (original) +++ freeswitch/trunk/src/switch_core_memory.c Sat Mar 21 11:47:57 2009 @@ -569,11 +569,12 @@ abort(); } - if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_DEFAULT, memory_manager.memory_pool)) != APR_SUCCESS) { + if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED, memory_manager.memory_pool)) != APR_SUCCESS) { abort(); } apr_allocator_mutex_set(my_allocator, my_mutex); + apr_pool_mutex_set(memory_manager.memory_pool, my_mutex); apr_allocator_owner_set(my_allocator, memory_manager.memory_pool); #else apr_pool_create(&memory_manager.memory_pool, NULL); From brian at freeswitch.org Sat Mar 21 16:24:49 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Sat, 21 Mar 2009 18:24:49 -0500 Subject: [Freeswitch-svn] [commit] r12706 - freeswitch/trunk/patches Message-ID: Author: brian Date: Sat Mar 21 18:24:48 2009 New Revision: 12706 Log: do_patches Added: freeswitch/trunk/patches/sofia.diff Removed: freeswitch/trunk/patches/pa.diff Added: freeswitch/trunk/patches/sofia.diff ============================================================================== --- (empty file) +++ freeswitch/trunk/patches/sofia.diff Sat Mar 21 18:24:48 2009 @@ -0,0 +1,383 @@ +Index: src/mod/endpoints/mod_sofia/sofia_reg.c +=================================================================== +--- src/mod/endpoints/mod_sofia/sofia_reg.c (revision 12705) ++++ src/mod/endpoints/mod_sofia/sofia_reg.c (working copy) +@@ -37,26 +37,56 @@ + */ + #include "mod_sofia.h" + +-static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr, int unreg) ++static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr) + { ++ int ss_state = nua_callstate_authenticating; ++ + if (gateway_ptr->nh) { +- if (unreg) { +- nua_unregister(gateway_ptr->nh, +- NUTAG_URL(gateway_ptr->register_url), +- SIPTAG_FROM_STR(gateway_ptr->register_from), +- SIPTAG_TO_STR(gateway_ptr->register_from), +- SIPTAG_CONTACT_STR(gateway_ptr->register_contact), +- SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), +- NUTAG_REGISTRAR(gateway_ptr->register_proxy), +- NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); +- } + nua_handle_bind(gateway_ptr->nh, NULL); + nua_handle_destroy(gateway_ptr->nh); + gateway_ptr->nh = NULL; ++ sofia_private_free(gateway_ptr->sofia_private); + } + ++ gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, ++ SIPTAG_CALL_ID_STR(gateway_ptr->uuid_str), ++ NUTAG_URL(gateway_ptr->register_proxy), ++ SIPTAG_TO_STR(gateway_ptr->register_to), ++ NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); ++ ++ ++ if (!gateway_ptr->sofia_private) { ++ gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); ++ switch_assert(gateway_ptr->sofia_private); ++ } ++ memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); ++ ++ gateway_ptr->sofia_private->gateway = gateway_ptr; ++ nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); + } + ++static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr) ++{ ++ ++ if (!gateway_ptr->nh) { ++ sofia_reg_new_handle(gateway_ptr); ++ ++ } ++ ++ if (gateway_ptr->nh) { ++ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UNRegistering %s\n", gateway_ptr->name); ++ nua_unregister(gateway_ptr->nh, ++ NUTAG_URL(gateway_ptr->register_url), ++ SIPTAG_FROM_STR(gateway_ptr->register_from), ++ SIPTAG_TO_STR(gateway_ptr->register_from), ++ SIPTAG_CONTACT_STR(gateway_ptr->register_contact), ++ SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), ++ NUTAG_REGISTRAR(gateway_ptr->register_proxy), ++ NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); ++ } ++ ++} ++ + static void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway) { + switch_event_t *s_event; + if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_STATE) == SWITCH_STATUS_SUCCESS) { +@@ -71,10 +101,9 @@ + sofia_gateway_t *gateway_ptr; + for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { + if (gateway_ptr->sofia_private) { +- free(gateway_ptr->sofia_private); +- gateway_ptr->sofia_private = NULL; ++ sofia_private_free(gateway_ptr->sofia_private); + } +- sofia_reg_kill_reg(gateway_ptr, 1); ++ sofia_reg_kill_reg(gateway_ptr); + } + } + +@@ -108,7 +137,7 @@ + break; + case SUB_STATE_UNSUBSCRIBE: + gw_sub_ptr->state = SUB_STATE_NOSUB; +- ++ + /* not tested .. */ + nua_unsubscribe(gateway_ptr->nh, + NUTAG_URL(gateway_ptr->register_url), +@@ -121,24 +150,23 @@ + + break; + case SUB_STATE_UNSUBED: +- if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, +- NUTAG_URL(gateway_ptr->register_proxy), +- SIPTAG_TO_STR(gateway_ptr->register_to), +- NUTAG_CALLSTATE_REF(ss_state), +- SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) { +- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); +- } ++ gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL, ++ NUTAG_URL(gateway_ptr->register_proxy), ++ SIPTAG_TO_STR(gateway_ptr->register_to), ++ NUTAG_CALLSTATE_REF(ss_state), ++ SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); ++ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); + + gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); + switch_assert(gateway_ptr->sofia_private); +- ++ + memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); + + gateway_ptr->sofia_private->gateway = gateway_ptr; + nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); + + if (now) { +- nua_subscribe(gateway_ptr->nh, ++ nua_subscribe(gateway_ptr->sub_nh, + NUTAG_URL(gateway_ptr->register_url), + SIPTAG_EVENT_STR(gw_sub_ptr->event), + SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), +@@ -149,7 +177,7 @@ + TAG_NULL()); + gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds; + } else { +- nua_unsubscribe(gateway_ptr->nh, ++ nua_unsubscribe(gateway_ptr->sub_nh, + NUTAG_URL(gateway_ptr->register_url), + SIPTAG_EVENT_STR(gw_sub_ptr->event), + SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), +@@ -207,7 +235,6 @@ + } + + for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { +- int ss_state = nua_callstate_authenticating; + reg_state_t ostate = gateway_ptr->state; + + if (!now) { +@@ -223,6 +250,7 @@ + switch_assert(pvt); + memset(pvt, 0, sizeof(*pvt)); + pvt->destroy_nh = 1; ++ pvt->destroy_me = 1; + switch_copy_string(pvt->gateway_name, gateway_ptr->name, sizeof(pvt->gateway_name)); + nua_handle_bind(nh, pvt); + +@@ -254,64 +282,46 @@ + break; + + case REG_STATE_UNREGISTER: +- sofia_reg_kill_reg(gateway_ptr, 1); ++ sofia_reg_kill_reg(gateway_ptr); + gateway_ptr->state = REG_STATE_NOREG; + break; + case REG_STATE_UNREGED: + gateway_ptr->status = SOFIA_GATEWAY_DOWN; +- sofia_reg_kill_reg(gateway_ptr, 0); ++ ++ sofia_reg_new_handle(gateway_ptr); + +- if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, +- SIPTAG_CALL_ID_STR(gateway_ptr->uuid_str), +- NUTAG_URL(gateway_ptr->register_proxy), +- SIPTAG_TO_STR(gateway_ptr->register_to), +- NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) { +- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name); +- +- if (!gateway_ptr->sofia_private) { +- gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); +- switch_assert(gateway_ptr->sofia_private); +- } +- memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); +- +- gateway_ptr->sofia_private->gateway = gateway_ptr; +- nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); +- +- if (now) { +- nua_register(gateway_ptr->nh, +- NUTAG_URL(gateway_ptr->register_url), +- TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)), +- SIPTAG_TO_STR(gateway_ptr->register_from), +- SIPTAG_FROM_STR(gateway_ptr->register_from), +- SIPTAG_CONTACT_STR(gateway_ptr->register_contact), +- SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), +- NUTAG_REGISTRAR(gateway_ptr->register_proxy), +- NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); +- gateway_ptr->retry = now + gateway_ptr->retry_seconds; +- } else { +- nua_unregister(gateway_ptr->nh, +- NUTAG_URL(gateway_ptr->register_url), +- SIPTAG_FROM_STR(gateway_ptr->register_from), +- SIPTAG_TO_STR(gateway_ptr->register_from), +- SIPTAG_CONTACT_STR(gateway_ptr->register_contact), +- SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), +- NUTAG_REGISTRAR(gateway_ptr->register_proxy), +- NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); +- } ++ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name); ++ ++ if (now) { ++ nua_register(gateway_ptr->nh, ++ NUTAG_URL(gateway_ptr->register_url), ++ TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)), ++ SIPTAG_TO_STR(gateway_ptr->register_from), ++ SIPTAG_FROM_STR(gateway_ptr->register_from), ++ SIPTAG_CONTACT_STR(gateway_ptr->register_contact), ++ SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), ++ NUTAG_REGISTRAR(gateway_ptr->register_proxy), ++ NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); + gateway_ptr->retry = now + gateway_ptr->retry_seconds; +- gateway_ptr->state = REG_STATE_TRYING; +- + } else { +- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error registering %s failure #%d\n", gateway_ptr->name, ++gateway_ptr->failures); +- gateway_ptr->state = REG_STATE_FAILED; ++ nua_unregister(gateway_ptr->nh, ++ NUTAG_URL(gateway_ptr->register_url), ++ SIPTAG_FROM_STR(gateway_ptr->register_from), ++ SIPTAG_TO_STR(gateway_ptr->register_from), ++ SIPTAG_CONTACT_STR(gateway_ptr->register_contact), ++ SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), ++ NUTAG_REGISTRAR(gateway_ptr->register_proxy), ++ NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); + } ++ gateway_ptr->retry = now + gateway_ptr->retry_seconds; ++ gateway_ptr->state = REG_STATE_TRYING; ++ + break; + + case REG_STATE_FAILED: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Failed Registration, setting retry to %d seconds.\n", + gateway_ptr->name, gateway_ptr->retry_seconds * (gateway_ptr->failures + 1)); + gateway_ptr->retry = now + (gateway_ptr->retry_seconds * (gateway_ptr->failures + 1)); +- sofia_reg_kill_reg(gateway_ptr, 0); + gateway_ptr->status = SOFIA_GATEWAY_DOWN; + gateway_ptr->state = REG_STATE_FAIL_WAIT; + break; +@@ -408,6 +418,7 @@ + SIPTAG_CONTACT_STR(profile->url), + TAG_END()); + ++ nua_handle_bind(nh, &mod_sofia_globals.destroy_private); + nua_notify(nh, + NUTAG_NEWSUB(1), + SIPTAG_EVENT_STR(event), +@@ -1275,6 +1286,23 @@ + if (ostate != sofia_private->gateway->state) { + sofia_reg_fire_custom_gateway_state_event(sofia_private->gateway); + } ++ ++ ++ if (status >= 200) { ++ if (sofia_private) { ++ if (sofia_private->gateway) { ++ nua_handle_destroy(sofia_private->gateway->nh); ++ sofia_private->gateway->nh = NULL; ++ nua_handle_bind(sofia_private->gateway->nh, NULL); ++ sofia_private->gateway->sofia_private = NULL; ++ } else { ++ nua_handle_destroy(nh); ++ } ++ sofia_private_free(sofia_private); ++ } else { ++ nua_handle_destroy(nh); ++ } ++ } + } + } + +Index: src/mod/endpoints/mod_sofia/mod_sofia.c +=================================================================== +--- src/mod/endpoints/mod_sofia/mod_sofia.c (revision 12705) ++++ src/mod/endpoints/mod_sofia/mod_sofia.c (working copy) +@@ -2703,6 +2703,8 @@ + SIPTAG_CONTACT_STR(profile->url), + TAG_END()); + ++ nua_handle_bind(nh, &mod_sofia_globals.destroy_private); ++ + nua_notify(nh, + NUTAG_NEWSUB(1), + SIPTAG_EVENT_STR(es), +@@ -2902,6 +2904,8 @@ + + memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals)); + mod_sofia_globals.destroy_private.destroy_nh = 1; ++ mod_sofia_globals.destroy_private.is_static = 1; ++ mod_sofia_globals.keep_private.is_static = 1; + mod_sofia_globals.pool = pool; + switch_mutex_init(&mod_sofia_globals.mutex, SWITCH_MUTEX_NESTED, mod_sofia_globals.pool); + +Index: src/mod/endpoints/mod_sofia/sofia.c +=================================================================== +--- src/mod/endpoints/mod_sofia/sofia.c (revision 12705) ++++ src/mod/endpoints/mod_sofia/sofia.c (working copy) +@@ -111,6 +111,7 @@ + sofia_sla_handle_sip_i_notify(nua, profile, nh, sip, tags); + + if (sub_state == nua_substate_terminated) { ++ sofia_private_free(sofia_private); + nua_handle_bind(nh, NULL); + nua_handle_destroy(nh); + } +@@ -544,8 +545,7 @@ + nua_handle_bind(nh, NULL); + } + sofia_private->destroy_me = 12; +- free(sofia_private); +- sofia_private = NULL; ++ sofia_private_free(sofia_private); + } + + if (gateway) { +@@ -4721,7 +4721,7 @@ + } + + nua_handle_bind(nh, NULL); +- free(sofia_private); ++ sofia_private_free(sofia_private); + switch_core_session_destroy(&session); + nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + } +Index: src/mod/endpoints/mod_sofia/mod_sofia.h +=================================================================== +--- src/mod/endpoints/mod_sofia/mod_sofia.h (revision 12705) ++++ src/mod/endpoints/mod_sofia/mod_sofia.h (working copy) +@@ -122,10 +122,12 @@ + int destroy_nh; + int destroy_me; + int is_call; ++ int is_static; + }; + + #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);} + #define set_anchor(t,m) if (t->Anchor) {delete t->Anchor;} t->Anchor = new SipMessage(m); ++#define sofia_private_free(_pvt) if (_pvt && ! _pvt->is_static) {free(_pvt); _pvt = NULL;} + + /* Local Structures */ + /*************************************************************************************************************************************************************/ +@@ -321,6 +323,7 @@ + struct sofia_gateway { + sofia_private_t *sofia_private; + nua_handle_t *nh; ++ nua_handle_t *sub_nh; + sofia_profile_t *profile; + char *name; + char *register_scheme; +Index: src/mod/endpoints/mod_sofia/sofia_presence.c +=================================================================== +--- src/mod/endpoints/mod_sofia/sofia_presence.c (revision 12705) ++++ src/mod/endpoints/mod_sofia/sofia_presence.c (working copy) +@@ -177,7 +177,7 @@ + SIPTAG_FROM_STR(from), NUTAG_URL(contact), + SIPTAG_TO_STR(clean_to), SIPTAG_CONTACT_STR(profile->url), + TAG_END()); +- ++ nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private); + nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), TAG_END()); + + end: +@@ -1860,6 +1860,16 @@ + default: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status); + gw_sub_ptr->state = SUB_STATE_FAILED; ++ ++ if (sofia_private) { ++ nua_handle_destroy(sofia_private->gateway->sub_nh); ++ sofia_private->gateway->sub_nh = NULL; ++ nua_handle_bind(sofia_private->gateway->sub_nh, NULL); ++ sofia_private_free(sofia_private); ++ } else { ++ nua_handle_destroy(nh); ++ } ++ + break; + } + } From silik0n at freeswitch.org Sat Mar 21 21:59:54 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sat, 21 Mar 2009 23:59:54 -0500 Subject: [Freeswitch-svn] [commit] r12707 - in freeswitch/trunk/scripts/contrib/swk/php: amfphp xml_curl Message-ID: Author: silik0n Date: Sat Mar 21 23:59:54 2009 New Revision: 12707 Log: fix a few little issues and dont connect to ESL when we dont need to Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sat Mar 21 23:59:54 2009 @@ -38,8 +38,6 @@ require_once "ESL.php"; class FreeSWITCH { - var $esl; - var $dbh; private function getDbh(){ $dbtype='mysql'; /* Set the Database type */ @@ -56,23 +54,26 @@ return $dbh; } - public function __construct() { + private function getEsl(){ $esl_server = "127.0.0.1"; /* ESL Server */ $esl_port = "8021"; /* ESL Port */ $esl_secret = "ClueCon"; /* ESL Secret */ - $this->esl = new eslConnection($esl_server, $esl_port, $esl_secret); + $esl = new eslConnection($esl_server, $esl_port, $esl_secret); + return $esl; } /*** General Whats happening Methods ***/ public function getStatus() { - $e = $this->esl->sendRecv("api status"); + $esl = getEsl(); + $e = $esl->sendRecv("api status"); $body = $e->getBody(); return $body; } public function getChannels() { - $e = $this->esl->sendRecv("api show channels"); + $esl = getEsl(); + $e = $esl->sendRecv("api show channels"); $body = $e->getBody(); $temp = explode ("\n", $body); $total_count = sizeof($temp); @@ -101,7 +102,8 @@ } public function getCalls() { - $e = $this->esl->sendRecv("api show calls"); + $esl = getEsl(); + $e = $esl->sendRecv("api show calls"); $body = $e->getBody(); $temp = explode ("\n", $body); $total_count = sizeof($temp); @@ -129,13 +131,15 @@ public function originate($call_url, $exten, $dialplan = "XML", $context= "default", $cid_name = "amf_php", $cid_number = "888", $timeout="30"){ $dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout"; - $e = $this->esl->sendRecv($dialstring); + $esl = getEsl(); + $e = $esl->sendRecv($dialstring); $body = $e->getBody(); return $body; } public function killUuid($uuid) { - $e = $this->esl->sendRecv("api uuid_kill $uuid"); + $esl = getEsl(); + $e = $esl->sendRecv("api uuid_kill $uuid"); $body = $e->getBody(); return $body; } @@ -143,13 +147,15 @@ /*** Conference Methods ***/ public function kickConferenceUser($conference, $member) { - $e = $this->esl->sendRecv("api conference $conference kick $member"); + $esl = getEsl(); + $e = $esl->sendRecv("api conference $conference kick $member"); $body = $e->getBody(); return $body; } public function getConferenceList() { - $e = $this->esl->sendRecv("api conference list"); + $esl = getEsl(); + $e = $esl->sendRecv("api conference list"); $body = $e->getBody(); $data=explode("\n", $body); $y=0; @@ -164,7 +170,8 @@ } public function getConferenceUsers($conference_name) { - $e = $this->esl->sendRecv("api conference $conference_name list"); + $esl = getEsl(); + $e = $esl->sendRecv("api conference $conference_name list"); $body = $e->getBody(); $data=explode("\n", $body); $y=0; @@ -218,35 +225,40 @@ public function confPlayfile($conference, $file_path){ $playfile = "api conference $conference play " . $file_path; - $e = $this->esl->sendRecv($playfile); + $esl = getEsl(); + $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; } public function confLock($conference){ $playfile = "api conference $conference lock"; - $e = $this->esl->sendRecv($playfile); + $esl = getEsl(); + $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; } public function confUnlock($conference){ $playfile = "api conference $conference unlock"; - $e = $this->esl->sendRecv($playfile); + $esl = getEsl(); + $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; } public function confMute($conference, $member){ $playfile = "api conference $conference mute $member"; - $e = $this->esl->sendRecv($playfile); + $esl = getEsl(); + $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; } public function confUnmute($conference, $member){ $playfile = "api conference $conference unmute $member"; - $e = $this->esl->sendRecv($playfile); + $esl = getEsl(); + $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; } Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Sat Mar 21 23:59:54 2009 @@ -20,7 +20,7 @@ $user="1000"; */ -if ($section == "directory" && $tag_name == "domain" && $key_name == "name") { +if ($section == "directory" && $tag_name == "domain" && $key_name == "name" && $user != "" ) { $db_domain = $fsd->getDirDomainbyName($key_value); } else { printf("\n\n
\n". @@ -28,16 +28,29 @@ die(); } -$db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user); -$db_user_settings = $fsd->getDirUser($db_user['uid']); +$db_domain_settings = $fsd->getDirDomain($db_domain['uid']); + + +$db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user); +$db_user_settings = $fsd->getDirUser($db_user['uid']); $db_groups = $fsd->getDirGroupsByDomianUidByUserUid($db_domain['uid'], $db_user['uid']); printf(" \n"); printf(" \n"); printf("
\n"); printf(" \n", $db_domain['name']); +printf(" \n"); +foreach($db_domain_settings['params'] as $db_params) { + printf(" \n", $db_params['name'], $db_params['value']); +} +printf(" \n"); +printf(" \n"); +foreach($db_domain_settings['variables'] as $db_variables) { + printf(" \n", $db_variables['name'], $db_variables['value']); +} +printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); From anthm at freeswitch.org Sat Mar 21 22:15:17 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 00:15:17 -0500 Subject: [Freeswitch-svn] [commit] r12708 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Sun Mar 22 00:15:17 2009 New Revision: 12708 Log: clean up dialog stuff on presence for sla and other stuff Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Sun Mar 22 00:15:17 2009 @@ -2703,6 +2703,8 @@ SIPTAG_CONTACT_STR(profile->url), TAG_END()); + nua_handle_bind(nh, &mod_sofia_globals.destroy_private); + nua_notify(nh, NUTAG_NEWSUB(1), SIPTAG_EVENT_STR(es), @@ -2902,6 +2904,8 @@ memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals)); mod_sofia_globals.destroy_private.destroy_nh = 1; + mod_sofia_globals.destroy_private.is_static = 1; + mod_sofia_globals.keep_private.is_static = 1; mod_sofia_globals.pool = pool; switch_mutex_init(&mod_sofia_globals.mutex, SWITCH_MUTEX_NESTED, mod_sofia_globals.pool); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Sun Mar 22 00:15:17 2009 @@ -122,10 +122,12 @@ int destroy_nh; int destroy_me; int is_call; + int is_static; }; #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);} #define set_anchor(t,m) if (t->Anchor) {delete t->Anchor;} t->Anchor = new SipMessage(m); +#define sofia_private_free(_pvt) if (_pvt && ! _pvt->is_static) {free(_pvt); _pvt = NULL;} /* Local Structures */ /*************************************************************************************************************************************************************/ @@ -321,6 +323,7 @@ struct sofia_gateway { sofia_private_t *sofia_private; nua_handle_t *nh; + nua_handle_t *sub_nh; sofia_profile_t *profile; char *name; char *register_scheme; @@ -810,10 +813,12 @@ * SLA (shared line appearance) entrypoints */ -void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const *sip); +void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const *sip, long exptime, const char *full_contact); void sofia_sla_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); -void sofia_sla_handle_sip_r_subscribe(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); +void sofia_sla_handle_sip_r_subscribe(int status, + char const *phrase, + nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]); void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]); /* Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sun Mar 22 00:15:17 2009 @@ -111,6 +111,7 @@ sofia_sla_handle_sip_i_notify(nua, profile, nh, sip, tags); if (sub_state == nua_substate_terminated) { + sofia_private_free(sofia_private); nua_handle_bind(nh, NULL); nua_handle_destroy(nh); } @@ -544,8 +545,7 @@ nua_handle_bind(nh, NULL); } sofia_private->destroy_me = 12; - free(sofia_private); - sofia_private = NULL; + sofia_private_free(sofia_private); } if (gateway) { @@ -4721,7 +4721,7 @@ } nua_handle_bind(nh, NULL); - free(sofia_private); + sofia_private_free(sofia_private); switch_core_session_destroy(&session); nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Sun Mar 22 00:15:17 2009 @@ -3265,6 +3265,15 @@ " contact_str VARCHAR(255)\n" ");\n"; + char shared_appearance_dialogs_sql[] = + "CREATE TABLE sip_shared_appearance_dialogs (\n" + " profile_name VARCHAR(255),\n" + " hostname VARCHAR(255),\n" + " contact_str VARCHAR(255),\n" + " call_id VARCHAR(255),\n" + " expires INTEGER\n" + ");\n"; + if (profile->odbc_dsn) { #ifdef SWITCH_HAVE_ODBC int x; @@ -3298,6 +3307,13 @@ "create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)", "create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)", "create index ssa_aor on sip_shared_appearance_subscriptions (aor)", + + "create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)", + "create index ssd_hostname on sip_shared_appearance_dialogs (hostname)", + "create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)", + "create index ssd_call_id on sip_shared_appearance_dialogs (call_id)", + "create index ssd_expires on sip_shared_appearance_dialogs (expires)", + NULL }; @@ -3361,6 +3377,15 @@ } free(test_sql); + + test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str='' or hostname='%q'", mod_sofia_globals.hostname); + if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { + switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_dialogs", NULL); + switch_odbc_handle_exec(profile->master_odbc, shared_appearance_dialogs_sql, NULL); + } + free(test_sql); + + for (x = 0; indexes[x]; x++) { switch_odbc_handle_exec(profile->master_odbc, indexes[x], NULL); } @@ -3402,6 +3427,10 @@ test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql); free(test_sql); + + test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname); + switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql); + free(test_sql); switch_core_db_exec(profile->master_db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)", NULL, NULL, NULL); @@ -3412,6 +3441,18 @@ switch_core_db_exec(profile->master_db, "create index if not exists ssa_aor on sip_shared_appearance_subscriptions (aor)", NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists ssd_profile_name on sip_shared_appearance_dialogs (profile_name)", + NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)", + NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)", + NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)", + NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists ssd_expires on sip_shared_appearance_dialogs (expires)", + NULL, NULL, NULL); + + switch_core_db_exec(profile->master_db, "create index if not exists sr_call_id on sip_registrations (call_id)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists sr_sip_user on sip_registrations (sip_user)", NULL, NULL, NULL); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Sun Mar 22 00:15:17 2009 @@ -177,7 +177,7 @@ SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(clean_to), SIPTAG_CONTACT_STR(profile->url), TAG_END()); - + nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private); nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), TAG_END()); end: @@ -1827,7 +1827,7 @@ /* the following could possibly be refactored back towards the calling event handler in sofia.c XXX MTK */ if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (!strcasecmp(o->o_type, "dialog") && msg_params_find(o->o_params, "sla")) { - sofia_sla_handle_sip_r_subscribe(nua, profile, nh, sip, tags); + sofia_sla_handle_sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags); return; } } @@ -1860,6 +1860,16 @@ default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status); gw_sub_ptr->state = SUB_STATE_FAILED; + + if (sofia_private) { + nua_handle_destroy(sofia_private->gateway->sub_nh); + sofia_private->gateway->sub_nh = NULL; + nua_handle_bind(sofia_private->gateway->sub_nh, NULL); + sofia_private_free(sofia_private); + } else { + nua_handle_destroy(nh); + } + break; } } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Sun Mar 22 00:15:17 2009 @@ -37,24 +37,54 @@ */ #include "mod_sofia.h" -static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr, int unreg) +static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr) { + int ss_state = nua_callstate_authenticating; + if (gateway_ptr->nh) { - if (unreg) { - nua_unregister(gateway_ptr->nh, - NUTAG_URL(gateway_ptr->register_url), - SIPTAG_FROM_STR(gateway_ptr->register_from), - SIPTAG_TO_STR(gateway_ptr->register_from), - SIPTAG_CONTACT_STR(gateway_ptr->register_contact), - SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), - NUTAG_REGISTRAR(gateway_ptr->register_proxy), - NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); - } nua_handle_bind(gateway_ptr->nh, NULL); nua_handle_destroy(gateway_ptr->nh); gateway_ptr->nh = NULL; + sofia_private_free(gateway_ptr->sofia_private); } + gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, + SIPTAG_CALL_ID_STR(gateway_ptr->uuid_str), + NUTAG_URL(gateway_ptr->register_proxy), + SIPTAG_TO_STR(gateway_ptr->register_to), + NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); + + + if (!gateway_ptr->sofia_private) { + gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); + switch_assert(gateway_ptr->sofia_private); + } + memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); + + gateway_ptr->sofia_private->gateway = gateway_ptr; + nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); +} + +static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr) +{ + + if (!gateway_ptr->nh) { + sofia_reg_new_handle(gateway_ptr); + + } + + if (gateway_ptr->nh) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Registering %s\n", gateway_ptr->name); + nua_unregister(gateway_ptr->nh, + NUTAG_URL(gateway_ptr->register_url), + SIPTAG_FROM_STR(gateway_ptr->register_from), + SIPTAG_TO_STR(gateway_ptr->register_from), + SIPTAG_CONTACT_STR(gateway_ptr->register_contact), + SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), + NUTAG_REGISTRAR(gateway_ptr->register_proxy), + NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); + } + } static void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway) { @@ -71,10 +101,9 @@ sofia_gateway_t *gateway_ptr; for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { if (gateway_ptr->sofia_private) { - free(gateway_ptr->sofia_private); - gateway_ptr->sofia_private = NULL; + sofia_private_free(gateway_ptr->sofia_private); } - sofia_reg_kill_reg(gateway_ptr, 1); + sofia_reg_kill_reg(gateway_ptr); } } @@ -108,7 +137,7 @@ break; case SUB_STATE_UNSUBSCRIBE: gw_sub_ptr->state = SUB_STATE_NOSUB; - + /* not tested .. */ nua_unsubscribe(gateway_ptr->nh, NUTAG_URL(gateway_ptr->register_url), @@ -121,24 +150,23 @@ break; case SUB_STATE_UNSUBED: - if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, - NUTAG_URL(gateway_ptr->register_proxy), - SIPTAG_TO_STR(gateway_ptr->register_to), - NUTAG_CALLSTATE_REF(ss_state), - SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); - } + gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL, + NUTAG_URL(gateway_ptr->register_proxy), + SIPTAG_TO_STR(gateway_ptr->register_to), + NUTAG_CALLSTATE_REF(ss_state), + SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); switch_assert(gateway_ptr->sofia_private); - + memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); gateway_ptr->sofia_private->gateway = gateway_ptr; nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); if (now) { - nua_subscribe(gateway_ptr->nh, + nua_subscribe(gateway_ptr->sub_nh, NUTAG_URL(gateway_ptr->register_url), SIPTAG_EVENT_STR(gw_sub_ptr->event), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), @@ -149,7 +177,7 @@ TAG_NULL()); gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds; } else { - nua_unsubscribe(gateway_ptr->nh, + nua_unsubscribe(gateway_ptr->sub_nh, NUTAG_URL(gateway_ptr->register_url), SIPTAG_EVENT_STR(gw_sub_ptr->event), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), @@ -207,7 +235,6 @@ } for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { - int ss_state = nua_callstate_authenticating; reg_state_t ostate = gateway_ptr->state; if (!now) { @@ -223,6 +250,7 @@ switch_assert(pvt); memset(pvt, 0, sizeof(*pvt)); pvt->destroy_nh = 1; + pvt->destroy_me = 1; switch_copy_string(pvt->gateway_name, gateway_ptr->name, sizeof(pvt->gateway_name)); nua_handle_bind(nh, pvt); @@ -254,64 +282,46 @@ break; case REG_STATE_UNREGISTER: - sofia_reg_kill_reg(gateway_ptr, 1); + sofia_reg_kill_reg(gateway_ptr); gateway_ptr->state = REG_STATE_NOREG; break; case REG_STATE_UNREGED: gateway_ptr->status = SOFIA_GATEWAY_DOWN; - sofia_reg_kill_reg(gateway_ptr, 0); - - if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, - SIPTAG_CALL_ID_STR(gateway_ptr->uuid_str), - NUTAG_URL(gateway_ptr->register_proxy), - SIPTAG_TO_STR(gateway_ptr->register_to), - NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name); - - if (!gateway_ptr->sofia_private) { - gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); - switch_assert(gateway_ptr->sofia_private); - } - memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); - gateway_ptr->sofia_private->gateway = gateway_ptr; - nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); - - if (now) { - nua_register(gateway_ptr->nh, - NUTAG_URL(gateway_ptr->register_url), - TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)), - SIPTAG_TO_STR(gateway_ptr->register_from), - SIPTAG_FROM_STR(gateway_ptr->register_from), - SIPTAG_CONTACT_STR(gateway_ptr->register_contact), - SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), - NUTAG_REGISTRAR(gateway_ptr->register_proxy), - NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); - gateway_ptr->retry = now + gateway_ptr->retry_seconds; - } else { - nua_unregister(gateway_ptr->nh, - NUTAG_URL(gateway_ptr->register_url), - SIPTAG_FROM_STR(gateway_ptr->register_from), - SIPTAG_TO_STR(gateway_ptr->register_from), - SIPTAG_CONTACT_STR(gateway_ptr->register_contact), - SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), - NUTAG_REGISTRAR(gateway_ptr->register_proxy), - NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); - } + sofia_reg_new_handle(gateway_ptr); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name); + + if (now) { + nua_register(gateway_ptr->nh, + NUTAG_URL(gateway_ptr->register_url), + TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)), + SIPTAG_TO_STR(gateway_ptr->register_from), + SIPTAG_FROM_STR(gateway_ptr->register_from), + SIPTAG_CONTACT_STR(gateway_ptr->register_contact), + SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), + NUTAG_REGISTRAR(gateway_ptr->register_proxy), + NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); gateway_ptr->retry = now + gateway_ptr->retry_seconds; - gateway_ptr->state = REG_STATE_TRYING; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error registering %s failure #%d\n", gateway_ptr->name, ++gateway_ptr->failures); - gateway_ptr->state = REG_STATE_FAILED; + nua_unregister(gateway_ptr->nh, + NUTAG_URL(gateway_ptr->register_url), + SIPTAG_FROM_STR(gateway_ptr->register_from), + SIPTAG_TO_STR(gateway_ptr->register_from), + SIPTAG_CONTACT_STR(gateway_ptr->register_contact), + SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), + NUTAG_REGISTRAR(gateway_ptr->register_proxy), + NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); } + gateway_ptr->retry = now + gateway_ptr->retry_seconds; + gateway_ptr->state = REG_STATE_TRYING; + break; case REG_STATE_FAILED: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Failed Registration, setting retry to %d seconds.\n", gateway_ptr->name, gateway_ptr->retry_seconds * (gateway_ptr->failures + 1)); gateway_ptr->retry = now + (gateway_ptr->retry_seconds * (gateway_ptr->failures + 1)); - sofia_reg_kill_reg(gateway_ptr, 0); gateway_ptr->status = SOFIA_GATEWAY_DOWN; gateway_ptr->state = REG_STATE_FAIL_WAIT; break; @@ -408,6 +418,7 @@ SIPTAG_CONTACT_STR(profile->url), TAG_END()); + nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_notify(nh, NUTAG_NEWSUB(1), SIPTAG_EVENT_STR(event), @@ -422,6 +433,17 @@ switch_safe_free(id); } +int sofia_sla_dialog_del_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + sofia_profile_t *profile = (sofia_profile_t *) pArg; + nua_handle_t *nh = NULL; + + if ((nh = nua_handle_by_call_id(profile->nua, argv[0]))) { + nua_handle_destroy(nh); + } + + return 0; +} int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames) { @@ -522,6 +544,21 @@ sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, NULL); + + if (now) { + switch_snprintf(sql, sizeof(sql), "select call_id from sip_shared_appearance_dialogs where hostname='%s' " + "and profile_name='%s' and expires <= %ld", + mod_sofia_globals.hostname, profile->name, (long) now); + + sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_sla_dialog_del_callback, profile); + switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s' and expires <= %ld", + mod_sofia_globals.hostname, (long) now); + + + sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, NULL); + } + + if (now) { switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and expires <= %ld and hostname='%s'", (long) now, mod_sofia_globals.hostname); @@ -1018,7 +1055,7 @@ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user-agent", (sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, reg_host); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "UNRegistered"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Unregistered"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); switch_event_fire(&event); } @@ -1112,7 +1149,11 @@ } if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { - sofia_sla_handle_register(nua, profile, sip); + char *full_contact = sip_header_as_string(nh->nh_home, (void *) sip->sip_contact); + if (full_contact && switch_stristr("SUBSCRIBE", full_contact)) { + sofia_sla_handle_register(nua, profile, sip, exptime, full_contact); + su_free(nh->nh_home, full_contact); + } } return 1; @@ -1275,6 +1316,23 @@ if (ostate != sofia_private->gateway->state) { sofia_reg_fire_custom_gateway_state_event(sofia_private->gateway); } + + + if (status >= 200) { + if (sofia_private) { + if (sofia_private->gateway) { + nua_handle_destroy(sofia_private->gateway->nh); + sofia_private->gateway->nh = NULL; + nua_handle_bind(sofia_private->gateway->nh, NULL); + sofia_private->gateway->sofia_private = NULL; + } else { + nua_handle_destroy(nh); + } + sofia_private_free(sofia_private); + } else { + nua_handle_destroy(nh); + } + } } } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c Sun Mar 22 00:15:17 2009 @@ -39,37 +39,81 @@ static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **columnNames); -void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const *sip) +struct sla_helper { + char call_id[1024]; +}; + + +static int get_call_id_callback(void *pArg, int argc, char **argv, char **columnNames) { - nua_handle_t *nh; + struct sla_helper *sh = (struct sla_helper *) pArg; - /* TODO: - * check to see if it says in the group or extension xml that we are handling SLA for this AOR - * check to see if we're already subscribed and the call-id in the subscribe matches. if so, - * we can skip this, which would keep us from re-subscribing which would also keep us from - * leaking so horribly much memory like we do now - */ + switch_set_string(sh->call_id, argv[0]); + + return 0; +} - nh = nua_handle(nua, NULL, NUTAG_URL(sip->sip_contact->m_url), TAG_NULL()); +char *strip_uri(const char *str) +{ + char *p; + char *r; - /* we make up and bind a sofia_private so that the existing event handler destruction code won't be confused by us */ - /* (though it isn't clear that this is sufficient... we still have break cases for nua_i_notify and nua_r_notify - * in sofia_event_callback's destruction end because if we don't, the handle gets destroyed. or maybe it is - * something else i'm doing wrong? MTK + if ((p = strchr(str, '<'))) { + p++; + r = strdup(p); + if ((p = strchr(r, '>'))) { + *p = '\0'; + } + } else { + r = strdup(str); + } - mod_sofia_globals.keep_private is a magic static private things can share for this purpose: ACM - */ + return r; +} + +void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const *sip, long exptime, const char *full_contact) +{ + nua_handle_t *nh = NULL; + char exp_str[256] = ""; + char my_contact[256] = ""; + char *sql; + struct sla_helper sh = { { 0 } }; + char *contact_str = strip_uri(full_contact); + + + sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'", + mod_sofia_globals.hostname, profile->name, contact_str); + sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, get_call_id_callback, &sh); + + free(sql); + + if (*sh.call_id) { + if (!(nh = nua_handle_by_call_id(profile->nua, sh.call_id))) { + if ((sql = switch_mprintf("delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'", + mod_sofia_globals.hostname, profile->name, contact_str))) { + sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); + } + } + } + + if (!nh) { + nh = nua_handle(nua, NULL, NUTAG_URL(sip->sip_contact->m_url), TAG_NULL()); + } nua_handle_bind(nh, &mod_sofia_globals.keep_private); + switch_snprintf(exp_str, sizeof(exp_str), "%ld", exptime + 30); + switch_snprintf(my_contact, sizeof(my_contact), "%s;expires=%s", profile->sla_contact, exp_str); nua_subscribe(nh, - SIPTAG_TO(sip->sip_to), - SIPTAG_FROM(sip->sip_to), // ? - SIPTAG_CONTACT_STR(profile->sla_contact), - SIPTAG_EXPIRES_STR("3500"), /* ok, this is totally fake here XXX MTK */ - SIPTAG_EVENT_STR("dialog;sla"), /* some phones want ;include-session-description too? */ - TAG_NULL()); + SIPTAG_TO(sip->sip_to), + SIPTAG_FROM(sip->sip_to), // ? + SIPTAG_CONTACT_STR(my_contact), + SIPTAG_EXPIRES_STR(exp_str), + SIPTAG_EVENT_STR("dialog;sla"), /* some phones want ;include-session-description too? */ + TAG_NULL()); + + free(contact_str); } void sofia_sla_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]) @@ -165,9 +209,32 @@ char *payload; }; -void sofia_sla_handle_sip_r_subscribe(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]) +void sofia_sla_handle_sip_r_subscribe(int status, + char const *phrase, + nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]) { - /* apparently, we do nothing */ + if (status >= 300) { + nua_handle_destroy(nh); + sofia_private_free(sofia_private); + } else { + char *full_contact = sip_header_as_string(nh->nh_home, (void *) sip->sip_contact); + time_t expires = switch_epoch_time_now(NULL); + char *sql; + char *contact_str = strip_uri(full_contact); + + if (sip && sip->sip_expires) { + expires += sip->sip_expires->ex_delta + 30; + } + + if ((sql = switch_mprintf("insert into sip_shared_appearance_dialogs (profile_name, hostname, contact_str, call_id, expires) " + "values ('%q','%q','%q','%q','%ld')", + profile->name, mod_sofia_globals.hostname, contact_str, sip->sip_call_id->i_id, (long)expires))) { + sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); + } + + free(contact_str); + } + } void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]) From brian at freeswitch.org Sun Mar 22 08:50:34 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 10:50:34 -0500 Subject: [Freeswitch-svn] [commit] r12709 - freeswitch/trunk/src Message-ID: Author: brian Date: Sun Mar 22 10:50:34 2009 New Revision: 12709 Log: fix ilbc snafu Modified: freeswitch/trunk/src/switch_core_codec.c Modified: freeswitch/trunk/src/switch_core_codec.c ============================================================================== --- freeswitch/trunk/src/switch_core_codec.c (original) +++ freeswitch/trunk/src/switch_core_codec.c Sun Mar 22 10:50:34 2009 @@ -437,7 +437,7 @@ return SWITCH_STATUS_GENERR; } - if (!strcasecmp(codec_name, "ilbc") && mode && strncasecmp(mode, "mode=", 5)) { + if (!strcasecmp(codec_name, "ilbc") && mode && !strncasecmp(mode, "mode=", 5)) { int mms; mode += 5; if (mode) { From mikej at freeswitch.org Sun Mar 22 09:53:29 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 11:53:29 -0500 Subject: [Freeswitch-svn] [commit] r12710 - freeswitch/trunk/src/mod/xml_int/mod_xml_rpc Message-ID: Author: mikej Date: Sun Mar 22 11:53:29 2009 New Revision: 12710 Log: remove unused vars Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c ============================================================================== --- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c (original) +++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c Sun Mar 22 11:53:29 2009 @@ -721,7 +721,7 @@ char *command = NULL, *arg = NULL; switch_stream_handle_t stream = { 0 }; xmlrpc_value *val = NULL; - const char *x_command = "bgapi", x_arg= "unload mod_xml_rpc"; +// const char *x_command = "bgapi", x_arg = "unload mod_xml_rpc"; switch_bool_t freed = 0; From mikej at freeswitch.org Sun Mar 22 09:54:45 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 11:54:45 -0500 Subject: [Freeswitch-svn] [commit] r12711 - freeswitch/trunk/w32/Library Message-ID: Author: mikej Date: Sun Mar 22 11:54:45 2009 New Revision: 12711 Log: turn off code analysis for now Modified: freeswitch/trunk/w32/Library/FreeSwitchCore.2008.vcproj Modified: freeswitch/trunk/w32/Library/FreeSwitchCore.2008.vcproj ============================================================================== --- freeswitch/trunk/w32/Library/FreeSwitchCore.2008.vcproj (original) +++ freeswitch/trunk/w32/Library/FreeSwitchCore.2008.vcproj Sun Mar 22 11:54:45 2009 @@ -60,7 +60,7 @@ WarnAsError="true" DebugInformationFormat="3" ForcedIncludeFiles="" - EnablePREfast="$(EnablePREfast)" + EnablePREfast="false" /> Author: mikej Date: Sun Mar 22 12:27:28 2009 New Revision: 12712 Log: tweak Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c ============================================================================== --- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c (original) +++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c Sun Mar 22 12:27:28 2009 @@ -721,7 +721,6 @@ char *command = NULL, *arg = NULL; switch_stream_handle_t stream = { 0 }; xmlrpc_value *val = NULL; -// const char *x_command = "bgapi", x_arg = "unload mod_xml_rpc"; switch_bool_t freed = 0; From anthm at freeswitch.org Sun Mar 22 11:23:25 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 13:23:25 -0500 Subject: [Freeswitch-svn] [commit] r12713 - freeswitch/trunk/src/mod/languages/mod_lua Message-ID: Author: anthm Date: Sun Mar 22 13:23:24 2009 New Revision: 12713 Log: tweak lua hangup hook Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Sun Mar 22 13:23:24 2009 @@ -133,10 +133,18 @@ CoreSession *coresession = NULL; switch_channel_state_t state = switch_channel_get_state(channel); - if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) { - if (coresession->hook_state != state) { + if (session_hungup) { + + channel = switch_core_session_get_channel(session_hungup); + + if (channel) { + coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"); + } + + if (coresession && coresession->allocated && (state == CS_HANGUP || state == CS_ROUTING) && coresession->hook_state != state) { coresession->hook_state = state; coresession->check_hangup_hook(); + switch_core_event_hook_remove_state_change(session_hungup, lua_hanguphook); } } From anthm at freeswitch.org Sun Mar 22 11:35:55 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 13:35:55 -0500 Subject: [Freeswitch-svn] [commit] r12714 - freeswitch/trunk/src/mod/languages/mod_lua Message-ID: Author: anthm Date: Sun Mar 22 13:35:55 2009 New Revision: 12714 Log: tweak lua hangup hook (part 2) Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Sun Mar 22 13:35:55 2009 @@ -24,6 +24,10 @@ Session::~Session() { + if (channel) { + switch_channel_set_private(channel, "CoreSession", NULL); + } + if (hangup_func_str) { if (session) { switch_core_event_hook_remove_state_change(session, lua_hanguphook); @@ -141,6 +145,10 @@ coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"); } + if (!(coresession && coresession->hook_state)) { + return SWITCH_STATUS_FALSE; + } + if (coresession && coresession->allocated && (state == CS_HANGUP || state == CS_ROUTING) && coresession->hook_state != state) { coresession->hook_state = state; coresession->check_hangup_hook(); From anthm at freeswitch.org Sun Mar 22 13:04:56 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 15:04:56 -0500 Subject: [Freeswitch-svn] [commit] r12715 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Sun Mar 22 15:04:56 2009 New Revision: 12715 Log: fix reg issue Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sun Mar 22 15:04:56 2009 @@ -89,7 +89,10 @@ private_object_t *tech_pvt = NULL; switch_event_t *s_event = NULL; sofia_gateway_subscription_t *gw_sub_ptr; + int sub_state; + tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END()); + /* make sure we have a proper event */ if (!sip || !sip->sip_event) { goto error; @@ -105,18 +108,8 @@ if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) { - int sub_state; - tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END()); - sofia_sla_handle_sip_i_notify(nua, profile, nh, sip, tags); - - if (sub_state == nua_substate_terminated) { - sofia_private_free(sofia_private); - nua_handle_bind(nh, NULL); - nua_handle_destroy(nh); - } - - return; + goto end; } } @@ -124,7 +117,7 @@ if (!strcasecmp(sip->sip_event->o_type, "keep-alive")) { /* XXX MTK - is this right? in this case isn't sofia is already sending a 200 itself also? */ nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END()); - return; + goto end; } if (session) { @@ -214,7 +207,7 @@ switch_channel_set_variable(channel, "auto_answer_destination", switch_channel_get_variable(channel, "destination_number")); switch_ivr_session_transfer(session, "auto_answer", NULL, NULL); nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END()); - return; + goto end; } } @@ -257,11 +250,20 @@ goto error; } - return; + goto end; error: + nua_respond(nh, 481, "Subscription Does Not Exist", NUTAG_WITH_THIS(nua), TAG_END()); - return; + + end: + + if (sub_state == nua_substate_terminated) { + sofia_private_free(sofia_private); + nua_handle_bind(nh, NULL); + nua_handle_destroy(nh); + } + } void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, @@ -425,7 +427,6 @@ switch (event) { case nua_r_get_params: - case nua_r_unregister: case nua_i_fork: case nua_r_info: case nua_r_bye: @@ -463,6 +464,7 @@ sofia_handle_sip_i_notify(session, status, phrase, nua, profile, nh, sofia_private, sip, tags); break; case nua_r_register: + case nua_r_unregister: sofia_reg_handle_sip_r_register(status, phrase, nua, profile, nh, sofia_private, sip, tags); break; case nua_i_options: Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Sun Mar 22 15:04:56 2009 @@ -37,7 +37,7 @@ */ #include "mod_sofia.h" -static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr) +static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr, int attach) { int ss_state = nua_callstate_authenticating; @@ -54,23 +54,23 @@ SIPTAG_TO_STR(gateway_ptr->register_to), NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); - - if (!gateway_ptr->sofia_private) { - gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); - switch_assert(gateway_ptr->sofia_private); - } - memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); + if (attach) { + if (!gateway_ptr->sofia_private) { + gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); + switch_assert(gateway_ptr->sofia_private); + } + memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); - gateway_ptr->sofia_private->gateway = gateway_ptr; - nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); + gateway_ptr->sofia_private->gateway = gateway_ptr; + nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private); + } } static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr) { if (!gateway_ptr->nh) { - sofia_reg_new_handle(gateway_ptr); - + sofia_reg_new_handle(gateway_ptr, SWITCH_FALSE); } if (gateway_ptr->nh) { @@ -80,7 +80,7 @@ SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_CONTACT_STR(gateway_ptr->register_contact), - SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), + SIPTAG_EXPIRES_STR("0"), NUTAG_REGISTRAR(gateway_ptr->register_proxy), NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); } @@ -100,10 +100,13 @@ { sofia_gateway_t *gateway_ptr; for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { + if (gateway_ptr->sofia_private) { sofia_private_free(gateway_ptr->sofia_private); } + sofia_reg_kill_reg(gateway_ptr); + } } @@ -288,7 +291,7 @@ case REG_STATE_UNREGED: gateway_ptr->status = SOFIA_GATEWAY_DOWN; - sofia_reg_new_handle(gateway_ptr); + sofia_reg_new_handle(gateway_ptr, now ? 1 : 0); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name); @@ -1318,7 +1321,7 @@ } - if (status >= 200) { + if (status >= 300) { if (sofia_private) { if (sofia_private->gateway) { nua_handle_destroy(sofia_private->gateway->nh); From anthm at freeswitch.org Sun Mar 22 13:52:41 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 15:52:41 -0500 Subject: [Freeswitch-svn] [commit] r12716 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Sun Mar 22 15:52:41 2009 New Revision: 12716 Log: fix killgw Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sun Mar 22 15:52:41 2009 @@ -430,6 +430,7 @@ case nua_i_fork: case nua_r_info: case nua_r_bye: + case nua_r_unregister: case nua_r_unsubscribe: case nua_r_publish: case nua_i_cancel: @@ -464,7 +465,6 @@ sofia_handle_sip_i_notify(session, status, phrase, nua, profile, nh, sofia_private, sip, tags); break; case nua_r_register: - case nua_r_unregister: sofia_reg_handle_sip_r_register(status, phrase, nua, profile, nh, sofia_private, sip, tags); break; case nua_i_options: Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Sun Mar 22 15:52:41 2009 @@ -50,10 +50,8 @@ gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, SIPTAG_CALL_ID_STR(gateway_ptr->uuid_str), - NUTAG_URL(gateway_ptr->register_proxy), SIPTAG_TO_STR(gateway_ptr->register_to), NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); - if (attach) { if (!gateway_ptr->sofia_private) { gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); @@ -77,12 +75,9 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Registering %s\n", gateway_ptr->name); nua_unregister(gateway_ptr->nh, NUTAG_URL(gateway_ptr->register_url), - SIPTAG_FROM_STR(gateway_ptr->register_from), - SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_CONTACT_STR(gateway_ptr->register_contact), - SIPTAG_EXPIRES_STR("0"), - NUTAG_REGISTRAR(gateway_ptr->register_proxy), - NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); + NUTAG_REGISTRAR(gateway_ptr->register_proxy), + TAG_END()); } } From anthm at freeswitch.org Sun Mar 22 14:19:25 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 16:19:25 -0500 Subject: [Freeswitch-svn] [commit] r12717 - freeswitch/trunk/src/mod/languages/mod_lua Message-ID: Author: anthm Date: Sun Mar 22 16:19:25 2009 New Revision: 12717 Log: update Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Sun Mar 22 16:19:25 2009 @@ -134,7 +134,7 @@ static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup) { switch_channel_t *channel = switch_core_session_get_channel(session_hungup); - CoreSession *coresession = NULL; + Session *coresession = NULL; switch_channel_state_t state = switch_channel_get_state(channel); if (session_hungup) { @@ -142,7 +142,7 @@ channel = switch_core_session_get_channel(session_hungup); if (channel) { - coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"); + coresession = (Session *) switch_channel_get_private(channel, "CoreSession"); } if (!(coresession && coresession->hook_state)) { From anthm at freeswitch.org Sun Mar 22 14:32:08 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 16:32:08 -0500 Subject: [Freeswitch-svn] [commit] r12718 - in freeswitch/trunk/src: . mod/languages/mod_lua Message-ID: Author: anthm Date: Sun Mar 22 16:32:08 2009 New Revision: 12718 Log: update Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp freeswitch/trunk/src/switch_cpp.cpp Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Sun Mar 22 16:32:08 2009 @@ -32,7 +32,7 @@ if (session) { switch_core_event_hook_remove_state_change(session, lua_hanguphook); } - free(hangup_func_str); + switch_safe_free(hangup_func_str); } switch_safe_free(hangup_func_arg); @@ -128,6 +128,16 @@ if (!switch_strlen_zero(err)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err); } + + if (channel) { + switch_channel_set_private(channel, "CoreSession", NULL); + } + + if (session) { + switch_core_event_hook_remove_state_change(session, lua_hanguphook); + } + switch_safe_free(hangup_func_str); + } } @@ -142,7 +152,10 @@ channel = switch_core_session_get_channel(session_hungup); if (channel) { - coresession = (Session *) switch_channel_get_private(channel, "CoreSession"); + void *vs = switch_channel_get_private(channel, "CoreSession"); + if (vs) { + coresession = (Session *) vs; + } } if (!(coresession && coresession->hook_state)) { Modified: freeswitch/trunk/src/switch_cpp.cpp ============================================================================== --- freeswitch/trunk/src/switch_cpp.cpp (original) +++ freeswitch/trunk/src/switch_cpp.cpp Sun Mar 22 16:32:08 2009 @@ -888,6 +888,10 @@ { this_check_void(); + if (channel) { + switch_channel_set_private(channel, "CoreSession", NULL); + } + switch_safe_free(xml_cdr_text); switch_safe_free(uuid); switch_safe_free(tts_name); From silik0n at freeswitch.org Sun Mar 22 16:31:49 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 18:31:49 -0500 Subject: [Freeswitch-svn] [commit] r12719 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Sun Mar 22 18:31:49 2009 New Revision: 12719 Log: ok really fix this crap Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Sun Mar 22 18:31:49 2009 @@ -38,41 +38,39 @@ require_once "ESL.php"; class FreeSWITCH { + + /* Edit these variables for your installation */ + var $esl_server = "127.0.0.1"; /* ESL Server */ + var $esl_port = "8021"; /* ESL Port */ + var $esl_secret = "ClueCon"; /* ESL Secret */ + + var $dbtype='mysql'; /* Set the Database type */ + var $db_hostname = '192.168.1.140'; /* Database Server hostname */ + var $db_port = '3306'; /* Database Server Port */ + var $db_username = 'root'; /* Database Server username */ + var $db_password = 'password'; /* Database Server password */ + var $db_database = 'shipment'; /* DataBase Name */ private function getDbh(){ - $dbtype='mysql'; /* Set the Database type */ - // $db_hostname = 'localhost'; /* Database Server hostname */ - $db_hostname = '192.168.1.140'; /* Database Server hostname */ - $db_port = '3306'; /* Database Server Port */ - $db_username = 'root'; /* Database Server username */ - $db_password = 'password'; /* Database Server password */ - $db_database = 'shipment'; /* DataBase Name */ - if ($dbtype == 'mysql') { + if ($this->dbtype == 'mysql') { $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,); } - $dbh = new PDO("$dbtype:host=$db_hostname;port=$db_port;dbname=$db_database", $db_username, $db_password, $pdo_flags); + $dbh = new PDO($this->dbtype . ":host=" . $this->db_hostname . ";port=" . $this->db_port . ";dbname=" . $this->db_database, + $this->db_username, $this->db_password, $pdo_flags); return $dbh; } - private function getEsl(){ - $esl_server = "127.0.0.1"; /* ESL Server */ - $esl_port = "8021"; /* ESL Port */ - $esl_secret = "ClueCon"; /* ESL Secret */ - $esl = new eslConnection($esl_server, $esl_port, $esl_secret); - return $esl; - } - /*** General Whats happening Methods ***/ public function getStatus() { - $esl = getEsl(); + $esl = new eslConnection($this->esl_ser"ver, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api status"); $body = $e->getBody(); return $body; } public function getChannels() { - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api show channels"); $body = $e->getBody(); $temp = explode ("\n", $body); @@ -102,7 +100,7 @@ } public function getCalls() { - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api show calls"); $body = $e->getBody(); $temp = explode ("\n", $body); @@ -131,14 +129,14 @@ public function originate($call_url, $exten, $dialplan = "XML", $context= "default", $cid_name = "amf_php", $cid_number = "888", $timeout="30"){ $dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout"; - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv($dialstring); $body = $e->getBody(); return $body; } public function killUuid($uuid) { - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api uuid_kill $uuid"); $body = $e->getBody(); return $body; @@ -147,14 +145,14 @@ /*** Conference Methods ***/ public function kickConferenceUser($conference, $member) { - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api conference $conference kick $member"); $body = $e->getBody(); return $body; } public function getConferenceList() { - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api conference list"); $body = $e->getBody(); $data=explode("\n", $body); @@ -170,7 +168,7 @@ } public function getConferenceUsers($conference_name) { - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api conference $conference_name list"); $body = $e->getBody(); $data=explode("\n", $body); @@ -225,7 +223,7 @@ public function confPlayfile($conference, $file_path){ $playfile = "api conference $conference play " . $file_path; - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; @@ -233,7 +231,7 @@ public function confLock($conference){ $playfile = "api conference $conference lock"; - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; @@ -241,7 +239,7 @@ public function confUnlock($conference){ $playfile = "api conference $conference unlock"; - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; @@ -249,7 +247,7 @@ public function confMute($conference, $member){ $playfile = "api conference $conference mute $member"; - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; @@ -257,7 +255,7 @@ public function confUnmute($conference, $member){ $playfile = "api conference $conference unmute $member"; - $esl = getEsl(); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv($playfile); $body = $e->getBody(); return $body; From anthm at freeswitch.org Sun Mar 22 18:59:36 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Mar 2009 20:59:36 -0500 Subject: [Freeswitch-svn] [commit] r12720 - freeswitch/trunk/src Message-ID: Author: anthm Date: Sun Mar 22 20:59:35 2009 New Revision: 12720 Log: make gaussian noise less noisy FSCORE-340 Modified: freeswitch/trunk/src/switch_ivr_originate.c freeswitch/trunk/src/switch_resample.c Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Sun Mar 22 20:59:35 2009 @@ -1871,7 +1871,7 @@ silence = ringback.silence; } } else { - silence = 400; + silence = 600; } if ((ringback.fh || silence || ringback.audio_buffer) && write_frame.codec && write_frame.datalen) { Modified: freeswitch/trunk/src/switch_resample.c ============================================================================== --- freeswitch/trunk/src/switch_resample.c (original) +++ freeswitch/trunk/src/switch_resample.c Sun Mar 22 20:59:35 2009 @@ -181,24 +181,22 @@ } } -#if SILENCE_METHOD_ONE +#if 1 SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor) { int16_t x; uint32_t i; int sum_rnd = 0; - int16_t rnd2 = (int16_t) switch_micro_time_now(); + int16_t rnd2 = (int16_t) switch_micro_time_now() + (int16_t) (intptr_t) data; assert(divisor); - - for (i = 0; i < samples; i++, sum_rnd = 0) { for (x = 0; x < 6; x++) { rnd2 = rnd2 * 31821U + 13849U; - sum_rnd += rnd2; + sum_rnd += rnd2 ; } - switch_normalize_to_16bit(sum_rnd); + //switch_normalize_to_16bit(sum_rnd); *data = (int16_t) ((int16_t) sum_rnd / (int) divisor); data++; From rupa at freeswitch.org Mon Mar 23 08:34:46 2009 From: rupa at freeswitch.org (FreeSWITCH SVN) Date: Mon, 23 Mar 2009 10:34:46 -0500 Subject: [Freeswitch-svn] [commit] r12721 - freeswitch/trunk/src/mod/applications/mod_lcr Message-ID: Author: rupa Date: Mon Mar 23 10:34:46 2009 New Revision: 12721 Log: don't leak Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original) +++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Mon Mar 23 10:34:46 2009 @@ -563,6 +563,8 @@ /* format the custom_sql */ safe_sql = format_custom_sql(profile->custom_sql, cb_struct, digits_copy); if (!safe_sql) { + switch_event_safe_destroy(&cb_struct->event); + switch_core_hash_destroy(&cb_struct->dedup_hash); return SWITCH_STATUS_GENERR; } SWITCH_STANDARD_STREAM(sql_stream); @@ -577,6 +579,7 @@ lookup_status = lcr_execute_sql_callback((char *)sql_stream.data, route_add_callback, cb_struct); switch_safe_free(sql_stream.data); + switch_event_safe_destroy(&cb_struct->event); switch_core_hash_destroy(&cb_struct->dedup_hash); if (lookup_status) { From anthm at freeswitch.org Mon Mar 23 09:06:32 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 23 Mar 2009 11:06:32 -0500 Subject: [Freeswitch-svn] [commit] r12722 - in freeswitch/trunk/src: . include mod/applications/mod_fifo Message-ID: Author: anthm Date: Mon Mar 23 11:06:32 2009 New Revision: 12722 Log: add import vars to fifo Modified: freeswitch/trunk/src/include/switch_ivr.h freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c freeswitch/trunk/src/switch_ivr_originate.c Modified: freeswitch/trunk/src/include/switch_ivr.h ============================================================================== --- freeswitch/trunk/src/include/switch_ivr.h (original) +++ freeswitch/trunk/src/include/switch_ivr.h Mon Mar 23 11:06:32 2009 @@ -550,10 +550,10 @@ /******************************************************************************************************/ - struct switch_ivr_digit_stream_parser; - typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t; - struct switch_ivr_digit_stream; - typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t; +struct switch_ivr_digit_stream_parser; +typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t; +struct switch_ivr_digit_stream; +typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t; /*! \brief Create a digit stream parser object \param pool the pool to use for the new hash @@ -639,25 +639,25 @@ * @{ */ - typedef enum { - SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0), - SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1), - SWITCH_IVR_MENU_FLAG_STACK = (1 << 2) - } switch_ivr_menu_flags; +typedef enum { + SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0), + SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1), + SWITCH_IVR_MENU_FLAG_STACK = (1 << 2) +} switch_ivr_menu_flags; /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */ - typedef enum { - SWITCH_IVR_ACTION_DIE, /* Exit the menu. */ - SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */ - SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */ - SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */ - SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */ - SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */ - SWITCH_IVR_ACTION_NOOP /* No operation */ - } switch_ivr_action_t; - struct switch_ivr_menu; - typedef switch_ivr_action_t switch_ivr_menu_action_function_t (struct switch_ivr_menu *, char *, char *, size_t, void *); - typedef struct switch_ivr_menu switch_ivr_menu_t; - typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; +typedef enum { + SWITCH_IVR_ACTION_DIE, /* Exit the menu. */ + SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */ + SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */ + SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */ + SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */ + SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */ + SWITCH_IVR_ACTION_NOOP /* No operation */ +} switch_ivr_action_t; +struct switch_ivr_menu; +typedef switch_ivr_action_t switch_ivr_menu_action_function_t (struct switch_ivr_menu *, char *, char *, size_t, void *); +typedef struct switch_ivr_menu switch_ivr_menu_t; +typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; /******************************************************************************************************/ /*! @@ -682,20 +682,20 @@ *\return SWITCH_STATUS_SUCCESS if the menu was created. */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu, - switch_ivr_menu_t *main, - const char *name, - const char *greeting_sound, - const char *short_greeting_sound, - const char *invalid_sound, - const char *exit_sound, - const char *confirm_macro, - const char *confirm_key, - const char *tts_engine, - const char *tts_voice, - int confirm_attempts, - int inter_timeout, int digit_len, int timeout, int max_failures, - int max_timeouts, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu, + switch_ivr_menu_t *main, + const char *name, + const char *greeting_sound, + const char *short_greeting_sound, + const char *invalid_sound, + const char *exit_sound, + const char *confirm_macro, + const char *confirm_key, + const char *tts_engine, + const char *tts_voice, + int confirm_attempts, + int inter_timeout, int digit_len, int timeout, int max_failures, + int max_timeouts, switch_memory_pool_t *pool); /*! *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action. @@ -705,8 +705,8 @@ *\param bind KeyStrokes to bind the action to. *\return SWUTCH_STATUS_SUCCESS if the action was binded */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, - const char *bind); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, + const char *bind); /*! @@ -720,8 +720,8 @@ *\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args. *\return SWUTCH_STATUS_SUCCESS if the function was binded */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, - switch_ivr_menu_action_function_t *function, const char *arg, const char *bind); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, + switch_ivr_menu_action_function_t *function, const char *arg, const char *bind); /*! @@ -732,17 +732,17 @@ *\param obj A void pointer to an object you want to make avaliable to your callback functions that you may have binded with switch_ivr_menu_bind_function. *\return SWITCH_STATUS_SUCCESS if all is well */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj); /*! *\brief free a stack of menu objects. *\param stack The top level menu you wish to destroy. *\return SWITCH_STATUS_SUCCESS if the object was a top level menu and it was freed */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack); - struct switch_ivr_menu_xml_ctx; - typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; +struct switch_ivr_menu_xml_ctx; +typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; /*! *\brief Build a menu stack from an xml source *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init @@ -751,10 +751,10 @@ *\param xml_menu The xml Menu source of the menu to be created *\return SWITCH_STATUS_SUCCESS if all is well */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, - switch_ivr_menu_t **menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, + switch_ivr_menu_t **menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu); - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action); /*! *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init @@ -762,46 +762,47 @@ *\param function The menu function callback that will be executed when menu digits are bound to this name *\return SWITCH_STATUS_SUCCESS if all is well */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, - const char *name, switch_ivr_menu_action_function_t *function); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, + const char *name, switch_ivr_menu_action_function_t *function); /*! *\param xml_menu_ctx A pointer of a XML menu parser context to be created *\param pool memory pool (NULL to create one) *\return SWITCH_STATUS_SUCCESS if all is well */ - SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool); - SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang, - switch_input_args_t *args); - SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms); - SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen); - SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg); - SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session); - SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session); - - SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session, - uint32_t min_digits, - uint32_t max_digits, - const char *prompt_audio_file, - const char *var_name, - char *digit_buffer, - switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators); - - SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, - switch_bind_flag_t bind_flags, const char *app); - SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session, uint32_t key); - SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b); - SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, - const char *say_method, switch_input_args_t *args); - - SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name); - SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name); - SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data); - SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang, + switch_input_args_t *args); +SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms); +SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen); +SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg); +SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session); + +SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session, + uint32_t min_digits, + uint32_t max_digits, + const char *prompt_audio_file, + const char *var_name, + char *digit_buffer, + switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators); + +SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, + switch_bind_flag_t bind_flags, const char *app); +SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session, uint32_t key); +SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b); +SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, + const char *say_method, switch_input_args_t *args); + +SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name); +SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name); +SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data); +SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session); +SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname); /** @} */ - SWITCH_END_EXTERN_C +SWITCH_END_EXTERN_C #endif /* For Emacs: * Local Variables: Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original) +++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Mon Mar 23 11:06:32 2009 @@ -1253,6 +1253,8 @@ switch_core_media_bug_resume(session); switch_core_media_bug_resume(other_session); + switch_process_import(session, other_channel, "fifo_caller_consumer_import"); + switch_process_import(other_session, channel, "fifo_consumer_caller_import"); switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session); switch_core_media_bug_pause(session); switch_core_media_bug_pause(other_session); Modified: freeswitch/trunk/src/switch_ivr_originate.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_originate.c (original) +++ freeswitch/trunk/src/switch_ivr_originate.c Mon Mar 23 11:06:32 2009 @@ -841,7 +841,7 @@ return (!caller_channel || switch_channel_ready(caller_channel)) ? status : SWITCH_STATUS_FALSE; } -static void process_import(switch_core_session_t *session, switch_channel_t *peer_channel) +SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname) { const char *import, *val; switch_channel_t *caller_channel; @@ -849,7 +849,7 @@ switch_assert(session && peer_channel); caller_channel = switch_core_session_get_channel(session); - if ((import = switch_channel_get_variable(caller_channel, "import"))) { + if ((import = switch_channel_get_variable(caller_channel, varname))) { char *mydata = switch_core_session_strdup(session, import); int i, argc; char *argv[64] = { 0 }; @@ -1956,7 +1956,7 @@ } else { status = SWITCH_STATUS_FALSE; if (caller_channel && peer_channel) { - process_import(oglobals.session, peer_channel); + switch_process_import(oglobals.session, peer_channel, "import"); } peer_channel = NULL; goto done; @@ -2007,7 +2007,7 @@ if (caller_channel) { switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted"); if (peer_channel) { - process_import(oglobals.session, peer_channel); + switch_process_import(oglobals.session, peer_channel, "import"); } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n", switch_channel_get_name(peer_channel)); From anthm at freeswitch.org Mon Mar 23 12:53:57 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 23 Mar 2009 14:53:57 -0500 Subject: [Freeswitch-svn] [commit] r12723 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket Message-ID: Author: anthm Date: Mon Mar 23 14:53:57 2009 New Revision: 12723 Log: move connect command to always work on outbound socket not just the first time Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Mon Mar 23 14:53:57 2009 @@ -1439,8 +1439,26 @@ } if (!strncasecmp(cmd, "connect", 7)) { - switch_snprintf(reply, reply_len, "+OK"); - goto done; + switch_event_t *call_event; + char *event_str; + switch_size_t len; + switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA); + + switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event); + switch_channel_event_set_data(channel, call_event); + switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply"); + switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Reply-Text", "+OK\n"); + switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode", switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static"); + switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Control", switch_test_flag(listener, LFLAG_FULL) ? "full" : "single-channel"); + + switch_event_serialize(call_event, &event_str, SWITCH_TRUE); + switch_assert(event_str); + len = strlen(event_str); + switch_socket_send(listener->sock, event_str, &len); + switch_safe_free(event_str); + + //switch_snprintf(reply, reply_len, "+OK"); + goto done_noreply; } else if (!strncasecmp(cmd, "getvar", 6)) { char *arg; const char *val = ""; @@ -1966,10 +1984,8 @@ add_listener(listener); if (session && switch_test_flag(listener, LFLAG_AUTHED)) { - switch_event_t *ievent = NULL, *call_event; - char *event_str; - - + switch_event_t *ievent = NULL; + switch_set_flag_locked(listener, LFLAG_SESSION); status = read_packet(listener, &ievent, 25); @@ -1978,35 +1994,14 @@ switch_clear_flag_locked(listener, LFLAG_RUNNING); goto done; } - - if (switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); - switch_clear_flag_locked(listener, LFLAG_RUNNING); - goto done; - } + if (parse_command(listener, &ievent, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) { switch_clear_flag_locked(listener, LFLAG_RUNNING); goto done; } - switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event); - switch_channel_event_set_data(channel, call_event); - switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply"); - switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Reply-Text", "+OK\n"); - switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode", switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static"); - switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Control", switch_test_flag(listener, LFLAG_FULL) ? "full" : "single-channel"); - - switch_event_serialize(call_event, &event_str, SWITCH_TRUE); - if (!event_str) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); - switch_clear_flag_locked(listener, LFLAG_RUNNING); - goto done; - } - len = strlen(event_str); - switch_socket_send(listener->sock, event_str, &len); - switch_safe_free(event_str); } else { switch_snprintf(buf, sizeof(buf), "Content-Type: auth/request\n\n"); From anthm at freeswitch.org Mon Mar 23 12:55:03 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 23 Mar 2009 14:55:03 -0500 Subject: [Freeswitch-svn] [commit] r12724 - in freeswitch/trunk/libs/esl: . lua perl php python ruby src src/include Message-ID: Author: anthm Date: Mon Mar 23 14:55:02 2009 New Revision: 12724 Log: add disconnect method and check in ivrd Added: freeswitch/trunk/libs/esl/ivrd.c freeswitch/trunk/libs/esl/test.pl (contents, props changed) Modified: freeswitch/trunk/libs/esl/Makefile freeswitch/trunk/libs/esl/lua/esl_wrap.cpp freeswitch/trunk/libs/esl/perl/ESL.pm freeswitch/trunk/libs/esl/perl/esl_wrap.cpp freeswitch/trunk/libs/esl/php/ESL.php freeswitch/trunk/libs/esl/php/esl_wrap.cpp freeswitch/trunk/libs/esl/php/php_ESL.h freeswitch/trunk/libs/esl/python/ESL.py freeswitch/trunk/libs/esl/python/esl_wrap.cpp freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp freeswitch/trunk/libs/esl/src/esl_oop.cpp freeswitch/trunk/libs/esl/src/include/esl_oop.h Modified: freeswitch/trunk/libs/esl/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/Makefile (original) +++ freeswitch/trunk/libs/esl/Makefile Mon Mar 23 14:55:02 2009 @@ -16,7 +16,7 @@ # comment the next line to disable c++ (no swig mods for you then) OBJS += src/esl_oop.o -all: $(MYLIB) fs_cli testclient testserver +all: $(MYLIB) fs_cli testclient testserver ivrd $(MYLIB): $(OBJS) $(HEADERS) $(SRC) ar rcs $(MYLIB) $(OBJS) @@ -25,6 +25,9 @@ testserver: $(MYLIB) testserver.c $(CC) $(CC_CFLAGS) $(CFLAGS) testserver.c -o testserver $(LDFLAGS) $(LIBS) +ivrd: $(MYLIB) ivrd.c + $(CC) $(CC_CFLAGS) $(CFLAGS) ivrd.c -o ivrd $(LDFLAGS) $(LIBS) + testclient: $(MYLIB) testclient.c $(CC) $(CC_CFLAGS) $(CFLAGS) testclient.c -o testclient $(LDFLAGS) $(LIBS) @@ -38,7 +41,7 @@ $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) -c $< -o $@ clean: - rm -f *.o src/*.o testclient testserver fs_cli libesl.a *~ src/*~ src/include/*~ + rm -f *.o src/*.o testclient testserver ivrd fs_cli libesl.a *~ src/*~ src/include/*~ $(MAKE) -C perl clean $(MAKE) -C php clean $(MAKE) -C lua clean Added: freeswitch/trunk/libs/esl/ivrd.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/esl/ivrd.c Mon Mar 23 14:55:02 2009 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2009, Anthony Minessale II + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) +{ + esl_handle_t handle = {{0}}; + char path_buffer[1024] = { 0 }; + const char *path; + + if (fork()) { + close(client_sock); + return; + } + + esl_attach_handle(&handle, client_sock, addr); + + if (!(path = esl_event_get_header(handle.info_event, "variable_ivr_path"))) { + esl_log(ESL_LOG_ERROR, "Missing ivr_path param!\n"); + return; + } + + strncpy(path_buffer, path, sizeof(path_buffer) - 1); + + /* hotwire the socket to STDIN/STDOUT */ + dup2(client_sock, STDIN_FILENO); + dup2(client_sock, STDOUT_FILENO); + + /* close the handle but leak the socket on purpose cos the child will need it open */ + handle.sock = -1; + esl_disconnect(&handle); + + /* DOH! we're still here! Close the socket. */ + + execl(path_buffer, path_buffer, NULL); + esl_log(ESL_LOG_ERROR, "Error %d\n", client_sock); + close(client_sock); + +} + +int main(int argc, char *argv[]) +{ + int i; + char *ip = NULL; + int port = 0; + + for (i = 1; i + 1 < argc; ) { + if (!strcasecmp(argv[i], "-h")) { + ip = argv[++i]; + } else if (!strcasecmp(argv[i], "-p")) { + port = atoi(argv[++i]); + } else { + i++; + } + } + + if (!(ip && port)) { + fprintf(stderr, "Usage %s -h -p \n", argv[0]); + return -1; + } + + esl_listen(ip, port, mycallback); + + return 0; +} Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/lua/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/lua/esl_wrap.cpp Mon Mar 23 14:55:02 2009 @@ -1927,14 +1927,14 @@ SWIG_check_num_args("getHeader",2,2) if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getHeader",1,"ESLevent *"); - if(!lua_isstring(L,2)) SWIG_fail_arg("getHeader",2,"char *"); + if(!lua_isstring(L,2)) SWIG_fail_arg("getHeader",2,"char const *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLevent,0))){ SWIG_fail_ptr("ESLevent_getHeader",1,SWIGTYPE_p_ESLevent); } arg2 = (char *)lua_tostring(L, 2); - result = (char *)(arg1)->getHeader(arg2); + result = (char *)(arg1)->getHeader((char const *)arg2); SWIG_arg=0; lua_pushstring(L,(const char*)result); SWIG_arg++; return SWIG_arg; @@ -2688,6 +2688,31 @@ } +static int _wrap_ESLconnection_disconnect(lua_State* L) { + int SWIG_arg = -1; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + + SWIG_check_num_args("disconnect",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("disconnect",1,"ESLconnection *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ + SWIG_fail_ptr("ESLconnection_disconnect",1,SWIGTYPE_p_ESLconnection); + } + + result = (int)(arg1)->disconnect(); + SWIG_arg=0; + lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static void swig_delete_ESLconnection(void *obj) { ESLconnection *arg1 = (ESLconnection *) obj; delete arg1; @@ -2707,6 +2732,7 @@ {"execute", _wrap_ESLconnection_execute}, {"setBlockingExecute", _wrap_ESLconnection_setBlockingExecute}, {"setEventLock", _wrap_ESLconnection_setEventLock}, + {"disconnect", _wrap_ESLconnection_disconnect}, {0,0} }; static swig_lua_attribute swig_ESLconnection_attributes[] = { Modified: freeswitch/trunk/libs/esl/perl/ESL.pm ============================================================================== --- freeswitch/trunk/libs/esl/perl/ESL.pm (original) +++ freeswitch/trunk/libs/esl/perl/ESL.pm Mon Mar 23 14:55:02 2009 @@ -142,6 +142,7 @@ *execute = *ESLc::ESLconnection_execute; *setBlockingExecute = *ESLc::ESLconnection_setBlockingExecute; *setEventLock = *ESLc::ESLconnection_setEventLock; +*disconnect = *ESLc::ESLconnection_disconnect; sub DISOWN { my $self = shift; my $ptr = tied(%$self); Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Mon Mar 23 14:55:02 2009 @@ -2304,10 +2304,10 @@ arg1 = reinterpret_cast< ESLevent * >(argp1); res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - result = (char *)(arg1)->getHeader(arg2); + result = (char *)(arg1)->getHeader((char const *)arg2); ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; @@ -3330,6 +3330,34 @@ } +XS(_wrap_ESLconnection_disconnect) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_disconnect(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_disconnect" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->disconnect(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + XS(_wrap_eslSetLogLevel) { { int arg1 ; @@ -3435,6 +3463,7 @@ {"ESLc::ESLconnection_execute", _wrap_ESLconnection_execute}, {"ESLc::ESLconnection_setBlockingExecute", _wrap_ESLconnection_setBlockingExecute}, {"ESLc::ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock}, +{"ESLc::ESLconnection_disconnect", _wrap_ESLconnection_disconnect}, {"ESLc::eslSetLogLevel", _wrap_eslSetLogLevel}, {0,0} }; Modified: freeswitch/trunk/libs/esl/php/ESL.php ============================================================================== --- freeswitch/trunk/libs/esl/php/ESL.php (original) +++ freeswitch/trunk/libs/esl/php/ESL.php Mon Mar 23 14:55:02 2009 @@ -194,6 +194,10 @@ function setEventLock($val) { return ESLconnection_setEventLock($this->_cPtr,$val); } + + function disconnect() { + return ESLconnection_disconnect($this->_cPtr); + } } Modified: freeswitch/trunk/libs/esl/php/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/php/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/php/esl_wrap.cpp Mon Mar 23 14:55:02 2009 @@ -1465,7 +1465,7 @@ arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - result = (char *)(arg1)->getHeader(arg2); + result = (char *)(arg1)->getHeader((char const *)arg2); { if(!result) { ZVAL_NULL(return_value); @@ -2313,6 +2313,32 @@ } +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + { + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLconnection_disconnect. Expected SWIGTYPE_p_ESLconnection"); + } + } + if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); + result = (int)(arg1)->disconnect(); + { + ZVAL_LONG(return_value,result); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel) { int arg1 ; zval **args[1]; @@ -2391,6 +2417,7 @@ SWIG_ZEND_NAMED_FE(eslconnection_execute,_wrap_ESLconnection_execute,NULL) SWIG_ZEND_NAMED_FE(eslconnection_setblockingexecute,_wrap_ESLconnection_setBlockingExecute,NULL) SWIG_ZEND_NAMED_FE(eslconnection_seteventlock,_wrap_ESLconnection_setEventLock,NULL) + SWIG_ZEND_NAMED_FE(eslconnection_disconnect,_wrap_ESLconnection_disconnect,NULL) SWIG_ZEND_NAMED_FE(eslsetloglevel,_wrap_eslSetLogLevel,NULL) {NULL, NULL, NULL} }; Modified: freeswitch/trunk/libs/esl/php/php_ESL.h ============================================================================== --- freeswitch/trunk/libs/esl/php/php_ESL.h (original) +++ freeswitch/trunk/libs/esl/php/php_ESL.h Mon Mar 23 14:55:02 2009 @@ -64,5 +64,6 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_execute); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setBlockingExecute); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock); +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect); ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel); #endif /* PHP_ESL_H */ Modified: freeswitch/trunk/libs/esl/python/ESL.py ============================================================================== --- freeswitch/trunk/libs/esl/python/ESL.py (original) +++ freeswitch/trunk/libs/esl/python/ESL.py Mon Mar 23 14:55:02 2009 @@ -91,6 +91,7 @@ def execute(*args): return apply(_ESL.ESLconnection_execute, args) def setBlockingExecute(*args): return apply(_ESL.ESLconnection_setBlockingExecute, args) def setEventLock(*args): return apply(_ESL.ESLconnection_setEventLock, args) + def disconnect(*args): return apply(_ESL.ESLconnection_disconnect, args) ESLconnection_swigregister = _ESL.ESLconnection_swigregister ESLconnection_swigregister(ESLconnection) Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/python/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp Mon Mar 23 14:55:02 2009 @@ -3298,10 +3298,10 @@ arg1 = reinterpret_cast< ESLevent * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - result = (char *)(arg1)->getHeader(arg2); + result = (char *)(arg1)->getHeader((char const *)arg2); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; @@ -4173,6 +4173,28 @@ } +SWIGINTERN PyObject *_wrap_ESLconnection_disconnect(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_disconnect",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_disconnect" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->disconnect(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *ESLconnection_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; @@ -4237,6 +4259,7 @@ { (char *)"ESLconnection_execute", _wrap_ESLconnection_execute, METH_VARARGS, NULL}, { (char *)"ESLconnection_setBlockingExecute", _wrap_ESLconnection_setBlockingExecute, METH_VARARGS, NULL}, { (char *)"ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock, METH_VARARGS, NULL}, + { (char *)"ESLconnection_disconnect", _wrap_ESLconnection_disconnect, METH_VARARGS, NULL}, { (char *)"ESLconnection_swigregister", ESLconnection_swigregister, METH_VARARGS, NULL}, { (char *)"eslSetLogLevel", _wrap_eslSetLogLevel, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } Modified: freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp Mon Mar 23 14:55:02 2009 @@ -2414,10 +2414,10 @@ arg1 = reinterpret_cast< ESLevent * >(argp1); res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","getHeader", 2, argv[0] )); + SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","getHeader", 2, argv[0] )); } arg2 = reinterpret_cast< char * >(buf2); - result = (char *)(arg1)->getHeader(arg2); + result = (char *)(arg1)->getHeader((char const *)arg2); vresult = SWIG_FromCharPtr((const char *)result); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return vresult; @@ -3306,6 +3306,30 @@ SWIGINTERN VALUE +_wrap_ESLconnection_disconnect(int argc, VALUE *argv, VALUE self) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLconnection *","disconnect", 1, self )); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->disconnect(); + vresult = SWIG_From_int(static_cast< int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE _wrap_eslSetLogLevel(int argc, VALUE *argv, VALUE self) { int arg1 ; int val1 ; @@ -3658,6 +3682,7 @@ rb_define_method(cESLconnection.klass, "execute", VALUEFUNC(_wrap_ESLconnection_execute), -1); rb_define_method(cESLconnection.klass, "setBlockingExecute", VALUEFUNC(_wrap_ESLconnection_setBlockingExecute), -1); rb_define_method(cESLconnection.klass, "setEventLock", VALUEFUNC(_wrap_ESLconnection_setEventLock), -1); + rb_define_method(cESLconnection.klass, "disconnect", VALUEFUNC(_wrap_ESLconnection_disconnect), -1); cESLconnection.mark = 0; cESLconnection.destroy = (void (*)(void *)) free_ESLconnection; cESLconnection.trackObjects = 0; Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Mon Mar 23 14:55:02 2009 @@ -33,6 +33,15 @@ } +int ESLconnection::disconnect() +{ + if (handle.connected) { + return esl_disconnect(&handle); + } + + return 0; +} + int ESLconnection::connected() { return handle.connected; Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Mon Mar 23 14:55:02 2009 @@ -90,6 +90,7 @@ int execute(const char *app, const char *arg = NULL, const char *uuid = NULL); int setBlockingExecute(const char *val); int setEventLock(const char *val); + int disconnect(void); }; void eslSetLogLevel(int level); Added: freeswitch/trunk/libs/esl/test.pl ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/esl/test.pl Mon Mar 23 14:55:02 2009 @@ -0,0 +1,21 @@ +#!/usr/bin/perl +require ESL; +use Data::Dumper; + +my $fd = fileno(STDIN); +my $con = new ESL::ESLconnection($fd); +my $info = $con->getInfo(); + +select STDERR; + +print $info->serialize(); + +my $uuid = $info->getHeader("unique-id"); + +$con->execute("answer", "", $uuid); +$con->execute("playback", "/ram/swimp.raw", $uuid); + + +$con->disconnect(); + + From mcollins at freeswitch.org Mon Mar 23 15:55:56 2009 From: mcollins at freeswitch.org (FreeSWITCH SVN) Date: Mon, 23 Mar 2009 17:55:56 -0500 Subject: [Freeswitch-svn] [commit] r12725 - freeswitch/trunk/libs/esl Message-ID: Author: mcollins Date: Mon Mar 23 17:55:56 2009 New Revision: 12725 Log: Cosmetics Modified: freeswitch/trunk/libs/esl/fs_cli.c Modified: freeswitch/trunk/libs/esl/fs_cli.c ============================================================================== --- freeswitch/trunk/libs/esl/fs_cli.c (original) +++ freeswitch/trunk/libs/esl/fs_cli.c Mon Mar 23 17:55:56 2009 @@ -180,7 +180,7 @@ printf(" -p, --password=FILENAME Password\n"); printf(" -x, --execute=command Execute Command and Exit\n"); printf(" -l, --loglevel=command Log Level\n"); - printf(" -q, --quiet Disable logging\n"); + printf(" -q, --quiet Disable logging\n"); printf(" -d, --debug=level Debug Level (0 - 7)\n\n"); return 1; } From silik0n at freeswitch.org Tue Mar 24 01:41:09 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 03:41:09 -0500 Subject: [Freeswitch-svn] [commit] r12726 - freeswitch/trunk/scripts/contrib/swk/php/xml_curl Message-ID: Author: silik0n Date: Tue Mar 24 03:41:09 2009 New Revision: 12726 Log: ok lets add a few more things in here for IVR stuff Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php (contents, props changed) freeswitch/trunk/scripts/contrib/swk/php/xml_curl/fs_curl.php - copied, changed from r12725, /freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php Tue Mar 24 03:41:09 2009 @@ -0,0 +1,74 @@ + + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Ken Rice + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Ken Rice + * + * freeswitch.php -- Initial Class file for XML_CURL responses for Codename: SHIPMENT + * + *************************************************************************************************** + * + * This Requires the FreeSWITCH ESL Extension to be installed properly on your system. + * + */ + +// require_once "ESL.php"; + +class FSConfig { + // var $esl; + + var $dbh; + + public function __construct(){ + $dbtype='mysql'; /* Set the Database type */ + // $db_hostname = 'localhost'; /* Database Server hostname */ + $db_hostname = '192.168.1.140'; /* Database Server hostname */ + $db_port = '3306'; /* Database Server Port */ + $db_username = 'root'; /* Database Server username */ + $db_password = 'password'; /* Database Server password */ + $db_database = 'shipment'; /* DataBase Name */ + if ($dbtype == 'mysql') { + $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,); + } + $this->dbh = new PDO("$dbtype:host=$db_hostname;port=$db_port;dbname=$db_database", $db_username, $db_password, $pdo_flags); + + } + + /*** IVR Methods Methods ***/ + public function getConfigMenus(){ + $query = sprintf("select * from menus"); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + + public function getConfigMenuOptions($menu_uid) { + $query = sprintf("select * from menu_entries where menu_uid = %s", $menu_uid); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } +} Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Tue Mar 24 03:41:09 2009 @@ -0,0 +1 @@ +link fs_curl.php \ No newline at end of file Copied: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/fs_curl.php (from r12725, /freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php) ============================================================================== --- /freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/fs_curl.php Tue Mar 24 03:41:09 2009 @@ -1,6 +1,7 @@ getDirDomainbyName($key_value); -} else { - printf("\n\n
\n". - "\n
\n
"); - die(); -} - - +/* Uncomment and edit for debugging directory*/ +/* +$section = "configuration"; +$tag_name= "configuration"; +$key_name ="name"; +$key_value="ivr.conf"; +*/ +/* section=configuration&tag_name=configuration&key_name=name&key_value=ivr.conf&Event-Name=REQUEST_PARAMS */ -$db_domain_settings = $fsd->getDirDomain($db_domain['uid']); +if ($section == "configuration" && $tag_name == "configuration" && $key_name == "name" && $key_value == "ivr.conf" ) { + + $fsc = new FSConfig(); + + printf(" \n"); + printf(" \n"); + printf("
\n"); + printf(" \n"); + printf(" \n"); + + $db_menus = $fsc->getConfigMenus(); + foreach ($db_menus as $db_menu) { + printf(" \n", + $db_menu['name'], $db_menu['greet_long'], $db_menu['greet_short'], $db_menu['invalid_sound'], + $db_menu['exit_sound'], $db_menu['timeout'], $db_menu['inter_digit_timeout'], $db_menu['max_failures'], + $db_menu['max_timeouts'], $db_menu['digit_len']); + + $db_menuopts = $fsc->getConfigMenuOptions($db_menu['uid']); + + foreach ($db_menuopts as $db_menuopt) { + printf(" \n", + $db_menuopt['action'], $db_menuopt['digits'], $db_menuopt['param']); + } + + printf(" \n"); + } + printf(" \n"); + printf(" \n"); + printf("
\n"); + printf("
\n"); +} else if ($section == "directory" && $tag_name == "domain" && $key_name == "name" && $user != "" ) { -$db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user); -$db_user_settings = $fsd->getDirUser($db_user['uid']); -$db_groups = $fsd->getDirGroupsByDomianUidByUserUid($db_domain['uid'], $db_user['uid']); - -printf(" \n"); -printf(" \n"); -printf("
\n"); -printf(" \n", $db_domain['name']); -printf(" \n"); -foreach($db_domain_settings['params'] as $db_params) { - printf(" \n", $db_params['name'], $db_params['value']); -} -printf(" \n"); -printf(" \n"); -foreach($db_domain_settings['variables'] as $db_variables) { - printf(" \n", $db_variables['name'], $db_variables['value']); -} -printf(" \n"); -printf(" \n"); -printf(" \n"); -printf(" \n"); -printf(" \n", $db_user['username'], $db_user['mailbox']); -printf(" \n"); -foreach($db_user_settings['params'] as $db_params) { - printf(" \n", $db_params['name'], $db_params['value']); -} -printf(" \n"); -printf(" \n"); -foreach($db_user_settings['variables'] as $db_variables) { - printf(" \n", $db_variables['name'], $db_variables['value']); -} -printf(" \n"); -printf(" \n"); -printf(" \n"); -printf(" \n"); -foreach($db_groups as $db_group){ - printf(" \n", $db_group['groupName']); + $fsd = new FSDirectory(); + $db_domain = $fsd->getDirDomainbyName($key_value); + $db_domain_settings = $fsd->getDirDomain($db_domain['uid']); + $db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user); + $db_user_settings = $fsd->getDirUser($db_user['uid']); + $db_groups = $fsd->getDirGroupsByDomianUidByUserUid($db_domain['uid'], $db_user['uid']); + + printf(" \n"); + printf(" \n"); + printf("
\n"); + printf(" \n", $db_domain['name']); + printf(" \n"); + foreach($db_domain_settings['params'] as $db_params) { + printf(" \n", $db_params['name'], $db_params['value']); + } + printf(" \n"); + printf(" \n"); + foreach($db_domain_settings['variables'] as $db_variables) { + printf(" \n", $db_variables['name'], $db_variables['value']); + } + printf(" \n"); + printf(" \n"); + printf(" \n"); printf(" \n"); - printf(" \n", $user); + printf(" \n", $db_user['username'], $db_user['mailbox']); + printf(" \n"); + foreach($db_user_settings['params'] as $db_params) { + printf(" \n", $db_params['name'], $db_params['value']); + } + printf(" \n"); + printf(" \n"); + foreach($db_user_settings['variables'] as $db_variables) { + printf(" \n", $db_variables['name'], $db_variables['value']); + } + printf(" \n"); + printf(" \n"); printf(" \n"); printf(" \n"); + foreach($db_groups as $db_group){ + printf(" \n", $db_group['groupName']); + printf(" \n"); + printf(" \n", $user); + printf(" \n"); + printf(" \n"); + } + + printf(" \n"); + printf(" \n"); + printf("
\n"); + printf("
\n"); + +} else { + printf("\n\n
\n". + "\n
\n
"); + die(); } - -printf("
\n"); -printf("
\n"); -printf("
\n"); -printf("
\n"); ?> From silik0n at freeswitch.org Tue Mar 24 01:43:19 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 03:43:19 -0500 Subject: [Freeswitch-svn] [commit] r12727 - freeswitch/trunk/scripts/contrib/swk/php/xml_curl Message-ID: Author: silik0n Date: Tue Mar 24 03:43:19 2009 New Revision: 12727 Log: you dont need my RFC1918 address in your configs Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php Tue Mar 24 03:43:19 2009 @@ -45,7 +45,7 @@ public function __construct(){ $dbtype='mysql'; /* Set the Database type */ // $db_hostname = 'localhost'; /* Database Server hostname */ - $db_hostname = '192.168.1.140'; /* Database Server hostname */ + $db_hostname = '127.0.0.1'; /* Database Server hostname */ $db_port = '3306'; /* Database Server Port */ $db_username = 'root'; /* Database Server username */ $db_password = 'password'; /* Database Server password */ Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSDirectory.php Tue Mar 24 03:43:19 2009 @@ -45,7 +45,7 @@ public function __construct(){ $dbtype='mysql'; /* Set the Database type */ // $db_hostname = 'localhost'; /* Database Server hostname */ - $db_hostname = '192.168.1.140'; /* Database Server hostname */ + $db_hostname = '127.0.0.1'; /* Database Server hostname */ $db_port = '3306'; /* Database Server Port */ $db_username = 'root'; /* Database Server username */ $db_password = 'password'; /* Database Server password */ From anthm at freeswitch.org Tue Mar 24 07:54:13 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 09:54:13 -0500 Subject: [Freeswitch-svn] [commit] r12728 - in freeswitch/trunk/src: . mod/formats/mod_sndfile mod/languages/mod_lua Message-ID: Author: anthm Date: Tue Mar 24 09:54:13 2009 New Revision: 12728 Log: FSCORE-341 Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp freeswitch/trunk/src/switch_core_file.c freeswitch/trunk/src/switch_cpp.cpp Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c ============================================================================== --- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c (original) +++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c Tue Mar 24 09:54:13 2009 @@ -103,7 +103,8 @@ context->sfinfo.channels = handle->channels; context->sfinfo.samplerate = handle->samplerate; if (handle->samplerate == 8000 || handle->samplerate == 16000 || - handle->samplerate == 24000 || handle->samplerate == 32000 || handle->samplerate == 48000) { + handle->samplerate == 24000 || handle->samplerate == 32000 || handle->samplerate == 48000 || + handle->samplerate == 11025 || handle->samplerate == 22050 || handle->samplerate == 44100) { context->sfinfo.format |= SF_FORMAT_PCM_16; } Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Tue Mar 24 09:54:13 2009 @@ -24,20 +24,23 @@ Session::~Session() { - if (channel) { - switch_channel_set_private(channel, "CoreSession", NULL); - } - - if (hangup_func_str) { - if (session) { - switch_core_event_hook_remove_state_change(session, lua_hanguphook); + if (session) { + if (!channel) { + channel = switch_core_session_get_channel(session); } - switch_safe_free(hangup_func_str); + switch_channel_set_private(channel, "CoreSession", NULL); + switch_core_event_hook_remove_state_change(session, lua_hanguphook); + session = NULL; + channel = NULL; } + switch_safe_free(hangup_func_str); switch_safe_free(hangup_func_arg); switch_safe_free(cb_function); switch_safe_free(cb_arg); + + init_vars(); + } bool Session::begin_allow_threads() Modified: freeswitch/trunk/src/switch_core_file.c ============================================================================== --- freeswitch/trunk/src/switch_core_file.c (original) +++ freeswitch/trunk/src/switch_core_file.c Tue Mar 24 09:54:13 2009 @@ -290,10 +290,10 @@ fh->dbuf = switch_core_alloc(fh->memory_pool, fh->dbuflen); } switch_assert(fh->resampler->to_len <= fh->dbuflen); - memcpy(fh->dbuf, fh->resampler->to, fh->resampler->to_len); + memcpy(fh->dbuf, fh->resampler->to, fh->resampler->to_len * 2); data = fh->dbuf; } else { - memcpy(data, fh->resampler->to, fh->resampler->to_len); + memcpy(data, fh->resampler->to, fh->resampler->to_len * 2); } *len = fh->resampler->to_len / fh->channels; Modified: freeswitch/trunk/src/switch_cpp.cpp ============================================================================== --- freeswitch/trunk/src/switch_cpp.cpp (original) +++ freeswitch/trunk/src/switch_cpp.cpp Tue Mar 24 09:54:13 2009 @@ -888,22 +888,28 @@ { this_check_void(); - if (channel) { - switch_channel_set_private(channel, "CoreSession", NULL); - } - switch_safe_free(xml_cdr_text); switch_safe_free(uuid); switch_safe_free(tts_name); switch_safe_free(voice_name); if (session) { + if (!channel) { + channel = switch_core_session_get_channel(session); + } + + if (channel) { + switch_channel_set_private(channel, "CoreSession", NULL); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy/unlink session from object\n"); - if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) { + + if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) { switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } switch_core_session_rwunlock(session); session = NULL; + channel = NULL; } allocated = 0; From brian at freeswitch.org Tue Mar 24 08:00:44 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:00:44 -0500 Subject: [Freeswitch-svn] [commit] r12729 - freeswitch/trunk/libs/esl/python Message-ID: Author: brian Date: Tue Mar 24 10:00:44 2009 New Revision: 12729 Log: ESL-9 Modified: freeswitch/trunk/libs/esl/python/single_command.py Modified: freeswitch/trunk/libs/esl/python/single_command.py ============================================================================== --- freeswitch/trunk/libs/esl/python/single_command.py (original) +++ freeswitch/trunk/libs/esl/python/single_command.py Tue Mar 24 10:00:44 2009 @@ -2,21 +2,42 @@ import string import sys +from optparse import OptionParser from ESL import * -con = ESLconnection("localhost","8021","ClueCon") -#are we connected? - -if con.connected: - - #get argument passed to script - command = string.join(sys.argv[1:]) - - #run command - e=con.sendRecv("api "+ command) - print e.getBody() - -else: - - print "Not Connected" - +def main(argv): + + try: + + parser = OptionParser() + parser.add_option("-a", "--auth", dest="auth", default="ClueCon", + help="ESL password") + parser.add_option("-s", "--server", dest="server", default="127.0.0.1", + help="FreeSWITCH server IP address") + parser.add_option("-p", "--port", dest="port", default="8021", + help="FreeSWITCH server event socket port") + parser.add_option("-c", "--command", dest="command", + help="command to run, surround mutli word commands in \"\'s") + + (options, args) = parser.parse_args() + + + con = ESLconnection(options.server, options.port, options.auth) + #are we connected? + + if con.connected: + #run command + e=con.sendRecv("api "+ options.command) + print e.getBody() + + else: + + print "Not Connected" + sys.exit(2) + + except: + + print parser.get_usage() + +if __name__ == "__main__": + main(sys.argv[1:]) \ No newline at end of file From anthm at freeswitch.org Tue Mar 24 08:30:08 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:30:08 -0500 Subject: [Freeswitch-svn] [commit] r12730 - in freeswitch/trunk/src: . include mod/languages/mod_lua mod/languages/mod_managed mod/languages/mod_managed/managed mod/languages/mod_perl mod/languages/mod_python Message-ID: Author: anthm Date: Tue Mar 24 10:30:08 2009 New Revision: 12730 Log: fix hanguphook order of operations vs destroy method issue in c++ code Modified: freeswitch/trunk/src/include/switch_cpp.h freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp freeswitch/trunk/src/switch_cpp.cpp Modified: freeswitch/trunk/src/include/switch_cpp.h ============================================================================== --- freeswitch/trunk/src/include/switch_cpp.h (original) +++ freeswitch/trunk/src/include/switch_cpp.h Tue Mar 24 10:30:08 2009 @@ -264,7 +264,7 @@ SWITCH_DECLARE(int) originate(CoreSession * a_leg_session, char *dest, int timeout = 60); - SWITCH_DECLARE(void) destroy(void); + SWITCH_DECLARE(virtual void) destroy(void); /** \brief set a DTMF callback function * Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp Tue Mar 24 10:30:08 2009 @@ -21,8 +21,14 @@ hh = mark = 0; } static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup); -Session::~Session() + + +void Session::destroy(void) { + + if (!allocated) { + return; + } if (session) { if (!channel) { @@ -30,8 +36,6 @@ } switch_channel_set_private(channel, "CoreSession", NULL); switch_core_event_hook_remove_state_change(session, lua_hanguphook); - session = NULL; - channel = NULL; } switch_safe_free(hangup_func_str); @@ -39,8 +43,13 @@ switch_safe_free(cb_function); switch_safe_free(cb_arg); - init_vars(); - + CoreSession::destroy(); +} + + +Session::~Session() +{ + destroy(); } bool Session::begin_allow_threads() Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h Tue Mar 24 10:30:08 2009 @@ -23,6 +23,7 @@ Session(char *uuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); ~Session(); + virtual void destroy(void); virtual bool begin_allow_threads(); virtual bool end_allow_threads(); @@ -40,6 +41,7 @@ char *hangup_func_str; char *hangup_func_arg; void setLUA(lua_State *state); + }; } #endif Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp Tue Mar 24 10:30:08 2009 @@ -7388,6 +7388,30 @@ } +static int _wrap_Session_destroy(lua_State* L) { + int SWIG_arg = -1; + LUA::Session *arg1 = (LUA::Session *) 0 ; + + SWIG_check_num_args("destroy",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("destroy",1,"LUA::Session *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){ + SWIG_fail_ptr("Session_destroy",1,SWIGTYPE_p_LUA__Session); + } + + (arg1)->destroy(); + SWIG_arg=0; + + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_Session_begin_allow_threads(lua_State* L) { int SWIG_arg = -1; LUA::Session *arg1 = (LUA::Session *) 0 ; @@ -8086,6 +8110,7 @@ delete arg1; } static swig_lua_method swig_LUA_Session_methods[] = { + {"destroy", _wrap_Session_destroy}, {"begin_allow_threads", _wrap_Session_begin_allow_threads}, {"end_allow_threads", _wrap_Session_end_allow_threads}, {"check_hangup_hook", _wrap_Session_check_hangup_hook}, Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx (original) +++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx Tue Mar 24 10:30:08 2009 @@ -1444,6 +1444,17 @@ } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "transfer_after_bridge"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -13113,6 +13124,64 @@ } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_in_set(void * jarg1, void * jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_file_handle *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->samples_in = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_samples_in_get(void * jarg1) { + void * jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t result; + + arg1 = (switch_file_handle *)jarg1; + result = ((arg1)->samples_in); + jresult = new switch_size_t((switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_out_set(void * jarg1, void * jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_file_handle *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->samples_out = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_samples_out_get(void * jarg1) { + void * jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t result; + + arg1 = (switch_file_handle *)jarg1; + result = ((arg1)->samples_out); + jresult = new switch_size_t((switch_size_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_vol_set(void * jarg1, int jarg2) { switch_file_handle *arg1 = (switch_file_handle *) 0 ; int32_t arg2 ; @@ -22245,6 +22314,18 @@ } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_process_import(void * jarg1, void * jarg2, char * jarg3) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_channel_t *arg2 = (switch_channel_t *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_channel_t *)jarg2; + arg3 = (char *)jarg3; + switch_process_import(arg1,arg2,(char const *)arg3); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs (original) +++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs Tue Mar 24 10:30:08 2009 @@ -249,7 +249,7 @@ return ret; } - public void destroy() { + public virtual void destroy() { freeswitchPINVOKE.CoreSession_destroy(swigCPtr); } @@ -3382,6 +3382,10 @@ return ret; } + public static void switch_process_import(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_channel peer_channel, string varname) { + freeswitchPINVOKE.switch_process_import(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_channel.getCPtr(peer_channel), varname); + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4181,6 +4185,7 @@ public static readonly string SWITCH_LOCAL_VIDEO_PORT_VARIABLE = freeswitchPINVOKE.SWITCH_LOCAL_VIDEO_PORT_VARIABLE_get(); public static readonly string SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_PARK_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get(); + public static readonly string SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE = freeswitchPINVOKE.SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get(); public static readonly string SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE = freeswitchPINVOKE.SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE_get(); public static readonly string SWITCH_MAX_FORWARDS_VARIABLE = freeswitchPINVOKE.SWITCH_MAX_FORWARDS_VARIABLE_get(); @@ -4754,6 +4759,9 @@ [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get")] public static extern string SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get")] + public static extern string SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get")] public static extern string SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get(); @@ -7520,6 +7528,18 @@ [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_offset_pos_get")] public static extern uint switch_file_handle_offset_pos_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_in_set")] + public static extern void switch_file_handle_samples_in_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_in_get")] + public static extern IntPtr switch_file_handle_samples_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_out_set")] + public static extern void switch_file_handle_samples_out_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_out_get")] + public static extern IntPtr switch_file_handle_samples_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_vol_set")] public static extern void switch_file_handle_vol_set(HandleRef jarg1, int jarg2); @@ -9632,6 +9652,9 @@ [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_sound_test")] public static extern int switch_ivr_sound_test(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_process_import")] + public static extern void switch_process_import(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); @@ -20488,6 +20511,30 @@ } } + public SWIGTYPE_p_switch_size_t samples_in { + set { + freeswitchPINVOKE.switch_file_handle_samples_in_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_file_handle_samples_in_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_size_t samples_out { + set { + freeswitchPINVOKE.switch_file_handle_samples_out_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_file_handle_samples_out_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public int vol { set { freeswitchPINVOKE.switch_file_handle_vol_set(swigCPtr, value); Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm (original) +++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm Tue Mar 24 10:30:08 2009 @@ -478,6 +478,7 @@ } } +*destroy = *freeswitchc::Session_destroy; *begin_allow_threads = *freeswitchc::Session_begin_allow_threads; *end_allow_threads = *freeswitchc::Session_end_allow_threads; *check_hangup_hook = *freeswitchc::Session_check_hangup_hook; Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp Tue Mar 24 10:30:08 2009 @@ -44,18 +44,33 @@ } } static switch_status_t perl_hanguphook(switch_core_session_t *session_hungup); -Session::~Session() + +void Session::destroy(void) { - switch_safe_free(cb_function); - switch_safe_free(cb_arg); + + if (!allocated) { + return; + } - if (session && hangup_func_str) { + if (session) { + if (!channel) { + channel = switch_core_session_get_channel(session); + } + switch_channel_set_private(channel, "CoreSession", NULL); switch_core_event_hook_remove_state_change(session, perl_hanguphook); } + switch_safe_free(cb_function); + switch_safe_free(cb_arg); switch_safe_free(hangup_func_str); - switch_safe_free(hangup_func_arg); + switch_safe_free(hangup_func_arg); + + CoreSession::destroy(); +} +Session::~Session() +{ + destroy(); } bool Session::begin_allow_threads() Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h (original) +++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h Tue Mar 24 10:30:08 2009 @@ -31,7 +31,8 @@ Session(char *uuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); ~Session(); - + + virtual void destroy(void); virtual bool begin_allow_threads(); virtual bool end_allow_threads(); virtual void check_hangup_hook(); Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp Tue Mar 24 10:30:08 2009 @@ -9942,6 +9942,33 @@ } +XS(_wrap_Session_destroy) { + { + PERL::Session *arg1 = (PERL::Session *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Session_destroy(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_PERL__Session, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_destroy" "', argument " "1"" of type '" "PERL::Session *""'"); + } + arg1 = reinterpret_cast< PERL::Session * >(argp1); + (arg1)->destroy(); + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + XS(_wrap_Session_begin_allow_threads) { { PERL::Session *arg1 = (PERL::Session *) 0 ; @@ -11217,6 +11244,7 @@ {"freeswitchc::dtmf_callback", _wrap_dtmf_callback}, {"freeswitchc::new_Session", _wrap_new_Session}, {"freeswitchc::delete_Session", _wrap_delete_Session}, +{"freeswitchc::Session_destroy", _wrap_Session_destroy}, {"freeswitchc::Session_begin_allow_threads", _wrap_Session_begin_allow_threads}, {"freeswitchc::Session_end_allow_threads", _wrap_Session_end_allow_threads}, {"freeswitchc::Session_check_hangup_hook", _wrap_Session_check_hangup_hook}, @@ -11534,17 +11562,17 @@ SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) "freeswitch::IVRMenu"); SWIG_TypeClientData(SWIGTYPE_p_API, (void*) "freeswitch::API"); SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) "freeswitch::input_callback_state_t"); - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_HUP", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_HUP))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_FREE", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_FREE))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_RDLOCK", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK))); SvREADONLY_on(sv); Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py (original) +++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py Tue Mar 24 10:30:08 2009 @@ -324,6 +324,7 @@ def begin_allow_threads(*args): return _freeswitch.Session_begin_allow_threads(*args) def end_allow_threads(*args): return _freeswitch.Session_end_allow_threads(*args) def check_hangup_hook(*args): return _freeswitch.Session_check_hangup_hook(*args) + def destroy(*args): return _freeswitch.Session_destroy(*args) def run_dtmf_callback(*args): return _freeswitch.Session_run_dtmf_callback(*args) def setInputCallback(*args): return _freeswitch.Session_setInputCallback(*args) def unsetInputCallback(*args): return _freeswitch.Session_unsetInputCallback(*args) Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp Tue Mar 24 10:30:08 2009 @@ -21,16 +21,25 @@ } static switch_status_t python_hanguphook(switch_core_session_t *session_hungup); -Session::~Session() +void Session::destroy(void) { - if (hangup_func) { - if (session) { - switch_core_event_hook_remove_state_change(session, python_hanguphook); + if (!allocated) { + return; + } + + if (session) { + if (!channel) { + channel = switch_core_session_get_channel(session); } - Py_DECREF(hangup_func); - hangup_func = NULL; + switch_channel_set_private(channel, "CoreSession", NULL); + switch_core_event_hook_remove_state_change(session, python_hanguphook); } + + if (hangup_func) { + Py_DECREF(hangup_func); + hangup_func = NULL; + } if (hangup_func_arg) { Py_DECREF(hangup_func_arg); @@ -49,7 +58,14 @@ if (Self) { Py_DECREF(Self); - } + } + + CoreSession::destroy(); +} + +Session::~Session() +{ + destroy(); } bool Session::begin_allow_threads() Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h (original) +++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h Tue Mar 24 10:30:08 2009 @@ -27,6 +27,7 @@ virtual bool begin_allow_threads(); virtual bool end_allow_threads(); virtual void check_hangup_hook(); + virtual void destroy(void); virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype); void setInputCallback(PyObject *cbfunc, PyObject *funcargs = NULL); Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Tue Mar 24 10:30:08 2009 @@ -9442,6 +9442,27 @@ } +SWIGINTERN PyObject *_wrap_Session_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + PYTHON::Session *arg1 = (PYTHON::Session *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Session_destroy",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_PYTHON__Session, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_destroy" "', argument " "1"" of type '" "PYTHON::Session *""'"); + } + arg1 = reinterpret_cast< PYTHON::Session * >(argp1); + (arg1)->destroy(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_Session_run_dtmf_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; PYTHON::Session *arg1 = (PYTHON::Session *) 0 ; @@ -10114,6 +10135,7 @@ { (char *)"Session_begin_allow_threads", _wrap_Session_begin_allow_threads, METH_VARARGS, NULL}, { (char *)"Session_end_allow_threads", _wrap_Session_end_allow_threads, METH_VARARGS, NULL}, { (char *)"Session_check_hangup_hook", _wrap_Session_check_hangup_hook, METH_VARARGS, NULL}, + { (char *)"Session_destroy", _wrap_Session_destroy, METH_VARARGS, NULL}, { (char *)"Session_run_dtmf_callback", _wrap_Session_run_dtmf_callback, METH_VARARGS, NULL}, { (char *)"Session_setInputCallback", _wrap_Session_setInputCallback, METH_VARARGS, NULL}, { (char *)"Session_unsetInputCallback", _wrap_Session_unsetInputCallback, METH_VARARGS, NULL}, Modified: freeswitch/trunk/src/switch_cpp.cpp ============================================================================== --- freeswitch/trunk/src/switch_cpp.cpp (original) +++ freeswitch/trunk/src/switch_cpp.cpp Tue Mar 24 10:30:08 2009 @@ -887,6 +887,10 @@ SWITCH_DECLARE(void) CoreSession::destroy(void) { this_check_void(); + + if (!allocated) { + return; + } switch_safe_free(xml_cdr_text); switch_safe_free(uuid); @@ -903,7 +907,7 @@ } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy/unlink session from object\n"); - + if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) { switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } @@ -912,7 +916,7 @@ channel = NULL; } - allocated = 0; + init_vars(); } From brian at freeswitch.org Tue Mar 24 08:30:45 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:30:45 -0500 Subject: [Freeswitch-svn] [commit] r12731 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: brian Date: Tue Mar 24 10:30:45 2009 New Revision: 12731 Log: Thu Mar 5 10:19:35 CST 2009 Pekka Pessi * check_nua: using fail_unless_event() macro Ignore-this: b03dc7431e8fea9835322bd8f825a803 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:30:45 2009 @@ -1 +1 @@ -Tue Mar 10 14:57:43 CDT 2009 +Tue Mar 24 10:29:44 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c Tue Mar 24 10:30:45 2009 @@ -103,7 +103,7 @@ mark_point(); nua_shutdown(nua); - fail_unless(s2_check_event(nua_r_shutdown, 200)); + fail_unless_event(nua_r_shutdown, 200); s2_nua_teardown(); } @@ -186,7 +186,7 @@ fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); } @@ -216,7 +216,7 @@ respond_with_sdp(invite, d1, SIP_200_OK, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -253,7 +253,7 @@ invite = invite_sent_by_nua(nh, TAG_END()); s2_sip_respond_to(invite, d1, 404, "First not found", TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 404)); + fail_unless_event(nua_r_invite, 404); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -276,7 +276,7 @@ /* Wake up nua thread and let it time out INVITE transaction */ nua_set_params(s2->nua, TAG_END()); - s2_check_event(nua_r_set_params, 0); + fail_unless_event(nua_r_set_params, 0); s2_sip_respond_to(invite, d1, 404, "Not found after 32 seconds", TAG_END()); s2_sip_free_message(invite); @@ -307,7 +307,7 @@ respond_with_sdp(invite, d1, SIP_200_OK, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Tue Mar 24 10:30:45 2009 @@ -405,7 +405,7 @@ s2_sip_free_message(m); assert(s2->registration->contact != NULL); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); s2->registration->nh = nh; } @@ -437,7 +437,7 @@ s2_sip_free_message(m); - s2_check_event(nua_r_unregister, 200); + fail_unless_event(nua_r_unregister, 200); nua_handle_destroy(nh); s2->registration->nh = NULL; Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h Tue Mar 24 10:30:45 2009 @@ -83,6 +83,9 @@ int s2_check_callstate(enum nua_callstate state); int s2_check_substate(struct event *e, enum nua_substate state); +#define fail_unless_event(event, status) \ + fail_unless(s2_check_event(event, status)) + #define SIP_METHOD_UNKNOWN sip_method_unknown, NULL void s2_flush_all(void); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c Tue Mar 24 10:30:45 2009 @@ -94,7 +94,7 @@ { s2_teardown_started("register"); nua_shutdown(nua); - fail_unless(s2_check_event(nua_r_shutdown, 200)); + fail_unless_event(nua_r_shutdown, 200); s2_nua_teardown(); } @@ -162,7 +162,7 @@ SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 407); + fail_unless_event(nua_r_register, 407); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); @@ -173,7 +173,7 @@ SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 401); + fail_unless_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth2_credentials), TAG_END()); @@ -190,7 +190,7 @@ s2_sip_free_message(m); assert(s2->registration->contact != NULL); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); s2->registration->nh = nh; @@ -250,7 +250,7 @@ s2_sip_free_message(m); assert(s2->registration->contact != NULL); - s2_check_event(nua_r_register, 100); + fail_unless_event(nua_r_register, 100); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); @@ -266,7 +266,7 @@ fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); s2->registration->nh = nh; @@ -294,7 +294,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 401); + fail_unless_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); @@ -315,7 +315,7 @@ s2_sip_free_message(m); assert(s2->registration->contact != NULL); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); return nh; } @@ -392,7 +392,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_i_outbound, 0); + fail_unless_event(nua_i_outbound, 0); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); @@ -406,7 +406,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); @@ -448,7 +448,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 100); + fail_unless_event(nua_r_register, 100); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); @@ -465,7 +465,7 @@ fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); s2_register_teardown(); @@ -494,7 +494,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 100); + fail_unless_event(nua_r_register, 100); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); @@ -509,7 +509,7 @@ fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); s2->registration->nh = nh; @@ -545,7 +545,7 @@ s2_sip_free_message(m); assert(s2->registration->contact != NULL); - s2_check_event(nua_r_register, 100); + fail_unless_event(nua_r_register, 100); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); @@ -563,7 +563,7 @@ fail_if(s2->registration->contact->m_next != NULL); fail_unless( url_has_param(s2->registration->contact->m_url, "transport=tcp")); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); s2->registration->nh = nh; @@ -599,7 +599,7 @@ "close TCP at server, wait for re-REGISTERs."); nua_set_params(nua, NTATAG_TCP_RPORT(1), TAG_END()); - s2_check_event(nua_r_set_params, 200); + fail_unless_event(nua_r_set_params, 200); mark_point(); s2->registration->nh = nh; @@ -623,7 +623,7 @@ /* The "NAT binding" changed when new TCP connection is established */ /* => NUA re-REGISTERs with newly detected contact */ - s2_check_event(nua_r_register, 100); + fail_unless_event(nua_r_register, 100); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); @@ -637,7 +637,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); @@ -656,7 +656,7 @@ "Register with UDP, UDP time-outing, then w/ TCP using rport. "); nua_set_params(nua, NTATAG_TCP_RPORT(1), TAG_END()); - s2_check_event(nua_r_set_params, 200); + fail_unless_event(nua_r_set_params, 200); mark_point(); s2->registration->nh = nh; @@ -683,7 +683,7 @@ SIPTAG_VIA(natted_via(m)), TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 401); + fail_unless_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); /* Turn off pong */ @@ -703,7 +703,7 @@ s2_sip_free_message(m); /* NUA detects oops... re-registers UDP */ - s2_check_event(nua_r_register, 100); + fail_unless_event(nua_r_register, 100); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); @@ -717,7 +717,7 @@ TAG_END()); s2_sip_free_message(m); - s2_check_event(nua_r_register, 200); + fail_unless_event(nua_r_register, 200); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 24 10:30:45 2009 @@ -99,7 +99,7 @@ if (s2->shutdown == 0) { mark_point(); nua_shutdown(nua); - fail_unless(s2_check_event(nua_r_shutdown, 200)); + fail_unless_event(nua_r_shutdown, 200); } mark_point(); @@ -242,7 +242,7 @@ } ta_end(ta); - fail_unless(s2_check_event(nua_r_invite, status)); + fail_unless_event(nua_r_invite, status); return s2_sip_wait_for_request(SIP_METHOD_PRACK); } @@ -264,12 +264,12 @@ SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); } @@ -322,7 +322,7 @@ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); - fail_unless(s2_check_event(nua_i_ack, 200)); + fail_unless_event(nua_i_ack, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); return nh; @@ -343,7 +343,7 @@ fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); } @@ -366,14 +366,14 @@ SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 407)); + fail_unless_event(nua_r_bye, 407); nua_authenticate(nh, NUTAG_AUTH("Digest:\"s2test\":abc:abc"), TAG_END()); bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_if(s2->events); } @@ -396,12 +396,12 @@ fail_if(!cancel); s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(cancel); - fail_unless(s2_check_event(nua_r_cancel, 200)); + fail_unless_event(nua_r_cancel, 200); s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END()); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - fail_unless(s2_check_event(nua_r_invite, 487)); + fail_unless_event(nua_r_invite, 487); } static void @@ -414,7 +414,7 @@ fail_if(s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, ta_tags(ta))); ta_end(ta); - fail_unless(s2_check_event(nua_i_bye, 200)); + fail_unless_event(nua_i_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); } @@ -598,7 +598,7 @@ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); - fail_unless(s2_check_event(nua_i_ack, 200)); + fail_unless_event(nua_i_ack, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); nua_bye(nh, TAG_END()); @@ -608,7 +608,7 @@ fail_unless(tport_is_tcp(bye->tport)); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); @@ -669,12 +669,12 @@ SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_unless(ack && tport_is_tcp(ack->tport)); @@ -734,9 +734,9 @@ fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - fail_unless(s2_check_event(nua_r_invite, 487)); + fail_unless_event(nua_r_invite, 487); fail_unless(s2_check_callstate(nua_callstate_terminated)); - fail_unless(s2_check_event(nua_r_cancel, 200)); + fail_unless_event(nua_r_cancel, 200); fail_if(s2->events != NULL); nua_handle_destroy(nh); @@ -791,7 +791,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); cancel_by_nua(nh, invite, dialog, TAG_END()); @@ -823,7 +823,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_cancel(nh, TAG_END()); @@ -834,7 +834,7 @@ s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); s2_sip_free_message(cancel); - fail_unless(s2_check_event(nua_r_cancel, 481)); + fail_unless_event(nua_r_cancel, 481); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -872,7 +872,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_bye(nh, TAG_END()); @@ -883,7 +883,7 @@ s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END()); s2_sip_free_message(cancel); - fail_unless(s2_check_event(nua_r_cancel, 481)); + fail_unless_event(nua_r_cancel, 481); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -893,7 +893,7 @@ fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); @@ -935,7 +935,7 @@ s2_sip_free_message(response); fail_if(s2_sip_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END())); - fail_unless(s2_check_event(nua_i_cancel, 200)); + fail_unless_event(nua_i_cancel, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); response = s2_sip_wait_for_response(200, SIP_METHOD_CANCEL); @@ -990,7 +990,7 @@ s2_sip_free_message(response); fail_if(s2_sip_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END())); - fail_unless(s2_check_event(nua_i_cancel, 200)); + fail_unless_event(nua_i_cancel, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); response = s2_sip_wait_for_response(200, SIP_METHOD_CANCEL); @@ -1029,7 +1029,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_cancel(nh, TAG_END()); @@ -1045,8 +1045,8 @@ s2_sip_free_message(cancel); } - fail_unless(s2_check_event(nua_r_cancel, 408)); - fail_unless(s2_check_event(nua_r_invite, 408)); + fail_unless_event(nua_r_cancel, 408); + fail_unless_event(nua_r_invite, 408); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); } @@ -1074,7 +1074,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_cancel(nh, TAG_END()); @@ -1088,7 +1088,7 @@ s2_nua_fast_forward(1, s2base->root); } - fail_unless(s2_check_event(nua_r_invite, 408)); + fail_unless_event(nua_r_invite, 408); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); } @@ -1117,7 +1117,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_cancel(nh, TAG_END()); @@ -1138,7 +1138,7 @@ s2->registration->nh = NULL; nua_set_params(s2->nua, NUTAG_SHUTDOWN_EVENTS(1), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); nua_shutdown(s2->nua); event = s2_wait_for_event(nua_r_shutdown, 100); @@ -1202,7 +1202,7 @@ SIPTAG_RECORD_ROUTE(rr), TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); ack = s2_sip_wait_for_request(SIP_METHOD_ACK); if (rr == NULL) @@ -1319,7 +1319,7 @@ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); prack = respond_with_100rel(invite, dialog, with_sdp = 0, SIP_180_RINGING, @@ -1330,7 +1330,7 @@ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); /* Change the record-route */ rr->r_url->url_user = "record2"; @@ -1338,7 +1338,7 @@ SIPTAG_RECORD_ROUTE(rr), TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); @@ -1383,7 +1383,7 @@ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); prack = respond_with_100rel(invite, dialog, with_sdp = 0, SIP_180_RINGING, @@ -1391,11 +1391,11 @@ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -1450,7 +1450,7 @@ SIPTAG_REQUIRE_STR("100rel"), TAG_END()); s2_sip_free_message(prack), prack = NULL; - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); fail_unless(s2_check_callstate(nua_callstate_proceeding)); update = s2_sip_wait_for_request(SIP_METHOD_UPDATE); @@ -1463,7 +1463,7 @@ TAG_END()); s2_sip_free_message(update), update = NULL; - fail_unless(s2_check_event(nua_r_update, 200)); + fail_unless_event(nua_r_update, 200); fail_unless(s2_check_callstate(nua_callstate_proceeding)); prack = respond_with_100rel(invite, dialog, with_sdp = 0, @@ -1472,11 +1472,11 @@ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; fail_unless(s2_check_callstate(nua_callstate_proceeding)); - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -1518,7 +1518,7 @@ SIPTAG_REQUIRE_STR("100rel"), SIPTAG_RSEQ(rs), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 183)); + fail_unless_event(nua_r_invite, 183); fail_unless(s2_check_callstate(nua_callstate_proceeding)); sip_rack_init(rack)->ra_response = s2_rseq; @@ -1532,14 +1532,14 @@ s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_completing)); respond_with_sdp( prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -1554,7 +1554,7 @@ TAG_END()); s2_sip_free_message(update), update = NULL; - fail_unless(s2_check_event(nua_r_update, 200)); + fail_unless_event(nua_r_update, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); bye_to_nua(nh, TAG_END()); @@ -1594,7 +1594,7 @@ SIPTAG_REQUIRE_STR("100rel"), SIPTAG_RSEQ(rs), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 183)); + fail_unless_event(nua_r_invite, 183); fail_unless(s2_check_callstate(nua_callstate_proceeding)); sip_rack_init(rack)->ra_response = s2_rseq; @@ -1609,7 +1609,7 @@ prack, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(prack), prack = NULL; - fail_unless(s2_check_event(nua_r_prack, 200)); + fail_unless_event(nua_r_prack, 200); fail_unless(s2_check_callstate(nua_callstate_proceeding)); update = s2_sip_wait_for_request(SIP_METHOD_UPDATE); @@ -1618,7 +1618,7 @@ s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_completing)); process_offer(update); @@ -1627,7 +1627,7 @@ TAG_END()); s2_sip_free_message(update), update = NULL; - fail_unless(s2_check_event(nua_r_update, 200)); + fail_unless_event(nua_r_update, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); @@ -1681,7 +1681,7 @@ fail_if(!ack); s2_sip_free_message(ack); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); } @@ -1727,7 +1727,7 @@ fail_if(soa_process_reject(soa, NULL) < 0); /* We get nua_r_invite with 100 trying (and 500 in sip->sip_status) */ - fail_unless(s2_check_event(nua_r_invite, 100)); + fail_unless_event(nua_r_invite, 100); s2_nua_fast_forward(10, s2base->root); @@ -1737,7 +1737,7 @@ process_offer(invite); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); ack = s2_sip_wait_for_request(SIP_METHOD_ACK); fail_if(!ack); @@ -1780,13 +1780,13 @@ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); - fail_unless(s2_check_event(nua_i_ack, 200)); + fail_unless_event(nua_i_ack, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); s2_nua_fast_forward(10, s2base->root); nua_set_hparams(nh, NUTAG_REFRESH_WITHOUT_SDP(1), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_sip_request_to(dialog, SIP_METHOD_INVITE, NULL, SIPTAG_USER_AGENT_STR("evil (evil) evil"), @@ -1805,7 +1805,7 @@ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END())); - fail_unless(s2_check_event(nua_i_ack, 200)); + fail_unless_event(nua_i_ack, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); bye_by_nua(nh, TAG_END()); @@ -1842,7 +1842,7 @@ process_answer(ack); s2_sip_free_message(ack); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); bye_by_nua(nh, TAG_END()); @@ -1894,7 +1894,7 @@ fail_if(!ack); fail_if(strcmp(ack->sip->sip_to->a_display, "UAS Changed")); s2_sip_free_message(ack); - fail_unless(s2_check_event(nua_r_invite, 403)); + fail_unless_event(nua_r_invite, 403); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); @@ -1929,11 +1929,11 @@ fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); if (i == 3) break; - fail_unless(s2_check_event(nua_r_invite, 100)); + fail_unless_event(nua_r_invite, 100); s2_nua_fast_forward(5, s2base->root); } - fail_unless(s2_check_event(nua_r_invite, 500)); + fail_unless_event(nua_r_invite, 500); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); @@ -1961,7 +1961,7 @@ s2_sip_free_message(invite); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - fail_unless(s2_check_event(nua_r_invite, 403)); + fail_unless_event(nua_r_invite, 403); /* Return to previous state */ fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -1999,18 +1999,18 @@ fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); if (i == 3) break; - fail_unless(s2_check_event(nua_r_invite, 100)); + fail_unless_event(nua_r_invite, 100); s2_nua_fast_forward(5, s2base->root); } - fail_unless(s2_check_event(nua_r_invite, 500)); + fail_unless_event(nua_r_invite, 500); /* Graceful termination */ fail_unless(s2_check_callstate(nua_callstate_terminating)); bye = s2_sip_wait_for_request(SIP_METHOD_BYE); fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); @@ -2038,7 +2038,7 @@ s2_sip_respond_to(invite, NULL, SIP_491_REQUEST_PENDING, TAG_END()); s2_sip_free_message(invite); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); - fail_unless(s2_check_event(nua_r_invite, 491)); + fail_unless_event(nua_r_invite, 491); /* Return to previous state */ fail_unless(s2_check_callstate(nua_callstate_ready)); @@ -2088,7 +2088,7 @@ SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 407)); + fail_unless_event(nua_r_bye, 407); soa_generate_offer(soa, 1, NULL); @@ -2137,7 +2137,7 @@ s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); nua_handle_destroy(nh); } @@ -2157,7 +2157,7 @@ mark_point(); nua_set_hparams(nh, NUTAG_APPL_METHOD("BYE"), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_flush_events(); @@ -2174,7 +2174,7 @@ s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE)); @@ -2197,7 +2197,7 @@ mark_point(); nua_set_hparams(nh, NUTAG_APPL_METHOD("BYE"), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_flush_events(); s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); @@ -2212,7 +2212,7 @@ s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_respond(nh, 200, "OKOK", NUTAG_WITH(i_bye->data->e_msg), TAG_END()); @@ -2236,7 +2236,7 @@ mark_point(); nua_set_hparams(nh, NUTAG_APPL_METHOD("BYE"), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_flush_events(); s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); @@ -2251,7 +2251,7 @@ s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); nua_handle_destroy(nh); @@ -2271,14 +2271,14 @@ nh = invite_to_nua(TAG_END()); nua_set_hparams(nh, NUTAG_AUTOANSWER(0), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_flush_events(); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE)); nua_bye(nh, TAG_END()); - fail_unless(s2_check_event(nua_i_invite, 100)); + fail_unless_event(nua_i_invite, 100); fail_unless(s2_check_callstate(nua_callstate_received)); do { @@ -2309,14 +2309,14 @@ nh = invite_to_nua(TAG_END()); nua_set_hparams(nh, NUTAG_AUTOANSWER(0), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_flush_events(); request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE)); nua_bye(nh, TAG_END()); - fail_unless(s2_check_event(nua_i_invite, 100)); + fail_unless_event(nua_i_invite, 100); fail_unless(s2_check_callstate(nua_callstate_received)); bye = s2_sip_wait_for_request(SIP_METHOD_BYE); @@ -2352,7 +2352,7 @@ request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END()); fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE)); nua_bye(nh, TAG_END()); - fail_unless(s2_check_event(nua_i_invite, 100)); + fail_unless_event(nua_i_invite, 100); fail_unless(s2_check_callstate(nua_callstate_received)); nua_respond(nh, SIP_486_BUSY_HERE, TAG_END()); @@ -2445,7 +2445,7 @@ fail_if(!bye); fail_unless(s2_check_callstate(nua_callstate_calling)); - fail_unless(s2_check_event(nua_r_invite, 501)); + fail_unless_event(nua_r_invite, 501); fail_unless(s2_check_callstate(nua_callstate_terminating)); s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); @@ -2483,12 +2483,12 @@ invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_completing)); s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END()); @@ -2533,7 +2533,7 @@ SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 407)); + fail_unless_event(nua_r_bye, 407); s2_nua_fast_forward(300, s2base->root); @@ -2542,7 +2542,7 @@ fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_if(s2->events); @@ -2579,7 +2579,7 @@ SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 407)); + fail_unless_event(nua_r_bye, 407); s2_nua_fast_forward(160, s2base->root); @@ -2588,7 +2588,7 @@ fail_if(!bye); s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(bye); - fail_unless(s2_check_event(nua_r_bye, 200)); + fail_unless_event(nua_r_bye, 200); fail_unless(s2_check_callstate(nua_callstate_terminated)); fail_if(s2->events); @@ -2662,7 +2662,7 @@ invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_handle_destroy(nh); @@ -2690,11 +2690,11 @@ invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_completing)); nua_handle_destroy(nh); @@ -2726,11 +2726,11 @@ invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_completing)); nua_ack(nh, TAG_END()); @@ -2793,7 +2793,7 @@ invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_handle_destroy(nh); @@ -2822,11 +2822,11 @@ invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_completing)); nua_handle_destroy(nh); @@ -2892,7 +2892,7 @@ invite = invite_sent_by_nua(nh, TAG_END()); process_offer(invite); s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); nua_handle_destroy(nh); @@ -3156,7 +3156,7 @@ nua_handle_destroy(nh); nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); @@ -3202,7 +3202,7 @@ "Test multithreading nua_respond() API with OPTIONS."); nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END()); - fail_unless(s2_check_event(nua_r_set_params, 200)); + fail_unless_event(nua_r_set_params, 200); s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); @@ -3354,7 +3354,7 @@ invite, dialog, SIP_180_RINGING, SIPTAG_CONTENT_DISPOSITION_STR("session;handling=optional"), TAG_END()); - fail_unless(s2_check_event(nua_r_invite, 180)); + fail_unless_event(nua_r_invite, 180); fail_unless(s2_check_callstate(nua_callstate_proceeding)); notify1 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY); @@ -3362,7 +3362,7 @@ respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END()); s2_sip_free_message(invite); - fail_unless(s2_check_event(nua_r_invite, 200)); + fail_unless_event(nua_r_invite, 200); fail_unless(s2_check_callstate(nua_callstate_ready)); fail_unless(s2_sip_check_request(SIP_METHOD_ACK)); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Tue Mar 24 10:30:45 2009 @@ -80,7 +80,7 @@ nua_shutdown(nua); - fail_unless(s2_check_event(nua_r_shutdown, 200)); + fail_unless_event(nua_r_shutdown, 200); s2_nua_teardown(); } @@ -509,7 +509,7 @@ nua_set_params(nua, NUTAG_APPL_METHOD("SUBSCRIBE"), SIPTAG_ALLOW_EVENTS_STR(event), TAG_END()); - s2_check_event(nua_r_set_params, 200); + fail_unless_event(nua_r_set_params, 200); ta_start(ta, tag, value); s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, @@ -550,7 +550,7 @@ s2_sip_check_response(489, SIP_METHOD_SUBSCRIBE); nua_set_params(nua, NUTAG_APPL_METHOD("SUBSCRIBE"), TAG_END()); - s2_check_event(nua_r_set_params, 200); + fail_unless_event(nua_r_set_params, 200); s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, SIPTAG_EVENT_STR("presence"), @@ -558,7 +558,7 @@ s2_sip_check_response(489, SIP_METHOD_SUBSCRIBE); nua_set_params(nua, SIPTAG_ALLOW_EVENTS_STR("presence"), TAG_END()); - s2_check_event(nua_r_set_params, 200); + fail_unless_event(nua_r_set_params, 200); s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL, SIPTAG_EVENT_STR("presence"), @@ -601,7 +601,7 @@ "terminated")); s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); - s2_check_event(nua_r_notify, 200); + fail_unless_event(nua_r_notify, 200); nua_handle_destroy(nh); } END_TEST @@ -629,7 +629,7 @@ fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); - s2_check_event(nua_r_notify, 200); + fail_unless_event(nua_r_notify, 200); s2_nua_fast_forward(300, s2base->root); @@ -640,7 +640,7 @@ fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "terminated")); s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); - s2_check_event(nua_r_notify, 200); + fail_unless_event(nua_r_notify, 200); nua_handle_destroy(nh); } @@ -682,7 +682,7 @@ fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); - s2_check_event(nua_r_notify, 200); + fail_unless_event(nua_r_notify, 200); nua_notify(nh, NUTAG_SUBSTATE(nua_substate_active), @@ -728,7 +728,7 @@ fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate, "active")); s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END()); - s2_check_event(nua_r_notify, 200); + fail_unless_event(nua_r_notify, 200); nua_notify(nh, NUTAG_SUBSTATE(nua_substate_active), From mikej at freeswitch.org Tue Mar 24 08:32:08 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:32:08 -0500 Subject: [Freeswitch-svn] [commit] r12732 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 24 10:32:08 2009 New Revision: 12732 Log: Thu Mar 5 10:20:11 CST 2009 Pekka Pessi * check_nua: s2_setup_logs() now turns on transport logging, too Ignore-this: 4ad4dc1efaf76c34a46038586a00e084 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:32:08 2009 @@ -1 +1 @@ -Tue Mar 24 10:29:44 CDT 2009 +Tue Mar 24 10:30:39 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Tue Mar 24 10:32:08 2009 @@ -295,6 +295,11 @@ su_log_soft_set_level(nea_log, level); su_log_soft_set_level(nta_log, level); su_log_soft_set_level(tport_log, level); + + if (getenv("TPORT_LOG") == NULL && getenv("S2_TPORT_LOG") == NULL) { + if (s2sip) + tport_set_params(s2sip->master, TPTAG_LOG(level > 1), TAG_END()); + } } nua_t *s2_nua_setup(char const *label, From mikej at freeswitch.org Tue Mar 24 08:32:49 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:32:49 -0500 Subject: [Freeswitch-svn] [commit] r12733 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 24 10:32:49 2009 New Revision: 12733 Log: Thu Mar 5 11:44:15 CST 2009 Pekka Pessi * s2check.h: redefine tcase_add_loop_test, too Ignore-this: 149c19e8d089b60e8ddcb98da54c9d88 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2check.h freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:32:49 2009 @@ -1 +1 @@ -Tue Mar 24 10:30:39 CDT 2009 +Tue Mar 24 10:31:53 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2check.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2check.h (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2check.h Tue Mar 24 10:32:49 2009 @@ -42,10 +42,16 @@ SOFIA_BEGIN_DECLS #undef tcase_add_test +#undef tcase_add_loop_test + /* Redirect tcase_add_test() to our function */ -#define tcase_add_test(tc, tf) s2_tcase_add_test(tc, tf, "" #tf "") +#define tcase_add_test(tc, tf) s2_tcase_add_test(tc, tf, "" #tf "", 0, 0, 1) + +void s2_tcase_add_test(TCase *, TFun, char const *name, + int signo, int start, int end); -void s2_tcase_add_test(TCase *, TFun, char const *name); +#define tcase_add_loop_test(tc, tf, s, e) \ + s2_tcase_add_test(tc, tf, "" #tf "", 0, (s), (e)) void s2_select_tests(char const *pattern); Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c Tue Mar 24 10:32:49 2009 @@ -46,7 +46,8 @@ * A special version of tcase_add_test() that inserts test function into * tcase only if its name matches given pattern. */ -void s2_tcase_add_test(TCase *tc, TFun tf, char const *name) +void s2_tcase_add_test(TCase *tc, TFun tf, char const *name, + int signo, int start, int end) { char const * const *patterns; @@ -54,9 +55,9 @@ for (patterns = test_patterns; *patterns; patterns++) { if (!fnmatch(*patterns, name, 0)) { if (strcmp(*patterns, "*")) { - printf("%s: running\n", name); + printf("%s: selected\n", name); } - _tcase_add_test(tc, tf, name, 0, 0, 1); + _tcase_add_test(tc, tf, name, signo, start, end); return; } } @@ -64,9 +65,9 @@ for (patterns = test_patterns; *patterns; patterns++) { if (!strcmp(*patterns, name) || !strcmp(*patterns, "*")) { if (strcmp(*patterns, "*")) { - printf("%s: running\n", name); + printf("%s: selected\n", name); } - _tcase_add_test(tc, tf, name, 0, 0, 1); + _tcase_add_test(tc, tf, name, signo, start, end); return; } } From mikej at freeswitch.org Tue Mar 24 08:33:33 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:33:33 -0500 Subject: [Freeswitch-svn] [commit] r12734 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 24 10:33:33 2009 New Revision: 12734 Log: Thu Mar 5 12:29:30 CST 2009 Pekka Pessi * s2base.h: added S2_CASE(), added test function name to s2_case() parameters Ignore-this: c9ceff2812044e2643c21548be29233e Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2base.c freeswitch/trunk/libs/sofia-sip/s2check/s2base.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:33:33 2009 @@ -1 +1 @@ -Tue Mar 24 10:31:53 CDT 2009 +Tue Mar 24 10:32:33 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2base.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2base.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.c Tue Mar 24 10:33:33 2009 @@ -126,13 +126,15 @@ void s2_case(char const *number, char const *title, - char const *description) + char const *description, + char const *function) { stamps.start = now(); _s2_case = number; if (s2_start_stop) - printf("%s - starting %s/%s-%s\n", s2_tester, _s2_suite, _s2_case, title); + printf("%s - starting %s (%s/%s %s)\n", s2_tester, function, + _s2_suite, _s2_case, title); } void s2_step(void) Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2base.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2base.h (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.h Tue Mar 24 10:33:33 2009 @@ -44,7 +44,16 @@ void s2_case(char const *tag, char const *title, - char const *description); + char const *description, + char const *function); + +#if HAVE_FUNC +#define S2_CASE(n, t, d) s2_case((n),(t),(d), __func__) +#elif HAVE_FUNCTION +#define S2_CASE(n, t, d) s2_case((n),(t),(d), __FUNCTION__) +#else +#define S2_CASE(n, t, d) s2_case((n),(t),(d), "") +#endif void s2_teardown_started(char const *label); void s2_teardown(void); From mikej at freeswitch.org Tue Mar 24 08:34:23 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:34:23 -0500 Subject: [Freeswitch-svn] [commit] r12735 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 24 10:34:23 2009 New Revision: 12735 Log: Thu Mar 5 13:04:56 CST 2009 Pekka Pessi * check_nua: use S2_CASE() Ignore-this: 85691a39065d7ad3da57f45fe87c1da Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:34:23 2009 @@ -1 +1 @@ -Tue Mar 24 10:32:33 CDT 2009 +Tue Mar 24 10:33:24 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c Tue Mar 24 10:34:23 2009 @@ -201,7 +201,7 @@ struct message *invite; struct message *bye; - s2_case("6.1.1", "SIP_CC_OE_CE_V_019", + S2_CASE("6.1.1", "SIP_CC_OE_CE_V_019", "Ensure that the IUT when an INVITE client transaction " "is in the Calling state, on receipt of Success (200 OK) " "responses differing only on the tag in the To header, " @@ -241,7 +241,7 @@ nua_handle_t *nh; struct message *invite; - s2_case("6.1.2", "SIP_CC_OE_CE_TI_008", + S2_CASE("6.1.2", "SIP_CC_OE_CE_TI_008", "If an unreliable transport is used, ensure that " "the IUT, when an INVITE client transaction is in " "the Completed state, on receipt of final responses " @@ -291,7 +291,7 @@ nua_handle_t *nh; struct message *invite; - s2_case("6.1.2", "SIP_CC_OE_CE_TI_011_012", + S2_CASE("6.1.2", "SIP_CC_OE_CE_TI_011_012", "Ensure that the IUT, when an INVITE client transaction " "has been in the Terminated state, on receipt of a " "retransmitted Success (200 OK) responses sends an ACK " Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c Tue Mar 24 10:34:23 2009 @@ -117,7 +117,7 @@ nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); struct message *m; - s2_case("1.0.1", "Failed Register", "REGISTER returned 403 response"); + S2_CASE("1.0.1", "Failed Register", "REGISTER returned 403 response"); nua_register(nh, TAG_END()); @@ -135,7 +135,7 @@ START_TEST(register_1_1_1) { - s2_case("1.1.1", "Basic Register", "REGISTER returning 200 OK"); + S2_CASE("1.1.1", "Basic Register", "REGISTER returning 200 OK"); s2_register_setup(); @@ -149,7 +149,7 @@ nua_handle_t *nh; struct message *m; - s2_case("1.1.2", "Register with dual authentication", + S2_CASE("1.1.2", "Register with dual authentication", "Register, authenticate"); nh = nua_handle(nua, NULL, TAG_END()); @@ -230,7 +230,7 @@ nua_handle_t *nh; struct message *m; - s2_case("1.2.1", "Register behind NAT", + S2_CASE("1.2.1", "Register behind NAT", "Register through NAT, detect NAT, re-REGISTER"); nh = nua_handle(nua, NULL, TAG_END()); @@ -324,7 +324,7 @@ { nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); - s2_case("1.2.2.1", "Register behind NAT", + S2_CASE("1.2.2.1", "Register behind NAT", "Authenticate, outbound activated"); mark_point(); @@ -339,7 +339,7 @@ nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); struct message *m; - s2_case("1.2.2.2", "Register behind NAT", + S2_CASE("1.2.2.2", "Register behind NAT", "Authenticate, outbound activated, " "authenticate OPTIONS probe, " "NAT binding change"); @@ -421,7 +421,7 @@ nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); struct message *m; - s2_case("1.2.2.3", "Register behind NAT", + S2_CASE("1.2.2.3", "Register behind NAT", "Authenticate, outbound activated, " "detect NAT binding change when re-REGISTERing"); @@ -476,7 +476,7 @@ nua_handle_t *nh; struct message *m; - s2_case("1.2.3", "Register behind NAT", + S2_CASE("1.2.3", "Register behind NAT", "Outbound activated by error response"); nh = nua_handle(nua, NULL, TAG_END()); @@ -525,7 +525,7 @@ nua_handle_t *nh; struct message *m; - s2_case("1.3.1", "Register over TCP via NAT", + S2_CASE("1.3.1", "Register over TCP via NAT", "REGISTER via TCP, detect NTA, re-REGISTER"); nh = nua_handle(nua, NULL, TAG_END()); @@ -576,7 +576,7 @@ { nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); - s2_case("1.3.2.1", "Register behind NAT", + S2_CASE("1.3.2.1", "Register behind NAT", "Authenticate, outbound activated"); mark_point(); @@ -593,7 +593,7 @@ nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); struct message *m; - s2_case("1.3.2.2", "Register behind NAT with TCP", + S2_CASE("1.3.2.2", "Register behind NAT with TCP", "Detect NAT over TCP using rport. " "Authenticate, detect NAT, " "close TCP at server, wait for re-REGISTERs."); @@ -652,7 +652,7 @@ struct message *m; tport_t *tcp; - s2_case("1.3.3.1", "Register behind NAT with UDP and TCP", + S2_CASE("1.3.3.1", "Register behind NAT with UDP and TCP", "Register with UDP, UDP time-outing, then w/ TCP using rport. "); nua_set_params(nua, NTATAG_TCP_RPORT(1), TAG_END()); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 24 10:34:23 2009 @@ -428,7 +428,7 @@ { nua_handle_t *nh; - s2_case("2.1.1", "Basic call", + S2_CASE("2.1.1", "Basic call", "NUA sends INVITE, NUA sends BYE"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -446,7 +446,7 @@ { nua_handle_t *nh; - s2_case("2.1.2.1", "Basic call", + S2_CASE("2.1.2.1", "Basic call", "NUA sends INVITE, NUA receives BYE"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -463,7 +463,7 @@ { nua_handle_t *nh; - s2_case("2.1.2.2", "Basic call over TCP", + S2_CASE("2.1.2.2", "Basic call over TCP", "NUA sends INVITE, NUA receives BYE"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), @@ -484,7 +484,7 @@ { nua_handle_t *nh; - s2_case("2.1.3.1", "Incoming call", + S2_CASE("2.1.3.1", "Incoming call", "NUA receives INVITE and BYE"); nh = invite_to_nua(TAG_END()); @@ -500,7 +500,7 @@ { nua_handle_t *nh; - s2_case("2.1.3.2", "Incoming call over TCP", + S2_CASE("2.1.3.2", "Incoming call over TCP", "NUA receives INVITE and BYE"); dialog->tport = s2sip->tcp.tport; @@ -518,7 +518,7 @@ { nua_handle_t *nh; - s2_case("2.1.4", "Incoming call", + S2_CASE("2.1.4", "Incoming call", "NUA receives INVITE and sends BYE"); nh = invite_to_nua(TAG_END()); @@ -534,7 +534,7 @@ { nua_handle_t *nh; - s2_case("2.1.5", "Incoming call", + S2_CASE("2.1.5", "Incoming call", "NUA receives INVITE and sends BYE, BYE is challenged"); nh = invite_to_nua(TAG_END()); @@ -553,7 +553,7 @@ struct event *invite; struct message *response; - s2_case("2.1.6", "Basic call", + S2_CASE("2.1.6", "Basic call", "NUA received INVITE, " "NUA responds (and saves proxy for dialog), " "NUA sends BYE"); @@ -621,7 +621,7 @@ nua_handle_t *nh, *nh2; sip_replaces_t *replaces; - s2_case("2.1.7", "Call lookup", + S2_CASE("2.1.7", "Call lookup", "Test dialog and call-id lookup"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -654,7 +654,7 @@ nua_handle_t *nh; struct message *invite, *ack; - s2_case("2.1.8", "Call using NUTAG_PROXY()", + S2_CASE("2.1.8", "Call using NUTAG_PROXY()", "Test handle-specific NUTAG_PROXY()."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -713,7 +713,7 @@ nua_handle_t *nh; struct message *invite, *cancel; - s2_case("2.2.1", "Cancel call", + S2_CASE("2.2.1", "Cancel call", "NUA is caller, NUA sends CANCEL immediately"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -749,7 +749,7 @@ nua_handle_t *nh; struct message *invite; - s2_case("2.2.2", "Canceled call", + S2_CASE("2.2.2", "Canceled call", "NUA is caller, NUA sends CANCEL after receiving 100"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -776,7 +776,7 @@ nua_handle_t *nh; struct message *invite; - s2_case("2.2.3", "Canceled call", + S2_CASE("2.2.3", "Canceled call", "NUA is caller, NUA sends CANCEL after receiving 180"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -807,7 +807,7 @@ nua_handle_t *nh; struct message *invite, *cancel; - s2_case("2.2.4", "Cancel and 200 OK glare", + S2_CASE("2.2.4", "Cancel and 200 OK glare", "NUA is caller, NUA sends CANCEL after receiving 180 " "but UAS already sent 200 OK."); @@ -852,7 +852,7 @@ nua_handle_t *nh; struct message *invite, *cancel, *bye; - s2_case( + S2_CASE( "2.2.5", "Cancel and 200 OK glare", "NUA is caller, " "NUA uses nua_bye() to send CANCEL after receiving 180\n" @@ -907,7 +907,7 @@ struct event *invite; struct message *response; - s2_case("2.2.6", "Cancel call", + S2_CASE("2.2.6", "Cancel call", "NUA is callee, sends 100, 180, INVITE gets canceled"); soa_generate_offer(soa, 1, NULL); @@ -959,7 +959,7 @@ struct message *response; char const *via = "SIP/2.0/UDP host.in.invalid;rport"; - s2_case("2.2.7", "Call gets canceled", + S2_CASE("2.2.7", "Call gets canceled", "NUA is callee, sends 100, 180, INVITE gets canceled. " "Using RFC 2543 dialog and transaction matching."); @@ -1013,7 +1013,7 @@ struct message *invite, *cancel; int timeout; - s2_case("2.2.8", "CANCEL and INVITE times out", + S2_CASE("2.2.8", "CANCEL and INVITE times out", "NUA is caller, NUA sends CANCEL after receiving 180 " "but UAS never responds."); @@ -1058,7 +1058,7 @@ struct message *invite, *cancel; int timeout; - s2_case("2.2.9", "CANCEL a RFC2543 UA", + S2_CASE("2.2.9", "CANCEL a RFC2543 UA", "NUA is caller, NUA sends CANCEL after receiving 180, " "UAS sends 200 OK to CANCEL but no response to INVITE."); @@ -1101,7 +1101,7 @@ struct event *event; int timeout; - s2_case("2.2.10", "CANCEL and INVITE times out", + S2_CASE("2.2.10", "CANCEL and INVITE times out", "NUA is caller, NUA sends CANCEL after receiving 180 " "but UAS never responds."); @@ -1221,7 +1221,7 @@ rr->r_url->url_user = "record"; rr->r_url->url_params = "lr"; - s2_case("2.3.1", "Incoming call with call timers", + S2_CASE("2.3.1", "Incoming call with call timers", "NUA receives INVITE, " "activates call timers, " "sends re-INVITE twice, " @@ -1249,7 +1249,7 @@ { nua_handle_t *nh; - s2_case("2.3.2", "Incoming call with call timers", + S2_CASE("2.3.2", "Incoming call with call timers", "NUA receives INVITE, " "activates call timers, " "sends re-INVITE, " @@ -1294,7 +1294,7 @@ int with_sdp; sip_record_route_t rr[1]; - s2_case("2.4.1", "Call with 100rel", + S2_CASE("2.4.1", "Call with 100rel", "NUA sends INVITE, " "receives 183, sends PRACK, receives 200 for it, " "receives 180, sends PRACK, receives 200 for it, " @@ -1357,7 +1357,7 @@ struct message *invite, *prack; int with_sdp; - s2_case("2.4.2", "Call with 100rel", + S2_CASE("2.4.2", "Call with 100rel", "NUA sends INVITE, " "receives 183, sends PRACK, receives 200 for it, " "receives 180, sends PRACK, receives 200 for it, " @@ -1425,7 +1425,7 @@ struct message *invite, *prack, *update; int with_sdp; - s2_case("2.5.1", "Call with preconditions", + S2_CASE("2.5.1", "Call with preconditions", "NUA sends INVITE, " "receives 183, sends PRACK, receives 200 for it, " "sends UPDATE, receives 200 for it, " @@ -1493,7 +1493,7 @@ sip_rseq_t rs[1]; sip_rack_t rack[1]; - s2_case("2.5.2", "Call with preconditions - send 200 w/ ongoing PRACK ", + S2_CASE("2.5.2", "Call with preconditions - send 200 w/ ongoing PRACK ", "NUA sends INVITE, " "receives 183, sends PRACK, " "receives 200 to INVITE, " @@ -1570,7 +1570,7 @@ sip_rseq_t rs[1]; sip_rack_t rack[1]; - s2_case("2.5.3", "Call with preconditions - send 200 w/ ongoing UPDATE ", + S2_CASE("2.5.3", "Call with preconditions - send 200 w/ ongoing UPDATE ", "NUA sends INVITE, " "receives 183, sends PRACK, receives 200 to PRACK, " "sends UPDATE, " @@ -1658,7 +1658,7 @@ struct message *invite, *ack; int i; - s2_case("2.6.1", "Queued re-INVITEs", + S2_CASE("2.6.1", "Queued re-INVITEs", "NUA receives INVITE, " "sends re-INVITE twice, " "sends BYE."); @@ -1696,7 +1696,7 @@ nua_handle_t *nh; struct message *invite, *ack, *response; - s2_case("2.6.2", "Re-INVITE glare", + S2_CASE("2.6.2", "Re-INVITE glare", "NUA sends re-INVITE and then receives re-INVITE, " "sends BYE."); @@ -1754,7 +1754,7 @@ nua_handle_t *nh; struct message *response; - s2_case("2.6.3", "Handling re-INVITE without SDP gracefully", + S2_CASE("2.6.3", "Handling re-INVITE without SDP gracefully", "NUA receives INVITE, " "re-INVITE without SDP (w/o NUTAG_REFRESH_WITHOUT_SDP(), " "re-INVITE without SDP (using NUTAG_REFRESH_WITHOUT_SDP(), " @@ -1819,7 +1819,7 @@ nua_handle_t *nh; struct message *invite, *ack; - s2_case("2.6.4", "re-INVITEs w/o SDP", + S2_CASE("2.6.4", "re-INVITEs w/o SDP", "NUA sends re-INVITE w/o SDP, " "receives SDP w/ offer, " "sends ACK w/ answer, " @@ -1874,7 +1874,7 @@ nua_handle_t *nh; struct message *invite, *ack; - s2_case("3.1.1", "Call failure", "Call fails with 403 response"); + S2_CASE("3.1.1", "Call failure", "Call fails with 403 response"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -1908,7 +1908,7 @@ struct message *invite; int i; - s2_case("3.1.2", "Call fails after too many retries", + S2_CASE("3.1.2", "Call fails after too many retries", "Call fails after 4 times 500 Retry-After"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), @@ -1945,7 +1945,7 @@ nua_handle_t *nh; struct message *invite; - s2_case("3.2.1", "Re-INVITE failure", "Re-INVITE fails with 403 response"); + S2_CASE("3.2.1", "Re-INVITE failure", "Re-INVITE fails with 403 response"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -1976,7 +1976,7 @@ struct message *invite, *bye; int i; - s2_case("3.2.2", "Re-INVITE fails after too many retries", + S2_CASE("3.2.2", "Re-INVITE fails after too many retries", "Call fails after 4 times 500 Retry-After"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), @@ -2023,7 +2023,7 @@ nua_handle_t *nh; struct message *invite; - s2_case("3.2.3", "Re-INVITE failure", "Re-INVITE fails with 491 response"); + S2_CASE("3.2.3", "Re-INVITE failure", "Re-INVITE fails with 491 response"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2071,7 +2071,7 @@ nua_handle_t *nh; struct message *bye, *r481; - s2_case("4.1.1", "Re-INVITE while terminating", + S2_CASE("4.1.1", "Re-INVITE while terminating", "NUA sends BYE, " "BYE is challenged, " "and NUA is re-INVITEd at the same time."); @@ -2113,7 +2113,7 @@ nua_handle_t *nh; struct message *bye, *r481; - s2_case("4.1.2", "Re-INVITE while terminating", + S2_CASE("4.1.2", "Re-INVITE while terminating", "NUA sends BYE, and gets re-INVITEd at same time"); nh = invite_to_nua(TAG_END()); @@ -2149,7 +2149,7 @@ struct message *bye; struct event *i_bye; - s2_case("4.1.3", "BYE while terminating", + S2_CASE("4.1.3", "BYE while terminating", "NUA sends BYE and receives BYE"); nh = invite_to_nua(TAG_END()); @@ -2190,7 +2190,7 @@ struct message *bye; struct event *i_bye; - s2_case("4.1.4", "Send BYE after BYE has been received", + S2_CASE("4.1.4", "Send BYE after BYE has been received", "NUA receives BYE, tries to send BYE at same time"); nh = invite_to_nua(TAG_END()); @@ -2229,7 +2229,7 @@ struct message *bye; struct event *i_bye; - s2_case("4.1.5", "Send BYE after BYE has been received", + S2_CASE("4.1.5", "Send BYE after BYE has been received", "NUA receives BYE, tries to send BYE at same time"); nh = invite_to_nua(TAG_END()); @@ -2265,7 +2265,7 @@ nua_handle_t *nh; struct message *bye, *r486; - s2_case("4.1.6", "Send BYE after INVITE has been received", + S2_CASE("4.1.6", "Send BYE after INVITE has been received", "NUA receives INVITE, sends BYE at same time"); nh = invite_to_nua(TAG_END()); @@ -2303,7 +2303,7 @@ nua_handle_t *nh; struct message *bye, *r486; - s2_case("4.1.7", "Send BYE after INVITE has been received", + S2_CASE("4.1.7", "Send BYE after INVITE has been received", "NUA receives INVITE, sends BYE at same time"); nh = invite_to_nua(TAG_END()); @@ -2340,7 +2340,7 @@ nua_handle_t *nh; struct message *bye, *r486; - s2_case("4.1.8", "BYE followed by response to INVITE", + S2_CASE("4.1.8", "BYE followed by response to INVITE", "NUA receives INVITE, sends BYE at same time"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2380,7 +2380,7 @@ struct message *bye; struct event *i_bye; - s2_case("4.1.6", "Send BYE, receive BYE, destroy", + S2_CASE("4.1.6", "Send BYE, receive BYE, destroy", "NUA sends BYE, receives BYE and handle gets destroyed"); nh = invite_to_nua(TAG_END()); @@ -2424,7 +2424,7 @@ struct message *invite, *bye; struct event *i_bye; - s2_case("4.1.6", "Send auto-BYE upon receiving 501, receive BYE, destroy", + S2_CASE("4.1.6", "Send auto-BYE upon receiving 501, receive BYE, destroy", "NUA sends BYE, receives BYE and handle gets destroyed"); nh = invite_to_nua(TAG_END()); @@ -2475,7 +2475,7 @@ struct message *invite, *ack; struct event *i_bye; - s2_case("4.1.11", "Receive BYE in completing state", + S2_CASE("4.1.11", "Receive BYE in completing state", "NUA sends INVITE, receives 200, receives BYE."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2511,7 +2511,7 @@ nua_handle_t *nh; struct message *bye; - s2_case("4.2.1", "BYE in progress while call timer expires", + S2_CASE("4.2.1", "BYE in progress while call timer expires", "NUA receives INVITE, " "activates call timers, " "sends BYE, BYE challenged, " @@ -2555,7 +2555,7 @@ nua_handle_t *nh; struct message *bye; - s2_case("4.2.2", "BYE in progress while call timer expires", + S2_CASE("4.2.2", "BYE in progress while call timer expires", "NUA receives INVITE, " "activates call timers, " "sends BYE, BYE challenged, " @@ -2626,7 +2626,7 @@ nua_handle_t *nh; struct message *invite, *cancel; - s2_case("4.3.1", "Destroy handle after INVITE sent", + S2_CASE("4.3.1", "Destroy handle after INVITE sent", "NUA sends INVITE, handle gets destroyed."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2654,7 +2654,7 @@ nua_handle_t *nh; struct message *invite, *cancel; - s2_case("4.3.2", "Destroy handle in calling state", + S2_CASE("4.3.2", "Destroy handle in calling state", "NUA sends INVITE, receives 180, handle gets destroyed."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2682,7 +2682,7 @@ nua_handle_t *nh; struct message *invite, *ack, *bye; - s2_case("4.3.3", "Destroy handle in completing state", + S2_CASE("4.3.3", "Destroy handle in completing state", "NUA sends INVITE, receives 200, handle gets destroyed."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2718,7 +2718,7 @@ nua_handle_t *nh; struct message *invite, *ack, *bye; - s2_case("4.3.3", "Destroy handle in ready state ", + S2_CASE("4.3.3", "Destroy handle in ready state ", "NUA sends INVITE, receives 200, handle gets destroyed."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -2757,7 +2757,7 @@ nua_handle_t *nh; struct message *invite, *cancel; - s2_case("4.3.5", "Destroy handle in re-INVITE calling state", + S2_CASE("4.3.5", "Destroy handle in re-INVITE calling state", "NUA sends re-INVITE, handle gets destroyed."); nh = invite_to_nua(TAG_END()); @@ -2785,7 +2785,7 @@ nua_handle_t *nh; struct message *invite, *cancel; - s2_case("4.3.6", "Destroy handle in calling state of re-INVITE", + S2_CASE("4.3.6", "Destroy handle in calling state of re-INVITE", "NUA sends re-INVITE, receives 180, handle gets destroyed."); nh = invite_to_nua(TAG_END()); @@ -2814,7 +2814,7 @@ nua_handle_t *nh; struct message *invite, *ack, *bye; - s2_case("4.3.7", "Destroy handle in completing state of re-INVITE", + S2_CASE("4.3.7", "Destroy handle in completing state of re-INVITE", "NUA sends INVITE, receives 200, handle gets destroyed."); nh = invite_to_nua(TAG_END()); @@ -2850,7 +2850,7 @@ nua_handle_t *nh; struct message *invite, *ack, *bye; - s2_case("4.3.8", "Destroy handle after INVITE sent", + S2_CASE("4.3.8", "Destroy handle after INVITE sent", "NUA sends INVITE, handle gets destroyed, " "but remote end returns 200 OK. " "Make sure nua tries to release call properly."); @@ -2882,7 +2882,7 @@ nua_handle_t *nh; struct message *invite, *cancel, *ack, *bye; - s2_case("4.3.9", "Destroy handle in calling state", + S2_CASE("4.3.9", "Destroy handle in calling state", "NUA sends INVITE, receives 180, handle gets destroyed, " "but remote end returns 200 OK. " "Make sure nua tries to release call properly."); @@ -2923,7 +2923,7 @@ struct event *invite; struct message *response; - s2_case("4.4.1", "Destroy handle while call is on-going", + S2_CASE("4.4.1", "Destroy handle while call is on-going", "NUA is callee, sends 100, destroys handle"); soa_generate_offer(soa, 1, NULL); @@ -2958,7 +2958,7 @@ struct event *invite; struct message *response; - s2_case("4.4.1", "Destroy handle while call is on-going", + S2_CASE("4.4.1", "Destroy handle while call is on-going", "NUA is callee, sends 180, destroys handle"); soa_generate_offer(soa, 1, NULL); @@ -2999,7 +2999,7 @@ struct event *invite; struct message *response, *bye; - s2_case("4.4.3.1", "Destroy handle while call is on-going", + S2_CASE("4.4.3.1", "Destroy handle while call is on-going", "NUA is callee, sends 200, destroys handle"); soa_generate_offer(soa, 1, NULL); @@ -3053,7 +3053,7 @@ struct event *invite; struct message *response, *bye; - s2_case("4.4.3.1", "Destroy handle while call is on-going", + S2_CASE("4.4.3.1", "Destroy handle while call is on-going", "NUA is callee, sends 200, destroys handle"); soa_generate_offer(soa, 1, NULL); @@ -3139,7 +3139,7 @@ nua_handle_t *nh; struct message *response; - s2_case("5.1.1", "Test nua_respond() API", + S2_CASE("5.1.1", "Test nua_respond() API", "Test nua_respond() API with OPTIONS."); s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END()); @@ -3198,7 +3198,7 @@ pthread_t tid; void *thread_return = NULL; - s2_case("5.1.2", "Test nua_respond() API with another thread", + S2_CASE("5.1.2", "Test nua_respond() API with another thread", "Test multithreading nua_respond() API with OPTIONS."); nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END()); @@ -3262,7 +3262,7 @@ struct event *refer; struct message *notify; - s2_case("5.2.1", "Receive REFER", + S2_CASE("5.2.1", "Receive REFER", "Make a call, receive REFER."); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -3299,7 +3299,7 @@ struct message *notify0, *notify1, *notify2; struct dialog *dialog1, *dialog2; - s2_case("5.2.2", "Receive REFER", + S2_CASE("5.2.2", "Receive REFER", "Make a call, receive REFER, " "make another call with automatic NOTIFYs"); @@ -3395,7 +3395,7 @@ START_TEST(empty) { - s2_case("0.0.0", "Empty test case", + S2_CASE("0.0.0", "Empty test case", "Detailed explanation for empty test case."); tport_set_params(s2sip->master, TPTAG_LOG(1), TAG_END()); Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Tue Mar 24 10:34:23 2009 @@ -265,7 +265,7 @@ { nua_handle_t *nh; struct event *notify; - s2_case("6.1.1", "Basic subscription", + S2_CASE("6.1.1", "Basic subscription", "NUA sends SUBSCRIBE, waits for NOTIFY, sends un-SUBSCRIBE"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -283,7 +283,7 @@ struct message *subscribe, *response; struct event *notify, *event; - s2_case("6.1.2", "Basic subscription with refresh", + S2_CASE("6.1.2", "Basic subscription with refresh", "NUA sends SUBSCRIBE, waits for NOTIFY, " "sends re-SUBSCRIBE, waits for NOTIFY, " "sends un-SUBSCRIBE"); @@ -331,7 +331,7 @@ struct message *response; struct event *notify, *event; - s2_case("6.1.3", "Subscription terminated by notifier", + S2_CASE("6.1.3", "Subscription terminated by notifier", "NUA sends SUBSCRIBE, waits for NOTIFY, " "gets NOTIFY terminating the subscription,"); @@ -361,7 +361,7 @@ struct message *response; struct event *notify, *event; - s2_case("6.1.4", "Subscription terminated by notifier, re-established", + S2_CASE("6.1.4", "Subscription terminated by notifier, re-established", "NUA sends SUBSCRIBE, waits for NOTIFY, " "gets NOTIFY terminating the subscription,"); @@ -419,7 +419,7 @@ nua_handle_t *nh; struct event *notify; - s2_case("6.2.1", "Event fetch - NOTIFY after 202", + S2_CASE("6.2.1", "Event fetch - NOTIFY after 202", "NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -436,7 +436,7 @@ nua_handle_t *nh; struct event *notify; - s2_case("6.2.2", "Event fetch - NOTIFY before 200", + S2_CASE("6.2.2", "Event fetch - NOTIFY before 200", "NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY"); send_notify_before_response = 1; @@ -456,7 +456,7 @@ struct message *subscribe; struct event *event; - s2_case("6.2.3", "Event fetch - no NOTIFY", + S2_CASE("6.2.3", "Event fetch - no NOTIFY", "NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY, times out"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); @@ -539,7 +539,7 @@ struct message *notify, *response; sip_t *sip; - s2_case("6.3.1", "Basic NOTIFY server", + S2_CASE("6.3.1", "Basic NOTIFY server", "NUA receives SUBSCRIBE, sends 202 and NOTIFY. " "First NOTIFY terminates subscription. "); @@ -612,7 +612,7 @@ struct message *notify; sip_t *sip; - s2_case("6.3.2", "NOTIFY server - automatic subscription termination", + S2_CASE("6.3.2", "NOTIFY server - automatic subscription termination", "NUA receives SUBSCRIBE, sends 202 and NOTIFY. " "The subscription terminates with timeout. "); @@ -664,7 +664,7 @@ struct event *response; sip_t *sip; - s2_case("6.3.3", "NOTIFY server - terminate with error response to NOTIFY", + S2_CASE("6.3.3", "NOTIFY server - terminate with error response to NOTIFY", "NUA receives SUBSCRIBE, sends 202 and NOTIFY. " "The subscription terminates when watcher " "returns 481 to second NOTIFY."); @@ -709,7 +709,7 @@ struct event *response; sip_t *sip; - s2_case("6.3.4", "NOTIFY server - terminate with error response to NOTIFY", + S2_CASE("6.3.4", "NOTIFY server - terminate with error response to NOTIFY", "NUA receives SUBSCRIBE, sends 202 and NOTIFY. " "The subscription terminates when watcher " "returns 481 to second NOTIFY. The queued 3rd NOTIFY gets " @@ -778,7 +778,7 @@ START_TEST(empty) { - s2_case("0.0.0", "Empty test case", + S2_CASE("0.0.0", "Empty test case", "Detailed explanation for empty test case."); tport_set_params(s2sip->master, TPTAG_LOG(1), TAG_END()); From mikej at freeswitch.org Tue Mar 24 08:36:03 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:36:03 -0500 Subject: [Freeswitch-svn] [commit] r12736 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 24 10:36:03 2009 New Revision: 12736 Log: Thu Mar 5 13:06:15 CST 2009 Pekka Pessi * check_nta: use S2_CASE() Ignore-this: c94d4219b0882f1343bcfc56f975ea48 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:36:03 2009 @@ -1 +1 @@ -Tue Mar 24 10:33:24 CDT 2009 +Tue Mar 24 10:35:04 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/check_nta_client.c Tue Mar 24 10:36:03 2009 @@ -95,7 +95,7 @@ struct message *request; struct event *response; - s2_case("2.0.0", "Send MESSAGE", + S2_CASE("2.0.0", "Send MESSAGE", "Basic non-INVITE transaction with outbound proxy"); orq = nta_outgoing_tcreate(s2->default_leg, @@ -123,7 +123,7 @@ struct message *request; struct event *response; - s2_case("2.0.0", "Send MESSAGE", + S2_CASE("2.0.0", "Send MESSAGE", "Basic non-INVITE transaction with " "numeric per-transaction outbound proxy"); @@ -155,7 +155,7 @@ char payload[2048]; - s2_case("2.0.2", "Send MESSAGE", + S2_CASE("2.0.2", "Send MESSAGE", "Basic non-INVITE transaction exceeding " "default path MTU (1300 bytes)"); @@ -210,7 +210,7 @@ char payload[2048]; - s2_case("2.1.0", "Try UDP after trying with TCP", + S2_CASE("2.1.0", "Try UDP after trying with TCP", "TCP connect() is refused"); memset(payload, 'x', sizeof payload); @@ -279,7 +279,7 @@ char payload[2048]; - s2_case("2.1.1", "Try UDP after trying with TCP", + S2_CASE("2.1.1", "Try UDP after trying with TCP", "TCP connect() times out"); memset(payload, 'x', sizeof payload); @@ -337,7 +337,7 @@ struct event *response; url_t udpurl[1]; - s2_case("2.1.2", "Send MESSAGE", + S2_CASE("2.1.2", "Send MESSAGE", "Non-INVITE transaction to TCP-only server"); client_setup_tcp_only_server(); From mikej at freeswitch.org Tue Mar 24 08:37:01 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:37:01 -0500 Subject: [Freeswitch-svn] [commit] r12737 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/sresolv Message-ID: Author: mikej Date: Tue Mar 24 10:37:01 2009 New Revision: 12737 Log: Thu Mar 5 13:21:25 CST 2009 Pekka Pessi * check_sres_sip.c: use S2_CASE() Ignore-this: da194ea35fa98a73f3da3b4b5257aa8f Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:37:01 2009 @@ -1 +1 @@ -Tue Mar 24 10:35:04 CDT 2009 +Tue Mar 24 10:36:05 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c Tue Mar 24 10:37:01 2009 @@ -160,7 +160,7 @@ sres_sip_t *srs; #if 0 - s2_case("1.0", "Check invalid input values", + S2_CASE("1.0", "Check invalid input values", "Detailed explanation for empty test case."); #endif From mikej at freeswitch.org Tue Mar 24 08:37:43 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:37:43 -0500 Subject: [Freeswitch-svn] [commit] r12738 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 24 10:37:43 2009 New Revision: 12738 Log: Thu Mar 5 13:06:59 CST 2009 Pekka Pessi * run_test_nta: fixed bashism with exec Ignore-this: 6d034eb8fd66f6a903e3219589f62eef Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:37:43 2009 @@ -1 +1 @@ -Tue Mar 24 10:36:05 CDT 2009 +Tue Mar 24 10:36:48 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta Tue Mar 24 10:37:43 2009 @@ -188,7 +188,7 @@ # -g is also very nice option for named named -f -c $namedfile & pid=$! -while ! test -r $pidfile && kill -0 $! +while ! test -r $pidfile && kill -0 $! 2>/dev/null do sleep 1 done @@ -205,12 +205,10 @@ exit $exit else echo "$0: cannot start named (check apparmor/selinux)" - exec ipv6=$ipv6 $VALGRIND ./test_nta "$@" + ipv6=$ipv6 $VALGRIND exec ./test_nta "$@" fi else # not having BIND and portbind - -ipv6=$ipv6 $VALGRIND ./test_nta "$@" -exit $? + ipv6=$ipv6 $VALGRIND exec ./test_nta "$@" fi From mikej at freeswitch.org Tue Mar 24 08:38:33 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:38:33 -0500 Subject: [Freeswitch-svn] [commit] r12739 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 24 10:38:33 2009 New Revision: 12739 Log: Thu Mar 5 13:08:22 CST 2009 Pekka Pessi * nta.c: nta_leg_tag(leg, NULL) now always returns the tag (old or new) Ignore-this: f5a7d67ed90e2c284f6696d6b5b89326 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:38:33 2009 @@ -1 +1 @@ -Tue Mar 24 10:36:48 CDT 2009 +Tue Mar 24 10:37:37 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 24 10:38:33 2009 @@ -4391,7 +4391,7 @@ /* If there already is a tag, return NULL if it does not match with new one */ if (leg->leg_local->a_tag) { - if (su_casematch(tag, leg->leg_local->a_tag)) + if (tag == NULL || su_casematch(tag, leg->leg_local->a_tag)) return leg->leg_local->a_tag; else return NULL; From mikej at freeswitch.org Tue Mar 24 08:39:08 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:39:08 -0500 Subject: [Freeswitch-svn] [commit] r12740 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 24 10:39:08 2009 New Revision: 12740 Log: Thu Mar 5 13:09:53 CST 2009 Pekka Pessi * nta.c: #include here Ignore-this: bab8054edc65e3defbed6db325e1deba Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:39:08 2009 @@ -1 +1 @@ -Tue Mar 24 10:37:37 CDT 2009 +Tue Mar 24 10:38:12 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 24 10:39:08 2009 @@ -74,6 +74,7 @@ #include #include +#include /* Resolver context type */ #define SRES_CONTEXT_T nta_outgoing_t Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h Tue Mar 24 10:39:08 2009 @@ -47,7 +47,6 @@ #if HAVE_SOFIA_SRESOLV #include #endif -#include typedef struct nta_compressor nta_compressor_t; From mikej at freeswitch.org Tue Mar 24 08:40:31 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:40:31 -0500 Subject: [Freeswitch-svn] [commit] r12741 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 24 10:40:31 2009 New Revision: 12741 Log: Thu Mar 5 13:20:53 CST 2009 Pekka Pessi * s2util.h, s2time.c: added s2_timed_logger() Ignore-this: 504e7e5c1201b0b2d5c345c31d5d4b71 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2time.c freeswitch/trunk/libs/sofia-sip/s2check/s2util.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:40:31 2009 @@ -1 +1 @@ -Tue Mar 24 10:38:12 CDT 2009 +Tue Mar 24 10:39:35 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2time.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2time.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2time.c Tue Mar 24 10:40:31 2009 @@ -26,6 +26,9 @@ #include "s2util.h" +#include +#include + /* -- Delay scenarios --------------------------------------------------- */ static unsigned long time_offset; @@ -49,3 +52,23 @@ su_root_step(root, 0); } +void +s2_timed_logger(void *stream, char const *fmt, va_list ap) +{ + char buffer[4096]; + su_time_t now = su_now(); + size_t prefix, wrote; + int n; + + snprintf(buffer, sizeof buffer, + "%02u:%02u:%02u.%06lu[+%lu] ", + (unsigned)(now.tv_sec / 3600 % 24), + (unsigned)(now.tv_sec / 60 % 60), + (unsigned)(now.tv_sec % 60), + now.tv_usec, + time_offset); + prefix = strlen(buffer); + n = vsnprintf(buffer + prefix, (sizeof buffer) - prefix, fmt, ap); + if (n > 0) + wrote = fwrite(buffer, prefix + n, 1, stream); +} Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2util.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2util.h (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2util.h Tue Mar 24 10:40:31 2009 @@ -34,10 +34,12 @@ */ #include +#include SOFIA_BEGIN_DECLS void s2_fast_forward(unsigned long seconds, su_root_t *root); +void s2_timed_logger(void *stream, char const *fmt, va_list ap); SOFIA_END_DECLS From mikej at freeswitch.org Tue Mar 24 08:41:03 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:41:03 -0500 Subject: [Freeswitch-svn] [commit] r12742 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua Message-ID: Author: mikej Date: Tue Mar 24 10:41:03 2009 New Revision: 12742 Log: Mon Mar 9 12:32:13 CDT 2009 Pekka Pessi * nua: added nua_i_none to nua_event_name() Ignore-this: 5d262decadfc28b82ab7292330e20530 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:41:03 2009 @@ -1 +1 @@ -Tue Mar 24 10:39:35 CDT 2009 +Tue Mar 24 10:40:08 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c Tue Mar 24 10:41:03 2009 @@ -309,6 +309,8 @@ char const *nua_event_name(nua_event_t event) { switch (event) { + case nua_i_none: return "nua_i_none"; + case nua_i_error: return "nua_i_error"; case nua_i_invite: return "nua_i_invite"; case nua_i_cancel: return "nua_i_cancel"; From mikej at freeswitch.org Tue Mar 24 08:41:38 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:41:38 -0500 Subject: [Freeswitch-svn] [commit] r12743 - in freeswitch/trunk/libs/sofia-sip: . tests Message-ID: Author: mikej Date: Tue Mar 24 10:41:38 2009 New Revision: 12743 Log: Mon Mar 9 12:42:00 CDT 2009 Pekka Pessi * test_nua_api.c: nua_i_none is no more unknown Ignore-this: b7232be3e3956337161266c1814ddd37 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/tests/test_nua_api.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:41:38 2009 @@ -1 +1 @@ -Tue Mar 24 10:40:08 CDT 2009 +Tue Mar 24 10:40:43 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/tests/test_nua_api.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/tests/test_nua_api.c (original) +++ freeswitch/trunk/libs/sofia-sip/tests/test_nua_api.c Tue Mar 24 10:41:38 2009 @@ -94,7 +94,7 @@ TEST_1(!nua_handle_has_registrations(NULL)); TEST_1(!nua_handle_remote(NULL)); TEST_1(!nua_handle_local(NULL)); - TEST_S(nua_event_name(-1), "NUA_UNKNOWN"); + TEST_S(nua_event_name(-111), "NUA_UNKNOWN"); TEST_VOID(nua_register(NULL, TAG_END())); TEST_VOID(nua_unregister(NULL, TAG_END())); TEST_VOID(nua_invite(NULL, TAG_END())); From mikej at freeswitch.org Tue Mar 24 08:42:16 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:42:16 -0500 Subject: [Freeswitch-svn] [commit] r12744 - in freeswitch/trunk/libs/sofia-sip: . packages Message-ID: Author: mikej Date: Tue Mar 24 10:42:16 2009 New Revision: 12744 Log: Mon Mar 9 12:42:48 CDT 2009 Pekka Pessi * packages/sofia-sip-ua.pc.in: silenced warning from configure Ignore-this: dcf6a0fed627e267f5128af5508bcb8f Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/packages/sofia-sip-ua.pc.in Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:42:16 2009 @@ -1 +1 @@ -Tue Mar 24 10:40:43 CDT 2009 +Tue Mar 24 10:41:20 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/packages/sofia-sip-ua.pc.in ============================================================================== --- freeswitch/trunk/libs/sofia-sip/packages/sofia-sip-ua.pc.in (original) +++ freeswitch/trunk/libs/sofia-sip/packages/sofia-sip-ua.pc.in Tue Mar 24 10:42:16 2009 @@ -4,6 +4,7 @@ libexecdir=@libexecdir@ includedir=@includedir@ include_sofiadir=@include_sofiadir@ +datarootdir=@datarootdir@ sofiaawkdir=@datadir@/@PACKAGE@ Name: sofia-sip-ua From mikej at freeswitch.org Tue Mar 24 08:42:54 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:42:54 -0500 Subject: [Freeswitch-svn] [commit] r12745 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su Message-ID: Author: mikej Date: Tue Mar 24 10:42:53 2009 New Revision: 12745 Log: Mon Mar 9 12:44:03 CDT 2009 Pekka Pessi * su_alloc: shorten race on _su_deinit() Ignore-this: 6d4e6edb434a96e66c9bb018a201a3c6 Make home object unusable earlier during denitialization. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:42:53 2009 @@ -1 +1 @@ -Tue Mar 24 10:41:20 CDT 2009 +Tue Mar 24 10:41:57 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c Tue Mar 24 10:42:53 2009 @@ -993,6 +993,9 @@ if (home->suh_blocks) { size_t i; su_block_t *b; + void *suh_lock = home->suh_lock; + + home->suh_lock = NULL; if (home->suh_blocks->sub_destructor) { void (*destructor)(void *) = home->suh_blocks->sub_destructor; @@ -1034,11 +1037,7 @@ home->suh_blocks = NULL; - if (home->suh_lock) { - void *suh_lock = home->suh_lock; - - home->suh_lock = NULL; - + if (suh_lock) { /* Unlock, or risk assert() or leak handles on Windows */ _su_home_unlocker(suh_lock); _su_home_destroy_mutexes(suh_lock); From mikej at freeswitch.org Tue Mar 24 08:43:28 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:43:28 -0500 Subject: [Freeswitch-svn] [commit] r12746 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 24 10:43:28 2009 New Revision: 12746 Log: Wed Mar 11 09:49:37 CDT 2009 Pekka Pessi * s2base.c: use struct timeval with gettimeofday() Ignore-this: 1ca4ea3c958573a1fa845d8b66b7d6ad Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/s2base.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:43:28 2009 @@ -1 +1 @@ -Tue Mar 24 10:41:57 CDT 2009 +Tue Mar 24 10:42:34 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2base.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/s2base.c (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/s2base.c Tue Mar 24 10:43:28 2009 @@ -74,7 +74,7 @@ static double now(void) { - struct timespec tv; + struct timeval tv; gettimeofday(&tv, NULL); From mikej at freeswitch.org Tue Mar 24 08:44:04 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:44:04 -0500 Subject: [Freeswitch-svn] [commit] r12747 - in freeswitch/trunk/libs/sofia-sip: . s2check Message-ID: Author: mikej Date: Tue Mar 24 10:44:04 2009 New Revision: 12747 Log: Wed Mar 11 09:50:20 CDT 2009 Pekka Pessi * s2check: added exit77.c to EXTRA_DIST Ignore-this: ae3403c0bd1b4596c24bc7304916fa85 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:44:04 2009 @@ -1 +1 @@ -Tue Mar 24 10:42:34 CDT 2009 +Tue Mar 24 10:43:08 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/s2check/Makefile.am Tue Mar 24 10:44:04 2009 @@ -28,7 +28,7 @@ # ---------------------------------------------------------------------- # Install and distribution rules -EXTRA_DIST = +EXTRA_DIST = exit77.c # ---------------------------------------------------------------------- # Tests From mikej at freeswitch.org Tue Mar 24 08:44:33 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:44:33 -0500 Subject: [Freeswitch-svn] [commit] r12748 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su/sofia-sip Message-ID: Author: mikej Date: Tue Mar 24 10:44:33 2009 New Revision: 12748 Log: Wed Mar 11 11:58:14 CDT 2009 Pekka Pessi * sofia-sip/su_config.h: include extern in SOFIAPUBVAR Ignore-this: 7cccd45776e8452a8e404aaf01eaeadf Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_config.h Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:44:33 2009 @@ -1 +1 @@ -Tue Mar 24 10:43:08 CDT 2009 +Tue Mar 24 10:43:39 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_config.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_config.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_config.h Tue Mar 24 10:44:33 2009 @@ -84,7 +84,7 @@ #undef SOFIAPUBVAR #if defined(IN_LIBSOFIA_SIP_UA) #define SOFIAPUBFUN __declspec(dllexport) - #define SOFIAPUBVAR __declspec(dllexport) + #define SOFIAPUBVAR __declspec(dllexport) extern #else #define SOFIAPUBFUN __declspec(dllimport) #define SOFIAPUBVAR __declspec(dllimport) extern @@ -104,7 +104,7 @@ #undef SOFIAPUBVAR #if defined(IN_LIBSOFIA_SIP_UA) #define SOFIAPUBFUN __declspec(dllexport) - #define SOFIAPUBVAR __declspec(dllexport) extern + #define SOFIAPUBVAR __declspec(dllexport) extern #else #define SOFIAPUBFUN __declspec(dllimport) #define SOFIAPUBVAR __declspec(dllimport) From mikej at freeswitch.org Tue Mar 24 08:45:13 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:45:13 -0500 Subject: [Freeswitch-svn] [commit] r12749 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/msg Message-ID: Author: mikej Date: Tue Mar 24 10:45:13 2009 New Revision: 12749 Log: Wed Mar 11 11:50:44 CDT 2009 Pekka Pessi * msg_mime.c: explicit cast when assigning to mp_len Ignore-this: ca5b8291eb84d8b166ab7f659bcf69f8 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:45:13 2009 @@ -1 +1 @@ -Tue Mar 24 10:43:39 CDT 2009 +Tue Mar 24 10:44:15 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c Tue Mar 24 10:45:13 2009 @@ -513,7 +513,7 @@ for (mp = all; mp; mp = mp->mp_next) { mp->mp_data = boundary; - mp->mp_len = blen; + mp->mp_len = (unsigned)blen; /* XXX */ assert(mp->mp_payload || mp->mp_separator); @@ -613,7 +613,8 @@ for (; mp; mp = mp->mp_next) { if (mp->mp_data == NULL) { - mp->mp_data = boundary, mp->mp_len = blen; + mp->mp_data = boundary; + mp->mp_len = (unsigned)blen; /* XXX */ } else { if (mp->mp_len < 3) return -1; From mikej at freeswitch.org Tue Mar 24 08:45:45 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:45:45 -0500 Subject: [Freeswitch-svn] [commit] r12750 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/sresolv Message-ID: Author: mikej Date: Tue Mar 24 10:45:45 2009 New Revision: 12750 Log: Wed Mar 11 11:51:43 CDT 2009 Pekka Pessi * sres_sip.c: silence VC warnings Ignore-this: dd9d4b774716430cdf429ed86664b109 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:45:45 2009 @@ -1 +1 @@ -Tue Mar 24 10:44:15 CDT 2009 +Tue Mar 24 10:44:50 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c Tue Mar 24 10:45:45 2009 @@ -1440,8 +1440,8 @@ memset(ai, 0, (sizeof ai)); ai->ai_protocol = stp->stp_number; - ai->ai_addr = memset(su, 0, (sizeof su->su_sin6)); - su->su_len = ai->ai_addrlen = (sizeof su->su_sin6); + ai->ai_addr = memset(su, 0, ai->ai_addrlen = (sizeof su->su_sin6)); + su->su_len = (sizeof su->su_sin6); su->su_family = ai->ai_family = AF_INET6; su->su_port = htons(step->sp_port); @@ -1477,8 +1477,8 @@ memset(ai, 0, (sizeof ai)); ai->ai_protocol = stp->stp_number; - ai->ai_addr = memset(su, 0, (sizeof su->su_sin)); - su->su_len = ai->ai_addrlen = (sizeof su->su_sin); + ai->ai_addr = memset(su, 0, ai->ai_addrlen = (sizeof su->su_sin)); + su->su_len = (sizeof su->su_sin); su->su_family = ai->ai_family = AF_INET; su->su_port = htons(step->sp_port); @@ -1541,8 +1541,8 @@ memset(ai, 0, (sizeof ai)); (void)buffer; if (host_is_ip4_address(target)) { - ai->ai_addr = memset(su, 0, (sizeof su->su_sin)); - su->su_len = ai->ai_addrlen = (sizeof su->su_sin); + ai->ai_addr = memset(su, 0, ai->ai_addrlen = (sizeof su->su_sin)); + su->su_len = (sizeof su->su_sin); if (su_inet_pton(su->su_family = ai->ai_family = AF_INET, target, &su->su_sin.sin_addr) <= 0) { srs->srs_error = SRES_SIP_ERR_BAD_URI; @@ -1551,8 +1551,8 @@ } #if SU_HAVE_IN6 else if (host_is_ip6_address(target)) { - ai->ai_addr = memset(su, 0, (sizeof su->su_sin6)); - su->su_len = ai->ai_addrlen = (sizeof su->su_sin6); + ai->ai_addr = memset(su, 0, ai->ai_addrlen = (sizeof su->su_sin6)); + su->su_len = (sizeof su->su_sin6); if (su_inet_pton(su->su_family = ai->ai_family = AF_INET6, target, &su->su_sin6.sin6_addr) <= 0) { srs->srs_error = SRES_SIP_ERR_BAD_URI; @@ -1562,8 +1562,8 @@ else if (host_is_ip6_reference(target)) { size_t len = strlen(target) - 2; - ai->ai_addr = memset(su, 0, (sizeof su->su_sin6)); - su->su_len = ai->ai_addrlen = (sizeof su->su_sin6); + ai->ai_addr = memset(su, 0, ai->ai_addrlen = (sizeof su->su_sin6)); + su->su_len = (sizeof su->su_sin6); if (len >= sizeof buffer || !memcpy(buffer, target + 1, len) || From mikej at freeswitch.org Tue Mar 24 08:46:13 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:46:13 -0500 Subject: [Freeswitch-svn] [commit] r12751 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/tport Message-ID: Author: mikej Date: Tue Mar 24 10:46:13 2009 New Revision: 12751 Log: Wed Mar 11 11:52:58 CDT 2009 Pekka Pessi * tport.c: silence VC warnings Ignore-this: b81c43b73fcefa2dd58dd3366dd60368 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:46:13 2009 @@ -1 +1 @@ -Tue Mar 24 10:44:50 CDT 2009 +Tue Mar 24 10:45:18 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c Tue Mar 24 10:46:13 2009 @@ -3078,7 +3078,7 @@ int tport_subject_search(char const *subject, su_strlst_t const *lst) { - int idx, ilen; + usize_t idx, ilen; const char *subjuri; if (!subject || su_strmatch(tpn_any, subject)) From mikej at freeswitch.org Tue Mar 24 08:46:59 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:46:59 -0500 Subject: [Freeswitch-svn] [commit] r12752 - in freeswitch/trunk/libs/sofia-sip: . tests Message-ID: Author: mikej Date: Tue Mar 24 10:46:59 2009 New Revision: 12752 Log: Mon Mar 23 10:41:08 CDT 2009 Pekka Pessi * tests: added check_dlopen_sofia.c Ignore-this: 1f3a1a6dc3e9099c6488a637e5f06e9a Added: freeswitch/trunk/libs/sofia-sip/tests/check_dlopen_sofia.c Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/tests/Makefile.am Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:46:59 2009 @@ -1 +1 @@ -Tue Mar 24 10:45:18 CDT 2009 +Tue Mar 24 10:46:04 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/tests/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/tests/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/tests/Makefile.am Tue Mar 24 10:46:59 2009 @@ -33,8 +33,8 @@ libtestnat_a_SOURCES = test_nat.h test_nat.c test_nat_tags.c if HAVE_CHECK -TESTS += check_sofia -check_PROGRAMS += check_sofia +TESTS += check_dlopen_sofia check_sofia +check_PROGRAMS += check_dlopen_sofia check_sofia endif check_sofia_CFLAGS = @CHECK_CFLAGS@ @@ -46,6 +46,9 @@ ${sofiabuilddir}/libsofia-sip-ua.la \ @CHECK_LIBS@ +check_dlopen_sofia_CFLAGS = -I$(top_srcdir)/s2check @CHECK_CFLAGS@ +check_dlopen_sofia_LDADD = ${top_builddir}/s2check/libs2.a @CHECK_LIBS@ + CLEANFILES = tmp_sippasswd.?????? # ---------------------------------------------------------------------- Added: freeswitch/trunk/libs/sofia-sip/tests/check_dlopen_sofia.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/tests/check_dlopen_sofia.c Tue Mar 24 10:46:59 2009 @@ -0,0 +1,124 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2009 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE check_dlopen_sofia.c + * + * @brief Check dlopen()ing and dlclose() with libsofia-sip-ua + * + * @author Pekka Pessi + * + * @copyright (C) 2009 Nokia Corporation. + */ + +#include "config.h" + +#include +#include +#include + +#include + +#if HAVE_CHECK && HAVE_LIBDL + +#include +#include + +#include +#include + +static uint64_t (*su_random64)(void); + +START_TEST(load_su_uniqueid) +{ + void *sofia; + uint64_t rnd; + + sofia = dlopen("../libsofia-sip-ua/.libs/libsofia-sip-ua.so", RTLD_NOW); + su_random64 = dlsym(sofia, "su_random64"); + fail_unless(su_random64 != NULL); + rnd = su_random64(); + fail_unless(sofia != NULL); + fail_unless(dlclose(sofia) == 0); +} +END_TEST + +TCase *dl_tcase(void) +{ + TCase *tc = tcase_create("1 - dlopen/dlclose"); + + tcase_add_test(tc, load_su_uniqueid); + + return tc; +} + +/* ---------------------------------------------------------------------- */ + +static void usage(int exitcode) +{ + fprintf(exitcode ? stderr : stdout, + "usage: check_dlopen_sofia [--xml=logfile] case,...\n"); + exit(exitcode); +} + +int main(int argc, char *argv[]) +{ + int i, failed = 0; + + Suite *suite = suite_create("dlopen()ing and dlclose() with libsofia-sip-ua"); + SRunner *runner; + char const *xml = NULL; + + s2_select_tests(getenv("CHECK_CASES")); + + for (i = 1; argv[i]; i++) { + if (strncmp(argv[i], "--xml=", strlen("--xml=")) == 0) { + xml = argv[i] + strlen("--xml="); + } + else if (strcmp(argv[i], "--xml") == 0) { + if (!(xml = argv[++i])) + usage(2); + } + else if (strcmp(argv[i], "-?") == 0 || + strcmp(argv[i], "-h") == 0 || + strcmp(argv[i], "--help") == 0) + usage(0); + else + s2_select_tests(argv[i]); + } + + suite_add_tcase(suite, dl_tcase()); + + runner = srunner_create(suite); + if (xml) + srunner_set_xml(runner, xml); + srunner_run_all(runner, CK_ENV); + failed = srunner_ntests_failed(runner); + srunner_free(runner); + + exit(failed ? EXIT_FAILURE : EXIT_SUCCESS); +} + +#else +int main(void) { return 77; } +#endif From mikej at freeswitch.org Tue Mar 24 08:47:43 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:47:43 -0500 Subject: [Freeswitch-svn] [commit] r12753 - freeswitch/trunk/libs/sofia-sip Message-ID: Author: mikej Date: Tue Mar 24 10:47:43 2009 New Revision: 12753 Log: Mon Mar 23 10:41:29 CDT 2009 Pekka Pessi * configure.ac: check for dlopen in -ldl Ignore-this: e1fa8a4bf30eb9023e54264dbe8c42bd Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/configure.ac Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:47:43 2009 @@ -1 +1 @@ -Tue Mar 24 10:46:04 CDT 2009 +Tue Mar 24 10:46:45 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/configure.ac ============================================================================== --- freeswitch/trunk/libs/sofia-sip/configure.ac (original) +++ freeswitch/trunk/libs/sofia-sip/configure.ac Tue Mar 24 10:47:43 2009 @@ -110,6 +110,12 @@ fi AC_CHECK_HEADERS([fnmatch.h]) +dnl dl is currently used only in testing +AC_CHECK_LIB([dl], [dlopen], [ + dnl Note: -ldl is not added to LIBS + AC_DEFINE([HAVE_LIBDL], 1, [Define to 1 if dl library is available]) +]) + ### internal modules ### ---------------- AC_DEFINE([HAVE_SOFIA_SIP], 1, [Define to 1 always]) From mikej at freeswitch.org Tue Mar 24 08:48:19 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:48:19 -0500 Subject: [Freeswitch-svn] [commit] r12754 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta Message-ID: Author: mikej Date: Tue Mar 24 10:48:19 2009 New Revision: 12754 Log: Mon Mar 23 12:22:50 CDT 2009 Pekka Pessi * nta.c: use random key when generating tags Ignore-this: 3e989f42549acbdbc259383b1b64e74d Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:48:19 2009 @@ -1 +1 @@ -Tue Mar 24 10:46:45 CDT 2009 +Tue Mar 24 10:47:23 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 24 10:48:19 2009 @@ -1175,10 +1175,9 @@ static int agent_tag_init(nta_agent_t *self) { sip_contact_t *m = self->sa_contact; - uint32_t hash = 1; + uint32_t hash = su_random(); if (m) { - if (m->m_url->url_user) hash = 914715421U * hash + msg_hash_string(m->m_url->url_user); if (m->m_url->url_host) @@ -1192,7 +1191,7 @@ if (hash == 0) hash = 914715421U; - self->sa_branch = NTA_BRANCH_PRIME * su_ntp_now(); + self->sa_branch = NTA_BRANCH_PRIME * (uint64_t)su_nanotime(NULL); self->sa_branch *= hash; self->sa_tags = NTA_TAG_PRIME * self->sa_branch; @@ -2505,6 +2504,8 @@ if (!self->sa_contact) return -1; + agent_tag_init(self); + return 0; } From mikej at freeswitch.org Tue Mar 24 08:49:04 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:49:04 -0500 Subject: [Freeswitch-svn] [commit] r12755 - freeswitch/trunk/libs/sofia-sip Message-ID: Author: mikej Date: Tue Mar 24 10:49:03 2009 New Revision: 12755 Log: Mon Mar 23 12:27:27 CDT 2009 Pekka Pessi * RELEASE: urandom is no more public Ignore-this: 353234331d627b77c66841036c9d77f7 Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/RELEASE Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:49:03 2009 @@ -1 +1 @@ -Tue Mar 24 10:47:23 CDT 2009 +Tue Mar 24 10:48:07 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/RELEASE ============================================================================== --- freeswitch/trunk/libs/sofia-sip/RELEASE (original) +++ freeswitch/trunk/libs/sofia-sip/RELEASE Tue Mar 24 10:49:03 2009 @@ -51,7 +51,7 @@ - t_skip_next(), t_skip_move(), t_skip_len(), t_skip_dup(), t_skip_filter() - t_next_next(), t_next_move(), t_next_len(), t_next_dup(), t_next_filter() - t_filter_with(), t_any_filter() - - sres_record_class() + - sres_record_class(), urandom - u2s_alloc() libsofia-sip-ua-glib: From mikej at freeswitch.org Tue Mar 24 08:54:18 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 10:54:18 -0500 Subject: [Freeswitch-svn] [commit] r12756 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su Message-ID: Author: mikej Date: Tue Mar 24 10:54:18 2009 New Revision: 12756 Log: Tue Mar 3 12:23:35 CST 2009 Della Betta Filippo * su_uniqueid.c: srand() must be called per-thread on windows Ignore-this: ee98b86faadc4a39186ba4991b073c40 Mon Mar 23 12:41:53 CDT 2009 Pekka Pessi * su_uniqueid.c: simple threadsafe implementation Ignore-this: b3597fb6032b79a61b63f004f121188b Using /dev/urandom where available, simple 64-bit prng elsewhere. Modified: freeswitch/trunk/libs/sofia-sip/.update freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Modified: freeswitch/trunk/libs/sofia-sip/.update ============================================================================== --- freeswitch/trunk/libs/sofia-sip/.update (original) +++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 24 10:54:18 2009 @@ -1 +1 @@ -Tue Mar 24 10:48:07 CDT 2009 +Tue Mar 24 10:52:57 CDT 2009 Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Tue Mar 24 10:54:18 2009 @@ -74,116 +74,133 @@ #include "sofia-sip/su_uniqueid.h" /* For random number generator */ -static int initialized = 0; +static FILE *urandom; -static void init(void); -static void init_node(void); +union state { + uint64_t u64; +}; -/* Constants */ -static const unsigned version = 1; /* Current version */ -static const unsigned reserved = 128; /* DCE variant */ -#define granularity (10000000UL) -static const uint64_t mask60 = SU_U64_C(0xfffFFFFffffFFFF); -#define MAGIC (16384) +#if SU_HAVE_PTHREADS -/* 100-nanosecond intervals between 15 October 1582 and 1 January 1900 */ -static const uint64_t ntp_epoch = -(uint64_t)(141427) * (24 * 60 * 60L) * granularity; - -/* State */ -static uint64_t timestamp0 = 0; -static unsigned clock_sequence = MAGIC; -static unsigned char node[6]; +#include -FILE *urandom; +static pthread_once_t once = PTHREAD_ONCE_INIT; +static int done_once = 1; +static pthread_key_t state_key; -/* - * Get current timestamp - */ -static uint64_t timestamp(void) +static void +init_once(void) { - uint64_t tl = su_ntp_now(); - uint64_t hi = su_ntp_hi(tl), lo = su_ntp_lo(tl); + pthread_key_create(&state_key, free); +#if HAVE_DEV_URANDOM + urandom = fopen("/dev/urandom", "rb"); +#endif /* HAVE_DEV_URANDOM */ + done_once = 1; +} - lo *= granularity; - hi *= granularity; +#else +static int initialized; +#endif - tl = hi + (lo >> 32) + ntp_epoch; +static union state * +get_state(void) +{ + static union state *retval, state0[1]; -#ifdef TESTING - printf("timestamp %08x-%08x\n", (unsigned)(tl >>32), (unsigned)tl); -#endif +#if SU_HAVE_PTHREADS - tl &= mask60; + pthread_once(&once, init_once); - if (tl <= timestamp0) - clock_sequence = (clock_sequence + 1) & (MAGIC - 1); + if (urandom) + return NULL; - timestamp0 = tl; + retval = pthread_getspecific(state_key); + if (retval) { + return retval; + } - return tl; -} + retval = calloc(1, sizeof *retval); + if (retval != NULL) + pthread_setspecific(state_key, retval); + else + retval = state0; -#if !HAVE_RANDOM -#define random() rand() -#define srandom(x) srand(x) -#endif +#else /* !SU_HAVE_PTHREADS */ -/* - * Initialize clock_sequence and timestamp0 - */ -static void init(void) -{ - int i; + if (urandom == NULL) { +#if HAVE_DEV_URANDOM + urandom = fopen("/dev/urandom", "rb"); +#endif /* HAVE_DEV_URANDOM */ + } -#define N_SEED 32 + if (urandom) + return NULL; -#if HAVE_INITSTATE - /* Allow libsofia-sip-ua.so to unload. */ - uint32_t *seed = calloc(N_SEED, sizeof *seed); -#else - static uint32_t _seed[N_SEED] = { 0 }; - uint32_t *seed = _seed; + retval = state0; + + if (initialized) + return retval; #endif - su_time_t now; - initialized = 1; + { + uint32_t seed[32]; + int i; + union { + uint32_t u32; + pthread_t tid; + } tid32 = { 0 }; - /* Initialize our random number generator */ -#if HAVE_DEV_URANDOM - if (!urandom) - urandom = fopen("/dev/urandom", "rb"); -#endif /* HAVE_DEV_URANDOM */ + tid32.tid = pthread_self(); - if (urandom) { - size_t len = fread(seed, sizeof *seed, N_SEED, urandom); (void)len; - } - else { - for (i = 0; i < N_SEED; i += 2) { + memset(seed, 0, sizeof seed); /* Make valgrind happy */ + + for (i = 0; i < 32; i += 2) { #if HAVE_CLOCK_GETTIME struct timespec ts; (void)clock_gettime(CLOCK_REALTIME, &ts); seed[i] ^= ts.tv_sec; seed[i + 1] ^= ts.tv_nsec; -#endif +#else + su_time_t now; su_time(&now); seed[i] ^= now.tv_sec; seed[i + 1] ^= now.tv_sec; +#endif } seed[0] ^= getuid(); seed[1] ^= getpid(); + seed[2] ^= tid32.u32; + seed[3] ^= (uint32_t)(intptr_t)retval; + + for (i = 0; i < 32; i+= 4) { + retval->u64 += ((uint64_t)seed[i] << 32) | seed[i + 1]; + retval->u64 *= ((uint64_t)seed[i + 3] << 32) | seed[i + 2]; + } + + retval->u64 += (uint64_t)su_nanotime(NULL); } -#if HAVE_INITSTATE - initstate(seed[0] ^ seed[1], (void *)seed, N_SEED * (sizeof *seed)); -#else - srand(seed[0] ^ seed[1]); -#endif + return retval; +} - clock_sequence = su_randint(0, MAGIC - 1); +#if !defined(WIN32) && !defined(WIN64) +void sofia_su_uniqueid_destructor(void) + __attribute__((destructor)); +#endif - (void)timestamp(); +void +sofia_su_uniqueid_destructor(void) +{ +#if HAVE_DEV_URANDOM + if (urandom) + fclose(urandom); +#endif /* HAVE_DEV_URANDOM */ - init_node(); +#if SU_HAVE_PTHREADS + if (done_once) { + pthread_key_delete(state_key); + done_once = 0; + } +#endif } #if HAVE_GETIFADDRS @@ -196,10 +213,8 @@ #endif static -void init_node(void) +void init_node(uint8_t node[6]) { - size_t i; - #if HAVE_GETIFADDRS && HAVE_SOCKADDR_LL struct ifaddrs *ifa, *results; @@ -232,24 +247,18 @@ } #endif - if (urandom) { - size_t len = fread(node, sizeof node, 1, urandom); (void)len; - } - else for (i = 0; i < sizeof(node); i++) { - unsigned r = random(); - node[i] = (r >> 24) ^ (r >> 16) ^ (r >> 8) ^ r; - } - + su_randmem(node, 6); node[0] |= 1; /* "multicast" address */ } +static unsigned char node[6]; + size_t su_node_identifier(void *address, size_t addrlen) { if (addrlen > sizeof node) addrlen = sizeof node; - if (!initialized) init(); - + su_guid_generate(NULL); memcpy(address, node, addrlen); return addrlen; @@ -257,21 +266,66 @@ void su_guid_generate(su_guid_t *v) { - uint64_t time; - unsigned clock; + /* Constants */ + static const unsigned version = 1; /* Current version */ + static const unsigned reserved = 128; /* DCE variant */ +#define granularity (10000000UL) + static const uint64_t mask60 = SU_U64_C(0xfffFFFFffffFFFF); +#define MAGIC (16384) + + /* 100-nanosecond intervals between 15 October 1582 and 1 January 1900 */ + static const uint64_t ntp_epoch = + (uint64_t)(141427) * (24 * 60 * 60L) * granularity; + + static uint64_t timestamp0 = 0; + static unsigned clock_sequence = MAGIC; + +#if SU_HAVE_PTHREADS + static pthread_mutex_t update = PTHREAD_MUTEX_INITIALIZER; +#endif + + uint64_t tl = su_ntp_now(); + uint64_t hi = su_ntp_hi(tl), lo = su_ntp_lo(tl); + + lo *= granularity; + hi *= granularity; - if (!initialized) init(); + tl = hi + (lo >> 32) + ntp_epoch; + +#ifdef TESTING + printf("timestamp %08x-%08x\n", (unsigned)(tl >>32), (unsigned)tl); +#endif + + tl &= mask60; + if (tl == 0) tl++; + +#if SU_HAVE_PTHREADS + pthread_mutex_lock(&update); +#endif + + if (timestamp0 == 0) { + clock_sequence = su_randint(0, MAGIC - 1); + init_node(node); + } + else if (tl <= timestamp0) { + clock_sequence = (clock_sequence + 1) & (MAGIC - 1); + } + + timestamp0 = tl; - time = timestamp(); - clock = clock_sequence; +#if SU_HAVE_PTHREADS + pthread_mutex_unlock(&update); +#endif - v->s.time_high_and_version = - htons((unsigned short)(((time >> 48) & 0x0fff) | (version << 12))); - v->s.time_mid = htons((unsigned short)((time >> 32) & 0xffff)); - v->s.time_low = htonl((unsigned long)(time & 0xffffffffUL)); - v->s.clock_seq_low = clock & 0xff; - v->s.clock_seq_hi_and_reserved = (clock >> 8) | reserved; - memcpy(v->s.node, node, sizeof(v->s.node)); + if (v) { + v->s.time_high_and_version = + htons((unsigned short)(((tl >> 48) & 0x0fff) | (version << 12))); + v->s.time_mid = htons((unsigned short)((tl >> 32) & 0xffff)); + v->s.time_low = htonl((unsigned long)(tl & 0xffffffffUL)); + v->s.clock_seq_low = clock_sequence & 0xff; + v->s.clock_seq_hi_and_reserved = (clock_sequence >> 8) | reserved; + memcpy(v->s.node, node, sizeof(v->s.node)); + } } /* @@ -292,58 +346,73 @@ return su_guid_strlen; } -/* - * Generate random integer in range [lb, ub] (inclusive) - */ -int su_randint(int lb, int ub) +uint64_t su_random64(void) { - unsigned rnd = 0; + union state *state = get_state(); - if (!initialized) init(); - - if (urandom) { - size_t len = fread(&rnd, 1, sizeof rnd, urandom); (void)len; + if (state) { + /* Simple rand64 from AoCP */ + return state->u64 = state->u64 * 0X5851F42D4C957F2DULL + 1ULL; + } + else { + uint64_t retval; + size_t len = fread(&retval, 1, sizeof retval, urandom); (void)len; + return retval; } - else - rnd = random(); - - if (ub - lb + 1 != 0) - rnd %= (ub - lb + 1); - - return rnd + lb; } void *su_randmem(void *mem, size_t siz) { - size_t i; + union state *state = get_state(); - if (!initialized) init(); - - if (urandom) { - size_t len = fread(mem, 1, siz, urandom); (void)len; + if (state) { + size_t i; + uint64_t r64; + uint32_t r32; + + for (i = 0; i < siz; i += 4) { + /* Simple rand64 from AoCP */ + state->u64 = r64 = state->u64 * 0X5851F42D4C957F2DULL + 1ULL; + r32 = (uint32_t) (r64 >> 32) ^ (uint32_t)r64; + if (siz - i >= 4) + memcpy((char *)mem + i, &r32, 4); + else + memcpy((char *)mem + i, &r32, siz - i); + } } - else for (i = 0; i < siz; i++) { - unsigned r = random(); - ((char *)mem)[i] = (r >> 24) ^ (r >> 16) ^ (r >> 8) ^ r; + else { + size_t len = fread(mem, 1, siz, urandom); (void)len; } return mem; } -/** Get random number for RTP timestamps. - * - * This function returns a 32-bit random integer. It also initializes the - * random number generator, if needed. +/** + * Generate random integer in range [lb, ub] (inclusive) */ -uint32_t su_random(void) +int su_randint(int lb, int ub) { - if (!initialized) init(); + uint64_t rnd; + unsigned modulo = (unsigned)(ub - lb + 1); - if (urandom) { - uint32_t rnd; - size_t len = fread(&rnd, 1, sizeof rnd, urandom); (void)len; - return rnd; + if (modulo != 0) { + do { + rnd = su_random64(); + } while (rnd / modulo == 0xffffFFFFffffFFFFULL / modulo); + + rnd %= modulo; } + else { + rnd = su_random64(); + } + + return (int)rnd + lb; +} - return (uint32_t)random(); +/** Get random 32-bit unsigned number. + * + */ +uint32_t su_random(void) +{ + return (uint32_t)(su_random64() >> 16); } From mikej at freeswitch.org Tue Mar 24 10:57:00 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 12:57:00 -0500 Subject: [Freeswitch-svn] [commit] r12757 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mikej Date: Tue Mar 24 12:57:00 2009 New Revision: 12757 Log: use nua_handle_home instead of using nua internals to get the nua handle home Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Mar 24 12:57:00 2009 @@ -1280,7 +1280,7 @@ if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason); - nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), + nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL), TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); @@ -1303,12 +1303,12 @@ sofia_glue_tech_patch_sdp(tech_pvt); sofia_glue_tech_proxy_remote_addr(tech_pvt); } - nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); } else { - nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END()); + nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END()); } } } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Tue Mar 24 12:57:00 2009 @@ -793,7 +793,7 @@ } if (sip->sip_path) { - path_val = sip_header_as_string(nh->nh_home, (void *) sip->sip_path); + path_val = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_path); path_encoded_len = (strlen(path_val) * 3) + 1; switch_zmalloc(path_encoded, path_encoded_len); switch_copy_string(path_encoded, ";fs_path=", 10); @@ -1117,7 +1117,7 @@ if (exptime) { switch_snprintf(exp_param, sizeof(exp_param), "expires=%ld", exptime); - sip_contact_add_param(nh->nh_home, sip->sip_contact, exp_param); + sip_contact_add_param(nua_handle_home(nh), sip->sip_contact, exp_param); if (switch_event_create(&s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", to_user, reg_host); @@ -1147,10 +1147,10 @@ } if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { - char *full_contact = sip_header_as_string(nh->nh_home, (void *) sip->sip_contact); + char *full_contact = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_contact); if (full_contact && switch_stristr("SUBSCRIBE", full_contact)) { sofia_sla_handle_register(nua, profile, sip, exptime, full_contact); - su_free(nh->nh_home, full_contact); + su_free(nua_handle_home(nh), full_contact); } } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c Tue Mar 24 12:57:00 2009 @@ -217,7 +217,7 @@ nua_handle_destroy(nh); sofia_private_free(sofia_private); } else { - char *full_contact = sip_header_as_string(nh->nh_home, (void *) sip->sip_contact); + char *full_contact = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_contact); time_t expires = switch_epoch_time_now(NULL); char *sql; char *contact_str = strip_uri(full_contact); From anthm at freeswitch.org Tue Mar 24 10:58:01 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 12:58:01 -0500 Subject: [Freeswitch-svn] [commit] r12758 - freeswitch/trunk/libs/iksemel/src Message-ID: Author: anthm Date: Tue Mar 24 12:58:00 2009 New Revision: 12758 Log: don Modified: freeswitch/trunk/libs/iksemel/src/stream.c Modified: freeswitch/trunk/libs/iksemel/src/stream.c ============================================================================== --- freeswitch/trunk/libs/iksemel/src/stream.c (original) +++ freeswitch/trunk/libs/iksemel/src/stream.c Tue Mar 24 12:58:00 2009 @@ -45,8 +45,10 @@ }; #ifdef HAVE_GNUTLS +#ifndef WIN32 #include GCRY_THREAD_OPTION_PTHREAD_IMPL; +#endif static size_t tls_push (iksparser *prs, const char *buffer, size_t len) @@ -78,7 +80,9 @@ const int mac_priority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 }; int ret; +#ifndef WIN32 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#endif if (gnutls_global_init () != 0) return IKS_NOMEM; @@ -610,7 +614,9 @@ { int ok = 0; +#ifndef WIN32 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#endif if (gnutls_global_init () != 0) return IKS_NOMEM; From anthm at freeswitch.org Tue Mar 24 11:01:58 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 13:01:58 -0500 Subject: [Freeswitch-svn] [commit] r12759 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket Message-ID: Author: anthm Date: Tue Mar 24 13:01:58 2009 New Revision: 12759 Log: change blocking: true to async: true you can start with blocking and go async but not the other way around Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Tue Mar 24 13:01:58 2009 @@ -1575,7 +1575,13 @@ if (!strncasecmp(cmd, "sendmsg", 7)) { switch_core_session_t *session; char *uuid = cmd + 7; - + const char *async_var = switch_event_get_header(*event, "async"); + int async = switch_test_flag(listener, LFLAG_ASYNC); + + if (switch_true(async_var)) { + async = 1; + } + if (uuid) { while (*uuid == ' ') { uuid++; @@ -1592,14 +1598,11 @@ uuid = switch_event_get_header(*event, "session-id"); } - if (switch_strlen_zero(uuid) && listener->session) { - const char *blocking = switch_event_get_header(*event, "blocking"); - int async = switch_test_flag(listener, LFLAG_ASYNC); - - if (blocking && switch_true(blocking)) { - async = 0; - } + if (uuid && listener->session && !strcmp(uuid, switch_core_session_get_uuid(listener->session))) { + uuid = NULL; + } + if (switch_strlen_zero(uuid) && listener->session) { if (async) { if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) { switch_snprintf(reply, reply_len, "+OK"); From anthm at freeswitch.org Tue Mar 24 11:03:26 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 13:03:26 -0500 Subject: [Freeswitch-svn] [commit] r12760 - in freeswitch/trunk/libs/esl: lua perl perl/ESL php python ruby src src/include Message-ID: Author: anthm Date: Tue Mar 24 13:03:26 2009 New Revision: 12760 Log: match ESL to last commit and check in ESL::IVR perl mod Added: freeswitch/trunk/libs/esl/perl/ESL/ freeswitch/trunk/libs/esl/perl/ESL/IVR.pm Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp freeswitch/trunk/libs/esl/perl/ESL.pm freeswitch/trunk/libs/esl/perl/esl_wrap.cpp freeswitch/trunk/libs/esl/php/ESL.php freeswitch/trunk/libs/esl/php/esl_wrap.cpp freeswitch/trunk/libs/esl/php/php_ESL.h freeswitch/trunk/libs/esl/python/ESL.py freeswitch/trunk/libs/esl/python/esl_wrap.cpp freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp freeswitch/trunk/libs/esl/src/esl.c freeswitch/trunk/libs/esl/src/esl_oop.cpp freeswitch/trunk/libs/esl/src/include/esl.h freeswitch/trunk/libs/esl/src/include/esl_oop.h Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/lua/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/lua/esl_wrap.cpp Tue Mar 24 13:03:26 2009 @@ -2632,22 +2632,60 @@ } -static int _wrap_ESLconnection_setBlockingExecute(lua_State* L) { +static int _wrap_ESLconnection_executeAsync(lua_State* L) { int SWIG_arg = -1; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; int result; - SWIG_check_num_args("setBlockingExecute",2,2) - if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setBlockingExecute",1,"ESLconnection *"); - if(!lua_isstring(L,2)) SWIG_fail_arg("setBlockingExecute",2,"char const *"); + SWIG_check_num_args("executeAsync",2,4) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("executeAsync",1,"ESLconnection *"); + if(!lua_isstring(L,2)) SWIG_fail_arg("executeAsync",2,"char const *"); + if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("executeAsync",3,"char const *"); + if(lua_gettop(L)>=4 && !lua_isstring(L,4)) SWIG_fail_arg("executeAsync",4,"char const *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ - SWIG_fail_ptr("ESLconnection_setBlockingExecute",1,SWIGTYPE_p_ESLconnection); + SWIG_fail_ptr("ESLconnection_executeAsync",1,SWIGTYPE_p_ESLconnection); } arg2 = (char *)lua_tostring(L, 2); - result = (int)(arg1)->setBlockingExecute((char const *)arg2); + if(lua_gettop(L)>=3){ + arg3 = (char *)lua_tostring(L, 3); + } + if(lua_gettop(L)>=4){ + arg4 = (char *)lua_tostring(L, 4); + } + result = (int)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + SWIG_arg=0; + lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_ESLconnection_setAsyncExecute(lua_State* L) { + int SWIG_arg = -1; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + SWIG_check_num_args("setAsyncExecute",2,2) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setAsyncExecute",1,"ESLconnection *"); + if(!lua_isstring(L,2)) SWIG_fail_arg("setAsyncExecute",2,"char const *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ + SWIG_fail_ptr("ESLconnection_setAsyncExecute",1,SWIGTYPE_p_ESLconnection); + } + + arg2 = (char *)lua_tostring(L, 2); + result = (int)(arg1)->setAsyncExecute((char const *)arg2); SWIG_arg=0; lua_pushnumber(L, (lua_Number) result); SWIG_arg++; return SWIG_arg; @@ -2730,7 +2768,8 @@ {"filter", _wrap_ESLconnection_filter}, {"events", _wrap_ESLconnection_events}, {"execute", _wrap_ESLconnection_execute}, - {"setBlockingExecute", _wrap_ESLconnection_setBlockingExecute}, + {"executeAsync", _wrap_ESLconnection_executeAsync}, + {"setAsyncExecute", _wrap_ESLconnection_setAsyncExecute}, {"setEventLock", _wrap_ESLconnection_setEventLock}, {"disconnect", _wrap_ESLconnection_disconnect}, {0,0} Modified: freeswitch/trunk/libs/esl/perl/ESL.pm ============================================================================== --- freeswitch/trunk/libs/esl/perl/ESL.pm (original) +++ freeswitch/trunk/libs/esl/perl/ESL.pm Tue Mar 24 13:03:26 2009 @@ -140,7 +140,8 @@ *filter = *ESLc::ESLconnection_filter; *events = *ESLc::ESLconnection_events; *execute = *ESLc::ESLconnection_execute; -*setBlockingExecute = *ESLc::ESLconnection_setBlockingExecute; +*executeAsync = *ESLc::ESLconnection_executeAsync; +*setAsyncExecute = *ESLc::ESLconnection_setAsyncExecute; *setEventLock = *ESLc::ESLconnection_setEventLock; *disconnect = *ESLc::ESLconnection_disconnect; sub DISOWN { Added: freeswitch/trunk/libs/esl/perl/ESL/IVR.pm ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/esl/perl/ESL/IVR.pm Tue Mar 24 13:03:26 2009 @@ -0,0 +1,88 @@ +package ESL::IVR; +use ESL; +use Data::Dumper; + +sub new($$) { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = {}; + + $self->{_esl} = new ESL::ESLconnection(fileno(STDIN)); + $self->{_info} = $self->{_esl}->getInfo(); + $self->{_uuid} = $self->{_info}->getHeader("unique-id"); + + return bless($self, $class); + +} + +sub getHeader($;) { + my $self = shift; + + return $self->{_info} ? $self->{_info}->getHeader(shift) : undef; +} + +sub execute($;) { + my $self = shift; + return $self->{_esl}->execute(@_); +} + +sub api($;) { + my $self = shift; + return $self->{_esl}->api(@_); +} + +sub disconnect($;) { + my $self = shift; + return $self->{_esl}->disconnect(@_); +} + +sub getVar($;) { + my $self = shift; + my ($var) = @_; + my $e = $self->api("uuid_getvar", "$self->{_uuid} $var"); + my $input; + + if ($e) { + $input = $e->getBody() . "\n"; + if ($input eq "_undef_") { + $input = undef; + } + } + + chomp $input; + + return $input; + +} + +sub playAndGetDigits($;) { + my $self = shift; + my ($min, $max, $tries, $to, $term, $file, $invalid_file, $var) = @_; + + $self->execute("play_and_get_digits", "$min $max $tries $to $term $file $invalid_file $var"); + + return $self->getVar($var); + +} + +sub read($;) { + my $self = shift; + my ($min, $max, $file, $var, $to, $term) = @_; + + $self->execute("read", "$min $max $file $var $to $term"); + + return $self->getVar($var); + +} + +sub playback($;) { + my $self = shift; + my ($file) = @_; + + $self->execute("playback", $file); + return $self->getVar("playback_terminators_used"); + +} + + +1; Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Tue Mar 24 13:03:26 2009 @@ -3252,7 +3252,72 @@ } -XS(_wrap_ESLconnection_setBlockingExecute) { +XS(_wrap_ESLconnection_executeAsync) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: ESLconnection_executeAsync(self,app,arg,uuid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_executeAsync" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_executeAsync" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_executeAsync" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_executeAsync" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (int)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_setAsyncExecute) { { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; @@ -3266,19 +3331,19 @@ dXSARGS; if ((items < 2) || (items > 2)) { - SWIG_croak("Usage: ESLconnection_setBlockingExecute(self,val);"); + SWIG_croak("Usage: ESLconnection_setAsyncExecute(self,val);"); } res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setBlockingExecute" "', argument " "1"" of type '" "ESLconnection *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setAsyncExecute" "', argument " "1"" of type '" "ESLconnection *""'"); } arg1 = reinterpret_cast< ESLconnection * >(argp1); res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setBlockingExecute" "', argument " "2"" of type '" "char const *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setAsyncExecute" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - result = (int)(arg1)->setBlockingExecute((char const *)arg2); + result = (int)(arg1)->setAsyncExecute((char const *)arg2); ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; @@ -3461,7 +3526,8 @@ {"ESLc::ESLconnection_filter", _wrap_ESLconnection_filter}, {"ESLc::ESLconnection_events", _wrap_ESLconnection_events}, {"ESLc::ESLconnection_execute", _wrap_ESLconnection_execute}, -{"ESLc::ESLconnection_setBlockingExecute", _wrap_ESLconnection_setBlockingExecute}, +{"ESLc::ESLconnection_executeAsync", _wrap_ESLconnection_executeAsync}, +{"ESLc::ESLconnection_setAsyncExecute", _wrap_ESLconnection_setAsyncExecute}, {"ESLc::ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock}, {"ESLc::ESLconnection_disconnect", _wrap_ESLconnection_disconnect}, {"ESLc::eslSetLogLevel", _wrap_eslSetLogLevel}, Modified: freeswitch/trunk/libs/esl/php/ESL.php ============================================================================== --- freeswitch/trunk/libs/esl/php/ESL.php (original) +++ freeswitch/trunk/libs/esl/php/ESL.php Tue Mar 24 13:03:26 2009 @@ -187,8 +187,17 @@ return $r; } - function setBlockingExecute($val) { - return ESLconnection_setBlockingExecute($this->_cPtr,$val); + function executeAsync($app,$arg=null,$uuid=null) { + switch (func_num_args()) { + case 1: $r=ESLconnection_executeAsync($this->_cPtr,$app); break; + case 2: $r=ESLconnection_executeAsync($this->_cPtr,$app,$arg); break; + default: $r=ESLconnection_executeAsync($this->_cPtr,$app,$arg,$uuid); + } + return $r; + } + + function setAsyncExecute($val) { + return ESLconnection_setAsyncExecute($this->_cPtr,$val); } function setEventLock($val) { Modified: freeswitch/trunk/libs/esl/php/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/php/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/php/esl_wrap.cpp Tue Mar 24 13:03:26 2009 @@ -2247,7 +2247,58 @@ } -ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setBlockingExecute) { +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_executeAsync) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + int result; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>4 || + zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLconnection_executeAsync. Expected SWIGTYPE_p_ESLconnection"); + } + } + if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@SWIG@*/; + + if(arg_count > 2) { + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + } + if(arg_count > 3) { + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG@*/; + + } + result = (int)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + { + ZVAL_LONG(return_value,result); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; int result; @@ -2260,7 +2311,7 @@ { if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) { - SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLconnection_setBlockingExecute. Expected SWIGTYPE_p_ESLconnection"); + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLconnection_setAsyncExecute. Expected SWIGTYPE_p_ESLconnection"); } } if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); @@ -2270,7 +2321,7 @@ arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - result = (int)(arg1)->setBlockingExecute((char const *)arg2); + result = (int)(arg1)->setAsyncExecute((char const *)arg2); { ZVAL_LONG(return_value,result); } @@ -2415,7 +2466,8 @@ SWIG_ZEND_NAMED_FE(eslconnection_filter,_wrap_ESLconnection_filter,NULL) SWIG_ZEND_NAMED_FE(eslconnection_events,_wrap_ESLconnection_events,NULL) SWIG_ZEND_NAMED_FE(eslconnection_execute,_wrap_ESLconnection_execute,NULL) - SWIG_ZEND_NAMED_FE(eslconnection_setblockingexecute,_wrap_ESLconnection_setBlockingExecute,NULL) + SWIG_ZEND_NAMED_FE(eslconnection_executeasync,_wrap_ESLconnection_executeAsync,NULL) + SWIG_ZEND_NAMED_FE(eslconnection_setasyncexecute,_wrap_ESLconnection_setAsyncExecute,NULL) SWIG_ZEND_NAMED_FE(eslconnection_seteventlock,_wrap_ESLconnection_setEventLock,NULL) SWIG_ZEND_NAMED_FE(eslconnection_disconnect,_wrap_ESLconnection_disconnect,NULL) SWIG_ZEND_NAMED_FE(eslsetloglevel,_wrap_eslSetLogLevel,NULL) Modified: freeswitch/trunk/libs/esl/php/php_ESL.h ============================================================================== --- freeswitch/trunk/libs/esl/php/php_ESL.h (original) +++ freeswitch/trunk/libs/esl/php/php_ESL.h Tue Mar 24 13:03:26 2009 @@ -62,7 +62,8 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_events); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_execute); -ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setBlockingExecute); +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_executeAsync); +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect); ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel); Modified: freeswitch/trunk/libs/esl/python/ESL.py ============================================================================== --- freeswitch/trunk/libs/esl/python/ESL.py (original) +++ freeswitch/trunk/libs/esl/python/ESL.py Tue Mar 24 13:03:26 2009 @@ -89,7 +89,8 @@ def filter(*args): return apply(_ESL.ESLconnection_filter, args) def events(*args): return apply(_ESL.ESLconnection_events, args) def execute(*args): return apply(_ESL.ESLconnection_execute, args) - def setBlockingExecute(*args): return apply(_ESL.ESLconnection_setBlockingExecute, args) + def executeAsync(*args): return apply(_ESL.ESLconnection_executeAsync, args) + def setAsyncExecute(*args): return apply(_ESL.ESLconnection_setAsyncExecute, args) def setEventLock(*args): return apply(_ESL.ESLconnection_setEventLock, args) def disconnect(*args): return apply(_ESL.ESLconnection_disconnect, args) ESLconnection_swigregister = _ESL.ESLconnection_swigregister Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/python/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp Tue Mar 24 13:03:26 2009 @@ -4105,31 +4105,93 @@ } -SWIGINTERN PyObject *_wrap_ESLconnection_setBlockingExecute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_ESLconnection_executeAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_setBlockingExecute",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO|OO:ESLconnection_executeAsync",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setBlockingExecute" "', argument " "1"" of type '" "ESLconnection *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_executeAsync" "', argument " "1"" of type '" "ESLconnection *""'"); } arg1 = reinterpret_cast< ESLconnection * >(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setBlockingExecute" "', argument " "2"" of type '" "char const *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_executeAsync" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - result = (int)(arg1)->setBlockingExecute((char const *)arg2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_executeAsync" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_executeAsync" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (int)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_setAsyncExecute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_setAsyncExecute",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setAsyncExecute" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setAsyncExecute" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->setAsyncExecute((char const *)arg2); resultobj = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return resultobj; @@ -4257,7 +4319,8 @@ { (char *)"ESLconnection_filter", _wrap_ESLconnection_filter, METH_VARARGS, NULL}, { (char *)"ESLconnection_events", _wrap_ESLconnection_events, METH_VARARGS, NULL}, { (char *)"ESLconnection_execute", _wrap_ESLconnection_execute, METH_VARARGS, NULL}, - { (char *)"ESLconnection_setBlockingExecute", _wrap_ESLconnection_setBlockingExecute, METH_VARARGS, NULL}, + { (char *)"ESLconnection_executeAsync", _wrap_ESLconnection_executeAsync, METH_VARARGS, NULL}, + { (char *)"ESLconnection_setAsyncExecute", _wrap_ESLconnection_setAsyncExecute, METH_VARARGS, NULL}, { (char *)"ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock, METH_VARARGS, NULL}, { (char *)"ESLconnection_disconnect", _wrap_ESLconnection_disconnect, METH_VARARGS, NULL}, { (char *)"ESLconnection_swigregister", ESLconnection_swigregister, METH_VARARGS, NULL}, Modified: freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp ============================================================================== --- freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp (original) +++ freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp Tue Mar 24 13:03:26 2009 @@ -3236,7 +3236,68 @@ SWIGINTERN VALUE -_wrap_ESLconnection_setBlockingExecute(int argc, VALUE *argv, VALUE self) { +_wrap_ESLconnection_executeAsync(int argc, VALUE *argv, VALUE self) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLconnection *","executeAsync", 1, self )); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","executeAsync", 2, argv[0] )); + } + arg2 = reinterpret_cast< char * >(buf2); + if (argc > 1) { + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","executeAsync", 3, argv[1] )); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (argc > 2) { + res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","executeAsync", 4, argv[2] )); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (int)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + vresult = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ESLconnection_setAsyncExecute(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; int result; @@ -3252,15 +3313,15 @@ } res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLconnection *","setBlockingExecute", 1, self )); + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLconnection *","setAsyncExecute", 1, self )); } arg1 = reinterpret_cast< ESLconnection * >(argp1); res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","setBlockingExecute", 2, argv[0] )); + SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","setAsyncExecute", 2, argv[0] )); } arg2 = reinterpret_cast< char * >(buf2); - result = (int)(arg1)->setBlockingExecute((char const *)arg2); + result = (int)(arg1)->setAsyncExecute((char const *)arg2); vresult = SWIG_From_int(static_cast< int >(result)); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; return vresult; @@ -3680,7 +3741,8 @@ rb_define_method(cESLconnection.klass, "filter", VALUEFUNC(_wrap_ESLconnection_filter), -1); rb_define_method(cESLconnection.klass, "events", VALUEFUNC(_wrap_ESLconnection_events), -1); rb_define_method(cESLconnection.klass, "execute", VALUEFUNC(_wrap_ESLconnection_execute), -1); - rb_define_method(cESLconnection.klass, "setBlockingExecute", VALUEFUNC(_wrap_ESLconnection_setBlockingExecute), -1); + rb_define_method(cESLconnection.klass, "executeAsync", VALUEFUNC(_wrap_ESLconnection_executeAsync), -1); + rb_define_method(cESLconnection.klass, "setAsyncExecute", VALUEFUNC(_wrap_ESLconnection_setAsyncExecute), -1); rb_define_method(cESLconnection.klass, "setEventLock", VALUEFUNC(_wrap_ESLconnection_setEventLock), -1); rb_define_method(cESLconnection.klass, "disconnect", VALUEFUNC(_wrap_ESLconnection_disconnect), -1); cESLconnection.mark = 0; Modified: freeswitch/trunk/libs/esl/src/esl.c ============================================================================== --- freeswitch/trunk/libs/esl/src/esl.c (original) +++ freeswitch/trunk/libs/esl/src/esl.c Tue Mar 24 13:03:26 2009 @@ -451,7 +451,7 @@ char app_buf[512] = ""; char arg_buf[512] = ""; const char *el_buf = "event-lock: true\n"; - const char *bl_buf = "blocking: true\n"; + const char *bl_buf = "async: true\n"; char send_buf[1292] = ""; if (!handle->connected) { @@ -471,7 +471,7 @@ } snprintf(send_buf, sizeof(send_buf), "%s\ncall-command: execute\n%s%s%s%s\n", - cmd_buf, app_buf, arg_buf, handle->event_lock ? el_buf : "", handle->blocking_execute ? bl_buf : ""); + cmd_buf, app_buf, arg_buf, handle->event_lock ? el_buf : "", handle->async_execute ? bl_buf : ""); return esl_send_recv(handle, send_buf); } Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original) +++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Tue Mar 24 13:03:26 2009 @@ -131,12 +131,12 @@ return NULL; } -int ESLconnection::setBlockingExecute(const char *val) +int ESLconnection::setAsyncExecute(const char *val) { if (val) { - handle.blocking_execute = esl_true(val); + handle.async_execute = esl_true(val); } - return handle.blocking_execute; + return handle.async_execute; } int ESLconnection::setEventLock(const char *val) @@ -152,6 +152,19 @@ return esl_execute(&handle, app, arg, uuid); } + +int ESLconnection::executeAsync(const char *app, const char *arg, const char *uuid) +{ + int async = handle.async_execute; + int r; + + handle.async_execute = 1; + r = esl_execute(&handle, app, arg, uuid); + handle.async_execute = async; + + return r; +} + int ESLconnection::sendEvent(ESLevent *send_me) { return esl_sendevent(&handle, send_me->event); Modified: freeswitch/trunk/libs/esl/src/include/esl.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl.h Tue Mar 24 13:03:26 2009 @@ -272,7 +272,7 @@ int connected; struct sockaddr_in addr; esl_mutex_t *mutex; - int blocking_execute; + int async_execute; int event_lock; } esl_handle_t; Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Tue Mar 24 13:03:26 2009 @@ -88,7 +88,8 @@ ESLevent *filter(const char *header, const char *value); int events(const char *etype, const char *value); int execute(const char *app, const char *arg = NULL, const char *uuid = NULL); - int setBlockingExecute(const char *val); + int executeAsync(const char *app, const char *arg = NULL, const char *uuid = NULL); + int setAsyncExecute(const char *val); int setEventLock(const char *val); int disconnect(void); }; From anthm at freeswitch.org Tue Mar 24 11:06:25 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 13:06:25 -0500 Subject: [Freeswitch-svn] [commit] r12761 - freeswitch/trunk/libs/esl/perl/ESL Message-ID: Author: anthm Date: Tue Mar 24 13:06:25 2009 New Revision: 12761 Log: update Modified: freeswitch/trunk/libs/esl/perl/ESL/IVR.pm Modified: freeswitch/trunk/libs/esl/perl/ESL/IVR.pm ============================================================================== --- freeswitch/trunk/libs/esl/perl/ESL/IVR.pm (original) +++ freeswitch/trunk/libs/esl/perl/ESL/IVR.pm Tue Mar 24 13:06:25 2009 @@ -58,6 +58,10 @@ sub playAndGetDigits($;) { my $self = shift; my ($min, $max, $tries, $to, $term, $file, $invalid_file, $var) = @_; + + if (!$self->{_esl}->connected()) { + return undef; + } $self->execute("play_and_get_digits", "$min $max $tries $to $term $file $invalid_file $var"); @@ -69,6 +73,10 @@ my $self = shift; my ($min, $max, $file, $var, $to, $term) = @_; + if (!$self->{_esl}->connected()) { + return undef; + } + $self->execute("read", "$min $max $file $var $to $term"); return $self->getVar($var); @@ -79,6 +87,10 @@ my $self = shift; my ($file) = @_; + if (!$self->{_esl}->connected()) { + return undef; + } + $self->execute("playback", $file); return $self->getVar("playback_terminators_used"); From mikej at freeswitch.org Tue Mar 24 15:13:19 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 17:13:19 -0500 Subject: [Freeswitch-svn] [commit] r12762 - freeswitch/trunk/scripts/contrib/nmartin Message-ID: Author: mikej Date: Tue Mar 24 17:13:19 2009 New Revision: 12762 Log: add anm's folder Added: freeswitch/trunk/scripts/contrib/nmartin/ From anthm at freeswitch.org Tue Mar 24 15:22:05 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 17:22:05 -0500 Subject: [Freeswitch-svn] [commit] r12763 - in freeswitch/trunk/src/mod: applications/mod_commands event_handlers/mod_event_socket Message-ID: Author: anthm Date: Tue Mar 24 17:22:05 2009 New Revision: 12763 Log: fix typo Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original) +++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue Mar 24 17:22:05 2009 @@ -2598,7 +2598,7 @@ } else if (!strcasecmp(command, "tasks")) { sprintf(sql, "select * from %s", command); } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) { - if (argv[1]) { + if (argv[1] && strcasecmp(argv[1], "as")) { sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != '' and name = '%s' order by type,name", command, argv[1]); } else { sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != '' order by type,name", command); @@ -2628,7 +2628,7 @@ help = 1; holder.print_title = 0; - if ((cmdname = strchr(command, ' ')) != 0) { + if ((cmdname = strchr(command, ' ')) && strcasecmp(cmdname, "as")) { *cmdname++ = '\0'; switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s' order by name", cmdname); Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Tue Mar 24 17:22:05 2009 @@ -1593,7 +1593,7 @@ strip_cr(uuid); } } - + if (switch_strlen_zero(uuid)) { uuid = switch_event_get_header(*event, "session-id"); } From brian at freeswitch.org Tue Mar 24 16:18:04 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 18:18:04 -0500 Subject: [Freeswitch-svn] [commit] r12764 - freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx Message-ID: Author: brian Date: Tue Mar 24 18:18:04 2009 New Revision: 12764 Log: not really a warning Modified: freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c Modified: freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c ============================================================================== --- freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c (original) +++ freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c Tue Mar 24 18:18:04 2009 @@ -221,7 +221,7 @@ switch_mutex_unlock(ps->flag_mutex); switch_clear_flag(ps, PSFLAG_HAS_TEXT); switch_clear_flag(ps, PSFLAG_READY); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Port Closed.\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Port Closed.\n"); switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED); return SWITCH_STATUS_SUCCESS; } From anthm at freeswitch.org Tue Mar 24 16:44:03 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 18:44:03 -0500 Subject: [Freeswitch-svn] [commit] r12765 - in freeswitch/trunk/src: . include mod/applications/mod_dptools mod/endpoints/mod_sofia mod/event_handlers/mod_cdr_csv mod/event_handlers/mod_event_socket Message-ID: Author: anthm Date: Tue Mar 24 18:44:03 2009 New Revision: 12765 Log: fix var events to not have stamp info Modified: freeswitch/trunk/src/include/switch_event.h freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c freeswitch/trunk/src/switch_channel.c Modified: freeswitch/trunk/src/include/switch_event.h ============================================================================== --- freeswitch/trunk/src/include/switch_event.h (original) +++ freeswitch/trunk/src/include/switch_event.h Tue Mar 24 18:44:03 2009 @@ -332,6 +332,15 @@ */ #define switch_event_create(event, id) switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY) +static inline switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id) +{ + switch_status_t status = switch_event_create(event, SWITCH_EVENT_CLONE); + if (status == SWITCH_STATUS_SUCCESS) { + (*event)->event_id = event_id; + } + + return status; +} /*! \brief Deliver an event to all of the registered event listeners \param event the event to send (will be nulled) Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Mar 24 18:44:03 2009 @@ -938,7 +938,7 @@ switch_event_t *event; char *buf; - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { + if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(switch_core_session_get_channel(session), event); switch_event_serialize(event, &buf, SWITCH_FALSE); switch_assert(buf); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 24 18:44:03 2009 @@ -1147,14 +1147,14 @@ if (in) { if (!gateway->ib_vars) { - switch_event_create(&gateway->ib_vars, SWITCH_EVENT_GENERAL); + switch_event_create_plain(&gateway->ib_vars, SWITCH_EVENT_GENERAL); } switch_event_add_header_string(gateway->ib_vars, SWITCH_STACK_BOTTOM, var, val); } if (out) { if (!gateway->ob_vars) { - switch_event_create(&gateway->ob_vars, SWITCH_EVENT_GENERAL); + switch_event_create_plain(&gateway->ob_vars, SWITCH_EVENT_GENERAL); } switch_event_add_header_string(gateway->ob_vars, SWITCH_STACK_BOTTOM, var, val); } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Tue Mar 24 18:44:03 2009 @@ -1780,8 +1780,10 @@ if (first && ret == AUTH_OK) { if (v_event) { - switch_event_create(v_event, SWITCH_EVENT_REQUEST_PARAMS); + switch_event_create_plain(v_event, SWITCH_EVENT_REQUEST_PARAMS); } + + if (v_event && *v_event) { switch_xml_t xparams[3]; int i = 0; Modified: freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c Tue Mar 24 18:44:03 2009 @@ -199,7 +199,7 @@ if (globals.debug) { switch_event_t *event; - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { + if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { char *buf; switch_channel_event_set_data(channel, event); switch_event_serialize(event, &buf, SWITCH_FALSE); Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Tue Mar 24 18:44:03 2009 @@ -611,8 +611,7 @@ switch_mutex_lock(listener->filter_mutex); if (!listener->filters) { - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } if (!strcasecmp(action, "delete")) { @@ -623,8 +622,7 @@ if (!strcasecmp(header_val, "all")) { switch_event_destroy(&listener->filters); - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } else { switch_event_del_header(listener->filters, header_val); } @@ -1408,15 +1406,13 @@ switch_mutex_lock(listener->filter_mutex); if (!listener->filters) { - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } if (!strcasecmp(header_name, "delete")) { if (!strcasecmp(header_val, "all")) { switch_event_destroy(&listener->filters); - switch_event_create(&listener->filters, SWITCH_EVENT_CLONE); - listener->filters->event_id = SWITCH_EVENT_CHANNEL_DATA; + switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA); } else { switch_event_del_header(listener->filters, header_val); } Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Tue Mar 24 18:44:03 2009 @@ -220,7 +220,7 @@ return SWITCH_STATUS_MEMERR; } - switch_event_create(&(*channel)->variables, SWITCH_EVENT_GENERAL); + switch_event_create_plain(&(*channel)->variables, SWITCH_EVENT_CHANNEL_DATA); switch_core_hash_init(&(*channel)->private_hash, pool); switch_queue_create(&(*channel)->dtmf_queue, SWITCH_DTMF_LOG_LEN, pool); From nmartin at freeswitch.org Tue Mar 24 17:24:21 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 19:24:21 -0500 Subject: [Freeswitch-svn] [commit] r12766 - freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial Message-ID: Author: nmartin Date: Tue Mar 24 19:24:21 2009 New Revision: 12766 Log: initial import click2dial applet OS X only :( Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/ freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/README.txt freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/click2dial.zip (contents, props changed) freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/linkify.user.js Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/README.txt ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/README.txt Tue Mar 24 19:24:21 2009 @@ -0,0 +1,48 @@ +README + +Client Side Click2Dial + +============================================================== +Copyright (c) 2009 Nik Martin + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +The original author of this work, Nik Martin, must be credited +as the original author of this work. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + + +============================================================== + +Setup: + +Unzip Click2Dial.zip. + +Inside fs_dial.app, edit COntents/Resources/fsdial.py to set up your server information and phone number + +Import linkify.user.js into greasemonkey (http://www.greasespot.net/) + +Double Click fs_dial.app to register it as the handler for dial:// urls + +The greasemonkey script will linkify any text on a web page that looks like a phone number. +You can edit the reg-ex inside the greasemonkey script to match different types of numbers. + +The fsdial.py script assumes you have a default context, and outbound calls should go to this context \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/click2dial.zip ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/linkify.user.js ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/linkify.user.js Tue Mar 24 19:24:21 2009 @@ -0,0 +1,78 @@ +// FreeSWITCH Dial Linkify +// Author: Nik Martin +// License: MIT +// +//This script was taken from another script here: http://userscripts.org/scripts/show/1003 +// +// Matches these patterns: +// 800-555-1212 +// (800) 555-1212 +// (800)555-1212 +// 8005551212 +// Weak since it does any 10+ digit number +// 800.555.1212 +// Tested with: +// www.yellowpages.com +// local.google.com +// a9.com +// +// International calling sure would be neat +// ==UserScript== +// @name FreeSWITCH Dial Linkify +// @namespace +// @description Looks for phone numbers in pages and makes hyperlinks out of them. When clicking on the link, FS will connect your phone to the number you clicked +// @include * +// ==/UserScript== + +(function () { + +//this is the test to see if the number looks like a phone number or not + const trackRegex = /(\+\d\d?)?[\-\s\/\.]?[\(]?(\d){2,4}[\)]?[\-\s\/\.]?\d\d\d[\-\s\/\.]?(\d){3,5}\b/ig; + + function trackUrl(t) { + return "dial://org.FreeSWITCH.Dialer?number=" + String(t).replace(/[\(\)\- \.]/g, ""); + } + + // tags we will scan looking for un-hyperlinked urls + var allowedParents = [ + "abbr", "acronym", "address", "applet", "b", "bdo", "big", "blockquote", "body", + "caption", "center", "cite", "code", "dd", "del", "div", "dfn", "dt", "em", + "fieldset", "font", "form", "h1", "h2", "h3", "h4", "h5", "h6", "i", "iframe", + "ins", "kdb", "li", "object", "nobr", "pre", "p", "q", "samp", "small", "span", "strike", + "s", "strong", "sub", "sup", "td", "th", "tt", "u", "var" + ]; + + var xpath = "//text()[(parent::" + allowedParents.join(" or parent::") + ")" + + //" and contains(translate(., 'HTTP', 'http'), 'http') + " + + "]"; + + var candidates = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + + //var t0 = new Date().getTime(); + for (var cand = null, i = 0; (cand = candidates.snapshotItem(i)); i++) { + if (trackRegex.test(cand.nodeValue)) { + var span = document.createElement("span"); + var source = cand.nodeValue; + + cand.parentNode.replaceChild(span, cand); + + trackRegex.lastIndex = 0; + for (var match = null, lastLastIndex = 0; (match = trackRegex.exec(source)); ) { + span.appendChild(document.createTextNode(source.substring(lastLastIndex, match.index))); + + var a = document.createElement("a"); + a.setAttribute("href", trackUrl(match[0])); + a.appendChild(document.createTextNode(match[0])); + span.appendChild(a); + + lastLastIndex = trackRegex.lastIndex; + } + + span.appendChild(document.createTextNode(source.substring(lastLastIndex))); + span.normalize(); + } + } + // var t1 = new Date().getTime(); + // alert("X-Lite Dial linkify took " + ((t1 - t0) / 1000) + " seconds"); + +})(); From nmartin at freeswitch.org Tue Mar 24 17:39:41 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 19:39:41 -0500 Subject: [Freeswitch-svn] [commit] r12767 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Tue Mar 24 19:39:41 2009 New Revision: 12767 Log: initial import Address Book Dialer applet OS X only :( Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/ freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/ESL.pyc (contents, props changed) freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/_ESL.so (contents, props changed) freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.py freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.scpt (contents, props changed) freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/test.scpt (contents, props changed) Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/ESL.pyc ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Tue Mar 24 19:39:41 2009 @@ -0,0 +1,39 @@ +README + + +============================================================== +Copyright (c) 2009 Nik Martin + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +The original author of this work, Nik Martin, must be credited +as the original author of this work. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + + +============================================================== + + +Drop all thee files in ~/Library/Address Book Scripts + +Edit fsdial.py to set up your server information and phone number + +Start Address Book. You should now have a FS Dial entry on the popup menu on phone numbers now. \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/_ESL.so ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.py ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.py Tue Mar 24 19:39:41 2009 @@ -0,0 +1,82 @@ +#!/usr/bin/env python + + +#============================================================== +#Copyright (c) 2009 Nik Martin +# +#Permission is hereby granted, free of charge, to any person +#obtaining a copy of this software and associated documentation +#files (the "Software"), to deal in the Software without +#restriction, including without limitation the rights to use, +#copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the +#Software is furnished to do so, subject to the following +#conditions: +# +#The above copyright notice and this permission notice shall be +#included in all copies or substantial portions of the Software. +# +#The original author of this work, Nik Martin, must be credited +#as the original author of this work. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +#OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +#NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +#WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +#OTHER DEALINGS IN THE SOFTWARE. +# +# +#============================================================== + +import string +import sys +from optparse import OptionParser +from ESL import * + + +def main(argv): + # change these to match your configuration + my_number = "1000" #@mydomain.com + server_addr = "fs.ip.add.ress" + server_port = "8021" + server_auth = "ClueCon" + + + try: + + parser = OptionParser() + parser.add_option("-n", "--number", dest="number", + help="number to dial") + + (options, args) = parser.parse_args() + + + if not options.number: + print "ERROR: destination number required" + sys.exit(2) + + cmd = "api originate {ignore_early_media=true,origination_caller_id_number=" + options.number + ",effective_caller_id_number=" + my_number + "}user/" + my_number + " &transfer(" + options.number + " XML default)" + print cmd + + con = ESLconnection(server_addr, server_port, server_auth) + #are we connected? + + if con.connected: + + e=con.sendRecv(cmd) + print e.getBody() + + else: + + print "Not Connected" + sys.exit(2) + + except: + print "Unexpected error:", sys.exc_info()[0] + raise + +if __name__ == "__main__": + main(sys.argv[1:]) \ No newline at end of file Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.scpt ============================================================================== Binary file. No diff available. Added: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/test.scpt ============================================================================== Binary file. No diff available. From nmartin at freeswitch.org Tue Mar 24 17:40:03 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 19:40:03 -0500 Subject: [Freeswitch-svn] [commit] r12768 - in freeswitch/trunk/scripts/contrib/nmartin: fs_client_side_click2dial osx_click2dial Message-ID: Author: nmartin Date: Tue Mar 24 19:40:02 2009 New Revision: 12768 Log: delete old folder Added: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/ - copied from r12766, /freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/ Removed: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/ Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/click2dial.zip Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/click2dial.zip ============================================================================== Binary files. No diff available. From nmartin at freeswitch.org Tue Mar 24 17:49:53 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 19:49:53 -0500 Subject: [Freeswitch-svn] [commit] r12769 - freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial Message-ID: Author: nmartin Date: Tue Mar 24 19:49:53 2009 New Revision: 12769 Log: fix typo for SwK Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt ============================================================================== --- freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt (original) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt Tue Mar 24 19:49:53 2009 @@ -36,7 +36,7 @@ Unzip Click2Dial.zip. -Inside fs_dial.app, edit COntents/Resources/fsdial.py to set up your server information and phone number +Inside fs_dial.app, edit Contents/Resources/fsdial.py to set up your server information and phone number Import linkify.user.js into greasemonkey (http://www.greasespot.net/) From nmartin at freeswitch.org Tue Mar 24 18:05:30 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 20:05:30 -0500 Subject: [Freeswitch-svn] [commit] r12770 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Tue Mar 24 20:05:30 2009 New Revision: 12770 Log: fix typo Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt ============================================================================== --- freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt (original) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Tue Mar 24 20:05:30 2009 @@ -32,7 +32,7 @@ ============================================================== -Drop all thee files in ~/Library/Address Book Scripts +Drop all files in ~/Library/Address Book Scripts Edit fsdial.py to set up your server information and phone number From nmartin at freeswitch.org Tue Mar 24 19:20:12 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 21:20:12 -0500 Subject: [Freeswitch-svn] [commit] r12771 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Tue Mar 24 21:20:12 2009 New Revision: 12771 Log: removed personal info from test.scpt removed binary ESL lib files. these should be built from source and distributed to users locally Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/test.scpt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/test.scpt ============================================================================== Binary files. No diff available. From nmartin at freeswitch.org Tue Mar 24 19:21:52 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 21:21:52 -0500 Subject: [Freeswitch-svn] [commit] r12772 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Tue Mar 24 21:21:52 2009 New Revision: 12772 Log: removed binary ESL lib files. these should be built from source and distributed to users locally Removed: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/ESL.pyc From nmartin at freeswitch.org Tue Mar 24 19:22:23 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 21:22:23 -0500 Subject: [Freeswitch-svn] [commit] r12773 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Tue Mar 24 21:22:23 2009 New Revision: 12773 Log: removed binary ESL lib files. these should be built from source and distributed to users locally Removed: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/_ESL.so From nmartin at freeswitch.org Tue Mar 24 19:26:28 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Tue, 24 Mar 2009 21:26:28 -0500 Subject: [Freeswitch-svn] [commit] r12774 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Tue Mar 24 21:26:28 2009 New Revision: 12774 Log: added vague instructions for deploying ESL libs on client Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt ============================================================================== --- freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt (original) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Tue Mar 24 21:26:28 2009 @@ -36,4 +36,7 @@ Edit fsdial.py to set up your server information and phone number -Start Address Book. You should now have a FS Dial entry on the popup menu on phone numbers now. \ No newline at end of file +Start Address Book. You should now have a FS Dial entry on the popup menu on phone numbers now. + +These scripts depend on ESL libs to be loaded on the machine that the scripts run on. These should be +built on a dev machice and loaded on the client machine in the proper locations (python libs) \ No newline at end of file From nmartin at freeswitch.org Wed Mar 25 07:08:16 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 09:08:16 -0500 Subject: [Freeswitch-svn] [commit] r12775 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Wed Mar 25 09:08:16 2009 New Revision: 12775 Log: added contact info for bugs, features, and whatnot Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt ============================================================================== --- freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt (original) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/README.txt Wed Mar 25 09:08:16 2009 @@ -1,5 +1,6 @@ README +For support, contact me at freeswitch at servercorps.com ============================================================== Copyright (c) 2009 Nik Martin From nmartin at freeswitch.org Wed Mar 25 07:08:39 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 09:08:39 -0500 Subject: [Freeswitch-svn] [commit] r12776 - freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial Message-ID: Author: nmartin Date: Wed Mar 25 09:08:39 2009 New Revision: 12776 Log: added contact info for bugs, features, and whatnot Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt ============================================================================== --- freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt (original) +++ freeswitch/trunk/scripts/contrib/nmartin/osx_click2dial/README.txt Wed Mar 25 09:08:39 2009 @@ -2,6 +2,8 @@ Client Side Click2Dial +For support, contact me at freeswitch at servercorps.com + ============================================================== Copyright (c) 2009 Nik Martin From silik0n at freeswitch.org Wed Mar 25 09:32:05 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 11:32:05 -0500 Subject: [Freeswitch-svn] [commit] r12777 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Wed Mar 25 11:32:04 2009 New Revision: 12777 Log: oops Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Wed Mar 25 11:32:04 2009 @@ -63,7 +63,7 @@ /*** General Whats happening Methods ***/ public function getStatus() { - $esl = new eslConnection($this->esl_ser"ver, $this->esl_port, $this->esl_secret); + $esl = new eslConnection($this->esl_server, $this->esl_port, $this->esl_secret); $e = $esl->sendRecv("api status"); $body = $e->getBody(); return $body; From silik0n at freeswitch.org Wed Mar 25 09:33:58 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 11:33:58 -0500 Subject: [Freeswitch-svn] [commit] r12778 - in freeswitch/trunk/scripts/contrib/swk/flex/amf-test1: bin-debug src Message-ID: Author: silik0n Date: Wed Mar 25 11:33:58 2009 New Revision: 12778 Log: fix some stuff ad some stuff Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/bin-debug/main.swf ============================================================================== Binary files. No diff available. Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml (original) +++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml Wed Mar 25 11:33:58 2009 @@ -128,7 +128,7 @@ public function dgChangeDomainUserVars(event:DataGridEvent):void { var _rowIndex:Number=event.rowIndex; var _columnIndex:Number= event.columnIndex; - freeswitch.updateDirDomainUserVars(dgDomainUserVars.selectedItem.uid, dgDomainUserVars.selectedItem.name, TextInput(event.currentTarget.itemEditorInstance).text); + freeswitch.updateDirDomainUserVar(dgDomainUserVars.selectedItem.uid, dgDomainUserVars.selectedItem.name, TextInput(event.currentTarget.itemEditorInstance).text); freeswitch.getDirUser(dgDomainUsers.selectedItem.uid); } @@ -399,6 +399,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From mikej at freeswitch.org Wed Mar 25 09:44:17 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 11:44:17 -0500 Subject: [Freeswitch-svn] [commit] r12779 - freeswitch/trunk/libs/sofia-sip Message-ID: Author: mikej Date: Wed Mar 25 11:44:16 2009 New Revision: 12779 Log: move library checks to the end to keep from incorrect -lz added to LIBS from pkg-config to openssl on 64 bit when only 32 bit zlib-devel is installed. This was causing other checks to fail. Modified: freeswitch/trunk/libs/sofia-sip/configure.ac Modified: freeswitch/trunk/libs/sofia-sip/configure.ac ============================================================================== --- freeswitch/trunk/libs/sofia-sip/configure.ac (original) +++ freeswitch/trunk/libs/sofia-sip/configure.ac Wed Mar 25 11:44:16 2009 @@ -95,80 +95,6 @@ fi fi -### checks for libraries -### -------------------- - -SAC_SOFIA_SU -SAC_OPENSSL -SAC_TPORT - -dnl Check is used for testing -PKG_CHECK_MODULES(CHECK, check >= 0.9.4, have_check="yes", have_check="no") -AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes") -if test x"$have_check" = "xyes"; then - AC_DEFINE([HAVE_CHECK], 1, [Define to 1 if check library is available]) -fi -AC_CHECK_HEADERS([fnmatch.h]) - -dnl dl is currently used only in testing -AC_CHECK_LIB([dl], [dlopen], [ - dnl Note: -ldl is not added to LIBS - AC_DEFINE([HAVE_LIBDL], 1, [Define to 1 if dl library is available]) -]) - -### internal modules -### ---------------- -AC_DEFINE([HAVE_SOFIA_SIP], 1, [Define to 1 always]) -AC_DEFINE([HAVE_SOFIA_SRESOLV], 1, [Define to 1 if we use DNS library]) -AC_DEFINE([HAVE_SOFIA_SMIME], 0, [Define to 1 if we use S/MIME library]) - -AC_ARG_ENABLE(stun, -[ --disable-stun disable stun module (enabled)], - , enable_stun=yes) - -if test x$enable_stun = xno ; then - AC_MSG_WARN([** STUN support disabled **]) -elif test x${HAVE_OPENSSL} != x1 ; then - dnl compile STUN only if OPENSSL is available - AC_MSG_WARN([** TLS support for STUN disabled as OpenSSL headers and/or libraries were not found **]) - AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define to 1 if we use STUN library]) -else - AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define to 1 if we use STUN library]) -fi -AM_CONDITIONAL([HAVE_STUN], [test "x$enable_stun" = xyes]) - -AC_ARG_ENABLE(nth, -[ --disable-nth disable HTTP-related modules nth and http (enabled)], - , enable_nth=yes) -AM_CONDITIONAL([HAVE_NTH], [test "x$enable_nth" = xyes]) -if test x$enable_nth = xyes ; then - AC_DEFINE([HAVE_SOFIA_NTH], 1, [Define to 1 if we use NTH library]) - AC_DEFINE([HAVE_SOFIA_HTTP], 1, [Define to 1 if we use HTTP parser library]) -fi - -dnl Disable NTLM support by default -AC_ARG_ENABLE(ntlm, -[ --enable-ntlm enable NTLM support [[disabled]]], - , enable_ntlm=no) - -if test x$enable_ntlm = xyes ; then - AC_DEFINE([HAVE_SOFIA_NTLM], 1, [Define to 1 if we use NTLM library]) -fi -AM_CONDITIONAL([HAVE_NTLM], [test "x$enable_ntlm" = xyes]) - - -AC_DEFINE([HAVE_SRTP], 0, [Define to 1 if we use SRTP]) -AC_DEFINE([HAVE_UPNP], 0, [Define to 1 if we use UPnP]) - - -AC_ARG_ENABLE(memleak_log, -[ --enable-memleak-log enable logging of possible memory leaks [[disabled]]], - , enable_memleak_log=no) - -if test x$enable_memleak_log = xyes ; then - AC_DEFINE([HAVE_MEMLEAK_LOG], 1, [Define to 1 for memory-leak-related logging]) -fi - ### checks for header files ### ----------------------- AC_HEADER_STDC @@ -296,6 +222,80 @@ AC_DEV_URANDOM +### checks for libraries +### -------------------- + +SAC_SOFIA_SU +SAC_OPENSSL +SAC_TPORT + +dnl Check is used for testing +PKG_CHECK_MODULES(CHECK, check >= 0.9.4, have_check="yes", have_check="no") +AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes") +if test x"$have_check" = "xyes"; then + AC_DEFINE([HAVE_CHECK], 1, [Define to 1 if check library is available]) +fi +AC_CHECK_HEADERS([fnmatch.h]) + +dnl dl is currently used only in testing +AC_CHECK_LIB([dl], [dlopen], [ + dnl Note: -ldl is not added to LIBS + AC_DEFINE([HAVE_LIBDL], 1, [Define to 1 if dl library is available]) +]) + +### internal modules +### ---------------- +AC_DEFINE([HAVE_SOFIA_SIP], 1, [Define to 1 always]) +AC_DEFINE([HAVE_SOFIA_SRESOLV], 1, [Define to 1 if we use DNS library]) +AC_DEFINE([HAVE_SOFIA_SMIME], 0, [Define to 1 if we use S/MIME library]) + +AC_ARG_ENABLE(stun, +[ --disable-stun disable stun module (enabled)], + , enable_stun=yes) + +if test x$enable_stun = xno ; then + AC_MSG_WARN([** STUN support disabled **]) +elif test x${HAVE_OPENSSL} != x1 ; then + dnl compile STUN only if OPENSSL is available + AC_MSG_WARN([** TLS support for STUN disabled as OpenSSL headers and/or libraries were not found **]) + AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define to 1 if we use STUN library]) +else + AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define to 1 if we use STUN library]) +fi +AM_CONDITIONAL([HAVE_STUN], [test "x$enable_stun" = xyes]) + +AC_ARG_ENABLE(nth, +[ --disable-nth disable HTTP-related modules nth and http (enabled)], + , enable_nth=yes) +AM_CONDITIONAL([HAVE_NTH], [test "x$enable_nth" = xyes]) +if test x$enable_nth = xyes ; then + AC_DEFINE([HAVE_SOFIA_NTH], 1, [Define to 1 if we use NTH library]) + AC_DEFINE([HAVE_SOFIA_HTTP], 1, [Define to 1 if we use HTTP parser library]) +fi + +dnl Disable NTLM support by default +AC_ARG_ENABLE(ntlm, +[ --enable-ntlm enable NTLM support [[disabled]]], + , enable_ntlm=no) + +if test x$enable_ntlm = xyes ; then + AC_DEFINE([HAVE_SOFIA_NTLM], 1, [Define to 1 if we use NTLM library]) +fi +AM_CONDITIONAL([HAVE_NTLM], [test "x$enable_ntlm" = xyes]) + + +AC_DEFINE([HAVE_SRTP], 0, [Define to 1 if we use SRTP]) +AC_DEFINE([HAVE_UPNP], 0, [Define to 1 if we use UPnP]) + + +AC_ARG_ENABLE(memleak_log, +[ --enable-memleak-log enable logging of possible memory leaks [[disabled]]], + , enable_memleak_log=no) + +if test x$enable_memleak_log = xyes ; then + AC_DEFINE([HAVE_MEMLEAK_LOG], 1, [Define to 1 for memory-leak-related logging]) +fi + ### output ### ------ From brian at freeswitch.org Wed Mar 25 09:45:43 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 11:45:43 -0500 Subject: [Freeswitch-svn] [commit] r12780 - freeswitch/trunk/src/mod/applications/mod_soundtouch Message-ID: Author: brian Date: Wed Mar 25 11:45:43 2009 New Revision: 12780 Log: MODAPP-243 Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile (original) +++ freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile Wed Mar 25 11:45:43 2009 @@ -14,6 +14,7 @@ $(GETLIB) $(VERSION).tar.gz cd $(DIRECTORY) && ./configure $(DEFAULT_ARGS) --enable-integer-samples -$(LA): $(DIRECTORY) +$(LA): + $(DIRECTORY) cd $(DIRECTORY) && $(MAKE) $(TOUCH_TARGET) From mikej at freeswitch.org Wed Mar 25 09:59:25 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 11:59:25 -0500 Subject: [Freeswitch-svn] [commit] r12781 - freeswitch/trunk/src/mod/applications/mod_soundtouch Message-ID: Author: mikej Date: Wed Mar 25 11:59:25 2009 New Revision: 12781 Log: revert r12780/MODAPP-243 Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile (original) +++ freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile Wed Mar 25 11:59:25 2009 @@ -14,7 +14,6 @@ $(GETLIB) $(VERSION).tar.gz cd $(DIRECTORY) && ./configure $(DEFAULT_ARGS) --enable-integer-samples -$(LA): - $(DIRECTORY) +$(LA): $(DIRECTORY) cd $(DIRECTORY) && $(MAKE) $(TOUCH_TARGET) From anthm at freeswitch.org Wed Mar 25 11:47:47 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 13:47:47 -0500 Subject: [Freeswitch-svn] [commit] r12782 - freeswitch/trunk/src/mod/applications/mod_fifo Message-ID: Author: anthm Date: Wed Mar 25 13:47:47 2009 New Revision: 12782 Log: fix incorrect var name Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original) +++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Wed Mar 25 13:47:47 2009 @@ -464,7 +464,7 @@ channel = switch_core_session_get_channel(session); - if ((member_wait = switch_channel_get_variable(channel, "member_wait"))) { + if ((member_wait = switch_channel_get_variable(channel, "fifo_member_wait")) || (member_wait = switch_channel_get_variable(channel, "member_wait"))) { if (strcasecmp(member_wait, "wait") && strcasecmp(member_wait, "nowait")) { member_wait = NULL; } From mikej at freeswitch.org Wed Mar 25 12:34:37 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 14:34:37 -0500 Subject: [Freeswitch-svn] [commit] r12783 - freeswitch/trunk/src/mod/applications/mod_soundtouch Message-ID: Author: mikej Date: Wed Mar 25 14:34:37 2009 New Revision: 12783 Log: fix libsoundtouch build dependencies after a configure failure (MODAPP-243) Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile (original) +++ freeswitch/trunk/src/mod/applications/mod_soundtouch/Makefile Wed Mar 25 14:34:37 2009 @@ -1,4 +1,3 @@ - VERSION=soundtouch-1.3.1 DIRECTORY=$(switch_srcdir)/libs/$(VERSION) LA=$(DIRECTORY)/source/SoundTouch/.libs/libSoundTouch.a @@ -10,10 +9,12 @@ include $(BASE)/build/modmake.rules -$(DIRECTORY): +$(DIRECTORY)/Makefile $(DIRECTORY)/config.status: $(GETLIB) $(VERSION).tar.gz cd $(DIRECTORY) && ./configure $(DEFAULT_ARGS) --enable-integer-samples + $(TOUCH_TARGET) -$(LA): $(DIRECTORY) +$(LA): $(DIRECTORY)/Makefile $(DIRECTORY)/config.status cd $(DIRECTORY) && $(MAKE) $(TOUCH_TARGET) + From anthm at freeswitch.org Wed Mar 25 13:07:41 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 15:07:41 -0500 Subject: [Freeswitch-svn] [commit] r12784 - in freeswitch/trunk/src: . include mod/event_handlers/mod_cdr_csv Message-ID: Author: anthm Date: Wed Mar 25 15:07:40 2009 New Revision: 12784 Log: rearrange hangup callflow to do more work in the session's own thread Modified: freeswitch/trunk/src/include/switch_channel.h freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_core_state_machine.c Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Wed Mar 25 15:07:40 2009 @@ -511,6 +511,7 @@ SWITCH_DECLARE(void) switch_channel_set_app_flag(switch_channel_t *channel, uint32_t flags); SWITCH_DECLARE(void) switch_channel_clear_app_flag(switch_channel_t *channel, uint32_t flags); SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags); +SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel); /** @} */ Modified: freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c Wed Mar 25 15:07:40 2009 @@ -209,7 +209,7 @@ free(buf); } } - + g_template_str = (const char *) switch_core_hash_find(globals.template_hash, globals.default_template); if ((accountcode = switch_channel_get_variable(channel, "ACCOUNTCODE"))) { Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Wed Mar 25 15:07:40 2009 @@ -609,10 +609,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check) { + switch_status_t status = SWITCH_STATUS_FALSE; + switch_assert(channel != NULL); + switch_mutex_lock(channel->profile_mutex); if (channel->variables && !switch_strlen_zero(varname)) { - switch_mutex_lock(channel->profile_mutex); switch_event_del_header(channel->variables, varname); if (!switch_strlen_zero(value)) { int ok = 1; @@ -626,11 +628,11 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname); } } - switch_mutex_unlock(channel->profile_mutex); - return SWITCH_STATUS_SUCCESS; + status = SWITCH_STATUS_SUCCESS; } + switch_mutex_unlock(channel->profile_mutex); - return SWITCH_STATUS_FALSE; + return status; } switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data); @@ -640,10 +642,12 @@ int ret = 0; char *data; va_list ap; + switch_status_t status = SWITCH_STATUS_FALSE; + switch_assert(channel != NULL); + switch_mutex_lock(channel->profile_mutex); if (channel->variables && !switch_strlen_zero(varname)) { - switch_mutex_lock(channel->profile_mutex); switch_event_del_header(channel->variables, varname); va_start(ap, fmt); @@ -657,11 +661,11 @@ switch_event_base_add_header(channel->variables, SWITCH_STACK_BOTTOM, varname, data); - switch_mutex_unlock(channel->profile_mutex); - return SWITCH_STATUS_SUCCESS; + status = SWITCH_STATUS_SUCCESS; } + switch_mutex_unlock(channel->profile_mutex); - return SWITCH_STATUS_FALSE; + return status; } @@ -1582,6 +1586,16 @@ } +SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel) +{ + if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { + switch_mutex_lock(channel->profile_mutex); + channel->caller_profile->times->hungup = switch_micro_time_now(); + switch_mutex_unlock(channel->profile_mutex); + } +} + + SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel, const char *file, const char *func, int line, switch_call_cause_t hangup_cause) { @@ -1590,17 +1604,8 @@ switch_channel_clear_flag(channel, CF_BLOCK_STATE); if (channel->state < CS_HANGUP) { - switch_event_t *event; switch_channel_state_t last_state = channel->state; - if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { - switch_mutex_lock(channel->profile_mutex); - channel->caller_profile->times->hungup = switch_micro_time_now(); - switch_mutex_unlock(channel->profile_mutex); - } - - switch_channel_stop_broadcast(channel); - switch_mutex_lock(channel->state_mutex); channel->state = CS_HANGUP; switch_mutex_unlock(channel->state_mutex); @@ -1608,21 +1613,9 @@ channel->hangup_cause = hangup_cause; switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause)); - - switch_channel_set_variable(channel, "hangup_cause", switch_channel_cause2str(channel->hangup_cause)); - switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause), NULL); switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL); switch_core_session_signal_state_change(channel->session); - - switch_channel_set_timestamps(channel); - - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", switch_channel_cause2str(channel->hangup_cause)); - switch_channel_event_set_data(channel, event); - switch_event_fire(&event); - } - } return channel->state; Modified: freeswitch/trunk/src/switch_core_state_machine.c ============================================================================== --- freeswitch/trunk/src/switch_core_state_machine.c (original) +++ freeswitch/trunk/src/switch_core_state_machine.c Wed Mar 25 15:07:40 2009 @@ -424,8 +424,19 @@ { const char *hook_var; switch_core_session_t *use_session = NULL; - + switch_call_cause_t cause = switch_channel_get_cause(session->channel); + switch_event_t *event; + + switch_channel_set_hangup_time(session->channel); + switch_core_media_bug_remove_all(session); + + switch_channel_stop_broadcast(session->channel); + + switch_channel_set_variable(session->channel, "hangup_cause", switch_channel_cause2str(cause)); + switch_channel_presence(session->channel, "unavailable", switch_channel_cause2str(cause), NULL); + + switch_channel_set_timestamps(session->channel); STATE_MACRO(hangup, "HANGUP"); @@ -462,8 +473,16 @@ } switch_safe_free(stream.data); } + + if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", switch_channel_cause2str(cause)); + switch_channel_event_set_data(session->channel, event); + switch_event_fire(&event); + } + + switch_channel_set_state(session->channel, CS_REPORTING); } - switch_channel_set_state(session->channel, CS_REPORTING); + break; case CS_INIT: /* Basic setup tasks */ STATE_MACRO(init, "INIT"); From anthm at freeswitch.org Wed Mar 25 13:14:07 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 15:14:07 -0500 Subject: [Freeswitch-svn] [commit] r12785 - in freeswitch/trunk/src: include mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Wed Mar 25 15:14:07 2009 New Revision: 12785 Log: add username and realm to sip db Modified: freeswitch/trunk/src/include/switch_utils.h freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Modified: freeswitch/trunk/src/include/switch_utils.h ============================================================================== --- freeswitch/trunk/src/include/switch_utils.h (original) +++ freeswitch/trunk/src/include/switch_utils.h Wed Mar 25 15:14:07 2009 @@ -57,6 +57,7 @@ SWITCH_DECLARE(int) switch_isxdigit(int c); #define switch_goto_status(_status, _label) status = _status; goto _label +#define switch_goto_int(_n, _i, _label) _n = _i; goto _label #define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval))) #define SWITCH_SMAX 32767 #define SWITCH_SMIN -32768 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 25 15:14:07 2009 @@ -1488,14 +1488,19 @@ } cb->stream->write_function(cb->stream, - "Call-ID: \t%s\n" - "User: \t%s@%s\n" - "Contact: \t%s\n" - "Agent: \t%s\n" - "Status: \t%s(%s) EXP(%s)\n" - "Host: \t%s\n\n", + "Call-ID: \t%s\n" + "User: \t%s@%s\n" + "Contact: \t%s\n" + "Agent: \t%s\n" + "Status: \t%s(%s) EXP(%s)\n" + "Host: \t%s\n" + "IP: \t%s\n" + "Port: \t%s\n" + "Auth-User: \t%s\n" + "Auth-Realm: \t%s\n\n", switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]), - switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11])); + switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]), + switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15])); return 0; } @@ -1516,16 +1521,22 @@ } cb->stream->write_function(cb->stream, - "\n" - "%s\n" - "%s@%s\n" - "%s\n" - "%s\n" - "%s(%s) EXP(%s)\n" - "%s\n" - "\n", - switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_amp_encode(switch_str_nil(argv[3]),xmlbuf,buflen), - switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11])); + " \n" + " %s\n" + " %s@%s\n" + " %s\n" + " %s\n" + " %s(%s) exp(%s)\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " \n", + switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), + switch_amp_encode(switch_str_nil(argv[3]),xmlbuf,buflen), + switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]), + switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15])); return 0; } @@ -1639,13 +1650,15 @@ if (argv[4]) { if (!strcasecmp(argv[3], "pres")) { sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname" + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm" " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", profile->name, argv[4]); } } else { sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname" + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm" " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", profile->name, argv[3]); } @@ -1653,7 +1666,8 @@ if (!sql) { sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname" + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm" " from sip_registrations where profile_name='%q'", profile->name); } @@ -1739,28 +1753,29 @@ if (!strcasecmp(argv[0], "gateway")) { if ((gp = sofia_reg_find_gateway(argv[1]))) { switch_assert(gp->state < REG_STATE_LAST); - stream->write_function(stream, "%s\n", header); - stream->write_function(stream, "\n"); - stream->write_function(stream, "%s\n", switch_str_nil(gp->name)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->register_scheme)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->register_realm)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->register_username)); - stream->write_function(stream, "%s\n", switch_strlen_zero(gp->register_password) ? "no" : "yes"); - stream->write_function(stream, "%s\n", switch_amp_encode(switch_str_nil(gp->register_from),xmlbuf,buflen)); - stream->write_function(stream, "%s\n", switch_amp_encode(switch_str_nil(gp->register_contact),xmlbuf,buflen)); - stream->write_function(stream, "%s\n", switch_amp_encode(switch_str_nil(gp->extension),xmlbuf,buflen)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->register_to)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->register_proxy)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->register_context)); - stream->write_function(stream, "%s\n", switch_str_nil(gp->expires_str)); - stream->write_function(stream, "%d\n", gp->freq); - stream->write_function(stream, "%d\n", gp->ping); - stream->write_function(stream, "%d\n", gp->ping_freq); - stream->write_function(stream, "%s\n", sofia_state_names[gp->state]); - stream->write_function(stream, "%s%s\n", status_names[gp->status], gp->pinging ? " (ping)" : ""); - stream->write_function(stream, "%d\n", gp->ib_calls); - stream->write_function(stream, "%d\n", gp->ob_calls); - stream->write_function(stream, "\n"); + stream->write_function(stream, "%s\n", header); + stream->write_function(stream, " \n"); + stream->write_function(stream, " %s\n", switch_str_nil(gp->name)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->register_scheme)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->register_realm)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->register_username)); + stream->write_function(stream, " %s\n", switch_strlen_zero(gp->register_password) ? "no" : "yes"); + stream->write_function(stream, " %s\n", switch_amp_encode(switch_str_nil(gp->register_from),xmlbuf,buflen)); + stream->write_function(stream, " %s\n", switch_amp_encode(switch_str_nil(gp->register_contact),xmlbuf,buflen)); + stream->write_function(stream, " %s\n", switch_amp_encode(switch_str_nil(gp->extension),xmlbuf,buflen)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->register_to)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->register_proxy)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->register_context)); + stream->write_function(stream, " %s\n", switch_str_nil(gp->expires_str)); + stream->write_function(stream, " %d\n", gp->freq); + stream->write_function(stream, " %d\n", gp->ping); + stream->write_function(stream, " %d\n", gp->ping_freq); + stream->write_function(stream, " %s\n", sofia_state_names[gp->state]); + stream->write_function(stream, " %s%s\n", status_names[gp->status], gp->pinging ? " (ping)" : ""); + stream->write_function(stream, " %d\n", gp->ib_calls); + stream->write_function(stream, " %d\n", gp->ob_calls); + + stream->write_function(stream, " \n"); sofia_reg_release_gateway(gp); } else { stream->write_function(stream, "Invalid Gateway!\n"); @@ -1772,57 +1787,47 @@ if ((argv[1]) && (profile = sofia_glue_find_profile(argv[1]))) { if (!argv[2] || strcasecmp(argv[2], "reg")) { stream->write_function(stream, "%s\n", header); - stream->write_function(stream, "\n"); - stream->write_function(stream, "\n"); - stream->write_function(stream, "%s\n", switch_str_nil(argv[1])); - stream->write_function(stream, "%s\n", profile->domain_name ? profile->domain_name : "N/A"); + stream->write_function(stream, " \n"); + stream->write_function(stream, " \n"); + stream->write_function(stream, " %s\n", switch_str_nil(argv[1])); + stream->write_function(stream, " %s\n", profile->domain_name ? profile->domain_name : "N/A"); if (strcasecmp(argv[1], profile->name)) { - stream->write_function(stream, "%s\n", switch_str_nil(profile->name)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->name)); } - stream->write_function(stream, "%s\n", switch_str_nil(profile->dbname)); - stream->write_function(stream, "%s\n", switch_str_nil(profile->presence_hosts)); - stream->write_function(stream, "%s\n", switch_str_nil(profile->dialplan)); - stream->write_function(stream, "%s\n", switch_str_nil(profile->context)); - stream->write_function(stream, "%s\n", + stream->write_function(stream, " %s\n", switch_str_nil(profile->dbname)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->presence_hosts)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->dialplan)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->context)); + stream->write_function(stream, " %s\n", switch_strlen_zero(profile->challenge_realm) ? "auto_to" : profile->challenge_realm); - stream->write_function(stream, "%s\n", switch_str_nil(profile->rtpip)); - if (profile->extrtpip) { - stream->write_function(stream, "%s\n", profile->extrtpip); - } + stream->write_function(stream, " %s\n", switch_str_nil(profile->rtpip)); + stream->write_function(stream, " %s\n", profile->extrtpip); + stream->write_function(stream, " %s\n", switch_str_nil(profile->sipip)); + stream->write_function(stream, " %s\n", profile->extsipip); + stream->write_function(stream, " %s\n", switch_str_nil(profile->url)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->bindurl)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->tls_url)); + stream->write_function(stream, " %s\n", switch_str_nil(profile->tls_bindurl)); + stream->write_function(stream, " %s\n", switch_strlen_zero(profile->hold_music) ? "N/A" : profile->hold_music); + stream->write_function(stream, " %s\n", switch_strlen_zero(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); + stream->write_function(stream, " %s\n", switch_str_nil(profile->codec_string)); + stream->write_function(stream, " %d\n", profile->te); + stream->write_function(stream, " rfc2833\n"); + stream->write_function(stream, " info\n"); + stream->write_function(stream, " none\n"); + stream->write_function(stream, " %d\n", profile->cng_pt); + stream->write_function(stream, " %d\n", profile->session_timeout); + stream->write_function(stream, " %d\n", profile->max_proceeding); + stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false"); + stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false"); + stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false"); + stream->write_function(stream, " %s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false"); + stream->write_function(stream, " %s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false"); + stream->write_function(stream, " %s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false"); - stream->write_function(stream, "%s\n", switch_str_nil(profile->sipip)); - if (profile->extsipip) { - stream->write_function(stream, "%s\n", profile->extsipip); - } - stream->write_function(stream, "%s\n", switch_str_nil(profile->url)); - stream->write_function(stream, "%s\n", switch_str_nil(profile->bindurl)); - if (sofia_test_pflag(profile, PFLAG_TLS)) { - stream->write_function(stream, "%s\n", switch_str_nil(profile->tls_url)); - stream->write_function(stream, "%s\n", switch_str_nil(profile->tls_bindurl)); - } - stream->write_function(stream, "%s\n", switch_strlen_zero(profile->hold_music) ? "N/A" : profile->hold_music); - stream->write_function(stream, "%s\n", switch_strlen_zero(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); - stream->write_function(stream, "%s\n", switch_str_nil(profile->codec_string)); - stream->write_function(stream, "%d\n", profile->te); - if (profile->dtmf_type == DTMF_2833) { - stream->write_function(stream, "rfc2833\n"); - } else if (profile->dtmf_type == DTMF_INFO) { - stream->write_function(stream, "info\n"); - } else { - stream->write_function(stream, "none\n"); - } - stream->write_function(stream, "%d\n", profile->cng_pt); - stream->write_function(stream, "%d\n", profile->session_timeout); - stream->write_function(stream, "%d\n", profile->max_proceeding); - stream->write_function(stream, "%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false"); - stream->write_function(stream, "%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false"); - stream->write_function(stream, "%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false"); - stream->write_function(stream, "%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false"); - stream->write_function(stream, "%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false"); - stream->write_function(stream, "%s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false"); } - stream->write_function(stream, "\n"); - stream->write_function(stream, "\n"); + stream->write_function(stream, " \n"); + stream->write_function(stream, " \n"); cb.profile = profile; cb.stream = stream; @@ -1831,13 +1836,15 @@ if (argv[4]) { if (!strcasecmp(argv[3], "pres")) { sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname" + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm" " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", profile->name, argv[4]); } } else { sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname" + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm" " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", profile->name, argv[3]); } @@ -1845,7 +1852,8 @@ if (!sql) { sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname" + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm" " from sip_registrations where profile_name='%q'", profile->name); } @@ -1853,8 +1861,8 @@ sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, show_reg_callback_xml, &cb); free(sql); - stream->write_function(stream, "\n"); - stream->write_function(stream, "\n"); + stream->write_function(stream, "\n"); + stream->write_function(stream, "\n"); sofia_glue_release_profile(profile); } else { Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Wed Mar 25 15:14:07 2009 @@ -677,8 +677,10 @@ void sofia_presence_cancel(void); switch_status_t config_sofia(int reload, char *profile_name); void sofia_reg_auth_challenge(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_regtype_t regtype, const char *realm, int stale); -auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, sip_t const *sip, const char *regstr, - char *np, size_t nplen, char *ip, switch_event_t **v_event, long exptime, sofia_regtype_t regtype, const char *to_user); +auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, + sip_t const *sip, const char *regstr, char *np, size_t nplen, char *ip, switch_event_t **v_event, + long exptime, sofia_regtype_t regtype, const char *to_user, switch_event_t **auth_params); + void sofia_reg_handle_sip_r_challenge(int status, char const *phrase, Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 25 15:14:07 2009 @@ -406,7 +406,7 @@ get_addr(network_ip, sizeof(network_ip), addrinfo->ai_addr, addrinfo->ai_addrlen); auth_res = sofia_reg_parse_auth(profile, authorization, sip, (char *) sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key), network_ip, NULL, 0, - REG_INVITE, NULL); + REG_INVITE, NULL, NULL); } if (auth_res != AUTH_OK) { @@ -579,6 +579,12 @@ char *profile_name = switch_event_get_header(event, "orig-profile-name"); char *to_user = switch_event_get_header(event, "orig-to-user"); char *presence_hosts = switch_event_get_header(event, "presence-hosts"); + char *network_ip = switch_event_get_header(event, "network-ip"); + char *network_port = switch_event_get_header(event, "network-port"); + char *username = switch_event_get_header(event, "username"); + char *realm = switch_event_get_header(event, "realm"); + + sofia_profile_t *profile = NULL; char guess_ip4[256]; @@ -606,10 +612,11 @@ switch_find_local_ip(guess_ip4, sizeof(guess_ip4), AF_INET); sql = switch_mprintf("insert into sip_registrations " - "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname) " - "values ('%q', '%q','%q','%q','Registered', '%q', %ld, '%q', '%q', '%q','%q','%q')", + "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires," + "user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm) " + "values ('%q', '%q','%q','%q','Registered', '%q', %ld, '%q', '%q', '%q','%q','%q','%q','%q','%q','%q')", call_id, from_user, from_host, presence_hosts, contact_str, rpid, expires, user_agent, to_user, guess_ip4, - profile_name,mod_sofia_globals.hostname); + profile_name,mod_sofia_globals.hostname, network_ip, network_port, username, realm); if (sql) { sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 25 15:14:07 2009 @@ -3191,7 +3191,9 @@ " profile_name VARCHAR(255),\n" " hostname VARCHAR(255),\n" " network_ip VARCHAR(255),\n" - " network_port VARCHAR(6)\n" + " network_port VARCHAR(6),\n" + " sip_username VARCHAR(255),\n" + " sip_realm VARCHAR(255)\n" ");\n"; @@ -3289,6 +3291,8 @@ "create index sr_status on sip_registrations (status)", "create index sr_network_ip on sip_registrations (network_ip)", "create index sr_network_port on sip_registrations (network_port)", + "create index sr_sip_username on sip_registrations (sip_username)", + "create index sr_sip_realm on sip_registrations (sip_realm)", "create index ss_call_id on sip_subscriptions (call_id)", "create index ss_hostname on sip_subscriptions (hostname)", "create index ss_sip_user on sip_subscriptions (sip_user)", @@ -3329,7 +3333,7 @@ test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' " "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " - "and network_ip!='-1' and network_port!='-1'", + "and network_ip!='-1' and network_port!='-1' and sip_username != '-1'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { @@ -3401,7 +3405,7 @@ test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' " "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " - "and network_ip!='-1' and network_port!='-1'", + "and network_ip!='-1' and network_port!='-1' and sip_username != '-1'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql); @@ -3465,6 +3469,9 @@ switch_core_db_exec(profile->master_db, "create index if not exists sr_status on sip_registrations (status)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists sr_network_ip on sip_registrations (network_ip)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists sr_network_port on sip_registrations (network_port)", NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists sr_sip_username on sip_registrations (sip_username)", NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists sr_sip_realm on sip_registrations (sip_realm)", NULL, NULL, NULL); + switch_core_db_exec(profile->master_db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL); switch_core_db_exec(profile->master_db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Wed Mar 25 15:14:07 2009 @@ -699,6 +699,8 @@ char received_data[128] = ""; char *path_val = NULL; su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua)); + switch_event_t *auth_params = NULL; + int r = 0; /* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */ switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL); @@ -723,7 +725,7 @@ if (!to_user || !to_host) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete from header\n"); nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END()); - return 1; + switch_goto_int(r, 1, end); } if (!reg_host) { @@ -840,7 +842,7 @@ if (authorization) { char *v_contact_str; if ((auth_res = sofia_reg_parse_auth(profile, authorization, sip, sip->sip_request->rq_method_name, - key, keylen, network_ip, v_event, exptime, regtype, to_user)) == AUTH_STALE) { + key, keylen, network_ip, v_event, exptime, regtype, to_user, &auth_params)) == AUTH_STALE) { stale = 1; } @@ -913,7 +915,7 @@ } else { nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END()); } - return 1; + switch_goto_int(r, 1, end); } } @@ -934,12 +936,12 @@ } else { sofia_reg_auth_challenge(nua, profile, nh, regtype, realm, stale); } - return 1; + switch_goto_int(r, 1, end); } reg: if (regtype != REG_REGISTER) { - return 0; + switch_goto_int(r, 0, end); } call_id = sip->sip_call_id->i_id; @@ -959,6 +961,13 @@ if (exptime) { const char *agent = "dunno"; char guess_ip4[256]; + const char *username = "unknown"; + const char *realm = reg_host; + + if (auth_params) { + username = switch_event_get_header(auth_params, "sip_auth_username"); + realm = switch_event_get_header(auth_params, "sip_auth_realm"); + } if (sip->sip_user_agent) { agent = sip->sip_user_agent->g_string; @@ -979,11 +988,12 @@ switch_find_local_ip(guess_ip4, sizeof(guess_ip4), AF_INET); sql = switch_mprintf("insert into sip_registrations " - "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port) " - "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q')", + "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires," + "user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm) " + "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q')", call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host, contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2, - agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c); + agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm); if (sql) { sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); @@ -1006,6 +1016,8 @@ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-host", from_host); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "network-ip", network_ip); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "network-port", network_port_c); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "username", username); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "realm", realm); switch_event_fire(&s_event); } @@ -1154,10 +1166,17 @@ } } - return 1; + switch_goto_int(r, 1, end); } - return 0; + + end: + + if (auth_params) { + switch_event_destroy(&auth_params); + } + + return r; } @@ -1458,8 +1477,19 @@ } -auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, sip_t const *sip, const char *regstr, - char *np, size_t nplen, char *ip, switch_event_t **v_event, long exptime, sofia_regtype_t regtype, const char *to_user) +auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, + sip_authorization_t const *authorization, + sip_t const *sip, + const char *regstr, + char *np, + size_t nplen, + char *ip, + switch_event_t **v_event, + long exptime, + sofia_regtype_t + regtype, + const char *to_user, + switch_event_t **auth_params) { int indexnum; const char *cur; @@ -1600,6 +1630,10 @@ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_method", (sip && sip->sip_request) ? sip->sip_request->rq_method_name : NULL); + if (auth_params) { + switch_event_dup(auth_params, params); + } + if (!switch_strlen_zero(profile->reg_domain)) { domain_name = profile->reg_domain; From anthm at freeswitch.org Wed Mar 25 13:19:28 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 15:19:28 -0500 Subject: [Freeswitch-svn] [commit] r12786 - freeswitch/trunk/src/mod/applications/mod_commands Message-ID: Author: anthm Date: Wed Mar 25 15:19:28 2009 New Revision: 12786 Log: MODAPP-242 Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original) +++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Wed Mar 25 15:19:28 2009 @@ -359,7 +359,6 @@ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", user); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "type", type); - switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "key", key); if (key && type && switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, NULL, params) == SWITCH_STATUS_SUCCESS) { if (!strcmp(type, "attr")) { From anthm at freeswitch.org Wed Mar 25 14:01:53 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 16:01:53 -0500 Subject: [Freeswitch-svn] [commit] r12787 - freeswitch/trunk/src/mod/applications/mod_conference Message-ID: Author: anthm Date: Wed Mar 25 16:01:53 2009 New Revision: 12787 Log: add lock caller_control Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Wed Mar 25 16:01:53 2009 @@ -93,7 +93,8 @@ CALLER_CONTROL_HANGUP, CALLER_CONTROL_MENU, CALLER_CONTROL_DIAL, - CALLER_CONTROL_EVENT + CALLER_CONTROL_EVENT, + CALLER_CONTROL_LOCK } caller_control_t; /* forward declaration for conference_obj and caller_control */ @@ -1280,6 +1281,42 @@ } } + +static void conference_loop_fn_lock_toggle(conference_member_t *member, caller_control_action_t *action) +{ + switch_event_t *event; + + if (member == NULL) + return; + + if (!switch_test_flag(member->conference, CFLAG_LOCKED)) { + if (member->conference->is_locked_sound) { + conference_play_file(member->conference, member->conference->is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0); + } + + switch_set_flag_locked(member->conference, CFLAG_LOCKED); + if (test_eflag(member->conference, EFLAG_LOCK) && + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + conference_add_event_data(member->conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "lock"); + switch_event_fire(&event); + } + } else { + if (member->conference->is_unlocked_sound) { + conference_play_file(member->conference, member->conference->is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0); + } + + switch_clear_flag_locked(member->conference, CFLAG_LOCKED); + if (test_eflag(member->conference, EFLAG_UNLOCK) && + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + conference_add_event_data(member->conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "unlock"); + switch_event_fire(&event); + } + } + +} + static void conference_loop_fn_deafmute_toggle(conference_member_t *member, caller_control_action_t *action) { if (member == NULL) @@ -1755,7 +1792,8 @@ {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero}, {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn}, {"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup}, - {"event", NULL, CALLER_CONTROL_EVENT, conference_loop_fn_event} + {"event", NULL, CALLER_CONTROL_EVENT, conference_loop_fn_event}, + {"lock", NULL, CALLER_CONTROL_LOCK, conference_loop_fn_lock_toggle} }; #define CCFNTBL_QTY (sizeof(ccfntbl)/sizeof(ccfntbl[0])) From mikej at freeswitch.org Wed Mar 25 19:45:05 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 21:45:05 -0500 Subject: [Freeswitch-svn] [commit] r12788 - freeswitch/trunk/build/config Message-ID: Author: mikej Date: Wed Mar 25 21:45:04 2009 New Revision: 12788 Log: fix odbc detection to not try to use odbc when no headers are installed Modified: freeswitch/trunk/build/config/odbc.m4 Modified: freeswitch/trunk/build/config/odbc.m4 ============================================================================== --- freeswitch/trunk/build/config/odbc.m4 (original) +++ freeswitch/trunk/build/config/odbc.m4 Wed Mar 25 21:45:04 2009 @@ -135,7 +135,7 @@ fi AC_MSG_CHECKING(whether to include odbc) - if test "X$ac_cv_odbc_where_lib" = "X" -a "X$ac_cv_odbc_where_inc" = "X"; then + if test "X$ac_cv_odbc_where_lib" = "X" -o "X$ac_cv_odbc_where_inc" = "X"; then ac_cv_found_odbc=no AC_MSG_RESULT(no) else From nmartin at freeswitch.org Wed Mar 25 20:38:22 2009 From: nmartin at freeswitch.org (FreeSWITCH SVN) Date: Wed, 25 Mar 2009 22:38:22 -0500 Subject: [Freeswitch-svn] [commit] r12789 - freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial Message-ID: Author: nmartin Date: Wed Mar 25 22:38:22 2009 New Revision: 12789 Log: for some reason, Address Book started adding "-" between numbers added replace function to clean up phone numbers before passing to FS Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.scpt Modified: freeswitch/trunk/scripts/contrib/nmartin/osx_address_book_dial/fsdial.scpt ============================================================================== Binary files. No diff available. From gmaruzz at freeswitch.org Thu Mar 26 03:29:28 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 05:29:28 -0500 Subject: [Freeswitch-svn] [commit] r12790 - freeswitch/trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Mar 26 05:29:28 2009 New Revision: 12790 Log: skypiax: fixed transferred call to skype user busy in another call: was transferring using the interface name, not the skype_user. Fixed as per Jira: MODSKYPIAX-28 Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Thu Mar 26 05:29:28 2009 @@ -245,11 +245,11 @@ if (available_skypiax_interface) { /* there is a skypiax interface idle, let's transfer the call to it */ DEBUGA_SKYPE - ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", + ("Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, - available_skypiax_interface->name, id); + available_skypiax_interface->name, available_skypiax_interface->skype_user, id); sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, - available_skypiax_interface->name); + available_skypiax_interface->skype_user); } else { /* no skypiax interfaces idle, let's refuse the call */ DEBUGA_SKYPE From anthm at freeswitch.org Thu Mar 26 08:07:44 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 10:07:44 -0500 Subject: [Freeswitch-svn] [commit] r12791 - freeswitch/trunk/src/mod/applications/mod_fifo Message-ID: Author: anthm Date: Thu Mar 26 10:07:44 2009 New Revision: 12791 Log: fire events on bridge in fifo Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original) +++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Thu Mar 26 10:07:44 2009 @@ -1255,6 +1255,18 @@ switch_core_media_bug_resume(other_session); switch_process_import(session, other_channel, "fifo_caller_consumer_import"); switch_process_import(other_session, channel, "fifo_consumer_caller_import"); + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-consumer"); + switch_event_fire(&event); + } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(other_channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-caller"); + switch_event_fire(&event); + } switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session); switch_core_media_bug_pause(session); switch_core_media_bug_pause(other_session); From anthm at freeswitch.org Thu Mar 26 09:06:25 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 11:06:25 -0500 Subject: [Freeswitch-svn] [commit] r12792 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Thu Mar 26 11:06:25 2009 New Revision: 12792 Log: MODENDP-207 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Thu Mar 26 11:06:25 2009 @@ -210,7 +210,8 @@ if ((sql = switch_mprintf( "select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," "full_via,expires,user_agent,accept,profile_name" - ",-1,'unavailable','unavailable' from sip_subscriptions where event='presence'"))) { + ",-1,'unavailable','unavailable' from sip_subscriptions where event='presence' and hostname='%q'", + mod_sofia_globals.hostname))) { switch_mutex_lock(mod_sofia_globals.hash_mutex); for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Thu Mar 26 11:06:25 2009 @@ -597,8 +597,11 @@ if (now) { - switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name" - " from sip_registrations where status like '%%AUTO-NAT%%' or status like '%%UDP-NAT%%'"); + switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid," + "expires,user_agent,server_user,server_host,profile_name" + " from sip_registrations where (status like '%%AUTO-NAT%%' " + "or status like '%%UDP-NAT%%') and hostname='%s'", mod_sofia_globals.hostname); + sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_nat_callback, profile); } From mikej at freeswitch.org Thu Mar 26 10:02:31 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 12:02:31 -0500 Subject: [Freeswitch-svn] [commit] r12793 - freeswitch/trunk/libs/esl/php Message-ID: Author: mikej Date: Thu Mar 26 12:02:30 2009 New Revision: 12793 Log: work around broken php-config that only takes one option at a time Modified: freeswitch/trunk/libs/esl/php/Makefile Modified: freeswitch/trunk/libs/esl/php/Makefile ============================================================================== --- freeswitch/trunk/libs/esl/php/Makefile (original) +++ freeswitch/trunk/libs/esl/php/Makefile Thu Mar 26 12:02:30 2009 @@ -1,5 +1,7 @@ LOCAL_CFLAGS=$(shell php-config --includes) -LOCAL_LDFLAGS=$(shell php-config --ldflags --libs) +PHP_LDFLAGS=$(shell php-config --ldflags) +PHP_LIBS=$(shell php-config --libs) +LOCAL_LDFLAGS=$(PHP_LDFLAGS) $(PHP_LIBS) WRAP_GCC_WARNING_SILENCE=-Wno-unused-label -Wno-unused-function all: ESL.so From intralanman at freeswitch.org Thu Mar 26 12:00:00 2009 From: intralanman at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 14:00:00 -0500 Subject: [Freeswitch-svn] [commit] r12794 - freeswitch/trunk/scripts/contrib/jtregunna Message-ID: Author: intralanman Date: Thu Mar 26 14:00:00 2009 New Revision: 12794 Log: adding contrib dir for jer Added: freeswitch/trunk/scripts/contrib/jtregunna/ From jtregunna at freeswitch.org Thu Mar 26 12:12:45 2009 From: jtregunna at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 14:12:45 -0500 Subject: [Freeswitch-svn] [commit] r12795 - freeswitch/trunk/scripts/contrib/jtregunna Message-ID: Author: jtregunna Date: Thu Mar 26 14:12:45 2009 New Revision: 12795 Log: Added a simple TTS weather reporting agent. Primitive at the moment, no searching capabilities, location is fixed to Waterloo, Ontario, Canada. TODO: Create an ASR, and have it search major city centers in North America, maybe the world if I can find an easy way of doing that. Added: freeswitch/trunk/scripts/contrib/jtregunna/weather.js Added: freeswitch/trunk/scripts/contrib/jtregunna/weather.js ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/jtregunna/weather.js Thu Mar 26 14:12:45 2009 @@ -0,0 +1,123 @@ +/* + * Weather application + * Copyright (c) 2009, Jeremy Tregunna, All Rights Reserved. + * Redistributable under any terms you like! + * + * Uses the Yahoo! Weather forecasting engine. http://weather.yahoo.com/ + * + * Makes use of mod_flite, should be easy to adapt to any other TTS engine. + */ +var yweather = new Namespace("http://xml.weather.yahoo.com/ns/rss/1.0"); + +var rssFile = "/usr/local/freeswitch/rss/weather.rss"; +var currentConditions = "Unknown"; +var highTemperature = lowTemperature = currentTemperature = "0"; +var doc = null; + +// XXX: Big and nasty, but the values Yahoo! Weather's RSS feed gives out for "text" attributes on yweather:condition +// really don't fit in well with any method of saying things. That is, "You can expect conditions" works for +// most cases, but falls down or reads weird, when things like "tornado conditions" are inserted into . If you +// don't mind that awkwardness, you can get rid of the conditions object, and just change the code in sayWeather() +// replacing occurences of @code with @text, of course, first removing the conditions[...] that surround fc. at code. +var conditions = new Object(); +conditions[0] = "a tornado"; +conditions[1] = "tropical storm conditions"; +conditions[2] = "hurricane conditions"; +conditions[3] = "severe thunderstorms"; +conditions[4] = "thunderstorms"; +conditions[5] = "mixture of rain and snow"; +conditions[6] = "mixture of rain and sleet"; +conditions[7] = "mixture of snow and sleet"; +conditions[8] = "freezing drizzle"; +conditions[9] = "some drizzle"; +conditions[10] = "freezing rain"; +conditions[11] = "rain showers"; +conditions[12] = "light rain showers"; +conditions[13] = "snow flurries"; +conditions[14] = "light snow"; +conditions[15] = "blowing snow"; +conditions[16] = "snow"; +conditions[17] = "periods of hail"; +conditions[18] = "sleet"; +conditions[19] = "dusty conditions"; +conditions[20] = "foggy conditions"; +conditions[21] = "hazy conditions"; +conditions[22] = "smokey conditions"; +conditions[23] = "high winds"; +conditions[24] = "windy"; +conditions[25] = "cold conditions"; +conditions[26] = "overcast conditions"; +conditions[27] = "mostly cloudy conditions"; // Night time +conditions[28] = "mostly cloudy conditions"; // Day time +conditions[29] = "partly cloudy conditions"; // Night time +conditions[30] = "partly cloudy conditions"; // Day time +conditions[31] = "clear conditions"; // Night time +conditions[32] = "sunny conditions"; // Day time +conditions[33] = "fair conditions"; // Night time +conditions[34] = "fair conditions"; // Day time +conditions[35] = "periods of mixed rain and hail"; +conditions[36] = "hot conditions"; +conditions[37] = "isolated thunderstorms"; +conditions[38] = "scattered thunderstorms"; +conditions[39] = "scattered thunderstorms"; +conditions[40] = "scattered showers"; +conditions[41] = "heavy snow"; +conditions[42] = "scattered snow flurries"; +conditions[43] = "heavy snow"; +conditions[44] = "partly cloudy conditions"; +conditions[45] = "thundershowers"; +conditions[46] = "snow flurries"; +conditions[47] = "isolated thunderstorms"; +conditions[3200] = "conditions are not available at this time"; + +/********** Say something **********/ +say = function(something) { + session.speak("flite", "rms", something); +} + +/********** Load the XML **********/ +loadXML = function(url) { + fetchURLFile(url, rssFile); + var fd = new FileIO(rssFile, "r"); + fd.read(3072); + // Need to strip out the tag otherwise we get a syntax error, silly E4X + doc = new XML(fd.data().replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "")); +} + +/********** Say the weather **********/ +sayWeather = function() { + var currentCondition = doc.channel.item.yweather::condition. at text; + var currentTemperature = doc.channel.item.yweather::condition. at temp; + var firstLoop = true; + var forecast = "The current conditions are: "; + forecast += conditions[doc.channel.item.yweather::condition. at code]; + forecast += " and it is " + currentTemperature + " degree" + ((currentTemperature != 1) ? "s" : "") + " out.\n"; + for each(var fc in doc.channel.item.yweather::forecast) { + // XXX: Figure out why day.replace("Sun", "Sunday") et. al., doesn't actually replace the date when used here + // but when using the "js" spidermonkey executable, it does. + var day = fc. at day; + if (day == "Sun") + day = "Sunday"; + else if (day == "Mon") + day = "Monday"; + else if (day == "Tue") + day = "Tuesday"; + else if (day == "Wed") + day = "Wednesday"; + else if (day == "Thu") + day = "Thursday"; + else if (day == "Fri") + day = "Friday"; + else if (day == "Sat") + day = "Saturday"; + forecast += day + "'s forecast calls for " + conditions[fc. at code] + ", with a daytime high of "; + forecast += fc. at high + " degree" + ((fc. at high != 1) ? "s" : "") + " and a low of " + fc. at low + " degree" + ((fc. at low != 1) ? "s" : "") + ".\n"; + } + say(forecast); +} + +if (session.ready()) { + session.answer(); + loadXML("http://weather.yahooapis.com/forecastrss?p=CAXX0531&u=c"); + sayWeather(); +} From gmaruzz at freeswitch.org Thu Mar 26 12:37:10 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 14:37:10 -0500 Subject: [Freeswitch-svn] [commit] r12796 - freeswitch/trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Mar 26 14:37:10 2009 New Revision: 12796 Log: skypiax: added SWITCH_API_COMMANDS: list || console || skype_API_msg Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Mar 26 14:37:10 2009 @@ -39,6 +39,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown); SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); +SWITCH_STANDARD_API(sk_function); +#define SK_SYNTAX "list || console || skype_API_msg" static struct { int debug; @@ -59,6 +61,7 @@ char hold_music[256]; private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; switch_mutex_t *mutex; + private_t *sk_console; } globals; switch_endpoint_interface_t *skypiax_endpoint_interface; @@ -1021,6 +1024,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) { skypiax_module_pool = pool; + switch_api_interface_t *commands_api_interface; memset(&globals, '\0', sizeof(globals)); @@ -1038,9 +1042,12 @@ skypiax_endpoint_interface->io_routines = &skypiax_io_routines; skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; - if (running) + if (running){ + + SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax commands", sk_function, SK_SYNTAX); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; + } else return SWITCH_STATUS_FALSE; } @@ -1335,6 +1342,83 @@ return NULL; } +SWITCH_STANDARD_API(sk_function) +{ + char *mycmd = NULL, *argv[10] = { 0 }; + int argc = 0; + + if(globals.sk_console) + stream->write_function(stream,"sk console is: |||%s|||\n", globals.sk_console->name); + else + stream->write_function(stream,"sk console is NOT yet assigned\n"); + + + if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + if (!argc) { + stream->write_function(stream, "%s", SK_SYNTAX); + goto end; + } + + if (!strcasecmp(argv[0], "list")) { + int i; + for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) { + if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { + if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) { + stream->write_function(stream,"globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tBUSY, session_uuid_str=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str); + } else { + stream->write_function(stream,"globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tIDLE\n", i, globals.SKYPIAX_INTERFACES[i].name); + } + } + } + } else if (!strcasecmp(argv[0], "console")) { + int i; + int found =0; + + if (argc == 2) { + for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { + /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ + if (strlen(globals.SKYPIAX_INTERFACES[i].name) + && + (strncmp + (globals.SKYPIAX_INTERFACES[i].name, argv[1], + strlen(argv[1])) == 0)) { + globals.sk_console=&globals.SKYPIAX_INTERFACES[i]; + stream->write_function(stream,"sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name); + stream->write_function(stream,"sk console is: |||%s|||\n", globals.sk_console->name); + found = 1; + break; + } + + } + if(!found) + stream->write_function(stream,"ERROR: A Skypiax interface with name='%s' was not found\n", argv[1]); + } else { + + stream->write_function(stream, "-ERR Usage: sk console interface_name\n"); + goto end; + } + + + } else if (!strcasecmp(argv[0], "ciapalino")) { + + } else { + if(globals.sk_console) + skypiax_signaling_write(globals.sk_console, (char *)cmd); + else + stream->write_function(stream,"sk console is NOT yet assigned\n"); + } +end: + switch_safe_free(mycmd); + + return SWITCH_STATUS_SUCCESS; +} + + + + /* For Emacs: * Local Variables: * mode:c From anthm at freeswitch.org Thu Mar 26 13:08:30 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 15:08:30 -0500 Subject: [Freeswitch-svn] [commit] r12797 - freeswitch/trunk/src Message-ID: Author: anthm Date: Thu Mar 26 15:08:30 2009 New Revision: 12797 Log: update Modified: freeswitch/trunk/src/switch_core.c Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Thu Mar 26 15:08:30 2009 @@ -1590,6 +1590,8 @@ static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj) { struct system_thread_handle *sth = (struct system_thread_handle *)obj; + +#if 0 // if we are a luser we can never turn this back down, didn't we already set the stack size? #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) struct rlimit rlim; @@ -1599,9 +1601,11 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno)); } #endif +#endif sth->ret = system(sth->cmd); +#if 0 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) rlim.rlim_cur = SWITCH_THREAD_STACKSIZE; rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE; @@ -1610,6 +1614,7 @@ } #endif +#endif switch_mutex_lock(sth->mutex); switch_thread_cond_signal(sth->cond); From silik0n at freeswitch.org Thu Mar 26 15:01:48 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 17:01:48 -0500 Subject: [Freeswitch-svn] [commit] r12798 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Thu Mar 26 17:01:48 2009 New Revision: 12798 Log: the start of merging the xml_curl fork to the amf fork Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Thu Mar 26 17:01:48 2009 @@ -272,6 +272,13 @@ return $results; } + public function getDirDomainbyName($domain_name){ + $query = sprintf("select * from domains where name = '%s'", $domain_name); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results[0]; + } + public function getDirDomain($domains_uid){ $dbh = $this->getDbh(); $query = sprintf("select * from domain_params where domains_uid = $domains_uid"); @@ -327,6 +334,13 @@ /* Directory User Methods */ + public function getDirUsersByDomainUidByUsername($domain_uid, $user_name){ + $query = sprintf("select * from users where domains_uid = '%s' and username = '%s'", $domain_uid, $user_name); + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results[0]; + } + public function getDirUser($user_uid){ $dbh = $this->getDbh(); $query = sprintf("select * from user_params where users_uid = $user_uid"); @@ -399,6 +413,13 @@ return $results; } + public function getDirGroupsByDomianUidByUserUid($domain_uid, $user_uid){ + $query = sprintf("select a.uid as groupUid, a.name as groupName, b.uid as usersUid from groups as a, group_members as b where a.uid = b.groups_uid and b.domains_uid = %s and b.users_uid = %s", $domain_uid, $user_uid) ; + $stmt = $this->dbh->query($query); + $results = $stmt->fetchAll(); + return $results; + } + public function getDirGroup($groups_uid){ $dbh = $this->getDbh(); $query = sprintf("select a.uid as groupMemberUid, a.users_uid as usersUid, b.username as usersUsername from group_members as a, users as b where a.groups_uid = $groups_uid and a.users_uid = b.uid") ; From gmaruzz at freeswitch.org Thu Mar 26 15:02:32 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 17:02:32 -0500 Subject: [Freeswitch-svn] [commit] r12799 - freeswitch/trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Mar 26 17:02:32 2009 New Revision: 12799 Log: skypiax: added another SWITCH_API_COMMANDS to send skype_api command to the named client: skypiax interface_name skype_API_msg Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Mar 26 17:02:32 2009 @@ -41,6 +41,8 @@ SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); SWITCH_STANDARD_API(sk_function); #define SK_SYNTAX "list || console || skype_API_msg" +SWITCH_STANDARD_API(skypiax_function); +#define SKYPIAX_SYNTAX "interface_name skype_API_msg" static struct { int debug; @@ -1044,7 +1046,8 @@ if (running){ - SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax commands", sk_function, SK_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax console commands", sk_function, SK_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "skypiax", "Skypiax interface commands", skypiax_function, SKYPIAX_SYNTAX); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } @@ -1416,6 +1419,62 @@ return SWITCH_STATUS_SUCCESS; } +SWITCH_STANDARD_API(skypiax_function) +{ + char *mycmd = NULL, *argv[10] = { 0 }; + int argc = 0; + private_t *tech_pvt=NULL; + + + if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + if (!argc) { + stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX); + goto end; + } + + if (argc < 2) { + stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX); + goto end; + } + + if (argv[0]) { + int i; + int found =0; + + for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { + /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ + if (strlen(globals.SKYPIAX_INTERFACES[i].name) + && + (strncmp + (globals.SKYPIAX_INTERFACES[i].name, argv[0], + strlen(argv[0])) == 0)) { + tech_pvt=&globals.SKYPIAX_INTERFACES[i]; + stream->write_function(stream,"Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name); + found = 1; + break; + } + + } + if(!found){ + stream->write_function(stream,"ERROR: A Skypiax interface with name='%s' was not found\n", argv[0]); + switch_safe_free(mycmd); + + return SWITCH_STATUS_SUCCESS; + } else { + skypiax_signaling_write(tech_pvt, (char *)&cmd[ strlen(argv[0]) + 1 ] ); + } + } else { + stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX); + } +end: + switch_safe_free(mycmd); + + return SWITCH_STATUS_SUCCESS; +} + From silik0n at freeswitch.org Thu Mar 26 16:06:23 2009 From: silik0n at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 18:06:23 -0500 Subject: [Freeswitch-svn] [commit] r12800 - freeswitch/trunk/scripts/contrib/swk/php/amfphp Message-ID: Author: silik0n Date: Thu Mar 26 18:06:23 2009 New Revision: 12800 Log: fix some errors on generic DB handler Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php ============================================================================== --- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php (original) +++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php Thu Mar 26 18:06:23 2009 @@ -274,7 +274,8 @@ public function getDirDomainbyName($domain_name){ $query = sprintf("select * from domains where name = '%s'", $domain_name); - $stmt = $this->dbh->query($query); + $dbh = $this->getDbh(); + $stmt = $dbh->query($query); $results = $stmt->fetchAll(); return $results[0]; } @@ -336,7 +337,8 @@ /* Directory User Methods */ public function getDirUsersByDomainUidByUsername($domain_uid, $user_name){ $query = sprintf("select * from users where domains_uid = '%s' and username = '%s'", $domain_uid, $user_name); - $stmt = $this->dbh->query($query); + $dbh = $this->getDbh(); + $stmt = $dbh->query($query); $results = $stmt->fetchAll(); return $results[0]; } @@ -360,6 +362,13 @@ return $results; } + public function addDirDomainUser($domains_uid, $username, $mailbox, $cidr, $enabled) { + $dbh = $this->getDbh(); + $query = sprintf('insert into users (domains_uid, username, mailbox, cidr, enabled) values (%s, "%s", "%s", "%s", %s)', + $domain_uid, $username, $mailbox, $cidr, $enabled); + return $dbh->exec($query); + } + public function addDirDomainUserParam($users_uid, $name, $value) { $dbh = $this->getDbh(); $query = sprintf('insert into user_params (users_uid, name, value) values (%s, "%s", "%s")', $users_uid, $name, $value); @@ -415,7 +424,8 @@ public function getDirGroupsByDomianUidByUserUid($domain_uid, $user_uid){ $query = sprintf("select a.uid as groupUid, a.name as groupName, b.uid as usersUid from groups as a, group_members as b where a.uid = b.groups_uid and b.domains_uid = %s and b.users_uid = %s", $domain_uid, $user_uid) ; - $stmt = $this->dbh->query($query); + $dbh = $this->getDbh(); + $stmt = $dbh->query($query); $results = $stmt->fetchAll(); return $results; } From anthm at freeswitch.org Thu Mar 26 17:27:07 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 19:27:07 -0500 Subject: [Freeswitch-svn] [commit] r12801 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Thu Mar 26 19:27:07 2009 New Revision: 12801 Log: reduce exponential mwi notifies Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu Mar 26 19:27:07 2009 @@ -477,6 +477,8 @@ sofia_presence_handle_sip_i_publish(nua, profile, nh, sofia_private, sip, tags); break; case nua_i_register: + //nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact), NUTAG_WITH_THIS(nua), TAG_END()); + //nua_handle_destroy(nh); sofia_reg_handle_sip_i_register(nua, profile, nh, sofia_private, sip, tags); break; case nua_i_state: Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Thu Mar 26 19:27:07 2009 @@ -283,6 +283,8 @@ switch_event_header_t *hp; struct mwi_helper h = { 0 }; char *pname = NULL; + const char *call_id; + const char *sub_call_id; switch_assert(event != NULL); @@ -296,6 +298,9 @@ return; } + call_id = switch_event_get_header(event, "call-id"); + sub_call_id = switch_event_get_header(event, "sub-call-id"); + dup_account = strdup(account); switch_assert(dup_account != NULL); sofia_glue_get_user_host(dup_account, &user, &host); @@ -339,30 +344,39 @@ stream.write_function(&stream, "\r\n"); - sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," - "full_via,expires,user_agent,accept,profile_name" - ",'%q','%q' from sip_subscriptions where event='message-summary' " - "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", - stream.data, host, user, host, host); - - switch_assert(sql != NULL); - sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h); - - switch_safe_free(sql); - - sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' from sip_registrations where sip_user='%q' and sip_host='%q'", - stream.data, user, host); - + sql = NULL; + if (sub_call_id) { + sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," + "full_via,expires,user_agent,accept,profile_name" + ",'%q','%q' from sip_subscriptions where event='message-summary' " + "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%' and call_id='%q')", + stream.data, host, user, host, host, sub_call_id); + } else if (!call_id) { + sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," + "full_via,expires,user_agent,accept,profile_name" + ",'%q','%q' from sip_subscriptions where event='message-summary' " + "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", + stream.data, host, user, host, host); + } + + if (sql) { + sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h); + switch_safe_free(sql); + + } else if (call_id) { + sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' " + "from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'", + stream.data, user, host, call_id); + switch_assert(sql != NULL); + sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback2, &h); + } - switch_assert(sql != NULL); - sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback2, &h); switch_safe_free(sql); - switch_safe_free(stream.data); - switch_safe_free(dup_account); + if (profile) { sofia_glue_release_profile(profile); } @@ -791,6 +805,7 @@ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", user, host); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "VM-sub-call-id", argv[7]); switch_event_fire(&event); } return 0; Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Thu Mar 26 19:27:07 2009 @@ -1137,6 +1137,7 @@ if (switch_event_create(&s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", to_user, reg_host); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Call-ID", call_id); } } else { if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) { From mikej at freeswitch.org Thu Mar 26 18:44:28 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Thu, 26 Mar 2009 20:44:28 -0500 Subject: [Freeswitch-svn] [commit] r12802 - in freeswitch/trunk/conf: . directory/default Message-ID: Author: mikej Date: Thu Mar 26 20:44:28 2009 New Revision: 12802 Log: You can lead a horse to water But you can't make him drink You can send a kid to college But you can't make him think PLEASE THINK! /b Modified: freeswitch/trunk/conf/directory/default/1000.xml freeswitch/trunk/conf/directory/default/1001.xml freeswitch/trunk/conf/directory/default/1002.xml freeswitch/trunk/conf/directory/default/1003.xml freeswitch/trunk/conf/directory/default/1004.xml freeswitch/trunk/conf/directory/default/1005.xml freeswitch/trunk/conf/directory/default/1006.xml freeswitch/trunk/conf/directory/default/1007.xml freeswitch/trunk/conf/directory/default/1008.xml freeswitch/trunk/conf/directory/default/1009.xml freeswitch/trunk/conf/directory/default/1010.xml freeswitch/trunk/conf/directory/default/1011.xml freeswitch/trunk/conf/directory/default/1012.xml freeswitch/trunk/conf/directory/default/1013.xml freeswitch/trunk/conf/directory/default/1014.xml freeswitch/trunk/conf/directory/default/1015.xml freeswitch/trunk/conf/directory/default/1016.xml freeswitch/trunk/conf/directory/default/1017.xml freeswitch/trunk/conf/directory/default/1018.xml freeswitch/trunk/conf/directory/default/1019.xml freeswitch/trunk/conf/directory/default/brian.xml freeswitch/trunk/conf/vars.xml Modified: freeswitch/trunk/conf/directory/default/1000.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1000.xml (original) +++ freeswitch/trunk/conf/directory/default/1000.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1001.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1001.xml (original) +++ freeswitch/trunk/conf/directory/default/1001.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1002.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1002.xml (original) +++ freeswitch/trunk/conf/directory/default/1002.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1003.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1003.xml (original) +++ freeswitch/trunk/conf/directory/default/1003.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1004.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1004.xml (original) +++ freeswitch/trunk/conf/directory/default/1004.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1005.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1005.xml (original) +++ freeswitch/trunk/conf/directory/default/1005.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1006.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1006.xml (original) +++ freeswitch/trunk/conf/directory/default/1006.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1007.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1007.xml (original) +++ freeswitch/trunk/conf/directory/default/1007.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1008.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1008.xml (original) +++ freeswitch/trunk/conf/directory/default/1008.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1009.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1009.xml (original) +++ freeswitch/trunk/conf/directory/default/1009.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1010.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1010.xml (original) +++ freeswitch/trunk/conf/directory/default/1010.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1011.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1011.xml (original) +++ freeswitch/trunk/conf/directory/default/1011.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1012.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1012.xml (original) +++ freeswitch/trunk/conf/directory/default/1012.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1013.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1013.xml (original) +++ freeswitch/trunk/conf/directory/default/1013.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1014.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1014.xml (original) +++ freeswitch/trunk/conf/directory/default/1014.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1015.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1015.xml (original) +++ freeswitch/trunk/conf/directory/default/1015.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1016.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1016.xml (original) +++ freeswitch/trunk/conf/directory/default/1016.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1017.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1017.xml (original) +++ freeswitch/trunk/conf/directory/default/1017.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1018.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1018.xml (original) +++ freeswitch/trunk/conf/directory/default/1018.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/1019.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/1019.xml (original) +++ freeswitch/trunk/conf/directory/default/1019.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,7 @@ - + Modified: freeswitch/trunk/conf/directory/default/brian.xml ============================================================================== --- freeswitch/trunk/conf/directory/default/brian.xml (original) +++ freeswitch/trunk/conf/directory/default/brian.xml Thu Mar 26 20:44:28 2009 @@ -43,8 +43,8 @@ - - + + Modified: freeswitch/trunk/conf/vars.xml ============================================================================== --- freeswitch/trunk/conf/vars.xml (original) +++ freeswitch/trunk/conf/vars.xml Thu Mar 26 20:44:28 2009 @@ -1,7 +1,20 @@ + + + WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + + YOU SHOULD CHANGE THIS default_password value if you don't want to be subject to any + toll fraud in the future. It's your responsibility to secure your own system. + + This default config is used to demonstrate the feature set of FreeSWITCH. + + WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + --> + + + - + From jtregunna at freeswitch.org Mon Mar 30 08:07:38 2009 From: jtregunna at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 10:07:38 -0500 Subject: [Freeswitch-svn] [commit] r12839 - freeswitch/trunk/scripts/contrib/jtregunna/mod_fastsms Message-ID: Author: jtregunna Date: Mon Mar 30 10:07:38 2009 New Revision: 12839 Log: Updated do_config() to strdup() three variables, and shutdown func to release that memory again. Modified: freeswitch/trunk/scripts/contrib/jtregunna/mod_fastsms/mod_fastsms.c Modified: freeswitch/trunk/scripts/contrib/jtregunna/mod_fastsms/mod_fastsms.c ============================================================================== --- freeswitch/trunk/scripts/contrib/jtregunna/mod_fastsms/mod_fastsms.c (original) +++ freeswitch/trunk/scripts/contrib/jtregunna/mod_fastsms/mod_fastsms.c Mon Mar 30 10:07:38 2009 @@ -29,9 +29,9 @@ if ((settings = switch_xml_child(cfg, "settings"))) { auth = switch_xml_child(settings, "auth"); - companyid = (char*)switch_xml_attr_soft(auth, "companyid"); - userid = (char*)switch_xml_attr_soft(auth, "userid"); - password = (char*)switch_xml_attr_soft(auth, "password"); + companyid = strdup(switch_xml_attr_soft(auth, "companyid")); + userid = strdup(switch_xml_attr_soft(auth, "userid")); + password = strdup(switch_xml_attr_soft(auth, "password")); } if (xml) @@ -129,6 +129,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fastsms_shutdown) { curl_easy_cleanup(curl); + free(companyid); + free(userid); + free(password); return SWITCH_STATUS_SUCCESS; } From anthm at freeswitch.org Mon Mar 30 09:48:44 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 11:48:44 -0500 Subject: [Freeswitch-svn] [commit] r12840 - in freeswitch/trunk/src: . include Message-ID: Author: anthm Date: Mon Mar 30 11:48:44 2009 New Revision: 12840 Log: add read_terminator_used var Modified: freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/switch_ivr_play_say.c Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Mon Mar 30 11:48:44 2009 @@ -110,6 +110,7 @@ #define SWITCH_PATH_SEPARATOR "/" #endif #define SWITCH_URL_SEPARATOR "://" +#define SWITCH_READ_TERMINATOR_USED_VARIABLE "read_terminator_used" #define SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE "send_silence_when_idle" #define SWITCH_CURRENT_APPLICATION_VARIABLE "current_application" #define SWITCH_CURRENT_APPLICATION_DATA_VARIABLE "current_application_data" Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Mon Mar 30 11:48:44 2009 @@ -1446,8 +1446,8 @@ switch_channel_t *channel; switch_input_args_t args = { 0 }; switch_status_t status = SWITCH_STATUS_SUCCESS; - char terminator; size_t len = 0; + char tb[2] = ""; switch_assert(session); @@ -1488,7 +1488,12 @@ if ((min_digits && len < min_digits) || len < max_digits) { args.buf = digit_buffer + len; args.buflen = (uint32_t) (digit_buffer_length - len); - status = switch_ivr_collect_digits_count(session, digit_buffer, digit_buffer_length, max_digits, valid_terminators, &terminator, timeout, 0, 0); + status = switch_ivr_collect_digits_count(session, digit_buffer, digit_buffer_length, max_digits, valid_terminators, &tb[0], timeout, 0, 0); + } + + + if (tb[0]) { + switch_channel_set_variable(channel, SWITCH_READ_TERMINATOR_USED_VARIABLE, tb); } len = strlen(digit_buffer); From mikej at freeswitch.org Mon Mar 30 10:20:46 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 12:20:46 -0500 Subject: [Freeswitch-svn] [commit] r12841 - freeswitch/trunk/src/mod/endpoints/mod_sofia Message-ID: Author: mikej Date: Mon Mar 30 12:20:46 2009 New Revision: 12841 Log: fix mwi Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Mon Mar 30 12:20:46 2009 @@ -285,6 +285,7 @@ char *pname = NULL; const char *call_id; const char *sub_call_id; + int for_everyone = 0; switch_assert(event != NULL); @@ -301,6 +302,11 @@ call_id = switch_event_get_header(event, "call-id"); sub_call_id = switch_event_get_header(event, "sub-call-id"); + if (!call_id && !sub_call_id) { + for_everyone = 1; + } + + dup_account = strdup(account); switch_assert(dup_account != NULL); sofia_glue_get_user_host(dup_account, &user, &host); @@ -346,34 +352,45 @@ sql = NULL; - if (sub_call_id) { + if (for_everyone) { sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," "full_via,expires,user_agent,accept,profile_name" ",'%q','%q' from sip_subscriptions where event='message-summary' " - "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%' and call_id='%q')", - stream.data, host, user, host, host, sub_call_id); - } else if (!call_id) { + "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", + stream.data, host, user, host, host); + } else if (sub_call_id) { sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," "full_via,expires,user_agent,accept,profile_name" ",'%q','%q' from sip_subscriptions where event='message-summary' " - "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", - stream.data, host, user, host, host); + "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%' and call_id='%q')", + stream.data, host, user, host, host, sub_call_id); } + if (sql) { sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h); - switch_safe_free(sql); + free(sql); + sql = NULL; + + } + if (for_everyone) { + sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' " + "from sip_registrations where sip_user='%q' and sip_host='%q'", + stream.data, user, host); } else if (call_id) { sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' " "from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'", stream.data, user, host, call_id); + } + + if (sql) { switch_assert(sql != NULL); sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback2, &h); + free(sql); + sql = NULL; } - - switch_safe_free(sql); switch_safe_free(stream.data); switch_safe_free(dup_account); From mrene at freeswitch.org Mon Mar 30 10:48:25 2009 From: mrene at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 12:48:25 -0500 Subject: [Freeswitch-svn] [commit] r12842 - freeswitch/trunk/src Message-ID: Author: mrene Date: Mon Mar 30 12:48:25 2009 New Revision: 12842 Log: Fix Solaris build Modified: freeswitch/trunk/src/switch_xml_config.c Modified: freeswitch/trunk/src/switch_xml_config.c ============================================================================== --- freeswitch/trunk/src/switch_xml_config.c (original) +++ freeswitch/trunk/src/switch_xml_config.c Mon Mar 30 12:48:25 2009 @@ -336,7 +336,7 @@ case SWITCH_CONFIG_FLAGARRAY: { int8_t *dest = (int8_t*)item->ptr; - int8_t index = (int8_t)(intptr_t)item->data; + unsigned int index = (unsigned int)(intptr_t)item->data; int8_t newval = value ? !!switch_true(value) : (int8_t)((intptr_t)item->defaultvalue); if (dest[index] != newval) { changed = SWITCH_TRUE; From mikej at freeswitch.org Mon Mar 30 11:24:16 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 13:24:16 -0500 Subject: [Freeswitch-svn] [commit] r12843 - freeswitch/trunk Message-ID: Author: mikej Date: Mon Mar 30 13:24:16 2009 New Revision: 12843 Log: add build of fs_ivrd Modified: freeswitch/trunk/Makefile.am Modified: freeswitch/trunk/Makefile.am ============================================================================== --- freeswitch/trunk/Makefile.am (original) +++ freeswitch/trunk/Makefile.am Mon Mar 30 13:24:16 2009 @@ -165,12 +165,15 @@ CLEANFILES = src/include/switch_version.h src/include/switch_swigable_cpp.h BUILT_SOURCES = src/include/switch_version.h src/include/switch_swigable_cpp.h -bin_PROGRAMS = freeswitch fs_cli +bin_PROGRAMS = freeswitch fs_cli fs_ivrd +fs_ivrd_SOURCES = libs/esl/src/esl.c libs/esl/src/esl_config.c libs/esl/src/esl_event.c libs/esl/src/esl_threadmutex.c libs/esl/ivrd.c fs_cli_SOURCES = libs/esl/src/esl.c libs/esl/src/esl_config.c libs/esl/src/esl_event.c libs/esl/src/esl_threadmutex.c libs/esl/fs_cli.c freeswitch_SOURCES = src/switch.c nodist_freeswitch_SOURCES = src/include/switch_version.h fs_cli_CFLAGS = $(AM_CFLAGS) -Ilibs/esl/src/include fs_cli_LDFLAGS = $(AM_LDFLAGS) -lpthread $(ESL_LDFLAGS) +fs_ivrd_CFLAGS = $(AM_CFLAGS) -Ilibs/esl/src/include +fs_ivrd_LDFLAGS = $(AM_LDFLAGS) -lpthread $(ESL_LDFLAGS) freeswitch_CFLAGS = $(AM_CFLAGS) $(CORE_CFLAGS) freeswitch_LDFLAGS = $(AM_LDFLAGS) -rpath $(libdir) freeswitch_LDADD = libfreeswitch.la libs/apr/libapr-1.la From anthm at freeswitch.org Mon Mar 30 14:09:59 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 16:09:59 -0500 Subject: [Freeswitch-svn] [commit] r12844 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 30 16:09:49 2009 New Revision: 12844 Log: add warnings Modified: freeswitch/trunk/src/switch_event.c Modified: freeswitch/trunk/src/switch_event.c ============================================================================== --- freeswitch/trunk/src/switch_event.c (original) +++ freeswitch/trunk/src/switch_event.c Mon Mar 30 16:09:49 2009 @@ -1100,7 +1100,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, const char *func, int line, switch_event_t **event, void *user_data) { - + int index; + switch_assert(BLOCK != NULL); switch_assert(RUNTIME_POOL != NULL); switch_assert(EVENT_QUEUE_MUTEX != NULL); @@ -1116,8 +1117,22 @@ (*event)->event_user_data = user_data; } + for (;;) { + for (index = (*event)->priority; index < 3; index++) { + if (switch_queue_trypush(EVENT_QUEUE[index], *event) == SWITCH_STATUS_SUCCESS) { + if (index != (*event)->priority) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority!\n"); + } + goto end; + } + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Event queue is full!\n"); + switch_yield(100000); + } + + end: - switch_queue_push(EVENT_QUEUE[(*event)->priority], *event); *event = NULL; return SWITCH_STATUS_SUCCESS; From andrew at freeswitch.org Mon Mar 30 14:10:01 2009 From: andrew at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 16:10:01 -0500 Subject: [Freeswitch-svn] [commit] r12845 - freeswitch/trunk/src/mod/event_handlers/mod_erlang_event Message-ID: Author: andrew Date: Mon Mar 30 16:10:01 2009 New Revision: 12845 Log: Fixed registered process outbound mode (reported by rcpacheco) Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c ============================================================================== --- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (original) +++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c Mon Mar 30 16:10:01 2009 @@ -417,8 +417,10 @@ ei_get_type(rep->buff, &rep->index, &type, &size); - if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) /* XXX no unicode or character codes > 255 */ + if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) { /* XXX no unicode or character codes > 255 */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XML fetch response contained non ASCII characters? (was type %d of size %d)\n", type, size); return NULL; + } if (!(xmlstr = malloc(size + 1))) { @@ -778,7 +780,7 @@ check_log_queue(listener); check_event_queue(listener); - if (SWITCH_STATUS_SUCCESS != check_attached_sessions(listener)) { + if (check_attached_sessions(listener) != SWITCH_STATUS_SUCCESS) { return; } } @@ -1038,6 +1040,7 @@ if (!(session_element = switch_core_session_alloc(session, sizeof(*session_element)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate session element\n"); } else { + memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); session_element->process.type = ERLANG_REG_PROCESS; session_element->process.reg_name = switch_core_strdup(switch_core_session_get_pool(session),reg_name); switch_set_flag(session_element, LFLAG_SESSION_ALIVE); From anthm at freeswitch.org Mon Mar 30 14:12:06 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 16:12:06 -0500 Subject: [Freeswitch-svn] [commit] r12846 - freeswitch/trunk/src Message-ID: Author: anthm Date: Mon Mar 30 16:12:06 2009 New Revision: 12846 Log: change blocking rtp to psuedo-blocking to avoid endlessly blocking reads and refactor jitter buffer Modified: freeswitch/trunk/src/switch_apr.c freeswitch/trunk/src/switch_rtp.c Modified: freeswitch/trunk/src/switch_apr.c ============================================================================== --- freeswitch/trunk/src/switch_apr.c (original) +++ freeswitch/trunk/src/switch_apr.c Mon Mar 30 16:12:06 2009 @@ -791,7 +791,13 @@ SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout) { - return apr_poll((apr_pollfd_t *)aprset, numsock, nsds, timeout); + apr_status_t st = apr_poll((apr_pollfd_t *)aprset, numsock, nsds, timeout); + + if (st == APR_TIMEUP) { + st = SWITCH_STATUS_TIMEOUT; + } + + return st; } SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool) Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Mon Mar 30 16:12:06 2009 @@ -129,7 +129,9 @@ * used. */ switch_socket_t *sock_input, *sock_output; - + switch_pollfd_t *read_pollfd; + switch_pollfd_t *jb_pollfd; + switch_sockaddr_t *local_addr; rtp_msg_t send_msg; @@ -188,7 +190,6 @@ switch_timer_t timer; uint8_t ready; uint8_t cn; - switch_time_t last_time; stfu_instance_t *jb; uint32_t max_missed_packets; uint32_t missed_count; @@ -598,6 +599,8 @@ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) { switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE); switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK); + } else { + switch_socket_create_pollfd(&rtp_session->read_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool); } status = SWITCH_STATUS_SUCCESS; @@ -1013,7 +1016,14 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames) { + if (rtp_session->read_pollfd) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't use jitterbuffer without a timer.\n"); + return SWITCH_STATUS_FALSE; + } + rtp_session->jb = stfu_n_init(queue_frames); + switch_socket_create_pollfd(&rtp_session->jb_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool); + return SWITCH_STATUS_SUCCESS; } @@ -1364,11 +1374,15 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) { switch_size_t bytes = 0; - switch_status_t status; + switch_status_t status = SWITCH_STATUS_SUCCESS, poll_status = SWITCH_STATUS_SUCCESS; int check = 0; stfu_frame_t *jb_frame; int ret = -1; int sleep_mss = 1000; + int poll_sec = 5; + int poll_loop = 0; + int fdr = 0; + int from_jb = 0; if (!switch_rtp_ready(rtp_session)) { return -1; @@ -1376,8 +1390,6 @@ if (rtp_session->timer.interval) { sleep_mss = rtp_session->timer.interval * 1000; - } else { - rtp_session->last_time = switch_time_now(); } READ_INC(rtp_session); @@ -1386,13 +1398,54 @@ int do_cng = 0; if (rtp_session->timer.interval) { - switch_core_timer_next(&rtp_session->timer); + int do_sleep = 1; + if (rtp_session->jb) { + if (switch_poll(rtp_session->jb_pollfd, 1, &fdr, 1) == SWITCH_STATUS_SUCCESS) { + do_sleep = 0; + } + } + if (do_sleep) { + switch_core_timer_next(&rtp_session->timer); + } } recvfrom: - bytes = sizeof(rtp_msg_t); - status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes); + if (rtp_session->jb) { + if ((jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { + memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); + if (jb_frame->plc) { + *flags |= SFF_PLC; + } + bytes = jb_frame->dlen + rtp_header_len; + rtp_session->recv_msg.header.ts = htonl(jb_frame->ts); + rtp_session->recv_msg.header.pt = rtp_session->payload; + from_jb = 1; + goto post_read; + } + } + + + if (rtp_session->read_pollfd) { + poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, poll_sec * 1000000); + } + + + if (poll_status == SWITCH_STATUS_SUCCESS) { + bytes = sizeof(rtp_msg_t); + status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes); + } else { + if (!SWITCH_STATUS_IS_BREAK(poll_status) && poll_status != SWITCH_STATUS_TIMEOUT) { + ret = -1; + goto end; + } + + poll_loop = 1; + rtp_session->missed_count += (poll_sec * 1000 ) / (rtp_session->ms_per_packet / 1000); + bytes = 0; + } + + post_read: if (bytes < 0) { ret = (int) bytes; @@ -1427,6 +1480,10 @@ continue; } + if (!bytes && poll_loop) { + goto recvfrom; + } + if (bytes && rtp_session->recv_msg.header.m && rtp_session->recv_msg.header.pt != rtp_session->te) { rtp_flush_read_buffer(rtp_session); } @@ -1517,26 +1574,16 @@ goto end; } - if (rtp_session->jb && ((bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) || check)) { + if (rtp_session->jb && !from_jb && ((bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) || check)) { if (bytes) { + if (rtp_session->recv_msg.header.m) { stfu_n_reset(rtp_session->jb); } - stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.body, bytes - rtp_header_len); + stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.body, bytes - rtp_header_len); bytes = 0; - } - - if ((jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { - memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); - if (jb_frame->plc) { - *flags |= SFF_PLC; - } - bytes = jb_frame->dlen + rtp_header_len; - rtp_session->recv_msg.header.ts = htonl(jb_frame->ts); - rtp_session->recv_msg.header.pt = rtp_session->payload; - } else { - goto timer_check; + goto recvfrom; } } From mikej at freeswitch.org Mon Mar 30 15:17:26 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 17:17:26 -0500 Subject: [Freeswitch-svn] [commit] r12847 - freeswitch/trunk/scripts Message-ID: Author: mikej Date: Mon Mar 30 17:17:26 2009 New Revision: 12847 Log: add tag scripts Added: freeswitch/trunk/scripts/tagscript-test.sh (contents, props changed) freeswitch/trunk/scripts/tagscript.sh (contents, props changed) Added: freeswitch/trunk/scripts/tagscript-test.sh ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/tagscript-test.sh Mon Mar 30 17:17:26 2009 @@ -0,0 +1,18 @@ +NEW_MICRO=4pre3 +rm -rf freeswitch-1.0.$(NEW_MICRO) +svn co http://svn.freeswitch.org/svn/freeswitch/trunk freeswitch-1.0.$(NEW_MICRO) +cd freeswitch-1.0.$(NEW_MICRO) +SWITCH_VERSION_MAJOR=`grep SWITCH_VERSION_MAJOR configure.in | sed "s|.*\[||" | sed "s|\].*||"` +SWITCH_VERSION_MINOR=`grep SWITCH_VERSION_MINOR configure.in | sed "s|.*\[||" | sed "s|\].*||"` +SWITCH_VERSION_MICRO=`grep SWITCH_VERSION_MICRO configure.in | sed "s|.*\[||" | sed "s|\].*||"` +FREESWITCH_VERSION=$((`svnversion .` + 1)) +cat configure.in | sed "s|$SWITCH_VERSION_MICRO|$NEW_MICRO|" | sed "s|svn-revision-here|$FREESWITCH_VERSION|" | sed "s|#AC_SUBST(SWITCH_VERSION_REVISION|AC_SUBST(SWITCH_VERSION_REVISION|" > configure.tmp +cp -f configure.tmp configure.in +rm -f configure.tmp +./bootstrap.sh +rm -f docs/AUTHORS +rm -f docs/COPYING +rm -f docs/ChangeLog +cd .. +tar -czvf freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO.tar.gz freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO/ +tar -cjvf freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO.tar.bz2 freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO/ Added: freeswitch/trunk/scripts/tagscript.sh ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/tagscript.sh Mon Mar 30 17:17:26 2009 @@ -0,0 +1,34 @@ +NEW_MICRO=4 +rm -rf freeswitch.tag.working +svn co http://svn.freeswitch.org/svn/freeswitch/trunk freeswitch.tag.working +cd freeswitch.tag.working +SWITCH_VERSION_MAJOR=`grep SWITCH_VERSION_MAJOR configure.in | sed "s|.*\[||" | sed "s|\].*||"` +SWITCH_VERSION_MINOR=`grep SWITCH_VERSION_MINOR configure.in | sed "s|.*\[||" | sed "s|\].*||"` +SWITCH_VERSION_MICRO=`grep SWITCH_VERSION_MICRO configure.in | sed "s|.*\[||" | sed "s|\].*||"` +FREESWITCH_VERSION=$((`svnversion .` + 1)) +cat configure.in | sed "s|$SWITCH_VERSION_MICRO|$NEW_MICRO|" | sed "s|svn-revision-here|$FREESWITCH_VERSION|" | sed "s|#AC_SUBST(SWITCH_VERSION_REVISION|AC_SUBST(SWITCH_VERSION_REVISION|" > configure.tmp +cp -f configure.tmp configure.in +rm -f configure.tmp +cd libs/openzap/ +OPENZAP_VERSION=$((`svnversion .` + 1)) +svn copy . http://svn.openzap.org:81/svn/openzap/tags/v$OPENZAP_VERSION -m"tag" +cd ../.. +echo 'cat $1 | sed "s|openzap/trunk|openzap/tags/v'$OPENZAP_VERSION'|" > svn-temp-working' > externaleditor.sh +echo 'cp -f svn-temp-working $1' >> externaleditor.sh +echo 'rm -f svn-temp-working' >> externaleditor.sh +chmod a+x externaleditor.sh +svn propedit svn:externals . --editor-cmd=./externaleditor.sh +svn copy . http://svn.freeswitch.org/svn/freeswitch/tags/$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO -m"tag" +cd .. +rm -rf freeswitch.tag.working +svn co http://svn.freeswitch.org/svn/freeswitch/tags/$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO +cd freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO +./bootstrap.sh +rm -rf `find . -name .svn` +rm -f bootstrap.sh +rm -f docs/AUTHORS +rm -f docs/COPYING +rm -f docs/ChangeLog +cd .. +tar -czvf freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO.tar.gz freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO/ +tar -cjvf freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO.tar.bz2 freeswitch-$SWITCH_VERSION_MAJOR.$SWITCH_VERSION_MINOR.$NEW_MICRO/ From mikej at freeswitch.org Mon Mar 30 15:25:08 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Mon, 30 Mar 2009 17:25:08 -0500 Subject: [Freeswitch-svn] [commit] r12848 - freeswitch/trunk/scripts Message-ID: Author: mikej Date: Mon Mar 30 17:25:08 2009 New Revision: 12848 Log: typo Modified: freeswitch/trunk/scripts/tagscript-test.sh Modified: freeswitch/trunk/scripts/tagscript-test.sh ============================================================================== --- freeswitch/trunk/scripts/tagscript-test.sh (original) +++ freeswitch/trunk/scripts/tagscript-test.sh Mon Mar 30 17:25:08 2009 @@ -1,7 +1,7 @@ NEW_MICRO=4pre3 -rm -rf freeswitch-1.0.$(NEW_MICRO) -svn co http://svn.freeswitch.org/svn/freeswitch/trunk freeswitch-1.0.$(NEW_MICRO) -cd freeswitch-1.0.$(NEW_MICRO) +rm -rf freeswitch-1.0.$NEW_MICRO +svn co http://svn.freeswitch.org/svn/freeswitch/trunk freeswitch-1.0.$NEW_MICRO +cd freeswitch-1.0.$NEW_MICRO SWITCH_VERSION_MAJOR=`grep SWITCH_VERSION_MAJOR configure.in | sed "s|.*\[||" | sed "s|\].*||"` SWITCH_VERSION_MINOR=`grep SWITCH_VERSION_MINOR configure.in | sed "s|.*\[||" | sed "s|\].*||"` SWITCH_VERSION_MICRO=`grep SWITCH_VERSION_MICRO configure.in | sed "s|.*\[||" | sed "s|\].*||"` From anthm at freeswitch.org Tue Mar 31 06:08:43 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 08:08:43 -0500 Subject: [Freeswitch-svn] [commit] r12849 - freeswitch/trunk/src/mod/languages/mod_python Message-ID: Author: anthm Date: Tue Mar 31 08:08:43 2009 New Revision: 12849 Log: MODLANG-109 Modified: freeswitch/trunk/src/mod/languages/mod_python/hack.diff freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Modified: freeswitch/trunk/src/mod/languages/mod_python/hack.diff ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/hack.diff (original) +++ freeswitch/trunk/src/mod/languages/mod_python/hack.diff Tue Mar 31 08:08:43 2009 @@ -1,6 +1,26 @@ ---- mod_python_wrap.cpp 2008-07-16 17:05:18.000000000 -0400 -+++ old.cpp 2008-07-16 17:05:07.000000000 -0400 -@@ -8621,20 +8621,20 @@ +--- mod_python_wrap.cpp.orig 2009-03-21 11:37:16.000000000 +0100 ++++ mod_python_wrap.cpp 2009-03-21 11:33:18.000000000 +0100 +@@ -5469,7 +5469,9 @@ + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "EventConsumer_pop" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); ++ Py_BEGIN_ALLOW_THREADS; + result = (Event *)(arg1)->pop(arg2); ++ Py_END_ALLOW_THREADS; + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, 0 | 0 ); + return resultobj; + fail: +@@ -5491,7 +5493,9 @@ + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EventConsumer_pop" "', argument " "1"" of type '" "EventConsumer *""'"); + } + arg1 = reinterpret_cast< EventConsumer * >(argp1); ++ Py_BEGIN_ALLOW_THREADS; + result = (Event *)(arg1)->pop(); ++ Py_END_ALLOW_THREADS; + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, 0 | 0 ); + return resultobj; + fail: +@@ -9206,20 +9210,20 @@ } @@ -24,7 +44,7 @@ PyObject *resultobj = 0; char *arg1 = (char *) 0 ; CoreSession *arg2 = (CoreSession *) 0 ; -@@ -8659,7 +8659,7 @@ +@@ -9244,7 +9248,7 @@ } arg2 = reinterpret_cast< CoreSession * >(argp2); result = (PYTHON::Session *)new PYTHON::Session(arg1,arg2); @@ -33,7 +53,7 @@ if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: -@@ -8668,7 +8668,7 @@ +@@ -9253,7 +9257,7 @@ } @@ -42,7 +62,7 @@ PyObject *resultobj = 0; char *arg1 = (char *) 0 ; PYTHON::Session *result = 0 ; -@@ -8684,7 +8684,7 @@ +@@ -9269,7 +9273,7 @@ } arg1 = reinterpret_cast< char * >(buf1); result = (PYTHON::Session *)new PYTHON::Session(arg1); @@ -51,7 +71,7 @@ if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: -@@ -8693,7 +8693,7 @@ +@@ -9278,7 +9282,7 @@ } @@ -60,7 +80,7 @@ PyObject *resultobj = 0; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; PYTHON::Session *result = 0 ; -@@ -8708,7 +8708,7 @@ +@@ -9293,7 +9297,7 @@ } arg1 = reinterpret_cast< switch_core_session_t * >(argp1); result = (PYTHON::Session *)new PYTHON::Session(arg1); Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Tue Mar 31 08:08:43 2009 @@ -5469,7 +5469,9 @@ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "EventConsumer_pop" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + Py_BEGIN_ALLOW_THREADS; result = (Event *)(arg1)->pop(arg2); + Py_END_ALLOW_THREADS; resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, 0 | 0 ); return resultobj; fail: @@ -5491,7 +5493,9 @@ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EventConsumer_pop" "', argument " "1"" of type '" "EventConsumer *""'"); } arg1 = reinterpret_cast< EventConsumer * >(argp1); + Py_BEGIN_ALLOW_THREADS; result = (Event *)(arg1)->pop(); + Py_END_ALLOW_THREADS; resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, 0 | 0 ); return resultobj; fail: From anthm at freeswitch.org Tue Mar 31 06:14:16 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 08:14:16 -0500 Subject: [Freeswitch-svn] [commit] r12850 - freeswitch/trunk/src/mod/applications/mod_voicemail Message-ID: Author: anthm Date: Tue Mar 31 08:14:16 2009 New Revision: 12850 Log: MODAPP-240 Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Tue Mar 31 08:14:16 2009 @@ -2997,24 +2997,34 @@ } } - switch_channel_get_variables(channel, &vars); - status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars, - switch_core_session_get_pool(session), caller_id_name, caller_id_number, SWITCH_FALSE); - switch_event_destroy(&vars); - if (status == SWITCH_STATUS_SUCCESS) { - if ((vm_cc = switch_channel_get_variable(channel, "vm_cc"))) { - char *cmd = switch_core_session_sprintf(session, "%s %s %s %s", vm_cc, file_path, caller_id_number, caller_id_name); - if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Sent Carbon Copy to %s\n", vm_cc); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to Carbon Copy to %s\n", vm_cc); + switch_event_t *params = NULL; + + switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); + switch_assert(params); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", id); + + if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"), + &x_domain_root, &x_domain, &x_user, NULL, params) == SWITCH_STATUS_SUCCESS) { + + switch_channel_get_variables(channel, &vars); + status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars, + switch_core_session_get_pool(session), caller_id_name, caller_id_number, SWITCH_FALSE); + switch_event_destroy(&vars); + if (status == SWITCH_STATUS_SUCCESS) { + if ((vm_cc = switch_channel_get_variable(channel, "vm_cc"))) { + char *cmd = switch_core_session_sprintf(session, "%s %s %s %s", vm_cc, file_path, caller_id_number, caller_id_name); + if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Sent Carbon Copy to %s\n", vm_cc); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to Carbon Copy to %s\n", vm_cc); + } } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to deliver message\n"); + TRY_CODE(switch_ivr_phrase_macro(session, VM_ACK_MACRO, "deleted", NULL, NULL)); } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to deliver message\n"); - TRY_CODE(switch_ivr_phrase_macro(session, VM_ACK_MACRO, "deleted", NULL, NULL)); } - + switch_event_destroy(¶ms); end: if (x_domain_root) { From anthm at freeswitch.org Tue Mar 31 09:10:20 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 11:10:20 -0500 Subject: [Freeswitch-svn] [commit] r12851 - freeswitch/trunk/src Message-ID: Author: anthm Date: Tue Mar 31 11:10:20 2009 New Revision: 12851 Log: shutdown the queue when destroying the event consumer obj in c++ Modified: freeswitch/trunk/src/switch_cpp.cpp Modified: freeswitch/trunk/src/switch_cpp.cpp ============================================================================== --- freeswitch/trunk/src/switch_cpp.cpp (original) +++ freeswitch/trunk/src/switch_cpp.cpp Tue Mar 31 11:10:20 2009 @@ -97,6 +97,10 @@ switch_event_unbind(&node); } + if (events) { + switch_queue_interrupt_all(events); + } + switch_core_destroy_memory_pool(&pool); } From mikej at freeswitch.org Tue Mar 31 10:13:16 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 12:13:16 -0500 Subject: [Freeswitch-svn] [commit] r12852 - freeswitch/trunk/src/mod/loggers/mod_syslog Message-ID: Author: mikej Date: Tue Mar 31 12:13:16 2009 New Revision: 12852 Log: fix string scope on globals (LOGGER-1) Modified: freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c Modified: freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c ============================================================================== --- freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c (original) +++ freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c Tue Mar 31 12:13:16 2009 @@ -164,15 +164,16 @@ setlogmask(LOG_UPTO(LOG_DEBUG)); switch_log_bind_logger(mod_syslog_logger, log_level, SWITCH_FALSE); - switch_safe_free(globals.ident); - switch_safe_free(globals.format); - return SWITCH_STATUS_SUCCESS; } SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_syslog_shutdown) { closelog(); + + switch_safe_free(globals.ident); + switch_safe_free(globals.format); + switch_log_unbind_logger(mod_syslog_logger); return SWITCH_STATUS_SUCCESS; From mikej at freeswitch.org Tue Mar 31 10:33:45 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 12:33:45 -0500 Subject: [Freeswitch-svn] [commit] r12853 - freeswitch/trunk/libs/win32 Message-ID: Author: mikej Date: Tue Mar 31 12:33:45 2009 New Revision: 12853 Log: Windows sphinx downloads for release mode (FSBUILD-146) Modified: freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj Modified: freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj (original) +++ freeswitch/trunk/libs/win32/Download pocketsphinx.2008.vcproj Tue Mar 31 12:33:45 2009 @@ -85,7 +85,7 @@ Modified: freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj ============================================================================== --- freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj (original) +++ freeswitch/trunk/libs/win32/Download sphinxbase.2008.vcproj Tue Mar 31 12:33:45 2009 @@ -85,7 +85,7 @@ From anthm at freeswitch.org Tue Mar 31 12:10:43 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 14:10:43 -0500 Subject: [Freeswitch-svn] [commit] r12854 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia Message-ID: Author: anthm Date: Tue Mar 31 14:10:43 2009 New Revision: 12854 Log: add rtp-autoflush profile param and rtp_autoflush var to skip timer sleeps when the socket has data ready and refactor the jitter buffer code out into a different function and fix it so it works in blocking mode too Modified: freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/trunk/src/switch_rtp.c Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Tue Mar 31 14:10:43 2009 @@ -470,7 +470,8 @@ SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 << 17), SWITCH_RTP_FLAG_PROXY_MEDIA = (1 << 18), SWITCH_RTP_FLAG_SHUTDOWN = (1 << 19), - SWITCH_RTP_FLAG_FLUSH = (1 << 20) + SWITCH_RTP_FLAG_FLUSH = (1 << 20), + SWITCH_RTP_FLAG_AUTOFLUSH = (1 << 21) } switch_rtp_flag_enum_t; typedef uint32_t switch_rtp_flag_t; Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue Mar 31 14:10:43 2009 @@ -181,6 +181,7 @@ PFLAG_MANAGE_SHARED_APPEARANCE, PFLAG_DISABLE_SRV, PFLAG_DISABLE_NAPTR, + PFLAG_AUTOFLUSH, /* No new flags below this line */ PFLAG_MAX Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 31 14:10:43 2009 @@ -1655,6 +1655,12 @@ } else { sofia_clear_pflag(profile, PFLAG_PASS_RFC2833); } + } else if (!strcasecmp(var, "rtp-autoflush")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_AUTOFLUSH); + } else { + sofia_clear_pflag(profile, PFLAG_AUTOFLUSH); + } } else if (!strcasecmp(var, "inbound-codec-negotiation")) { if (!strcasecmp(val, "greedy")) { sofia_set_pflag(profile, PFLAG_GREEDY); @@ -2181,6 +2187,12 @@ if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_PASS_RFC2833); } + } else if (!strcasecmp(var, "rtp-autoflush")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_AUTOFLUSH); + } else { + sofia_clear_pflag(profile, PFLAG_AUTOFLUSH); + } } else if (!strcasecmp(var, "inbound-codec-negotiation")) { if (!strcasecmp(val, "greedy")) { sofia_set_pflag(profile, PFLAG_GREEDY); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Tue Mar 31 14:10:43 2009 @@ -2054,6 +2054,12 @@ flags |= SWITCH_RTP_FLAG_PASS_RFC2833; } + + if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFLUSH) + || ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_autoflush")) && switch_true(val))) { + flags |= SWITCH_RTP_FLAG_AUTOFLUSH; + } + if (!(sofia_test_pflag(tech_pvt->profile, PFLAG_REWRITE_TIMESTAMPS) || ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && !switch_true(val)))) { flags |= SWITCH_RTP_FLAG_RAW_WRITE; Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Tue Mar 31 14:10:43 2009 @@ -599,10 +599,10 @@ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) { switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE); switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK); - } else { - switch_socket_create_pollfd(&rtp_session->read_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool); } + switch_socket_create_pollfd(&rtp_session->read_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool); + status = SWITCH_STATUS_SUCCESS; *err = "Success"; switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_IO); @@ -1016,13 +1016,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames) { - if (rtp_session->read_pollfd) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't use jitterbuffer without a timer.\n"); - return SWITCH_STATUS_FALSE; - } rtp_session->jb = stfu_n_init(queue_frames); - switch_socket_create_pollfd(&rtp_session->jb_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool); return SWITCH_STATUS_SUCCESS; } @@ -1371,18 +1366,53 @@ #define return_cng_frame() do_cng = 1; goto timer_check +static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + stfu_frame_t *jb_frame; + + switch_assert(bytes); + + *bytes = sizeof(rtp_msg_t); + status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, bytes); + + if (rtp_session->jb && rtp_session->recv_msg.header.version == 2 && *bytes) { + if (rtp_session->recv_msg.header.m && rtp_session->recv_msg.header.pt != rtp_session->te) { + stfu_n_reset(rtp_session->jb); + } + + stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.body, *bytes - rtp_header_len); + *bytes = 0; + status = SWITCH_STATUS_FALSE; + } + + if (rtp_session->jb) { + if ((jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { + memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); + if (jb_frame->plc) { + *flags |= SFF_PLC; + } + *bytes = jb_frame->dlen + rtp_header_len; + rtp_session->recv_msg.header.ts = htonl(jb_frame->ts); + rtp_session->recv_msg.header.pt = rtp_session->payload; + status = SWITCH_STATUS_SUCCESS; + } + } + + return status; +} + static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) { switch_size_t bytes = 0; switch_status_t status = SWITCH_STATUS_SUCCESS, poll_status = SWITCH_STATUS_SUCCESS; int check = 0; - stfu_frame_t *jb_frame; int ret = -1; int sleep_mss = 1000; int poll_sec = 5; int poll_loop = 0; int fdr = 0; - int from_jb = 0; + int hot_socket = 0; if (!switch_rtp_ready(rtp_session)) { return -1; @@ -1398,42 +1428,24 @@ int do_cng = 0; if (rtp_session->timer.interval) { - int do_sleep = 1; - if (rtp_session->jb) { - if (switch_poll(rtp_session->jb_pollfd, 1, &fdr, 1) == SWITCH_STATUS_SUCCESS) { - do_sleep = 0; + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOFLUSH)) { + if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 1) == SWITCH_STATUS_SUCCESS) { + hot_socket = 1; } } - if (do_sleep) { + if (!hot_socket) { switch_core_timer_next(&rtp_session->timer); } } recvfrom: - if (rtp_session->jb) { - if ((jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { - memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); - if (jb_frame->plc) { - *flags |= SFF_PLC; - } - bytes = jb_frame->dlen + rtp_header_len; - rtp_session->recv_msg.header.ts = htonl(jb_frame->ts); - rtp_session->recv_msg.header.pt = rtp_session->payload; - from_jb = 1; - goto post_read; - } - } - - - if (rtp_session->read_pollfd) { + if (!rtp_session->timer.interval) { poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, poll_sec * 1000000); } - - + if (poll_status == SWITCH_STATUS_SUCCESS) { - bytes = sizeof(rtp_msg_t); - status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes); + status = read_rtp_packet(rtp_session, &bytes, flags); } else { if (!SWITCH_STATUS_IS_BREAK(poll_status) && poll_status != SWITCH_STATUS_TIMEOUT) { ret = -1; @@ -1445,8 +1457,6 @@ bytes = 0; } - post_read: - if (bytes < 0) { ret = (int) bytes; goto end; @@ -1574,20 +1584,6 @@ goto end; } - if (rtp_session->jb && !from_jb && ((bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) || check)) { - if (bytes) { - - if (rtp_session->recv_msg.header.m) { - stfu_n_reset(rtp_session->jb); - } - - stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.body, bytes - rtp_header_len); - bytes = 0; - goto recvfrom; - } - } - - if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) { int sbytes = (int) bytes; err_status_t stat = 0; @@ -1749,14 +1745,7 @@ } if (check || (bytes && !rtp_session->timer.interval)) { - if (rtp_session->jb && (jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { - memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); - if (jb_frame->plc) { - *flags |= SFF_PLC; - } - bytes = jb_frame->dlen + rtp_header_len; - rtp_session->recv_msg.header.ts = htonl(jb_frame->ts); - } else if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */ + if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */ if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) { switch_cond_next(); continue; From anthm at freeswitch.org Tue Mar 31 13:30:13 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 15:30:13 -0500 Subject: [Freeswitch-svn] [commit] r12855 - freeswitch/trunk/src/mod/applications/mod_fifo Message-ID: Author: anthm Date: Tue Mar 31 15:30:13 2009 New Revision: 12855 Log: FSCORE-343 Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original) +++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Tue Mar 31 15:30:13 2009 @@ -56,6 +56,7 @@ switch_memory_pool_t *pool; int has_outbound; int ready; + int is_static; }; typedef struct fifo_node fifo_node_t; @@ -1756,7 +1757,7 @@ void *val; for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); - if ((node = (fifo_node_t *) val)) { + if ((node = (fifo_node_t *) val) && node->is_static) { node->ready = 0; } } @@ -1845,6 +1846,7 @@ } node->ready = 1; + node->is_static = 1; switch_mutex_unlock(node->mutex); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s configured\n", node->name); @@ -1862,11 +1864,10 @@ for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) { int x = 0; switch_hash_this(hi, NULL, NULL, &val); - if (!(node = (fifo_node_t *) val) || node->ready) { + if (!(node = (fifo_node_t *) val) || !node->is_static || node->ready) { continue; } - if (node_consumer_wait_count(node) || node->consumer_count || node_idle_consumers(node)) { node->ready = 1; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s not removed, still in use.\n", node->name); From mikej at freeswitch.org Tue Mar 31 13:51:36 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 15:51:36 -0500 Subject: [Freeswitch-svn] [commit] r12856 - in freeswitch/trunk: libs/sofia-sip/libsofia-sip-ua/nta src src/mod/endpoints/mod_sofia Message-ID: Author: mikej Date: Tue Mar 31 15:51:35 2009 New Revision: 12856 Log: linux... how did that not crash every time Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_event.c Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 31 15:51:35 2009 @@ -3319,8 +3319,10 @@ msg_maxsize(msg, agent->sa_maxsize); - if (agent->sa_preload) - su_home_preload(msg_home(msg), 1, dlen + agent->sa_preload); + if (1 || agent->sa_preload) { + isize_t preload = (dlen + agent->sa_preload + 1023) & ~1023; + su_home_preload(msg_home(msg), 1, preload); + } return msg; } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 31 15:51:35 2009 @@ -744,6 +744,7 @@ sofia_event_callback, /* Callback for processing events */ profile, /* Additional data to pass to callback */ NUTAG_URL(profile->bindurl), + NTATAG_PRELOAD(2048), TAG_IF(!strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP4_ONLY)), TAG_IF(strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP6_ONLY)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_SIPS_URL(profile->tls_bindurl)), Modified: freeswitch/trunk/src/switch_event.c ============================================================================== --- freeswitch/trunk/src/switch_event.c (original) +++ freeswitch/trunk/src/switch_event.c Tue Mar 31 15:51:35 2009 @@ -1119,9 +1119,10 @@ for (;;) { for (index = (*event)->priority; index < 3; index++) { + int was = (*event)->priority; if (switch_queue_trypush(EVENT_QUEUE[index], *event) == SWITCH_STATUS_SUCCESS) { - if (index != (*event)->priority) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority!\n"); + if (index != was) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority %d/%d!\n", index, was); } goto end; } From mikej at freeswitch.org Tue Mar 31 13:54:32 2009 From: mikej at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 15:54:32 -0500 Subject: [Freeswitch-svn] [commit] r12857 - in freeswitch/trunk: libs/sofia-sip/libsofia-sip-ua/nta src src/mod/endpoints/mod_sofia Message-ID: Author: mikej Date: Tue Mar 31 15:54:31 2009 New Revision: 12857 Log: revert Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_event.c Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Mar 31 15:54:31 2009 @@ -3319,10 +3319,8 @@ msg_maxsize(msg, agent->sa_maxsize); - if (1 || agent->sa_preload) { - isize_t preload = (dlen + agent->sa_preload + 1023) & ~1023; - su_home_preload(msg_home(msg), 1, preload); - } + if (agent->sa_preload) + su_home_preload(msg_home(msg), 1, dlen + agent->sa_preload); return msg; } Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Mar 31 15:54:31 2009 @@ -744,7 +744,6 @@ sofia_event_callback, /* Callback for processing events */ profile, /* Additional data to pass to callback */ NUTAG_URL(profile->bindurl), - NTATAG_PRELOAD(2048), TAG_IF(!strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP4_ONLY)), TAG_IF(strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP6_ONLY)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_SIPS_URL(profile->tls_bindurl)), Modified: freeswitch/trunk/src/switch_event.c ============================================================================== --- freeswitch/trunk/src/switch_event.c (original) +++ freeswitch/trunk/src/switch_event.c Tue Mar 31 15:54:31 2009 @@ -1119,10 +1119,9 @@ for (;;) { for (index = (*event)->priority; index < 3; index++) { - int was = (*event)->priority; if (switch_queue_trypush(EVENT_QUEUE[index], *event) == SWITCH_STATUS_SUCCESS) { - if (index != was) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority %d/%d!\n", index, was); + if (index != (*event)->priority) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority!\n"); } goto end; } From anthm at freeswitch.org Tue Mar 31 13:55:26 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 15:55:26 -0500 Subject: [Freeswitch-svn] [commit] r12858 - freeswitch/trunk/src Message-ID: Author: anthm Date: Tue Mar 31 15:55:26 2009 New Revision: 12858 Log: linux... how did that not crash every time Modified: freeswitch/trunk/src/switch_event.c Modified: freeswitch/trunk/src/switch_event.c ============================================================================== --- freeswitch/trunk/src/switch_event.c (original) +++ freeswitch/trunk/src/switch_event.c Tue Mar 31 15:55:26 2009 @@ -1119,9 +1119,10 @@ for (;;) { for (index = (*event)->priority; index < 3; index++) { + int was = (*event)->priority; if (switch_queue_trypush(EVENT_QUEUE[index], *event) == SWITCH_STATUS_SUCCESS) { - if (index != (*event)->priority) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority!\n"); + if (index != was) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "queued event at a lower priority %d/%d!\n", index, was); } goto end; } From stkn at freeswitch.org Tue Mar 31 16:36:35 2009 From: stkn at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 18:36:35 -0500 Subject: [Freeswitch-svn] [commit] r12859 - freeswitch/trunk/src/mod/asr_tts/mod_flite Message-ID: Author: stkn Date: Tue Mar 31 18:36:35 2009 New Revision: 12859 Log: Flite does not like the "-std=c99" flag, use the fix from mod_xml_ldap (for openldap) to remove it from CFLAGS before calling the flite configure script Modified: freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile Modified: freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile ============================================================================== --- freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile (original) +++ freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile Tue Mar 31 18:36:35 2009 @@ -17,7 +17,7 @@ $(GETLIB) $(FLITE)-latest.tar.gz $(FLITE_DIR)/Makefile: $(FLITE_DIR) - cd $(FLITE_DIR) && ./configure --without-audio --with-pic --disable-shared + cd $(FLITE_DIR) && CFLAGS="`echo $(CFLAGS) | sed -e 's:-std=c99::'`" ./configure --without-audio --with-pic --disable-shared $(TOUCH_TARGET) $(FLITE_A): $(FLITE_DIR) $(FLITE_DIR)/Makefile From anthm at freeswitch.org Tue Mar 31 16:56:47 2009 From: anthm at freeswitch.org (FreeSWITCH SVN) Date: Tue, 31 Mar 2009 18:56:47 -0500 Subject: [Freeswitch-svn] [commit] r12860 - in freeswitch/trunk/src/mod/languages: mod_lua mod_perl mod_python mod_spidermonkey Message-ID: Author: anthm Date: Tue Mar 31 18:56:47 2009 New Revision: 12860 Log: remove old code Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c freeswitch/trunk/src/mod/languages/mod_python/mod_python.c freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp (original) +++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp Tue Mar 31 18:56:47 2009 @@ -438,38 +438,11 @@ return SWITCH_STATUS_SUCCESS; } -static void message_query_handler(switch_event_t *event) -{ - char *account = switch_event_get_header(event, "message-account"); - - if (account) { - char *path, *cmd; - - path = switch_mprintf("%s%smwi.lua", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR); - switch_assert(path != NULL); - - if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) { - cmd = switch_mprintf("%s %s", path, account); - switch_assert(cmd != NULL); - lua_thread(cmd); - switch_safe_free(cmd); - } - - switch_safe_free(path); - } -} - SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load) { switch_api_interface_t *api_interface; switch_application_interface_t *app_interface; - if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL, &globals.node) - != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); - return SWITCH_STATUS_GENERR; - } - /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c (original) +++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c Tue Mar 31 18:56:47 2009 @@ -429,24 +429,6 @@ return xml; } -static void message_query_handler(switch_event_t *event) -{ - char *account = switch_event_get_header(event, "message-account"); - - if (account) { - char path[512], *cmd; - - switch_snprintf(path, sizeof(path), "%s%smwi.pl", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR); - - if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) { - cmd = switch_mprintf("%s %s", path, account); - switch_assert(cmd != NULL); - perl_thread(cmd); - switch_safe_free(cmd); - } - } -} - static switch_status_t do_config(void) { char *cf = "perl.conf"; @@ -491,12 +473,6 @@ globals.pool = pool; - if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL, &globals.node) - != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); - return SWITCH_STATUS_GENERR; - } - if (!(my_perl = perl_alloc())) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate perl interpreter\n"); return SWITCH_STATUS_MEMERR; Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_python/mod_python.c (original) +++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.c Tue Mar 31 18:56:47 2009 @@ -333,26 +333,6 @@ return 0; } -static void message_query_handler(switch_event_t *event) -{ - char *account = switch_event_get_header(event, "message-account"); - - if (account) { - char *path, *cmd; - - path = switch_mprintf("%s%smwi.py", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR); - switch_assert(path != NULL); - - if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) { - cmd = switch_mprintf("%s %s", path, account); - switch_assert(cmd != NULL); - py_thread(cmd); - switch_safe_free(cmd); - } - switch_safe_free(path); - } -} - SWITCH_STANDARD_API(launch_python) { @@ -372,12 +352,6 @@ switch_application_interface_t *app_interface; char *pp = getenv("PYTHONPATH"); - if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL, &globals.node) - != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); - return SWITCH_STATUS_GENERR; - } - if (pp) { char *path = switch_mprintf("%s:%s", pp, SWITCH_GLOBAL_dirs.script_dir); setenv("PYTHONPATH", path, 1); Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c ============================================================================== --- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original) +++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Tue Mar 31 18:56:47 2009 @@ -3695,27 +3695,6 @@ return SWITCH_STATUS_SUCCESS; } -static void message_query_handler(switch_event_t *event) -{ - char *account = switch_event_get_header(event, "message-account"); - - if (account) { - char *path, *cmd; - - path = switch_mprintf("%s%smwi.js", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR); - switch_assert(path != NULL); - - if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) { - cmd = switch_mprintf("%s %s", path, account); - switch_assert(cmd != NULL); - js_thread_launch(cmd); - switch_safe_free(cmd); - } - - switch_safe_free(path); - } -} - SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load) { switch_application_interface_t *app_interface; @@ -3725,12 +3704,6 @@ return status; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL, &globals.node) - != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); - return SWITCH_STATUS_GENERR; - } - /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_API(js_run_interface, "jsrun", "run a script", launch_async, "jsrun