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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +