Author: mikej Date: Tue Jan 2 10:11:55 2007 New Revision: 3888 Added: freeswitch/trunk/libs/sofia-sip/configure.gnu freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c Removed: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/date_test.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/run_date_test Modified: freeswitch/trunk/libs/sofia-sip/AUTHORS freeswitch/trunk/libs/sofia-sip/RELEASE freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sofia.am freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_time.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Doxyfile freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4 Log: update to latest darcs sofia Modified: freeswitch/trunk/libs/sofia-sip/AUTHORS ============================================================================== --- freeswitch/trunk/libs/sofia-sip/AUTHORS (original) +++ freeswitch/trunk/libs/sofia-sip/AUTHORS Tue Jan 2 10:11:55 2007 @@ -5,17 +5,30 @@ Martti Mela <martti.mela -at nokia -dot com> Kai Vehmanen <kai.vehmanen -at nokia -dot com> -Contributors (in alphabetical order) ------------------------------------- +Contributors (in alphabetical order, surname first) +--------------------------------------------------- -Chan, Tat -Haataja, Mikko -Jacobs, Remeres -Jalava, Teemu +Chan, Tat <first.surname@nokia.com> +Ciarkowski, Andrzej <wp-voigtkampff -at users -dot sourceforge -dot net> +Haataja, Mikko <first.surname@nokia.com> +Jacobs, Remeres <first.surname@nokia.com> +Jalava, Teemu <first.surname@nokia.com> Jerris, Michael <mike -at jerris -dot com> +Legostayev Denis <legostayev -at neic -dot nsk -dot su> Prado, Dimitri E. <dprado -at e3c -dot com -dot br> -Puustinen, Ismo -Rinne-Rahkola, Pasi -Saari, Mika -Selin, Jari -Urpalainen, Jari +Puolakka, Petteri <first.surname@nokia.com> +Puustinen, Ismo <first.surname@nokia.com> +Rinne-Rahkola, Pasi <first.surname@nokia.com> +Saari, Mika <first.surname@nokia.com> +Selin, Jari <first.surname@nokia.com> +Underwood, Steve <steveu -at coppice -dot org> +Urpalainen, Jari <first.surname@nokia.com> +Whittaker, Colin <colinw -at occamnetworks -dot com> +Zabaluev, Mikhail <first.surname@nokia.com> + + +Note: for details on who did what, see the version control + system change history, and release notes for past releases at + http://sofia-sip.sourceforge.net/relnotes/ + + \ No newline at end of file Modified: freeswitch/trunk/libs/sofia-sip/RELEASE ============================================================================== --- freeswitch/trunk/libs/sofia-sip/RELEASE (original) +++ freeswitch/trunk/libs/sofia-sip/RELEASE Tue Jan 2 10:11:55 2007 @@ -55,6 +55,7 @@ - **template**: First Surname (patch to nua/soa/msg) - Petteri Puolakka (patch to stun) +- Mikhail Zabluev (patch to su-glib mainloop integration) See the AUTHORS file in the distribution package. @@ -94,3 +95,8 @@ Roman Filonenko. - Bug in zero-padding STUN messages with a message integrity attribute. Patch by Petteri Puolakka. +- Fixed a severe problem with timer accuracy, when sofia-sip timers + where used under glib's mainloop. +- Improved glib mainloop integration to avoid warnings about already + active mainloop context, and potentially other issue. Patch by + Mikhail Zabaluev. Closes sf.net item #1606786. Added: freeswitch/trunk/libs/sofia-sip/configure.gnu ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/configure.gnu Tue Jan 2 10:11:55 2007 @@ -0,0 +1,2 @@ +#! /bin/sh +./configure $@ --with-pic --with-glib=no 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 Tue Jan 2 10:11:55 2007 @@ -19,12 +19,12 @@ noinst_LTLIBRARIES = libsu-glib.la -check_PROGRAMS = su_source_test +check_PROGRAMS = su_source_test torture_su_glib_timer # ---------------------------------------------------------------------- # Tests -TESTS = su_source_test +TESTS = su_source_test torture_su_glib_timer # ---------------------------------------------------------------------- # Rules for building the targets Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c Tue Jan 2 10:11:55 2007 @@ -319,34 +319,28 @@ enter; - if (self->sup_head) + if (self->sup_head) { + *return_tout = 0; return TRUE; - - *return_tout = -1; + } if (self->sup_timers) { su_time_t now; GTimeVal gtimeval; su_duration_t tout; - tout = SU_DURATION_MAX; - g_source_get_current_time(gs, >imeval); - now.tv_sec = gtimeval.tv_sec + 2208988800UL; now.tv_usec = gtimeval.tv_usec; tout = su_timer_next_expires(self->sup_timers, now); - if (tout == 0) - return TRUE; - - if ((gint)tout < 0 || tout > (su_duration_t)G_MAXINT) - tout = -1; + *return_tout = (tout < 0 || tout > (su_duration_t)G_MAXINT)? + -1 : (gint)tout; - *return_tout = (gint)tout; + return (tout == 0); } - + return FALSE; } @@ -995,30 +989,30 @@ gmc = g_source_get_context(self->sup_source); if (gmc && g_main_context_acquire(gmc)) { + GPollFD *fds = NULL; + gint fds_size = 0; + gint fds_wait; gint priority = G_MAXINT; - if (g_main_context_prepare(gmc, &priority)) { - g_main_context_dispatch(gmc); - } else { - gint timeout = tout > G_MAXINT ? G_MAXINT : tout; - gint i, n = 0; - GPollFD *fds = NULL; - - priority = G_MAXINT; - - n = g_main_context_query(gmc, priority, &timeout, fds, n); - if (n > 0) { - fds = g_alloca(n * (sizeof *fds)); - n = g_main_context_query(gmc, priority, &timeout, fds, n); - } + gint src_tout = -1; - if (tout < timeout) - timeout = tout; + g_main_context_prepare(gmc, &priority); - i = su_wait((su_wait_t *)fds, n, timeout); - - if (g_main_context_check(gmc, priority, fds, n)) - g_main_context_dispatch(gmc); + fds_wait = g_main_context_query(gmc, priority, &src_tout, NULL, 0); + while (fds_wait > fds_size) { + fds = g_alloca(fds_wait * sizeof(fds[0])); + fds_size = fds_wait; + fds_wait = g_main_context_query(gmc, priority, &src_tout, fds, fds_size); } + + if (src_tout >= 0 && tout > (su_duration_t)src_tout) + tout = src_tout; + + su_wait((su_wait_t *)fds, fds_wait, tout); + + g_main_context_check(gmc, priority, fds, fds_wait); + + g_main_context_dispatch(gmc); + g_main_context_release(gmc); } Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am Tue Jan 2 10:11:55 2007 @@ -90,7 +90,7 @@ for d in $(DIST_SUBDIRS); do \ test -r $$d/Doxyfile \ && pushd $$d > /dev/null \ - && echo running ${DOXYGEN} in second time in $$d \ + && echo running ${DOXYGEN} second time in $$d \ && ${DOXYGEN} 2>&1 \ | egrep -v -i -e 'Warning: Unsupported (xml/)?html tag' \ ; popd > /dev/null ; \ 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 Jan 2 10:11:55 2007 @@ -3074,13 +3074,6 @@ if (!sip->sip_max_forwards) sip_add_dup(msg, sip, (sip_header_t *)leg->leg_agent->sa_max_forwards); - if (!sip->sip_call_id) { - if (leg->leg_id) - sip->sip_call_id = sip_call_id_dup(home, leg->leg_id); - else - sip->sip_call_id = sip_call_id_create(home, NULL); - } - if (!sip->sip_from) sip->sip_from = sip_from_dup(home, leg->leg_local); else if (leg->leg_local && leg->leg_local->a_tag && @@ -3113,7 +3106,10 @@ method = sip->sip_request->rq_method; method_name = sip->sip_request->rq_method_name; - if (method == sip_method_ack || method == sip_method_cancel) + if (!leg->leg_id && !sip->sip_call_id && sip->sip_cseq) + seq = sip->sip_cseq->cs_seq; + else if (method == sip_method_ack || method == sip_method_cancel) + /* Dangerous - we may do PRACK/UPDATE meanwhile */ seq = sip->sip_cseq ? sip->sip_cseq->cs_seq : leg->leg_seq; else if (leg->leg_seq) seq = ++leg->leg_seq; @@ -3122,6 +3118,13 @@ else seq = leg->leg_seq = (sip_now() >> 1) & 0x7ffffff; + if (!sip->sip_call_id) { + if (leg->leg_id) + sip->sip_call_id = sip_call_id_dup(home, leg->leg_id); + else + sip->sip_call_id = sip_call_id_create(home, NULL); + } + if ((!sip->sip_cseq || seq != sip->sip_cseq->cs_seq || method != sip->sip_cseq->cs_method || @@ -9718,6 +9721,9 @@ * @param magic * @param to_tag * @param rseq + * + * @bug Fix the memory leak - either one of the requests is left unreleased + * for ever. */ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq, nta_response_f *callback, @@ -9757,8 +9763,8 @@ tagged->orq_to = to; tagged->orq_tport = tport_ref(orq->orq_tport); - tagged->orq_request = (msg_t *)msg_ref_create(orq->orq_request); - tagged->orq_response = NULL; + 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, Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c Tue Jan 2 10:11:55 2007 @@ -138,7 +138,7 @@ a->a_params = NULL; if (!a->a_display) a->a_display = ""; - return sl_header_log(log, level, fmt, (sip_header_t *)a); + sl_header_log(log, level, fmt, (sip_header_t *)a); } /**Log a @To header. Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am Tue Jan 2 10:11:55 2007 @@ -17,7 +17,7 @@ noinst_LTLIBRARIES = libsip.la check_PROGRAMS = torture_sip \ - test_sip_msg validator date_test + test_sip_msg validator test_date # ---------------------------------------------------------------------- # Rules for building the targets @@ -59,7 +59,7 @@ torture_sip_LDFLAGS = -static test_sip_msg_LDFLAGS = -static -date_test_LDFLAGS = -static +test_date_LDFLAGS = -static # ---------------------------------------------------------------------- # Install and distribution rules @@ -93,9 +93,9 @@ # ---------------------------------------------------------------------- # Tests -#TESTS = torture_sip run_test_sip_msg run_date_test +#TESTS = torture_sip run_test_sip_msg run_test_date -#dist_noinst_SCRIPTS = run_test_sip_msg run_date_test +#dist_noinst_SCRIPTS = run_test_sip_msg run_test_date # ---------------------------------------------------------------------- # Sofia specific rules Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c ============================================================================== --- (empty file) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c Tue Jan 2 10:11:55 2007 @@ -0,0 +1,116 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2005 Nokia Corporation. + * + * Contact: Pekka Pessi <pekka.pessi@nokia.com> + * + * 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 + * + */ + +/**@internal + * + * @CFILE test_date.c + * + * Tester for SIP date parser + * + * @author Pekka Pessi <Pekka.Pessi@nokia.com>. + * + * @date Wed Mar 21 19:12:13 2001 ppessi + */ + +#include <stdio.h> +#include <sofia-sip/string0.h> +#include <stddef.h> +#include <stdlib.h> + +#include <sofia-sip/sip.h> +#include <sofia-sip/sip_header.h> +#include <sofia-sip/msg_date.h> + +void usage(void) +{ + fprintf(stderr, + "usage: test_date [SIP-date] " + "[YYYYy][DDd][HHh][MMm][SS[s]]\n"); + exit(1); +} + +int main(int ac, char *av[]) +{ + int i; + sip_time_t t, delta, t2; + char const *s; + int verbatim = 0, retval = 0; + + t = ((31 + 27) * 24) * 60 * 60; + delta = (365 * 24 + 6) * 60 * 60; + + if (str0cmp(av[1], "-v") == 0) + verbatim = 1, av++; + + if ((s = av[1])) { + if (msg_date_d(&s, &t) < 0) { + fprintf(stderr, "test_date: %s is not valid time\n", s); + exit(1); + } + + if ((s = av[2])) { + for (delta = 0; *s; ) { + t2 = 0; + msg_delta_d(&s, &t2); + + switch (*s++) { + case 'y': delta += t2 * (365 * 24 + 6) * 60 * 60; break; + case 'd': delta += t2 * 24 * 60 * 60; break; + case 'h': delta += t2 * 60 * 60; break; + case 'm': delta += t2 * 60; break; + case '\0': --s; /* FALLTHROUGH */ + case 's': delta += t2; break; + default: + fprintf(stderr, "test_date: %s is not valid time offset\n" , av[2]); + usage(); + break; + } + } + } + } + + for (i = 0; i < 20; i++) { + char buf[80]; + + msg_date_e(buf, sizeof(buf), t); + + if (verbatim) + printf("%08lx is %s\n", t, buf); + + s = buf, t2 = 0; + if (msg_date_d(&s, &t2) < 0) { + fprintf(stderr, "test_date: decoding %s failed\n", buf); + retval = 1; + break; + } + else if (t2 != t) { + fprintf(stderr, "test_date: %lu != %lu\n", t, t2); + retval = 1; + break; + } + t += delta; + } + + return retval; +} Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sofia.am ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sofia.am (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sofia.am Tue Jan 2 10:11:55 2007 @@ -1,7 +1,12 @@ # common Makefile targets for libsofia-sip-ua modules # --------------------------------------------------- -AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) +AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) $(SOFIA_COVERAGE) + +# Use with --enable-ndebug +if NDEBUG +AM_CFLAGS += -DNDEBUG +endif built-sources: $(BUILT_SOURCES) Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c Tue Jan 2 10:11:55 2007 @@ -58,6 +58,10 @@ #include <sofia-sip/su_tag_inline.h> #include <sofia-sip/su_tagarg.h> +#ifndef HAVE_STRTOULL +unsigned longlong strtoull(const char *, char **, int); +#endif + /**@defgroup su_tag Tag Item Lists * * Object-oriented tag routines for Sofia utility library. Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_time.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_time.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_time.c Tue Jan 2 10:11:55 2007 @@ -165,17 +165,16 @@ /** Time difference in milliseconds. * - * Calculates the duration from t2 to t1 in milliseconds. + * Calculates the duration from t2 to t1 in milliseconds. * * @param t1 after time * @param t2 before time * - * @return - * The duration in milliseconds between the two times. If the difference - * is bigger than @c SU_DURATION_MAX, the function su_duration() returns - * @c SU_DURATION_MAX instead. If the difference is smaller than @c - * -SU_DURATION_MAX, the function su_duration() returns @c - * -SU_DURATION_MAX. + * @return The duration in milliseconds between the two times. + * If the difference is bigger than #SU_DURATION_MAX, return #SU_DURATION_MAX + * instead. + * If the difference is smaller than -#SU_DURATION_MAX, return + * -#SU_DURATION_MAX. */ su_duration_t su_duration(su_time_t const t1, su_time_t const t2) { Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Doxyfile ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Doxyfile (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Doxyfile Tue Jan 2 10:11:55 2007 @@ -7,7 +7,10 @@ TAGFILES += \ ../docs/su.doxytags=../su \ - ../docs/msg.doxytags=../msg + ../docs/msg.doxytags=../msg \ + ../docs/nth.doxytags=../nth \ + ../docs/nta.doxytags=../nta \ + ../docs/nua.doxytags=../nua \ GENERATE_TAGFILE = ../docs/tport.doxytags Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h Tue Jan 2 10:11:55 2007 @@ -51,28 +51,46 @@ TPORT_DLL extern tag_typedef_t tptag_any; TPORT_DLL extern tag_typedef_t tptag_ident; -/** Ident transport connection (true by default). */ +/**Identify a transport interface. + * + * Use with tport_tbind(), tport_tsend(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nta_outgoing_tcreate(), nta_outgoing_mcreate(), + * nth_engine_create(), nth_client_tcreate(), or initial nth_site_create(). + */ #define TPTAG_IDENT(x) tptag_ident, tag_str_v((x)) TPORT_DLL extern tag_typedef_t tptag_ident_ref; #define TPTAG_IDENT_REF(x) tptag_ident_ref, tag_str_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_reuse; -/** Allow reusing transport connection (true by default). */ +/** Allow reusing transport connection (true by default). + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), + * tport_tsend(), nua_create(), nta_agent_create(), nta_agent_add_tport(), + * nta_outgoing_tcreate(), nta_outgoing_mcreate(), nth_engine_create(), + * nth_client_tcreate(), or initial nth_site_create(). + */ #define TPTAG_REUSE(x) tptag_reuse, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_reuse_ref; #define TPTAG_REUSE_REF(x) tptag_reuse_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_fresh; -/** Create new connection (but allow reusing new one). */ +/** Create new connection (but allow other messages to reuse the new one). + * + * Use with tport_tsend(), nta_outgoing_tcreate(), nta_outgoing_mcreate(), + * or nth_client_tcreate(). + */ #define TPTAG_FRESH(x) tptag_fresh, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_fresh_ref; #define TPTAG_FRESH_REF(x) tptag_fresh_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_server; -/** Bind server sockets (true by default, disable with TPTAG_SERVER(0)). */ +/** Bind server sockets (true by default, disable with TPTAG_SERVER(0)). + * + * Use with tport_tbind(). + */ #define TPTAG_SERVER(x) tptag_server, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_server_ref; @@ -93,58 +111,99 @@ } tport_pri_type_t; TPORT_DLL extern tag_typedef_t tptag_public; -/** Use a transport reaching to public Internet. */ +/** Use a transport reaching to public Internet. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). + */ #define TPTAG_PUBLIC(x) tptag_public, tag_int_v((x)) TPORT_DLL extern tag_typedef_t tptag_public_ref; #define TPTAG_PUBLIC_REF(x) tptag_public_ref, tag_int_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_mtu; -/** Specify MTU. */ +/** Specify MTU. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), + * tport_tsend(), nua_create(), nta_agent_create(), nta_agent_add_tport(), + * nta_outgoing_tcreate(), nta_outgoing_mcreate(), nth_engine_create(), + * nth_client_tcreate(), or initial nth_site_create(). + */ #define TPTAG_MTU(x) tptag_mtu, tag_usize_v((x)) TPORT_DLL extern tag_typedef_t tptag_mtu_ref; #define TPTAG_MTU_REF(x) tptag_mtu_ref, tag_usize_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_connect; -/** Specify that tport must always use connections. */ +/** Specify that tport must always use connections (even with UDP). + * + * @note Unimplemented (?). + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). + */ #define TPTAG_CONNECT(x) tptag_connect, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_connect_ref; #define TPTAG_CONNECT_REF(x) tptag_connect_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_queuesize; -/** Specify the number of messages that can be queued per connection. */ +/** Specify the number of messages that can be queued per connection. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). + */ #define TPTAG_QUEUESIZE(x) tptag_queuesize, tag_uint_v((x)) TPORT_DLL extern tag_typedef_t tptag_queuesize_ref; #define TPTAG_QUEUESIZE_REF(x) tptag_queuesize_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_sdwn_error; -/** If true, half close of a connection by remote is considered as an error. */ +/** If true, half close of a connection by remote is considered as an error. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). + */ #define TPTAG_SDWN_ERROR(x) tptag_sdwn_error, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_sdwn_error_ref; #define TPTAG_SDWN_ERROR_REF(x) tptag_sdwn_error_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_sdwn_after; -/** Half-close (shutdown(c, 1) after sending the message. */ +/** Half-close (shutdown(c, 1)) after sending the message. + * + * Use with tport_tsend(), nta_outgoing_tcreate(), nta_outgoing_mcreate(), + * or nth_client_tcreate(). + */ #define TPTAG_SDWN_AFTER(x) tptag_sdwn_after, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_sdwn_after_ref; #define TPTAG_SDWN_AFTER_REF(x) tptag_sdwn_after_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_close_after; -/** Close of a connection after sending the message. */ +/** Close of a connection after sending the message. + * + * Use with tport_tsend(), nta_outgoing_tcreate(), nta_outgoing_mcreate(), + * or nth_client_tcreate(). + */ #define TPTAG_CLOSE_AFTER(x) tptag_close_after, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_close_after_ref; #define TPTAG_CLOSE_AFTER_REF(x) tptag_close_after_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_idle; -/** How long transports may be idle (value in milliseconds). +/** How long transports may be idle (value in milliseconds). + * * If 0, zap immediately, * if UINT_MAX, leave them there (default value for now). + * + * @par Use With + * tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). */ #define TPTAG_IDLE(x) tptag_idle, tag_uint_v((x)) @@ -156,6 +215,10 @@ * * If UINT_MAX, leave the incomplete messages there for ever. * Default value for now is UINT_MAX. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). */ #define TPTAG_TIMEOUT(x) tptag_timeout, tag_uint_v((x)) @@ -163,11 +226,15 @@ #define TPTAG_TIMEOUT_REF(x) tptag_timeout_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_sigcomp_lifetime; -/**Default SigComp lifetime. +/**Default SigComp lifetime in seconds. * - * If UINT_MAX, keep SigComp compartments around for ever. + * If value is UINT_MAX, keep SigComp compartments around for ever. * * @note Experimental. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). */ #define TPTAG_SIGCOMP_LIFETIME(x) tptag_sigcomp_lifetime, tag_uint_v((x)) @@ -176,7 +243,10 @@ tptag_sigcomp_lifetime_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_compartment; -/** Pointer to SigComp compartment. */ +/** Pointer to SigComp compartment. + * + * @note Not used. + */ #define TPTAG_COMPARTMENT(x) tptag_compartment, tag_ptr_v((x)) TPORT_DLL extern tag_typedef_t tptag_compartment_ref; @@ -185,6 +255,9 @@ TPORT_DLL extern tag_typedef_t tptag_certificate; /** Path to the public key certificate directory. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). */ #define TPTAG_CERTIFICATE(x) tptag_certificate, tag_str_v((x)) @@ -193,43 +266,80 @@ TPORT_DLL extern tag_typedef_t tptag_tls_version; /** Sets the TLS version (version 0 implies SSL2/SSL3). + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). */ #define TPTAG_TLS_VERSION(x) tptag_tls_version, tag_uint_v((x)) TPORT_DLL extern tag_typedef_t tptag_tls_version_ref; #define TPTAG_TLS_VERSION_REF(x) tptag_tls_version_ref, tag_uint_vr(&(x)) +#if 0 TPORT_DLL extern tag_typedef_t tptag_trusted; -/** Mark transport as trusted. */ +/** Mark transport as trusted. + * + * @note Not implemented. +*/ #define TPTAG_TRUSTED(x) tptag_trusted, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_trusted_ref; #define TPTAG_TRUSTED_REF(x) tptag_trusted_ref, tag_bool_vr(&(x)) +#endif TPORT_DLL extern tag_typedef_t tptag_debug_drop; -/** Sets the drop propability for (0..1000) incoming/outgoing packets. */ +/** Sets the drop propability for (0..1000) incoming/outgoing packets. + * + * This is a parameter suitable for debugging only. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). + */ #define TPTAG_DEBUG_DROP(x) tptag_debug_drop, tag_uint_v((x)) TPORT_DLL extern tag_typedef_t tptag_debug_drop_ref; #define TPTAG_DEBUG_DROP_REF(x) tptag_debug_drop_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_udp_rmem; -/** Sets the maximum receive buffer in bytes for primary UDP socket. */ +/** Sets the maximum receive buffer in bytes for primary UDP socket. + * + * This is a parameter suitable for tuning. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). + */ #define TPTAG_UDP_RMEM(x) tptag_udp_rmem, tag_uint_v((x)) TPORT_DLL extern tag_typedef_t tptag_udp_rmem_ref; #define TPTAG_UDP_RMEM_REF(x) tptag_udp_rmem_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_udp_wmem; -/** Sets the maximum send buffer in bytes for primary UDP socket. */ +/** Sets the maximum send buffer in bytes for primary UDP socket. + * + * This is a parameter suitable for tuning. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). + */ #define TPTAG_UDP_WMEM(x) tptag_udp_wmem, tag_uint_v((x)) TPORT_DLL extern tag_typedef_t tptag_udp_wmem_ref; #define TPTAG_UDP_WMEM_REF(x) tptag_udp_wmem_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_thrpsize; -/** Determines the number of threads in the pool receiving, uncompressing, +/**Determines the number of threads in the pool. + * + * The thread pools can have multiple threads receiving, uncompressing, * parsing, compressing, and sending messages. + * + * This is a parameter suitable for tuning. + * + * @note Thread pools are currently broken. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). */ #define TPTAG_THRPSIZE(x) tptag_thrpsize, tag_uint_v((x)) @@ -237,7 +347,13 @@ #define TPTAG_THRPSIZE_REF(x) tptag_thrpsize_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_thrprqsize; -/** Length of per-thread receive queue (as messages) +/** Length of per-thread receive queue (as messages). + * + * This is a parameter suitable for tuning. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). */ #define TPTAG_THRPRQSIZE(x) tptag_thrprqsize, tag_uint_v((x)) @@ -245,26 +361,66 @@ #define TPTAG_THRPRQSIZE_REF(x) tptag_thrprqsize_ref, tag_uint_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_http_connect; -/** Specify that tport can use HTTP connect method. */ +/** Specify that tport can use HTTP connect method. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). + */ #define TPTAG_HTTP_CONNECT(x) tptag_http_connect, tag_str_v((x)) TPORT_DLL extern tag_typedef_t tptag_http_connect_ref; #define TPTAG_HTTP_CONNECT_REF(x) tptag_http_connect_ref, tag_str_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_stun_server; -/** Enable STUN server. */ +/** Enable STUN server. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). + */ #define TPTAG_STUN_SERVER(x) tptag_stun_server, tag_bool_v((x)) TPORT_DLL extern tag_typedef_t tptag_stun_server_ref; #define TPTAG_STUN_SERVER_REF(x) tptag_stun_server_ref, tag_bool_vr(&(x)) TPORT_DLL extern tag_typedef_t tptag_tos; -/** Sets the IP TOS for the socket. */ +/** Sets the IP TOS for the socket. + * + * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(), + * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or + * initial nth_site_create(). + */ #define TPTAG_TOS(x) tptag_tos, tag_int_v((x)) TPORT_DLL extern tag_typedef_t tptag_tos_ref; #define TPTAG_TOS_REF(x) tptag_tos_ref, tag_int_vr(&(x)) +TPORT_DLL extern tag_typedef_t tptag_log; +/** If set, print out parsed or sent messages at transport layer. + * + * Use with tport_tcreate(), nua_create(), nta_agent_create(), + * nth_engine_create(), or initial nth_site_create(). + * + * @sa #TPORT_DUMP, TPTAG_DUMP() + */ +#define TPTAG_LOG(x) tptag_log, tag_bool_v((x)) + +TPORT_DLL extern tag_typedef_t tptag_log_ref; +#define TPTAG_LOG_REF(x) tptag_log_ref, tag_bool_vr(&(x)) + +TPORT_DLL extern tag_typedef_t tptag_dump; +/** Filename for dumping unparsed messages from transport. + * + * Use with tport_tcreate(), nta_agent_create(), nua_create(), + * nth_engine_create(), or initial nth_site_create(). + * + * @sa #TPORT_DUMP, TPTAG_LOG(). + */ +#define TPTAG_DUMP(x) tptag_dump, tag_str_v((x)) + +TPORT_DLL extern tag_typedef_t tptag_dump_ref; +#define TPTAG_DUMP_REF(x) tptag_dump_ref, tag_str_vr(&(x)) + SOFIA_END_DECLS #endif /* !defined TPORT_TAG_H */ 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 Jan 2 10:11:55 2007 @@ -286,7 +286,7 @@ } /** Test if transport connection has been established. @NEW_1_12_5 */ -inline int tport_is_connected(tport_t const *self) +int tport_is_connected(tport_t const *self) { return self->tp_is_connected; } @@ -308,7 +308,7 @@ { if (tos >= 0 && ai->ai_family == AF_INET && - setsockopt(socket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) { + setsockopt(socket, IPPROTO_IP, IP_TOS, (const void*)&tos, sizeof(tos)) < 0) { SU_DEBUG_3(("tport: setsockopt(IP_TOS): %s\n", su_strerror(su_errno()))); } @@ -427,7 +427,12 @@ /** Name for "any" transport. @internal */ static char const tpn_any[] = "*"; -/** Create the master transport. */ +/** Create the master transport. + * + * @TAGS + * TPTAG_LOG(), TPTAG_DUMP(), tags used with tport_set_params(), especially + * TPTAG_QUEUESIZE(). + */ tport_t *tport_tcreate(tp_stack_t *stack, tp_stack_class_t const *tpac, su_root_t *root, @@ -1128,6 +1133,12 @@ * * @param self pointer to a transport object * @param tag,value,... list of tags + * + * @TAGS + * TPTAG_MTU(), TPTAG_QUEUESIZE(), TPTAG_IDLE(), TPTAG_TIMEOUT(), + * TPTAG_DEBUG_DROP(), TPTAG_THRPSIZE(), TPTAG_THRPRQSIZE(), + * TPTAG_SIGCOMP_LIFETIME(), TPTAG_CONNECT(), TPTAG_SDWN_ERROR(), + * TPTAG_REUSE(), TPTAG_STUN_SERVER(), and TPTAG_TOS(). */ int tport_set_params(tport_t *self, tag_type_t tag, tag_value_t value, ...) @@ -1138,8 +1149,6 @@ int connect, sdwn_error, reusable, stun_server; - struct sigcomp_compartment *cc = NONE; - if (self == NULL) return su_seterrno(EINVAL); @@ -1164,7 +1173,6 @@ TPTAG_CONNECT_REF(connect), TPTAG_SDWN_ERROR_REF(sdwn_error), TPTAG_REUSE_REF(reusable), - TPTAG_COMPARTMENT_REF(cc), TPTAG_STUN_SERVER_REF(stun_server), TPTAG_TOS_REF(tpp->tpp_tos), TAG_END()); @@ -1324,6 +1332,11 @@ * @param tpn desired transport address * @param transports list of protocol names supported by stack * @param tag,value,... tagged argument list + * + * @TAGS + * TPTAG_SERVER(), TPTAG_PUBLIC(), TPTAG_IDENT(), TPTAG_HTTP_CONNECT(), + * TPTAG_CERTIFICATE(), TPTAG_TLS_VERSION(), and tags used with + * tport_set_params(), especially TPTAG_QUEUESIZE(). */ int tport_tbind(tport_t *self, tp_name_t const *tpn, @@ -2940,6 +2953,7 @@ * * @TAGS * TPTAG_MTU(), TPTAG_REUSE(), TPTAG_CLOSE_AFTER(), TPTAG_SDWN_AFTER(), + * TPTAG_FRESH(), TPTAG_COMPARTMENT(). */ tport_t *tport_tsend(tport_t *self, msg_t *msg, @@ -4526,5 +4540,3 @@ return buf; } - -/* ---------------------------------------------------------------------- */ Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c Tue Jan 2 10:11:55 2007 @@ -90,14 +90,24 @@ /** Initialize logging. */ void tport_open_log(tport_master_t *mr, tagi_t *tags) { - char const *log; - - mr->mr_log = - getenv("MSG_STREAM_LOG") != NULL || - getenv("TPORT_LOG") != NULL - ? MSG_DO_EXTRACT_COPY : 0; - - if ((log = getenv("TPORT_DUMP")) || (log = getenv("MSG_DUMP"))) { + char const *log = NULL; + int log_msg = 0; + + tl_gets(tags, TPTAG_LOG_REF(log_msg), TAG_END()); + + if (getenv("MSG_STREAM_LOG") != NULL || getenv("TPORT_LOG") != NULL) + log_msg = 1; + + mr->mr_log = log_msg ? MSG_DO_EXTRACT_COPY : 0; + + tl_gets(tags, TPTAG_DUMP_REF(log), TAG_END()); + + if (getenv("MSG_DUMP")) + log = getenv("MSG_DUMP"); + if (getenv("TPORT_DUMP")) + log = getenv("TPORT_DUMP"); + + if (log) { time_t now; if (strcmp(log, "-")) Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c Tue Jan 2 10:11:55 2007 @@ -78,3 +78,6 @@ tag_typedef_t tptag_http_connect = STRTAG_TYPEDEF(http_connect); tag_typedef_t tptag_stun_server = BOOLTAG_TYPEDEF(stun_server); tag_typedef_t tptag_tos = INTTAG_TYPEDEF(tos); +tag_typedef_t tptag_log = INTTAG_TYPEDEF(log); +tag_typedef_t tptag_dump = STRTAG_TYPEDEF(dump); + Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c Tue Jan 2 10:11:55 2007 @@ -54,7 +54,7 @@ #elif HAVE_FUNCTION #define __func__ __FUNCTION__ #else -char const __func__[] = "tport_type_tcp"; +static char const __func__[] = "tport_type_tcp"; #endif /* ---------------------------------------------------------------------- */ Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c ============================================================================== --- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c (original) +++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c Tue Jan 2 10:11:55 2007 @@ -58,6 +58,13 @@ tagi_t const *tags, char const **return_culprit); +#if HAVE_FUNC +#elif HAVE_FUNCTION +#define __func__ __FUNCTION__ +#else +static char const __func__[] = "tport_type_udp"; +#endif + tport_vtable_t const tport_udp_client_vtable = { "udp", tport_type_client, @@ -215,7 +222,7 @@ int tport_recv_dgram(tport_t *self) { msg_t *msg; - ssize_t n, veclen; + ssize_t n, veclen, N; su_addrinfo_t *ai; su_sockaddr_t *from; socklen_t fromlen; @@ -232,8 +239,21 @@ assert(self->tp_msg == NULL); - veclen = tport_recv_iovec(self, &self->tp_msg, iovec, 65536, 1); - if (veclen < 0) +#if nomore + /* We used to resize the buffer, but it fragments the memory */ + N = 65535; +#else + N = (ssize_t)su_getmsgsize(self->tp_socket); + if (N == -1) { + int err = su_errno(); + SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, self, + su_strerror(err), err)); + return -1; + } +#endif + + veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, 1); + if (veclen == -1) return -1; msg = self->tp_msg; 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 Tue Jan 2 10:11:55 2007 @@ -133,7 +133,7 @@ if test X$enable_coverage != Xno ; then case "${CC-cc}" in *gcc*) - SOFIA_CFLAGS="$SOFIA_CFLAGS -fprofile-arcs -ftest-coverage" + AC_SUBST([SOFIA_COVERAGE], ["-fprofile-arcs -ftest-coverage"]) ;; *) AC_MSG_ERROR([--enable-coverage requires gcc]) esac @@ -344,7 +344,6 @@ [ --enable-ndebug compile with NDEBUG (disabled)], , enable_ndebug=no) AM_CONDITIONAL(NDEBUG, test x$enable_ndebug = yes) -SOFIA_CFLAGS="$SOFIA_CFLAGS -DNDEBUG" ]) dnl ======================================================================