]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
a little update to the sofia-sip library
authorMichael Jerris <mike@jerris.com>
Sun, 15 Apr 2007 02:03:41 +0000 (02:03 +0000)
committerMichael Jerris <mike@jerris.com>
Sun, 15 Apr 2007 02:03:41 +0000 (02:03 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4939 d0543943-73ff-0310-b7d9-9358b9ac24b2

270 files changed:
libs/sofia-sip/AUTHORS
libs/sofia-sip/COPYRIGHTS
libs/sofia-sip/Makefile.am
libs/sofia-sip/README
libs/sofia-sip/RELEASE
libs/sofia-sip/RELEASE.template
libs/sofia-sip/configure.ac
libs/sofia-sip/docs/build_system.txt
libs/sofia-sip/docs/devel_platform_notes.txt
libs/sofia-sip/docs/release_management.txt
libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am
libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am
libs/sofia-sip/libsofia-sip-ua-glib/su-glib/sofia-sip/su_glib.h
libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c
libs/sofia-sip/libsofia-sip-ua-glib/su-glib/torture_su_glib_timer.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/ChangeLog
libs/sofia-sip/libsofia-sip-ua/Makefile.am
libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.am
libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c
libs/sofia-sip/libsofia-sip-ua/bnf/torture_bnf.c
libs/sofia-sip/libsofia-sip-ua/docs/Doxyfile.aliases
libs/sofia-sip/libsofia-sip-ua/docs/Makefile.am
libs/sofia-sip/libsofia-sip-ua/features/Makefile.am
libs/sofia-sip/libsofia-sip-ua/http/Makefile.am
libs/sofia-sip/libsofia-sip-ua/http/http_basic.c
libs/sofia-sip/libsofia-sip-ua/http/http_inlined.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/http/http_parser.c
libs/sofia-sip/libsofia-sip-ua/http/sofia-sip/http_header.h
libs/sofia-sip/libsofia-sip-ua/http/test_http.c
libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.am
libs/sofia-sip/libsofia-sip-ua/ipt/sofia-sip/base64.h
libs/sofia-sip/libsofia-sip-ua/ipt/sofia-sip/string0.h
libs/sofia-sip/libsofia-sip-ua/ipt/torture_base64.c
libs/sofia-sip/libsofia-sip-ua/iptsec/Doxyfile
libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.am
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_delayed.c
libs/sofia-sip/libsofia-sip-ua/iptsec/sofia-sip/auth_client_plugin.h
libs/sofia-sip/libsofia-sip-ua/iptsec/sofia-sip/auth_plugin.h
libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c
libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am
libs/sofia-sip/libsofia-sip-ua/msg/msg_inlined.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.awk
libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c
libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_parser.h
libs/sofia-sip/libsofia-sip-ua/msg/test_inlined.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/msg/test_msg.c
libs/sofia-sip/libsofia-sip-ua/nea/Makefile.am
libs/sofia-sip/libsofia-sip-ua/nea/nea_server.c
libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am
libs/sofia-sip/libsofia-sip-ua/nta/nta.c
libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c
libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h
libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c
libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta
libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h
libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h
libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
libs/sofia-sip/libsofia-sip-ua/nth/Makefile.am
libs/sofia-sip/libsofia-sip-ua/nth/http-server.c
libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c
libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c
libs/sofia-sip/libsofia-sip-ua/nth/sofia-sip/nth_tag.h
libs/sofia-sip/libsofia-sip-ua/nth/test_nth.c
libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile
libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
libs/sofia-sip/libsofia-sip-ua/nua/nua.c
libs/sofia-sip/libsofia-sip-ua/nua/nua.docs
libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
libs/sofia-sip/libsofia-sip-ua/nua/outbound.h
libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h
libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
libs/sofia-sip/libsofia-sip-ua/nua/test_basic_call.c
libs/sofia-sip/libsofia-sip-ua/nua/test_call_hold.c
libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c
libs/sofia-sip/libsofia-sip-ua/nua/test_extension.c
libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
libs/sofia-sip/libsofia-sip-ua/nua/test_nat.c
libs/sofia-sip/libsofia-sip-ua/nua/test_nat.h
libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
libs/sofia-sip/libsofia-sip-ua/nua/test_nua_api.c
libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
libs/sofia-sip/libsofia-sip-ua/nua/test_offer_answer.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c
libs/sofia-sip/libsofia-sip-ua/nua/test_proxy.c
libs/sofia-sip/libsofia-sip-ua/nua/test_proxy.h
libs/sofia-sip/libsofia-sip-ua/nua/test_refer.c
libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
libs/sofia-sip/libsofia-sip-ua/nua/test_session_timer.c
libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c
libs/sofia-sip/libsofia-sip-ua/nua/test_sip_events.c
libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.am
libs/sofia-sip/libsofia-sip-ua/sdp/run_test_sdp
libs/sofia-sip/libsofia-sip-ua/sdp/sdp.c
libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c
libs/sofia-sip/libsofia-sip-ua/sip/Doxyfile
libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am
libs/sofia-sip/libsofia-sip-ua/sip/run_test_date [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg [new file with mode: 0755]
libs/sofia-sip/libsofia-sip-ua/sip/sip_basic.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_event.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_extra_headers.txt
libs/sofia-sip/libsofia-sip-ua/sip/sip_feature.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_inlined.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/sip/sip_mime.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_parser.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_prack.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_reason.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_refer.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_tag_class.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c
libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_header.h
libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_parser.h
libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_util.h
libs/sofia-sip/libsofia-sip-ua/sip/test_date.c
libs/sofia-sip/libsofia-sip-ua/sip/test_sip_msg.c
libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c
libs/sofia-sip/libsofia-sip-ua/sip/validator.c
libs/sofia-sip/libsofia-sip-ua/soa/Makefile.am
libs/sofia-sip/libsofia-sip-ua/soa/soa.c
libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
libs/sofia-sip/libsofia-sip-ua/soa/sofia-sip/soa_session.h
libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c
libs/sofia-sip/libsofia-sip-ua/sresolv/Doxyfile
libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am
libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv
libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c
libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
libs/sofia-sip/libsofia-sip-ua/sresolv/sresolv.c
libs/sofia-sip/libsofia-sip-ua/sresolv/sresolv.docs
libs/sofia-sip/libsofia-sip-ua/sresolv/test_sresolv.c
libs/sofia-sip/libsofia-sip-ua/stun/Makefile.am
libs/sofia-sip/libsofia-sip-ua/stun/stun.c
libs/sofia-sip/libsofia-sip-ua/su/Makefile.am
libs/sofia-sip/libsofia-sip-ua/su/addrinfo.c
libs/sofia-sip/libsofia-sip-ua/su/poll.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/run_test_su
libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable2.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_bm.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_configure.h.in
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_debug.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_tag.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/tstdef.h
libs/sofia-sip/libsofia-sip-ua/su/su.c
libs/sofia-sip/libsofia-sip-ua/su/su_addrinfo.c
libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
libs/sofia-sip/libsofia-sip-ua/su/su_alloc_lock.c
libs/sofia-sip/libsofia-sip-ua/su/su_base_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_bm.c
libs/sofia-sip/libsofia-sip-ua/su/su_devpoll_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_epoll_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
libs/sofia-sip/libsofia-sip-ua/su/su_os_nw.c
libs/sofia-sip/libsofia-sip-ua/su/su_osx_runloop.c
libs/sofia-sip/libsofia-sip-ua/su/su_poll_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_port.c
libs/sofia-sip/libsofia-sip-ua/su/su_port.h
libs/sofia-sip/libsofia-sip-ua/su/su_pthread_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_root.c
libs/sofia-sip/libsofia-sip-ua/su/su_select_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_socket_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/su_time.c
libs/sofia-sip/libsofia-sip-ua/su/su_timer.c
libs/sofia-sip/libsofia-sip-ua/su/su_wait.c
libs/sofia-sip/libsofia-sip-ua/su/su_win32_port.c [new file with mode: 0644]
libs/sofia-sip/libsofia-sip-ua/su/tag_dll.awk
libs/sofia-sip/libsofia-sip-ua/su/test_htable.c
libs/sofia-sip/libsofia-sip-ua/su/test_memmem.c
libs/sofia-sip/libsofia-sip-ua/su/test_su.c
libs/sofia-sip/libsofia-sip-ua/su/torture_rbtree.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_alloc.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_bm.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_port.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_root.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_root_osx.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_tag.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_time.c
libs/sofia-sip/libsofia-sip-ua/su/torture_su_timer.c
libs/sofia-sip/libsofia-sip-ua/tport/Makefile.am
libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h
libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c
libs/sofia-sip/libsofia-sip-ua/tport/tport.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h
libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_stub_stun.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_type_sctp.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
libs/sofia-sip/libsofia-sip-ua/url/Makefile.am
libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h
libs/sofia-sip/libsofia-sip-ua/url/torture_url.c
libs/sofia-sip/libsofia-sip-ua/url/url.c
libs/sofia-sip/m4/sac-general.m4
libs/sofia-sip/m4/sac-openssl.m4
libs/sofia-sip/m4/sac-su.m4
libs/sofia-sip/m4/sac-su2.m4
libs/sofia-sip/m4/sac-tport.m4
libs/sofia-sip/packages/sofia-sip.spec.in
libs/sofia-sip/rules/recursive.am [new file with mode: 0644]
libs/sofia-sip/rules/sofia.am [new file with mode: 0644]
libs/sofia-sip/rules/valcheck.am [new file with mode: 0644]
libs/sofia-sip/utils/sip-options.c
libs/sofia-sip/win32/Makefile.am
libs/sofia-sip/win32/SofiaSIP.dsw
libs/sofia-sip/win32/SofiaSIP.sln [new file with mode: 0644]
libs/sofia-sip/win32/build_sources.cmd
libs/sofia-sip/win32/check.cmd
libs/sofia-sip/win32/config.h.in
libs/sofia-sip/win32/libsofia-sip-ua-static/libsofia_sip_ua_static.dsp
libs/sofia-sip/win32/libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/libsofia-sip-ua/libsofia_sip_ua.dsp
libs/sofia-sip/win32/libsofia-sip-ua/libsofia_sip_ua.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/test_htable/test_htable.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/test_memmem/test_memmem.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/test_nta/test_nta.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/test_nua/test_nua.dsp
libs/sofia-sip/win32/tests/test_nua/test_nua.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/test_su/test_su.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/test_tport/test_tport.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_rbtree/torture_rbtree.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su/torture_su.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_alloc/torture_su_alloc.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_bm/torture_su_bm.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_port/torture_su_port.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_root/torture_su_root.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_tag/torture_su_tag.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_time/torture_su_time.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/tests/torture_su_timer/torture_su_timer.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/utils/localinfo/localinfo.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/utils/sip_dig/sip_dig.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/utils/sip_options/sip_options.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/utils/sip_options_static/sip_options_static.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/utils/stunc/stunc.vcproj [new file with mode: 0644]
libs/sofia-sip/win32/version_files.cmd
libs/win32/sofia/libsofia_sip_ua_static.vcproj

index 5d1f563250bf6852ce6f15c5efa06c83cf85c2e6..4adcf4e6861968d181b5ebd64212e0abdcf3854e 100644 (file)
@@ -10,6 +10,8 @@ Contributors (in alphabetical order, surname first)
 
 Chan, Tat <first.surname@nokia.com>
 Ciarkowski, Andrzej <wp-voigtkampff -at users -dot sourceforge -dot net>
+Denis-Courmont, Remi <first.surname@nokia.com>
+Filonenko Roman <shkoder -at ua -dot fm>
 Haataja, Mikko <first.surname@nokia.com>
 Jacobs, Remeres <first.surname@nokia.com>
 Jalava, Teemu <first.surname@nokia.com>
@@ -26,9 +28,7 @@ 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
\ No newline at end of file
index 8aff640204a45d432d63cbbc7f2b9be6684196ba..09a1d2f70e36388efdba770fa2cfbcac35f1beb8 100644 (file)
@@ -221,3 +221,31 @@ other special, indirect and consequential damages, even if author has
 been advised of the possibility of such damages.
 
 ----------------------------------------------------------------------------
+
+libsofia-sip-ua/su/poll.c
+
+The package also contains files from GNU C Library by Free Software
+Foundation.
+
+These files are distributed with the following copyright notice:
+
+Copyright (C) 1994,1996,1997,1998,1999,2001,2002
+Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C 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.
+
+The GNU C 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 the GNU C Library; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+----------------------------------------------------------------------------
index 844a503b7d4be1a833885717283707febd87fabf..c63e5956d645dd5bbd1e3f7e238bd9a936fc9afd 100644 (file)
@@ -27,6 +27,10 @@ ACLOCAL_AMFLAGS = -I m4
 EXTRA_DIST +=  m4/sac-general.m4 m4/sac-su.m4 \
                m4/sac-su2.m4 m4/sac-tport.m4 m4/sac-openssl.m4
 
+EXTRA_DIST +=   docs/build_system.txt \
+               docs/devel_platform_notes.txt \
+               docs/release_management.txt
+
 dist_man_MANS = man/man1/sip-date.1 man/man1/sip-options.1 \
                man/man1/localinfo.1 man/man1/addrinfo.1 \
                man/man1/stunc.1 man/man1/sip-dig.1
@@ -44,7 +48,12 @@ endif
 
 CLEANFILES = $(dist_man_MANS)
 
-coverage built-sources clean-built-sources doxygen:
-       for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do $(MAKE) $(AM_MAKEFLAGS) -C $$i $@ ; done
+coverage built-sources clean-built-sources valcheck doxygen:
+       @failcom='exit 1'; for f in x $$MAKEFLAGS; do \
+       case $$f in *=* | --[!k]*);; *k*) failcom='fail=yes';; esac; done; \
+       for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do \
+         (cd $$i && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \
+       done ; \
+       test -z "$$fail"
 
-.PHONY: coverage built-sources clean-built-sources doxygen manpages
+.PHONY: coverage built-sources clean-built-sources valcheck doxygen manpages
index f3ee2266d8c136da40995208c41d6856287d9a47..e560df5ed288865614ec2a223dc43d724e2c0e22 100644 (file)
@@ -46,7 +46,6 @@ The Sofia-SIP su submodule also provides some small utilities:
 - localinfo (libsofia-sip-ua/su), prints information about
   local network interfaces 
 
-
 References
 ----------
 
index e2df85637a6132019b1d32a74abfe8926b747ee6..87aeee75bbca4d01a7762f1eb5f49760c7dd5dfd 100644 (file)
@@ -5,98 +5,108 @@ Release notes for current version of Sofia-SIP
 Changes since last release
 --------------------------
 
-<changes since last written in freshmeat.net "Changes:" style;
- and in less than 10 lines />
-
-Bugs in blaa and foo have been fixed. The stack now supports
-use of foobar...
+Numerous nua bugs introduced in the release 1.12.5 have been fixed. Support
+for nextnonce in Authentication-Info header has been added. The nua engine
+now fully supports application-driven SDP.
 
 API/ABI changes and versioning
 ------------------------------
 
-<see previous release notes at
- http://sofia-sip.sourceforge.net/relnotes/ for examples ;
- - should include all changes to public headers, and 
-   other important information to developers; 
- - and should be updated _continuously_! />
-
-**template**: New features in API are marked with Doxytag macro @VERSION_1_XX_X.
-
 libsofia-sip-ua:
-- **template**: Added foobar() function (sofia-sip/foobar.h).
-- Added sip_is_allowed() function and k_bitmap field to the 
-  sip_allow_t structure 
-- Added SIP header Refer-Sub and related functions
-- Added <sofia-sip/sip_extra.h> include file
-- Added auc_info() function (sofia-sip/auth_client.h)
+- Use calling/received callstate in nua_i_state event sent because of UPDATE
+  while call is ready
+- Added tag define NUTAG_WITH_CURRENT() as an alias to NUTAG_WITH_THIS()
+- Added tag NUTAG_DIALOG() controlling whether nua_method() creates a dialog.
+- Added tag NUTAG_AUTH_CACHE() <sofia-sip/nua_tag.h> determining when to 
+  include credentials in the request
+- Added kqueue and /dev/poll interfaces (su_devpoll_port_create(),
+  su_devpoll_clone_start(), su_kqueue_port_create(), su_kqueue_clone_start()
+  in <sofia-sip/su_wait.h>)
+- Added SIP_IS_ALLOWED() macro to <sofia-sip/sip_util.h>
+- Fixed NUTAG_APPL_METHOD() implementation for UPDATE and PRACK as documented
+  ("100rel" and "precondition" extensions now require explicit calls to
+  nua_update() and nua_prack() if those methods are included in
+  NUTAG_APPL_METHOD())
+- Added auc_clear field and member to authentication client plugin interface
+  in <sofia-sip/auth_client_plugin.h>
+- Added nua_event_is_incoming_request() to <sofia-sip/nua.h>
 - This release is ABI/API compatible with applications linked against 
   any 1.12.x release. However, applications built against this release won't 
   work against an older library. The ABI has been tested with the nua module 
   unit test (test_nua) built against original 1.12.0 release.
 
 libsofia-sip-ua-glib:
-- The 'nua-glib' module has been removed from the library and moved
-  to a separate package 'sofia-nua-glib'. The remaining library (su-glib) 
-  is now considered stable and will be API/ABI compatible with later 
-  releases in the 1.12.x series.
-- ABI has been modified and applications built against 1.12.4 and earlier 
-  releases need to be rebuilt.
+- No ABI/API changes, compatible with 1.12.0. Note, libsofia-sip-ua-glib
+  interface is not considered stable and may change in a future 1.12.x
+  release.
 
 Contributors to this release
 ----------------------------
 
-<list of people who contributed to _this_ release
- - update as people's patches are added, or when you commit stuff
- - current development team members (see AUTHORS) may be omitted
- - name of the contributor should be enough (email addresses in AUTHORS),
-   plus a brief description of what was contributed
- - roughly sorted by number of patches accepted
-/> 
-
-- **template**: First Surname (patch to nua/soa/msg)
-- Petteri Puolakka (patch to stun)
-- Mikhail Zabluev (patch to su-glib mainloop integration)
+- Pekka Pessi (/dev/poll interface to Solaris, kqueue)
+- Martti Mela (kqueue interface to Max OS X and FreeBSD)
+- Michael Jerris (Solaris patches)
+- Colin Whittaker (sresolv patch)
 
 See the AUTHORS file in the distribution package.
 
 Notes on new features
 ---------------------
 
-RFC 4488 defines the Refer-Sub header. Its datatypes, related functions and
-methods declared in <sofia-sip/sip_extra.h> include file. The Refer-Sub
-header structure can be accessed from sip_t structure with sip_refer_sub()
-method, e.g.,
+The Sofia-SIP has been compiled and tested on Solaris. The /dev/poll
+interface (in su_devpoll_port.c) has been added for Solaris. Likewise, the
+kqueue interface (in su_kqueue_port.c) has been added for FreeBSD and Mac OS
+X. There is also select-based reactor for systems without poll().
 
-  if (sip_refer_sub(sip) && 
-      strcasecmp("false", sip_refer_sub(sip)->rs_value) == 0) {
-     /* Do not create implicit subscription */ 
-  }
+The client authentication in nua has been updated. The nextnonce in
+Authentication-Info or Proxy-Authentication-Info headers is now used during
+the next . The NUTAG_AUTH_CACHE() policy determines how the cached
+credentials are used. By default, the credentials are included in each
+request within the dialog, however, with the
+NUTAG_AUTH_CACHE(nua_auth_cache_challenged) the client authenticates
+requests only after they have been challenged.
 
-<information about major new features
- - new/changed/removed functionality
- - links to further documentation
- - section may be omitted for minor releases
-/> 
+The application can now fully control the SDP negotiation (when soa is
+disabled with NUTAG_MEDIA_ENABLE(0)). The application can send UPDATE and
+PRACK requests and respond to them. The callstate sent in nua_i_state after
+UPDATE while the call has already been completed has been also changed.
 
 Bugs fixed in this release
 --------------------------
 
-< notable bugs fixed in this release
- - check the sf.net bug tracker; see closed bugs,
-   sorted by closing date
- - other bugs as fixed in CVS/darcs
-/>
-
-- **template**: #9499652 sf.net bug item title
-
-- Fixed crash when nua_bye() was called while a NOTIFY client transaction
-  was in progress. Problem reported by Anthony Minnessale.
-- Not using close() with sockets in sres.c. Problem reported by
-  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.
+- Fixed status code sent to network and returned to the client if there was
+  an internal error while responding to a request. 
+  The problem was reported by Michael Jerris and Joshua Engelbrecht.
+- Fixed #1685249, unclear termination of call in absense of credentials by
+  nua_authenticate(). Problem reported by Mikhail Zabaluev.
+- Fixed status code reported to application when REGISTER transaction was
+  restarted by nua stack. Problem reported by Mikhail Zabaluev.
+- An invalid Contact was used if STUN was disabled but there was no STUN
+  server. Problem reported by Miguel Freitas.
+- Fixed problem logging long lines from with TPORT_LOG.
+  Problem reported by Mike Murdock and Michael Jerris.
+- Nua now includes the SDP capabilities in the response to the OPTIONS
+- Fixed assertion failure because BYE destroyed a session twice.
+  Problem reported by Michael Jerris.
+- Fixed crash caused by a 0-length UDP datagram.
+  Problem reported by Michael Jerris.
+- Fixed the 305 response handling by nua stack.
+  Bug #1676445 reported by Fabio Margarido.
+- Fixed authentication-related bugs #1685245 and #1570746.
+  #1685245 reported by Mikhail Zabaluev.
+- Fixed problems resuming DNS after server or link downtime.
+  Bug #1631198 reported and initial patch submitted by Colin Whittaker.
+- Fixed NUTAG_APPL_METHOD() implementation for UPDATE and PRACK as documented
+- Fixed crashes in nua state engines:
+  - when nua_invite() was called second time before receiving
+    final response to first INVITE
+  - when UAS expected PRACK but received CANCEL
+  - when UAC received error response to PRACK, it tried to send BYE and crashed
+  - when UAS rejected initial request, the subsequent request with same 
+    dialog id (Call-ID, From-tag) crashed (dialog cleanup code left dialog
+    dangling)
+  Problems reported by Michael Jerris
+- Fixed crash in nta state engine:
+  - DNS resolver failure in non-invite transctions crashed
+- Fixed sdp handling when soa is disabled (NUTAG_MEDIA_ENABLE(0)).
+  Problem reported by Marcin Michalak
index 87c8f4ccdb63ce1ed9928f621a11b37c6ee5e2fc..611367c1e3da69de18546abe360cb05b0b62fb30 100644 (file)
@@ -6,7 +6,8 @@ Changes since last release
 --------------------------
 
 <changes since last written in freshmeat.net "Changes:" style;
- and in less than 10 lines />
+ and in less than 10 lines, written in 3rd person English, with
+ complete sentences />
 
 Bugs in blaa and foo have been fixed. The stack now supports
 use of foobar...
@@ -39,9 +40,11 @@ Contributors to this release
 
 <list of people who contributed to _this_ release
  - update as people's patches are added, or when you commit stuff
- - current development team members (see AUTHORS) may be omitted
+ - current development team members (see AUTHORS) may be omitted,
+   or listed at the end of the contribur list (depending on the scope 
+   of the work done since the last release)
  - name of the contributor should be enough (email addresses in AUTHORS),
-   plus a brief description of what was contributed
+   plus a _brief_ description of what was contributed
  - roughly sorted by number of patches accepted
 /> 
 
index 7e94cd4e64ca7a46ac1e76804ad536b2dbf95a47..a5fc25a2f04d1d35cb5a888875e3db54eab681f6 100644 (file)
@@ -11,14 +11,14 @@ dnl information on the package
 dnl ---------------------------
 
 dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR
-AC_INIT([sofia-sip], [1.12.4work])
+AC_INIT([sofia-sip], [1.12.5work6])
 AC_CONFIG_SRCDIR([libsofia-sip-ua/sip/sofia-sip/sip.h])
 AC_SUBST(VER_LIBSOFIA_SIP_UA_MAJOR_MINOR, [1.12])
 dnl Includedir specific to this sofia version
 AC_SUBST(include_sofiadir, '${includedir}/sofia-sip-1.12')
-AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [3])
+AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [5])
 AC_SUBST(LIBVER_SOFIA_SIP_UA_REV, [0])
-AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [3])
+AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [5])
 AC_SUBST(LIBVER_SOFIA_SIP_UA_SOVER, [0]) # CUR-AGE
 AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_CUR, [3])
 AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_REV, [0])
@@ -53,8 +53,15 @@ SAC_ENABLE_EXPENSIVE_CHECKS
 dnl Add parameters for aclocal
 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
 
-AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen], [echo])
-AM_CONDITIONAL([HAVE_DOXYGEN], [test $DOXYGEN = doxygen])
+AC_ARG_WITH(doxygen,
+[  --with-doxygen[[=CMD]]    use doxygen command CMD [[doxygen]]],[
+case $enable_doxygen in 
+yes ) doxygen=doxygen ;;
+no ) doxygen=echo ;;
+esac], doxygen=doxygen)
+
+AC_CHECK_PROG([DOXYGEN], [doxygen], [$doxygen], [echo])
+AM_CONDITIONAL([HAVE_DOXYGEN], [test $DOXYGEN != echo])
 
 ### checks for libraries
 ### --------------------
@@ -71,7 +78,7 @@ AC_DEFINE([HAVE_SOFIA_SRESOLV], 1, [Define to 1 if we use DNS library])
 AC_DEFINE([HAVE_SOFIA_SMIME], 0, [Define to 1 if we use S/MIME library])
 
 AC_ARG_ENABLE(stun,
-[  --disable-stun              disable stun module (enabled)],
+[  --disable-stun          disable stun module (enabled)],
  , enable_stun=yes)
 
 if test x$enable_stun = xno ; then
@@ -83,10 +90,19 @@ elif test x${HAVE_OPENSSL} != x1 ; then
 else
   AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define to 1 if we use STUN library])
 fi
+AM_CONDITIONAL([HAVE_STUN], [test "x$enable_stun" = xyes])
+
+AC_ARG_ENABLE(nth,
+[  --disable-nth           disable nth and http modules (enabled)],
+ , enable_nth=yes)
+AM_CONDITIONAL([HAVE_NTH], [test "x$enable_nth" = xyes])
+if test x$enable_nth = xyes ; then
+  AC_DEFINE([HAVE_SOFIA_NTH], 1, [Define to 1 if we use NTH library])
+fi
 
 dnl Disable NTLM support by default
 AC_ARG_ENABLE(ntlm,
-[  --enable-ntlm               enable NTLM support (disabled)],
+[  --enable-ntlm           enable NTLM support [[disabled]]],
  , enable_ntlm=no)
 
 if test x$enable_ntlm = xyes ; then
@@ -104,22 +120,97 @@ AC_HEADER_STDC
 
 ### checks for declarations
 ### -----------------------
-AC_CHECK_DECL([SIGPIPE], [
-AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
-#include <signal.h>
-])
 
 ### checks for types
 ### ----------------
 
 AC_TYPE_SIGNAL
-AC_TYPE_LONGLONG([
-AC_DEFINE([LLU], ["%llu"], [Define to format (%llu) for unsigned long long])dnl
-AC_DEFINE([LLI], ["%lli"], [Define to format (%lli) for long long])dnl
-AC_DEFINE([LLX], ["%llx"], [Define to format (%llx) for long long hex])dnl
+AC_TYPE_LONGLONG
+
+dnl
+dnl Define HAVE_C99_FORMAT to 1 if the formatted IO functions (printf/scanf
+dnl et.al.) support the C99 'size specifiers', namely ll, hh, j, z, t
+dnl (representing long long int, char, intmax_t, size_t, ptrdiff_t). Some C
+dnl compilers supported these specifiers prior to C99 as an extension.
+dnl
+AC_CACHE_CHECK([whether IO functions support C99 size specifiers],
+[ac_cv_c_c99_format],[
+
+ac_cv_c_c99_format=yes
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+[[char buf[64];
+ if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
+  exit(1);
+ else if (strcmp(buf, "12345"))
+  exit(2);]])],
+ [ac_cv_c_c99_format=yes],
+ [ac_cv_c_c99_format=no],
+ [ac_cv_c_c99_format=yes])
+])
+
+if test $ac_cv_c_c99_format = yes; then
+  AC_DEFINE([HAVE_C99_FORMAT], [1], [Define to 1 if printf supports C99 size specifiers])dnl
+
+  AC_DEFINE([LLU], ["%llu"], [Format (%llu) for unsigned long long])dnl
+  AC_DEFINE([LLI], ["%lli"], [Format (%lli) for long long])dnl
+  AC_DEFINE([LLX], ["%llx"], [Format (%llx) for long long hex])dnl
+  AC_DEFINE([MOD_ZD], ["%zd"], [Define printf() modifier for ssize_t])dnl
+  AC_DEFINE([MOD_ZU], ["%zu"], [Define printf() modifier for size_t])dnl
+
+else
+
+AC_CACHE_CHECK([whether IO functions support size specifier for long long],
+[ac_cv_c_ll_format],[
+
+ac_cv_c_ll_format=yes
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+[[char buf[64];
+ if (sprintf(buf, "%lld", (long long int)1) != 1)
+  exit(1);
+ else if (strcmp(buf, "1"))
+  exit(2);]])],
+ [ac_cv_c_ll_format=yes],
+ [ac_cv_c_ll_format=no],
+ [ac_cv_c_ll_format=yes])
+])
+
+if test $ac_cv_c_ll_format = yes; then
+  AC_DEFINE([LLU], ["%llu"], [Format (%llu) for unsigned long long])dnl
+  AC_DEFINE([LLI], ["%lli"], [Format (%lli) for long long])dnl
+  AC_DEFINE([LLX], ["%llx"], [Format (%llx) for long long hex])dnl
+else
+  AC_MSG_ERROR("printf cannot handle 64-bit integers")
+fi
+
+AC_CACHE_CHECK([whether IO functions support size specifier for size_t],
+[ac_cv_c_z_format],[
+
+ac_cv_c_z_format=yes
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+[[char buf[64];
+ if (sprintf(buf, "%zd", (size_t)1) != 1)
+  exit(1);
+ else if (strcmp(buf, "1"))
+  exit(2);]])],
+ [ac_cv_c_z_format=yes],
+ [ac_cv_c_z_format=no],
+ [ac_cv_c_z_format=yes])
 ])
-AC_DEFINE([MOD_ZD], ["%zd"], [Define printf() modifier for ssize_t])
-AC_DEFINE([MOD_ZU], ["%zu"], [Define printf() modifier for size_t])
+
+if test $ac_cv_c_z_format = yes; then
+  AC_DEFINE([MOD_ZD], ["%ld"], [Define printf() modifier for ssize_t])dnl
+  AC_DEFINE([MOD_ZU], ["%lu"], [Define printf() modifier for size_t])dnl
+else 
+  dnl Cross fingers
+  AC_MSG_WARN("printf cannot handle size_t, using long instead")
+  AC_DEFINE([MOD_ZD], ["%ld"], [Define printf() modifier for ssize_t])dnl
+  AC_DEFINE([MOD_ZU], ["%lu"], [Define printf() modifier for size_t])dnl
+fi 
+
+fi
 
 ### checks for structures
 ### ---------------------
index ea057852a3ac57f55d4ffc4f68b4a0d61207270d..ae9db277149a36b585778d5259458c3b831e4a0d 100644 (file)
@@ -38,6 +38,11 @@ Makefile target notes
   separately in ``DIST_SOURCES`` variable (otherwise ``make dist``
   will fail)
 
+Makefile fragments
+------------------
+
+Some common makefile rules are in 'rules' subdirectory.
+
 Maintainer mode
 ---------------
 
@@ -54,13 +59,16 @@ option '--enable-maintainer-mode'.
 Running tests
 =============
 
-Sofia-SIP has quite complete suite of test cases. It is prudent to
-run them while making changes and before committing them to revision
-control system. However, running certain tests takes quite a long
-time. Therefore, they are run only if the environment variable
+Sofia-SIP has quite complete suite of test cases. It is prudent to run
+them while making changes and before committing them to revision control
+system. However, running certain tests takes quite a long time to
+execture. Therefore, they are run only if the environment variable
 EXPENSIVE_CHECKS has been set. EXPENSIVE_CHECKS is also set by the build
 system if configure option '--enable-expensive-checks' has been used.
 
+On hosts with i386 architecture, it is possible to run tests under
+valgrind. Use the make target 'valcheck' for that purpose.
+
 Code-tree layout
 ================
 
index 0b8b4180253a06e32046605883d9e8e18c0b3a85..9d7cc4f1aff3f2fb40d4fc0e0ab400a48c619c18 100644 (file)
@@ -11,14 +11,30 @@ up-to-date autotools. Autoconf should be at least 2.57 and automake should
 be at least 1.7. You can avoid running autoreconf explicitly if you use
 ./configure option --enable-maintainer-mode.
 
+Notes to distributors
+----------------------
+
+Build options such as "--disable-stun" (HAVE_SOFIA_STUN) and 
+"--disable-nth" (HAVE_SOFIA_NTH) modify the public library API/ABI,
+by omitting certain interfaces from the resulting library and installed
+header files.
+
+Options such as '--disable-size-compat' modify the library
+ABI by changing the types used in public library function 
+signatures.
+
 Generic POSIX (GNU/Linux, BSD, ...) 
 -----------------------------------
 
 Sofia-SIP should compile out-of-the-box on generic POSIX
 machines. Use the standard GNU autotool 'configure+make'
-procedure to build the software. See top-level INSTALL
+procedure to build the software. See top-level README file
 for more information.
 
+The configure script accepts various options. See "./configure --help"
+for the full list.
+
+
 Mac OS X 
 --------
 
index faaf7c3467fe5c6767011ff4f378175f810a8ed0..ef1a0aef7d8e32e860fc55f39f7011336f55722a 100644 (file)
@@ -61,7 +61,8 @@ Making the release tarball
     sh> cvs tag rel-sofia-sip-x_y_z
 - take a fresh checkout of the release using the release tag
     sh> darcs get http://sofia-sip.org/repos/sofia-sip --tag=rel-sofia-sip-1_yy_z
-- create the release tarball with "make distcheck"
+- create the release tarball with "make distcheck" (make sure depcomp et
+  al libtool scripts are correctly created)
 - calculate md5 and sha1 hashes using md5sum and sha1sum utilities,
   and copy the values to the release-notes (see below)
 
index 12defa1a276f4879e3f8637fc80dd885f0addc11..25491ef5001cc3ccbcb0e084a4384bb677471594 100644 (file)
@@ -31,16 +31,6 @@ EXTRA_DIST = docs/Doxyfile.aliases \
             docs/Doxyfile.conf \
             docs/Doxyfile.version
 
-built-sources: built-sources-recursive 
-clean-built-sources: clean-built-sources-recursive
-
-built-sources-recursive clean-built-sources-recursive:
-       target=`echo $@ | sed s/-recursive//`; \
-       list='$(SUBDIRS)'; for subdir in $$list; do \
-         echo "Making $@ in $$subdir"; \
-         (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
-       done;
-
 doxygen: built-sources
        @cd ${srcdir} ;\
        mkdir -p docs docs/html &&\
@@ -53,4 +43,6 @@ doxygen: built-sources
        done
        cd ${srcdir}/docs/html && ../../${top_srcdir}/libsofia-sip-ua/docs/hide_emails.sh
 
+include $(top_srcdir)/rules/recursive.am
+
 .PHONY: built-sources built-sources-am doxygen 
index c5f0ae94d66423528269512aa099968c6cf2d910..85d6ad89e4334af3b1942729bb1859fb57f4c4a9 100644 (file)
@@ -58,4 +58,4 @@ AUTOMAKE_OPTIONS =    foreign
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../../libsofia-sip-ua/sofia.am
+include $(top_srcdir)/rules/sofia.am
index e202f343a566cde9d3ebb37ee0d18b985ccc961e..f6f2448de2b5f5914fafc66f1cc6bbaffac97778 100644 (file)
@@ -43,6 +43,7 @@ SOFIA_BEGIN_DECLS
 
 SOFIAPUBFUN su_root_t *su_glib_root_create(su_root_magic_t *) __attribute__((__malloc__));
 SOFIAPUBFUN GSource *su_glib_root_gsource(su_root_t *);
+SOFIAPUBFUN void su_glib_prefer_gsource(void);
 
 SOFIA_END_DECLS
 
index 2e45a322540691aea01e7950b1e7c0f69de2e5e4..a2b4380dd5d1ae8c2cee4c69d432f71d4002603a 100644 (file)
 /**
  * @file su_source.c
  * @brief Wrapper for glib GSource.
- * *  
+ *  
+ * Refs: 
+ *  - http://sofia-sip.sourceforge.net/refdocs/su/group__su__wait.html
+ *  - http://developer.gnome.org/doc/API/glib/glib-the-main-event-loop.html
+ *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>.
  * 
  * @date Created: Thu Mar  4 15:15:15 2004 ppessi
 #include "config.h"
 #endif
 
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-
 #include <glib.h>
 
 #define SU_PORT_IMPLEMENTATION 1
 #include "su_port.h"
 #include "sofia-sip/su_alloc.h"
 
-static su_port_t *su_source_create(void) __attribute__((__malloc__));
+#include <stdlib.h>
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#if 1
+#define PORT_LOCK_DEBUG(x)  ((void)0)
+#else
+#define PORT_LOCK_DEBUG(x)  printf x
+#endif
+
+static su_port_t *su_source_port_create(void) __attribute__((__malloc__));
 static gboolean su_source_prepare(GSource *gs, gint *return_tout);
 static gboolean su_source_check(GSource *gs);
 static gboolean su_source_dispatch(GSource *gs,
-                           GSourceFunc callback,
-                           gpointer user_data);
+                                  GSourceFunc callback,
+                                  gpointer user_data);
 static void su_source_finalize(GSource *source);
 
-static int su_source_getmsgs(su_port_t *self);
-
 static
 GSourceFuncs su_source_funcs[1] = {{
     su_source_prepare,
@@ -106,21 +114,22 @@ static void su_source_break(su_port_t *self);
 static su_duration_t su_source_step(su_port_t *self, su_duration_t tout);
 static int su_source_own_thread(su_port_t const *port);
 static int su_source_add_prepoll(su_port_t *port,
-                              su_root_t *root, 
-                              su_prepoll_f *, 
-                              su_prepoll_magic_t *);
+                                su_root_t *root, 
+                                su_prepoll_f *, 
+                                su_prepoll_magic_t *);
 static int su_source_remove_prepoll(su_port_t *port,
                                  su_root_t *root);
-static su_timer_t **su_source_timers(su_port_t *port);
 static int su_source_multishot(su_port_t *self, int multishot);
-static int su_source_threadsafe(su_port_t *port);
 
-static
-su_port_vtable_t const su_source_vtable[1] =
+static char const *su_source_name(su_port_t const *self);
+
+static 
+su_port_vtable_t const su_source_port_vtable[1] =
   {{
-      /* su_vtable_size: */ sizeof su_source_vtable,
+      /* su_vtable_size: */ sizeof su_source_port_vtable,
       su_source_lock,
       su_source_unlock,
+
       su_source_incref,
       su_source_decref,
 
@@ -138,32 +147,38 @@ su_port_vtable_t const su_source_vtable[1] =
       su_source_own_thread,
       su_source_add_prepoll,
       su_source_remove_prepoll,
-      su_source_timers,
+      su_base_port_timers,
       su_source_multishot,
-      su_source_threadsafe
-
+      su_base_port_threadsafe,
+      /*su_source_yield*/ NULL,
+      /*su_source_wait_events*/ NULL,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_source_name,
+      su_base_port_start_shared,
+      su_base_port_wait,
+      NULL,
     }};
 
+static char const *su_source_name(su_port_t const *self)
+{
+  return "GSource";
+}
+
 /** 
  * Port is a per-thread reactor.  
  *
  * Multiple root objects executed by single thread share a su_port_t object. 
  */
 struct su_source_s {
-  su_home_t        sup_home[1];
-  su_port_vtable_t const *sup_vtable;
+  su_base_port_t   sup_base[1];
   
   GThread         *sup_tid;
   GStaticMutex     sup_mutex[1];
-  GStaticRWLock    sup_ref[1];
 
-  GSource         *sup_source;
-  GMainLoop       *sup_main_loop;
+  GSource         *sup_source; /**< Backpointer to source */
+  GMainLoop       *sup_main_loop; /**< Reference to mainloop while running */
   
-  /* Message list - this is protected by lock  */
-  su_msg_t        *sup_head;
-  su_msg_t       **sup_tail;
-
   /* Waits */
   unsigned         sup_registers; /** Counter incremented by 
                                      su_port_register() or 
@@ -177,9 +192,6 @@ struct su_source_s {
   su_wakeup_f     *sup_wait_cbs; 
   su_wakeup_arg_t**sup_wait_args; 
   su_root_t      **sup_wait_roots; 
-
-  /* Timer list */
-  su_timer_t      *sup_timers;
 };
 
 typedef struct _SuSource
@@ -194,10 +206,6 @@ typedef struct _SuSource
 #define SU_SOURCE_INCREF(p, f)    (g_source_ref(p->sup_source))
 #define SU_SOURCE_DECREF(p, f)    (g_source_unref(p->sup_source))
 
-#define SU_SOURCE_INITLOCK(p)     (g_static_mutex_init((p)->sup_mutex))
-#define SU_SOURCE_LOCK(p, f)      (g_static_mutex_lock((p)->sup_mutex))
-#define SU_SOURCE_UNLOCK(p, f)    (g_static_mutex_unlock((p)->sup_mutex))
-
 #else
 
 /* Debugging versions */
@@ -205,15 +213,6 @@ typedef struct _SuSource
 #define SU_SOURCE_DECREF(p, f)    do { printf("decref(%p) by %s\n", (p), f), \
   g_source_unref(p->sup_source); } while(0)
 
-#define SU_SOURCE_INITLOCK(p) \
-   (g_static_mutex_init((p)->sup_mutex), printf("init_lock(%p)\n", p))
-
-#define SU_SOURCE_LOCK(p, f)    \
-   (printf("%ld at %s locking(%p)...", g_thread_self(), f, p), g_static_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", g_thread_self(), f, p))
-
-#define SU_SOURCE_UNLOCK(p, f)  \
-  (g_static_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", g_thread_self(), f, p))
-
 #endif
 
 #if HAVE_FUNC
@@ -229,7 +228,7 @@ typedef struct _SuSource
 /** Create a root that uses GSource as reactor */
 su_root_t *su_glib_root_create(su_root_magic_t *magic)
 {
-  return su_root_create_with_port(magic, su_source_create());
+  return su_root_create_with_port(magic, su_source_port_create());
 }
 
 /** Deprecated */
@@ -238,6 +237,15 @@ su_root_t *su_root_source_create(su_root_magic_t *magic)
   return su_glib_root_create(magic);
 }
 
+/** 
+ * Returns a GSource object for the root 
+ *
+ * Note that you need to unref the GSource with g_source_unref() 
+ * before destroying the root object.
+ *
+ * @return NULL on error (for instance if root was not created with 
+ *         su_glib_root_create())
+ */
 GSource *su_glib_root_gsource(su_root_t *root)
 {
   g_assert(root);
@@ -246,41 +254,20 @@ GSource *su_glib_root_gsource(su_root_t *root)
 
 /*=============== Private function definitions ===============*/
 
-/**@internal
- *
- * Allocates and initializes a reactor and message port object.
- *
- * @return
- *   If successful a pointer to the new message port is returned, otherwise
- *   NULL is returned.  
- */
-su_port_t *su_source_create(void)
+/** Initialize source port */
+int su_source_port_init(su_port_t *self,
+                       GSource *gs,
+                       su_port_vtable_t const *vtable)
 {
-  SuSource *ss;
-
-  SU_DEBUG_9(("su_source_create() called\n"));
-
-  ss = (SuSource *)g_source_new(su_source_funcs, (sizeof *ss));
-
-  if (ss) {
-    su_port_t *self = ss->ss_port;
-
-    self->sup_vtable = su_source_vtable;
-    self->sup_source = ss->ss_source;
-    
-    SU_SOURCE_INITLOCK(self);
-
-    self->sup_tail = &self->sup_head;
-    self->sup_tid = g_thread_self();
+  if (su_base_port_init(self, vtable) < 0)
+    return -1;
 
-    SU_DEBUG_9(("su_source_with_main_context() returns %p\n", self));
+  self->sup_source = gs;
+  self->sup_tid = g_thread_self();
 
-    return self;
-  } else {
-    su_perror("su_source_with_main_context(): su_home_clone");
-    SU_DEBUG_9(("su_source_with_main_context() fails\n"));
-    return NULL;
-  }
+  g_static_mutex_init(self->sup_mutex);
+  
+  return 0;
 }
 
 /** @internal Destroy a port. */
@@ -294,23 +281,70 @@ void su_source_finalize(GSource *gs)
 
   SU_DEBUG_9(("su_source_finalize() called\n"));
 
-  if (self->sup_waits) 
-    free(self->sup_waits), self->sup_waits = NULL;
-  if (self->sup_wait_cbs)
-    free(self->sup_wait_cbs), self->sup_wait_cbs = NULL;
-  if (self->sup_wait_args)
-    free(self->sup_wait_args), self->sup_wait_args = NULL;
-  if (self->sup_wait_roots)
-    free(self->sup_wait_roots), self->sup_wait_roots = NULL;
-  if (self->sup_indices)
-    free(self->sup_indices), self->sup_indices = NULL;
-
-  su_home_deinit(self->sup_home);
+  g_static_mutex_free(self->sup_mutex);
+
+  su_base_port_deinit(self);
+
+  su_home_deinit(self->sup_base->sup_home);
+}
+
+void su_source_port_lock(su_port_t *self, char const *who)
+{
+  PORT_LOCK_DEBUG(("%p at %s locking(%p)...",
+                  (void *)g_thread_self(), who, self));
+
+  g_static_mutex_lock(self->sup_mutex);
+
+  PORT_LOCK_DEBUG((" ...%p at %s locked(%p)...", 
+                  (void *)g_thread_self(), who, self));
+}
+
+void su_source_port_unlock(su_port_t *self, char const *who)
+{
+  g_static_mutex_unlock(self->sup_mutex);
+
+  PORT_LOCK_DEBUG((" ...%p at %s unlocked(%p)\n", 
+                  (void *)g_thread_self(), who, self));
+}
+
+/** @internal Send a message to the port. */
+int su_source_send(su_port_t *self, su_msg_r rmsg)
+{
+  int wakeup = su_base_port_send(self, rmsg);
+  GMainContext *gmc;
+
+  if (wakeup < 0)
+    return -1;
+  if (wakeup == 0)
+    return 0;
+
+  gmc = g_source_get_context(self->sup_source);
+
+  if (gmc)
+    g_main_context_wakeup(gmc);
+
+  return 0;
+}
+
+/** @internal
+ * Checks if the calling thread owns the port object.
+ *
+ * @param self pointer to a port object
+ *
+ * @retval true (nonzero) if the calling thread owns the port,
+ * @retval false (zero) otherwise.
+ */
+int su_source_own_thread(su_port_t const *self)
+{
+  return self == NULL || SU_SOURCE_OWN_THREAD(self);
 }
 
+/* -- Registering and unregistering ------------------------------------- */
+
 /* Seconds from 1.1.1900 to 1.1.1970 */
 #define NTP_EPOCH 2208988800UL 
 
+/** Prepare to wait - calculate time to next timer */
 static
 gboolean su_source_prepare(GSource *gs, gint *return_tout)
 {
@@ -319,12 +353,12 @@ gboolean su_source_prepare(GSource *gs, gint *return_tout)
 
   enter;
   
-  if (self->sup_head) {
+  if (self->sup_base->sup_head) {
     *return_tout = 0;
     return TRUE;
   }
 
-  if (self->sup_timers) {
+  if (self->sup_base->sup_timers) {
     su_time_t now;
     GTimeVal  gtimeval;
     su_duration_t tout;
@@ -333,7 +367,7 @@ gboolean su_source_prepare(GSource *gs, gint *return_tout)
     now.tv_sec = gtimeval.tv_sec + 2208988800UL;
     now.tv_usec = gtimeval.tv_usec;
 
-    tout = su_timer_next_expires(self->sup_timers, now);
+    tout = su_timer_next_expires(self->sup_base->sup_timers, now);
 
     *return_tout = (tout < 0 || tout > (su_duration_t)G_MAXINT)?
        -1 : (gint)tout;
@@ -376,10 +410,10 @@ gboolean su_source_dispatch(GSource *gs,
 
   enter;
 
-  if (self->sup_head)
-    su_source_getmsgs(self);
+  if (self->sup_base->sup_head)
+    su_base_port_getmsgs(self);
 
-  if (self->sup_timers) {
+  if (self->sup_base->sup_timers) {
     su_time_t now;
     GTimeVal  gtimeval;
     su_duration_t tout;
@@ -392,7 +426,7 @@ gboolean su_source_dispatch(GSource *gs,
     now.tv_sec = gtimeval.tv_sec + 2208988800UL;
     now.tv_usec = gtimeval.tv_usec;
 
-    timers = su_timer_expire(&self->sup_timers, &tout, now);
+    timers = su_timer_expire(&self->sup_base->sup_timers, &tout, now);
   }
 
 #if SU_HAVE_POLL
@@ -424,12 +458,20 @@ gboolean su_source_dispatch(GSource *gs,
 
 static void su_source_lock(su_port_t *self, char const *who)
 {
-  SU_SOURCE_LOCK(self, who);
+  PORT_LOCK_DEBUG(("%p at %s locking(%p)...",
+                  (void *)g_thread_self(), who, self));
+  g_static_mutex_lock(self->sup_mutex);
+
+  PORT_LOCK_DEBUG((" ...%p at %s locked(%p)...", 
+                  (void *)g_thread_self(), who, self));
 }
 
 static void su_source_unlock(su_port_t *self, char const *who)
 {
-  SU_SOURCE_UNLOCK(self, who);
+  g_static_mutex_unlock(self->sup_mutex);
+
+  PORT_LOCK_DEBUG((" ...%p at %s unlocked(%p)\n", 
+                  (void *)g_thread_self(), who, self));
 }
 
 static void su_source_incref(su_port_t *self, char const *who)
@@ -448,81 +490,6 @@ GSource *su_source_gsource(su_port_t *self)
   return self->sup_source;
 }
 
-/** @internal Send a message to the port. */
-int su_source_send(su_port_t *self, su_msg_r rmsg)
-{
-  enter;
-  
-  if (self) {
-    su_msg_t *msg;
-    GMainContext *gmc;
-
-    SU_SOURCE_LOCK(self, "su_source_send");
-    
-    msg = rmsg[0]; rmsg[0] = NULL;
-    *self->sup_tail = msg;
-    self->sup_tail = &msg->sum_next;
-
-    SU_SOURCE_UNLOCK(self, "su_source_send");
-
-    gmc = g_source_get_context(self->sup_source);
-
-    if (gmc)
-      g_main_context_wakeup(gmc);
-
-    return 0;
-  }
-  else {
-    su_msg_destroy(rmsg);
-    return -1;
-  }
-}
-
-/** @internal
- * Execute the messages in the incoming queue until the queue is empty..
- *
- * @param self - pointer to a port object
- *
- * @retval 0 if there was a signal to handle, 
- * @retval -1 otherwise.
- */
-static
-int su_source_getmsgs(su_port_t *self)
-{
-  enter;
-  
-  if (self && self->sup_head) {
-    su_root_t *root;
-    su_msg_f f;
-
-    SU_SOURCE_INCREF(self, "su_source_getmsgs");
-    SU_SOURCE_LOCK(self, "su_source_getmsgs");
-
-    while (self->sup_head) {
-      su_msg_t *msg = self->sup_head;
-      self->sup_head = msg->sum_next;
-      if (!self->sup_head) {
-       assert(self->sup_tail == &msg->sum_next);
-       self->sup_tail = &self->sup_head;
-      }
-      root = msg->sum_to->sut_root;
-      f = msg->sum_func;
-      SU_SOURCE_UNLOCK(self, "su_source_getmsgs");
-      if (f) 
-       f(su_root_magic(root), &msg, msg->sum_data);
-      su_msg_delivery_report(&msg);
-      SU_SOURCE_LOCK(self, "su_source_getmsgs");
-    }
-
-    SU_SOURCE_UNLOCK(self, "su_source_getmsgs");
-    SU_SOURCE_DECREF(self, "su_source_getmsgs");
-
-    return 0;
-  }
-  else
-    return -1;
-}
-
 /** @internal
  *
  *  Register a @c su_wait_t object. The wait object, a callback function and
@@ -914,13 +881,6 @@ int su_source_multishot(su_port_t *self, int multishot)
     return (errno = EINVAL), -1;
 }
 
-/** @internal Enable threadsafe operation. */
-static
-int su_source_threadsafe(su_port_t *port)
-{
-  return su_home_threadsafe(port->sup_home);
-}
-
 
 /** @internal Main loop.
  * 
@@ -1019,18 +979,19 @@ su_duration_t su_source_step(su_port_t *self, su_duration_t tout)
   return 0;
 }
 
+static int su_source_add_prepoll(su_port_t *port,
+                                su_root_t *root, 
+                                su_prepoll_f *prepoll, 
+                                su_prepoll_magic_t *magic)
+{
+  /* We could call prepoll in su_source_prepare()?? */
+  return -1;
+}
 
-/** @internal
- * Checks if the calling thread owns the port object.
- *
- * @param self pointer to a port object
- *
- * @retval true (nonzero) if the calling thread owns the port,
- * @retval false (zero) otherwise.
- */
-int su_source_own_thread(su_port_t const *self)
+static int su_source_remove_prepoll(su_port_t *port,
+                                 su_root_t *root)
 {
-  return self == NULL || SU_SOURCE_OWN_THREAD(self);
+  return -1;
 }
 
 #if 0
@@ -1061,52 +1022,44 @@ void su_source_dump(su_port_t const *self, FILE *f)
 
 #endif
 
-/* =========================================================================
- * Pre-poll() callback
+/**@internal
+ *
+ * Allocates and initializes a reactor and message port object.
+ *
+ * @return
+ *   If successful a pointer to the new message port is returned, otherwise
+ *   NULL is returned.  
  */
-
-int su_source_add_prepoll(su_port_t *port,
-                       su_root_t *root, 
-                       su_prepoll_f *callback, 
-                       su_prepoll_magic_t *magic)
+static su_port_t *su_source_port_create(void)
 {
-#if 0
-  if (port->sup_prepoll)
-    return -1;
+  SuSource *ss;
+  su_port_t *self = NULL;
 
-  port->sup_prepoll = callback;
-  port->sup_pp_magic = magic;
-  port->sup_pp_root = root;
+  SU_DEBUG_9(("su_source_port_create() called\n"));
 
-  return 0;
-#else
-  return -1;
-#endif
-}
+  ss = (SuSource *)g_source_new(su_source_funcs, (sizeof *ss));
 
-int su_source_remove_prepoll(su_port_t *port,
-                          su_root_t *root)
-{
-#if 0
-  if (port->sup_pp_root != root)
-    return -1;
+  if (ss) {
+    self = ss->ss_port;
+    if (su_source_port_init(self, ss->ss_source, su_source_port_vtable) < 0)
+      g_source_unref(ss->ss_source), self = NULL;
+  } else {
+    su_perror("su_source_port_create(): g_source_new");
+  }
 
-  port->sup_prepoll = NULL;
-  port->sup_pp_magic = NULL;
-  port->sup_pp_root = NULL;
+  SU_DEBUG_1(("su_source_port_create() returns %p\n", (void *)self));
 
-  return 0;
-#else
-  return -1;
-#endif
+  return self;
 }
 
-/* =========================================================================
- * Timers
- */
+/* No su_source_port_start */
 
-static
-su_timer_t **su_source_timers(su_port_t *self)
+/** Use su_source implementation when su_root_create() is called.
+ *
+ * @NEW_1_12_5
+ */
+void su_glib_prefer_gsource(void)
 {
-  return &self->sup_timers;
+  su_port_prefer(su_source_port_create, NULL);
 }
+
diff --git a/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/torture_su_glib_timer.c b/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/torture_su_glib_timer.c
new file mode 100644 (file)
index 0000000..13fb84c
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2005,2006 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
+ *
+ */
+
+/**
+ * @brief Test program for su-glib timers 
+ *
+ * Based on torture_su_timer.c of libsofia-sip-ua.
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <first.surname@nokia.com>
+ *
+ * @internal
+ *
+ * @date Created: Fri Oct 19 08:53:55 2001 pessi
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+
+#include <assert.h>
+
+struct tester;
+
+#define SU_ROOT_MAGIC_T struct tester
+#define SU_INTERNAL_P   su_root_t *
+#define SU_TIMER_ARG_T  struct timing
+
+#include "sofia-sip/su.h"
+#include "sofia-sip/su_wait.h"
+#include "sofia-sip/su_log.h"
+
+#include <sofia-sip/su_glib.h>
+
+struct timing
+{
+  int       t_run;
+  int       t_times;
+  su_time_t t_prev;
+};
+
+struct tester
+{
+  su_root_t *root;
+  su_timer_t *t, *t1;
+  unsigned times;
+  void *sentinel;
+};
+
+void
+print_stamp(struct tester *x, su_timer_t *t, struct timing *ti)
+{
+  su_time_t now = su_now(), prev = ti->t_prev;
+
+  ti->t_prev = now;
+
+  printf("timer interval %f\n", 1000 * su_time_diff(now, prev));
+
+  if (!ti->t_run)
+    su_timer_set(t, print_stamp, ti);
+
+  if (++ti->t_times >= 10)
+    su_timer_reset(t);
+}
+
+void
+print_X(struct tester *x, su_timer_t *t1, struct timing *ti)
+{
+  su_timer_set(t1, print_X, ti);
+  putchar('X'); fflush(stdout);
+}
+
+su_msg_r intr_msg = SU_MSG_R_INIT;
+
+static RETSIGTYPE intr_handler(int signum)
+{
+  su_msg_send(intr_msg);
+}
+
+static void test_break(struct tester *tester, su_msg_r msg, su_msg_arg_t *arg)
+{
+  su_root_break(tester->root);
+}
+
+void
+end_test(struct tester *tester, su_timer_t *t, struct timing *ti)
+{
+  printf("ending test\n");
+  su_timer_destroy(t);
+  su_timer_reset(tester->t);
+  su_timer_reset(tester->t1);
+  su_root_break(tester->root);
+}
+
+void
+increment(struct tester *tester, su_timer_t *t, struct timing *ti)
+{
+  tester->times++;
+
+  if ((void *)ti == (void*)tester->sentinel)
+    su_root_break(tester->root);
+}
+
+void
+usage(char const *name)
+{
+  fprintf(stderr, "usage: %s [-1r] [-Nnum] [interval]\n", name);
+  exit(1);
+}
+
+/*
+ * test su_timer functionality:
+ *
+ * Create a timer, executing print_stamp() in every 20 ms
+ */
+int main(int argc, char *argv[])
+{
+  su_root_t *root;
+  su_timer_t *t, *t1, *t_end;
+  su_timer_t **timers;
+  su_duration_t interval = 60;
+  char *argv0 = argv[0];
+  char *s;
+  int use_t1 = 0;
+  su_time_t now, started;
+  intptr_t i, N = 500;
+  GSource *source;
+
+  struct timing timing[1] = {{ 0 }};
+  struct tester tester[1] = {{ 0 }};
+
+  while (argv[1] && argv[1][0] == '-') {
+    char *o = argv[1] + 1;
+    while (*o) {
+      if (*o == '1')
+       o++, use_t1 = 1;
+      else if (*o == 'r')
+       o++, timing->t_run = 1;
+      else if (*o == 'N') {
+       if (o[1])
+         N = strtoul(o + 1, &o, 0);
+       else if (argv[2])
+         N = strtoul(argv++[2], &o, 0);
+       break;
+      }
+      else
+       break;
+
+    }
+    if (*o)
+      usage(argv0);
+    argv++;
+  }
+
+  if (argv[1]) {
+    interval = strtoul(argv[1], &s, 10);
+
+    if (interval == 0 || s == argv[1])
+      usage(argv0);
+  }
+
+  su_init(); atexit(su_deinit);
+
+  tester->root = root = su_glib_root_create(tester);
+  
+  source = su_root_gsource(tester->root);
+  g_source_attach(source, NULL /*g_main_context_default ()*/);
+
+  su_msg_create(intr_msg,
+               su_root_task(root),
+               su_root_task(root),
+               test_break, 0);
+
+  signal(SIGINT, intr_handler);
+#if HAVE_SIGPIPE
+  signal(SIGPIPE, intr_handler);
+  signal(SIGQUIT, intr_handler);
+  signal(SIGHUP, intr_handler);
+#endif
+
+  t = su_timer_create(su_root_task(root), interval);
+  t1 = su_timer_create(su_root_task(root), 1);
+  t_end = su_timer_create(su_root_task(root), 20 * interval);
+
+  if (t == NULL || t1 == NULL || t_end == NULL)
+    su_perror("su_timer_create"), exit(1);
+
+  tester->t = t, tester->t1 = t1;
+
+  timing->t_prev = su_now();
+
+  if (timing->t_run)
+    su_timer_run(t, print_stamp, timing);
+  else
+    su_timer_set(t, print_stamp, timing);
+
+  if (use_t1)
+    su_timer_set(t1, print_X, NULL);
+
+  su_timer_set(t_end, end_test, NULL);
+
+  su_root_run(root);
+
+  su_msg_destroy(intr_msg);
+
+  su_timer_destroy(t);
+  su_timer_destroy(t1);
+
+  if (timing->t_times != 10) {
+    fprintf(stderr, "%s: t expired %d times (expecting 10)\n",
+           argv0, timing->t_times);
+    return 1;
+  }
+
+  /* Insert timers in order */
+  timers = calloc(N, sizeof *timers);
+  if (!timers) { perror("calloc"); exit(1); }
+
+  now = started = su_now();
+
+  for (i = 0; i < N; i++) {
+    t = su_timer_create(su_root_task(root), 1000);
+    if (!t) { perror("su_timer_create"); exit(1); }
+    if (++now.tv_usec == 0) ++now.tv_sec;
+    su_timer_set_at(t, increment, (void *)i, now);
+    timers[i] = t;
+  }
+
+  tester->sentinel = (void*)(i - 1);
+
+  su_root_run(root);
+
+  printf("Processing %u timers took %f millisec (%f expected)\n",
+        (unsigned)i, su_time_diff(su_now(), started) * 1000, (double)i / 1000);
+
+  for (i = 0; i < N; i++) {
+    su_timer_destroy(timers[i]);
+  }
+
+  su_root_destroy(root);
+
+  su_deinit();
+
+  return 0;
+}
index b85f3bad3839a41f54d95703ec56734360589dea..9b33ad7b5bf22acf6d7638db06140c8ffdebf0f8 100644 (file)
@@ -1,3 +1,11 @@
+2007-02-09  Kai Vehmanen  <kai.vehmanen@nokia.com>
+
+       * libsofia-sip-ua interface v4 frozen (4:0:4) for the 1.12.5 release
+
+2006-10-12  Kai Vehmanen  <kai.vehmanen@nokia.com>
+
+       * libsofia-sip-ua interface v3 frozen (3:0:3) for the 1.12.3 release
+       
 2006-09-26  Kai Vehmanen  <kai.vehmanen@nokia.com>
 
        * libsofia-sip-ua interface v2 frozen (2:0:2) for the 1.12.2 release
index 2001bd2eb0c57fd7a52edad7ae1c95cdc2431c24..4c46c8833c09a1107f936855c66e7df54523bf7d 100644 (file)
@@ -9,12 +9,25 @@
 
 AUTOMAKE_OPTIONS = foreign
 
+# select whicn optional sofia-sip modules have been enabled
+# in the build
+OPT_LIBADD =
+OPT_SUBDIRS_STUN =
+OPT_SUBDIRS_NTH =
+if HAVE_STUN
+OPT_LIBADD += stun/libstun.la 
+OPT_SUBDIRS_STUN += stun
+endif
+if HAVE_NTH
+OPT_LIBADD += nth/libnth.la http/libhttp.la
+OPT_SUBDIRS_NTH += nth http
+endif
+
 # note: order does matter in the subdir list
-SUBDIRS = su features bnf sresolv sdp url msg sip stun ipt soa \
-         tport http nta nea iptsec nth nua
+SUBDIRS = su features bnf sresolv sdp url msg sip $(OPT_SUBDIRS_STUN) ipt soa \
+         tport nta nea iptsec $(OPT_SUBDIRS_NTH) nua
 DIST_SUBDIRS = $(SUBDIRS) docs
 
-EXTRA_DIST = sofia.am
 DOXYGEN = doxygen
 
 lib_LTLIBRARIES = libsofia-sip-ua.la
@@ -27,37 +40,22 @@ libsofia_sip_ua_la_LIBADD =         bnf/libbnf.la \
                                msg/libmsg.la \
                                nea/libnea.la \
                                nta/libnta.la \
-                               nth/libnth.la \
                                nua/libnua.la \
-                               http/libhttp.la \
                                sdp/libsdp.la \
                                sip/libsip.la \
                                soa/libsoa.la \
                                sresolv/libsresolv.la \
                                su/libsu.la \
-                               stun/libstun.la \
                                tport/libtport.la \
-                               url/liburl.la
+                               url/liburl.la \
+                               $(OPT_LIBADD)
+
 # set the libtool version info version:revision:age for libsofia-sip-ua
 # - soname to 'libsofia-sip-ua.so.(CUR-AGE)'
 libsofia_sip_ua_la_LDFLAGS = \
        -version-info $(LIBVER_SOFIA_SIP_UA_CUR):$(LIBVER_SOFIA_SIP_UA_REV):$(LIBVER_SOFIA_SIP_UA_AGE)
 
-if ENABLE_COVERAGE
-COVERAGE_RECURSIVE = coverage-recursive
-coverage: $(COVERAGE_RECURSIVE)
-endif
-
-all-recursive: built-sources-recursive
-built-sources: built-sources-recursive 
-clean-built-sources: clean-built-sources-recursive
-
-built-sources-recursive clean-built-sources-recursive $(COVERAGE_RECURSIVE):
-       target=`echo $@ | sed s/-recursive//`; \
-       list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-         echo "Making $@ in $$subdir"; \
-         (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
-       done;
+include $(top_srcdir)/rules/recursive.am
 
 doxygen: built-sources
        @echo Generating empty doxytags
index 3957b1be0d830726905c7c7b57568ae43034a743..5fc5406f879ed69b57c5b21b404c3eefaa4a559d 100644 (file)
@@ -43,4 +43,5 @@ TESTS = torture_bnf
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index a82b63aa5758357c451af8ecf81a4de50c4d3af2..3a55fec87562978f9c8a50ac8b25cad684333d8e 100644 (file)
@@ -377,7 +377,7 @@ int canonize_ip6_address(char *host, char *hexparts[9])
 
     if (i == maxparts + 1) {
       /* There is an extra doublecolon */
-      for (j = doublecolon; j <= i; j++)
+      for (j = doublecolon; j + 1 < i; j++)
        hexparts[j] = hexparts[j + 1];
       i--;
     }
@@ -825,9 +825,9 @@ static size_t convert_ip_address(char const *s,
 {
   size_t len;
   int canonize = 0;
+  char buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
 
 #if SU_HAVE_IN6
-  char buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
 
   len = span_ip6_reference(s);
   if (len) {
index ad5f4be1c9fc9c0c6c8144f32a239922ad2325f9..e977551b6cd612a5e384e25f53883b59f0d41545 100644 (file)
@@ -340,9 +340,10 @@ int host_test(void)
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v]\n", name);
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -353,8 +354,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       test_flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      test_flags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= bnf_test(); fflush(stdout);
index bfd981efdbd7508c4d03709944cf67d57a7285f9..f8d84c85d98aca8d878eec1f1da43327cb32437b 100644 (file)
@@ -45,4 +45,8 @@ ALIASES = \
  "VERSION_1_12_4=<a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.4.txt\">1.12.4</a>" \
  "VERSION_1_12_5=<a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.5.txt\">1.12.5</a>" \
  "NEW_1_12_5=@since New in <a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.5.txt\">1.12.5</a>" \
+ "EXP_1_12_5=@since Experimental in <a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.5.txt\">1.12.5</a>, available if --enable-experimental configuration option is given" \
+ "VERSION_1_12_6=<a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.6.txt\">1.12.6</a>" \
+ "NEW_1_12_6=@since New in <a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.6.txt\">1.12.6</a>" \
+ "EXP_1_12_6=@since Experimental in <a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.6.txt\">1.12.6</a>, available if --enable-experimental configuration option is given" \
 
index ef489f31a31c0e03844538e9e6976a175d3baa52..112632432d46cedce52ea9d8bfbcf211e0e80cdc 100644 (file)
@@ -47,4 +47,4 @@ CLEANFILES = Doxyfile.rfc
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
\ No newline at end of file
+include $(top_srcdir)/rules/sofia.am
index 527ec0c6b93e18b7d487b46e3626b3d92da303e3..8f96fb05c6a7fdd17d1c53d0352ce727a2d07f11 100644 (file)
@@ -31,4 +31,5 @@ EXTRA_DIST =          Doxyfile features.docs
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index 4914e18933dcb52806de39a9a6acf2f72d0b0d55..1306f53db03cad625469f4655cf06f4673a8724d 100644 (file)
@@ -30,17 +30,17 @@ PUBLIC_H =          sofia-sip/http.h sofia-sip/http_header.h \
                        sofia-sip/http_status.h sofia-sip/http_hclasses.h
 
 BUILT_H =              sofia-sip/http_protos.h sofia-sip/http_tag.h 
-BUILT_C =              http_tag.c http_tag_ref.c http_parser_table.c
+BUILT_C =              http_tag.c http_parser_table.c
 
-BUILT_SOURCES =        $(BUILT_H) $(BUILT_C)
+BUILT_SOURCES =        $(BUILT_H) $(BUILT_C) http_tag_ref.c
 
 nobase_include_sofia_HEADERS = $(BUILT_H) $(PUBLIC_H) 
 
 libhttp_la_SOURCES =   $(INTERNAL_H) \
                        http_parser.c http_header.c \
-                       http_basic.c http_extra.c \
+                       http_basic.c http_extra.c http_inlined.c \
                        http_status.c http_tag_class.c \
-                       $(BUILT_C)
+                       $(BUILT_SOURCES)
 
 COVERAGE_INPUT =       $(libhttp_la_SOURCES) $(include_sofia_HEADERS)
 
@@ -48,6 +48,7 @@ LDADD =               libhttp.la \
                        ../bnf/libbnf.la \
                        ../msg/libmsg.la \
                        ../url/liburl.la \
+                       ../ipt/libipt.la \
                        ../su/libsu.la
 
 test_http_LDFLAGS =    -static
@@ -64,30 +65,29 @@ EXTRA_DIST =                Doxyfile http.docs \
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 TAG_DLL_FLAGS = DLLREF=1
 
-MSG_PARSER_AWK = $(srcdir)/../msg/msg_parser.awk
+MSG_PARSER_AWK = ${srcdir}/../msg/msg_parser.awk
 
-AWK_HTTP_AWK = $(AWK) -f $(MSG_PARSER_AWK) module=http
+AWK_HTTP_AWK = ${AWK} -f ${MSG_PARSER_AWK} module=http
 
-sofia-sip/http_tag.h: sofia-sip/http_tag.h.in $(MSG_PARSER_AWK)
-sofia-sip/http_protos.h: sofia-sip/http_protos.h.in $(MSG_PARSER_AWK)
-http_tag.c: http_tag.c.in $(MSG_PARSER_AWK)
-http_parser_table.c: http_parser_table.c.in $(MSG_PARSER_AWK)
+SS_HTTP_H = ${srcdir}/sofia-sip/http.h
 
-sofia-sip/http_protos.h: sofia-sip/http.h
+${BUILT_H} ${BUILT_C}: ${srcdir}/sofia-sip/http.h ${MSG_PARSER_AWK}
+
+sofia-sip/http_protos.h: ${srcdir}/sofia-sip/http_protos.h.in 
        @-mkdir sofia-sip 2>/dev/null || true
-       $(AWK_HTTP_AWK) PR=$@ TEMPLATE=$(srcdir)/sofia-sip/http_protos.h.in $<
+       ${AWK_HTTP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_HTTP_H}
 
-sofia-sip/http_tag.h: sofia-sip/http.h
+sofia-sip/http_tag.h: ${srcdir}/sofia-sip/http_tag.h.in
        @-mkdir sofia-sip 2>/dev/null || true
-       $(AWK_HTTP_AWK) PR=$@ TEMPLATE=$(srcdir)/sofia-sip/http_tag.h.in $<
+       ${AWK_HTTP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_HTTP_H}
 
-http_tag.c: sofia-sip/http.h
-       $(AWK_HTTP_AWK) PR=$@ TEMPLATE=$(srcdir)/http_tag.c.in $<
+http_tag.c: ${srcdir}/http_tag.c.in
+       ${AWK_HTTP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_HTTP_H}
 
-http_parser_table.c: sofia-sip/http.h
-       $(AWK_HTTP_AWK) PT=$@ TEMPLATE=$(srcdir)/http_parser_table.c.in \
-               MC_HASH_SIZE=127 $<
+http_parser_table.c: ${srcdir}/http_parser_table.c.in
+       ${AWK_HTTP_AWK} PT=$@ TEMPLATE=${srcdir}/$@.in \
+               MC_HASH_SIZE=127 ${SS_HTTP_H}
index cd495e6144c8f8ae04775bdd99d4ccddb492f49f..c3510b4a0c53eea869978ac98240260a699fd433 100644 (file)
@@ -55,6 +55,7 @@
 #include <string.h>
 #include <assert.h>
 #include <stdio.h>
+#include <limits.h>
 
 /* ====================================================================== */
 
@@ -1196,7 +1197,7 @@ char *http_range_dup_one(msg_header_t *dst, msg_header_t const *src,
   http_range_t const *o = (http_range_t const *)src;
   char *end = b + xtra;
 
-  b = msg_params_dup((char const * const **)&rng->rng_specs,
+  b = msg_params_dup((msg_param_t const **)&rng->rng_specs,
                     o->rng_specs, b, xtra);
   MSG_STRING_DUP(b, rng->rng_unit, o->rng_unit);
 
diff --git a/libs/sofia-sip/libsofia-sip-ua/http/http_inlined.c b/libs/sofia-sip/libsofia-sip-ua/http/http_inlined.c
new file mode 100644 (file)
index 0000000..eb4bd47
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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
+ *
+ */
+
+/**@CFILE http_inlined.c
+ *
+ * Expand inlined http functions non-inline.
+ *
+ */
+
+#include "config.h"
+
+#include <sofia-sip/su_config.h>
+
+#if SU_HAVE_INLINE
+
+extern int xyzzy;
+
+#else
+
+#include "sofia-sip/msg_header.h"
+#include "sofia-sip/su_tag.h"
+
+#undef SU_HAVE_INLINE
+#undef su_inline
+
+#define SU_HAVE_INLINE 1
+#define su_inline
+
+#include "sofia-sip/http_header.h"
+
+#endif
index 1848086dabcfbed99bc104bd26b48143db573981..d3b2b3578120ea71a4ce128b3bc217df051c0a52 100644 (file)
@@ -61,9 +61,9 @@ char const http_version_1_0[] = "HTTP/1.0";
 /** HTTP version 0.9 is an empty string. */
 char const http_version_0_9[] = "";
 
-msg_mclass_t *http_default_mclass(void)
+msg_mclass_t const *http_default_mclass(void)
 {
-  extern msg_mclass_t http_mclass[];
+  extern msg_mclass_t const http_mclass[];
 
   return http_mclass;
 }
index 94234a62f731cf354e0ee392bfcc46835424ea93..6f8cf29fa95fcfd2a75571c470b84f8027eed79e 100644 (file)
@@ -95,7 +95,7 @@ SOFIAPUBVAR char const http_version_1_1[];
  */
 
 /** HTTP parser description. */
-SOFIAPUBFUN msg_mclass_t *http_default_mclass(void);
+SOFIAPUBFUN msg_mclass_t const *http_default_mclass(void);
 
 /** Complete a HTTP request. */
 SOFIAPUBFUN int http_request_complete(msg_t *msg);
index f282d233d85974bb9c81c719faa32497214cce81..3b76a2b7bb219ae5c8defddfc5542aa93ff5c197 100644 (file)
@@ -76,14 +76,7 @@ static int http_tag_test(void);
 static int test_query_parser(void);
 
 static msg_t *read_message(char const string[]);
-msg_mclass_t *test_mclass = NULL;
-
-void usage(void)
-{
-  fprintf(stderr,
-         "usage: %s [-v]\n",
-         name);
-}
+msg_mclass_t const *test_mclass = NULL;
 
 char *lastpart(char *path)
 {
@@ -95,6 +88,14 @@ char *lastpart(char *path)
 
 int tstflags;
 
+void usage(int exitcode)
+{
+  fprintf(stderr,
+         "usage: %s [-v] [-a]\n",
+         name);
+  exit(exitcode);
+}
+
 int main(int argc, char *argv[])
 {
   int retval = 0;
@@ -105,8 +106,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   if (!test_mclass)
index 107546af7acc04c4071ee3da2e1f0e093b24b141..90c7cc242b77144d6d3ef976ba63d68c76d991c0 100644 (file)
@@ -51,4 +51,5 @@ EXTRA_DIST +=         Doxyfile ipt.docs
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index dff6dc4be171f2ed765be71848d3119530f0ccb4..9f4b1e7487e1df91f5195238dd4668c173fcc5c3 100644 (file)
@@ -57,6 +57,9 @@ SOFIAPUBFUN isize_t base64_e(char buf[], isize_t bsiz, void *data, isize_t dsiz)
 /** Calculate size of n bytes encoded in base64 */
 #define BASE64_SIZE(n) ((((n) + 2) / 3) * 4)
 
+/** Calculate size of n bytes encoded in base64 sans trailing =. @NEW_1_12_5 */
+#define BASE64_MINSIZE(n) ((n * 4 + 2) / 3)
+
 SOFIA_END_DECLS
 
 #endif /* !BASE_64 */
index 58365583a6f68e6db8248779505aeb9a2a4f409f..afd569e9fdb2705f2300791a7d68611154f8ce95 100644 (file)
 
 SOFIA_BEGIN_DECLS
 
-#if SU_HAVE_INLINE
-su_inline
-#else
-SOFIAPUBFUN
-#endif
-int 
-  str0cmp(char const *a, char const *b),
-  str0ncmp(char const *a, char const *b, size_t n),
-  str0casecmp(char const *a, char const *b),
-  str0ncasecmp(char const *a, char const *b, size_t n);
-
-#if SU_HAVE_INLINE
-su_inline
-#else
-SOFIAPUBFUN
-#endif
-size_t
-strnspn(char const *s, size_t size, char const *term),
-  strncspn(char const *s, size_t ssize, char const *reject);
-
-#if SU_HAVE_INLINE
-int str0cmp(char const *a, char const *b)
+su_inline int str0cmp(char const *a, char const *b)
 {
   if (a == NULL) a = "";
   if (b == NULL) b = "";
   return strcmp(a, b);
 }
 
-int str0ncmp(char const *a, char const *b, size_t n)
+su_inline int str0ncmp(char const *a, char const *b, size_t n)
 {
   if (a == NULL) a = "";
   if (b == NULL) b = "";
   return strncmp(a, b, n);
 }
 
-int str0casecmp(char const *a, char const *b)
+su_inline int str0casecmp(char const *a, char const *b)
 {
   if (a == NULL) a = "";
   if (b == NULL) b = "";
   return strcasecmp(a, b);
 }
 
-int str0ncasecmp(char const *a, char const *b, size_t n)
+su_inline int str0ncasecmp(char const *a, char const *b, size_t n)
 {
   if (a == NULL) a = "";
   if (b == NULL) b = "";
   return strncasecmp(a, b, n);
 }
 
-size_t strnspn(char const *s, size_t ssize, char const *term)
+#if !SU_HAVE_INLINE
+SOFIAPUBFUN size_t strnspn(char const *s, size_t size, char const *term);
+SOFIAPUBFUN size_t strncspn(char const *s, size_t ssize, char const *reject);
+#else
+su_inline size_t strnspn(char const *s, size_t ssize, char const *term)
 {
   size_t n;
   size_t tsize = strlen(term);
@@ -123,7 +106,7 @@ size_t strnspn(char const *s, size_t ssize, char const *term)
   return n;
 }
 
-size_t strncspn(char const *s, size_t ssize, char const *reject)
+su_inline size_t strncspn(char const *s, size_t ssize, char const *reject)
 {
   size_t n;
   size_t rsize = strlen(reject);
index 456211cbd5107389415e9f2daa067c30cc749205..c61db6261df4b243b288442bdd05a072bee104fa 100644 (file)
@@ -161,11 +161,12 @@ int test_decoding(void)
 }
 
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr,
-         "usage: %s [-v]\n",
+         "usage: %s [-v] [-a]\n",
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -176,8 +177,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_encoding(); fflush(stdout);
index f9ad87b93c36e7c24c98b28e5eebdff223fc8954..bc16f9cfed977921fb3b389389339d3c2a420096 100644 (file)
@@ -11,6 +11,7 @@ TAGFILES           += ../docs/bnf.doxytags=../bnf
 TAGFILES           += ../docs/url.doxytags=../url
 TAGFILES           += ../docs/msg.doxytags=../msg
 TAGFILES           += ../docs/sip.doxytags=../sip
+TAGFILES           += ../docs/http.doxytags=../http
 TAGFILES           += ../docs/sresolv.doxytags=../sresolv
 TAGFILES           += ../docs/tport.doxytags=../tport
 TAGFILES           += ../docs/nta.doxytags=../nta
@@ -18,3 +19,6 @@ TAGFILES           += ../docs/nta.doxytags=../nta
 GENERATE_TAGFILE    = ../docs/iptsec.doxytags
 
 ALIASES           += 
+
+PREDEFINED         += SOFIA_EXTEND_AUTH_CLIENT=1
+
index 4c84e805a4001b061c71bf4cf2a3c9d61591ccf7..aa3424098dea917724cf9c1025a2c0d3d9c9ce1f 100644 (file)
@@ -35,29 +35,18 @@ nobase_include_sofia_HEADERS = \
                        sofia-sip/auth_common.h \
                        sofia-sip/auth_client.h sofia-sip/auth_digest.h \
                        sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
-                       sofia-sip/auth_client_plugin.h \
-                       $(NTLM_HEADER)
+                       sofia-sip/auth_client_plugin.h
 
 libiptsec_la_SOURCES =         iptsec_debug.h \
                        auth_client.c auth_common.c auth_digest.c \
                        auth_module.c auth_tag.c auth_tag_ref.c \
                        auth_plugin.c auth_plugin_delayed.c \
-                       auth_module_http.c auth_module_sip.c \
-                       $(NTLM_SOURCE) \
+                       auth_module_sip.c \
                        iptsec_debug.c
 
-NTLM_HEADER =          sofia-sip/auth_ntlm.h
-if HAVE_NTLM
-NTLM_SOURCE =          auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
-endif
-
-EXTRA_libiptsec_la_SOURCES = \
-                       auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
-
 COVERAGE_INPUT =       $(libiptsec_la_SOURCES) $(include_sofia_HEADERS)
 
 LDADD =                libiptsec.la \
-                       ../http/libhttp.la \
                        ../nta/libnta.la \
                        ../sip/libsip.la \
                        ../msg/libmsg.la \
@@ -68,13 +57,31 @@ LDADD =             libiptsec.la \
 
 test_auth_digest_LDFLAGS = -static
 
+if HAVE_NTLM
+nobase_include_sofia_HEADERS += $(NTLM_HEADER)
+libiptsec_la_SOURCES += $(NTLM_SOURCE)
+endif
+
+if HAVE_NTH
+libiptsec_la_SOURCES += $(HTTP_SOURCE)
+LDADD +=               ../http/libhttp.la
+endif
+
+HTTP_SOURCE =          auth_module_http.c
+
+NTLM_HEADER =          sofia-sip/auth_ntlm.h
+NTLM_SOURCE =          auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
+
+EXTRA_libiptsec_la_SOURCES = \
+                       $(NTLM_HEADER) $(NTLM_SOURCE) $(HTTP_SOURCE)
+
 # ----------------------------------------------------------------------
 # Install and distribution rules
 
-EXTRA_DIST =           Doxyfile iptsec.docs testpasswd \
-                       auth_module_sip.c auth_module_http.c $(BUILT_SOURCES)
+EXTRA_DIST =           Doxyfile iptsec.docs testpasswd $(BUILT_SOURCES)
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index 5c7dd4b1c2967e418ac1350820386b6340f09142..e12e0bc0127386a566a02f2a6cbf274cf60f72b2 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "config.h"
 
+#define SOFIA_EXTEND_AUTH_CLIENT 1
+
 #include <sofia-sip/su.h>
 #include <sofia-sip/su_md5.h>
 
@@ -77,9 +79,7 @@ static int ca_credentials(auth_client_t *ca,
                          char const *user,
                          char const *pass);
 
-static int ca_clear_credentials(auth_client_t *ca, 
-                               char const *scheme,
-                               char const *realm);
+static int ca_clear_credentials(auth_client_t *ca);
 
 
 /** Initialize authenticators.
@@ -178,29 +178,31 @@ int ca_challenge(auth_client_t *ca,
     return -1;
 
   if (!ca->ca_credential_class)
-    stale = 1, ca->ca_credential_class = credential_class;
+    stale = 2, ca->ca_credential_class = credential_class;
 
-  return stale ? 2 : 1;
+  return stale > 1 ? 2 : 1;
 }
 
 /** Store authentication info to authenticators.
  *
- * The function auc_info() feeds the authentication data from the
- * authentication info @a info to the list of authenticators @a auc_list.
+ * The function auc_info() feeds the authentication data from the @b
+ * Authentication-Info header @a info to the list of authenticators @a
+ * auc_list.
  *
  * @param[in,out] auc_list  list of authenticators to be updated
- * @param[in] info      info to be processed
- * @param[in] crcl      corresponding credential class
+ * @param[in] info        info header to be processed
+ * @param[in] credential_class      corresponding credential class
  *
- * The authentication info can be in either Authentication-Info or in
- * Proxy-Authentication-Info headers.
- * If the header is Authentication-Info, the @a crcl should be
- * #sip_authorization_class or #http_authorization_class.
- * Likewise, If the header is Proxy-Authentication-Info, the @a crcl should
- * be #sip_proxy_authorization_class or #http_proxy_authorization_class.
-
- * The authentication into usually contains next nonce or mutual
- * authentication information. We handle only nextnonce parameter. 
+ * The authentication info can be in either @AuthenticationInfo or in
+ * @ProxyAuthenticationInfo headers. If the header is @AuthenticationInfo,
+ * the @a credential_class should be #sip_authorization_class or
+ * #http_authorization_class. Likewise, If the header is
+ * @ProxyAuthenticationInfo, the @a credential_class should be
+ * #sip_proxy_authorization_class or #http_proxy_authorization_class.
+
+ * The authentication into header usually contains next nonce or mutual
+ * authentication information. Currently, only the nextnonce parameter is
+ * processed.
  *
  * @bug
  * The result can be quite unexpected if there are more than one
@@ -210,9 +212,11 @@ int ca_challenge(auth_client_t *ca,
  * @retval number of challenges to updated
  * @retval 0 when there was no challenge to update
  * @retval -1 upon an error
+ *
+ * @NEW_1_12_5
  */
 int auc_info(auth_client_t **auc_list,
-            msg_auth_info_t const *ai,
+            msg_auth_info_t const *info,
             msg_hclass_t *credential_class)
 {
   auth_client_t *ca;
@@ -222,7 +226,7 @@ int auc_info(auth_client_t **auc_list,
 
   /* Update matching authenticator */
   for (ca = *auc_list; ca; ca = ca->ca_next) {
-    int updated = ca_info(ca, ai, credential_class);
+    int updated = ca_info(ca, info, credential_class);
     if (updated < 0)
       return -1;
     if (updated >= 1)
@@ -241,12 +245,12 @@ int auc_info(auth_client_t **auc_list,
  */
 static
 int ca_info(auth_client_t *ca, 
-           msg_auth_info_t const *ai,
+           msg_auth_info_t const *info,
            msg_hclass_t *credential_class)
 {
-  assert(ca); assert(ai);
+  assert(ca); assert(info);
 
-  if (!ca || !ai)
+  if (!ca || !info)
     return -1;
 
   if (!ca->ca_credential_class)
@@ -261,7 +265,7 @@ int ca_info(auth_client_t *ca,
       || !ca->ca_auc->auc_info)
     return 0;
 
-  return ca->ca_auc->auc_info(ca, ai);
+  return ca->ca_auc->auc_info(ca, info);
 }
 
 
@@ -336,8 +340,8 @@ int auc_credentials(auth_client_t **auc_list, su_home_t *home,
  * @param[in] user          username 
  * @param[in] pass          password
  * 
- * @retval number of matching clients
- * @retval 0 when no matching client was found
+ * @retval number of updated clients
+ * @retval 0 when no client was updated
  * @retval -1 upon an error
  */
 int auc_all_credentials(auth_client_t **auc_list, 
@@ -371,6 +375,9 @@ int ca_credentials(auth_client_t *ca,
                   char const *user,
                   char const *pass)
 {
+  char *new_user, *new_pass;
+  char *old_user, *old_pass;
+
   assert(ca);
 
   if (!ca || !ca->ca_scheme || !ca->ca_realm)
@@ -380,12 +387,24 @@ int ca_credentials(auth_client_t *ca,
       (realm != NULL && strcmp(realm, ca->ca_realm)))
     return -1;
 
-  ca->ca_user = su_strdup(ca->ca_home, user);
-  ca->ca_pass = su_strdup(ca->ca_home, pass);
+  old_user = ca->ca_user, old_pass = ca->ca_pass;
 
-  if (!ca->ca_user || !ca->ca_pass)
+  if (str0cmp(user, old_user) == 0 && str0cmp(pass, old_pass) == 0)
+    return 0;
+
+  new_user = su_strdup(ca->ca_home, user);
+  new_pass = su_strdup(ca->ca_home, pass);
+
+  if (!new_user || !new_pass)
     return -1;
 
+  ca->ca_user = new_user, ca->ca_pass = new_pass;
+  if (AUTH_CLIENT_IS_EXTENDED(ca))
+    ca->ca_clear = 0;
+
+  su_free(ca->ca_home, old_user);
+  su_free(ca->ca_home, old_pass);
+
   return 1;
 }
 
@@ -412,12 +431,15 @@ int auc_copy_credentials(auth_client_t **dst,
       char *u, *p;
       if (!ca->ca_user || !ca->ca_pass)
        continue;
+      if (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear)
+       continue;
       if (!ca->ca_scheme[0] || strcmp(ca->ca_scheme, d->ca_scheme))
        continue;
       if (!ca->ca_realm[0] || strcmp(ca->ca_realm, d->ca_realm))
        continue;
 
-      if (d->ca_user && strcmp(d->ca_user, ca->ca_user) == 0 &&
+      if (!(AUTH_CLIENT_IS_EXTENDED(d) && d->ca_clear) &&
+         d->ca_user && strcmp(d->ca_user, ca->ca_user) == 0 &&
          d->ca_pass && strcmp(d->ca_pass, ca->ca_pass) == 0) {
        retval++;
        break;
@@ -431,6 +453,9 @@ int auc_copy_credentials(auth_client_t **dst,
       if (d->ca_user) su_free(d->ca_home, (void *)d->ca_user);
       if (d->ca_pass) su_free(d->ca_home, (void *)d->ca_pass);
       d->ca_user = u, d->ca_pass = p;
+      if (AUTH_CLIENT_IS_EXTENDED(d))
+       d->ca_clear = 0;
+
       retval++;
       break;
     }
@@ -453,13 +478,24 @@ int auc_copy_credentials(auth_client_t **dst,
  * @retval -1 upon an error
  */
 int auc_clear_credentials(auth_client_t **auc_list, 
-                        char const *scheme,
-                        char const *realm)
+                         char const *scheme,
+                         char const *realm)
 {
   int retval = 0;
+  int match;
 
   for (; *auc_list; auc_list = &(*auc_list)->ca_next) {
-    int match = ca_clear_credentials(*auc_list, scheme, realm);
+    auth_client_t *ca = *auc_list;
+
+    if (!AUTH_CLIENT_IS_EXTENDED(ca))
+      continue;
+
+    if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
+       (realm != NULL && strcmp(realm, ca->ca_realm)))
+      continue;
+
+    match = ca->ca_auc->auc_clear(*auc_list);
+
     if (match < 0) {
       retval = -1;
       break;
@@ -472,21 +508,14 @@ int auc_clear_credentials(auth_client_t **auc_list,
 }
 
 static
-int ca_clear_credentials(auth_client_t *ca, 
-                        char const *scheme,
-                        char const *realm)
+int ca_clear_credentials(auth_client_t *ca)
 {
-  assert(ca);
-
-  if (!ca || !ca->ca_scheme || !ca->ca_realm)
-    return -1;
+  assert(ca); assert(ca->ca_home->suh_size >= (int)(sizeof *ca));
 
-  if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
-      (realm != NULL && strcmp(realm, ca->ca_realm)))
+  if (!ca)
     return -1;
 
-  su_free(ca->ca_home, (void *)ca->ca_user), ca->ca_user = NULL;
-  su_free(ca->ca_home, (void *)ca->ca_pass), ca->ca_pass = NULL;
+  ca->ca_clear = 1;
 
   return 1;
 }
@@ -495,6 +524,8 @@ int ca_clear_credentials(auth_client_t *ca,
  * 
  * @retval 1 when authorization can proceed
  * @retval 0 when there is not enough credentials
+ *
+ * @NEW_1_12_5
  */
 int auc_has_authorization(auth_client_t **auc_list)
 {
@@ -507,6 +538,8 @@ int auc_has_authorization(auth_client_t **auc_list)
   for (ca = *auc_list; ca; ca = ca->ca_next) {
     if (!ca->ca_user || !ca->ca_pass || !ca->ca_credential_class)
       return 0;
+    if (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear)
+      return 0;
   }
 
   return 1;
@@ -564,8 +597,11 @@ int auc_authorization(auth_client_t **auc_list, msg_t *msg, msg_pub_t *pub,
     if (!ca->ca_auc)
       continue;
 
-    if (ca->ca_auc->auc_authorize(ca, home, method, url, body, &h) < 0
-       || msg_header_insert(msg, pub, h) < 0)
+    if (ca->ca_auc->auc_authorize(ca, home, method, url, body, &h) < 0)
+      return -1;
+    if (h == NULL)
+      continue;
+    if (msg_header_insert(msg, pub, h) < 0)
       return -1;
   }
 
@@ -633,14 +669,15 @@ static int auc_basic_authorization(auth_client_t *ca,
                                   msg_payload_t const *body,
                                   msg_header_t **);
 
-const auth_client_plugin_t ca_basic_plugin = 
+static const auth_client_plugin_t ca_basic_plugin = 
 { 
   /* auc_plugin_size: */ sizeof ca_basic_plugin,
   /* auc_size: */        sizeof (auth_client_t),
   /* auc_name: */       "Basic",
   /* auc_challenge: */   NULL,
   /* auc_authorize: */   auc_basic_authorization,
-  /* auc_info: */        NULL
+  /* auc_info: */        NULL,
+  /* auc_clear: */       ca_clear_credentials
 };
 
 /**Create a basic authorization header.
@@ -677,6 +714,9 @@ int auc_basic_authorization(auth_client_t *ca,
   if (user == NULL || pass == NULL)
     return -1;
 
+  if (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear)
+    return 0;
+
   ulen = strlen(user), plen = strlen(pass), uplen = ulen + 1 + plen;
   b64len = BASE64_SIZE(uplen);
   basiclen = strlen("Basic ") + b64len;
@@ -731,7 +771,7 @@ static int auc_digest_authorization(auth_client_t *ca,
                                    msg_payload_t const *body,
                                    msg_header_t **);
 static int auc_digest_info(auth_client_t *ca, 
-                          msg_auth_info_t const *ai);
+                          msg_auth_info_t const *info);
 
 static const auth_client_plugin_t ca_digest_plugin = 
 { 
@@ -740,10 +780,15 @@ static const auth_client_plugin_t ca_digest_plugin =
   /* auc_name: */       "Digest", 
   /* auc_challenge: */   auc_digest_challenge,
   /* auc_authorize: */   auc_digest_authorization,
-  /* auc_info: */        auc_digest_info
+  /* auc_info: */        auc_digest_info,
+  /* auc_clear: */       ca_clear_credentials
 };
 
 /** Store a digest authorization challenge.
+ *
+ * @retval 2 if credentials need to be (re)sent
+ * @retval 1 if challenge was updated
+ * @retval -1 upon an error
  */
 static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
 {
@@ -761,27 +806,18 @@ static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
   if (ac->ac_qop && !ac->ac_auth && !ac->ac_auth_int)
     goto error;
 
-  stale = ac->ac_stale || str0cmp(ac->ac_nonce, cda->cda_ac->ac_nonce);
+  stale = ac->ac_stale || cda->cda_ac->ac_nonce == NULL;
 
   if (ac->ac_qop && (cda->cda_cnonce == NULL || ac->ac_stale)) {
     su_guid_t guid[1];
     char *cnonce;
-    char *e;
-
+    size_t b64len = BASE64_MINSIZE(sizeof(guid)) + 1;
     if (cda->cda_cnonce != NULL)
       /* Free the old one if we are updating after stale=true */
       su_free(home, (void *)cda->cda_cnonce);
     su_guid_generate(guid);
-    cda->cda_cnonce = cnonce = su_alloc(home, BASE64_SIZE(sizeof(guid)) + 1);
-    base64_e(cnonce, BASE64_SIZE(sizeof(guid)) + 1, guid, sizeof(guid));
-    /* somewhere else in the code the '=' chars are stripped in the header 
-       we need to strip it now before the digest is created or we're in trouble
-       cos they won't match.....
-    */
-    e = cnonce + strlen(cnonce) - 1;
-    while(*e == '=') {
-       *e-- = '\0';
-    }
+    cda->cda_cnonce = cnonce = su_alloc(home, b64len);
+    base64_e(cnonce, b64len, guid, sizeof(guid));
     cda->cda_ncount = 0;
   }
 
@@ -797,14 +833,14 @@ static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
 }
 
 static int auc_digest_info(auth_client_t *ca,
-                          msg_auth_info_t const *ai)
+                          msg_auth_info_t const *info)
 {
   auth_digest_client_t *cda = (auth_digest_client_t *)ca;
   su_home_t *home = ca->ca_home;
   char const *nextnonce = NULL;
   issize_t n;
 
-  n = auth_get_params(home, ai->ai_params,
+  n = auth_get_params(home, info->ai_params,
                      "nextnonce=", &nextnonce,
                      NULL);
 
@@ -825,9 +861,9 @@ static int auc_digest_info(auth_client_t *ca,
  * sip_authorization_class or sip_proxy_authorization_class, as well as
  * http_authorization_class or http_proxy_authorization_class.
  *
- * @return
- * Returns a pointer to newly created authorization header, or NULL upon an
- * error.
+ * @retval 1 when authorization headers has been created  
+ * @retval 0 when there is no credentials
+ * @retval -1 upon an error
  */
 static
 int auc_digest_authorization(auth_client_t *ca, 
@@ -853,6 +889,9 @@ int auc_digest_authorization(auth_client_t *ca,
   auth_response_t ar[1] = {{ 0 }};
   char ncount[17];
 
+  if (!user || !pass || (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear))
+    return 0;
+
   ar->ar_size = sizeof(ar);
   ar->ar_username = user;
   ar->ar_realm = ac->ac_realm;
index 5205185a5e2d686278aaae562f9b143bff67c941..0974b311b5caf5e0a9e25b67534e132bb8c933b1 100644 (file)
@@ -76,6 +76,7 @@ static char const __func__[] = "auth_mod";
 
 char const auth_internal_server_error[] = "Internal server error";
 
+static void auth_call_scheme_destructor(void *);
 static void auth_md5_hmac_key(auth_mod_t *am);
 
 HTABLE_PROTOS_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
@@ -94,7 +95,7 @@ auth_mod_t *auth_mod_alloc(auth_scheme_t *scheme,
 
   if ((am = su_home_new(scheme->asch_size))) {
     am->am_scheme = scheme;
-    am->am_refcount = 1;
+    su_home_destructor(am->am_home, auth_call_scheme_destructor);
   }
 
   return am;
@@ -246,10 +247,14 @@ int auth_init_default(auth_mod_t *am,
 /** Destroy (a reference to) an authentication module. */
 void auth_mod_destroy(auth_mod_t *am)
 {
-  if (am && am->am_refcount != 0 && --am->am_refcount == 0) {
-    am->am_scheme->asch_destroy(am);
-    su_home_zap(am->am_home);
-  }
+  su_home_unref(am->am_home);
+}
+
+/** Call scheme-specific destructor function. */
+static void auth_call_scheme_destructor(void *arg)
+{
+  auth_mod_t *am = arg;
+  am->am_scheme->asch_destroy(am);
 }
 
 /** Do-nothing destroy function.
@@ -264,18 +269,13 @@ void auth_destroy_default(auth_mod_t *am)
 /** Create a new reference to authentication module. */
 auth_mod_t *auth_mod_ref(auth_mod_t *am)
 {
-  if (!am || am->am_refcount == 0)
-    return NULL;
-
-  am->am_refcount++;
-
-  return am;
+  return (auth_mod_t *)su_home_ref(am->am_home);
 }
 
 /** Destroy a reference to an authentication module. */
 void auth_mod_unref(auth_mod_t *am)
 {
-  auth_mod_destroy(am);
+  su_home_unref(am->am_home);
 }
 
 /** Get authenticatin module name. @NEW_1_12_4. */
@@ -608,7 +608,7 @@ struct nonce {
   uint8_t    digest[6];
 };
 
-#define AUTH_DIGEST_NONCE_LEN (BASE64_SIZE(sizeof (struct nonce)) + 1)
+#define AUTH_DIGEST_NONCE_LEN (BASE64_MINSIZE(sizeof (struct nonce)) + 1)
 
 /** Authenticate a request with @b Digest authentication scheme.
  *
@@ -950,7 +950,8 @@ int auth_readdb_if_needed(auth_mod_t *am)
 #include <sys/file.h>
 #endif
 
-#define auth_apw_local auth_readdb_internal
+/* This is just a magic value */
+#define auth_apw_local ((void *)(intptr_t)auth_readdb_internal)
 
 /** Read authentication database */
 static
index d60c41a28183154cf65ec44870baef986ae601ac..69178a1c5140cfe452702a906bfc7bc10f778b94 100644 (file)
@@ -126,7 +126,7 @@ static int delayed_auth_init(auth_mod_t *am,
 
 struct auth_splugin_t 
 {
-  void const      *asp_tag;
+  void const      *asp_cookie;
   auth_splugin_t  *asp_next;
   auth_splugin_t **asp_prev;
   auth_mod_t      *asp_am;
@@ -136,6 +136,8 @@ struct auth_splugin_t
   int              asp_canceled;
 };
 
+/* This is unique identifier */
+#define delayed_asp_cookie ((void const *)(intptr_t)delayed_auth_cancel)
 
 static void delayed_auth_method_recv(su_root_magic_t *rm,
                                     su_msg_r msg,
@@ -162,7 +164,7 @@ static void delayed_auth_method(auth_mod_t *am,
 
   asp = su_msg_data(mamc); assert(asp);
 
-  asp->asp_tag = delayed_auth_cancel;
+  asp->asp_cookie = delayed_asp_cookie;
   asp->asp_am = am;
   asp->asp_as = as;
   asp->asp_header = auth;
@@ -216,7 +218,7 @@ static void delayed_auth_cancel(auth_mod_t *am, auth_status_t *as)
 
   (void)ap;                    /* xyzzy */
   
-  if (as->as_plugin && as->as_plugin->asp_tag == delayed_auth_cancel)
+  if (as->as_plugin && as->as_plugin->asp_cookie == delayed_asp_cookie)
     as->as_plugin->asp_canceled = 1;
 
   as->as_status = 500, as->as_phrase = "Authentication canceled";
index a0ed90bd7ec3410f8de28309f6891d2f377a72bb..a87a2bb9e957d19e62e76a1d519fcefee31fd4c0 100644 (file)
@@ -29,6 +29,9 @@
 /**@file sofia-sip/auth_client_plugin.h
  * @brief Client-side plugin interface for authentication
  * 
+ * @note For extensions in 1.12.6 or later, 
+ * you have to #define SOFIA_EXTEND_AUTH_CLIENT to 1.
+ *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  * 
  * @date Created: Fri May 19 16:18:21 EEST 2006
@@ -58,6 +61,10 @@ struct auth_client_s {
   char         *ca_pass;
 
   msg_hclass_t *ca_credential_class;
+
+#if SOFIA_EXTEND_AUTH_CLIENT
+  int           ca_clear;
+#endif
 };
 
 struct auth_client_plugin
@@ -81,8 +88,19 @@ struct auth_client_plugin
 
   /** Store nextnonce from Authentication-Info or Proxy-Authentication-Info. */
   int (*auc_info)(auth_client_t *ca, msg_auth_info_t const *ai);
+
+#if SOFIA_EXTEND_AUTH_CLIENT
+  /** Clear credentials (user/pass). @NEW_1_12_6 */
+  int (*auc_clear)(auth_client_t *ca);
+#endif
 };
 
+/** Check if authentication client has been extended. @NEW_1_12_6 */
+#define AUTH_CLIENT_IS_EXTENDED(ca)                                    \
+  ((ca)->ca_auc->auc_plugin_size >                                     \
+   (int)offsetof(auth_client_plugin_t, auc_clear)                      \
+   && (ca)->ca_auc->auc_clear != NULL)
+
 SOFIA_END_DECLS
 
 #endif /* !defined AUTH_CLIENT_PLUGIN_H */
index 517c80ddd6e603893c77b6efcf3f39e4680dbf0e..97b10a8509181bd4ba707d763bfe9fb850c3438a 100644 (file)
@@ -105,7 +105,7 @@ struct auth_scheme
 typedef struct
 {
   unsigned        apw_index;   /**< Key to hash table */
-  void const     *apw_type;    /**< Magic pointer */
+  void const     *apw_type;    /**< Magic identifier */
 
   char const            *apw_user;     /**< Username */
   char const     *apw_realm;   /**< Realm */
@@ -124,7 +124,7 @@ struct stat;
 struct auth_mod_t
 {
   su_home_t      am_home[1];
-  unsigned       am_refcount;  /**< Number of references to this module */
+  unsigned       _am_refcount; /**< Not used */
 
   /* User database / cache */
   char const    *am_db;                /**< User database file name */
index ee253a2fa9859ba64ce73fc28152b085537ae41f..d819a9978435b1657c7e118cab0c9ca31204ab2f 100644 (file)
@@ -769,8 +769,6 @@ int test_digest_client()
     {
       char const *nonce1, *nextnonce, *nonce2;
 
-      reinit_as(as); auth_mod_destroy(am); aucs = NULL;
-
       TEST_1(am = auth_mod_create(NULL, 
                                  AUTHTAG_METHOD("Digest"),
                                  AUTHTAG_REALM("ims3.so.noklab.net"),
@@ -1164,9 +1162,10 @@ int test_module_io()
 extern su_log_t iptsec_log[];
 
 static
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v] [-l n]\n", name);
+  fprintf(stderr, "usage: %s [-v] [-a] [-l n]\n", name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -1179,8 +1178,10 @@ int main(int argc, char *argv[])
   su_init();
 
   for (i = 1; argv[i]; i++) {
-    if (argv[i] && strcmp(argv[i], "-v") == 0)
+    if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else if (strncmp(argv[i], "-l", 2) == 0) {
       int level = 3;
       char *rest = NULL;
@@ -1193,11 +1194,11 @@ int main(int argc, char *argv[])
        level = 3, rest = "";
 
       if (rest == NULL || *rest)
-       usage();
+       usage(1);
       
       su_log_set_level(iptsec_log, level);
     } else {
-      usage();
+      usage(1);
     }
   }
 
index 5accd41bc29b0ffbc2e676b24ee61b3eff986bea..25b32ec93814911220c1e048e32d1af95419f59a 100644 (file)
@@ -35,10 +35,12 @@ INTERNAL_H = msg_internal.h test_class.h
 nobase_include_sofia_HEADERS = \
                        $(GENERATED_H) $(PUBLIC_H) 
 
-BUILT_SOURCES = $(GENERATED_H) msg_mime_table.c test_table.c test_protos.h
+GENERATED_HC = $(GENERATED_H) msg_mime_table.c test_table.c test_protos.h
 
-libmsg_la_SOURCES = $(INTERNAL_H) \
-       msg.c msg_tag.c \
+BUILT_SOURCES = $(GENERATED_HC)
+
+libmsg_la_SOURCES = msg_internal.h \
+       msg.c msg_tag.c msg_inlined.c \
        msg_mime.c msg_mime_table.c \
        msg_header_copy.c msg_header_make.c \
        msg_parser.c msg_mclass.c msg_parser_util.c \
@@ -46,11 +48,13 @@ libmsg_la_SOURCES = $(INTERNAL_H) \
 
 COVERAGE_INPUT =       $(libmsg_la_SOURCES) $(include_sofia_HEADERS)
 
-libtest_msg_a_SOURCES = test_class.c test_table.c test_protos.h
+libtest_msg_a_SOURCES = test_class.c test_class.h \
+                       test_table.c test_inlined.c test_protos.h
 
 LDADD =                libtest_msg.a libmsg.la \
                        ../bnf/libbnf.la \
                        ../url/liburl.la \
+                       ../ipt/libipt.la \
                        ../su/libsu.la 
 
 test_msg_LDFLAGS =     -static
@@ -77,41 +81,43 @@ TESTS =             test_msg
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 MSG_PARSER_AWK = $(srcdir)/msg_parser.awk
 
 AWK_MSG_AWK = $(AWK) -f $(MSG_PARSER_AWK)
 
-test_protos.h: test_protos.h.in $(MSG_PARSER_AWK)
-test_table.c: test_table.c.in $(MSG_PARSER_AWK)
+${GENERATED_HC}: ${MSG_PARSER_AWK}
 
-sofia-sip/msg_mime_protos.h: sofia-sip/msg_mime_protos.h.in
-sofia-sip/msg_protos.h: sofia-sip/msg_protos.h.in
-msg_mime_table.c: msg_mime_table.c.in $(MSG_PARSER_AWK)
+TEST_CLASS_H = ${srcdir}/test_class.h
 
-sofia-sip/msg_mime_protos.h sofia-sip/msg_protos.h: $(MSG_PARSER_AWK)
+test_protos.h test_table.c: ${TEST_CLASS_H}
 
-test_protos.h: test_class.h
+test_protos.h: ${srcdir}/test_protos.h.in
        $(AWK_MSG_AWK) module=msg_test NO_MIDDLE=1 NO_LAST=1 \
-               PR=$@ TEMPLATE=$(srcdir)/test_protos.h.in $<
+               PR=$@ TEMPLATE=$(srcdir)/$@.in ${TEST_CLASS_H}
 
-test_table.c: test_class.h 
+test_table.c: ${srcdir}/test_table.c.in
        $(AWK_MSG_AWK) module=msg_test prefix=msg \
                MC_HASH_SIZE=127 multipart=msg_multipart \
-               PT=$@ TEMPLATE=$(srcdir)/test_table.c.in $<
+               PT=$@ TEMPLATE=$(srcdir)/$@.in ${TEST_CLASS_H}
+
+SS_MIME_H = ${srcdir}/sofia-sip/msg_mime.h
+
+sofia-sip/msg_protos.h sofia-sip/msg_mime_protos.h: ${SS_MIME_H}
+msg_mime_table.c: ${SS_MIME_H}
 
-sofia-sip/msg_protos.h: sofia-sip/msg_mime.h
+sofia-sip/msg_protos.h: ${srcdir}/sofia-sip/msg_protos.h.in
        @-mkdir sofia-sip 2>/dev/null || true
        $(AWK_MSG_AWK) module=msg NO_FIRST=1 NO_MIDDLE=1 \
-               PR=$@ TEMPLATE=$(srcdir)/sofia-sip/msg_protos.h.in $<
+               PR=$@ TEMPLATE=$(srcdir)/$@.in ${SS_MIME_H}
 
-sofia-sip/msg_mime_protos.h: sofia-sip/msg_mime.h
+sofia-sip/msg_mime_protos.h: ${srcdir}/sofia-sip/msg_mime_protos.h.in
        @-mkdir sofia-sip 2>/dev/null || true
        $(AWK_MSG_AWK) module=msg NO_FIRST=1 NO_LAST=1 \
-               PR=$@ TEMPLATE=$(srcdir)/sofia-sip/msg_mime_protos.h.in $<
+               PR=$@ TEMPLATE=$(srcdir)/$@.in ${SS_MIME_H}
 
-msg_mime_table.c: sofia-sip/msg_mime.h
+msg_mime_table.c: ${srcdir}/msg_mime_table.c.in
        $(AWK_MSG_AWK) module=msg_multipart \
                tprefix=msg prefix=mp MC_HASH_SIZE=127 \
-               PT=$@ TEMPLATE=$(srcdir)/msg_mime_table.c.in $<
+               PT=$@ TEMPLATE=$(srcdir)/$@.in ${SS_MIME_H}
diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/msg_inlined.c b/libs/sofia-sip/libsofia-sip-ua/msg/msg_inlined.c
new file mode 100644 (file)
index 0000000..97cb95e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2007 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
+ *
+ */
+
+/**@CFILE msg_inlined.c
+ *
+ * Expand inlined msg functions non-inline.
+ *
+ */
+
+#include "config.h"
+
+#include <sofia-sip/su_config.h>
+
+#if SU_HAVE_INLINE
+extern int xyzzy;
+#else
+#undef SU_HAVE_INLINE
+#undef su_inline
+
+#define SU_HAVE_INLINE 1
+#define su_inline
+
+#include "sofia-sip/msg_header.h"
+#include "sofia-sip/msg_mime_protos.h"
+
+#endif
index 037b2c729d69448dfa9bb98d82353b0397d4913f..28a6b8a2c17e1e9964fe3b0384916aa1a998a40c 100644 (file)
@@ -54,11 +54,13 @@ BEGIN {
   split("", NAMES);
   split("", Comments);
   split("", COMMENTS);
+  split("", experimental);
 
   # indexed by the C name of the header
   split("", Since);            # Non-NUL if extra
   split("", Extra);            # Offset in extra headers
 
+  without_experimental = 0;
   template="";
   template1="";
   template2="";
@@ -78,13 +80,18 @@ function name_hash (name)
 {
   hash = 0;
 
-  len = split(name, chars, "");
+  len = length(name); 
 
   for (i = 1; i <= len; i++) {
-    c = tolower(chars[i]);
+    c = tolower(substr(name, i, 1));
     hash = (38501 * (hash + index(ascii, c))) % 65536;
   }
 
+  if (hash == 0) {
+    print "*** msg_parser.awk: calculating hash failed\n";
+    exit(5);
+  }
+
   if (0) {
     # Test that hash algorithm above agrees with the C version
     pipe = ("../msg/msg_name_hash " name);
@@ -155,11 +162,24 @@ function protos (name, comment, hash, since)
     Extra[name] = extra++;
   }
 
+  expr = (without_experimental > 0 && do_hash);
+  if (expr) {
+    printf "%s is experimental\n", Comment;
+  }    
+  
+  experimental[N] = expr;
+
   if (PR) {
+    if (expr) {
+      print "#if SU_HAVE_EXPERIMENTAL" > PR;
+    }
     replace(template, hash, name, NAME, comment, Comment, COMMENT, since);
     replace(template1, hash, name, NAME, comment, Comment, COMMENT, since);
     replace(template2, hash, name, NAME, comment, Comment, COMMENT, since);
     replace(template3, hash, name, NAME, comment, Comment, COMMENT, since);
+    if (expr) {
+      print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
+    }
   }
 }
 
@@ -210,8 +230,19 @@ function process_footer (text)
   for (i = 1; i <= n; i++) {
     l = lines[i];
     if (match(tolower(l), /#(xxxxxx(x_xxxxxxx)?|hash)#/)) {
+      expr = 0;
+
       for (j = 1; j <= N; j++) {
        l = lines[i];
+       if (expr != experimental[j]) {
+         expr = experimental[j];
+         if (expr) {
+           print "#if SU_HAVE_EXPERIMENTAL" > PR;
+         }
+         else {
+           print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
+         }
+       }
        gsub(/#hash#/, hashes[j], l);
        gsub(/#xxxxxxx_xxxxxxx#/, comments[j], l);
        gsub(/#Xxxxxxx_Xxxxxxx#/, Comments[j], l);
@@ -220,6 +251,10 @@ function process_footer (text)
        gsub(/#XXXXXX#/, NAMES[j], l);
        print l > PR;
       }
+
+      if (expr) {
+       print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
+      }
     } else {
       print l > PR;
     }
@@ -333,10 +368,11 @@ function templates ()
 }
 
 /^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); }
+HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ { 
+  without_experimental=total; }
 HLIST && /^[a-z]/ { protos($1, $0, 0, $2); headers[total++] = $1; }
 /^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0;  }
 
-
 /^ *\/\* === Headers start here \*\// { in_header_list=1;  templates(); }
 /^ *\/\* === Headers end here \*\// { in_header_list=0; }
 
@@ -366,10 +402,13 @@ in_header_list && /^  (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ {
 END {
   if (failed) { exit };
 
+  if (without_experimental == 0)
+    without_experimental = total;
+
   if (!NO_LAST) {
     protos("unknown", "/**< Unknown headers */", -3);
     protos("error", "/**< Erroneous headers */", -4);
-    protos("separator", "/**< Separator line between headers and payload */", -5);
+    protos("separator", "/**< Separator line between headers and body */", -5);
     protos("payload", "/**< Message payload */", -6);
     if (multipart)
       protos("multipart", "/**< Multipart payload */", -7);
@@ -397,6 +436,10 @@ END {
     gsub(/#DATE#/, "@date Generated: " date, header);
     print header > PT;
 
+    print "" > PT;
+    print "#define msg_offsetof(s, f) ((unsigned short)offsetof(s ,f))" > PT;
+    print "" > PT;
+
     if (MC_SHORT_SIZE) {
       printf("static msg_href_t const " \
             "%s_short_forms[MC_SHORT_SIZE] = \n{\n", 
@@ -408,7 +451,7 @@ END {
          n = shorts[i];
         flags = header_flags[n]; if (flags) flags = ",\n      " flags;
          
-         printf("  { /* %s */ %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n", 
+         printf("  { /* %s */ %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n", 
                 substr(lower_case, i, 1), 
                 tprefix, n, module, prefix, n, flags, c)       \
            > PT;
@@ -426,7 +469,16 @@ END {
     if (extra > 0) {
       printf("struct %s {\n", extra_struct) > PT;
       printf("  %s base;\n", module_struct) > PT;
-      printf("  msg_header_t *extra[%u];\n", extra) > PT;
+      if (total - without_experimental < extra) {
+       printf("  msg_header_t *extra[%u];\n", 
+              extra - (total - without_experimental)) > PT;
+      }
+      if (total - without_experimental > 0) {
+       print "#if SU_HAVE_EXPERIMENTAL" > PT;
+       printf("  msg_header_t *experimental[%u];\n", 
+              total - without_experimental) > PT;
+       print "#endif" > PT;
+      }
       printf("};\n\n") > PT;
       module_struct = "struct " extra_struct;
     }
@@ -450,11 +502,11 @@ END {
     len = split("request status separator payload unknown error", unnamed, " ");
 
     for (i = 1; i <= len; i++) {
-      printf("  {{ %s_%s_class, offsetof(%s_t, %s_%s) }},\n", 
+      printf("  {{ %s_%s_class, msg_offsetof(%s_t, %s_%s) }},\n", 
             tprefix, unnamed[i], module, prefix, unnamed[i]) > PT;
     }
     if (multipart) {
-      printf("  {{ %s_class, offsetof(%s_t, %s_multipart) }},\n",
+      printf("  {{ %s_class, msg_offsetof(%s_t, %s_multipart) }},\n",
             multipart, module, prefix) > PT;
     } else {
       printf("  {{ NULL, 0 }},\n") > PT;
@@ -465,7 +517,13 @@ END {
     else {
       printf("  NULL, \n") > PT;
     }
-    printf("  %d, %d, \n", MC_HASH_SIZE, total) > PT;
+    printf("  %d, \n", MC_HASH_SIZE) > PT;
+    printf ("#if SU_HAVE_EXPERIMENTAL\n" \
+           "  %d,\n" \
+           "#else\n" \
+           "  %d,\n" \
+           "#endif\n", \
+           total, without_experimental) > PT;
     printf("  {\n") > PT;
 
     for (i = 0; i < total; i++) {
@@ -484,6 +542,7 @@ END {
       }
 
       header_hash[j] = n;
+      experimental2[j] = (i >= without_experimental);
     }
 
     for (i = 0; i < MC_HASH_SIZE; i++) {
@@ -492,14 +551,23 @@ END {
        n = header_hash[i];
         flags = header_flags[n]; if (flags) flags = ",\n      " flags;
 
+       if (experimental2[i]) {
+         print "#if SU_HAVE_EXPERIMENTAL" > PT;
+       }
+
        if (Since[n]) {
-         printf("    { %s_%s_class, offsetof(struct %s, extra[%u])%s }%s\n", 
+         printf("    { %s_%s_class,\n" \
+                "      msg_offsetof(struct %s, extra[%u])%s }%s\n", 
                 tprefix, n, extra_struct, Extra[n], flags, c) > PT;
        }
        else {
-         printf("    { %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n", 
+         printf("    { %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n", 
                 tprefix, n, module, prefix, n, flags, c) > PT;
        }
+
+       if (experimental2[i]) {
+         printf("#else\n    { NULL, 0 }%s\n#endif\n", c) > PT;
+       }
       }
       else {
        printf("    { NULL, 0 }%s\n", c) > PT;
index eade159d6ea28fd0a6d6ff0b774aa6ec94bfc5e0..fe01a12eab38f38978acc24a009ae90922214dc7 100644 (file)
@@ -1974,6 +1974,8 @@ msg_t *msg_make(msg_mclass_t const *mc, int flags,
     return NULL;
 
   msg = msg_create(mc, flags);
+  if (msg == NULL)
+    return NULL;
 
   su_home_preload(msg_home(msg), 1, len + 1024);
 
index 670d36298700bd73d3f46d66bd88efb7c6d9ecbd..701a55ede5fe36034aa38a718d91da64743699ae 100644 (file)
@@ -56,7 +56,8 @@ SOFIA_BEGIN_DECLS
  * 1) Header class definitions.
  */
 
-#if HAVE_STRUCT_KEYWORDS
+/* Do not use keywords until you fix msg_kind_foo_critical thing! */ \
+#if HAVE_STRUCT_KEYWORDS && 0
 /** Define a header class */
 #define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd)  \
   {{                                                           \
@@ -74,6 +75,7 @@ SOFIA_BEGIN_DECLS
     hc_kind:   msg_kind_##kind,                                \
   }}
 #else
+/** Define a header class */
 #define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd)  \
   {{ \
      pr##c##_hash, \
@@ -198,9 +200,11 @@ SOFIAPUBFUN issize_t msg_parse_next_field(su_home_t *home, msg_header_t *prev,
 
 /** Duplicate string. @HI */
 #define MSG_STRING_DUP(p, d, s) \
-  (void)((s)?((p)=(char*)memccpy((void *)((d)=(char*)p),(s),0,SIZE_MAX))\
+  (void)((s)?((p)=(char*)memccpy((void *)((d)=(char*)p),(s),0,INT_MAX))\
            :((d)=NULL))
 
+/* Solaris has broken memccpy - it considers last argument as signed */
+
 /** Calculate string size. @HI */
 #define MSG_STRING_SIZE(s) ((s) ? (strlen(s) + 1) : 0)
 
diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/test_inlined.c b/libs/sofia-sip/libsofia-sip-ua/msg/test_inlined.c
new file mode 100644 (file)
index 0000000..76e012d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2007 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
+ *
+ */
+
+/**@CFILE test_inlined.c
+ *
+ * Expand inlined test functions non-inline.
+ *
+ */
+
+#include "config.h"
+
+#include <sofia-sip/su_config.h>
+
+#if SU_HAVE_INLINE
+extern int xyzzy;
+#else
+#undef SU_HAVE_INLINE
+#undef su_inline
+
+#define SU_HAVE_INLINE 1
+#define su_inline
+
+#include "test_protos.h"
+
+#endif
index 0ddf54a8faa275a592397f19ac9fb25224e0c915..0e936d4417afab1808980252a15779e91f7a1242 100644 (file)
@@ -59,11 +59,6 @@ static int test_flags = 0;
 
 char const name[] = "test_msg";
 
-void usage(void)
-{
-  fprintf(stderr, "usage: %s [-v]\n", name);
-}
-
 static int msg_time_test(void)
 {
   char buf[32];
@@ -138,7 +133,6 @@ static int msg_time_test(void)
   }
 
   END();
-  return 0;
 }
 
 static int addr_test(void)
@@ -1688,6 +1682,12 @@ static int random_test(void)
   END();
 }
 
+void usage(int exitcode)
+{
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
+}
+
 int main(int argc, char *argv[])
 {
   int retval = 0;
@@ -1696,8 +1696,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       test_flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      test_flags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= msg_time_test(); fflush(stdout);
index 0a3aa763eac77391b28bf5552da5a60fc2aa6792..5b27b9252efc461a71dd2cfe866b9d2f07ea206f 100644 (file)
@@ -59,4 +59,5 @@ EXTRA_DIST =          Doxyfile nea.docs $(BUILT_SOURCES)
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index 52a774d74e179456fec222a4a1ac309fe472f0e9..f4ec303f5b5051ae5a325b070e5960a2618fb75a 100644 (file)
@@ -496,14 +496,14 @@ nea_server_t *nea_server_create(nta_agent_t *agent,
        nes->nes_eventity_uri &&
        (nes->nes_leg || leg == NULL) &&
        nes->nes_timer) {
-      SU_DEBUG_5(("nea_server_create(%p): success\n", nes));
+      SU_DEBUG_5(("nea_server_create(%p): success\n", (void *)nes));
       su_timer_set(nes->nes_timer, nes_event_timer, nes);
 
       nes->nes_callback = callback;
       nes->nes_context = context;
     }
     else {
-      SU_DEBUG_5(("nea_server_create(%p): failed\n", nes));
+      SU_DEBUG_5(("nea_server_create(%p): failed\n", (void *)nes));
       nea_server_destroy(nes), nes = NULL;
     }
   }
@@ -551,11 +551,11 @@ int nea_server_shutdown(nea_server_t *nes,
     return 500;
 
   if (nes->nes_in_callback) {
-    SU_DEBUG_5(("nea_server_shutdown(%p) while in callback\n", nes));
+    SU_DEBUG_5(("nea_server_shutdown(%p) while in callback\n", (void *)nes));
     return 100;
   }
   
-  SU_DEBUG_5(("nea_server_shutdown(%p)\n", nes));
+  SU_DEBUG_5(("nea_server_shutdown(%p)\n", (void *)nes));
 
   in_callback = nes->nes_in_callback; nes->nes_in_callback = 1;
 
@@ -585,12 +585,12 @@ void nea_server_destroy(nea_server_t *nes)
     return;
 
   if (nes->nes_in_callback) {
-    SU_DEBUG_5(("nea_server_destroy(%p) while in callback\n", nes));
+    SU_DEBUG_5(("nea_server_destroy(%p) while in callback\n", (void *)nes));
     nes->nes_pending_destroy = 1;
     return;
   }
   
-  SU_DEBUG_5(("nea_server_destroy(%p)\n", nes));
+  SU_DEBUG_5(("nea_server_destroy(%p)\n", (void *)nes));
   
   nta_leg_destroy(nes->nes_leg), nes->nes_leg = NULL;
   
@@ -837,8 +837,8 @@ int nea_view_update(nea_server_t *nes,
   if (evq->evq_content_type)
     nea_view_queue(nes, evv, evq);
 
-  SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", 
-             nes, ev->ev_event->o_type, evv->evv_content_type->c_type));
+  SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", (void *)nes,
+             ev->ev_event->o_type, evv->evv_content_type->c_type));
 
   return 1;
 }
@@ -1019,7 +1019,8 @@ int nea_server_notify(nea_server_t *nes, nea_event_t *ev)
   nea_sub_t *s;
   int notified = 0, throttled = nes->nes_throttled;
 
-  SU_DEBUG_7(("nea_server_notify(%p): %s\n", nes, ev ? ev->ev_event->o_type: ""));
+  SU_DEBUG_7(("nea_server_notify(%p): %s\n", (void *)nes,
+             ev ? ev->ev_event->o_type: ""));
 
   ++nes->nes_in_list;
 
index 4b9459db2a027426f5d0c7fb460fc72f0f263b24..ac86e31c6bd742dfab409f0ad04aad725e0ad43f 100644 (file)
@@ -73,7 +73,7 @@ EXTRA_DIST =          Doxyfile nta.docs sl_utils.docs \
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 # Generate list of nta tags
 TAG_DLL_FLAGS =        LIST=nta_tag_list
\ No newline at end of file
index de88d85322da06307c9a8a8962362be5314b3e2c..b759787bb1e72bcf3f4bdb02132a2608b431b0fa 100644 (file)
@@ -29,7 +29,7 @@
  * 1) agent
  * 2) tport handling
  * 3) dispatching messages received from network
- * 4) message creation, message utility
+ * 4) message creation and message utility functions
  * 5) stateless operation
  * 6) dialogs (legs)
  * 7) server transactions (incoming)
@@ -145,7 +145,7 @@ static msg_t *nta_msg_create_for_transport(nta_agent_t *agent, int flags,
 
 static int complete_response(msg_t *response, 
                             int status, char const *phrase, 
-                            msg_t const *request);
+                            msg_t *request);
 
 #define IF_SIGCOMP_TPTAG_COMPARTMENT(cc)     TAG_IF(cc, TPTAG_COMPARTMENT(cc)),
 #define IF_SIGCOMP_TPTAG_COMPARTMENT_REF(cc) TPTAG_COMPARTMENT_REF(cc),
@@ -225,7 +225,7 @@ static inline int incoming_cancel(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
 static inline int incoming_merge(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
                                 tport_t *tport);
 static inline int incoming_timestamp(nta_incoming_t *, msg_t *, sip_t *);
-static inline int incoming_timer(nta_agent_t *, su_duration_t);
+static inline su_duration_t incoming_timer(nta_agent_t *, su_duration_t);
 
 static nta_reliable_t *reliable_mreply(nta_incoming_t *,
                                       nta_prack_f *, nta_reliable_magic_t *,
@@ -259,7 +259,7 @@ static nta_outgoing_t *outgoing_find(nta_agent_t const *sa,
                                     sip_via_t const *v);
 static int outgoing_recv(nta_outgoing_t *orq, int status, msg_t *, sip_t *);
 static void outgoing_default_recv(nta_outgoing_t *, int, msg_t *, sip_t *);
-static inline int outgoing_timer(nta_agent_t *, su_duration_t);
+static inline su_duration_t outgoing_timer(nta_agent_t *, su_duration_t);
 static int outgoing_recv_reliable(nta_outgoing_t *orq, msg_t *msg, sip_t *sip);
 
 /* Internal message passing */
@@ -311,7 +311,7 @@ su_log_t nta_log[] = { SU_LOG_INIT("nta", "NTA_DEBUG", SU_DEBUG) };
 /**
  * Create an NTA agent object.
  *
- * The function nta_agent_create() creates an NTA agent object.  The agent
+ * Create an NTA agent object.  The agent
  * object creates and binds a server socket with address specified in @e url.
  * If the @e host portion of the @e url is @c "*", the agent listens to all
  * addresses available on the host.
@@ -327,6 +327,8 @@ su_log_t nta_log[] = { SU_LOG_INIT("nta", "NTA_DEBUG", SU_DEBUG) };
  * @note
  * If @e url is @c NULL, the default @e url @c "sip:*" is used.
  * @par
+ * If @e url is @c NONE (iow, (void*)-1), no server sockets are bound.
+ * @par
  * If @p transport parameters are specified in @a url, agent uses only
  * specified transport type.
  *
@@ -369,8 +371,10 @@ nta_agent_t *nta_agent_create(su_root_t *root,
     agent->sa_flags = MSG_DO_CANONIC;
 
     agent->sa_maxsize         = 2 * 1024 * 1024; /* 2 MB */
-    agent->sa_bad_req_mask    = (unsigned)(~(sip_mask_response | sip_mask_proxy));
-    agent->sa_bad_resp_mask   = (unsigned)(~(sip_mask_request | sip_mask_proxy));
+    agent->sa_bad_req_mask    = 
+      (unsigned) ~(sip_mask_response | sip_mask_proxy);
+    agent->sa_bad_resp_mask   = 
+      (unsigned) ~(sip_mask_request | sip_mask_proxy);
     agent->sa_t1             = NTA_SIP_T1;
     agent->sa_t2             = NTA_SIP_T2;
     agent->sa_t4              = NTA_SIP_T4;
@@ -563,14 +567,10 @@ nta_agent_magic_t *nta_agent_magic(nta_agent_t const *agent)
 
 /** Return @Contact header.
  *
- * The function nta_agent_contact() returns a @Contact header, which can be
- * used to reach @a agent.
+ * Get a @Contact header, which can be used to reach @a agent.
  *
  * @param agent NTA agent object
  *
- * @return The function nta_agent_contact() returns a sip_contact_t object
- * corresponding to the @a agent.
- *
  * User agents can insert the @Contact header in the outgoing REGISTER,
  * INVITE, and ACK requests and replies to incoming INVITE and OPTIONS
  * transactions.
@@ -582,6 +582,8 @@ nta_agent_magic_t *nta_agent_magic(nta_agent_t const *agent)
  *                              sip->sip_request->rq_url,
  *                              contact->m_url);
  * @endcode
+ *
+ * @return A sip_contact_t object corresponding to the @a agent.
  */
 sip_contact_t *nta_agent_contact(nta_agent_t const *agent)
 {
@@ -590,44 +592,68 @@ sip_contact_t *nta_agent_contact(nta_agent_t const *agent)
 
 /** Return a list of @Via headers.
  *
- * The function nta_agent_via() returns @Via headers for all activated
- * transport.
+ * Get @Via headers for all activated transport.
  *
  * @param agent NTA agent object
  *
- * @return The function nta_agent_via() returns a list of sip_via_t objects
- * used by the @a agent.
+ * @return A list of #sip_via_t objects used by the @a agent.
  */
 sip_via_t *nta_agent_via(nta_agent_t const *agent)
 {
   return agent ? agent->sa_vias : NULL;
 }
 
-
 /** Return a list of public (UPnP, STUN) @Via headers.
  *
- * The function nta_agent_public_via() returns public @Via headers for all activated
- * transports.
+ * Get public @Via headers for all activated transports.
  *
  * @param agent NTA agent object
  *
- * @return The function nta_agent_public_via() returns a list of sip_via_t objects
- * used by the @a agent.
+ * @return A list of #sip_via_t objects used by the @a agent.
  */
 sip_via_t *nta_agent_public_via(nta_agent_t const *agent)
 {
   return agent ? agent->sa_public_vias : NULL;
 }
 
+/** Match a @Via header @a v with @Via headers in @a agent.
+ *
+ */
+static
+sip_via_t *agent_has_via(nta_agent_t const *agent, sip_via_t const *via)
+{
+  sip_via_t const *v;
+
+  for (v = agent->sa_public_vias; v; v = v->v_next) {
+    if (strcasecmp(via->v_host, v->v_host))
+      continue;
+    if (str0cmp(via->v_port, v->v_port))
+      continue;
+    if (strcasecmp(via->v_protocol, v->v_protocol))
+      continue;
+    return (sip_via_t *)v;
+  }
+
+  for (v = agent->sa_vias; v; v = v->v_next) {
+    if (strcasecmp(via->v_host, v->v_host))
+      continue;
+    if (str0cmp(via->v_port, v->v_port))
+      continue;
+    if (strcasecmp(via->v_protocol, v->v_protocol))
+      continue;
+    return (sip_via_t *)v;
+  }
+
+  return NULL;
+}
+
 /** Return @UserAgent header.
  *
- * The function nta_agent_name() returns a @UserAgent information with
- * NTA version.
+ * Get @UserAgent information with NTA version.
  *
  * @param agent NTA agent object (may be NULL)
  *
- * @return The function nta_agent_contact() returns a string containing the
- * @a agent version.
+ * @return A string containing the @a agent version.
  */
 char const *nta_agent_version(nta_agent_t const *agent)
 {
@@ -667,53 +693,108 @@ static int agent_tag_init(nta_agent_t *self)
 static
 int agent_timer_init(nta_agent_t *agent)
 {
-  return su_timer_set(agent->sa_timer =
-                     su_timer_create(su_root_task(agent->sa_root),
-                                     NTA_SIP_T1 / 8),
+  agent->sa_timer = su_timer_create(su_root_task(agent->sa_root),
+                                   NTA_SIP_T1 / 8);
+#if 0
+  return su_timer_set(agent->sa_timer,
                      agent_timer,
                      agent);
+#endif
+  return -(agent->sa_timer == NULL);
 }
 
+#define NEXT_TIMEOUT(next, p, f, now) \
+  (p && p->f - (next) < 0 ? (p->f - (now) > 0 ? p->f : (now)) : (next))
+
 /**
  * Agent timer routine.
  */
 static
 void agent_timer(su_root_magic_t *rm, su_timer_t *timer, nta_agent_t *agent)
 {
-  su_duration_t now = su_time_ms(agent->sa_now = su_now());
-  int again;
+  su_time_t stamp = su_now();
+  su_duration_t now = su_time_ms(stamp), next;
 
   now += now == 0;
 
+  agent->sa_now = stamp;
   agent->sa_millisec = now;
+  agent->sa_next = 0;
+  agent->sa_in_timer = 1;
 
-  again = outgoing_timer(agent, now);
-  again = incoming_timer(agent, now) || again;
+  next = now + SU_DURATION_MAX;
+  next = outgoing_timer(agent, next);
+  next = incoming_timer(agent, next);
 
   agent->sa_millisec = 0;
+  agent->sa_in_timer = 0;
+
+  if (agent->sa_next)
+    next = NEXT_TIMEOUT(next, agent, sa_next, now);
+
+  if (next == now + SU_DURATION_MAX) {
+    /* Do not set timer */
+    SU_DEBUG_9(("nta: timer not set\n"));
+    assert(!agent->sa_out.completed->q_head);
+    assert(!agent->sa_out.trying->q_head);
+    assert(!agent->sa_out.inv_calling->q_head);
+    assert(!agent->sa_out.re_list);
+    assert(!agent->sa_in.inv_confirmed->q_head);
+    assert(!agent->sa_in.preliminary->q_head);
+    assert(!agent->sa_in.completed->q_head);
+    assert(!agent->sa_in.inv_completed->q_head);
+    assert(!agent->sa_in.re_list);
+    return;
+  }
 
-  if (again)
-    su_timer_set_at(timer, agent_timer, agent, su_time_add(su_now(), 1));
-  else
-    su_timer_set(timer, agent_timer, agent);
+  if (next == now) if (++next == 0) ++next;
+
+  SU_DEBUG_9(("nta: timer %s to %ld ms\n", "set next", (long)(next - now)));
+
+  agent->sa_next = next;
+
+  su_timer_set_at(timer, agent_timer, agent, su_time_add(stamp, next - now));
 }
 
-/** Calculate nonzero value for timer */
-static inline
-su_duration_t set_timeout(nta_agent_t const *agent, su_duration_t offset)
+/** Calculate nonzero value for timeout.
+ *
+ * Sets or adjusts agent timer when needed.
+ *
+ * @retval 0 if offset is 0
+ * @retval timeout (millisecond counter) otherwise
+ */
+static
+su_duration_t set_timeout(nta_agent_t *agent, su_duration_t offset)
 {
-  su_duration_t now;
+  su_time_t now;
+  su_duration_t next, ms;
 
-#if 0
-  if (agent->sa_millisec)
-    now = agent->sa_millisec;
+  if (offset == 0)
+    return 0;
+
+  if (agent->sa_millisec) /* Avoid expensive call to su_timer_ms() */
+    now = agent->sa_now, ms = agent->sa_millisec;
   else
-#endif
-    now = (su_duration_t)su_time_ms(su_now());
+    now = su_now(), ms = (su_duration_t)su_time_ms(now);
+  
+  next = ms + offset; if (next == 0) next = 1;
+
+  if (agent->sa_in_timer)
+    return next;
 
-  now += offset;
+  if (agent->sa_next == 0 || agent->sa_next - next - 5L > 0) {
+    /* Set timer */
+    if (agent->sa_next)
+      SU_DEBUG_9(("nta: timer %s to %ld ms\n", "shortened", (long)offset));
+    else
+      SU_DEBUG_9(("nta: timer %s to %ld ms\n", "set", (long)offset));
+      
+    su_timer_set_at(agent->sa_timer, agent_timer, agent, 
+                   su_time_add(now, offset));
+    agent->sa_next = next;
+  }
 
-  return now ? now : 1;
+  return next;
 }
 
 
@@ -721,7 +802,10 @@ su_duration_t set_timeout(nta_agent_t const *agent, su_duration_t offset)
 static
 su_time_t agent_now(nta_agent_t const *agent)
 {
-  return agent->sa_millisec ? agent->sa_now : su_now();
+  if (agent && agent->sa_millisec != 0)
+    return agent->sa_now;
+  else 
+    return su_now();
 }
 
 
@@ -833,7 +917,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
   unsigned threadpool      = agent->sa_tport_threadpool;
   char const *sigcomp = agent->sa_sigcomp_options;
   char const *algorithm = NONE;
-  msg_mclass_t *mclass = NONE;
+  msg_mclass_t const *mclass = NONE;
   sip_contact_t const *aliases = NONE;
   url_string_t const *proxy = NONE;
   tport_t *tport;
@@ -929,7 +1013,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
     agent->sa_algorithm = su_strdup(home, algorithm);
 
   if (str0cmp(sigcomp, agent->sa_sigcomp_options)) {
-    char const * const *l = NULL;
+    msg_param_t const *l = NULL;
     char *s = su_strdup(home, sigcomp);
     char *s1 = su_strdup(home, s), *s2 = s1;
 
@@ -1338,7 +1422,7 @@ static tport_stack_class_t nta_agent_class[1] =
 
 /** Add a transport to the agent.
  *
- * The function nta_agent_add_tport() creates a new transport and binds it
+ * Creates a new transport and binds it
  * to the port specified by the @a uri. The @a uri must have sip: or sips:
  * scheme or be a wildcard uri ("*"). The @a uri syntax allowed is as
  * follows:
@@ -1475,7 +1559,7 @@ int nta_agent_add_tport(nta_agent_t *self,
        (nta_compressor_vtable == NULL || 
         strcasecmp(tpn->tpn_comp, nta_compressor_vtable->ncv_name) != 0)) {
       SU_DEBUG_1(("nta(%p): comp=%s not supported for " URL_PRINT_FORMAT "\n",
-                 self, tpn->tpn_comp, URL_PRINT_ARGS(url)));
+                 (void *)self, tpn->tpn_comp, URL_PRINT_ARGS(url)));
     }
   }
 
@@ -1739,10 +1823,20 @@ int agent_init_contact(nta_agent_t *self)
   if (self->sa_contact)
     return 0;
 
-  if (self->sa_vias)
-    v1 = self->sa_vias;
-  else
-    v1 = self->sa_public_vias;
+  for (v1 = self->sa_vias ? self->sa_vias : self->sa_public_vias;
+       v1;
+       v1 = v1->v_next) {
+    if (host_is_ip_address(v1->v_host)) {
+      if (!host_is_local(v1->v_host))
+       break;
+    }
+    else if (!host_has_domain_invalid(v1->v_host)) {
+      break;
+    }
+  }
+
+  if (v1 == NULL)
+    v1 = self->sa_vias ? self->sa_vias : self->sa_public_vias;
 
   if (!v1)
     return -1;
@@ -1960,7 +2054,8 @@ static void agent_update_tport(nta_agent_t *self, tport_t *tport)
   }
   else {
     /* XXX - we should do something else? */
-    SU_DEBUG_3(("nta(%p): transport address updated\n", self));
+    SU_DEBUG_3(("%s(%p): %s\n", "nta", (void *)self, 
+               "transport address updated"));
   }
 }
 
@@ -2474,7 +2569,10 @@ void agent_recv_response(nta_agent_t *agent,
 
   if (sip->sip_cseq->cs_method == sip_method_invite
       && 200 <= sip->sip_status->st_status
-      && sip->sip_status->st_status < 300) {
+      && sip->sip_status->st_status < 300
+      /* Exactly one Via header, belonging to us */
+      && sip->sip_via && !sip->sip_via->v_next 
+      && agent_has_via(agent, sip->sip_via)) {
     agent->sa_stats->as_trless_200++;
     /* Orphan 200 Ok to INVITE. ACK and BYE it */
     SU_DEBUG_5(("nta: %03d %s must be ACK&BYE\n", status, phrase));
@@ -2485,6 +2583,7 @@ void agent_recv_response(nta_agent_t *agent,
   SU_DEBUG_5(("nta: %03d %s was discarded\n", status, phrase));
   msg_destroy(msg);
 }
+
 /** @internal Agent receives garbage */
 static
 void agent_recv_garbage(nta_agent_t *agent,
@@ -2800,7 +2899,7 @@ int nta_msg_mreply(nta_agent_t *agent,
 static
 int complete_response(msg_t *response, 
                      int status, char const *phrase, 
-                     msg_t const *request)
+                     msg_t *request)
 {
   su_home_t *home = msg_home(response);
   sip_t *response_sip = sip_object(response);
@@ -2951,11 +3050,11 @@ int nta_msg_ackbye(nta_agent_t *agent, msg_t *msg)
 
 /**Complete a request with values from dialog.
  *
- * The function nta_msg_request_complete() completes a request message @a
- * msg belonging to a dialog associated with @a leg. It increments the local
- * @CSeq value, adds @CallID, @To, @From and @Route headers (if
- * there is such headers present in @a leg), and creates a new request line
- * object from @a method, @a method_name and @a request_uri.
+ * Complete a request message @a msg belonging to a dialog associated with
+ * @a leg. It increments the local @CSeq value, adds @CallID, @To, @From and
+ * @Route headers (if there is such headers present in @a leg), and creates
+ * a new request line object from @a method, @a method_name and @a
+ * request_uri.
  *
  * @param msg          pointer to a request message object
  * @param leg          pointer to a #nta_leg_t object
@@ -3106,7 +3205,7 @@ int nta_msg_request_complete(msg_t *msg,
   method = sip->sip_request->rq_method;
   method_name = sip->sip_request->rq_method_name;
 
-  if (!leg->leg_id && !sip->sip_call_id && sip->sip_cseq)
+  if (!leg->leg_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 */
@@ -3179,9 +3278,9 @@ hash_value_t hash_istring(char const *, char const *, hash_value_t);
 /**
  * Create a new leg object.
  *
- * The function nta_leg_tcreate() creates a leg object. A leg object is used
- * to represent dialogs, partial dialogs (for example, in case of REGISTER),
- * and destinations within a particular NTA object.
+ * Creates a leg object, which is used to represent dialogs, partial dialogs
+ * (for example, in case of REGISTER), and destinations within a particular
+ * NTA object.
  *
  * When a leg is created, a callback pointer and a application context is
  * provided. All other parameters are optional.
@@ -3421,7 +3520,7 @@ nta_leg_t *nta_leg_tcreate(nta_agent_t *agent,
 
   leg_insert(agent, leg);
 
-  SU_DEBUG_9(("nta_leg_create(%p)\n", leg));
+  SU_DEBUG_9(("nta_leg_create(%p)\n", (void *)leg));
 
   return leg;
 
@@ -3471,7 +3570,7 @@ void leg_insert(nta_agent_t *sa, nta_leg_t *leg)
  */
 void nta_leg_destroy(nta_leg_t *leg)
 {
-  SU_DEBUG_9(("nta_leg_destroy(%p)\n", leg));
+  SU_DEBUG_9(("nta_leg_destroy(%p)\n", (void *)leg));
 
   if (leg) {
     leg_htable_t *leg_hash;
@@ -3518,8 +3617,8 @@ nta_leg_magic_t *nta_leg_magic(nta_leg_t const *leg,
 
 /**Bind a callback function and context to a leg object.
  *
- * The function nta_leg_bind() is used to change the callback
- * and context pointer attached to a leg object.
+ * Change the callback function and context pointer attached to a leg
+ * object.
  *
  * @param leg      leg object to be bound
  * @param callback new callback function (or NULL if no callback is desired)
@@ -3566,6 +3665,7 @@ char const *nta_leg_tag(nta_leg_t *leg, char const *tag)
   if (tag) {
     if (sip_to_tag(leg->leg_home, leg->leg_local, tag) < 0)
       return NULL;
+    leg->leg_tagged = 1;
     return leg->leg_local->a_tag;
   }
 
@@ -3574,6 +3674,8 @@ char const *nta_leg_tag(nta_leg_t *leg, char const *tag)
   if (!tag || sip_to_add_param(leg->leg_home, leg->leg_local, tag) < 0)
     return NULL;
 
+  leg->leg_tagged = 1;
+
   return leg->leg_local->a_tag;
 }
 
@@ -3757,7 +3859,7 @@ void leg_recv(nta_leg_t *leg, msg_t *msg, sip_t *sip, tport_t *tport)
 
   if (!(irq = incoming_create(agent, msg, sip, tport, tag))) {
     SU_DEBUG_3(("nta: leg_recv(%p): cannot create transaction for %s\n",
-               leg, method_name));
+               (void *)leg, method_name));
     nta_msg_treply(agent, msg,
                   SIP_500_INTERNAL_SERVER_ERROR,
                   NTATAG_TPORT(tport),
@@ -3783,12 +3885,12 @@ void leg_recv(nta_leg_t *leg, msg_t *msg, sip_t *sip, tport_t *tport)
 
   if (status < 100 || status > 699) {
     SU_DEBUG_3(("nta_leg(%p): invalid status %03d from callback\n",
-               leg, status));
+               (void *)leg, status));
     status = 500;
   }
   else if (method == sip_method_invite && status >= 200 && status < 300) {
     SU_DEBUG_3(("nta_leg(%p): invalid INVITE status %03d from callback\n",
-               leg, status));
+               (void *)leg, status));
     status = 500;
   }
 
@@ -3818,8 +3920,8 @@ int addr_cmp(url_t const *a, url_t const *b)
 
 /** Get a leg by dialog.
  *
- * The function nta_leg_by_dialog() searches for a dialog leg from agent's
- * hash table. The matching rules based on parameters  are as follows:
+ * Search for a dialog leg from agent's hash table. The matching rules based
+ * on parameters are as follows:
  *
  * @param agent        pointer to agent object
  * @param request_uri  if non-NULL, and there is destination URI
@@ -3922,6 +4024,14 @@ nta_leg_t *leg_find(nta_agent_t const *sa,
     /* Do not match if the incoming To has tag, but the local does not */
     if (!local_tag && to_tag)
       continue;
+
+    /*
+     * Do not match if incoming To has no tag and we have local tag
+     * and the tag has been there from the beginning.
+     */
+    if (local_tag && !to_tag && !leg->leg_tagged)
+      continue;
+
     /* Do not match if incoming From has no tag but remote has a tag */
     if (remote_tag && !from_tag)
       continue;
@@ -4034,8 +4144,8 @@ nta_leg_t *dst_find(nta_agent_t const *sa,
 
 /** Set leg route and target URL.
  *
- * The function leg_route() sets the leg route and contact using the
- * @RecordRoute and @Contact headers.
+ * Sets the leg route and contact using the @RecordRoute and @Contact
+ * headers.
  */
 static
 int leg_route(nta_leg_t *leg,
@@ -4153,7 +4263,7 @@ static inline void incoming_queue(incoming_queue_t *queue, nta_incoming_t *);
 static inline void incoming_remove(nta_incoming_t *irq);
 static inline void incoming_set_timer(nta_incoming_t *, unsigned interval);
 static inline void incoming_reset_timer(nta_incoming_t *);
-static inline size_t incoming_mass_destroy(nta_agent_t *sa, incoming_queue_t *q);
+static inline size_t incoming_mass_destroy(nta_agent_t *, incoming_queue_t *);
 
 static int incoming_set_params(nta_incoming_t *irq, tagi_t const *tags);
 static inline
@@ -4208,9 +4318,9 @@ nta_incoming_t *nta_incoming_default(nta_agent_t *agent)
 
 /** Create a server transaction. 
  *
- * The function nta_incoming_create() creates a server transaction for a
- * request message. This function is used when an element processing
- * requests statelessly wants to process a particular request statefully.
+ * Create a server transaction for a request message. This function is used
+ * when an element processing requests statelessly wants to process a
+ * particular request statefully.
  *
  * @param agent pointer to agent object
  * @param leg  pointer to leg object (either @a agent or @a leg may be NULL)
@@ -4436,7 +4546,7 @@ int incoming_callback(nta_leg_t *leg, nta_incoming_t *irq, sip_t *sip)
 
     if (leg->leg_rseq > sip->sip_cseq->cs_seq) {
       SU_DEBUG_3(("nta_leg(%p): out-of-order %s (%u < %u)\n",
-                 leg, method_name, seq, leg->leg_rseq));
+                 (void *)leg, method_name, seq, leg->leg_rseq));
       return 500;
     }
 
@@ -4514,8 +4624,8 @@ int incoming_is_queued(nta_incoming_t const *irq)
 /** @internal
  * Insert an incoming transaction into a queue. 
  *
- * The function incoming_queue() inserts a server transaction into a queue,
- * and sets the corresponding timeout at the same time.
+ * Insert a server transaction into a queue, and sets the corresponding
+ * timeout at the same time.
  */
 static inline
 void incoming_queue(incoming_queue_t *queue, 
@@ -4531,10 +4641,7 @@ void incoming_queue(incoming_queue_t *queue,
 
   assert(*queue->q_tail == NULL);
 
-  if (queue->q_timeout)
-    irq->irq_timeout = set_timeout(irq->irq_agent, queue->q_timeout);
-  else
-    irq->irq_timeout = 0;
+  irq->irq_timeout = set_timeout(irq->irq_agent, queue->q_timeout);
 
   irq->irq_queue = queue;
   irq->irq_prev = queue->q_tail; 
@@ -4626,7 +4733,7 @@ void incoming_reset_timer(nta_incoming_t *irq)
 static
 void incoming_free(nta_incoming_t *irq)
 {
-  SU_DEBUG_9(("nta: incoming_free(%p)\n", irq));
+  SU_DEBUG_9(("nta: incoming_free(%p)\n", (void *)irq));
 
   incoming_cut_off(irq);
   incoming_reclaim(irq);
@@ -4706,7 +4813,8 @@ void incoming_reclaim_queued(su_root_magic_t *rm,
   incoming_queue_t *q = u->a_incoming_queue;
   nta_incoming_t *irq, *irq_next;
 
-  SU_DEBUG_9(("incoming_reclaim_all(%p, %p, %p)\n", rm, msg, u));
+  SU_DEBUG_9(("incoming_reclaim_all(%p, %p, %p)\n",
+             (void *)rm, (void *)msg, (void *)u));
 
   for (irq = q->q_head; irq; irq = irq_next) {
     irq_next = irq->irq_next;
@@ -4716,10 +4824,10 @@ void incoming_reclaim_queued(su_root_magic_t *rm,
 
 /**Bind a callback and context to an incoming transaction object
  *
- * The function nta_incoming_bind() is used to set the callback and
- * context pointer attached to an incoming request object.  The callback
- * function will be invoked if the incoming request is cancelled, or if the
- * final response to an incoming @b INVITE request has been acknowledged.
+ * Set the callback function and context pointer attached to an incoming
+ * request object. The callback function will be invoked if the incoming
+ * request is cancelled, or if the final response to an incoming @b INVITE
+ * request has been acknowledged.
  *
  * If the callback is NULL, or no callback has been bound, NTA invokes the
  * request callback of the call leg.
@@ -4916,15 +5024,16 @@ static inline
 nta_incoming_t *incoming_find(nta_agent_t const *agent,
                              sip_t const *sip,
                              sip_via_t const *v,
-                             nta_incoming_t **merge,
-                             nta_incoming_t **ack)
+                             nta_incoming_t **return_merge,
+                             nta_incoming_t **return_ack)
 {
   sip_cseq_t const *cseq = sip->sip_cseq;
   sip_call_id_t const *i = sip->sip_call_id;
   sip_to_t const *to = sip->sip_to;
   sip_from_t const *from = sip->sip_from;
   sip_request_t *rq = sip->sip_request;
-  int is_uas_ack = ack && agent->sa_is_a_uas && rq->rq_method == sip_method_ack;
+  int is_uas_ack = return_ack && 
+    agent->sa_is_a_uas && rq->rq_method == sip_method_ack;
   incoming_htable_t const *iht = agent->sa_incoming;
   hash_value_t hash = NTA_HASH(i, cseq->cs_seq);
 
@@ -4941,6 +5050,30 @@ nta_incoming_t *incoming_find(nta_agent_t const *agent,
       continue;
     if (str0casecmp(irq->irq_from->a_tag, from->a_tag))
       continue;
+
+    if (str0casecmp(irq->irq_via->v_branch, v->v_branch) != 0 ||
+       strcasecmp(irq->irq_via->v_host, v->v_host) != 0) {
+      if (!agent->sa_is_a_uas)
+       continue;
+      
+      if (is_uas_ack &&
+         irq->irq_method == sip_method_invite && 
+         200 <= irq->irq_status && irq->irq_status < 300 &&
+         addr_match(irq->irq_to, to))
+       *return_ack = irq;
+      /* RFC3261 - section 8.2.2.2 Merged Requests */
+      else if (return_merge && agent->sa_merge_482 &&
+              irq->irq_cseq->cs_method == cseq->cs_method &&
+              (irq->irq_cseq->cs_method != sip_method_unknown ||
+               strcmp(irq->irq_cseq->cs_method_name, 
+                      cseq->cs_method_name) == 0)) {
+       *return_merge = irq;
+       continue;
+      }
+      else
+       continue;
+    }
+
     if (is_uas_ack) {
       if (!addr_match(irq->irq_to, to))
        continue;
@@ -4953,16 +5086,6 @@ nta_incoming_t *incoming_find(nta_agent_t const *agent,
     else if (str0casecmp(irq->irq_to->a_tag, to->a_tag))
       continue;
 
-    if (str0casecmp(irq->irq_via->v_branch, v->v_branch) != 0) {
-      if (!agent->sa_is_a_uas)
-       continue;
-      if (is_uas_ack && irq->irq_status >= 200 && irq->irq_status < 300)
-       *ack = irq;
-      /* RFC3261 - section 8.2.2.2 Merged Requests */
-      else if (merge && !to->a_tag && agent->sa_merge_482)
-       *merge = irq;
-      continue;
-    }
     if (!is_uas_ack && url_cmp(irq->irq_rq->rq_url, rq->rq_url))
       continue;
 
@@ -4974,18 +5097,24 @@ nta_incoming_t *incoming_find(nta_agent_t const *agent,
     if (irq->irq_method == rq->rq_method)
       break;           /* found */
 
-    if (ack && rq->rq_method == sip_method_cancel)
-      *ack = irq;
-    else if (ack && rq->rq_method == sip_method_ack && 
-            irq->irq_method == sip_method_invite)
-      *ack = irq;
+    if (!return_ack)
+      continue;
+
+    if (irq->irq_method == sip_method_invite) {
+      if (rq->rq_method == sip_method_cancel)
+       *return_ack = irq;
+      else if (rq->rq_method == sip_method_ack)
+       *return_ack = irq;
+    }
+    else if (rq->rq_method == sip_method_cancel && !irq->irq_terminated)
+      *return_ack = irq;
   }
 
   if (irq)
     return irq;
 
   /* Check PRACKed requests */
-  if (ack && rq->rq_method == sip_method_prack && sip->sip_rack) {
+  if (return_ack && rq->rq_method == sip_method_prack && sip->sip_rack) {
     sip_rack_t const *rack = sip->sip_rack;
     hash = NTA_HASH(i, rack->ra_cseq);
 
@@ -5005,7 +5134,7 @@ nta_incoming_t *incoming_find(nta_agent_t const *agent,
        continue;
       if (!irq->irq_from->a_tag != !from->a_tag)
        continue;
-      *ack = irq;
+      *return_ack = irq;
 
       return NULL;
     }
@@ -5097,10 +5226,18 @@ int incoming_cancel(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
   nta_agent_t *agent = irq->irq_agent;
 
   /* Respond to the CANCEL */
-  nta_msg_treply(agent, msg_ref_create(msg), SIP_200_OK, 
-                NTATAG_TPORT(tport),
-                TAG_END());
 
+  if (200 <= irq->irq_status && irq->irq_status < 300) {
+    nta_msg_treply(agent, msg_ref_create(msg), SIP_481_NO_TRANSACTION, 
+                  NTATAG_TPORT(tport),
+                  TAG_END());
+  }
+  else
+    nta_msg_treply(agent, msg_ref_create(msg), SIP_200_OK, 
+                  NTATAG_TPORT(tport),
+                  TAG_END());
+
+  /* We have already sent final response */
   if (irq->irq_completed || irq->irq_method != sip_method_invite) {
     msg_destroy(msg);
     return 0;
@@ -5276,6 +5413,34 @@ int incoming_set_compartment(nta_incoming_t *irq, tport_t *tport, msg_t *msg,
   return 0;
 }
 
+/** Add essential headers to the response message */
+static int nta_incoming_response_headers(nta_incoming_t *irq, 
+                                        msg_t *msg,
+                                        sip_t *sip)
+{
+  int clone = 0;
+  su_home_t *home = msg_home(msg);
+
+  if (!sip->sip_from)
+    clone = 1, sip->sip_from = sip_from_copy(home, irq->irq_from);
+  if (!sip->sip_to)
+    clone = 1, sip->sip_to = sip_to_copy(home, irq->irq_to);
+  if (!sip->sip_call_id)
+    clone = 1, sip->sip_call_id = sip_call_id_copy(home, irq->irq_call_id);
+  if (!sip->sip_cseq)
+    clone = 1, sip->sip_cseq = sip_cseq_copy(home, irq->irq_cseq);
+  if (!sip->sip_via)
+    clone = 1, sip->sip_via = sip_via_copy(home, irq->irq_via);
+
+  if (clone)
+    msg_set_parent(msg, (msg_t *)irq->irq_home);
+
+  if (!sip->sip_from || !sip->sip_to || !sip->sip_call_id || !sip->sip_cseq || !sip->sip_via)
+    return -1;
+
+  return 0;
+}
+
 /** Complete a response message.
  *
  * @param irq     server transaction object
@@ -5297,7 +5462,6 @@ int nta_incoming_complete_response(nta_incoming_t *irq,
 {
   su_home_t *home = msg_home(msg);
   sip_t *sip = sip_object(msg);
-  int clone = 0;
   int retval;
   ta_list ta;
 
@@ -5307,7 +5471,7 @@ int nta_incoming_complete_response(nta_incoming_t *irq,
   if (status != 0 && (status < 100 || status > 699))
     return su_seterrno(EINVAL), -1;
 
-  if (!sip->sip_status)
+  if (status != 0 && !sip->sip_status)
     sip->sip_status = sip_status_create(home, status, phrase, NULL);
 
   ta_start(ta, tag, value);
@@ -5320,42 +5484,54 @@ int nta_incoming_complete_response(nta_incoming_t *irq,
   if (irq->irq_default)
     return sip_complete_message(msg);
 
-  if (!sip->sip_from)
-    clone = 1, sip->sip_from = sip_from_copy(home, irq->irq_from);
   if (status > 100 && !irq->irq_tag) {
     if (sip->sip_to)
       nta_incoming_tag(irq, sip->sip_to->a_tag);
     else
       nta_incoming_tag(irq, NULL);
   }
-  if (!sip->sip_to)
-    clone = 1, sip->sip_to = sip_to_copy(home, irq->irq_to);
+
+  if (nta_incoming_response_headers(irq, msg, sip) < 0)
+    return -1;
+
   if (sip->sip_status && sip->sip_status->st_status > 100 &&
       irq->irq_tag && sip->sip_to && !sip->sip_to->a_tag)
-    sip_to_tag(home, sip->sip_to, irq->irq_tag);
-  if (!sip->sip_call_id)
-    clone = 1, sip->sip_call_id = sip_call_id_copy(home, irq->irq_call_id);
-  if (!sip->sip_cseq)
-    clone = 1, sip->sip_cseq = sip_cseq_copy(home, irq->irq_cseq);
-  if (!sip->sip_via)
-    clone = 1, sip->sip_via = sip_via_copy(home, irq->irq_via);
-  if (status < 300 && 
-      !sip->sip_record_route && irq->irq_record_route)
-    sip_add_dup(msg, sip, (sip_header_t *)irq->irq_record_route);
-
-  if (clone)
-    msg_set_parent(msg, (msg_t *)irq->irq_home);
+    if (sip_to_tag(home, sip->sip_to, irq->irq_tag) < 0)
+      return -1;
 
-  if (retval < 0 || !sip->sip_from || !sip->sip_to || !sip->sip_call_id
-      || !sip->sip_cseq || !sip->sip_via
-      || (status < 300 && irq->irq_record_route && !sip->sip_record_route &&
-         sip->sip_cseq && sip->sip_cseq->cs_method != sip_method_register))
-    return -1;
+  if (status < 300 && !sip->sip_record_route && irq->irq_record_route)
+    if (sip_add_dup(msg, sip, (sip_header_t *)irq->irq_record_route) < 0)
+      return -1;
 
   return sip_complete_message(msg);
 }
 
 
+/** Create a response message for request.
+ *
+ * @NEW_1_12_5.
+ */
+msg_t *nta_incoming_create_response(nta_incoming_t *irq,
+                                   int status, char const *phrase)
+{
+  msg_t *msg = NULL;
+  sip_t *sip;
+
+  if (irq) {
+    msg = nta_msg_create(irq->irq_agent, 0);
+    sip = sip_object(msg);
+
+    if (status != 0)
+      sip->sip_status = sip_status_create(msg_home(msg), status, phrase, NULL);
+
+    if (nta_incoming_response_headers(irq, msg, sip) < 0)
+      msg_destroy(msg), msg = NULL;
+  }
+  
+  return msg;
+}
+
+
 /**Reply to an incoming transaction request.
  *
  * This function creates a response message to an incoming request and sends
@@ -5744,8 +5920,9 @@ enum {
 
 /** @internal Timer routine for the incoming request. */
 static inline
-int incoming_timer(nta_agent_t *sa, su_duration_t now)
+su_duration_t incoming_timer(nta_agent_t *sa, su_duration_t next)
 {
+  su_duration_t now = sa->sa_millisec;
   nta_incoming_t *irq, *irq_next;
   size_t retransmitted = 0, timeout = 0, terminated = 0, destroyed = 0;
   size_t unconfirmed = 
@@ -5762,8 +5939,9 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
 
   /* Handle retry queue */
   while ((irq = sa->sa_in.re_list)) {
-    if ((irq->irq_retry && irq->irq_retry - now > 0) ||
-       retransmitted >= timer_max_retransmit) 
+    if (irq->irq_retry - now > 0)
+      break;
+    if (retransmitted >= timer_max_retransmit)
       break;
 
     if (irq->irq_method == sip_method_invite && irq->irq_status >= 200) {
@@ -5801,7 +5979,8 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
        retransmitted++;
        incoming_retransmit_reply(irq, irq->irq_tport);
       }
-    } else {
+    }
+    else {
       /* Timer N1 */
       SU_DEBUG_5(("nta: timer N1 fired, sending %u %s\n", SIP_100_TRYING));
       incoming_reset_timer(irq);
@@ -5809,6 +5988,8 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
     }
   }
 
+  next = NEXT_TIMEOUT(next, irq, irq_retry, now);
+
   while ((irq = sa->sa_in.final_failed->q_head)) {
     incoming_remove(irq);
     irq->irq_final_failed = 0;
@@ -5841,8 +6022,9 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
     assert(irq->irq_status < 200);
     assert(irq->irq_timeout);
 
-    if (irq->irq_timeout - now > 0 
-       || timeout >= timer_max_timeout)
+    if (irq->irq_timeout - now > 0)
+      break;
+    if (timeout >= timer_max_timeout)
       break;
 
     timeout++;
@@ -5855,6 +6037,8 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
     reliable_timeout(irq, 1);
   }
 
+  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
+
   while ((irq = sa->sa_in.inv_completed->q_head)) {
     assert(irq->irq_status >= 200);
     assert(irq->irq_timeout);
@@ -5883,13 +6067,14 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
     }
   } 
 
+  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
+
   while ((irq = sa->sa_in.inv_confirmed->q_head)) {
     assert(irq->irq_timeout);
     assert(irq->irq_status >= 200);
     assert(irq->irq_method == sip_method_invite);
 
-    if (irq->irq_timeout - now > 0 || 
-       terminated >= timer_max_terminate)
+    if (irq->irq_timeout - now > 0 || terminated >= timer_max_terminate)
       break;
     
     /* Timer I */
@@ -5905,13 +6090,14 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
       incoming_free_queue(rq, irq);
   }
 
+  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
+
   while ((irq = sa->sa_in.completed->q_head)) {
     assert(irq->irq_status >= 200);
     assert(irq->irq_timeout);
     assert(irq->irq_method != sip_method_invite);
 
-    if (irq->irq_timeout - now > 0 || 
-       terminated >= timer_max_terminate)
+    if (irq->irq_timeout - now > 0 || terminated >= timer_max_terminate)
       break;
 
     /* Timer J */
@@ -5928,6 +6114,8 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
       incoming_free_queue(rq, irq);
   }
 
+  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
+
   for (irq = sa->sa_in.terminated->q_head; irq; irq = irq_next) {
     irq_next = irq->irq_next;
     if (irq->irq_destroyed)
@@ -5947,10 +6135,7 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
                terminated, unterminated, 
                destroyed, total));
 
-  return 
-    retransmitted >= timer_max_retransmit
-    || timeout >= timer_max_timeout
-    || terminated >= timer_max_terminate;
+  return next;
 }
 
 /** Mass destroy server transactions */
@@ -6018,11 +6203,11 @@ static inline void outgoing_remove(nta_outgoing_t *orq);
 static inline void outgoing_set_timer(nta_outgoing_t *orq, unsigned interval);
 static inline void outgoing_reset_timer(nta_outgoing_t *orq);
 static size_t outgoing_timer_dk(outgoing_queue_t *q, 
-                            char const *timer, 
-                            su_duration_t now);
+                               char const *timer, 
+                               su_duration_t now);
 static size_t outgoing_timer_bf(outgoing_queue_t *q, 
-                            char const *timer, 
-                            su_duration_t now);
+                               char const *timer, 
+                               su_duration_t now);
 
 static void outgoing_ack(nta_outgoing_t *orq, msg_t *msg, sip_t *sip);
 static msg_t *outgoing_ackmsg(nta_outgoing_t *, sip_method_t, char const *,
@@ -6093,12 +6278,11 @@ nta_outgoing_t *nta_outgoing_default(nta_agent_t *agent,
 
 /**Create an outgoing request and client transaction belonging to the leg.
  *
- * The function nta_outgoing_tcreate() creates a request message and passes
- * the request message to an outgoing client transaction object. The request
- * is sent to the @a route_url (if non-NULL), default proxy (if defined by
- * NTATAG_DEFAULT_PROXY()), or to the address specified by @a request_uri.
- * If no @a request_uri is specified, it is taken from route-set target or
- * from the @To header.
+ * Create a request message and pass the request message to an outgoing
+ * client transaction object. The request is sent to the @a route_url (if
+ * non-NULL), default proxy (if defined by NTATAG_DEFAULT_PROXY()), or to
+ * the address specified by @a request_uri. If no @a request_uri is
+ * specified, it is taken from route-set target or from the @To header.
  *
  * When NTA receives response to the request, it invokes the @a callback
  * function.
@@ -6381,7 +6565,8 @@ void nta_outgoing_destroy(nta_outgoing_t *orq)
     return;
 
   if (orq->orq_destroyed) {
-    SU_DEBUG_1(("nta_outgoing_destroy(%p): already destroyed\n", orq));
+    SU_DEBUG_1(("%s(%p): %s\n", "nta_outgoing_destroy", (void *)orq, 
+               "already destroyed"));
     return;
   }
 
@@ -6474,10 +6659,10 @@ msg_t *nta_outgoing_getrequest(nta_outgoing_t *orq)
 
 /**Create an outgoing request.
  *
- * The function outgoing_create() creates an outgoing transaction object and
- * sends the request to the network. The request is sent to the @a route_url
- * (if non-NULL), default proxy (if defined by NTATAG_DEFAULT_PROXY()), or
- * to the address specified by @a sip->sip_request->rq_url.
+ * Create an outgoing transaction object and send the request to the
+ * network. The request is sent to the @a route_url (if non-NULL), default
+ * proxy (if defined by NTATAG_DEFAULT_PROXY()), or to the address specified
+ * by @a sip->sip_request->rq_url.
  *
  * When NTA receives response to the request, it invokes the @a callback
  * function.
@@ -7228,8 +7413,8 @@ int outgoing_is_queued(nta_outgoing_t const *orq)
 /** @internal
  * Insert an outgoing transaction into a queue. 
  *
- * The function outgoing_queue() inserts a client transaction into a queue,
- * and sets the corresponding timeout at the same time.
+ * Insert a client transaction into a queue and set the corresponding
+ * timeout at the same time.
  */
 static inline
 void outgoing_queue(outgoing_queue_t *queue, 
@@ -7246,7 +7431,7 @@ void outgoing_queue(outgoing_queue_t *queue,
   assert(*queue->q_tail == NULL);
 
   orq->orq_timeout = set_timeout(orq->orq_agent, queue->q_timeout);
-    
+
   orq->orq_queue = queue;
   orq->orq_prev = queue->q_tail; 
   *queue->q_tail = orq;
@@ -7277,8 +7462,7 @@ void outgoing_remove(nta_outgoing_t *orq)
 
 /** Set retransmit timer (orq_retry).
  *
- * The function outgoing_set_timer() will set the retry timer (B/D) on
- * the outgoing request (client transaction). 
+ * Set the retry timer (B/D) on the outgoing request (client transaction).
  */
 static inline
 void outgoing_set_timer(nta_outgoing_t *orq, unsigned interval)
@@ -7305,6 +7489,7 @@ void outgoing_set_timer(nta_outgoing_t *orq, unsigned interval)
 
   orq->orq_retry = set_timeout(orq->orq_agent, orq->orq_interval = interval);
 
+  /* Shortcut into queue at SIP T1 */
   rq = orq->orq_agent->sa_out.re_t1;
 
   if (!(*rq) || (*rq)->orq_retry - orq->orq_retry > 0)
@@ -7343,7 +7528,7 @@ void outgoing_reset_timer(nta_outgoing_t *orq)
 static
 void outgoing_free(nta_outgoing_t *orq)
 {
-  SU_DEBUG_9(("nta: outgoing_free(%p)\n", orq));
+  SU_DEBUG_9(("nta: outgoing_free(%p)\n", (void *)orq));
   outgoing_cut_off(orq);
   outgoing_reclaim(orq);
 }
@@ -7410,7 +7595,8 @@ void outgoing_reclaim_queued(su_root_magic_t *rm,
   outgoing_queue_t *q = u->a_outgoing_queue;
   nta_outgoing_t *orq, *orq_next;
 
-  SU_DEBUG_9(("outgoing_reclaim_all(%p, %p, %p)\n", rm, msg, u));
+  SU_DEBUG_9(("outgoing_reclaim_all(%p, %p, %p)\n",
+             (void *)rm, (void *)msg, (void *)u));
 
   for (orq = q->q_head; orq; orq = orq_next) {
     orq_next = orq->orq_next;
@@ -7434,6 +7620,14 @@ void outgoing_destroy(nta_outgoing_t *orq)
   if (orq->orq_terminated || orq->orq_default) {
     outgoing_free(orq);
   }
+  /* We have to handle 200 OK statelessly => 
+     kill transaction immediately */
+  else if (orq->orq_method == sip_method_invite && !orq->orq_completed
+          /* (unless we have to wait to send CANCEL) */
+          && !orq->orq_cancel) {
+    orq->orq_destroyed = 1;
+    outgoing_terminate(orq);
+  }
   else {
     orq->orq_destroyed = 1;
     orq->orq_callback = outgoing_default_cb;
@@ -7441,24 +7635,29 @@ void outgoing_destroy(nta_outgoing_t *orq)
   }
 }
 
-/** @internal Outgoing transaction timer routine. */
-static
-int outgoing_timer(nta_agent_t *sa, su_duration_t now)
+/** @internal Outgoing transaction timer routine. 
+ *
+ */
+static inline 
+su_duration_t outgoing_timer(nta_agent_t *sa, su_duration_t next)
 {
+  su_duration_t now = sa->sa_millisec;
   nta_outgoing_t *orq;
   outgoing_queue_t rq[1];
   size_t retransmitted = 0, terminated = 0, timeout = 0, destroyed;
   size_t total = sa->sa_outgoing->oht_used;
   size_t trying = sa->sa_out.re_length;
-  size_t pending = sa->sa_out.trying->q_length + sa->sa_out.inv_calling->q_length;
+  size_t pending = sa->sa_out.trying->q_length + 
+    sa->sa_out.inv_calling->q_length;
   size_t completed = sa->sa_out.completed->q_length + 
     sa->sa_out.inv_completed->q_length;
 
   outgoing_queue_init(sa->sa_out.free = rq, 0);
 
   while ((orq = sa->sa_out.re_list)) {
-    if ((orq->orq_retry && orq->orq_retry - now > 0)
-       || retransmitted >= timer_max_retransmit)
+    if (orq->orq_retry - now > 0)
+      break;
+    if (retransmitted >= timer_max_retransmit)
       break;
 
     if (orq->orq_reliable) {
@@ -7494,14 +7693,22 @@ int outgoing_timer(nta_agent_t *sa, su_duration_t now)
       su_root_yield(sa->sa_root);      /* Handle received packets */
   }
 
+  next = NEXT_TIMEOUT(next, orq, orq_retry, now);
+
   terminated
     = outgoing_timer_dk(sa->sa_out.inv_completed, "D", now)
     + outgoing_timer_dk(sa->sa_out.completed, "K", now);
 
+  next = NEXT_TIMEOUT(next, sa->sa_out.inv_completed->q_head, orq_timeout, now);
+  next = NEXT_TIMEOUT(next, sa->sa_out.completed->q_head, orq_timeout, now);
+
   timeout
     = outgoing_timer_bf(sa->sa_out.inv_calling, "B", now)
     + outgoing_timer_bf(sa->sa_out.trying, "F", now);
 
+  next = NEXT_TIMEOUT(next, sa->sa_out.inv_calling->q_head, orq_timeout, now);
+  next = NEXT_TIMEOUT(next, sa->sa_out.trying->q_head, orq_timeout, now);
+
   destroyed = outgoing_mass_destroy(sa, rq);
 
   sa->sa_out.free = NULL;
@@ -7518,10 +7725,7 @@ int outgoing_timer(nta_agent_t *sa, su_duration_t now)
                destroyed, total));
   }
 
-  return 
-    retransmitted >= timer_max_retransmit || 
-    terminated >= timer_max_terminate || 
-    timeout >= timer_max_timeout;
+  return next;
 }
 
 /** @internal Retransmit the outgoing request. */
@@ -7558,16 +7762,12 @@ size_t outgoing_timer_bf(outgoing_queue_t *q,
                         char const *timer, 
                         su_duration_t now)
 {
+  nta_outgoing_t *orq;
   size_t timeout = 0;
 
-  for (;;) {
-    nta_outgoing_t *orq = q->q_head;
-
-    if (!orq 
-       || !orq->orq_timeout
-       || orq->orq_timeout - now > 0 
-       || timeout >= timer_max_timeout)
-      return timeout;
+  while ((orq = q->q_head)) {
+    if (orq->orq_timeout - now > 0 || timeout >= timer_max_timeout)
+      break;
 
     timeout++;
     
@@ -7579,6 +7779,8 @@ size_t outgoing_timer_bf(outgoing_queue_t *q,
 
     assert(q->q_head != orq || orq->orq_timeout - now > 0);
   }
+
+  return timeout;
 }
 
 /** @internal Signal transaction timeout to the application. */
@@ -7587,7 +7789,8 @@ void outgoing_timeout(nta_outgoing_t *orq, su_duration_t now)
   nta_outgoing_t *cancel;
 
   if (outgoing_other_destinations(orq)) {
-    SU_DEBUG_5(("nta(%p): try next after timeout\n", orq));
+    SU_DEBUG_5(("%s(%p): %s\n", "nta", (void *)orq,
+               "try next after timeout"));
     outgoing_try_another(orq);
     return;
   }
@@ -7634,16 +7837,12 @@ size_t outgoing_timer_dk(outgoing_queue_t *q,
                         char const *timer, 
                         su_duration_t now)
 {
+  nta_outgoing_t *orq;
   size_t terminated = 0;
 
-  for (;;) {
-    nta_outgoing_t *orq = q->q_head;
-
-    if (!orq 
-       || !orq->orq_timeout 
-       || orq->orq_timeout - now > 0 
-       || terminated >= timer_max_terminate)
-      return terminated;
+  while ((orq = q->q_head)) {
+    if (orq->orq_timeout - now > 0 || terminated >= timer_max_terminate)
+      break;
 
     terminated++;
 
@@ -7652,6 +7851,8 @@ size_t outgoing_timer_dk(outgoing_queue_t *q,
 
     outgoing_terminate(orq);
   }
+  
+  return terminated;
 }
 
 /** Terminate a client transaction. */
@@ -7815,10 +8016,11 @@ int outgoing_recv(nta_outgoing_t *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;
 
   if (status < 100) status = 100;
 
-  if (sip && orq->orq_delay == UINT_MAX)
+  if (!internal && orq->orq_delay == UINT_MAX)
     outgoing_estimate_delay(orq, sip);
 
   if (orq->orq_cc)
@@ -7835,6 +8037,16 @@ int outgoing_recv(nta_outgoing_t *orq,
       outgoing_send(cancel, 0);
     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;
+    }
   }
 
   if (orq->orq_pending) {
@@ -7866,7 +8078,7 @@ int outgoing_recv(nta_outgoing_t *orq,
     }
     else {
       /* Final response */
-      if (status >= 300)
+      if (status >= 300 && !internal)
        outgoing_ack(orq, msg, sip);
 
       if (!orq->orq_completed) {
@@ -7896,7 +8108,8 @@ int outgoing_recv(nta_outgoing_t *orq,
   }
   else if (orq->orq_method != sip_method_ack) {
     /* Non-INVITE */
-    if (orq->orq_queue == sa->sa_out.trying) {
+    if (orq->orq_queue == sa->sa_out.trying ||
+       orq->orq_queue == sa->sa_out.resolving) {
       assert(orq_status < 200); (void)orq_status;
 
       if (status < 200) {
@@ -7911,7 +8124,8 @@ int outgoing_recv(nta_outgoing_t *orq,
        msg_destroy(msg);
        return 0;
       }
-    } else {
+    }
+    else {
       /* Already completed or terminated */
       assert(orq->orq_queue == sa->sa_out.completed ||
             orq->orq_queue == sa->sa_out.terminated);
@@ -8167,7 +8381,8 @@ int outgoing_reply(nta_outgoing_t *orq, int status, char const *phrase,
 
   if (orq->orq_method == sip_method_ack) {
     if (status != delayed)
-      SU_DEBUG_3(("nta(%p): responding %u %s to ACK!\n", orq, status, phrase));
+      SU_DEBUG_3(("nta(%p): responding %u %s to ACK!\n",
+                 (void *)orq, status, phrase));
     orq->orq_status = status;
     if (orq->orq_queue == NULL)
       outgoing_complete(orq);  /* Timer D/K */
@@ -8447,8 +8662,8 @@ outgoing_resolve(nta_outgoing_t *orq)
 
     /* Nothing found */
     if (!sr->sr_tports[0]) {
-      SU_DEBUG_3(("nta(%p): transport %s is not supported%s%s\n", orq, tpname,
-                 ident ? " by interface " : "", ident ? ident : ""));
+      SU_DEBUG_3(("nta(%p): transport %s is not supported%s%s\n", (void *)orq,
+                 tpname, ident ? " by interface " : "", ident ? ident : ""));
       outgoing_resolving_error(orq, SIPDNS_503_ERROR);
       return;
     }
@@ -9062,10 +9277,10 @@ void outgoing_answer_aaaa(sres_context_t *orq, sres_query_t *q,
     inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
 
     if (j == 0)
-      SU_DEBUG_5(("nta(%p): %s IN AAAA %s\n", orq, 
+      SU_DEBUG_5(("nta(%p): %s IN AAAA %s\n", (void *)orq, 
                  aaaa->aaaa_record->r_name, addr));
     else
-      SU_DEBUG_5(("nta(%p):  AAAA %s\n", orq, addr));
+      SU_DEBUG_5(("nta(%p):  AAAA %s\n", (void *)orq, addr));
 
     assert(j < found);
     results[j++] = su_strdup(home, addr);
@@ -9147,7 +9362,7 @@ void outgoing_answer_a(sres_context_t *orq, sres_query_t *q,
     if (j == 0)
       SU_DEBUG_5(("nta: %s IN A %s\n", a->a_record->r_name, addr));
     else
-      SU_DEBUG_5(("nta(%p):  A %s\n", orq, addr));
+      SU_DEBUG_5(("nta(%p):  A %s\n", (void *)orq, addr));
 
     assert(j < found);
     results[j++] = su_strdup(home, addr);
@@ -9171,7 +9386,7 @@ outgoing_query_results(nta_outgoing_t *orq,
       sq->sq_type != sr->sr_a_aaaa2) {
     sq->sq_type = sr->sr_a_aaaa2;
 
-    SU_DEBUG_7(("nta(%p): %s %s record still unresolved\n", orq,
+    SU_DEBUG_7(("nta(%p): %s %s record still unresolved\n", (void *)orq,
                sq->sq_domain, sq->sq_type == sres_type_a ? "A" : "AAAA"));
 
     /*
@@ -9492,8 +9707,9 @@ int reliable_recv(nta_incoming_t *irq, msg_t *msg, sip_t *sip, tport_t *tp)
   status = rel->rel_callback(rel->rel_magic, rel, pr_irq, sip); rel = NULL;
   irq->irq_in_callback = pr_irq->irq_in_callback = 0;
 
-  if (pr_irq->irq_destroyed && pr_irq->irq_terminated) {
-    incoming_free(pr_irq);
+  if (pr_irq->irq_completed) { /* Already sent final response */
+    if (pr_irq->irq_terminated && pr_irq->irq_destroyed)
+      incoming_free(pr_irq);
   }
   else if (status != 0) {
     if (status < 200 || status > 299) {
@@ -9622,8 +9838,7 @@ int nta_reliable_leg_prack(nta_reliable_magic_t *magic,
 
 /** Destroy a reliable response.
  *
- * The function nta_reliable_destroy() marks a reliable response object for
- * destroyal, and frees it if possible.
+ * Mark a reliable response object for destroyal and free it if possible.
  */
 void nta_reliable_destroy(nta_reliable_t *rel)
 {
@@ -9631,7 +9846,7 @@ void nta_reliable_destroy(nta_reliable_t *rel)
     return;
 
   if (rel->rel_callback == nta_reliable_destroyed)
-    SU_DEBUG_1(("%s(%p): already destroyed\n", __func__, rel));
+    SU_DEBUG_1(("%s(%p): %s\n", __func__, (void *)rel, "already destroyed"));
 
   rel->rel_callback = nta_reliable_destroyed;
 
@@ -9658,7 +9873,7 @@ int nta_reliable_destroyed(nta_reliable_magic_t *rmagic,
 
   if (!*prev) {
     assert(*prev);
-    SU_DEBUG_1(("%s(%p): not linked\n", __func__, rel));
+    SU_DEBUG_1(("%s(%p): %s\n", __func__, (void *)rel, "not linked"));
     return 200;
   }
 
@@ -9739,7 +9954,8 @@ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
   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__, orq));
+    SU_DEBUG_1(("%s: transaction %p already in dialog\n", __func__,
+               (void *)orq));
     return NULL;
   }
 
@@ -9755,6 +9971,9 @@ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
 
   tagged->orq_prev = NULL, tagged->orq_next = NULL, tagged->orq_queue = NULL;
   tagged->orq_rprev = NULL, tagged->orq_rnext = NULL;
+#if HAVE_SOFIA_SRESOLV
+  tagged->orq_resolver = NULL;
+#endif
 
   if (tagged->orq_cc)
     nta_compartment_ref(tagged->orq_cc);
@@ -9784,8 +10003,8 @@ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
 
 /**PRACK a provisional response.
  *
- * The function nta_outgoing_prack() creates and sends a PRACK request used
- * to acknowledge a provisional response. 
+ * Create and send a PRACK request used to acknowledge a provisional
+ * response.
  *
  * The request is sent using the route of the original request @a oorq.
  *
@@ -9801,9 +10020,8 @@ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
  * @param tag,value,... optional
  *
  * @return
- * If successful, the function nta_outgoing_prack() returns a pointer
- * to newly created client transaction object for PRACK request, NULL
- * otherwise.
+ * If successful, return a pointer to newly created client transaction
+ * object for PRACK request, NULL otherwise.
  *
  * @sa
  * nta_outgoing_tcreate(), nta_outgoing_tcancel(), nta_outgoing_destroy().
@@ -10147,8 +10365,12 @@ int nta_tport_keepalive(nta_outgoing_t *orq)
 
   assert(orq); (void)tp;
 
+#if HAVE_SOFIA_STUN
   return tport_keepalive(orq->orq_tport, msg_addrinfo(orq->orq_request),
                         TAG_END());
+#else
+  return -1;
+#endif
 }
 
 /** Close all transports. @since Experimental in @VERSION_1_12_2. */
@@ -10168,7 +10390,7 @@ int nta_agent_close_tports(nta_agent_t *agent)
       
       orq->orq_pending = 0;
       tport_unref(orq->orq_tport), orq->orq_tport = NULL;
-    }  
+    }
   
   
   for (i = iht->iht_size; i-- > 0;)
index 0094a89baaa65f0f5e8ba28de780de3426188b05..9046154af41d6f51d45a012fc3d5484ed7b6ff1f 100644 (file)
@@ -343,8 +343,8 @@ int nta_check_accept(nta_incoming_t *irq,
 /**Check @SessionExpires header.
  *
  * If the proposed session-expiration time is smaller than @MinSE or our
- * minimal session expiration time, respond with 422 containing our minimal
- * session expiration time in @MinSE header.
+ * minimal session expiration time, respond with 422 containing shortest
+ * acceptable session expiration time in @MinSE header.
  *
  * @param irq  incoming transaction object (may be NULL).
  * @param sip  contents of the SIP message
@@ -359,26 +359,28 @@ int nta_check_session_expires(nta_incoming_t *irq,
                              sip_time_t my_min_se,
                              tag_type_t tag, tag_value_t value, ...)
 {
-  if ((sip->sip_min_se &&
-       sip->sip_session_expires->x_delta < sip->sip_min_se->min_delta)
-      || sip->sip_session_expires->x_delta < my_min_se) {
-    ta_list ta;
+  unsigned long min_se = my_min_se;
 
-    sip_min_se_t min_se[1];
+  if (sip->sip_min_se && min_se < sip->sip_min_se->min_delta)
+    min_se = sip->sip_min_se->min_delta;
 
-    sip_min_se_init(min_se)->min_delta = my_min_se;
+  if (sip->sip_session_expires->x_delta >= min_se)
+    return 0;
 
-    if (irq) {
-      ta_start(ta, tag, value);
-      nta_incoming_treply(irq,
-                         SIP_422_SESSION_TIMER_TOO_SMALL,
-                         SIPTAG_MIN_SE(min_se),
-                         ta_tags(ta));
-      ta_end(ta);
-    }
+  if (irq) {
+    ta_list ta;
+    sip_min_se_t min_se0[1];
 
-    return 422;
+    ta_start(ta, tag, value);
+
+    sip_min_se_init(min_se0)->min_delta = min_se;
+
+    nta_incoming_treply(irq,
+                       SIP_422_SESSION_TIMER_TOO_SMALL,
+                       SIPTAG_MIN_SE(min_se0),
+                       ta_tags(ta));
+    ta_end(ta);
   }
 
-  return 0;
+  return 422;
 }
index e2e0979c0a0d267f57da6d7eb130c8d2c7681780..1a8440b34306aa93cf0167619009efaf09117712 100644 (file)
@@ -98,16 +98,17 @@ struct nta_agent_s
   nta_agent_magic_t    *sa_magic;
   nta_message_f        *sa_callback;     
 
-  uint32_t              sa_nw_updates; /* Shall we enable network detector? */
-
   nta_update_magic_t   *sa_update_magic;
   nta_update_tport_f   *sa_update_tport;
 
-  su_time_t             sa_now;        /**< Timestamp in microsecond resolution. */
+  su_duration_t         sa_next; /**< Timestamp for next agent_timer. */
+  su_time_t             sa_now;         /**< Timestamp in microsecond resolution. */
   uint32_t              sa_millisec; /**< Timestamp in milliseconds resolution. */
 
+  uint32_t              sa_nw_updates; /* Shall we enable network detector? */
+
   uint32_t              sa_flags;      /**< Message flags */
-  msg_mclass_t         *sa_mclass;
+  msg_mclass_t const   *sa_mclass;
 
   sip_contact_t        *sa_contact;
   sip_via_t            *sa_vias;   /**< @Via headers for all transports */
@@ -223,6 +224,9 @@ struct nta_agent_s
   /** If true, automatically create compartments */
   unsigned              sa_auto_comp:1;
 
+  /** Set when executing timer */
+  unsigned              sa_in_timer:1;
+
   unsigned              :0;
 
   /** Messages memory preload. */
@@ -342,6 +346,11 @@ struct nta_leg_s
   unsigned          leg_loose_route : 1; /**< Topmost route in set is LR */
 #endif
   unsigned          leg_local_is_to : 1; /**< Backwards-compatibility. */
+  unsigned          leg_tagged : 1; /**< Tagged after creation.
+                                    *
+                                    * Request missing To tag matches it
+                                    * even after tagging.
+                                    */
   unsigned:0;
   nta_request_f    *leg_callback;
   nta_leg_magic_t  *leg_magic;
@@ -463,12 +472,17 @@ struct nta_outgoing_s
 
   sip_method_t         orq_method;
   char const           *orq_method_name;
+  url_t const          *orq_url;        /**< Original RequestURI */
+
   sip_from_t const     *orq_from;
   sip_to_t const       *orq_to;
+  char const           *orq_tag;        /**< Tag from final response. */
+
   sip_cseq_t const     *orq_cseq;
   sip_call_id_t const  *orq_call_id;
 
-  char const           *orq_tag;        /**< Tag from final response. */
+  msg_t                       *orq_request;
+  msg_t                *orq_response;
 
   su_time_t             orq_sent;       /**< When request was sent? */
   unsigned              orq_delay;      /**< RTT estimate */
@@ -501,11 +515,9 @@ struct nta_outgoing_s
   unsigned orq_sigcomp_new:1;  /**< Create compartment if needed */
   unsigned orq_sigcomp_zap:1;  /**< Reset SigComp after completing */
   unsigned orq_must_100rel : 1;
-  unsigned orq_timestamp : 1;  /**< insert @Timestamp header. */
+  unsigned orq_timestamp : 1;  /**< Insert @Timestamp header. */
   unsigned : 0;        /* pad */
 
-  uint32_t              orq_rseq;       /**< Latest incoming rseq */
-
 #if HAVE_SOFIA_SRESOLV
   sipdns_resolver_t    *orq_resolver;
 #endif
@@ -522,12 +534,10 @@ struct nta_outgoing_s
 
   char const           *orq_branch;    /**< Transaction branch */
   char const           *orq_via_branch;        /**< @Via branch */
-  url_t const          *orq_url;        /**< Original RequestURI */
-
-  msg_t                       *orq_request;
-  msg_t                *orq_response;
 
   nta_outgoing_t       *orq_cancel;     /**< CANCEL transaction */
+
+  uint32_t              orq_rseq;       /**< Latest incoming rseq */
 };
 
 /* Virtual function table for plugging in SigComp */
index d6548234d95bf36c48d84a2d096127f09db16333..60adcd74ad3250d37e21c7c6f05fbdd2bd1fcdb4 100644 (file)
@@ -110,38 +110,38 @@ tag_typedef_t ntatag_rseq = UINTTAG_TYPEDEF(rseq);
 
 /* Status */
 
-tag_typedef_t ntatag_s_irq_hash =         UINTTAG_TYPEDEF(s_irq_hash);
-tag_typedef_t ntatag_s_orq_hash =         UINTTAG_TYPEDEF(s_orq_hash);
-tag_typedef_t ntatag_s_leg_hash =         UINTTAG_TYPEDEF(s_leg_hash);
-tag_typedef_t ntatag_s_irq_hash_used =    UINTTAG_TYPEDEF(s_irq_hash_used);
-tag_typedef_t ntatag_s_orq_hash_used =    UINTTAG_TYPEDEF(s_orq_hash_used);
-tag_typedef_t ntatag_s_leg_hash_used =    UINTTAG_TYPEDEF(s_leg_hash_used);
-tag_typedef_t ntatag_s_recv_msg =         UINTTAG_TYPEDEF(s_recv_msg);
-tag_typedef_t ntatag_s_recv_request =     UINTTAG_TYPEDEF(s_recv_request);
-tag_typedef_t ntatag_s_recv_response =    UINTTAG_TYPEDEF(s_recv_response);
-tag_typedef_t ntatag_s_bad_message =      UINTTAG_TYPEDEF(s_bad_message);
-tag_typedef_t ntatag_s_bad_request =      UINTTAG_TYPEDEF(s_bad_request);
-tag_typedef_t ntatag_s_bad_response =     UINTTAG_TYPEDEF(s_bad_response);
-tag_typedef_t ntatag_s_drop_request =     UINTTAG_TYPEDEF(s_drop_request);
-tag_typedef_t ntatag_s_drop_response =    UINTTAG_TYPEDEF(s_drop_response);
-tag_typedef_t ntatag_s_client_tr =        UINTTAG_TYPEDEF(s_client_tr);
-tag_typedef_t ntatag_s_server_tr =        UINTTAG_TYPEDEF(s_server_tr);
-tag_typedef_t ntatag_s_dialog_tr =        UINTTAG_TYPEDEF(s_dialog_tr);
-tag_typedef_t ntatag_s_acked_tr =         UINTTAG_TYPEDEF(s_acked_tr);
-tag_typedef_t ntatag_s_canceled_tr =      UINTTAG_TYPEDEF(s_canceled_tr);
-tag_typedef_t ntatag_s_trless_request =   UINTTAG_TYPEDEF(s_trless_request);
-tag_typedef_t ntatag_s_trless_to_tr =     UINTTAG_TYPEDEF(s_trless_to_tr);
-tag_typedef_t ntatag_s_trless_response =  UINTTAG_TYPEDEF(s_trless_response);
-tag_typedef_t ntatag_s_trless_200 =       UINTTAG_TYPEDEF(s_trless_200);
-tag_typedef_t ntatag_s_merged_request =   UINTTAG_TYPEDEF(s_merged_request);
-tag_typedef_t ntatag_s_sent_msg =                UINTTAG_TYPEDEF(s_sent_msg);
-tag_typedef_t ntatag_s_sent_request =            UINTTAG_TYPEDEF(s_sent_request);
-tag_typedef_t ntatag_s_sent_response =           UINTTAG_TYPEDEF(s_sent_response);
-tag_typedef_t ntatag_s_retry_request =           UINTTAG_TYPEDEF(s_retry_request);
-tag_typedef_t ntatag_s_retry_response =   UINTTAG_TYPEDEF(s_retry_response);
-tag_typedef_t ntatag_s_recv_retry =       UINTTAG_TYPEDEF(s_recv_retry);
-tag_typedef_t ntatag_s_tout_request =     UINTTAG_TYPEDEF(s_tout_request);
-tag_typedef_t ntatag_s_tout_response =    UINTTAG_TYPEDEF(s_tout_response);
+tag_typedef_t ntatag_s_irq_hash =         USIZETAG_TYPEDEF(s_irq_hash);
+tag_typedef_t ntatag_s_orq_hash =         USIZETAG_TYPEDEF(s_orq_hash);
+tag_typedef_t ntatag_s_leg_hash =         USIZETAG_TYPEDEF(s_leg_hash);
+tag_typedef_t ntatag_s_irq_hash_used =    USIZETAG_TYPEDEF(s_irq_hash_used);
+tag_typedef_t ntatag_s_orq_hash_used =    USIZETAG_TYPEDEF(s_orq_hash_used);
+tag_typedef_t ntatag_s_leg_hash_used =    USIZETAG_TYPEDEF(s_leg_hash_used);
+tag_typedef_t ntatag_s_recv_msg =         USIZETAG_TYPEDEF(s_recv_msg);
+tag_typedef_t ntatag_s_recv_request =     USIZETAG_TYPEDEF(s_recv_request);
+tag_typedef_t ntatag_s_recv_response =    USIZETAG_TYPEDEF(s_recv_response);
+tag_typedef_t ntatag_s_bad_message =      USIZETAG_TYPEDEF(s_bad_message);
+tag_typedef_t ntatag_s_bad_request =      USIZETAG_TYPEDEF(s_bad_request);
+tag_typedef_t ntatag_s_bad_response =     USIZETAG_TYPEDEF(s_bad_response);
+tag_typedef_t ntatag_s_drop_request =     USIZETAG_TYPEDEF(s_drop_request);
+tag_typedef_t ntatag_s_drop_response =    USIZETAG_TYPEDEF(s_drop_response);
+tag_typedef_t ntatag_s_client_tr =        USIZETAG_TYPEDEF(s_client_tr);
+tag_typedef_t ntatag_s_server_tr =        USIZETAG_TYPEDEF(s_server_tr);
+tag_typedef_t ntatag_s_dialog_tr =        USIZETAG_TYPEDEF(s_dialog_tr);
+tag_typedef_t ntatag_s_acked_tr =         USIZETAG_TYPEDEF(s_acked_tr);
+tag_typedef_t ntatag_s_canceled_tr =      USIZETAG_TYPEDEF(s_canceled_tr);
+tag_typedef_t ntatag_s_trless_request =   USIZETAG_TYPEDEF(s_trless_request);
+tag_typedef_t ntatag_s_trless_to_tr =     USIZETAG_TYPEDEF(s_trless_to_tr);
+tag_typedef_t ntatag_s_trless_response =  USIZETAG_TYPEDEF(s_trless_response);
+tag_typedef_t ntatag_s_trless_200 =       USIZETAG_TYPEDEF(s_trless_200);
+tag_typedef_t ntatag_s_merged_request =   USIZETAG_TYPEDEF(s_merged_request);
+tag_typedef_t ntatag_s_sent_msg =                USIZETAG_TYPEDEF(s_sent_msg);
+tag_typedef_t ntatag_s_sent_request =            USIZETAG_TYPEDEF(s_sent_request);
+tag_typedef_t ntatag_s_sent_response =           USIZETAG_TYPEDEF(s_sent_response);
+tag_typedef_t ntatag_s_retry_request =           USIZETAG_TYPEDEF(s_retry_request);
+tag_typedef_t ntatag_s_retry_response =   USIZETAG_TYPEDEF(s_retry_response);
+tag_typedef_t ntatag_s_recv_retry =       USIZETAG_TYPEDEF(s_recv_retry);
+tag_typedef_t ntatag_s_tout_request =     USIZETAG_TYPEDEF(s_tout_request);
+tag_typedef_t ntatag_s_tout_response =    USIZETAG_TYPEDEF(s_tout_response);
 
 /* Internal */
 tag_typedef_t ntatag_delay_sending = BOOLTAG_TYPEDEF(delay_sending);
index 1c47c6562f7ce063caf9a5717da8ae621fda813a..78865d32d19241f6bcbc5d257ed5209a347ec357 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # Run nta_test with our own name server
 #
@@ -50,11 +50,11 @@ export PATH
 
 me6="::1"
 
-if ../su/localinfo -6 -n -g -s >& /dev/null ; then
+if ../su/localinfo -6 -n -g -s > /dev/null 2>&1 ; then
     ipv6=true aaaa=aaaa v6flag=-6
     me6=$(../su/localinfo -6 -n -s -g | awk '{print $1; exit(0); }')
 else
-    if ! ../su/localinfo '--help' >& /dev/null ; then
+    if ! ../su/localinfo '--help' > /dev/null 2>&1 ; then
        echo "warning: $0: missing 'localinfo', cannot test IPv6"
     else
        echo "warning: $0: no valid IPv6 addresses available"
@@ -62,7 +62,7 @@ else
     ipv6=false aaaa=a
 fi
 
-if type named >& /dev/null && ./portbind --help >& /dev/null
+if type named > /dev/null 2>&1 && ./portbind --help > /dev/null 2>&1
 then
 
 port=$(./portbind $v6flag) sink=$port
index f6f2f5a7ac253a75aa1c2c4f5d574dccfc91c609..ca921674d17889c30a0986a9da457e7a1eca88e2 100644 (file)
@@ -299,6 +299,9 @@ int nta_incoming_complete_response(nta_incoming_t *irq,
                                   char const *phrase,
                                   tag_type_t tag, tag_value_t value, ...);
 
+SOFIAPUBFUN
+msg_t *nta_incoming_create_response(nta_incoming_t *irq, int status, char const *phrase);
+
 SOFIAPUBFUN
 int nta_incoming_treply(nta_incoming_t *ireq, 
                        int status, char const *phrase, 
index 6cc8f8f6d0face8ba540af67a848e3399c5c92e6..e0f284b7e73bbe8eb534c13f9190cfb317fbfe25 100644 (file)
@@ -59,10 +59,10 @@ NTA_DLL extern tag_typedef_t ntatag_any;
 
 NTA_DLL extern tag_typedef_t ntatag_mclass;
 /** Message class used by NTA. @HI */
-#define NTATAG_MCLASS(x) ntatag_mclass, tag_ptr_v((x))
+#define NTATAG_MCLASS(x) ntatag_mclass, tag_cptr_v((x))
 
 NTA_DLL extern tag_typedef_t ntatag_mclass_ref;
-#define NTATAG_MCLASS_REF(x) ntatag_mclass_ref, tag_ptr_vr(&(x), (x))
+#define NTATAG_MCLASS_REF(x) ntatag_mclass_ref, tag_cptr_vr(&(x), (x))
 
 NTA_DLL extern tag_typedef_t ntatag_bad_req_mask;
 /** Mask for bad request messages. 
@@ -464,223 +464,223 @@ NTA_DLL extern tag_typedef_t ntatag_rseq_ref;
 /* Tags for statistics. */
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash;
-#define NTATAG_S_IRQ_HASH(x) ntatag_s_irq_hash, tag_uint_v(x)
+#define NTATAG_S_IRQ_HASH(x) ntatag_s_irq_hash, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash_ref;
-#define NTATAG_S_IRQ_HASH_REF(x) ntatag_s_irq_hash_ref, tag_uint_vr(&(x))
+#define NTATAG_S_IRQ_HASH_REF(x) ntatag_s_irq_hash_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash;
-#define NTATAG_S_ORQ_HASH(x) ntatag_s_orq_hash, tag_uint_v(x)
+#define NTATAG_S_ORQ_HASH(x) ntatag_s_orq_hash, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash_ref;
-#define NTATAG_S_ORQ_HASH_REF(x) ntatag_s_orq_hash_ref, tag_uint_vr(&(x))
+#define NTATAG_S_ORQ_HASH_REF(x) ntatag_s_orq_hash_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash;
-#define NTATAG_S_LEG_HASH(x) ntatag_s_leg_hash, tag_uint_v(x)
+#define NTATAG_S_LEG_HASH(x) ntatag_s_leg_hash, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash_ref;
-#define NTATAG_S_LEG_HASH_REF(x) ntatag_s_leg_hash_ref, tag_uint_vr(&(x))
+#define NTATAG_S_LEG_HASH_REF(x) ntatag_s_leg_hash_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash_used;
-#define NTATAG_S_IRQ_HASH_USED(x) ntatag_s_irq_hash_used, tag_uint_v(x)
+#define NTATAG_S_IRQ_HASH_USED(x) ntatag_s_irq_hash_used, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash_used_ref;
 #define NTATAG_S_IRQ_HASH_USED_REF(x) \
-ntatag_s_irq_hash_used_ref, tag_uint_vr(&(x))
+ntatag_s_irq_hash_used_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash_used;
-#define NTATAG_S_ORQ_HASH_USED(x) ntatag_s_orq_hash_used, tag_uint_v(x)
+#define NTATAG_S_ORQ_HASH_USED(x) ntatag_s_orq_hash_used, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash_used_ref;
 #define NTATAG_S_ORQ_HASH_USED_REF(x) \
-ntatag_s_orq_hash_used_ref, tag_uint_vr(&(x))
+ntatag_s_orq_hash_used_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash_used;
-#define NTATAG_S_LEG_HASH_USED(x) ntatag_s_leg_hash_used, tag_uint_v(x)
+#define NTATAG_S_LEG_HASH_USED(x) ntatag_s_leg_hash_used, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash_used_ref;
 #define NTATAG_S_LEG_HASH_USED_REF(x) \
-ntatag_s_leg_hash_used_ref, tag_uint_vr(&(x))
+ntatag_s_leg_hash_used_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_msg;
-#define NTATAG_S_RECV_MSG(x) ntatag_s_recv_msg, tag_uint_v(x)
+#define NTATAG_S_RECV_MSG(x) ntatag_s_recv_msg, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_msg_ref;
-#define NTATAG_S_RECV_MSG_REF(x) ntatag_s_recv_msg_ref, tag_uint_vr(&(x))
+#define NTATAG_S_RECV_MSG_REF(x) ntatag_s_recv_msg_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_request;
-#define NTATAG_S_RECV_REQUEST(x) ntatag_s_recv_request, tag_uint_v(x)
+#define NTATAG_S_RECV_REQUEST(x) ntatag_s_recv_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_request_ref;
 #define NTATAG_S_RECV_REQUEST_REF(x)\
- ntatag_s_recv_request_ref, tag_uint_vr(&(x))
+ ntatag_s_recv_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_response;
-#define NTATAG_S_RECV_RESPONSE(x) ntatag_s_recv_response, tag_uint_v(x)
+#define NTATAG_S_RECV_RESPONSE(x) ntatag_s_recv_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_response_ref;
 #define NTATAG_S_RECV_RESPONSE_REF(x)\
- ntatag_s_recv_response_ref, tag_uint_vr(&(x))
+ ntatag_s_recv_response_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_message;
-#define NTATAG_S_BAD_MESSAGE(x) ntatag_s_bad_message, tag_uint_v(x)
+#define NTATAG_S_BAD_MESSAGE(x) ntatag_s_bad_message, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_message_ref;
 #define NTATAG_S_BAD_MESSAGE_REF(x)\
- ntatag_s_bad_message_ref, tag_uint_vr(&(x))
+ ntatag_s_bad_message_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_request;
-#define NTATAG_S_BAD_REQUEST(x) ntatag_s_bad_request, tag_uint_v(x)
+#define NTATAG_S_BAD_REQUEST(x) ntatag_s_bad_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_request_ref;
 #define NTATAG_S_BAD_REQUEST_REF(x)\
- ntatag_s_bad_request_ref, tag_uint_vr(&(x))
+ ntatag_s_bad_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_response;
-#define NTATAG_S_BAD_RESPONSE(x) ntatag_s_bad_response, tag_uint_v(x)
+#define NTATAG_S_BAD_RESPONSE(x) ntatag_s_bad_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_response_ref;
 #define NTATAG_S_BAD_RESPONSE_REF(x)\
- ntatag_s_bad_response_ref, tag_uint_vr(&(x))
+ ntatag_s_bad_response_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_request;
-#define NTATAG_S_DROP_REQUEST(x) ntatag_s_drop_request, tag_uint_v(x)
+#define NTATAG_S_DROP_REQUEST(x) ntatag_s_drop_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_request_ref;
 #define NTATAG_S_DROP_REQUEST_REF(x)\
- ntatag_s_drop_request_ref, tag_uint_vr(&(x))
+ ntatag_s_drop_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_response;
-#define NTATAG_S_DROP_RESPONSE(x) ntatag_s_drop_response, tag_uint_v(x)
+#define NTATAG_S_DROP_RESPONSE(x) ntatag_s_drop_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_response_ref;
 #define NTATAG_S_DROP_RESPONSE_REF(x)\
- ntatag_s_drop_response_ref, tag_uint_vr(&(x))
+ ntatag_s_drop_response_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_client_tr;
-#define NTATAG_S_CLIENT_TR(x) ntatag_s_client_tr, tag_uint_v(x)
+#define NTATAG_S_CLIENT_TR(x) ntatag_s_client_tr, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_client_tr_ref;
 #define NTATAG_S_CLIENT_TR_REF(x)\
- ntatag_s_client_tr_ref, tag_uint_vr(&(x))
+ ntatag_s_client_tr_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_server_tr;
-#define NTATAG_S_SERVER_TR(x) ntatag_s_server_tr, tag_uint_v(x)
+#define NTATAG_S_SERVER_TR(x) ntatag_s_server_tr, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_server_tr_ref;
 #define NTATAG_S_SERVER_TR_REF(x)\
- ntatag_s_server_tr_ref, tag_uint_vr(&(x))
+ ntatag_s_server_tr_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_dialog_tr;
-#define NTATAG_S_DIALOG_TR(x) ntatag_s_dialog_tr, tag_uint_v(x)
+#define NTATAG_S_DIALOG_TR(x) ntatag_s_dialog_tr, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_dialog_tr_ref;
 #define NTATAG_S_DIALOG_TR_REF(x)\
- ntatag_s_dialog_tr_ref, tag_uint_vr(&(x))
+ ntatag_s_dialog_tr_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_acked_tr;
-#define NTATAG_S_ACKED_TR(x) ntatag_s_acked_tr, tag_uint_v(x)
+#define NTATAG_S_ACKED_TR(x) ntatag_s_acked_tr, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_acked_tr_ref;
-#define NTATAG_S_ACKED_TR_REF(x) ntatag_s_acked_tr_ref, tag_uint_vr(&(x))
+#define NTATAG_S_ACKED_TR_REF(x) ntatag_s_acked_tr_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_canceled_tr;
-#define NTATAG_S_CANCELED_TR(x) ntatag_s_canceled_tr, tag_uint_v(x)
+#define NTATAG_S_CANCELED_TR(x) ntatag_s_canceled_tr, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_canceled_tr_ref;
 #define NTATAG_S_CANCELED_TR_REF(x)  \
- ntatag_s_canceled_tr_ref, tag_uint_vr(&(x))
+ ntatag_s_canceled_tr_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_request;
-#define NTATAG_S_TRLESS_REQUEST(x) ntatag_s_trless_request, tag_uint_v(x)
+#define NTATAG_S_TRLESS_REQUEST(x) ntatag_s_trless_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_request_ref;
 #define NTATAG_S_TRLESS_REQUEST_REF(x)\
- ntatag_s_trless_request_ref, tag_uint_vr(&(x))
+ ntatag_s_trless_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_to_tr;
-#define NTATAG_S_TRLESS_TO_TR(x) ntatag_s_trless_to_tr, tag_uint_v(x)
+#define NTATAG_S_TRLESS_TO_TR(x) ntatag_s_trless_to_tr, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_to_tr_ref;
 #define NTATAG_S_TRLESS_TO_TR_REF(x)\
- ntatag_s_trless_to_tr_ref, tag_uint_vr(&(x))
+ ntatag_s_trless_to_tr_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_response;
-#define NTATAG_S_TRLESS_RESPONSE(x) ntatag_s_trless_response, tag_uint_v(x)
+#define NTATAG_S_TRLESS_RESPONSE(x) ntatag_s_trless_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_response_ref;
 #define NTATAG_S_TRLESS_RESPONSE_REF(x)\
- ntatag_s_trless_response_ref, tag_uint_vr(&(x))
+ ntatag_s_trless_response_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_200;
-#define NTATAG_S_TRLESS_200(x) ntatag_s_trless_200, tag_uint_v(x)
+#define NTATAG_S_TRLESS_200(x) ntatag_s_trless_200, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_200_ref;
 #define NTATAG_S_TRLESS_200_REF(x)\
- ntatag_s_trless_200_ref, tag_uint_vr(&(x))
+ ntatag_s_trless_200_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_merged_request;
-#define NTATAG_S_MERGED_REQUEST(x) ntatag_s_merged_request, tag_uint_v(x)
+#define NTATAG_S_MERGED_REQUEST(x) ntatag_s_merged_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_merged_request_ref;
 #define NTATAG_S_MERGED_REQUEST_REF(x)\
- ntatag_s_merged_request_ref, tag_uint_vr(&(x))
+ ntatag_s_merged_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_msg;
-#define NTATAG_S_SENT_MSG(x) ntatag_s_sent_msg, tag_uint_v(x)
+#define NTATAG_S_SENT_MSG(x) ntatag_s_sent_msg, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_msg_ref;
 #define NTATAG_S_SENT_MSG_REF(x)\
- ntatag_s_sent_msg_ref, tag_uint_vr(&(x))
+ ntatag_s_sent_msg_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_request;
-#define NTATAG_S_SENT_REQUEST(x) ntatag_s_sent_request, tag_uint_v(x)
+#define NTATAG_S_SENT_REQUEST(x) ntatag_s_sent_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_request_ref;
 #define NTATAG_S_SENT_REQUEST_REF(x)\
- ntatag_s_sent_request_ref, tag_uint_vr(&(x))
+ ntatag_s_sent_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_response;
-#define NTATAG_S_SENT_RESPONSE(x) ntatag_s_sent_response, tag_uint_v(x)
+#define NTATAG_S_SENT_RESPONSE(x) ntatag_s_sent_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_response_ref;
 #define NTATAG_S_SENT_RESPONSE_REF(x)\
- ntatag_s_sent_response_ref, tag_uint_vr(&(x))
+ ntatag_s_sent_response_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_request;
-#define NTATAG_S_RETRY_REQUEST(x) ntatag_s_retry_request, tag_uint_v(x)
+#define NTATAG_S_RETRY_REQUEST(x) ntatag_s_retry_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_request_ref;
 #define NTATAG_S_RETRY_REQUEST_REF(x)\
- ntatag_s_retry_request_ref, tag_uint_vr(&(x))
+ ntatag_s_retry_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_response;
-#define NTATAG_S_RETRY_RESPONSE(x) ntatag_s_retry_response, tag_uint_v(x)
+#define NTATAG_S_RETRY_RESPONSE(x) ntatag_s_retry_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_response_ref;
 #define NTATAG_S_RETRY_RESPONSE_REF(x)\
- ntatag_s_retry_response_ref, tag_uint_vr(&(x))
+ ntatag_s_retry_response_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_retry;
-#define NTATAG_S_RECV_RETRY(x) ntatag_s_recv_retry, tag_uint_v(x)
+#define NTATAG_S_RECV_RETRY(x) ntatag_s_recv_retry, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_retry_ref;
 #define NTATAG_S_RECV_RETRY_REF(x)\
- ntatag_s_recv_retry_ref, tag_uint_vr(&(x))
+ ntatag_s_recv_retry_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_request;
-#define NTATAG_S_TOUT_REQUEST(x) ntatag_s_tout_request, tag_uint_v(x)
+#define NTATAG_S_TOUT_REQUEST(x) ntatag_s_tout_request, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_request_ref;
 #define NTATAG_S_TOUT_REQUEST_REF(x)\
- ntatag_s_tout_request_ref, tag_uint_vr(&(x))
+ ntatag_s_tout_request_ref, tag_usize_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_response;
-#define NTATAG_S_TOUT_RESPONSE(x) ntatag_s_tout_response, tag_uint_v(x)
+#define NTATAG_S_TOUT_RESPONSE(x) ntatag_s_tout_response, tag_usize_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_response_ref;
 #define NTATAG_S_TOUT_RESPONSE_REF(x)\
- ntatag_s_tout_response_ref, tag_uint_vr(&(x))
+ ntatag_s_tout_response_ref, tag_usize_vr(&(x))
 
 SOFIA_END_DECLS
 
index 0ac9be30aca4f64c644a5767c929ae4ca5eeafcc..620f7d3af9ee1b64b676d8eb086d29189e9c1a5b 100644 (file)
@@ -654,7 +654,7 @@ int readfile(FILE *f, void **contents)
 
   *contents = buffer;
 
-  return len;
+  return (int)len;
 }
 
 #if HAVE_DIRENT_H
@@ -663,6 +663,8 @@ int readfile(FILE *f, void **contents)
 
 static int test_bad_messages(agent_t *ag)
 {
+  BEGIN();
+
 #if HAVE_DIRENT_H
   DIR *dir;
   struct dirent *d;
@@ -687,13 +689,10 @@ static int test_bad_messages(agent_t *ag)
   if (dir == NULL) {
     fprintf(stderr, "test_nta: cannot find sip torture messages\n"); 
     fprintf(stderr, "test_nta: tried %s\n", name); 
-    return 0;
   }
 
   offset = strlen(name);
 
-  BEGIN();
-
   TEST_1(ag->ag_default_leg = nta_leg_tcreate(ag->ag_agent, 
                                              leg_callback_500,
                                              ag,
@@ -713,14 +712,14 @@ static int test_bad_messages(agent_t *ag)
   
   TEST(su_getaddrinfo(host, port, hints, &ai), 0); TEST_1(ai);
   s = su_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); TEST_1(s != -1);
-  memset(su, 0, sulen = sizeof su); 
+  memset(su, 0, sulen = ai->ai_addrlen); 
   su->su_len = sizeof su; su->su_family = ai->ai_family;
   TEST_1(bind(s, &su->su_sa, sulen) == 0);
   TEST_1(getsockname(s, &su->su_sa, &sulen) == 0);
   sprintf(via, "v: SIP/2.0/UDP is.invalid:%u\r\n", ntohs(su->su_port));
   vlen = strlen(via);
 
-  for (d = readdir(dir); d; d = readdir(dir)) {
+  for (d = dir ? readdir(dir) : NULL; d; d = readdir(dir)) {
     size_t len = strlen(d->d_name);
     FILE *f;
     int blen, n;
@@ -733,6 +732,7 @@ static int test_bad_messages(agent_t *ag)
     strncpy(name + offset, d->d_name, PATH_MAX - offset);
     TEST_1(f = fopen(name, "rb"));
     TEST_1((blen = readfile(f, &buffer)) > 0);
+    fclose(f);
     r = buffer;
 
     if (strncmp(r, "JUNK ", 5) == 0) {
@@ -751,6 +751,12 @@ static int test_bad_messages(agent_t *ag)
     su_root_step(ag->ag_root, 1);
   }
 
+  TEST_SIZE(su_sendto(s, "\r\n\r\n", 4, 0, (void *)ai->ai_addr, ai->ai_addrlen), 4);
+
+  su_root_step(ag->ag_root, 1);
+
+  TEST_SIZE(su_sendto(s, "", 0, 0, ai->ai_addr, ai->ai_addrlen), 0);
+
   su_close(s);
 
   for (i = 0; i < 20; i++)
@@ -758,12 +764,12 @@ static int test_bad_messages(agent_t *ag)
 
   nta_leg_destroy(ag->ag_default_leg), ag->ag_default_leg = NULL;
 
-  closedir(dir);
+  if (dir)
+    closedir(dir);
 
-  END();
-#else
-  return 0;
 #endif /* HAVE_DIRENT_H */
+
+  END();
 }
 
 static unsigned char const code[] = 
@@ -3357,6 +3363,7 @@ char const nta_test_usage[] =
   "usage: %s OPTIONS\n"
   "where OPTIONS are\n"
   "   -v | --verbose    be verbose\n"
+  "   -a | --abort      abort() on error\n"
   "   -q | --quiet      be quiet\n"
   "   -1                quit on first error\n"
   "   -l level          set logging level (0 by default)\n"
@@ -3368,10 +3375,10 @@ char const nta_test_usage[] =
 #endif
   ;
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, nta_test_usage, name);
-  exit(1);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -3384,6 +3391,8 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--abort") == 0)
+      tstflags |= tst_abort;
     else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0)
       tstflags &= ~tst_verbatim;
     else if (strcmp(argv[i], "-1") == 0)
@@ -3400,7 +3409,7 @@ int main(int argc, char *argv[])
        level = 3, rest = "";
 
       if (rest == NULL || *rest)
-       usage();
+       usage(1);
       
       su_log_set_level(nta_log, level);
       su_log_set_level(tport_log, level);
@@ -3411,7 +3420,7 @@ int main(int argc, char *argv[])
       else if (argv[i + 1])
        ag->ag_obp = (url_string_t *)(argv[++i]);
       else
-       usage();
+       usage(1);
     }
     else if (strncmp(argv[i], "-m", 2) == 0) {
       if (argv[i][2])
@@ -3419,7 +3428,7 @@ int main(int argc, char *argv[])
       else if (argv[i + 1])
        ag->ag_m = argv[++i];
       else
-       usage();
+       usage(1);
     }
     else if (strcmp(argv[i], "--attach") == 0) {
       o_attach = 1;
@@ -3434,7 +3443,7 @@ int main(int argc, char *argv[])
       break;
     }
     else
-      usage();
+      usage(1);
   }
 
   if (o_attach) {
index 84f38cc3edb41f9e5d1c31038990b5f4d9b93a51..46d6c4c4d1ba9925a537a42795432307ba744d91 100644 (file)
@@ -559,18 +559,18 @@ int api_test_stats(agent_t *ag)
 
   nta_agent_t *nta;
 
-  uint32_t irq_hash = -1, orq_hash = -1, leg_hash = -1;
-  uint32_t recv_msg = -1, sent_msg = -1;
-  uint32_t recv_request = -1, recv_response = -1;
-  uint32_t bad_message = -1, bad_request = -1, bad_response = -1;
-  uint32_t drop_request = -1, drop_response = -1;
-  uint32_t client_tr = -1, server_tr = -1, dialog_tr = -1;
-  uint32_t acked_tr = -1, canceled_tr = -1;
-  uint32_t trless_request = -1, trless_to_tr = -1, trless_response = -1;
-  uint32_t trless_200 = -1, merged_request = -1;
-  uint32_t sent_request = -1, sent_response = -1;
-  uint32_t retry_request = -1, retry_response = -1, recv_retry = -1;
-  uint32_t tout_request = -1, tout_response = -1;
+  usize_t irq_hash = -1, orq_hash = -1, leg_hash = -1;
+  usize_t recv_msg = -1, sent_msg = -1;
+  usize_t recv_request = -1, recv_response = -1;
+  usize_t bad_message = -1, bad_request = -1, bad_response = -1;
+  usize_t drop_request = -1, drop_response = -1;
+  usize_t client_tr = -1, server_tr = -1, dialog_tr = -1;
+  usize_t acked_tr = -1, canceled_tr = -1;
+  usize_t trless_request = -1, trless_to_tr = -1, trless_response = -1;
+  usize_t trless_200 = -1, merged_request = -1;
+  usize_t sent_request = -1, sent_response = -1;
+  usize_t retry_request = -1, retry_response = -1, recv_retry = -1;
+  usize_t tout_request = -1, tout_response = -1;
 
   TEST_1(nta = nta_agent_create(ag->ag_root, (url_string_t *)"sip:*:*",
                                NULL, NULL, TAG_END()));
@@ -1238,6 +1238,7 @@ char const nta_test_api_usage[] =
   "usage: %s OPTIONS\n"
   "where OPTIONS are\n"
   "   -v | --verbose    be verbose\n"
+  "   -a | --abort      abort() on error\n"
   "   -q | --quiet      be quiet\n"
   "   -1                quit on first error\n"
   "   -l level          set logging level (0 by default)\n"
@@ -1247,10 +1248,10 @@ char const nta_test_api_usage[] =
 #endif
   ;
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, nta_test_api_usage, name);
-  exit(1);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -1261,9 +1262,11 @@ int main(int argc, char *argv[])
   agent_t ag[1] = {{ { SU_HOME_INIT(ag) }, 0, NULL }};
 
   for (i = 1; argv[i]; i++) {
-    if (strcmp(argv[i], "-v") == 0)
+    if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0)
       tstflags |= tst_verbatim;
-    else if (strcmp(argv[i], "-q") == 0)
+    else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--abort") == 0)
+      tstflags |= tst_abort;
+    else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0)
       tstflags &= ~tst_verbatim;
     else if (strcmp(argv[i], "-1") == 0)
       quit_on_single_failure = 1;
@@ -1279,7 +1282,7 @@ int main(int argc, char *argv[])
        level = 3, rest = "";
 
       if (rest == NULL || *rest)
-       usage();
+       usage(1);
       
       su_log_set_level(nta_log, level);
       su_log_set_level(tport_log, level);
@@ -1297,14 +1300,14 @@ int main(int argc, char *argv[])
       break;
     }
     else
-      usage();
+      usage(1);
   }
 
   if (o_attach) {
-    char line[10];
+    char *response, line[10];
     printf("nua_test: pid %lu\n", (unsigned long)getpid());
     printf("<Press RETURN to continue>\n");
-    fgets(line, sizeof line, stdin);
+    response = fgets(line, sizeof line, stdin);
   }
 #if HAVE_ALARM
   else if (o_alarm) {
index df670a55eff8f32d397f170759427f9c77d1c31d..6117959c58aaebdfe0a0f5c7ea6d6c7574fff9f5 100644 (file)
@@ -63,4 +63,4 @@ EXTRA_DIST =          Doxyfile nth.docs $(BUILT_SOURCES) \
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
index 13b058b81fcf547fa332d196913a559b229e9eb2..db359db23441350f562c918b95aa8c856a37320b 100644 (file)
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
+
+#if HAVE_SIGNAL
 #include <signal.h>
+#endif
 
 typedef struct context_s context_t;
 #define NTH_SITE_MAGIC_T context_t
@@ -77,7 +80,10 @@ static int request(context_t *context,
                   http_t const *http,
                   char const *path);
 su_msg_r server_intr_msg = SU_MSG_R_INIT;
+
+#if HAVE_SIGNAL
 static RETSIGTYPE server_intr_handler(int signum);
+#endif
 static void server_break(context_t *c, su_msg_r msg, su_msg_arg_t *arg);
 
 static msg_payload_t *read_payload(su_home_t *home, char const *fname);
@@ -140,12 +146,12 @@ int main(int argc, char *argv[])
                su_root_task(context->c_root),
                server_break, 0);
 
+#if HAVE_SIGNAL
   signal(SIGINT, server_intr_handler);
-
-#ifndef _WIN32
-  signal(SIGPIPE, server_intr_handler);
+#if HAVE_SIGQUIT
   signal(SIGQUIT, server_intr_handler);
   signal(SIGHUP, server_intr_handler);
+#endif
 #endif
 
   if (context->c_root) {
index 52a1fd5db15e3b92ce8e1cfda7a07aea8660c8db..94e35d57b5e65ba4cc9b8318872b7bde235a4f3a 100644 (file)
@@ -1094,7 +1094,7 @@ int hc_reply(nth_client_t * hc, int status, char const *phrase)
 
   assert(status >= 400);
 
-  SU_DEBUG_5(("nth: hc_reply(%p, %u, %s)\n", hc, status, phrase));
+  SU_DEBUG_5(("nth: hc_reply(%p, %u, %s)\n", (void *)hc, status, phrase));
 
   if (hc->hc_pending) {
     tport_release(hc->hc_tport, hc->hc_pending, hc->hc_request, NULL, hc,
index 288c83a8ec6f4e2f0ab193f6d75087772538e9ae..0eb56bedf8f9ef97e943698234a8fdc3ae90db36 100644 (file)
@@ -704,7 +704,7 @@ server_t *server_create(url_t const *url,
                        tag_type_t tag, tag_value_t value, ...)
 {
   server_t *srv;
-  msg_mclass_t *mclass = NULL;
+  msg_mclass_t const *mclass = NULL;
   tp_name_t tpn[1] = {{ NULL }};
   su_root_t *root = NULL;
   http_server_t const *server = NULL;
index 546d9af010886d3363f6518ee8d3699eb2753565..47e2613e36021e948e57aedb37d8d6b86b59bd38 100644 (file)
@@ -109,7 +109,7 @@ su_inline tag_value_t nthtag_template_vr(struct nth_client_s const **vp)
 {return(tag_value_t)vp;}
 #else
 #define nthtag_template_v(v) ((tag_value_t)(v))
-#define nthtag_template_vr(vp) ((tag_value_t)&(vp))
+#define nthtag_template_vr(vp) ((tag_value_t)(vp))
 #endif
 
 NTH_DLL extern tag_typedef_t nthtag_template;
@@ -126,7 +126,7 @@ su_inline tag_value_t nthtag_message_vr(struct msg_s **vp)
 { return(tag_value_t)vp; }
 #else
 #define nthtag_message_v(v) ((tag_value_t)(v))
-#define nthtag_message_vr(vp) ((tag_value_t)&(vp))
+#define nthtag_message_vr(vp) ((tag_value_t)(vp))
 #endif
 
 NTH_DLL extern tag_typedef_t nthtag_message;
@@ -142,7 +142,7 @@ su_inline tag_value_t nthtag_authentication_v(struct auth_client_s **v) { return
 su_inline tag_value_t nthtag_authentication_vr(struct auth_client_s ***vp) {return(tag_value_t)vp;}
 #else
 #define nthtag_authentication_v(v) ((tag_value_t)(v))
-#define nthtag_authentication_vr(vp) ((tag_value_t)&(vp))
+#define nthtag_authentication_vr(vp) ((tag_value_t)(vp))
 #endif
 
 NTH_DLL extern tag_typedef_t nthtag_authentication;
index 463cb399d9b9c383b4b46131640f13443e39c432..f7f6b63306b2f275dd73b4645d793762862d656a 100644 (file)
@@ -893,10 +893,10 @@ static RETSIGTYPE sig_alarm(int s)
 }
 #endif
 
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v|-q] [-p proxy-uri]\n", name);
-  exit(1);
+  fprintf(stderr, "usage: %s [-v|-q] [-a] [-p proxy-uri]\n", name);
+  exit(exitcode);
 }
 
 int main(int argc, char **argv)
@@ -915,6 +915,8 @@ int main(int argc, char **argv)
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else if (strcmp(argv[i], "-q") == 0)
       tstflags &= ~tst_verbatim;
     else if (strcmp(argv[i], "-p") == 0 && argv[i + 1])
@@ -931,7 +933,7 @@ int main(int argc, char **argv)
       break;
     }
     else
-      usage();
+      usage(1);
   }
 
   t->t_srcdir = srcdir;
index 3957efebabf3e92a254b7bc787efab01cb126175..3a6c8029cad368991556a7390aaeae9397d86c0e 100644 (file)
@@ -30,6 +30,9 @@ ALIASES           += nua="@ref index \"nua\""
 ALIASES                    += NUA_EVENT="@var nua_event_e::"
 ALIASES                    += END_NUA_EVENT="@par &nbsp;"
 
+ALIASES             += \
+  NUA_HPARAM_CALLS="nua_invite(), nua_respond(), nua_ack(), nua_prack(), nua_update(), nua_info(), nua_bye(), nua_options(), nua_message(), nua_register(), nua_publish(), nua_refer(),nua_subscribe(), nua_notify(), nua_refer(), nua_notifier()"
+
 VERBATIM_HEADERS     = NO
 
 @INCLUDE             = ../sip/sip.doxyaliases
index 49b512c51a1042d9b4434a91886bd5f1cc940fff..fcab6520f33c029cfda38d96c553369476c8d5b8 100644 (file)
@@ -80,6 +80,7 @@ test_nua_SOURCES =    test_nua.c test_nua.h test_ops.c \
                        test_init.c \
                        test_nua_api.c test_nua_params.c \
                        test_register.c test_basic_call.c \
+                       test_offer_answer.c \
                        test_call_reject.c test_cancel_bye.c \
                        test_call_hold.c test_session_timer.c \
                        test_refer.c test_100rel.c \
@@ -96,6 +97,6 @@ EXTRA_DIST =          Doxyfile nua.docs $(BUILT_SOURCES)
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 TAG_DLL_FLAGS =                LIST=nua_tag_list
index a1e75fa0c8daf8dbee0d6df09ce630418be986ef..07140603c9fff8090a67423c361c59e893b69344 100644 (file)
@@ -67,7 +67,7 @@ char const nua_version[] = VERSION;
  *
  * The NUA_DEBUG environment variable is used to determine the debug logging
  * level for @nua module. The default level is 3.
- * 
+ *
  * @sa <sofia-sip/su_debug.h>, nua_log, SOFIA_DEBUG
  */
 extern char const NUA_DEBUG[];
@@ -76,8 +76,8 @@ extern char const NUA_DEBUG[];
 #define SU_DEBUG 3
 #endif
 
-/**Debug log for @nua module. 
- * 
+/**Debug log for @nua module.
+ *
  * The nua_log is the log object used by @nua module. The level of
  * #nua_log is set using #NUA_DEBUG environment variable.
  */
@@ -104,16 +104,17 @@ su_log_t nua_log[] = { SU_LOG_INIT("nua", "NUA_DEBUG", SU_DEBUG) };
  *     NUTAG_UICC()             \n
  *     NUTAG_CERTIFICATE_DIR()  \n
  *     and all tags listed in nua_set_params(), \n
- *     and all relevant NTATAG_* are passed to NTA.
+ *     and all relevant NTATAG_* are passed to NTA \n
+ *     and all tport tags listed in <sofia-sip/tport_tag.h>
  *
  * @note
- * From the @VERSION_1_12_2 all the nua_set_params() tags are processed. 
+ * From the @VERSION_1_12_2 all the nua_set_params() tags are processed.
  * Previously all nutags except NUTAG_SOA_NAME() and NUTAG_MEDIA_ENABLE()
  * were ignored.
  *
  * @note
  * Both the NUTAG_URL() and NUTAG_SIPS_URL() are used to pass arguments to
- * nta_agent_add_tport(). 
+ * nta_agent_add_tport().
  *
  * @par Events:
  *     none
@@ -187,9 +188,9 @@ void nua_shutdown(nua_t *nua)
 
 /** Destroy the @nua stack.
  *
- * Before calling nua_destroy() the application 
+ * Before calling nua_destroy() the application
  * should call nua_shutdown and wait for successful #nua_r_shutdown event.
- * Shuts down and destroys the @nua stack. Ongoing calls, registrations, 
+ * Shuts down and destroys the @nua stack. Ongoing calls, registrations,
  * and subscriptions are left as they are.
  *
  * @param nua         Pointer to @nua stack object
@@ -211,7 +212,8 @@ void nua_destroy(nua_t *nua)
 
   if (nua) {
     if (!nua->nua_shutdown_final) {
-      SU_DEBUG_0(("nua_destroy(%p): FATAL: nua_shutdown not completed\n", nua));
+      SU_DEBUG_0(("nua_destroy(%p): FATAL: nua_shutdown not completed\n",
+                 (void *)nua));
       assert(nua->nua_shutdown);
       return;
     }
@@ -242,7 +244,7 @@ nua_magic_t *nua_magic(nua_t *nua)
 
 /** Obtain default operation handle of the @nua stack object.
  *
- * A default operation can be used for operations where the 
+ * A default operation can be used for operations where the
  * ultimate result is not important or can be discarded.
  *
  * @param nua         Pointer to @nua stack object
@@ -262,7 +264,7 @@ nua_handle_t *nua_default(nua_t *nua)
   return nua ? nua->nua_handles : NULL;
 }
 
-/** Create an operation handle 
+/** Create an operation handle
  *
  * Allocates a new operation handle and associated storage.
  *
@@ -275,7 +277,7 @@ nua_handle_t *nua_default(nua_t *nua)
  *
  * @par Related tags:
  *     Duplicates the provided tags for use with every operation. Note that
- *     NUTAG_URL() is converted to SIPTAG_TO() if there is no SIPTAG_TO(). 
+ *     NUTAG_URL() is converted to SIPTAG_TO() if there is no SIPTAG_TO().
  *     And also vice versa, request-URI is taken from SIPTAG_TO() if there
  *     is no NUTAG_URL(). Note that certain SIP headers cannot be saved with
  *     the handle. They include @ContentLength, @CSeq, @RSeq, @RAck, and
@@ -302,7 +304,7 @@ nua_handle_t *nua_handle(nua_t *nua, nua_hmagic_t *hmagic,
     ta_start(ta, tag, value);
 
     nh = nh_create_handle(nua, hmagic, ta_args(ta));
-    
+
     if (nh)
       nh->nh_ref_by_user = 1;
 
@@ -312,7 +314,7 @@ nua_handle_t *nua_handle(nua_t *nua, nua_hmagic_t *hmagic,
   return nh;
 }
 
-/** Bind a callback context to an operation handle. 
+/** Bind a callback context to an operation handle.
  *
  * @param nh          Pointer to operation handle
  * @param hmagic      Pointer to callback context
@@ -334,7 +336,7 @@ void nua_handle_bind(nua_handle_t *nh, nua_hmagic_t *hmagic)
     nh->nh_magic = hmagic;
 }
 
-/** Fetch a callback context from an operation handle. 
+/** Fetch a callback context from an operation handle.
  *
  * @param nh          Pointer to operation handle
  *
@@ -356,7 +358,7 @@ nua_hmagic_t *nua_handle_magic(nua_handle_t *nh)
 
   if (NH_IS_VALID(nh))
     magic = nh->nh_magic;
-  
+
   return magic;
 }
 
@@ -369,8 +371,8 @@ nua_hmagic_t *nua_handle_magic(nua_handle_t *nh)
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0 no invite in operation or operation handle is invalid 
- * @retval 1 operation has invite 
+ * @retval 0 no invite in operation or operation handle is invalid
+ * @retval 1 operation has invite
  *
  * @par Related tags:
  *     none
@@ -383,15 +385,15 @@ int nua_handle_has_invite(nua_handle_t const *nh)
   return nh ? nh->nh_has_invite : 0;
 }
 
-/**Check if operation handle has active event subscriptions. 
+/**Check if operation handle has active event subscriptions.
  *
  * Active subscription can be established either by nua_subscribe() or
  * nua_refer() calls.
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0    no event subscriptions in operation or 
- *              operation handle is invalid 
+ * @retval 0    no event subscriptions in operation or
+ *              operation handle is invalid
  * @retval !=0  operation has event subscriptions
  *
  * @par Related tags:
@@ -416,7 +418,7 @@ int nua_handle_has_events(nua_handle_t const *nh)
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0 no active registration in operation or 
+ * @retval 0 no active registration in operation or
  *           operation handle is invalid
  * @retval 1 operation has registration
  *
@@ -433,12 +435,12 @@ int nua_handle_has_registrations(nua_handle_t const *nh)
   return nh && nh->nh_ds->ds_has_register;
 }
 
-/** Check if operation handle has been used with outgoing SUBSCRIBE of REFER request. 
+/** Check if operation handle has been used with outgoing SUBSCRIBE of REFER request.
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0 no active subscription in operation or 
- *           operation handle is invalid 
+ * @retval 0 no active subscription in operation or
+ *           operation handle is invalid
  * @retval 1 operation has subscription.
  *
  * @par Related tags:
@@ -470,7 +472,7 @@ int nua_handle_has_register(nua_handle_t const *nh)
   return nh ? nh->nh_has_register : 0;
 }
 
-/** Check if operation handle has an active call 
+/** Check if operation handle has an active call
  *
  * @param nh          Pointer to operation handle
  *
@@ -488,17 +490,17 @@ int nua_handle_has_active_call(nua_handle_t const *nh)
   return nh ? nh->nh_active_call : 0;
 }
 
-/** Check if operation handle has a call on hold 
+/** Check if operation handle has a call on hold
  *
- * Please note that this status is not affected by remote end putting 
- * this end on hold. Remote end can put each media separately on hold 
- * and status is reflected on SOATAG_ACTIVE_AUDIO(), SOATAG_ACTIVE_VIDEO() 
+ * Please note that this status is not affected by remote end putting
+ * this end on hold. Remote end can put each media separately on hold
+ * and status is reflected on SOATAG_ACTIVE_AUDIO(), SOATAG_ACTIVE_VIDEO()
  * and SOATAG_ACTIVE_CHAT() tag values in #nua_i_state event.
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0  if no call on hold in operation or operation handle is invalid 
- * @retval 1  if operation has call on hold, for example nua_invite() or 
+ * @retval 0  if no call on hold in operation or operation handle is invalid
+ * @retval 1  if operation has call on hold, for example nua_invite() or
  *            nua_update() has been called with SOATAG_HOLD() with non-NULL
  *            argument.
  *
@@ -515,14 +517,14 @@ int nua_handle_has_call_on_hold(nua_handle_t const *nh)
 
 /** Get the remote address (From/To header) of operation handle
  *
- * Remote address is used as To header in outgoing operations and 
+ * Remote address is used as To header in outgoing operations and
  * derived from From: header in incoming operations.
  *
  * @param nh          Pointer to operation handle
  *
  * @retval NULL   no remote address for operation or operation handle invalid
  * @retval !=NULL pointer to remote address for operation
- *     
+ *
  * @par Related tags:
  *     none
  *
@@ -536,14 +538,14 @@ sip_to_t const *nua_handle_remote(nua_handle_t const *nh)
 
 /** Get the local address (From/To header) of operation handle
  *
- * Local address is used as From header in outgoing operations and 
+ * Local address is used as From header in outgoing operations and
  * derived from To: header in incoming operations.
  *
  * @param nh          Pointer to operation handle
  *
  * @retval NULL   no local address for operation or operation handle invalid
  * @retval !=NULL pointer to local address for operation
- *     
+ *
  * @par Related tags:
  *     none
  *
@@ -590,7 +592,7 @@ void nua_get_params(nua_t *nua, tag_type_t tag, tag_value_t value, ...)
     ta_end(ta); \
   } \
   else { \
-    SU_DEBUG_1(("nua: " #event " with invalid handle %p\n", nh));      \
+    SU_DEBUG_1(("nua: " #event " with invalid handle %p\n", (void *)nh)); \
   }
 
 /* Documented with nua_stack_set_params() */
@@ -658,18 +660,18 @@ void nua_method(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
   NUA_SIGNAL(nh, nua_r_method, tag, value);
 }
 
-/** Send a chat message. 
+/** Send a chat message.
  *
- * A chat channel can be established during call setup using "message" media. 
- * An active chat channel is indicated using #nua_i_state event containing 
- * SOATAG_ACTIVE_CHAT() tag. Chat messages can be sent using this channel with 
- * nua_chat() function. Currently this is implemented using SIP MESSAGE 
+ * A chat channel can be established during call setup using "message" media.
+ * An active chat channel is indicated using #nua_i_state event containing
+ * SOATAG_ACTIVE_CHAT() tag. Chat messages can be sent using this channel with
+ * nua_chat() function. Currently this is implemented using SIP MESSAGE
  * requests but in future MSRP (message session protocol) will replace it.
 *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return 
+ * @return
  *    nothing
  *
  * @par Related Tags:
@@ -707,18 +709,18 @@ void nua_notify(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
 
 /* nua_r_notify is documented with process_response_to_notify() */
 
-/** Create an event server. 
+/** Create an event server.
  *
- * This function create an event server taking care of sending NOTIFY 
- * requests and responding to further SUBSCRIBE requests. The event 
- * server can accept multiple subscriptions from several sources and 
- * takes care for distributing the notifications. Unlike other functions 
+ * This function create an event server taking care of sending NOTIFY
+ * requests and responding to further SUBSCRIBE requests. The event
+ * server can accept multiple subscriptions from several sources and
+ * takes care for distributing the notifications. Unlike other functions
  * this call only accepts the SIP tags listed below.
  *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return 
+ * @return
  *    nothing
  *
  * @par Related Tags:
@@ -736,7 +738,7 @@ void nua_notifier(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
   NUA_SIGNAL(nh, nua_r_notifier, tag, value);
 }
 
-/** Terminate an event server. 
+/** Terminate an event server.
  *
  * Terminate an event server with matching event and content type. The event
  * server was created earlier with nua_notifier() function.
@@ -744,7 +746,7 @@ void nua_notifier(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return 
+ * @return
  *    nothing
  *
  * @par Related Tags:
@@ -809,7 +811,7 @@ void nua_update(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return 
+ * @return
  *    nothing
  *
  * @par Related Tags:
@@ -827,7 +829,7 @@ void nua_authenticate(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
  *
  * After creating a local presence server by nua_notifier(), an incoming
  * SUBSCRIBE request causes #nua_i_subscription event. Each subscriber is
- * identified with NEATAG_SUB() tag in the #nua_i_subscription event. 
+ * identified with NEATAG_SUB() tag in the #nua_i_subscription event.
  * Application can either authorize the subscriber with
  * NUTAG_SUBSTATE(#nua_substate_active) or terminate the subscription with
  * NUTAG_SUBSTATE(#nua_substate_terminated).
@@ -835,7 +837,7 @@ void nua_authenticate(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return 
+ * @return
  *    nothing
  *
  * @par Related Tags:
@@ -875,11 +877,11 @@ void nua_respond(nua_handle_t *nh,
     ta_end(ta);
   }
   else {
-    SU_DEBUG_1(("nua: respond with invalid handle %p\n", nh));
+    SU_DEBUG_1(("nua: respond with invalid handle %p\n", (void *)nh));
   }
 }
 
-/** Destroy a handle 
+/** Destroy a handle
  *
  * Terminate the protocol state associated with an operation handle. The
  * stack discards resources and terminates the ongoing dialog usage,
@@ -893,7 +895,7 @@ void nua_respond(nua_handle_t *nh,
  *
  * @param nh              Pointer to operation handle
  *
- * @return 
+ * @return
  *    nothing
  *
  * @par Related Tags:
@@ -954,11 +956,14 @@ void nua_signal(nua_t *nua, nua_handle_t *nh, msg_t *msg, int always,
     e->e_status = status;
     e->e_phrase = phrase;
 
-    if (su_msg_send(sumsg) != 0)
+    SU_DEBUG_7(("nua(%p): signal %s\n", (void *)nh,
+               nua_event_name(event) + 4));
+
+    if (su_msg_send(sumsg) != 0 && event != nua_r_destroy)
       nua_handle_unref(nh);
-  } 
+  }
   else {
-    /* XXX  - we should return error code to application */
+    /* XXX  - we should return error code to application but we just abort() */
     assert(ENOMEM == 0);
   }
 
@@ -981,8 +986,16 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
   }
 
   if (!nh || !nh->nh_valid) {  /* Handle has been destroyed */
+    if (nua_log->log_level >= 7) {
+      char const *name = nua_event_name(e->e_event) + 4;
+      SU_DEBUG_7(("nua(%p): event %s dropped\n", (void *)nh, name));
+    }
     if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
-      SU_DEBUG_9(("nua(%p): freed by application\n", nh));
+#if HAVE_NUA_HANDLE_DEBUG
+      SU_DEBUG_0(("nua(%p): freed by application\n", (void *)nh));
+#else
+      SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
+#endif
     }
     if (e->e_msg)
       msg_destroy(e->e_msg), e->e_msg = NULL;
@@ -1011,7 +1024,11 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
                    e->e_tags);
 
   if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
-    SU_DEBUG_9(("nua(%p): freed by application\n", nh));
+#if HAVE_NUA_HANDLE_DEBUG
+    SU_DEBUG_0(("nua(%p): freed by application\n", (void *)nh));
+#else
+    SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
+#endif
   }
 
   if (!su_msg_is_non_null(nua->nua_current))
@@ -1066,7 +1083,7 @@ void nua_destroy_event(nua_saved_event_t saved[1])
       msg_destroy(e->e_msg), e->e_msg = NULL;
 
     if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
-      SU_DEBUG_9(("nua(%p): freed by application\n", nh));
+      SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
     }
 
     su_msg_destroy(saved);
@@ -1093,21 +1110,36 @@ static int nua_stack_handle_make_replaces_call(void *arg)
 
 
 /**Generate a @Replaces header for handle.
+ *
+ * A @Replaces header contains the @CallID value, @From and @To tags
+ * corresponding to SIP dialog associated with handle @a nh. Note that the
+ * @Replaces matches with dialog of the remote peer,
+ * nua_handle_by_replaces() does not return same handle (unless you swap
+ * rp_from_tag and rp_to_tag in @Replaces header).
+ *
+ * A @Replaces header is used in attended transfer, among other things.
+ *
+ * @param nh pointer to operation handle
+ * @param home memory home used to allocate the header
+ * @param early_only if true, include "early-only" parameter in @Replaces, too
+ *
+ * @return A newly created @Replaces header.
  *
  * @since New in @VERSION_1_12_4.
  *
- * @sa nua_handle_by_replaces(), @Replaces, @RFC3891, nua_refer(),
- * #nua_i_refer, @ReferTo, nta_leg_make_replaces()
+ * @sa nua_handle_by_replaces(), @Replaces, @RFC3891, @RFC3515, nua_refer(),
+ * #nua_i_refer(), @ReferTo, nta_leg_make_replaces(),
+ * sip_headers_as_url_query()
  */
-sip_replaces_t *nua_handle_make_replaces(nua_handle_t *nh, 
+sip_replaces_t *nua_handle_make_replaces(nua_handle_t *nh,
                                         su_home_t *home,
                                         int early_only)
 {
   if (nh && nh->nh_valid && nh->nh_nua) {
     struct nua_stack_handle_make_replaces_args a = { NULL, nh, home, early_only };
 
-    if (su_task_execute(nh->nh_nua->nua_server, 
-                       nua_stack_handle_make_replaces_call, (void *)&a, 
+    if (su_task_execute(nh->nh_nua->nua_server,
+                       nua_stack_handle_make_replaces_call, (void *)&a,
                        NULL) == 0) {
       return a.retval;
     }
@@ -1134,9 +1166,9 @@ static int nua_stack_handle_by_replaces_call(void *arg)
  *
  * @since New in @VERSION_1_12_4.
  *
- * @note 
+ * @note
  * You should release the reference with nua_handle_unref() when you are
- * done with handle.
+ * done with the handle.
  *
  * @sa nua_handle_make_replaces(), @Replaces, @RFC3891, nua_refer(),
  * #nua_i_refer, @ReferTo, nta_leg_by_replaces()
@@ -1146,8 +1178,8 @@ nua_handle_t *nua_handle_by_replaces(nua_t *nua, sip_replaces_t const *r)
   if (nua) {
     struct nua_stack_handle_by_replaces_args a = { NULL, nua, r };
 
-    if (su_task_execute(nua->nua_server, 
-                       nua_stack_handle_by_replaces_call, (void *)&a, 
+    if (su_task_execute(nua->nua_server,
+                       nua_stack_handle_by_replaces_call, (void *)&a,
                        NULL) == 0) {
       nua_handle_t *nh = a.retval;
 
index f259e78afbbe090da8c760109f9b339dd95c7d3b..0d322ca96d5d54d0380189daa01c3514876a13e3 100644 (file)
@@ -1124,7 +1124,7 @@ follows:
     <td>terminating</td>
     <td>Process answer</td>
     <td>
-   If there was an failure in SDP negotiation or other failure with media,
+   If there was a failure in SDP negotiation or other failure with media,
    the stack will automatically terminate the call. The BYE follows
    immediatelhy after the ACK.
 </td></tr>
@@ -1262,7 +1262,7 @@ does not include the extensions like @b 100rel or @b UPDATE.
      |    +---------------|            |    :         |     :
      |    |               +------------+    :         |     :
      |    |                           |     :         |     :
-     |    |          nua_respond/18X (2   :         |     :
+     |    |          nua_respond/18X (2a)   :         |     :
      |    |                           |     :         |     :
      |    |                           V     V         |     :
      |    |                          +------------+   |     :
@@ -2029,7 +2029,8 @@ NUTAG_AUTOANSWER(0) on B side, NUTAG_AUTOACK(0) on A side.
  *               Always present
  * @param nh     Pointer to operation handle.
  * @param hmagic Pointer to callback context from nua_handle().
- * @param sip    Parsed incoming message. May be NULL.
+ * @param sip    Headers in parsed incoming message. May be NULL.
+ *               See also nua_current_request().
  * @param tags   Tag list containing more information about the state of NUA.
  *               May be empty.
  *
@@ -2038,17 +2039,22 @@ NUTAG_AUTOANSWER(0) on B side, NUTAG_AUTOACK(0) on A side.
  * individual event.
  *
  * The events can be divided into the following categories: \n
- * @par Indications:
+ * @par Status or Error Indications:
  * #nua_i_active           \n
+ * #nua_i_error            \n
+ * #nua_i_fork             \n
+ * #nua_i_media_error      \n
+ * #nua_i_subscription     \n
+ * #nua_i_state            \n
+ * #nua_i_terminated
+ *
+ * @par SIP requests:
  * #nua_i_ack              \n
  * #nua_i_bye              \n
  * #nua_i_cancel           \n
  * #nua_i_chat             \n
- * #nua_i_error            \n
- * #nua_i_fork             \n
  * #nua_i_info             \n
  * #nua_i_invite           \n
- * #nua_i_media_error      \n
  * #nua_i_message          \n
  * #nua_i_method           \n
  * #nua_i_notify           \n
@@ -2058,9 +2064,6 @@ NUTAG_AUTOANSWER(0) on B side, NUTAG_AUTOACK(0) on A side.
  * #nua_i_refer            \n
  * #nua_i_register         \n
  * #nua_i_subscribe        \n
- * #nua_i_subscription     \n
- * #nua_i_state            \n
- * #nua_i_terminated       \n
  * #nua_i_update
  *
  * @par Responses:
@@ -2122,7 +2125,8 @@ NUTAG_AUTOANSWER(0) on B side, NUTAG_AUTOACK(0) on A side.
  *
  * Outgoing call has been forked.
  *
- * This is sent when an INVITE request is answered with multiple 200 responses.
+ * This is sent when an INVITE request is answered with multiple 2XX series
+ * responses.
  *
  * @param status response status code
  * @param phrase a short textual description of @a status code
@@ -2219,7 +2223,7 @@ NUTAG_AUTOANSWER(0) on B side, NUTAG_AUTOACK(0) on A side.
  * @param nh     operation handle associated with the notifier
  * @param hmagic operation magic associated with the notifier
  * @param sip    response to MESSAGE request or NULL upon an error
- *               (error code and message are in status an phrase parameters)
+ *               (error code and message are in status and phrase parameters)
  * @param tags   empty
  *
  * @sa nua_chat(), #nua_r_message
index f979ccc8005877515aa4663e24da1f715be9a0b1..934df00cd7228581c15168594138b98b1082c574 100644 (file)
@@ -110,13 +110,14 @@ nua_handle_t *nh_create_handle(nua_t *nua,
   assert(nua->nua_home);
 
   if ((nh = su_home_clone(nua->nua_home, sizeof(*nh)))) {
-    nh->nh_valid = nua_handle;
+    nh->nh_valid = nua_valid_handle_cookie;
     nh->nh_nua = nua;
     nh->nh_magic = hmagic;
     nh->nh_prefs = nua->nua_dhandle->nh_prefs;
 
     if (nua_handle_save_tags(nh, tags) < 0) {
-      SU_DEBUG_5(("nua(%p): creating handle %p failed\n", nua, nh));
+      SU_DEBUG_5(("nua(%p): creating handle %p failed\n",
+                 (void *)nua, (void *)nh));
       su_home_unref(nh->nh_home), nh = NULL;
     }
     
@@ -136,7 +137,7 @@ nua_handle_t *nh_create_handle(nua_t *nua,
       } 
       else {
        _handle_lifetime = 2;
-       SU_DEBUG_0(("nh_handle_create(%p)\n", nh));
+       SU_DEBUG_0(("nh_handle_create(%p)\n", (void *)nh));
        su_home_destructor(nh->nh_home, nh_destructor);
       }
     }
@@ -159,10 +160,12 @@ extern char const _NUA_HANDLE_DEBUG[];
 static void nh_destructor(void *arg)
 {
   nua_handle_t *nh = arg;
-
-  SU_DEBUG_0(("nh_destructor(%p)\n", nh));
+  SU_DEBUG_0(("nh_destructor(%p)\n", (void *)nh));
 }
 
+#undef nua_handle_ref
+#undef nua_handle_unref
+
 /** Make a new reference to handle.
  *
  * The handles use reference counting for memory management. In addition to
@@ -180,7 +183,6 @@ nua_handle_t *nua_handle_ref(nua_handle_t *nh)
   return (nua_handle_t *)su_home_ref(nh->nh_home);
 }
 
-
 /** Destroy reference to handle. 
  *
  * The handles use reference counting for memory management. In addition to
@@ -214,6 +216,50 @@ char const *nua_generate_instance_identifier(su_home_t *home)
   return su_strdup(home, str);
 }
 
+/** Check if event is a request that can be responded with nua_respond().
+ *
+ * Note that if event status is 200 or greater, it already has been
+ * responded. This function is provided for compatibility with future
+ * versions of nua. An unknown event can always be handled in the event
+ * callback like this:
+ * @code
+ * switch (event) {
+ *   ...
+ *   default:
+ *     if (status < 200 && nua_event_is_incoming_request(event))
+ *       nua_respond(nh, SIP_501_NOT_IMPLEMENTED,
+ *                   NUTAG_WITH_THIS(nua), TAG_END());
+ *     if (hmagic == NULL)
+ *       nua_handle_destroy(nh);
+ *     return;
+ *   ...
+ * @endcode
+ *
+ * @sa #nua_event_t, nua_respond()
+ *
+ * @NEW_1_12_6
+ */
+int nua_event_is_incoming_request(nua_event_t event)
+{
+  switch (event) {
+  case nua_i_invite: return 1;
+  case nua_i_cancel: return 1;
+  case nua_i_register: return 1;
+  case nua_i_bye: return 1;
+  case nua_i_options: return 1;
+  case nua_i_refer: return 1;
+  case nua_i_publish: return 1;
+  case nua_i_prack: return 1;
+  case nua_i_info: return 1;
+  case nua_i_update: return 1;
+  case nua_i_message: return 1;
+  case nua_i_subscribe: return 1;
+  case nua_i_notify: return 1;
+  case nua_i_method: return 1;
+  default: return 0;
+  }
+}
+
 /** Get name for a NUA event. */
 char const *nua_event_name(nua_event_t event)
 {
@@ -301,3 +347,34 @@ char const *nua_callstate_name(enum nua_callstate state)
   default: return "UNKNOWN";
   }
 }
+
+/** Return name of subscription state. @NEW_1_12_5. */
+char const *nua_substate_name(enum nua_substate substate)
+{
+  switch (substate) {
+  case nua_substate_embryonic:
+      /*FALLTHROUGH*/
+  case nua_substate_pending:
+    return "pending";
+  case nua_substate_terminated:
+    return "terminated";
+  case nua_substate_active:
+      /*FALLTHROUGH*/
+  default:
+    return "active";
+  }
+}
+
+/** Convert string to enum nua_substate. @NEW_1_12_5. */
+enum nua_substate nua_substate_make(char const *sip_substate)
+{
+  if (sip_substate == NULL)
+    return nua_substate_active;
+  else if (strcasecmp(sip_substate, "terminated") == 0)
+    return nua_substate_terminated;
+  else if (strcasecmp(sip_substate, "pending") == 0)
+    return nua_substate_pending;
+  else /* if (strcasecmp(sip_substate, "active") == 0) */ 
+    return nua_substate_active;
+}
+
index 781c89ef3f7eb2cc6cd4c8cca7410033ebe986ad..185c35c5f986a7d22c9f39173c9119d988390753 100644 (file)
@@ -269,7 +269,7 @@ nua_dialog_usage_t *nua_dialog_usage_add(nua_owner_t *own,
     du = *prev_du;
     if (du) {          /* Already exists */
       SU_DEBUG_5(("nua(%p): adding already existing %s usage%s%s\n",
-                 own, nua_dialog_usage_name(du), 
+                 (void *)own, nua_dialog_usage_name(du), 
                  event ? "  with event " : "", event ? event->o_type : ""));
       
       if (prev_du != &ds->ds_usage) {
@@ -297,7 +297,7 @@ nua_dialog_usage_t *nua_dialog_usage_add(nua_owner_t *own,
       }
        
       SU_DEBUG_5(("nua(%p): adding %s usage%s%s\n",
-                 own, nua_dialog_usage_name(du), 
+                 (void *)own, nua_dialog_usage_name(du), 
                  o ? " with event " : "", o ? o->o_type :""));
 
       su_home_ref(own);
@@ -345,6 +345,24 @@ void nua_dialog_usage_remove_at(nua_owner_t *own,
     nua_client_request_t *cr, *cr_next;
     nua_server_request_t *sr, *sr_next;
 
+    *at = du->du_next;
+
+    o = du->du_event;
+
+    SU_DEBUG_5(("nua(%p): removing %s usage%s%s\n",
+               (void *)own, nua_dialog_usage_name(du), 
+               o ? " with event " : "", o ? o->o_type :""));
+    du->du_class->usage_remove(own, ds, du);
+
+    /* Destroy saved client request */
+    if (nua_client_is_bound(du->du_cr)) {
+      nua_client_bind(cr = du->du_cr, NULL);
+      if (!nua_client_is_queued(cr) &&
+         !nua_client_is_reporting(cr))
+       nua_client_request_destroy(cr);
+    }
+
+    /* Clean references from queued client requests */
     for (cr = ds->ds_cr; cr; cr = cr_next) {
       cr_next = cr->cr_next;
       if (cr->cr_usage == du)
@@ -357,29 +375,19 @@ void nua_dialog_usage_remove_at(nua_owner_t *own,
        nua_server_request_destroy(sr);
     }
 
-    *at = du->du_next;
-
-    o = du->du_event;
-
-    SU_DEBUG_5(("nua(%p): removing %s usage%s%s\n",
-               own, nua_dialog_usage_name(du), 
-               o ? " with event " : "", o ? o->o_type :""));
-    du->du_class->usage_remove(own, ds, du);
-    msg_destroy(du->du_msg), du->du_msg = NULL;
     su_home_unref(own);
     su_free(own, du);
   }
 
-  /* Zap dialog if there is no more usages */
-  if (ds->ds_usage == NULL) {
-    nta_leg_destroy(ds->ds_leg), ds->ds_leg = NULL;
-    su_free(own, (void *)ds->ds_remote_tag), ds->ds_remote_tag = NULL;
-    ds->ds_route = 0;
+  /* Zap dialog if there are no more usages */
+  if (ds->ds_terminating)
+    ;
+  else if (ds->ds_usage == NULL) {
+    nua_dialog_remove(own, ds, NULL);
     ds->ds_has_events = 0;
-    ds->ds_terminated = 0;
     return;
   }
-  else if (!ds->ds_terminated) {
+  else {
     nua_dialog_log_usage(own, ds);
   }
 }
@@ -412,7 +420,7 @@ void nua_dialog_log_usage(nua_owner_t *own, nua_dialog_state_t *ds)
       }
     }
     
-    SU_DEBUG_3(("nua(%p): handle with %s%s%s\n", own,
+    SU_DEBUG_3(("nua(%p): handle with %s%s%s\n", (void *)own,
                ds->ds_has_session ? "session and " : "", 
                ds->ds_has_events ? "events " : "",
                buffer));
@@ -423,49 +431,16 @@ void nua_dialog_log_usage(nua_owner_t *own, nua_dialog_state_t *ds)
 void nua_dialog_deinit(nua_owner_t *own,
                       nua_dialog_state_t *ds)
 {
-  while (ds->ds_usage) {
-    nua_dialog_usage_remove_at(own, ds, &ds->ds_usage);
-  }
-}
-
-
-/** @internal Dialog has been terminated. Remove all usages. */
-void nua_dialog_terminated(nua_owner_t *own,
-                          struct nua_dialog_state *ds,
-                          int status,
-                          char const *phrase)
-{
-
-  ds->ds_terminated = 1;
+  ds->ds_terminating = 1;
 
   while (ds->ds_usage) {
-#if 0
-    int call = 0;
-
-    if (ds->ds_usage->du_kind == nua_session_usage)
-      call = 1;                        /* Delay sending the event */
-    else
-      /* XXX */;
-#endif
     nua_dialog_usage_remove_at(own, ds, &ds->ds_usage);
   }
-}
 
-/**@internal
- * Set expiration time. 
- */
-void nua_dialog_usage_set_expires(nua_dialog_usage_t *du,
-                                 unsigned delta)
-{
-  if (delta) {
-    sip_time_t now = sip_now(), expires = now + delta;
-    if (expires < now)
-      expires = SIP_TIME_MAX;
-    du->du_expires = expires;
-    nua_dialog_usage_set_refresh(du, delta);
-  }
-  else
-    du->du_expires = 0, du->du_refresh = 0;
+  nua_dialog_remove(own, ds, NULL);
+
+  ds->ds_has_events = 0;
+  ds->ds_terminating = 0;
 }
 
 /**@internal
@@ -521,10 +496,20 @@ void nua_dialog_usage_refresh_range(nua_dialog_usage_t *du,
   du->du_refresh = target;
 }
 
+/** Set absolute refresh time */
+void nua_dialog_usage_refresh_at(nua_dialog_usage_t *du,
+                                sip_time_t target)
+{
+  SU_DEBUG_7(("nua(): refresh %s after %lu seconds\n",
+             nua_dialog_usage_name(du), target - sip_now()));
+  du->du_refresh = target;
+} 
+
 /**@internal Do not refresh. */
 void nua_dialog_usage_reset_refresh(nua_dialog_usage_t *du)
 {
-  du->du_refresh = 0;
+  if (du)
+    du->du_refresh = 0;
 }
 
 /** @internal Refresh usage or shutdown usage if @a now is 0. */
@@ -537,18 +522,52 @@ void nua_dialog_usage_refresh(nua_owner_t *owner,
     du->du_refresh = 0;
 
     if (now > 0) {
-      if (du->du_class->usage_refresh) {
-       du->du_class->usage_refresh(owner, ds, du, now);
-       return;
-      }
+      assert(du->du_class->usage_refresh);
+      du->du_class->usage_refresh(owner, ds, du, now);
     }
     else {
       du->du_shutdown = 1;
-      if (du->du_class->usage_shutdown) {
-       du->du_class->usage_shutdown(owner, ds, du);
-       return;
-      }
+      assert(du->du_class->usage_shutdown);
+      du->du_class->usage_shutdown(owner, ds, du);
     }
   }
 }
 
+/** Terminate all dialog usages gracefully. */
+int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds)
+{
+  nua_dialog_usage_t *du;
+
+  ds->ds_terminating = 1;
+
+  do {
+    for (du = ds->ds_usage; du; du = du->du_next) {
+      if (!du->du_shutdown) {
+       nua_dialog_usage_shutdown(owner, ds, du);
+       break;
+      }
+    }
+  } while (du);
+
+  return 1;
+}
+
+/** (Gracefully) terminate usage.
+ *
+ * @retval >0  shutdown done
+ * @retval 0   shutdown in progress
+ * @retval <0  try again later
+ */
+int nua_dialog_usage_shutdown(nua_owner_t *owner,
+                              nua_dialog_state_t *ds,
+                              nua_dialog_usage_t *du)
+{
+  if (du) {
+    du->du_refresh = 0;
+    du->du_shutdown = 1;
+    assert(du->du_class->usage_shutdown);
+    return du->du_class->usage_shutdown(owner, ds, du);
+  }
+  else
+    return 200;
+}
index 2a23e56ea28defa7a7a3f1d469fef4d47a731a71..1edeb2bd366f142002eb79a743ef02c6c5b646c5 100644 (file)
@@ -48,49 +48,93 @@ typedef NUA_OWNER_T nua_owner_t;
 #include <sofia-sip/nta.h>
 #endif
 
+typedef su_msg_r nua_saved_signal_t;
+
 typedef struct nua_server_request nua_server_request_t; 
 typedef struct nua_client_request nua_client_request_t; 
 
-/** Respond to an incoming request. */
-typedef int nua_server_respond_f(nua_server_request_t *, tagi_t const *);
+typedef struct {
+  sip_method_t sm_method; 
+  char const *sm_method_name;
+
+  int sm_event;
+
+  struct {
+    unsigned create_dialog:1, in_dialog:1, target_refresh:1, add_contact:1;
+    unsigned :0;
+  } sm_flags;
+
+  /** Initialize server-side request. */
+  int (*sm_init)(nua_server_request_t *sr);
+
+  /** Preprocess server-side request (after handle has been created). */
+  int (*sm_preprocess)(nua_server_request_t *sr);
+
+  /** Update server-side request parameters */
+  int (*sm_params)(nua_server_request_t *sr, tagi_t const *tags);
+
+  /** Respond to server-side request. */
+  int (*sm_respond)(nua_server_request_t *sr, tagi_t const *tags);
 
-/** Restart an outgoing request. */
-typedef void nua_creq_restart_f(nua_owner_t *, tagi_t *tags);
+  /** Report server-side request to application. */
+  int (*sm_report)(nua_server_request_t *sr, tagi_t const *tags);
+
+} nua_server_methods_t;
 
 /** Server side transaction */
 struct nua_server_request {
   struct nua_server_request *sr_next, **sr_prev;
 
+  nua_server_methods_t const *sr_methods;
+
   nua_owner_t *sr_owner;       /**< Backpointer to handle */
   nua_dialog_usage_t *sr_usage;        /**< Backpointer to usage */
 
-  /** When the application responds to an request with
-   * nua_respond(), the sr_respond() is called
-   */
-  nua_server_respond_f *sr_respond;
-  
   nta_incoming_t *sr_irq;      /**< Server transaction object */
-  msg_t *sr_msg;               /**< Request message */
+  
+  struct {
+    msg_t *msg;                        /**< Request message */
+    sip_t const *sip;          /**< Headers in request message */
+  } sr_request;
+
+  struct {
+    msg_t *msg;                        /**< Response message */
+    sip_t *sip;                        /**< Headers in response message */
+  } sr_response;
 
   sip_method_t sr_method;      /**< Request method */
+
+  int sr_application;          /**< Status by application */
+
   int sr_status;               /**< Status code */
   char const *sr_phrase;       /**< Status phrase */
 
-  unsigned sr_auto:1;          /**< Autoresponse - no event has been sent */
+  unsigned sr_event:1;         /**< Reported to application */
   unsigned sr_initial:1;       /**< Handle was created by this request */
+  unsigned sr_add_contact:1;   /**< Add Contact header to the response */
+  unsigned sr_target_refresh:1;        /**< Refresh target */
+  unsigned sr_terminating:1;   /**< Terminate usage after final response */
+  unsigned sr_gracefully:1;    /**< Terminate usage gracefully */
+
+  unsigned sr_neutral:1;       /**< No effect on session or other usage */
+
+  /* Flags used with 100rel */
+  unsigned sr_100rel:1, sr_pracked:1;
 
   /* Flags used with offer-answer */
   unsigned sr_offer_recv:1;    /**< We have received an offer */
   unsigned sr_answer_sent:2;   /**< We have answered (reliably, if >1) */
 
-  unsigned sr_offer_sent:1;    /**< We have offered SDP */
+  unsigned sr_offer_sent:2;    /**< We have offered SDP (reliably, if >1) */
   unsigned sr_answer_recv:1;   /**< We have received SDP answer */
-};
+  unsigned :0;
 
-#define SR_INIT(sr)                         \
-  ((void)memset((sr), 0, sizeof (sr)[0]),    \
-   (void)(SR_STATUS1((sr), SIP_100_TRYING)), \
-   sr)
+  char const *sr_sdp;          /**< SDP received from client */
+  size_t sr_sdp_len;           /**< SDP length */
+
+  /**< Save 200 OK nua_respond() signal until PRACK has been received */
+  nua_saved_signal_t sr_signal;        
+};
 
 #define SR_STATUS(sr, status, phrase) \
   ((sr)->sr_phrase = (phrase), (sr)->sr_status = (status))
@@ -104,46 +148,194 @@ int sr_status(nua_server_request_t *sr, int status, char const *phrase)
   return (void)(sr->sr_phrase = phrase), (sr->sr_status = status);
 }
 
+/** Methods for client request */
+typedef struct {
+  sip_method_t crm_method;
+  char const *crm_method_name;
+  size_t crm_extra;            /**< Size of private data */
+
+  struct {
+    unsigned create_dialog:1, in_dialog:1, target_refresh:1;
+    unsigned:0;
+  } crm_flags;
+
+  /** Generate a request message.
+   *
+   * @retval 1 when request message has been created
+   * @retval 0 when request message should be created in normal fashion
+   * @retval -1 upon an error
+   */
+  int (*crm_template)(nua_client_request_t *cr,
+                     msg_t **return_msg,
+                     tagi_t const *tags);
+
+  /**@a crm_init is called when a client request is sent first time. 
+   *
+   * @retval 1 when request has been responded
+   * @retval 0 when request should be sent in normal fashion
+   * @retval -1 upon an error
+   */
+  int (*crm_init)(nua_client_request_t *, msg_t *msg, sip_t *sip,
+                 tagi_t const *tags);
+
+  /** @a crm_send is called each time when a client request is sent.
+   *
+   * @retval 1 when request has been responded
+   * @retval 0 when request has been sent
+   * @retval -1 upon an error (request message has not been destroyed)
+   * @retval -2 upon an error (request message has been destroyed)
+   */
+  int (*crm_send)(nua_client_request_t *,
+                 msg_t *msg, sip_t *sip,
+                 tagi_t const *tags);
+
+  /** @a crm_check_restart is called each time when a response is received.
+   *
+   * It is used to restart reqquest after responses with method-specific
+   * status code or method-specific way of restarting the request.
+   *
+   * @retval 1 when request has been restarted
+   * @retval 0 when response should be processed normally
+   */
+  int (*crm_check_restart)(nua_client_request_t *,
+                          int status, char const *phrase,
+                          sip_t const *sip);
+
+  /** @a crm_recv is called each time a final response is received.
+   *
+   * A final response is in range 200 .. 699 (or internal response) and it
+   * cannot be restarted.
+   *
+   * crm_recv() should call nua_base_client_response() or
+   * nua_base_client_tresponse(). The return values below are documented with
+   * nua_base_client_response(), too.
+   *
+   * @retval 0 if response was preliminary
+   * @retval 1 if response was final
+   * @retval 2 if response destroyed the handle, too.
+   */
+  int (*crm_recv)(nua_client_request_t *,
+                 int status, char const *phrase,
+                 sip_t const *sip);
+
+  /** @a crm_preliminary is called each time a preliminary response is received.
+   *
+   * A preliminary response is in range 101 .. 199.
+   *
+   * crm_preliminary() should call nua_base_client_response() or
+   * nua_base_client_tresponse().
+   *
+   * @retval 0 if response was preliminary
+   * @retval 1 if response was final
+   * @retval 2 if response destroyed the handle, too.
+   */
+  int (*crm_preliminary)(nua_client_request_t *,
+                        int status, char const *phrase,
+                        sip_t const *sip);
+
+  /** @a crm_report is called each time a response is received and it is
+   * reported to the application.
+   *
+   * The status and phrase may be different from the status and phrase
+   * received from the network, e.g., when the request is restarted.
+   *
+   * @return The return value should be 0. It is currently ignored.
+   */
+  int (*crm_report)(nua_client_request_t *,
+                   int status, char const *phrase,
+                   sip_t const *sip,
+                   nta_outgoing_t *orq,
+                   tagi_t const *tags);
+
+  /** @a crm_deinit is called when a client-side request is destroyed.
+   *
+   * @return The return value should be 0. It is currently ignored.
+   */
+  int (*crm_deinit)(nua_client_request_t *);
+
+} nua_client_methods_t;
+
+/* Client-side request. Documented by nua_client_create() */
 struct nua_client_request
 {
-  nua_client_request_t *cr_next;        /**< Linked list of requests */
-  /*nua_event_t*/ int cr_event;                /**< Request event */
-  nua_creq_restart_f *cr_restart;
-  nta_outgoing_t     *cr_orq;
-  msg_t              *cr_msg;
+  nua_client_request_t *cr_next, **cr_prev; /**< Linked list of requests */
+  nua_owner_t        *cr_owner;
   nua_dialog_usage_t *cr_usage;
+
+  nua_saved_signal_t cr_signal;
+  tagi_t const      *cr_tags;
+
+  nua_client_methods_t const *cr_methods;
+
+  msg_t              *cr_msg;
+  sip_t              *cr_sip;
+
+  nta_outgoing_t     *cr_orq;
+
+  /*nua_event_t*/ int cr_event;                /**< Request event */
+  sip_method_t        cr_method;
+  char const         *cr_method_name;
+
+  url_t              *cr_target;
+
+  uint32_t            cr_seq;
+
+  unsigned short      cr_status;        /**< Latest status */
+
   unsigned short      cr_retry_count;   /**< Retry count for this request */
 
   /* Flags used with offer-answer */
   unsigned short      cr_answer_recv;   /**< Recv answer in response 
                                         *  with this status.
                                         */
-  unsigned            cr_offer_sent:1;  /**< Sent offer in this request */
-
-  unsigned            cr_offer_recv:1;  /**< Recv offer in a response */
-  unsigned            cr_answer_sent:1; /**< Sent answer in (PR)ACK */
-
-  unsigned            cr_has_contact:1; /**< Request has application contact */
+  unsigned cr_offer_sent:1;    /**< Sent offer in this request */
+
+  unsigned cr_offer_recv:1;    /**< Recv offer in a response */
+  unsigned cr_answer_sent:1;   /**< Sent answer in (PR)ACK */
+
+  /* Flags with usage */
+  unsigned cr_neutral:1;       /**< No effect on session or other usage */
+
+  /* Lifelong flags? */
+  unsigned cr_auto:1;          /**< Request was generated by stack */
+  unsigned cr_has_contact:1;   /**< Request has user Contact */
+  unsigned cr_contactize:1;    /**< Request needs Contact */
+  unsigned cr_dialog:1;                /**< Request can initiate dialog */
+
+  /* Current state */
+  unsigned cr_challenged:1;    /**< Request was challenged */
+  unsigned cr_wait_for_cred:1; /**< Request is pending authentication */
+  unsigned cr_restarting:1;    /**< Request is being restarted */
+  unsigned cr_reporting:1;     /**< Reporting in progress */
+  unsigned cr_terminating:1;   /**< Request terminates the usage */
+  signed int cr_terminated:2;  /**< Response terminated usage (1) or 
+                                   whole dialog (-1) */
+  unsigned cr_graceful:1;      /**< Graceful termination required */
 };
 
 
 struct nua_dialog_state
 {
-  nua_client_request_t ds_cr[1];
-  nua_server_request_t *ds_sr;
-
   /** Dialog usages. */
   nua_dialog_usage_t     *ds_usage;
 
+  /** Client requests */
+  nua_client_request_t   *ds_cr;
+  /** Server requests */
+  nua_server_request_t *ds_sr;
+
   /* Dialog and subscription state */
+  unsigned ds_reporting:1;     /**< We are reporting */
+
   unsigned ds_route:1;         /**< We have route */
-  unsigned ds_terminated:1;    /**< Being terminated */
+  unsigned ds_terminating:1;   /**< Being terminated */
 
   unsigned ds_has_session:1;   /**< We have session */
   unsigned ds_has_register:1;  /**< We have registration */
   unsigned ds_has_publish:1;   /**< We have publish */
 
-  unsigned ds_has_referrals:1; /**< We have (or have had) referrals */
+  unsigned ds_got_session:1;   /**< We have (or have had) session */
+  unsigned ds_got_referrals:1; /**< We have (or have had) referrals */
 
   unsigned :0;
 
@@ -196,8 +388,8 @@ typedef struct {
 struct nua_dialog_usage {
   nua_dialog_usage_t *du_next;
   nua_usage_class const *du_class;
+  nua_client_request_t *du_cr;         /**< Client request bound with usage */
 
-  unsigned     du_terminating:1;       /**< Now trying to terminate usage */
   unsigned     du_ready:1;             /**< Established usage */
   unsigned     du_shutdown:1;          /**< Shutdown in progress */
   unsigned:0;
@@ -206,13 +398,11 @@ struct nua_dialog_usage {
    * Non-zero if the usage is established, SIP_TIME_MAX if there no
    * expiration time.
    */
-  sip_time_t      du_expires;          
 
   sip_time_t      du_refresh;          /**< When to refresh */
 
   sip_event_t const *du_event;         /**< Event of usage */
 
-  msg_t *du_msg;                       /**< Template message */
 };
 
 void nua_dialog_uac_route(nua_owner_t *, nua_dialog_state_t *ds,
@@ -225,6 +415,11 @@ int nua_dialog_remove(nua_owner_t *own,
                      nua_dialog_state_t *ds,
                      nua_dialog_usage_t *usage);
 
+static inline int nua_dialog_is_reporting(nua_dialog_state_t const *ds)
+{
+  return ds && ds->ds_reporting;
+}
+
 char const *nua_dialog_usage_name(nua_dialog_usage_t const *du);
 
 nua_dialog_usage_t *nua_dialog_usage_add(nua_owner_t *, 
@@ -243,18 +438,16 @@ void nua_dialog_usage_remove(nua_owner_t *,
 void nua_dialog_deinit(nua_owner_t *own,
                       nua_dialog_state_t *ds);
 
-void nua_dialog_terminated(nua_owner_t *,
-                          struct nua_dialog_state *ds,
-                          int status,
-                          char const *phrase);
-
-void nua_dialog_usage_set_expires(nua_dialog_usage_t *du, unsigned delta);
+int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds);
 
 void nua_dialog_usage_set_refresh(nua_dialog_usage_t *du, unsigned delta);
 
 void nua_dialog_usage_refresh_range(nua_dialog_usage_t *du, 
                                    unsigned min, unsigned max);
 
+void nua_dialog_usage_refresh_at(nua_dialog_usage_t *du, 
+                                sip_time_t target);
+
 void nua_dialog_usage_reset_refresh(nua_dialog_usage_t *du);
 
 void nua_dialog_usage_refresh(nua_owner_t *owner,
@@ -262,6 +455,10 @@ void nua_dialog_usage_refresh(nua_owner_t *owner,
                              nua_dialog_usage_t *du, 
                              sip_time_t now);
 
+int nua_dialog_usage_shutdown(nua_owner_t *owner,
+                             nua_dialog_state_t *ds,
+                             nua_dialog_usage_t *du);
+
 static inline
 int nua_dialog_is_established(nua_dialog_state_t const *ds)
 {
@@ -287,18 +484,178 @@ nua_dialog_usage_t *nua_dialog_usage_public(void const *p)
 
 /* ---------------------------------------------------------------------- */
 
-void nua_server_request_destroy(nua_server_request_t *sr);
+int nua_client_create(nua_owner_t *owner,
+                     int event,
+                     nua_client_methods_t const *methods,
+                     tagi_t const *tags);
 
-int nua_server_respond(nua_server_request_t *sr,
-                      int status, char const *phrase,
+int nua_client_tcreate(nua_owner_t *nh, 
+                      int event,
+                      nua_client_methods_t const *methods,
                       tag_type_t tag, tag_value_t value, ...);
 
-msg_t *nua_server_response(nua_server_request_t *sr,
-                          int status, char const *phrase,
-                          tag_type_t tag, tag_value_t value, ...);
+static inline 
+void *nua_private_client_request(nua_client_request_t const *cr)
+{
+  return (void *)(cr + 1);
+}
+
+void nua_client_request_destroy(nua_client_request_t *);
+
+int nua_client_request_queue(nua_client_request_t *cr);
+
+static inline int nua_client_is_queued(nua_client_request_t const *cr)
+{
+  return cr && cr->cr_prev;
+}
+
+nua_client_request_t *nua_client_request_remove(nua_client_request_t *cr);
+
+int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du);
+
+static inline int nua_client_is_bound(nua_client_request_t const *cr)
+{
+  return cr && cr->cr_usage && cr->cr_usage->du_cr == cr;
+}
+
+static inline int nua_client_is_reporting(nua_client_request_t const *cr)
+{
+  return cr && cr->cr_reporting;
+}
+
+/** Mark client request as a terminating one */
+static inline void nua_client_terminating(nua_client_request_t *cr)
+{
+  cr->cr_terminating = 1;
+}
+
+int nua_client_init_request(nua_client_request_t *cr);
+
+int nua_client_restart_request(nua_client_request_t *cr,
+                              int terminating,
+                              tagi_t const *tags);
+
+int nua_client_resend_request(nua_client_request_t *cr,
+                             int terminating);
+
+int nua_base_client_request(nua_client_request_t *cr,
+                           msg_t *msg,
+                           sip_t *sip,
+                           tagi_t const *tags);
+
+int nua_base_client_trequest(nua_client_request_t *cr,
+                            msg_t *msg,
+                            sip_t *sip,
+                            tag_type_t tag, tag_value_t value, ...);
+
+extern nta_response_f nua_client_orq_response;
+
+int nua_client_return(nua_client_request_t *cr,
+                     int status,
+                     char const *phrase,
+                     msg_t *to_be_destroyed);
+
+int nua_client_response(nua_client_request_t *cr,
+                       int status,
+                       char const *phrase,
+                       sip_t const *sip);
 
-int nua_default_respond(nua_server_request_t *sr,
-                       tagi_t const *tags);
+int nua_client_check_restart(nua_client_request_t *cr,
+                            int status,
+                            char const *phrase,
+                            sip_t const *sip);
 
+int nua_base_client_check_restart(nua_client_request_t *cr,
+                                 int status,
+                                 char const *phrase,
+                                 sip_t const *sip);
+
+int nua_client_restart(nua_client_request_t *cr,
+                      int status, char const *phrase);
+
+int nua_base_client_response(nua_client_request_t *cr,
+                            int status, char const *phrase,
+                            sip_t const *sip,
+                            tagi_t const *tags);
+
+int nua_base_client_tresponse(nua_client_request_t *cr,
+                             int status, char const *phrase,
+                             sip_t const *sip,
+                             tag_type_t tag, tag_value_t value, ...);
+
+int nua_client_set_target(nua_client_request_t *cr, url_t const *target);
+
+int nua_client_report(nua_client_request_t *cr,
+                     int status, char const *phrase,
+                     sip_t const *sip,
+                     nta_outgoing_t *orq,
+                     tagi_t const *tags);
+
+nua_client_request_t *nua_client_request_pending(nua_client_request_t const *);
+
+int nua_client_next_request(nua_client_request_t *cr, int invite);
+
+/* ---------------------------------------------------------------------- */
+
+extern nua_server_methods_t const
+  nua_extension_server_methods,
+  nua_invite_server_methods,   /**< INVITE */
+  nua_bye_server_methods,      /**< BYE */
+  nua_options_server_methods,  /**< OPTIONS */
+  nua_register_server_methods, /**< REGISTER */
+  nua_info_server_methods,     /**< INFO */
+  nua_prack_server_methods,    /**< PRACK */
+  nua_update_server_methods,   /**< UPDATE */
+  nua_message_server_methods,  /**< MESSAGE */
+  nua_subscribe_server_methods, /**< SUBSCRIBE */
+  nua_notify_server_methods,   /**< NOTIFY */
+  nua_refer_server_methods,    /**< REFER */
+  nua_publish_server_methods;  /**< PUBLISH */
+
+/** Return true if we have not sent final response to request */ 
+static inline 
+int nua_server_request_is_pending(nua_server_request_t const *sr)
+{
+  return sr && sr->sr_response.msg;
+}
+
+static inline 
+int nua_server_request_status(nua_server_request_t const *sr)
+{
+  return sr ? nta_incoming_status(sr->sr_irq) : 500;
+}
+
+void nua_server_request_destroy(nua_server_request_t *sr);
+
+int nua_base_server_init(nua_server_request_t *sr);
+
+#define nua_base_server_init NULL
+
+int nua_base_server_preprocess(nua_server_request_t *sr);
+
+#define nua_base_server_preprocess NULL
+
+int nua_server_params(nua_server_request_t *sr, tagi_t const *tags);
+
+int nua_base_server_params(nua_server_request_t *sr, tagi_t const *tags);
+
+#define nua_base_server_params NULL
+
+int nua_server_trespond(nua_server_request_t *sr,
+                       tag_type_t tag, tag_value_t value, ...);
+int nua_server_respond(nua_server_request_t *sr, tagi_t const *tags);
+
+int nua_base_server_trespond(nua_server_request_t *sr,
+                            tag_type_t tag, tag_value_t value, ...);
+int nua_base_server_respond(nua_server_request_t *sr,
+                           tagi_t const *tags);
+
+int nua_server_report(nua_server_request_t *sr);
+
+int nua_base_server_treport(nua_server_request_t *sr, 
+                           tag_type_t tag, tag_value_t value, ...);
+int nua_base_server_report(nua_server_request_t *sr, tagi_t const *tags);
+
+/* ---------------------------------------------------------------------- */
 
 #endif /* NUA_DIALOG_H */
index bd8f9c01948c8320efdd67fcdaf05539356fbeaf..20ac4ebc3dc7f095c6e3aff8178af993dce57f44 100644 (file)
@@ -45,9 +45,6 @@
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/su_tagarg.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-
 #define NEA_SMAGIC_T         struct nua_handle_s
 #define NEA_EMAGIC_T         struct nua_handle_s
 
@@ -121,13 +118,13 @@ nua_stack_notifier(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *ta
     status = 900, phrase = "Error when notifying watchers";
 
   else 
-    nua_stack_event(nua, nh, NULL, e, status = SIP_200_OK, 
-                   SIPTAG_EVENT(event),
-                   SIPTAG_CONTENT_TYPE(ct),
-                   TAG_END());
+    nua_stack_tevent(nua, nh, NULL, e, status = SIP_200_OK, 
+                    SIPTAG_EVENT(event),
+                    SIPTAG_CONTENT_TYPE(ct),
+                    TAG_END());
             
   if (status != 200)
-    nua_stack_event(nua, nh, NULL, e, status, phrase, TAG_END());
+    nua_stack_event(nua, nh, NULL, e, status, phrase, NULL);
 
   su_home_deinit(home);
 }
@@ -223,7 +220,7 @@ void authorize_watcher(nea_server_t *nes,
       what = "active";
     }
 
-    SU_DEBUG_7(("nua(%p): authorize_watcher: %s\n", nh, what)); 
+    SU_DEBUG_7(("nua(%p): authorize_watcher: %s\n", (void *)nh, what)); 
     nea_sub_auth(sn->sn_subscriber, substate,
                 TAG_IF(substate == nua_substate_pending,
                        NEATAG_FAKE(1)),
@@ -235,13 +232,13 @@ void authorize_watcher(nea_server_t *nes,
     substate = nua_substate_terminated;
     nea_server_flush(nes, NULL);
     SU_DEBUG_7(("nua(%p): authorize_watcher: %s\n", 
-               nh, "watcher is removed")); 
+               (void *)nh, "watcher is removed")); 
   }
 
-  nua_stack_event(nua, nh, msg, nua_i_subscription, status, phrase,
-          NUTAG_SUBSTATE(substate),
-          NEATAG_SUB(sn->sn_subscriber),
-          TAG_END());
+  nua_stack_tevent(nua, nh, msg, nua_i_subscription, status, phrase,
+                  NUTAG_SUBSTATE(substate),
+                  NEATAG_SUB(sn->sn_subscriber),
+                  TAG_END());
 }
 
 /* ---------------------------------------------------------------------- */
@@ -262,12 +259,11 @@ void nua_stack_authorize(nua_t *nua,
 
   if (sub && state > 0) {
     nea_sub_auth(sub, state, TAG_NEXT(tags));
-    nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END());
+    nua_stack_event(nua, nh, NULL, e, SIP_200_OK, NULL);
   }
   else {
-    nua_stack_event(nua, nh, NULL, e, NUA_INTERNAL_ERROR, TAG_END());
+    nua_stack_event(nua, nh, NULL, e, NUA_INTERNAL_ERROR, NULL);
   }
-  return;
 }
 
 /** @internal Shutdown notifier object */
@@ -347,5 +343,5 @@ void nua_stack_terminate(nua_t *nua,
                       NEATAG_REASON("noresource"), 
                       TAG_NEXT(tags));
 
-  nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END());
+  nua_stack_event(nua, nh, NULL, e, SIP_200_OK, NULL);
 }
index b8c647cbd3601e8f0047e460504ff8b0c90508d9..941b91d3ab17f8cfd6eb4e36c271bafd519288de 100644 (file)
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-
 #include "nua_stack.h"
 
-static int process_response_to_method(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip);
-static void restart_method(nua_handle_t *nh, tagi_t *tags);
-static int respond_to_method(nua_server_request_t *sr, tagi_t const *tags);
-
 /** Send an extension request. 
  *
  * Send an entension request message.
@@ -78,32 +69,25 @@ static int respond_to_method(nua_server_request_t *sr, tagi_t const *tags);
  * @since New in @VERSION_1_12_4.
  */
 
+static nua_client_methods_t const nua_method_client_methods = {
+  SIP_METHOD_UNKNOWN,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 0,
+    /* target_refresh */ 1,
+  },
+  /* nua_method_client_template */ NULL,
+  /* nua_method_client_init */ NULL,
+  /* nua_method_client_request */ NULL,
+  /* nua_method_client_check_restart */ NULL,
+  /* nua_method_client_response */ NULL
+};
+
 int 
 nua_stack_method(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 { 
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
-
-  if (cr->cr_orq)
-    return UA_EVENT2(e, 900, "Request already in progress");
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                    SIP_METHOD_UNKNOWN,
-                    TAG_NEXT(tags));
-  if (msg)
-    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                     process_response_to_method, nh, NULL,
-                                     msg,
-                                     SIPTAG_END(),
-                                     TAG_NEXT(tags));
-  if (!cr->cr_orq) {
-    msg_destroy(msg);
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-  }
-
-  return cr->cr_event = e;
+  return nua_client_create(nh, e, &nua_method_client_methods, tags);
 }
 
 /** @NUA_EVENT nua_r_method
@@ -127,20 +111,6 @@ nua_stack_method(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags
  * @END_NUA_EVENT
  */
 
-static int process_response_to_method(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip)
-{
-  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_method))
-    return 0;
-  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
-}
-
-void restart_method(nua_handle_t *nh, tagi_t *tags)
-{
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_method, tags);
-}
-
 /** @NUA_EVENT nua_i_method
  *
  * @brief Incoming extension request.
@@ -155,50 +125,35 @@ void restart_method(nua_handle_t *nh, tagi_t *tags)
  * @param nh     operation handle associated with the method
  * @param hmagic application context associated with the handle
  *               (maybe NULL if outside session)
- * @param sip    incoming request
+ * @param sip    headers in incoming request (see also nua_current_request())
  * @param tags   NUTAG_METHOD()
  *
- * The extension name is in sip->sip_request->rq_method_name, too.
+ * The extension method name is in sip->sip_request->rq_method_name, too.
+ *
+ * @note If the @a status is < 200, it is up to application to respond to
+ * the request with nua_respond(). If the handle is destroyed, the stack
+ * returns a <i>500 Internal Server Error</i> response to any unresponded
+ * request.
  *
- * @sa nua_method(), #nua_r_method
+ * @sa nua_method(), #nua_r_method, NUTAG_ALLOW(), NUTAG_APPL_METHOD(),
+ * nua_respond(), NUTAG_WITH(), NUTAG_WITH_THIS(), NUTAG_
  *
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_method(nua_t *nua,
-                             nua_handle_t *nh,
-                             nta_incoming_t *irq,
-                             sip_t const *sip)
-{
-  nua_server_request_t *sr, sr0[1];
-  
-  sr = SR_INIT(sr0);
-  
-  sr = nua_server_request(nua, nh, irq, sip, sr, sizeof *sr,
-                         respond_to_method, 0);
-
-  return nua_stack_server_event(nua, sr, nua_i_method, TAG_END());
-}
-
-static
-int respond_to_method(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_t *nua = nh->nh_nua;
-  msg_t *msg;
-
-  msg = nua_server_response(sr, sr->sr_status, sr->sr_phrase, TAG_NEXT(tags));
-
-  if (msg) {
-    nta_incoming_mreply(sr->sr_irq, msg);
-  }
-  else {
-    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
-    nua_stack_event(nua, nh, NULL,
-                   nua_i_error, 900, "Response to Extension Method Fails",
-                   TAG_END());
-  }
-  
-  return sr->sr_status >= 200 ? sr->sr_status : 0;
-}
+nua_server_methods_t const nua_extension_server_methods = 
+  {
+    SIP_METHOD_UNKNOWN,
+    nua_i_method,              /* Event */
+    { 
+      1,                       /* Do create dialog */
+      0,                       /* Can be an initial request */
+      1,                       /* Perhaps a target refresh request? */
+      1,                       /* Add a contact? */
+    },
+    nua_base_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_base_server_respond,
+    nua_base_server_report,
+  };
index 2365b263cb2f8fec3cdff68af932e2439d72b20b..b58f60497c259e9cae4e99f02bfd203a49cd6fd2 100644 (file)
@@ -43,9 +43,6 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-
 #include "nua_stack.h"
 
 /* ======================================================================== */
  * @sa #nua_i_message, @RFC3428
  */
 
-static int process_response_to_message(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip);
+static int nua_message_client_init(nua_client_request_t *cr, 
+                                  msg_t *, sip_t *,
+                                  tagi_t const *tags);
+
+static nua_client_methods_t const nua_message_client_methods = {
+  SIP_METHOD_MESSAGE,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 0,
+    /* target refresh */ 0
+  },
+  /* nua_message_client_template */ NULL,
+  nua_message_client_init,
+  /*nua_message_client_request*/ NULL,
+  /* nua_message_client_check_restart */ NULL,
+  /*nua_message_client_response*/ NULL
+};
 
 int 
-nua_stack_message(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
+nua_stack_message(nua_t *nua,
+                 nua_handle_t *nh,
+                 nua_event_t e,
+                 tagi_t const *tags)
 { 
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
-  sip_t *sip;
-
-  if (nh_is_special(nh)) {
-    return UA_EVENT2(e, 900, "Invalid handle for MESSAGE");
-  }
-  else if (cr->cr_orq) {
-    return UA_EVENT2(e, 900, "Request already in progress");
-  }
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                        SIP_METHOD_MESSAGE,
-                        NUTAG_ADD_CONTACT(NH_PGET(nh, win_messenger_enable)),
-                        TAG_NEXT(tags));
-  sip = sip_object(msg);
-
-  if (sip)
-    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                     process_response_to_message, nh, NULL,
-                                     msg,
-                                     SIPTAG_END(), TAG_NEXT(tags));
-  if (!cr->cr_orq) {
-    msg_destroy(msg);
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-  }
-
-  return cr->cr_event = e;
+  return nua_client_create(nh, e, &nua_message_client_methods, tags);
 }
 
-void restart_message(nua_handle_t *nh, tagi_t *tags)
+static int nua_message_client_init(nua_client_request_t *cr, 
+                                  msg_t *msg, sip_t *sip,
+                                  tagi_t const *tags)
 {
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_message, tags);
+  if (NH_PGET(cr->cr_owner, win_messenger_enable))
+    cr->cr_contactize = 1;
+  return 0;
 }
 
 /** @NUA_EVENT nua_r_message
@@ -137,15 +127,6 @@ void restart_message(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_message(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip)
-{
-  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_message))
-    return 0;
-  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
-}
-
 /** @NUA_EVENT nua_i_message
  *
  * @brief Incoming @b MESSAGE request.
@@ -168,32 +149,39 @@ static int process_response_to_message(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_message(nua_t *nua,
-                             nua_handle_t *nh,
-                             nta_incoming_t *irq,
-                             sip_t const *sip)
+int nua_message_server_init(nua_server_request_t *sr);
+int nua_message_server_params(nua_server_request_t *, tagi_t const *);
+
+nua_server_methods_t const nua_message_server_methods = 
+  {
+    SIP_METHOD_MESSAGE,
+    nua_i_message,             /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      0,                       /* Can be initial request */
+      0,                       /* Perhaps a target refresh request? */
+      0,                       /* Do not add contact by default */
+    },
+    nua_message_server_init,
+    nua_base_server_preprocess,
+    nua_message_server_params,
+    nua_base_server_respond,
+    nua_base_server_report,
+  };
+
+int nua_message_server_init(nua_server_request_t *sr)
 {
-  msg_t *msg;
-
-  if (nh
-      ? !NH_PGET(nh, message_enable)
-      : !DNH_PGET(nua->nua_dhandle, message_enable))
-    return 403;
+  if (!NH_PGET(sr->sr_owner, message_enable))
+    return SR_STATUS1(sr, SIP_403_FORBIDDEN);
 
-  if (nh == NULL)
-    if (!(nh = nua_stack_incoming_handle(nua, irq, sip, 0)))
-      return 500;              /* respond with 500 Internal Server Error */
-
-  msg = nta_incoming_getrequest(irq);
-
-  nua_stack_event(nh->nh_nua, nh, msg, nua_i_message, SIP_200_OK, TAG_END());
+  return 0;
+}
 
-#if 0 /* XXX */
-  if (nh->nh_nua->nua_messageRespond) {        
-    nh->nh_irq = irq;
-    return 0;
-  }
-#endif
+int nua_message_server_params(nua_server_request_t *sr,
+                             tagi_t const *tags)
+{
+  if (NH_PGET(sr->sr_owner, win_messenger_enable))
+    sr->sr_add_contact = 1;
 
-  return 200;
+  return 0;
 }
index ff5b276313d3ea14428325b71a46e96513370597..70af312c8a9c288e07d83dd975721741190ca08c 100644 (file)
 
 #include <sofia-sip/string0.h>
 #include <sofia-sip/sip_protos.h>
+#include <sofia-sip/sip_extra.h>
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/su_uniqueid.h>
-
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+#include <sofia-sip/su_md5.h>
+#include <sofia-sip/token64.h>
 
 #include "nua_stack.h"
 
 struct notifier_usage
 {
   enum nua_substate  nu_substate;      /**< Subscription state */
-  sip_time_t         nu_expires;
+  sip_time_t         nu_expires;       /**< Expiration time */
+  sip_time_t         nu_requested;      /**< Requested expiration time */
+#if SU_HAVE_EXPERIMENTAL
+  char              *nu_tag;           /**< @ETag in last NOTIFY */
+  unsigned           nu_etags:1;       /**< Subscriber supports etags */
+  unsigned           nu_appl_etags:1;   /**< Application generates etags */
+  unsigned           nu_no_body:1;      /**< Suppress body */
+#endif
 };
 
 static char const *nua_notify_usage_name(nua_dialog_usage_t const *du);
@@ -115,8 +122,6 @@ void nua_notify_usage_remove(nua_handle_t *nh,
 /* ====================================================================== */
 /* SUBSCRIBE server */
 
-static int respond_to_subscribe(nua_server_request_t *sr, tagi_t const *tags);
-
 /** @NUA_EVENT nua_i_subscribe
  *
  * Incoming @b SUBSCRIBE request.
@@ -130,7 +135,7 @@ static int respond_to_subscribe(nua_server_request_t *sr, tagi_t const *tags);
  * (or SIPTAG_ALLOW_EVENTS() or SIPTAG_ALLOW_EVENTS_STR()). The application
  * can decide whether to accept the SUBSCRIBE request or reject it. The
  * nua_response() call responding to a SUBSCRIBE request must have
- * NUTAG_WITH() (or NUTAG_WITH_CURRENT()/NUTAG_WITH_SAVED()) tag.
+ * NUTAG_WITH() (or NUTAG_WITH_THIS()/NUTAG_WITH_SAVED()) tag.
  *
  * If the application accepts the SUBSCRIBE request, it must immediately
  * send an initial NOTIFY establishing the dialog. This is because the
@@ -160,152 +165,185 @@ static int respond_to_subscribe(nua_server_request_t *sr, tagi_t const *tags);
  * @END_NUA_EVENT
  */
 
+static int nua_subscribe_server_init(nua_server_request_t *sr);
+static int nua_subscribe_server_preprocess(nua_server_request_t *sr);
+static int nua_subscribe_server_respond(nua_server_request_t*, tagi_t const *);
+static int nua_subscribe_server_report(nua_server_request_t*, tagi_t const *);
 
-/** @internal Process incoming SUBSCRIBE. */
-int nua_stack_process_subscribe(nua_t *nua,
-                               nua_handle_t *nh,
-                               nta_incoming_t *irq,
-                               sip_t const *sip)
+nua_server_methods_t const nua_subscribe_server_methods = 
+  {
+    SIP_METHOD_SUBSCRIBE,
+    nua_i_subscribe,           /* Event */
+    { 
+      1,                       /* Create dialog */
+      0,                       /* Initial request */
+      1,                       /* Target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_subscribe_server_init,
+    nua_subscribe_server_preprocess,
+    nua_base_server_params,
+    nua_subscribe_server_respond,
+    nua_subscribe_server_report,
+  };
+
+int nua_subscribe_server_init(nua_server_request_t *sr)
 {
-  nua_server_request_t *sr, sr0[1];
-  nua_dialog_state_t *ds;
-  nua_dialog_usage_t *du = NULL;
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  sip_allow_events_t const *allow_events = NH_PGET(nh, allow_events);
+  sip_t const *sip = sr->sr_request.sip;
   sip_event_t *o = sip->sip_event;
   char const *event = o ? o->o_type : NULL;
   
-  enum nua_substate substate = nua_substate_terminated;
+  if (sr->sr_initial || !nua_dialog_usage_get(ds, nua_notify_usage, o)) {
+    if (event && str0cmp(event, "refer") == 0)
+      /* refer event subscription should be initiated with REFER */
+      return SR_STATUS1(sr, SIP_403_FORBIDDEN);
 
-  enter;
+    /* XXX - event is case-sensitive, should use msg_header_find_item() */
+    if (!event || !msg_header_find_param(allow_events->k_common, event))
+      return SR_STATUS1(sr, SIP_489_BAD_EVENT);
+  }
 
-  if (nh)
-    du = nua_dialog_usage_get(ds = nh->nh_ds, nua_notify_usage, o);
+  return 0;
+}
 
-  sr = SR_INIT(sr0);
+int nua_subscribe_server_preprocess(nua_server_request_t *sr)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_dialog_usage_t *du;
+  struct notifier_usage *nu;
+  sip_t const *sip = sr->sr_request.sip;
+  sip_event_t *o = sip->sip_event;
+  char const *event = o ? o->o_type : NULL;
+  /* Maximum expiration time */
+  unsigned long expires = 3600;
+
+  assert(nh && nh->nh_nua->nua_dhandle != nh);
   
-  if (nh == NULL || du == NULL) {
-    sip_allow_events_t *allow_events = NUA_PGET(nua, nh, allow_events);
+  du = nua_dialog_usage_get(ds, nua_notify_usage, o);
 
-    if (event && str0cmp(event, "refer") == 0)
-      /* refer event subscription should be initiated with REFER */
-      SR_STATUS1(sr, SIP_403_FORBIDDEN);
-    else if (!event || !msg_header_find_param(allow_events->k_common, event))
-      SR_STATUS1(sr, SIP_489_BAD_EVENT);
-    else
-      substate = nua_substate_embryonic;
+  if (du == NULL) {
+    /* Create a new subscription */
+    du = nua_dialog_usage_add(nh, ds, nua_notify_usage, o);
+    if (du == NULL)
+      return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
   }
   else {
     /* Refresh existing subscription */
-    struct notifier_usage *nu = nua_dialog_usage_private(du);
-    unsigned long expires;
-
-    assert(nh && du && nu);
-
-    expires = str0cmp(event, "refer") ? 3600 : NH_PGET(nh, refer_expires);
-
-    if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
-      expires = sip->sip_expires->ex_delta;
-
-    if (expires == 0)
-      nu->nu_substate = nua_substate_terminated;
-
-    nu->nu_expires = sip_now() + expires;
-    substate = nu->nu_substate;
-
-    /* XXX - send notify */
+    if (str0cmp(event, "refer") == 0)
+      expires = NH_PGET(nh, refer_expires);
 
     SR_STATUS1(sr, SIP_200_OK);
   }
 
-  sr = nua_server_request(nua, nh, irq, sip, sr, sizeof *sr,
-                         respond_to_subscribe, 1);
-
-  if (!du && substate == nua_substate_embryonic && sr->sr_status < 300) {
-    nh = sr->sr_owner; assert(nh && nh != nua->nua_dhandle);
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, sip->sip_event);
-    if (du) {
-      struct notifier_usage *nu = nua_dialog_usage_private(du);
-      unsigned long expires = 3600; /* XXX */
-      
-      if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
-       expires = sip->sip_expires->ex_delta;
-
-      nu->nu_expires = sip_now() + expires;
-      nu->nu_substate = substate;
-    }
-    else 
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-  }
+  nu = nua_dialog_usage_private(du);
 
-  if (substate == nua_substate_embryonic && sr->sr_status >= 300)
-    substate = nua_substate_terminated;
+  if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
+    expires = sip->sip_expires->ex_delta;
+  nu->nu_requested = sip_now() + expires;
+
+#if SU_HAVE_EXPERIMENTAL
+  nu->nu_etags = 
+    sip_suppress_body_if_match(sip) ||
+    sip_suppress_notify_if_match(sip) ||
+    sip_has_feature(sr->sr_request.sip->sip_supported, "etags");
+#endif
 
   sr->sr_usage = du;
 
-  return nua_stack_server_event(nua, sr, nua_i_subscribe,
-                               NUTAG_SUBSTATE(substate), TAG_END());
+  return sr->sr_status <= 100 ? 0 : sr->sr_status;
 }
 
-/** @internal Respond to an SUBSCRIBE request.
+/** @internal Respond to a SUBSCRIBE request.
  *
  */
 static
-int respond_to_subscribe(nua_server_request_t *sr, tagi_t const *tags)
+int nua_subscribe_server_respond(nua_server_request_t *sr, tagi_t const *tags)
 {
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_t *nua = nh->nh_nua;
-  struct notifier_usage *nu;
-  sip_allow_events_t *allow_events = NUA_PGET(nua, nh, allow_events);
-  sip_expires_t ex[1]; 
-  sip_time_t now = sip_now();
-  msg_t *msg;
+  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
 
-  sip_expires_init(ex);
+  msg_t *msg = sr->sr_response.msg;
+  sip_t *sip = sr->sr_response.sip;
 
-  nu = nua_dialog_usage_private(sr->sr_usage);
-  if (nu && nu->nu_expires > now)
-    ex->ex_delta = nu->nu_expires - now;
+  if (200 <= sr->sr_status && sr->sr_status < 300) {
+    sip_expires_t ex[1]; 
 
-  msg = nua_server_response(sr,
-                           sr->sr_status, sr->sr_phrase,
-                           NUTAG_ADD_CONTACT(sr->sr_status < 300),
-                           TAG_IF(nu, SIPTAG_EXPIRES(ex)),
-                           SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
-                           SIPTAG_ALLOW_EVENTS(allow_events),
-                           TAG_NEXT(tags));
+    sip_expires_init(ex);
 
-  if (msg) {
-    sip_t *sip = sip_object(msg);
+    if (nu) {
+      sip_time_t now = sip_now();
 
-    if (nu && sip->sip_expires && sr->sr_status < 300)
-      nu->nu_expires = now + sip->sip_expires->ex_delta;
+      if (nu->nu_requested) {
+       if (nu->nu_requested > nu->nu_expires)
+         nu->nu_expires = nu->nu_requested;
+       else if (nu->nu_expires <= now || nu->nu_requested <= now)
+         nu->nu_substate = nua_substate_terminated;
+      }
 
-    nta_incoming_mreply(sr->sr_irq, msg);
+      if (nu->nu_expires > now)
+       ex->ex_delta = nu->nu_expires - now;
+    }
+    else {
+      /* Add header Expires: 0 */
+    }
 
-    if (nu && nu->nu_substate != nua_substate_embryonic)
-      /* Send NOTIFY (and terminate subscription, when needed) */
-      nua_dialog_usage_refresh(nh, ds, sr->sr_usage, sip_now());
+    if (!sip->sip_expires || sip->sip_expires->ex_delta > ex->ex_delta)
+      sip_add_dup(msg, sip, (sip_header_t *)ex);
   }
-  else {
-    /* XXX - send nua_i_error */
-    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
-  }
-  
-  return sr->sr_status >= 200 ? sr->sr_status : 0;
+
+  return nua_base_server_respond(sr, tags);
 }
 
-/* ======================================================================== */
-/* NOTIFY */
+static
+int nua_subscribe_server_report(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
+  enum nua_substate substate = nua_substate_terminated;
+  int notify = 0;
+  int retval;
 
-static int process_response_to_notify(nua_handle_t *nh,
-                                     nta_outgoing_t *orq,
-                                     sip_t const *sip);
+  if (nu && !sr->sr_terminating) {
+    substate = nu->nu_substate;
+  }
 
-static int nua_stack_notify2(nua_t *, nua_handle_t *, nua_event_t, 
-                            nua_dialog_usage_t *du,
-                            tagi_t const *tags);
+  /* nu_requested is set by SUBSCRIBE and cleared when NOTIFY is sent */
+  if (nu && nu->nu_requested && substate != nua_substate_embryonic) {
+#if SU_HAVE_EXPERIMENTAL
+    sip_t const *sip = sr->sr_request.sip;
+    sip_suppress_notify_if_match_t *snim = sip_suppress_notify_if_match(sip);
+    sip_suppress_body_if_match_t *sbim = sip_suppress_body_if_match(sip);
+    
+    if (!nu->nu_tag)
+      notify = 1;
+    else if (snim && !strcasecmp(snim->snim_tag, nu->nu_tag))
+      notify = 0;
+    else if (sbim && !strcasecmp(snim->snim_tag, nu->nu_tag))
+      notify = 1, nu->nu_no_body = 1;
+    else 
+#endif
+      notify = 1;
+  }
 
+  retval = nua_base_server_treport(sr, NUTAG_SUBSTATE(substate), TAG_END());
+
+  if (retval >= 2 || nu == NULL)
+    return retval;
+  
+  if (notify) {
+    /* Send NOTIFY (and terminate subscription, when needed) */
+    nua_dialog_usage_refresh(nh, ds, sr->sr_usage, sip_now());
+  }
+  
+  return retval;
+}
+
+/* ======================================================================== */
+/* NOTIFY client */
 
 /**@fn void nua_notify(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
@@ -336,175 +374,271 @@ static int nua_stack_notify2(nua_t *, nua_handle_t *, nua_event_t,
  * @sa @RFC3265, #nua_i_subscribe, #nua_i_refer, NUTAG_ALLOW_EVENTS()
  */
 
+static int nua_notify_client_init(nua_client_request_t *cr, 
+                                 msg_t *, sip_t *,
+                                 tagi_t const *tags);
+static int nua_notify_client_init_etag(nua_client_request_t *cr,
+                                      msg_t *msg, sip_t *sip,
+                                      tagi_t const *tags);
+static int nua_notify_client_request(nua_client_request_t *cr,
+                                    msg_t *, sip_t *,
+                                    tagi_t const *tags);
+static int nua_notify_client_report(nua_client_request_t *cr,
+                                   int status, char const *phrase,
+                                   sip_t const *sip,
+                                   nta_outgoing_t *orq,
+                                   tagi_t const *tags);
+
+static nua_client_methods_t const nua_notify_client_methods = {
+  SIP_METHOD_NOTIFY,
+  0,
+  { 
+    /* create_dialog */ 1,
+    /* in_dialog */ 1,
+    /* target refresh */ 1
+  },
+  /* nua_notify_client_template */ NULL,
+  nua_notify_client_init,
+  nua_notify_client_request,
+  /* nua_notify_client_check_restart */ NULL,
+  /* nua_notify_client_response */ NULL,
+  /* nua_notify_client_preliminary */ NULL,
+  nua_notify_client_report
+};
+
 /**@internal Send NOTIFY. */
 int nua_stack_notify(nua_t *nua,
                     nua_handle_t *nh,
                     nua_event_t e,
                     tagi_t const *tags)
 {
-  return nua_stack_notify2(nua, nh, e, NULL, tags);
+  return nua_client_create(nh, e, &nua_notify_client_methods, tags);
 }
 
-
-int nua_stack_notify2(nua_t *nua,
-                     nua_handle_t *nh,
-                     nua_event_t e,
-                     nua_dialog_usage_t *du,
-                     tagi_t const *tags)
+static int nua_notify_client_init(nua_client_request_t *cr,
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du;
   struct notifier_usage *nu;
-  msg_t *msg;
-  sip_t *sip;
-  sip_event_t const *o;
-  sip_time_t now;
-  int refresh = du != NULL;
-
-  if (cr->cr_orq) {
-    return UA_EVENT2(e, 900, "Request already in progress");
-  }
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  if (refresh) {
-    assert(!cr->cr_msg);
-    if (cr->cr_msg)
-      msg_destroy(cr->cr_msg);
-    cr->cr_msg = msg_copy(du->du_msg);
-  }
-
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count || refresh,
-                    SIP_METHOD_NOTIFY,
-                    NUTAG_ADD_CONTACT(1),
-                    TAG_NEXT(tags));
-  sip = sip_object(msg);
-  if (!sip)
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-
-  if (nh->nh_ds->ds_has_notifys == 1 && !sip->sip_event)
+  sip_event_t const *o = sip->sip_event;
+  sip_subscription_state_t *ss = sip->sip_subscription_state;
+  sip_time_t now = sip_now();
+    
+  if (o == NULL && nh->nh_ds->ds_has_notifys == 1)
     o = NONE;
-  else
-    o = sip->sip_event;
 
   du = nua_dialog_usage_get(nh->nh_ds, nua_notify_usage, o);
-  nu = nua_dialog_usage_private(du);
 
-  if (du && du->du_event && !sip->sip_event)
-    sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
+  if (!du) {
+    tagi_t const *newsub = tl_find_last(tags, nutag_newsub);
 
-  now = sip_now();
+    if (!newsub || !newsub->t_value)
+      return 0; /* Rejected eventually by nua_notify_client_request() */
 
-  if (!du)
-    ;
-  else if (sip->sip_subscription_state) {
-    /* SIPTAG_SUBSCRIPTION_STATE() overrides NUTAG_SUBSTATE() */
-    char const *ss_substate = sip->sip_subscription_state->ss_substate;
+    /* Create new notifier */
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, o);
+    if (du == NULL)
+      return -1;
 
-    if (strcasecmp(ss_substate, "terminated") == 0)
-      nu->nu_substate = nua_substate_terminated;
-    else if (strcasecmp(ss_substate, "pending") == 0)
-      nu->nu_substate = nua_substate_pending;
-    else /* if (strcasecmp(subs->ss_substate, "active") == 0) */ 
-      nu->nu_substate = nua_substate_active;
+    nu = nua_dialog_usage_private(du);
+    nu->nu_expires = now;
+  }
+  else
+    nu = nua_dialog_usage_private(du);
 
-    if (sip->sip_subscription_state->ss_expires) {
-      unsigned long expires;
-      expires = strtoul(sip->sip_subscription_state->ss_expires, NULL, 10);
-      if (expires > 3600)
-        expires = 3600;
-      nu->nu_expires = now + expires;
-    }
-    else if (nu->nu_substate != nua_substate_terminated) {
-      sip_subscription_state_t *ss = sip->sip_subscription_state;
-      char *param;
 
-      if (now < nu->nu_expires)
-        param = su_sprintf(msg_home(msg), "expires=%lu", nu->nu_expires - now);
-      else
-        param = "expires=0";
+  if (nu->nu_substate == nua_substate_terminated) {
+    /*Xyzzy*/;
+  }
+  else if (ss != NULL) {
+    /* SIPTAG_SUBSCRIPTION_STATE() overrides NUTAG_SUBSTATE() */
+    nu->nu_substate = nua_substate_make(ss->ss_substate);
 
-      msg_header_add_param(msg_home(msg), ss->ss_common, param);
+    if (ss->ss_expires) {
+      unsigned long expires = strtoul(ss->ss_expires, NULL, 10);
+      if (now + expires < now)
+       expires = SIP_TIME_MAX - now - 1;
+
+      /* Notifier can only shorten the subscription time */ 
+      if (nu->nu_requested == 0 || nu->nu_requested >= now + expires)
+       nu->nu_expires = nu->nu_requested = now + expires;
     }
   }
   else {
-    sip_subscription_state_t *ss;
-    enum nua_substate substate;
-    char const *name;
-
-    substate = nu->nu_substate;
+    enum nua_substate substate = nu->nu_substate;
 
-    if (nu->nu_expires <= now)
-      substate = nua_substate_terminated;
-
-    if (substate != nua_substate_terminated) {
+    if (nu->nu_expires > now) {
       tagi_t const *t = tl_find_last(tags, nutag_substate);
       if (t)
-       substate = (enum nua_substate)t->t_value;
+        substate = (enum nua_substate)t->t_value;
     }
+    else
+      substate = nua_substate_terminated;
 
     switch (substate) {
     case nua_substate_embryonic:
       /*FALLTHROUGH*/
     case nua_substate_pending:
-      name = "pending";
       nu->nu_substate = nua_substate_pending;
       break;
     case nua_substate_active:
     default:
-      name = "active";
       nu->nu_substate = nua_substate_active;
       break;
     case nua_substate_terminated:
-      name = "terminated";
       nu->nu_substate = nua_substate_terminated;
       break;
     }
+  }
 
-    if (nu->nu_substate != nua_substate_terminated) {
-      unsigned long expires = nu->nu_expires - now;
-      ss = sip_subscription_state_format(msg_home(msg), "%s;expires=%lu",
-                                        name, expires);
-    }
-    else {
-      ss = sip_subscription_state_make(msg_home(msg), "terminated; "
-                                      "reason=noresource");
-    }
+  if (nu->nu_substate == nua_substate_terminated)
+    cr->cr_terminating = 1;
 
-    msg_header_insert(msg, (void *)sip, (void *)ss);
-  }
+  cr->cr_usage = du;
 
-  if (du) {
-    if (nu->nu_substate == nua_substate_terminated)
-      du->du_terminating = 1;
+  return nua_notify_client_init_etag(cr, msg, sip, tags);
+}
 
-    if (!du->du_terminating && !refresh) {
-      /* Save template */
-      if (du->du_msg)
-        msg_destroy(du->du_msg);
-      du->du_msg = msg_ref_create(cr->cr_msg);
-    }
+static int nua_notify_client_init_etag(nua_client_request_t *cr,
+                                      msg_t *msg, sip_t *sip,
+                                      tagi_t const *tags)
+{
+#if SU_HAVE_EXPERIMENTAL
+  nua_handle_t *nh = cr->cr_owner;
+  struct notifier_usage *nu = nua_dialog_usage_private(cr->cr_usage);
+  nua_server_request_t *sr;
+
+  if (nu->nu_tag)
+    su_free(nh->nh_home, nu->nu_tag), nu->nu_tag = NULL;
+    nu->nu_no_body = 0;
+
+  if (sip->sip_etag) {
+    nu->nu_appl_etags = 1;
+    nu->nu_tag = su_strdup(nh->nh_home, sip->sip_etag->g_string);
   }
+  else if (!nu->nu_appl_etags && nu->nu_etags) {
+    su_md5_t md5[1];
+    unsigned char digest[SU_MD5_DIGEST_SIZE];
+    sip_payload_t pl[1] = { SIP_PAYLOAD_INIT() };
+    char token[2 * 16];
+
+    su_md5_init(md5);
 
-  /* NOTIFY outside a dialog */
-  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                   process_response_to_notify, nh, NULL,
-                                   msg,
-                                   SIPTAG_END(), TAG_NEXT(tags));
+    if (sip->sip_payload) *pl = *sip->sip_payload;
 
-  if (!cr->cr_orq) {
-    msg_destroy(msg);
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+    if (pl->pl_len)
+      su_md5_update(md5, pl->pl_data, pl->pl_len);
+    su_md5_update(md5, &pl->pl_len, sizeof(pl->pl_len));
+
+    if (sip->sip_content_type)
+      su_md5_striupdate(md5, sip->sip_content_type->c_type);
+
+    su_md5_digest(md5, digest);
+    token64_e(token, sizeof token, digest, sizeof digest);
+    token[(sizeof token) - 1] = '\0';
+    nu->nu_tag = su_strdup(nh->nh_home, token);
   }
 
-  cr->cr_usage = du;
+  if (!nu->nu_requested || !nu->nu_tag)
+    return 0;
+
+  /* Check if SUBSCRIBE had matching suppression */
+  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
+    if (sr->sr_usage == cr->cr_usage && sr->sr_method == sip_method_subscribe)
+      break;
+
+  if (sr) {
+    sip_t const *sip = sr->sr_request.sip;
+
+    sip_suppress_body_if_match_t *sbim;
+    sip_suppress_notify_if_match_t *snim;
+    
+    if (cr->cr_usage->du_ready) {
+      snim = sip_suppress_notify_if_match(sip);
+
+      if (snim && !strcasecmp(snim->snim_tag, nu->nu_tag)) {
+       if (nu->nu_requested > nu->nu_expires)
+         nu->nu_expires = nu->nu_requested;
+       nu->nu_requested = 0;
+       return nua_client_return(cr, 202, "NOTIFY Suppressed", msg);
+      }
+    }
+
+    sbim = sip_suppress_body_if_match(sip);
+    if (sbim && !strcasecmp(sbim->sbim_tag, nu->nu_tag))
+      nu->nu_no_body = 1;
+  }
+#endif
 
-  return cr->cr_event = e;
+  return 0;
 }
 
 static
-void restart_notify(nua_handle_t *nh, tagi_t *tags)
+int nua_notify_client_request(nua_client_request_t *cr,
+                             msg_t *msg, sip_t *sip,
+                             tagi_t const *tags)
 {
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_notify, tags);
+  nua_dialog_usage_t *du = cr->cr_usage; 
+  struct notifier_usage *nu = nua_dialog_usage_private(du);
+  su_home_t *home = msg_home(msg);
+  sip_time_t now = sip_now();
+  sip_subscription_state_t *ss = sip->sip_subscription_state;
+  char const *expires;
+
+  if (du == NULL)              /* Subscription has been terminated */
+    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
+
+  assert(du && nu);
+
+  if (du && nua_client_bind(cr, du) < 0)
+    return -1;
+
+  if (nu->nu_requested)
+    nu->nu_expires = nu->nu_requested;
+  nu->nu_requested = 0;
+
+  if (nu->nu_expires <= now || du->du_shutdown) {
+    nu->nu_substate = nua_substate_terminated;
+    expires = "expires=0";
+  }
+  else {
+    expires = su_sprintf(home, "expires=%lu", nu->nu_expires - now);
+  }
+
+  if (ss == NULL || nua_substate_make(ss->ss_substate) != nu->nu_substate) {
+    if (nu->nu_substate == nua_substate_terminated)
+      expires = nu->nu_expires > now ? "noresource" : "timeout";
+
+    ss = sip_subscription_state_format(home, "%s;%s", 
+                                      nua_substate_name(nu->nu_substate),
+                                      expires);
+
+    msg_header_insert(msg, (void *)sip, (void *)ss);
+  }
+  else if (nu->nu_substate != nua_substate_terminated) {
+    msg_header_replace_param(home, ss->ss_common, expires);
+  }
+
+#if SU_HAVE_EXPERIMENTAL
+  if (nu->nu_tag && !sip->sip_etag)
+    msg_header_add_make(msg, (void *)sip, sip_etag_class, nu->nu_tag);
+
+  if (nu->nu_no_body) {
+    nu->nu_no_body = 0;
+    msg_header_remove(msg, (void *)sip, (void *)sip->sip_payload);
+    msg_header_remove(msg, (void *)sip, (void *)sip->sip_content_length);
+  }
+#endif
+
+  if (nu->nu_substate == nua_substate_terminated)
+    cr->cr_terminating = 1;
+
+  if (du->du_event && !sip->sip_event)
+    sip_add_dup(cr->cr_msg, sip, (sip_header_t *)du->du_event);
+
+  return nua_base_client_request(cr, msg, sip, tags);
 }
 
 /** @NUA_EVENT nua_r_notify
@@ -527,30 +661,46 @@ void restart_notify(nua_handle_t *nh, tagi_t *tags)
  *               (status code is in @a status and 
  *               descriptive message in @a phrase parameters)
  * @param tags   NUTAG_SUBSTATE() indicating subscription state
+ *               SIPTAG_EVENT() indicating subscription event
  *
  * @sa nua_notify(), @RFC3265, #nua_i_subscribe, #nua_i_refer
  *
  * @END_NUA_EVENT
  */
 
-static int process_response_to_notify(nua_handle_t *nh,
-                                     nta_outgoing_t *orq,
-                                     sip_t const *sip)
+static int nua_notify_client_report(nua_client_request_t *cr,
+                                   int status, char const *phrase,
+                                   sip_t const *sip,
+                                   nta_outgoing_t *orq,
+                                   tagi_t const *tags)
 {
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  struct notifier_usage *nu = nua_dialog_usage_private(du);
   enum nua_substate substate = nua_substate_terminated;
 
-  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_notify))
-    return 0;
-
-  if (nh->nh_ds->ds_cr->cr_usage) {
-    struct notifier_usage *nu = nua_dialog_usage_private(nh->nh_ds->ds_cr->cr_usage);
+  if (nu && !cr->cr_terminated)
     substate = nu->nu_substate;
-    assert(substate != nua_substate_embryonic);
+
+  nua_stack_tevent(nh->nh_nua, nh, 
+                  nta_outgoing_getresponse(orq),
+                  cr->cr_event,
+                  status, phrase,
+                  NUTAG_SUBSTATE(substate),
+                  SIPTAG_EVENT(du ? du->du_event : NULL),
+                  TAG_NEXT(tags));
+
+  if (du && du->du_cr == cr && !cr->cr_terminated) {
+    if (nu->nu_requested) {
+      /* Re-SUBSCRIBEd while NOTIFY was in progress, resend NOTIFY */
+      nua_client_resend_request(cr, 0);
+    }
+    else if (nu->nu_expires) {
+      nua_dialog_usage_refresh_at(du, nu->nu_expires);
+    }
   }
 
-  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, 
-                                   NUTAG_SUBSTATE(substate),
-                                   TAG_END());
+  return 0;
 }
 
 
@@ -560,29 +710,30 @@ static void nua_notify_usage_refresh(nua_handle_t *nh,
                                     sip_time_t now)
 {
   struct notifier_usage *nu = nua_dialog_usage_private(du);
+  nua_client_request_t *cr = du->du_cr;
+  nua_event_t e = nua_r_notify;
 
-  if (nh->nh_ds->ds_cr->cr_usage == du) /* Already notifying. */
-    return;
-
-  if (now >= nu->nu_expires) {
-    sip_subscription_state_t ss[1];
-    char const *params[] = { NULL, NULL };
-    tagi_t tags[2] = {
-      { SIPTAG_SUBSCRIPTION_STATE(ss) }, { TAG_END() }
-    };
+  if (cr) {
+    int terminating = 0;
 
-    sip_subscription_state_init(ss);
+    if (nu->nu_expires && nu->nu_expires <= now)
+      terminating = 1;
+    else if (nu->nu_requested && nu->nu_requested <= now)
+      terminating = 1;
 
-    ss->ss_substate = "terminated";
-    ss->ss_params = params;
-    params[0] = "reason=timeout";
-    ss->ss_reason = "timeout";
-
-    nua_stack_notify2(nh->nh_nua, nh, nua_r_notify, du, tags);
+    if (nua_client_resend_request(cr, terminating) >= 0)
+      return;
   }
   else {
-    nua_stack_notify2(nh->nh_nua, nh, nua_r_notify, du, NULL);
+    if (nua_client_create(nh, e, &nua_notify_client_methods, NULL) >= 0)
+      return;
   }
+
+  nua_stack_tevent(nh->nh_nua, nh, NULL, e, NUA_INTERNAL_ERROR,
+                  NUTAG_SUBSTATE(nua_substate_terminated),
+                  TAG_END());
+
+  nua_dialog_usage_remove(nh, ds, du);
 }
 
 /** @interal Shut down NOTIFY usage. 
@@ -595,26 +746,110 @@ static int nua_notify_usage_shutdown(nua_handle_t *nh,
                                     nua_dialog_state_t *ds,
                                     nua_dialog_usage_t *du)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  struct notifier_usage *nu = nua_dialog_usage_private(du);
+  nua_client_request_t *cr = du->du_cr;
 
-  if (!cr->cr_usage) {
-    /* Unnotify */
-       /* Commenting this line out to supress an attended transfer bug (awaiting fix from pessi) */
-    //nua_stack_notify2(nh->nh_nua, nh, nua_r_destroy, du, NULL);
-    return cr->cr_usage != du;
-  }
+  nu->nu_substate = nua_substate_terminated;
 
-  if (!du->du_ready && !cr->cr_orq)
-    return 1;                  /* Unauthenticated NOTIFY? */
+  if (cr) {
+    if (nua_client_resend_request(cr, 1) >= 0)
+      return 0;
+  }
+  else {
+    if (nua_client_create(nh, nua_r_notify, 
+                         &nua_notify_client_methods, NULL) >= 0)
+      return 0;
+  }
 
-  return -1;  /* Request in progress */
+  nua_dialog_usage_remove(nh, ds, du);
+  return 200;
 }
 
-
 /* ======================================================================== */
 /* REFER */
 /* RFC 3515 */
 
+static int nua_refer_server_init(nua_server_request_t *sr);
+static int nua_refer_server_preprocess(nua_server_request_t *sr);
+static int nua_refer_server_respond(nua_server_request_t*, tagi_t const *);
+static int nua_refer_server_report(nua_server_request_t*, tagi_t const *);
+
+nua_server_methods_t const nua_refer_server_methods = 
+  {
+    SIP_METHOD_REFER,
+    nua_i_refer,               /* Event */
+    { 
+      1,                       /* Create dialog */
+      0,                       /* Initial request */
+      1,                       /* Target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_refer_server_init,
+    nua_refer_server_preprocess,
+    nua_base_server_params,
+    nua_refer_server_respond,
+    nua_refer_server_report,
+  };
+
+static int nua_refer_server_init(nua_server_request_t *sr)
+{
+  return 0;
+}
+
+static int nua_refer_server_preprocess(nua_server_request_t *sr)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  sip_t const *sip = sr->sr_request.sip;
+  struct notifier_usage *nu;
+  sip_event_t *o;
+
+  if (nh->nh_ds->ds_got_referrals || NH_PGET(nh, refer_with_id))
+    o = sip_event_format(nh->nh_home, "refer;id=%u", sip->sip_cseq->cs_seq);
+  else
+    o = sip_event_make(nh->nh_home, "refer");
+
+  if (o) {
+    sr->sr_usage = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, o);
+    msg_header_free(nh->nh_home, (msg_header_t *)o);
+  }
+
+  if (!sr->sr_usage)
+    return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+
+  nu = nua_dialog_usage_private(sr->sr_usage);
+  nu->nu_requested = sip_now() + NH_PGET(nh, refer_expires);
+
+  return 0;
+}
+
+static
+int nua_refer_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
+  sip_refer_sub_t const *rs = sip_refer_sub(sr->sr_response.sip);
+
+  if (sr->sr_status < 200 || nu == NULL) {
+  }
+  else if (sr->sr_status < 300 && 
+          /* Application included Refer-Sub: false in response */
+          (rs == NULL || str0casecmp("false", rs->rs_value))) {
+    sr->sr_usage->du_ready = 1;
+
+    nu->nu_expires = sip_now() + NH_PGET(nh, refer_expires);
+
+    if (sr->sr_application)    /* Application responded to REFER */
+      nu->nu_substate = nua_substate_active;
+  }
+  else {
+    /* Destroy the implicit subscription usage */
+    sr->sr_terminating = 1;
+  }
+
+  return nua_base_server_respond(sr, tags);
+}
+
+
 /** @NUA_EVENT nua_i_refer
  *
  * Incoming @b REFER request used to transfer calls.
@@ -635,89 +870,45 @@ static int nua_notify_usage_shutdown(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-/** @internal Process incoming REFER. */
-int nua_stack_process_refer(nua_t *nua,
-                           nua_handle_t *nh,
-                           nta_incoming_t *irq,
-                           sip_t const *sip)
+static
+int nua_refer_server_report(nua_server_request_t *sr, tagi_t const *tags)
 {
-  nua_dialog_usage_t *du = NULL;
-  struct notifier_usage *nu;
-  sip_event_t *event;
-  sip_referred_by_t *by = NULL, default_by[1];
-  msg_t *response;
-  sip_time_t expires;
-  int created = 0;
-
-  if (nh == NULL) {
-    if (!(nh = nua_stack_incoming_handle(nua, irq, sip, 1)))
-      return 500;
-    created = 1;
-  }
-
-  if (nh->nh_ds->ds_has_referrals || NH_PGET(nh, refer_with_id))
-    event = sip_event_format(nh->nh_home, "refer;id=%u", sip->sip_cseq->cs_seq);
-  else
-    event = sip_event_make(nh->nh_home, "refer");
-
-  if (event)
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, event);
+  nua_handle_t *nh = sr->sr_owner;
+  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
+  sip_t const *sip = sr->sr_request.sip;
+  sip_referred_by_t *by = sip->sip_referred_by, default_by[1];
+  sip_event_t const *o = sr->sr_usage->du_event;
+  enum nua_substate substate = nua_substate_terminated;
+  int initial = sr->sr_initial, retval;
 
-  if (!du || du->du_ready) {
-    if (du->du_ready) {
-      SU_DEBUG_1(("nua(%p): REFER with existing refer;id=%u\n", nh,
-                 sip->sip_cseq->cs_seq));
-    }
-    if (created) 
-      nh_destroy(nua, nh);
-    return 500;
+  if (nu) {
+    if (!sr->sr_terminating)
+      substate = nu->nu_substate;
   }
 
-  nu = nua_dialog_usage_private(du);
-  du->du_ready = 1;
-  nh->nh_ds->ds_has_referrals = 1;
-
-  nua_dialog_uas_route(nh, nh->nh_ds, sip, 1); /* Set route and tags */
-
-  if (!sip->sip_referred_by) {
-    sip_from_t *a = sip->sip_from;
-
-    sip_referred_by_init(by = default_by);
+  if (by == NULL) {
+     by = sip_referred_by_init(default_by);
 
-    *by->b_url = *a->a_url;
-    by->b_display = a->a_display;
+    by->b_display = sip->sip_from->a_display;
+    *by->b_url = *sip->sip_from->a_url;
   }
 
-  response = nh_make_response(nua, nh, irq, 
-                             SIP_202_ACCEPTED, 
-                             NUTAG_ADD_CONTACT(1),
-                             TAG_END());
+  retval = nua_base_server_treport(sr,
+                                  NUTAG_SUBSTATE(substate),
+                                  NUTAG_REFER_EVENT(o),
+                                  TAG_IF(by, SIPTAG_REFERRED_BY(by)),
+                                  TAG_END());
 
-  nta_incoming_mreply(irq, response);
+  if (retval >= 2 || nu == NULL)
+    return retval;
 
-  expires = NH_PGET(nh, refer_expires);
-
-  if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
-    expires = sip->sip_expires->ex_delta;
-  nu->nu_substate = nua_substate_pending;
-  nu->nu_expires = sip_now() + expires;
-
-  /* Immediate notify in order to establish the dialog */
-  if (!sip->sip_to->a_tag)
+  if (initial)
     nua_stack_post_signal(nh,
                          nua_r_notify,
-                         SIPTAG_EVENT(event),
+                         SIPTAG_EVENT(o),
                          SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
                          SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"),
                          TAG_END());
-  
-  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
-                 nua_i_refer, SIP_202_ACCEPTED, 
-                 NUTAG_REFER_EVENT(event),
-                 TAG_IF(by, SIPTAG_REFERRED_BY(by)),
-                 TAG_END());
-  
-  su_free(nh->nh_home, event);
 
-  return 500;   
+  return retval;
 }
index 739877687393e2a32b11abf59833fb9dc10b9a3c..e161e6423a0105d1f8706ff732250c89d63e2705 100644 (file)
@@ -45,9 +45,6 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-
 #include "nua_stack.h"
 
 /**@fn void nua_options(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  * @sa #nua_i_options, @RFC3261 section 10
  */
 
-static int process_response_to_options(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip);
-
-int
-nua_stack_options(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
-{
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
-
-  if (nh_is_special(nh)) {
-    return UA_EVENT2(e, 900, "Invalid handle for OPTIONS");
-  }
-  else if (cr->cr_orq) {
-    return UA_EVENT2(e, 900, "Request already in progress");
-  }
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                        SIP_METHOD_OPTIONS, 
-                        TAG_NEXT(tags));
-
-  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                   process_response_to_options, nh, NULL,
-                                   msg,
-                                   SIPTAG_END(), TAG_NEXT(tags));
-  if (!cr->cr_orq) {
-    msg_destroy(msg);
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-  }
-
-  return cr->cr_event = e;
-}
-
-void restart_options(nua_handle_t *nh, tagi_t *tags)
-{
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_options, tags);
-}
-
 /** @NUA_EVENT nua_r_options
  *
  * Answer to outgoing OPTIONS.
@@ -130,11 +87,25 @@ void restart_options(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_options(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip)
-{
-  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_options))
-    return 0;
-  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
+static nua_client_methods_t const nua_options_client_methods = {
+  SIP_METHOD_OPTIONS,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 0,
+    /* target refresh */ 0
+  },
+  /*nua_options_client_template*/ NULL,
+  /*nua_options_client_init*/ NULL,
+  /*nua_options_client_request*/ NULL,
+  /* nua_options_client_check_restart */ NULL,
+  /*nua_options_client_response*/ NULL
+};
+
+int nua_stack_options(nua_t *nua,
+                     nua_handle_t *nh,
+                     nua_event_t e,
+                     tagi_t const *tags)
+{ 
+  return nua_client_create(nh, e, &nua_options_client_methods, tags);
 }
index fdcd77234effd1498cec965e1fb12214ff3de766..a1bb6551809b9849e0c540302393122d87b171eb 100644 (file)
@@ -149,9 +149,10 @@ int nua_stack_set_defaults(nua_handle_t *nh,
   NHP_SET(nhp, auto_ack, 1);
   NHP_SET(nhp, invite_timeout, 120);
 
-  NHP_SET(nhp, session_timer, 1800);
+  nhp->nhp_session_timer = 1800;
+  nhp->nhp_refresher = nua_no_refresher;
+
   NHP_SET(nhp, min_se, 120);
-  NHP_SET(nhp, refresher, nua_no_refresher);
   NHP_SET(nhp, update_refresh, 0);
 
   NHP_SET(nhp, message_enable, 1);
@@ -393,6 +394,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
  *   NUTAG_ALLOW(), SIPTAG_ALLOW(), and SIPTAG_ALLOW_STR() \n
  *   NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and 
  *                         SIPTAG_ALLOW_EVENTS_STR() \n
+ *   NUTAG_AUTH_CACHE() \n
  *   NUTAG_AUTOACK() \n
  *   NUTAG_AUTOALERT() \n
  *   NUTAG_AUTOANSWER() \n
@@ -762,12 +764,6 @@ static int nhp_set_tags(su_home_t *home,
     else if (tag == nutag_enablemessenger) {
       NHP_SET(nhp, win_messenger_enable, value != 0);
     }
-#if 0
-    /* NUTAG_AUTORESPOND(autorespond) */
-    else if (tag == nutag_autorespond) {
-      NHP_SET(nhp, autorespond, value);
-    }
-#endif
     /* NUTAG_CALLEE_CAPS(callee_caps) */
     else if (tag == nutag_callee_caps) {
       NHP_SET(nhp, callee_caps, value != 0);
@@ -784,6 +780,11 @@ static int nhp_set_tags(su_home_t *home,
     else if (tag == nutag_path_enable) {
       NHP_SET(nhp, path_enable, value != 0);
     }
+    /* NUTAG_AUTH_CACHE(auth_cache) */
+    else if (tag == nutag_auth_cache) {
+      if (value >= 0 && value < (tag_value_t)_nua_auth_cache_invalid)
+       NHP_SET(nhp, auth_cache, (int)value);
+    }
     /* NUTAG_REFER_EXPIRES(refer_expires) */
     else if (tag == nutag_refer_expires) {
       NHP_SET(nhp, refer_expires, value);
@@ -882,7 +883,8 @@ static int nhp_set_tags(su_home_t *home,
                             sip_allow_class,
                             &appl_method,
                             (msg_list_t const *)nhp->nhp_appl_method,
-                            NHP_ISSET(nhp, allow), /* already set by tags */
+                            /* already set by tags? */
+                            NHP_ISSET(nhp, appl_method), 
                             0, /* dup it, don't make */
                             1, /* merge with old value */
                             t->t_value);
@@ -1171,10 +1173,10 @@ int nua_handle_save_tags(nua_handle_t *nh, tagi_t *tags)
 
   nh->nh_tags = 
     tl_filtered_tlist(nh->nh_home, tagfilter,
-                     SIPTAG_FROM(p_from),
-                     TAG_FILTER(nua_handle_tags_filter),
-                     SIPTAG_TO(p_to),
-                     TAG_FILTER(nua_handle_tags_filter),
+                     TAG_IF(p_from != SIP_NONE, SIPTAG_FROM(p_from)),
+                     TAG_IF(p_from != SIP_NONE, TAG_FILTER(nua_handle_tags_filter)),
+                     TAG_IF(p_to != SIP_NONE, SIPTAG_TO(p_to)),
+                     TAG_IF(p_to != SIP_NONE, TAG_FILTER(nua_handle_tags_filter)),
                      TAG_NEXT(tags));
 
   nh->nh_ptags = 
@@ -1366,7 +1368,9 @@ int nua_stack_set_smime_params(nua_t *nua, tagi_t const *tags)
  *               application contact associated with the operation handle 
  *               when responding to nua_get_hparams()
  * @param sip    NULL
- * @param tags   
+ * @param tags
+ *   NUTAG_APPL_METHOD() \n
+ *   NUTAG_AUTH_CACHE() \n
  *   NUTAG_AUTOACK() \n
  *   NUTAG_AUTOALERT() \n
  *   NUTAG_AUTOANSWER() \n
@@ -1500,6 +1504,11 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
 #define TIF(TAG, pref) \
   TAG_IF(nhp->nhp_set.nhb_##pref, TAG(nhp->nhp_##pref))
 
+  /* Include tag in the list returned to user
+   * if it has been earlier set (by user) returning default parameters */
+#define TIFD(TAG, pref) \
+  TAG_IF(nh == dnh || nhp->nhp_set.nhb_##pref, TAG(nhp->nhp_##pref))
+
   /* Include string tag made out of SIP header
    * if it has been earlier set (by user) */
 #define TIF_STR(TAG, pref)                                             \
@@ -1537,9 +1546,9 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
      TIF(NUTAG_AUTOACK, auto_ack),
      TIF(NUTAG_INVITE_TIMER, invite_timeout),
 
-     TIF(NUTAG_SESSION_TIMER, session_timer),
+     TIFD(NUTAG_SESSION_TIMER, session_timer),
      TIF(NUTAG_MIN_SE, min_se),
-     TIF(NUTAG_SESSION_REFRESHER, refresher),
+     TIFD(NUTAG_SESSION_REFRESHER, refresher),
      TIF(NUTAG_UPDATE_REFRESH, update_refresh),
 
      TIF(NUTAG_ENABLEMESSAGE, message_enable),
@@ -1550,6 +1559,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
      TIF(NUTAG_MEDIA_FEATURES, media_features),
      TIF(NUTAG_SERVICE_ROUTE_ENABLE, service_route_enable),
      TIF(NUTAG_PATH_ENABLE, path_enable),
+     TIF(NUTAG_AUTH_CACHE, auth_cache),
      TIF(NUTAG_REFER_EXPIRES, refer_expires),
      TIF(NUTAG_REFER_WITH_ID, refer_with_id),
 
@@ -1559,6 +1569,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
      TIF_STR(SIPTAG_SUPPORTED_STR, supported),
      TIF(SIPTAG_ALLOW, allow),
      TIF_STR(SIPTAG_ALLOW_STR, allow),
+     TIF_STR(NUTAG_APPL_METHOD, appl_method),
      TIF(SIPTAG_ALLOW_EVENTS, allow_events),
      TIF_STR(SIPTAG_ALLOW_EVENTS_STR, allow_events),
      TIF_SIP(SIPTAG_USER_AGENT, user_agent),
@@ -1607,7 +1618,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
 
      TAG_NEXT(media_params));
 
-  nua_stack_event(nua, nh, NULL, nua_r_get_params, SIP_200_OK, TAG_NEXT(lst));
+  nua_stack_event(nua, nh, NULL, nua_r_get_params, SIP_200_OK, lst);
 
   su_home_deinit(tmphome);
 
index 960f509e28a8ad9f9378144496930e1ba2b0b1cd..ae531f0844ecc44e88d7a03b3f4644a2fb59e11d 100644 (file)
@@ -95,9 +95,11 @@ typedef struct nua_handle_preferences
   unsigned         nhp_service_route_enable:1;
   /** Enable Path */
   unsigned         nhp_path_enable:1;
+  /** Authentication cache policy */
+  unsigned         nhp_auth_cache:1;
+
   /** Always include id with Event: refer */
   unsigned         nhp_refer_with_id:1;
-
   unsigned:0;
 
   /* Default lifetime for implicit subscriptions created by REFER */
@@ -157,6 +159,7 @@ typedef struct nua_handle_preferences
     unsigned nhb_media_features:1;
     unsigned nhb_service_route_enable:1;
     unsigned nhb_path_enable:1;
+    unsigned nhb_auth_cache:1;
     unsigned nhb_refer_with_id:1;
     unsigned nhb_refer_expires:1;
     unsigned nhb_substate:1;
@@ -166,8 +169,8 @@ typedef struct nua_handle_preferences
 
     unsigned nhb_allow:1;
     unsigned nhb_supported:1;
-    unsigned nhb_allow_events:1;
     unsigned :0;               /* at most 32 bits ... */
+    unsigned nhb_allow_events:1;
     unsigned nhb_user_agent:1;
     unsigned nhb_organization:1;
 
@@ -223,4 +226,9 @@ typedef struct nua_handle_preferences
   (NHP_ISSET((nh)->nh_prefs, pref) &&                                  \
    (nh)->nh_nua->nua_dhandle->nh_prefs != (nh)->nh_prefs)
 
+/* Check if preference has been set by applicationx */
+#define NUA_PISSET(nua, nh, pref)                                      \
+  (NHP_ISSET((nua)->nua_dhandle->nh_prefs, pref) ||                    \
+   ((nh) && NHP_ISSET((nh)->nh_prefs, pref)))
+
 #endif /* NUA_PARAMS_H */
index 9c25d44ac35e2d1bfc0a47e9b8fdc54e701a9343..251236fa084bf79141924d78d3c1a0509cf233e4 100644 (file)
@@ -45,9 +45,6 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-
 #include "nua_stack.h"
 
 /* ====================================================================== */
@@ -55,6 +52,7 @@
 
 struct publish_usage {
   sip_etag_t *pu_etag;
+  int pu_published;
 };
 
 static char const *nua_publish_usage_name(nua_dialog_usage_t const *du);
@@ -116,14 +114,6 @@ void nua_publish_usage_remove(nua_handle_t *nh,
 /* ======================================================================== */
 /* PUBLISH */
 
-static int nua_stack_publish2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                             int refresh, tagi_t const *tags);
-
-static int process_response_to_publish(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip);
-
-
 /**@fn \
  * void nua_publish(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
@@ -237,213 +227,213 @@ void nua_unpublish(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  * @END_NUA_EVENT
  */
 
-int nua_stack_publish(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                     tagi_t const *tags)
+static int nua_publish_client_template(nua_client_request_t *cr,
+                                      msg_t **return_msg,
+                                      tagi_t const *tags);
+static int nua_publish_client_init(nua_client_request_t *cr,
+                                  msg_t *, sip_t *,
+                                  tagi_t const *tags);
+static int nua_publish_client_request(nua_client_request_t *cr,
+                                     msg_t *, sip_t *,
+                                     tagi_t const *tags);
+static int nua_publish_client_response(nua_client_request_t *cr,
+                                      int status, char const *phrase,
+                                      sip_t const *sip);
+
+static nua_client_methods_t const nua_publish_client_methods = {
+  SIP_METHOD_PUBLISH,
+  0,
+  {
+    /* create_dialog */ 0,
+    /* in_dialog */ 0,
+    /* target refresh */ 0
+  },
+  nua_publish_client_template,
+  nua_publish_client_init,
+  nua_publish_client_request,
+  /* nua_publish_client_check_restart */ NULL,
+  nua_publish_client_response,
+  /* nua_publish_client_preliminary */ NULL
+};
+
+/**@internal Send PUBLISH. */
+int nua_stack_publish(nua_t *nua,
+                    nua_handle_t *nh,
+                    nua_event_t e,
+                    tagi_t const *tags)
 {
-  return nua_stack_publish2(nua, nh, e, 0, tags);
+  return nua_client_create(nh, e, &nua_publish_client_methods, tags);
 }
 
-static
-int nua_stack_publish2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                      int refresh,
-                      tagi_t const *tags)
+static int nua_publish_client_template(nua_client_request_t *cr,
+                                      msg_t **return_msg,
+                                      tagi_t const *tags)
 {
   nua_dialog_usage_t *du;
-  struct publish_usage *pu;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg = NULL;
-  sip_t *sip;
-  int remove_body = 0;
 
-  if (nua_stack_set_handle_special(nh, nh_has_nothing, nua_r_publish) < 0)
-    return UA_EVENT2(e, 900, "Invalid handle for PUBLISH");
+  if (cr->cr_event == nua_r_publish)
+    return 0;
 
-  if (cr->cr_orq) {
-    return UA_EVENT2(e, 900, "Request already in progress");
+  du = nua_dialog_usage_get(cr->cr_owner->nh_ds, nua_publish_usage, NULL);
+  if (du && du->du_cr) {
+    if (nua_client_set_target(cr, du->du_cr->cr_target) < 0)
+      return -1;
+    *return_msg = msg_copy(du->du_cr->cr_msg);
+    return 1;
   }
 
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+  return 0;
+}
 
-  if (e == nua_r_unpublish) {
-    du = nua_dialog_usage_get(nh->nh_ds, nua_publish_usage, NULL);
-    if (du)
-      refresh = 1;
-    else
-      du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
-  }
-  else if (!refresh)
+static int nua_publish_client_init(nua_client_request_t *cr,
+                                  msg_t *msg, sip_t *sip,
+                                  tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du;
+  struct publish_usage *pu;
+
+  if (cr->cr_event == nua_r_publish) {
     du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
+    if (!du)
+      return -1;
+    pu = nua_dialog_usage_private(du);
+    pu->pu_published = 0;
+    if (sip->sip_if_match) {
+      pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_if_match);
+      if (!pu->pu_etag)
+       return -1;
+      sip_header_remove(msg, sip, (sip_header_t *)sip->sip_if_match);
+    }
+  }
   else
     du = nua_dialog_usage_get(nh->nh_ds, nua_publish_usage, NULL);
 
-  if (!du)
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-
-  nua_dialog_usage_reset_refresh(du);
-  pu = nua_dialog_usage_private(du); assert(pu);
-
-  if (refresh) {
-    if (cr->cr_msg)
-      msg_destroy(cr->cr_msg);
-    cr->cr_msg = msg_copy(du->du_msg);
-    remove_body = pu->pu_etag != NULL;
-  }
+  cr->cr_usage = du;
 
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count || refresh,
-                    SIP_METHOD_PUBLISH,
-                    NUTAG_ADD_CONTACT(0),
-                    TAG_NEXT(tags));
-  sip = sip_object(msg);
+  return 0;
+}
 
-  if (!msg || !sip) 
-    goto error;
+static
+int nua_publish_client_request(nua_client_request_t *cr,
+                              msg_t *msg, sip_t *sip,
+                              tagi_t const *tags)
+{
+  nua_dialog_usage_t *du = cr->cr_usage;
+  int un, done;
+  sip_etag_t const *etag = NULL;
 
-  du->du_terminating =
-    e != nua_r_publish ||
+  un = cr->cr_terminating ||
+    cr->cr_event != nua_r_publish ||
+    (du && du->du_shutdown) ||
     (sip->sip_expires && sip->sip_expires->ex_delta == 0);
+  cr->cr_terminating = un;
+  done = un;
 
-  if (!du->du_terminating && !refresh) {
-    /* Save template */
-    if (du->du_msg)
-      msg_destroy(du->du_msg);
-    du->du_msg = msg_ref_create(cr->cr_msg);
-  }
-
-  cr->cr_orq =
-    nta_outgoing_mcreate(nua->nua_nta,
-                        process_response_to_publish, nh, NULL,
-                        msg,
-                        SIPTAG_IF_MATCH(pu->pu_etag),
-                        TAG_IF(remove_body, SIPTAG_PAYLOAD(NONE)),
-                        TAG_IF(remove_body, SIPTAG_CONTENT_TYPE(NONE)),
-                        TAG_IF(e != nua_r_publish,
-                               SIPTAG_EXPIRES_STR("0")),
-                        SIPTAG_END(), TAG_NEXT(tags));
-  if (!cr->cr_orq)
-    goto error;
-
-  cr->cr_usage = du;
+  if (du) {
+    struct publish_usage *pu = nua_dialog_usage_private(du);
 
-  return cr->cr_event = e;
+    if (nua_client_bind(cr, du) < 0)
+      return -1;
+    if (pu->pu_published)
+      done = 1;
+    etag = pu->pu_etag;
+  }
 
- error:
-  msg_destroy(msg);
-  if (!du->du_ready == 0)
-    nua_dialog_usage_remove(nh, nh->nh_ds, du);
-  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  return nua_base_client_trequest(cr, msg, sip,
+                                 SIPTAG_IF_MATCH(etag),
+                                 TAG_IF(done, SIPTAG_PAYLOAD(NONE)),
+                                 TAG_IF(done, SIPTAG_CONTENT_TYPE(NONE)),
+                                 TAG_IF(un, SIPTAG_EXPIRES_STR("0")),
+                                 TAG_NEXT(tags));
 }
 
-
-static void
-restart_publish(nua_handle_t *nh, tagi_t *tags)
+static int nua_publish_client_response(nua_client_request_t *cr,
+                                      int status, char const *phrase,
+                                      sip_t const *sip)
 {
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_publish, tags);
-}
-
-
-static
-int process_response_to_publish(nua_handle_t *nh,
-                               nta_outgoing_t *orq,
-                               sip_t const *sip)
-{
-  int status = sip->sip_status->st_status;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_handle_t *nh = cr->cr_owner;
   nua_dialog_usage_t *du = cr->cr_usage;
-  struct publish_usage *pu = nua_dialog_usage_private(du);
-  unsigned saved_retry_count = cr->cr_retry_count + 1;
-
-  if (nua_creq_check_restart(nh, cr, orq, sip, restart_publish))
-    return 0;
-
-  if (status < 200 || pu == NULL)
-    return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
 
-  if (pu->pu_etag)
-    su_free(nh->nh_home, pu->pu_etag), pu->pu_etag = NULL;
+  if (!cr->cr_terminated && du && sip) {
+    struct publish_usage *pu = nua_dialog_usage_private(du);
+    sip_expires_t const *ex = sip->sip_expires;
 
-  if (!du->du_terminating) {
-    int retry = 0, invalid_expiration = 0;
+    /* Reset state */
+    pu->pu_published = 0;
+    if (pu->pu_etag)
+      su_free(nh->nh_home, pu->pu_etag), pu->pu_etag = NULL;
 
-    if (status < 300) {
-      if (!sip->sip_expires)
-       invalid_expiration = 1;
-      else if (sip->sip_expires->ex_delta == 0)
-       retry = 1, invalid_expiration = 1;
+    if (status == 412) {
+      if (nua_client_restart(cr, 100, phrase))
+       return 0;
     }
-    else if (status == 412)
-      retry = 1;
+    else if (status < 300) {
+      if (ex && ex->ex_delta == 0 &&
+         nua_client_restart(cr, 100, "Trying re-PUBLISH"))
+       return 0;
 
-    if (status < 300 && !invalid_expiration && !retry) {
+      pu->pu_published = 1;
       pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_etag);
-      du->du_ready = 1;
-      nua_dialog_usage_set_expires(du, sip->sip_expires->ex_delta);
-    }
-    else if (retry && saved_retry_count < NH_PGET(nh, retry_count)) {
-      msg_t *response = nta_outgoing_getresponse(orq);
-      nua_stack_event(nh->nh_nua, nh, response, cr->cr_event,
-               100, "Trying re-PUBLISH",
-               TAG_END());
-      nua_creq_deinit(cr, orq);
-      nua_stack_publish2(nh->nh_nua, nh, cr->cr_event, 1, NULL);
-      cr->cr_retry_count = saved_retry_count;
-      return 0;
-    }
-    else if (invalid_expiration) {
-      msg_t *response = nta_outgoing_getresponse(orq);
-      nua_stack_event(nh->nh_nua, nh, response, cr->cr_event,
-               900, "Received Invalid Expiration Time",
-               TAG_END());
-      nua_dialog_usage_remove(nh, nh->nh_ds, cr->cr_usage);
-      nua_creq_deinit(cr, orq);
-      cr->cr_usage = NULL;
-      return 0;
+
+      if (!ex || ex->ex_delta == 0 || !pu->pu_etag) {
+       cr->cr_terminated = 1;
+
+       if (!ex || ex->ex_delta == 0)
+         SET_STATUS(900, "Received Invalid Expiration Time");
+       else
+         SET_STATUS1(NUA_INTERNAL_ERROR);
+      }
     }
   }
 
-  return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+  return nua_base_client_response(cr, status, phrase, sip, NULL);
 }
 
-
 static void nua_publish_usage_refresh(nua_handle_t *nh,
-                                     nua_dialog_state_t *ds,
-                                     nua_dialog_usage_t *du,
-                                     sip_time_t now)
+                                    nua_dialog_state_t *ds,
+                                    nua_dialog_usage_t *du,
+                                    sip_time_t now)
 {
-  if (ds->ds_cr->cr_usage == du) /* Already publishing. */
-    return;
-  nua_stack_publish2(nh->nh_nua, nh, nua_r_publish, 1, NULL);
+  nua_client_request_t *cr = du->du_cr;
+
+  if (cr) {
+    if (nua_client_resend_request(cr, 0) >= 0)
+      return;
+  }
+
+  nua_stack_event(nh->nh_nua, nh, NULL,
+                 nua_r_publish, NUA_INTERNAL_ERROR,
+                 NULL);
+
+  nua_dialog_usage_remove(nh, ds, du);
 }
 
-/** @interal Shut down PUBLISH usage. 
+/** @interal Shut down PUBLISH usage.
  *
  * @retval >0  shutdown done
  * @retval 0   shutdown in progress
  * @retval <0  try again later
  */
 static int nua_publish_usage_shutdown(nua_handle_t *nh,
-                                     nua_dialog_state_t *ds,
-                                     nua_dialog_usage_t *du)
+                                    nua_dialog_state_t *ds,
+                                    nua_dialog_usage_t *du)
 {
-  nua_client_request_t *cr = ds->ds_cr;
+  nua_client_request_t *cr = du->du_cr;
 
-  if (!cr->cr_usage) {
-    /* Unpublish */
-    nua_stack_publish2(nh->nh_nua, nh, nua_r_destroy, 1, NULL);
-    return cr->cr_usage != du;
+  if (cr) {
+    if (nua_client_resend_request(cr, 1) >= 0)
+      return 0;
   }
 
-  if (!du->du_ready && !cr->cr_orq)
-    return 1;                  /* had unauthenticated initial request */
-
-  return -1;  /* Request in progress */
+  /* XXX - report to user */
+  nua_dialog_usage_remove(nh, ds, du);
+  return 200;
 }
 
 /* ---------------------------------------------------------------------- */
 /* Server side */
 
-static
-int respond_to_publish(nua_server_request_t *sr, tagi_t const *tags);
-
 /** @NUA_EVENT nua_i_publish
  *
  * Incoming PUBLISH request.
@@ -453,7 +443,7 @@ int respond_to_publish(nua_server_request_t *sr, tagi_t const *tags);
  * events with nua_set_params() tag NUTAG_ALLOW_EVENTS(). 
  *
  * The nua_response() call responding to a PUBLISH request must have
- * NUTAG_WITH() (or NUTAG_WITH_CURRENT()/NUTAG_WITH_SAVED()) tag. Note that
+ * NUTAG_WITH() (or NUTAG_WITH_THIS()/NUTAG_WITH_SAVED()) tag. Note that
  * a successful response to PUBLISH @b MUST include @Expires and @SIPETag
  * headers.
  *
@@ -481,48 +471,35 @@ int respond_to_publish(nua_server_request_t *sr, tagi_t const *tags);
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_publish(nua_t *nua,
-                             nua_handle_t *nh,
-                             nta_incoming_t *irq,
-                             sip_t const *sip)
+int nua_publish_server_init(nua_server_request_t *sr);
+
+nua_server_methods_t const nua_publish_server_methods = 
+  {
+    SIP_METHOD_PUBLISH,
+    nua_i_publish,             /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      0,                       /* Initial request */
+      0,                       /* Not a target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_publish_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_base_server_respond,
+    nua_base_server_report,
+  };
+
+int nua_publish_server_init(nua_server_request_t *sr)
 {
-  nua_server_request_t *sr, sr0[1];
-  sip_allow_events_t *allow_events = NUA_PGET(nua, nh, allow_events);
-  sip_event_t *o = sip->sip_event;
+  sip_allow_events_t *allow_events = NH_PGET(sr->sr_owner, allow_events);
+  sip_event_t *o = sr->sr_request.sip->sip_event;
   char const *event = o ? o->o_type : NULL;
   
-  sr = SR_INIT(sr0);
-  
   if (!allow_events)
-    SR_STATUS1(sr, SIP_501_NOT_IMPLEMENTED);
+    return SR_STATUS1(sr, SIP_501_NOT_IMPLEMENTED);
   else if (!event || !msg_header_find_param(allow_events->k_common, event))
-    SR_STATUS1(sr, SIP_489_BAD_EVENT);
+    return SR_STATUS1(sr, SIP_489_BAD_EVENT);
 
-  sr = nua_server_request(nua, nh, irq, sip, sr, sizeof *sr,
-                         respond_to_publish, 0);
-
-  return nua_stack_server_event(nua, sr, nua_i_publish, TAG_END());
-}
-
-static
-int respond_to_publish(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_t *nua = nh->nh_nua;
-  msg_t *msg;
-
-  msg = nua_server_response(sr, sr->sr_status, sr->sr_phrase, TAG_NEXT(tags));
-
-  if (msg) {
-    nta_incoming_mreply(sr->sr_irq, msg);
-  }
-  else {
-    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
-    nua_stack_event(nua, nh, NULL,
-                   nua_i_error, 900, "PUBLISH Response Fails",
-                   TAG_END());
-  }
-  
-  return sr->sr_status >= 200 ? sr->sr_status : 0;
+  return 0;
 }
index 57861555d47f4bd93f96212d1d18542962d25600..44c32e005017c62b28001a974c02cbaaac8fbda7 100644 (file)
@@ -27,6 +27,7 @@
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  * @author Martti Mela <Martti.Mela@nokia.com>
+ * @author Kai Vehmanen <Kai.Vehmanen@nokia.com>
  *
  * @date Created: Wed Mar  8 11:48:49 EET 2006 ppessi
  */
@@ -45,8 +46,6 @@
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/sip_status.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 #define NTA_UPDATE_MAGIC_T   struct nua_s
 
 #include "nua_stack.h"
@@ -120,8 +119,11 @@ struct register_usage {
   nua_registration_t *nr_next, **nr_prev, **nr_list; /* Doubly linked list and its head */
   sip_from_t *nr_aor;          /**< AoR for this registration, NULL if none */
   sip_contact_t *nr_contact;   /**< Our Contact */
+  sip_contact_t nr_dcontact[1];        /**< Contact in dialog */
   sip_via_t *nr_via;           /**< Corresponding Via headers */
 
+  unsigned long nr_min_expires;        /**< Value from 423 negotiation */
+
   /** Status of registration */
   unsigned nr_ready:1;
   /** Kind of registration.
@@ -220,25 +222,16 @@ static void nua_register_usage_peer_info(nua_dialog_usage_t *du,
 /* ======================================================================== */
 /* REGISTER */
 
-static void restart_register(nua_handle_t *nh, tagi_t *tags);
-
-static int process_response_to_register(nua_handle_t *nh,
-                                       nta_outgoing_t *orq,
-                                       sip_t const *sip);
-
-static void unregister_expires_contacts(msg_t *msg, sip_t *sip);
-
 /* Interface towards outbound_t */
 sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
                                         su_home_t *home,
+                                        int in_dialog,
                                         char const *extra_username,
                                         sip_via_t const *v,
                                         char const *transport,
                                         char const *m_param,
                                         ...);
 
-static int nua_stack_outbound_features(nua_handle_t *nh, outbound_t *ob);
-
 static int nua_stack_outbound_refresh(nua_handle_t *,
                                      outbound_t *ob);
 
@@ -440,6 +433,11 @@ outbound_owner_vtable nua_stack_outbound_callbacks = {
  * the desired transport-layer keepalive interval for stream-based
  * transports like TLS and TCP.
  *
+ * As alternative to OPTIONS/STUN keepalives, the client can propose
+ * a more frequent registration refresh interval with
+ * NUTAG_M_FEATURES() (e.g. NUTAG_M_FEATURES("expires=120") given as 
+ * parameter to nua_register()).
+ * 
  * @sa #nua_r_register, nua_unregister(), #nua_r_unregister, 
  * #nua_i_register,
  * @RFC3261 section 10,
@@ -537,384 +535,353 @@ outbound_owner_vtable nua_stack_outbound_callbacks = {
  * @END_NUA_EVENT
  */
 
-int
-nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                  tagi_t const *tags)
+static int nua_register_client_template(nua_client_request_t *cr,
+                                       msg_t **return_msg,
+                                       tagi_t const *tags);
+static int nua_register_client_init(nua_client_request_t *cr,
+                                   msg_t *, sip_t *,
+                                   tagi_t const *tags);
+static int nua_register_client_request(nua_client_request_t *cr,
+                                      msg_t *, sip_t *,
+                                      tagi_t const *tags);
+static int nua_register_client_check_restart(nua_client_request_t *cr,
+                                            int status, char const *phrase,
+                                            sip_t const *sip);
+static int nua_register_client_response(nua_client_request_t *cr,
+                                       int status, char const *phrase,
+                                       sip_t const *sip);
+
+static nua_client_methods_t const nua_register_client_methods = {
+  SIP_METHOD_REGISTER,
+  0,
+  {
+    /* create_dialog */ 1,
+    /* in_dialog */ 0,
+    /* target refresh */ 0
+  },
+  nua_register_client_template,
+  nua_register_client_init,
+  nua_register_client_request,
+  nua_register_client_check_restart,
+  nua_register_client_response
+};
+
+/**@internal Send REGISTER. */
+int nua_stack_register(nua_t *nua,
+                      nua_handle_t *nh,
+                      nua_event_t e,
+                      tagi_t const *tags)
+{
+  return nua_client_create(nh, e, &nua_register_client_methods, tags);
+}
+
+static int nua_register_client_template(nua_client_request_t *cr,
+                                       msg_t **return_msg,
+                                       tagi_t const *tags)
 {
   nua_dialog_usage_t *du;
-  nua_registration_t *nr = NULL;
-  outbound_t *ob = NULL;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg = NULL;
-  sip_t *sip;
-  int terminating = e != nua_r_register;
 
-  if (nua_stack_set_handle_special(nh, nh_has_register, nua_r_register) < 0)
-    return UA_EVENT2(e, 900, "Invalid handle for REGISTER");
-  if (cr->cr_orq)
-    return UA_EVENT2(e, 900, "Request already in progress");
+  if (cr->cr_event == nua_r_register)
+    return 0;
+
+  /* Use a copy of REGISTER message as the template for un-REGISTER */
+  du = nua_dialog_usage_get(cr->cr_owner->nh_ds, nua_register_usage, NULL);
+  if (du && du->du_cr) {
+    if (nua_client_set_target(cr, du->du_cr->cr_target) < 0)
+      return -1;
+    *return_msg = msg_copy(du->du_cr->cr_msg);
+    return 1;
+  }
+
+  return 0;
+}
+
+static int nua_register_client_init(nua_client_request_t *cr,
+                                   msg_t *msg, sip_t *sip,
+                                   tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du;
+  nua_registration_t *nr;
+  sip_to_t const *aor = sip->sip_to;
+
+  int unreg;
+
+  /* Explicit empty (NULL) contact - used for CPL store/remove? */
+  if (!sip->sip_contact && cr->cr_has_contact)
+    /* Do not create any usage */
+    return 0;
 
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+  unreg = cr->cr_event != nua_r_register ||
+    (sip->sip_expires && sip->sip_expires->ex_delta == 0);
+  if (unreg)
+    nua_client_terminating(cr);
 
   du = nua_dialog_usage_add(nh, nh->nh_ds, nua_register_usage, NULL);
-  if (!du)
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-  nr = nua_dialog_usage_private(du); assert(nr);
-  nua_registration_add(&nh->nh_nua->nua_registrations, nr);
-  if (!terminating && du->du_terminating)
-    return UA_EVENT2(e, 900, "Unregister in progress");
-
-  if (cr->cr_msg)
-    msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
-  /* Use original message as template when unregistering */
-  if (terminating)             
-    cr->cr_msg = msg_ref_create(du->du_msg);
-
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_msg != NULL,
-                    SIP_METHOD_REGISTER,
-                    TAG_IF(!terminating, NUTAG_USE_DIALOG(1)),
-                    TAG_NEXT(tags));
-  sip = sip_object(msg);
-  if (!msg || !sip)
-    goto error;
-
-  if (!nr->nr_aor) {
-    if (nua_registration_set_aor(nh->nh_home, nr, sip->sip_to) < 0)
-      goto error;
-  }
+  if (du == NULL)
+    return -1;
+  nr = nua_dialog_usage_private(du);
 
-  if (terminating)
-    /* Add Expires: 0 and remove the expire parameters from contacts */
-    unregister_expires_contacts(msg, sip);
+  if (nua_client_bind(cr, du) < 0)
+    return -1;
 
-  if (!sip->sip_contact && cr->cr_has_contact) {
-    terminating = 1;
-  }
-  else if (nua_registration_set_contact(nh, nr, sip->sip_contact, terminating)
-          < 0)
-    goto error;
+  if (!nr->nr_list) {
+    nua_registration_add(&nh->nh_nua->nua_registrations, nr);
 
-  du->du_terminating = terminating;
+    if (aor == NULL)
+      aor = sip->sip_from;
+    if (aor == NULL)
+      aor = nh->nh_nua->nua_from;
 
-  if (du->du_msg == NULL && !terminating)
-    du->du_msg = msg_ref_create(cr->cr_msg); /* Save original message */
+    if (nua_registration_set_aor(nh->nh_home, nr, aor) < 0)
+      return -1;
+  }
 
-  ob = nr->nr_ob;
-  
-  if (!ob && (NH_PGET(nh, outbound) || NH_PGET(nh, instance))) {
-    nr->nr_ob = ob = outbound_new(nh, &nua_stack_outbound_callbacks,
-                                 nh->nh_nua->nua_root,
-                                 nh->nh_nua->nua_nta,
-                                 NH_PGET(nh, instance));
-    if (!ob)
-      goto error;
+  if (nua_registration_set_contact(nh, nr, sip->sip_contact, unreg) < 0)
+    return -1;
+
+  if (!nr->nr_ob && (NH_PGET(nh, outbound) || NH_PGET(nh, instance))) {
+    nr->nr_ob = outbound_new(nh, &nua_stack_outbound_callbacks,
+                            nh->nh_nua->nua_root,
+                            nh->nh_nua->nua_nta,
+                            NH_PGET(nh, instance));
+    if (!nr->nr_ob)
+      return nua_client_return(cr, 900, "Cannot create outbound", msg);
   }
 
-  if (ob) {
+  if (nr->nr_ob) {
+    outbound_t *ob = nr->nr_ob;
+    sip_contact_t *m;
+
+    if (!unreg && sip->sip_contact) {
+      for (m = sip->sip_contact; m; m = m->m_next)
+       if (!m->m_expires || strtoul(m->m_expires, NULL, 10) != 0)
+         break;
+      
+      if (m == NULL)
+       unreg = 1;      /* All contacts have expires=0 */
+    }
+
     outbound_set_options(ob,
                         NH_PGET(nh, outbound),
                         NH_PGET(nh, keepalive),
                         NH_PISSET(nh, keepalive_stream)
                         ? NH_PGET(nh, keepalive_stream)
                         : NH_PGET(nh, keepalive));
-    nua_stack_outbound_features(nh, ob);
-    outbound_stop_keepalive(ob);
 
-    if (outbound_set_contact(ob, sip->sip_contact, nr->nr_via, terminating) < 0)
-      goto error;
+    if (outbound_set_contact(ob, sip->sip_contact, nr->nr_via, unreg) < 0)
+      return nua_client_return(cr, 900, "Cannot set outbound contact", msg);
   }
 
-  /* This calls nta_outgoing_mcreate() but adds a few tags */
-  cr->cr_orq =
-    outbound_register_request(ob, terminating,
-                             nr->nr_by_stack ? nr->nr_contact : NULL,
-                             nua->nua_nta,
-                             process_response_to_register, nh, NULL,
-                             msg,
-                             SIPTAG_END(), 
-                             TAG_IF(terminating, NTATAG_SIGCOMP_CLOSE(1)),
-                             TAG_IF(!terminating, NTATAG_COMP("sigcomp")),
-                             TAG_NEXT(tags));
-
-  if (!cr->cr_orq)
-    goto error;
-
-  cr->cr_usage = du;
-  return cr->cr_event = e;
-
- error:
-  msg_destroy(msg);
-  msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
-  nua_dialog_usage_remove(nh, nh->nh_ds, du);    
-  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  return 0;
 }
 
-static void
-restart_register(nua_handle_t *nh, tagi_t *tags)
+static
+int nua_register_client_request(nua_client_request_t *cr,
+                               msg_t *msg, sip_t *sip,
+                               tagi_t const *tags)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
+  nua_handle_t *nh = cr->cr_owner;
   nua_dialog_usage_t *du = cr->cr_usage;
-  nua_registration_t *nr = nua_dialog_usage_private(du);
-  int terminating = du && du->du_terminating;
+  nua_registration_t *nr;
+  sip_contact_t *m, *contacts = sip->sip_contact;
+  char const *min_expires = NULL;
+  int unreg;
+
+  (void)nh;
+
+  /* Explicit empty (NULL) contact - used for CPL store/remove? */
+  if (!contacts && cr->cr_has_contact)
+    return nua_base_client_request(cr, msg, sip, tags);
+
+  if ((du && du->du_shutdown) ||
+      (sip->sip_expires && sip->sip_expires->ex_delta == 0))
+    nua_client_terminating(cr);
+
+  if (contacts) {
+    if (!cr->cr_terminating) {
+      for (m = contacts; m; m = m->m_next)
+       if (!m->m_expires || strtoul(m->m_expires, NULL, 10) != 0)
+         break;
+      /* All contacts have expires=0 */
+      if (m == NULL)
+       nua_client_terminating(cr);
+    }
+  }
+
+  unreg = cr->cr_terminating;
 
-  cr->cr_restart = NULL;
+  nr = nua_dialog_usage_private(du);
 
-  if (!cr->cr_msg)
-    return;
+  if (nr) {
+    if (nr->nr_ob) {
+      outbound_stop_keepalive(nr->nr_ob);
+      outbound_start_registering(nr->nr_ob);
+    }
 
-  msg = nua_creq_msg(nh->nh_nua, nh, cr, 1,
-                    SIP_METHOD_UNKNOWN,
-                    TAG_NEXT(tags));
+    if (nr->nr_by_stack) {
+      sip_contact_t *m = nr->nr_contact, *previous = NULL;
 
-  if (!msg)
-    return;                    /* XXX - Uh-oh */
+      outbound_get_contacts(nr->nr_ob, &m, &previous);
+
+      sip_add_dup(msg, sip, (sip_header_t *)m);
+      /* previous is an outdated contact generated by stack 
+       * and it is now unregistered */
+      if (previous)
+       sip_add_dup(msg, sip, (sip_header_t *)previous);
+    }
+  }
 
-  if (terminating)
-    unregister_expires_contacts(msg, sip_object(msg));
+  for (m = sip->sip_contact; m; m = m->m_next) {
+    if (m->m_url->url_type == url_any) {
+      /* If there is a '*' in contact list, remove everything else */
+      while (m != sip->sip_contact)
+       sip_header_remove(msg, sip, (sip_header_t *)sip->sip_contact);
+      while (m->m_next)
+       sip_header_remove(msg, sip, (sip_header_t *)m->m_next);
+      contacts = m;
+      break;
+    }
 
-  /* This calls nta_outgoing_mcreate() but adds a few tags */
-  cr->cr_orq =
-    outbound_register_request(nr->nr_ob, terminating,
-                             nr->nr_by_stack ? nr->nr_contact : NULL,
-                             nh->nh_nua->nua_nta,
-                             process_response_to_register, nh, NULL,
-                             msg,
-                             SIPTAG_END(), 
-                             TAG_IF(terminating, NTATAG_SIGCOMP_CLOSE(1)),
-                             TAG_IF(!terminating, NTATAG_COMP("sigcomp")),
-                             TAG_NEXT(tags));
+    if (!m->m_expires)
+      continue;
+    if (unreg) {
+      /* Remove the expire parameters from contacts */
+      msg_header_remove_param(m->m_common, "expires");
+    }
+    else if (nr && nr->nr_min_expires && 
+            strtoul(m->m_expires, 0, 10) < nr->nr_min_expires) {
+      if (min_expires == NULL) 
+       min_expires = su_sprintf(msg_home(msg), "expires=%lu", 
+                                nr->nr_min_expires);
+      msg_header_replace_param(msg_home(msg), m->m_common, min_expires);
+    }
+  }
 
-  if (!cr->cr_orq)
-    msg_destroy(msg);
+  return nua_base_client_trequest(cr, msg, sip,
+                                 TAG_IF(unreg, SIPTAG_EXPIRES_STR("0")),
+#if 0
+                                 TAG_IF(unreg, NTATAG_SIGCOMP_CLOSE(1)),
+                                 TAG_IF(!unreg, NTATAG_COMP("sigcomp")),
+#endif
+                                 TAG_NEXT(tags));
 }
 
-/** Refresh registration */
-static
-void nua_register_usage_refresh(nua_handle_t *nh,
-                               nua_dialog_state_t *ds,
-                               nua_dialog_usage_t *du,
-                               sip_time_t now)
+static int nua_register_client_check_restart(nua_client_request_t *cr,
+                                            int status, char const *phrase,
+                                            sip_t const *sip)
 {
-  nua_t *nua = nh->nh_nua;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  nua_registration_t *nr = nua_dialog_usage_private(du);
-  msg_t *msg;
-  sip_t *sip;
+  nua_registration_t *nr = nua_dialog_usage_private(cr->cr_usage);
+  unsigned short retry_count = cr->cr_retry_count;
+  int restart = 0, retry;
+
+  if (nr && nr->nr_ob) {
+    msg_t *_reqmsg = nta_outgoing_getrequest(cr->cr_orq);
+    sip_t *req = sip_object(_reqmsg); msg_destroy(_reqmsg);
+
+    retry = outbound_register_response(nr->nr_ob, cr->cr_terminating,
+                                      req, sip);
 
-  if (du->du_terminating || du->du_shutdown)
-    return;
+    restart = retry >= ob_reregister_now;
+    
+    if (retry == ob_reregister)
+      /* outbound restarts REGISTER later */;
 
-  if (cr->cr_msg) {
-    /* Dialog is busy, delay of 5 .. 15 seconds */
-    nua_dialog_usage_refresh_range(du, 5, 15);
-    return;
+    if (retry < 0)
+      /* XXX - report an error? */;
   }
 
-  outbound_stop_keepalive(nr->nr_ob);
-
-  cr->cr_msg = msg_copy(du->du_msg);
-  msg = nua_creq_msg(nua, nh, cr, 1,
-                    SIP_METHOD_REGISTER,
-                    NUTAG_USE_DIALOG(1),
-                    TAG_END());
-  sip = sip_object(msg);
-  if (!msg || !sip)
-    goto error;
-
-  cr->cr_orq =
-    outbound_register_request(nr->nr_ob, 0,
-                             nr->nr_by_stack ? nr->nr_contact : NULL,
-                             nh->nh_nua->nua_nta,
-                             process_response_to_register, nh, NULL,
-                             msg,
-                             SIPTAG_END(), 
-                             NTATAG_COMP("sigcomp"),
-                             TAG_END());
-  if (!cr->cr_orq)
-    goto error;
-
-  cr->cr_usage = du;
-  cr->cr_event = nua_r_register;
-  return;
+  if (nr && status == 423) {
+    if (sip->sip_min_expires)
+      nr->nr_min_expires = sip->sip_min_expires->me_delta;
+  }
 
- error:
-  msg_destroy(msg);
-  msg_destroy(cr->cr_msg);
-  UA_EVENT2(nua_r_register, NUA_INTERNAL_ERROR, TAG_END());
-  return;
+  /* Check for status-specific reasons to retry */
+  if (nua_base_client_check_restart(cr, status, phrase, sip))
+    return 1;
+
+  /* Restart only if nua_base_client_check_restart() did not try to restart */
+  if (restart && retry_count == cr->cr_retry_count)
+    return nua_client_restart(cr, 100, "Outbound NAT Detected");
+  
+  return 0;
 }
 
-/** Shutdown register usage. 
- *
- * Called when stack is shut down or handle is destroyed. Unregister.
- */
-static
-int nua_register_usage_shutdown(nua_handle_t *nh, 
-                               nua_dialog_state_t *ds,
-                               nua_dialog_usage_t *du)
+static int nua_register_client_response(nua_client_request_t *cr,
+                                       int status, char const *phrase,
+                                       sip_t const *sip)
 {
-  nua_t *nua = nh->nh_nua;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
   nua_registration_t *nr = nua_dialog_usage_private(du);
-  msg_t *msg;
-  sip_t *sip;
-
-  if (du->du_terminating)      /* Already terminating? */
-    return 100;
-
-  du->du_terminating = 1;
-
-  if (cr->cr_msg)    /* Busy */
-    return 100;
-
-  outbound_stop_keepalive(nr->nr_ob);
-
-  cr->cr_msg = msg_copy(du->du_msg);
-  msg = nua_creq_msg(nua, nh, cr, 1,
-                    SIP_METHOD_REGISTER,
-                    NUTAG_USE_DIALOG(1),
-                    TAG_END());
-  sip = sip_object(msg);
-  if (!msg || !sip)
-    goto error;
-
-  unregister_expires_contacts(msg, sip);
-
-  cr->cr_orq =
-    outbound_register_request(nr->nr_ob, 1,
-                             nr->nr_by_stack ? nr->nr_contact : NULL,
-                             nh->nh_nua->nua_nta,
-                             process_response_to_register, nh, NULL,
-                             msg,
-                             SIPTAG_END(), 
-                             NTATAG_SIGCOMP_CLOSE(1),
-                             TAG_END());
-  if (!cr->cr_orq)
-    goto error;
-
-  cr->cr_usage = du;
-  cr->cr_event = nua_r_destroy;
-  return 200;
+  int ready;
 
- error:
-  nua_dialog_usage_remove(nh, nh->nh_ds, du);
-  msg_destroy(msg);
-  msg_destroy(cr->cr_msg);
-  return 500;
-}
+  ready = du && !cr->cr_terminated && status < 300;
 
+  if (ready) {
+    sip_time_t mindelta = 0;
+    sip_time_t now = sip_now(), delta, reqdelta, mdelta;
 
-static
-int process_response_to_register(nua_handle_t *nh,
-                                nta_outgoing_t *orq,
-                                sip_t const *sip)
-{
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_registration_t *nr = nua_dialog_usage_private(du);
-  int status, ready, reregister, terminating;
-  char const *phrase;
-  msg_t *_reqmsg = nta_outgoing_getrequest(orq);
-  sip_t *req = sip_object(_reqmsg); msg_destroy(_reqmsg);
-
-  assert(sip);
-  assert(du && du->du_class == nua_register_usage);
-  status = sip->sip_status->st_status;
-  phrase = sip->sip_status->st_phrase;
-
-  if (status < 200 || !du)
-    return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
-
-  terminating = du->du_terminating;
-  if (!terminating)
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-
-  reregister = outbound_register_response(nr->nr_ob, terminating, req, sip);
-  if (reregister < 0)
-    SET_STATUS1(NUA_INTERNAL_ERROR);
-  else if (reregister >= ob_reregister) {
-    /* Save msg otherwise nua_creq_check_restart() will zap it */
-    msg_t *msg = msg_ref_create(cr->cr_msg);
-
-    if (nua_creq_check_restart(nh, cr, orq, sip, restart_register)) {
-      msg_destroy(msg);
-      return 0;
-    }
+    sip_contact_t const *m, *sent;
 
-    assert(cr->cr_msg == NULL);
-    cr->cr_msg = msg;
+    msg_t *_reqmsg = nta_outgoing_getrequest(cr->cr_orq);
+    sip_t *req = sip_object(_reqmsg);
 
-    if (reregister >= ob_reregister_now) {
-      /* We can try to reregister immediately */
-      nua_creq_restart_with(nh, cr, orq, 100, "Updated Contact",
-                           restart_register,
-                           TAG_END());
-    }
-    else {
-      /* Outbound will invoke refresh_register() later */
-      nua_creq_save_restart(nh, cr, orq, 100, "Updated Contact",
-                           restart_register);
-    }
-    return 0;
-  }
+    msg_destroy(_reqmsg);
 
-  if (status >= 300)
-    if (nua_creq_check_restart(nh, cr, orq, sip, restart_register))
-      return 0;
+    assert(nr); assert(sip); assert(req);
+
+#if HAVE_SIGCOMP
+    {
+      struct sigcomp_compartment *cc;
+      cc = nta_outgoing_compartment(cr->cr_orq);
+      sigcomp_compartment_unref(nr->nr_compartment);
+      nr->nr_compartment = cc;
+    }
+#endif
 
-  ready = !terminating && status < 300;
-  du->du_ready = ready;
+    /* XXX - if store/remove, remove 
+       Content-Disposition
+       Content-Type
+       body
+    */
 
-  if (status < 300) {
-    if (!du->du_terminating) {
-      sip_time_t mindelta = 0;
-      sip_time_t now = sip_now(), delta, reqdelta;
-      sip_contact_t const *m, *sent;
+    /** Search for lowest delta of SIP contacts we tried to register */
+    mindelta = SIP_TIME_MAX;
 
-      /** Search for lowest delta of SIP contacts we tried to register */
-      mindelta = SIP_TIME_MAX;
+    reqdelta = req->sip_expires ? req->sip_expires->ex_delta : 0;
 
-      reqdelta = req->sip_expires ? req->sip_expires->ex_delta : 0;
+    for (m = sip->sip_contact; m; m = m->m_next) {
+      if (m->m_url->url_type != url_sip && 
+         m->m_url->url_type != url_sips)
+       continue;
 
-      for (m = sip->sip_contact; m; m = m->m_next) {
-        if (m->m_url->url_type != url_sip && 
-            m->m_url->url_type != url_sips)
-          continue;
-        for (sent = req->sip_contact; sent; sent = sent->m_next)
-          if (url_cmp(m->m_url, sent->m_url) == 0) {
-            sip_time_t mdelta = reqdelta;
-
-            if (sent->m_expires)
-              mdelta = strtoul(sent->m_expires, NULL, 10);
-            if (mdelta == 0)
-              mdelta = 3600;
-
-            delta = sip_contact_expires(m, sip->sip_expires, sip->sip_date,
-                                        mdelta, now);
-            if (delta > 0 && delta < mindelta)
-              mindelta = delta;
-            if (url_cmp_all(m->m_url, sent->m_url) == 0)
-              break;
-          }
+      for (sent = req->sip_contact; sent; sent = sent->m_next) {
+       if (url_cmp(m->m_url, sent->m_url))
+         continue;
+
+       if (sent->m_expires)
+         mdelta = strtoul(sent->m_expires, NULL, 10);
+       else
+         mdelta = reqdelta;
+
+       if (mdelta == 0)
+         mdelta = 3600;
+         
+       delta = sip_contact_expires(m, sip->sip_expires, sip->sip_date,
+                                   mdelta, now);
+       if (delta > 0 && delta < mindelta)
+         mindelta = delta;
+
+       if (url_cmp_all(m->m_url, sent->m_url) == 0)
+         break;
       }
-
-      if (mindelta == SIP_TIME_MAX)
-        mindelta = 3600;
-      nua_dialog_usage_set_expires(du, mindelta);
     }
-    else
-      nua_dialog_usage_set_expires(du, 0);
-  }
 
-#if HAVE_SIGCOMP
-  if (ready) {
-    struct sigcomp_compartment *cc;
-    cc = nta_outgoing_compartment(orq);
-    sigcomp_compartment_unref(nr->nr_compartment);
-    nr->nr_compartment = cc;
-  }
-#endif
+    if (mindelta == SIP_TIME_MAX)
+      mindelta = 3600;
+
+    nua_dialog_usage_set_refresh(du, mindelta);
 
   /*  RFC 3608 Section 6.1 Procedures at the UA
 
@@ -934,46 +901,103 @@ int process_response_to_register(nua_handle_t *nh,
    route for that address-of-record.
 
   */
-  if (ready) {
     su_free(nh->nh_home, nr->nr_route);
     nr->nr_route = sip_route_dup(nh->nh_home, sip->sip_service_route);
-  }
-  else {
-    su_free(nh->nh_home, nr->nr_route);
-    nr->nr_route = NULL;
-  }
 
-  if (ready) {
-    /* RFC 3327 */
-    /* Store last URI in Path header */
-    sip_path_t *path = sip->sip_path;
+    {
+      /* RFC 3327 */
+      /* Store last URI in Path header */
+      sip_path_t *path = sip->sip_path;
 
-    while (path && path->r_next)
-      path = path->r_next;
+      while (path && path->r_next)
+       path = path->r_next;
 
-    if (!nr->nr_path || !path ||
-        url_cmp_all(nr->nr_path->r_url, path->r_url)) {
-      su_free(nh->nh_home, nr->nr_path);
-      nr->nr_path = sip_path_dup(nh->nh_home, path);
+      if (!nr->nr_path || !path ||
+         url_cmp_all(nr->nr_path->r_url, path->r_url)) {
+       su_free(nh->nh_home, nr->nr_path);
+       nr->nr_path = sip_path_dup(nh->nh_home, path);
+      }
     }
-  }
 
-  if (ready)
     if (sip->sip_to->a_url->url_type == url_sips)
       nr->nr_secure = 1;
 
-  if (nr->nr_ob) {
-    if (ready) {
+    if (nr->nr_ob) {
       outbound_gruuize(nr->nr_ob, sip);
-      outbound_start_keepalive(nr->nr_ob, orq);
+      outbound_start_keepalive(nr->nr_ob, cr->cr_orq);
     }
-    else
-      outbound_stop_keepalive(nr->nr_ob);
+
+    /* persistant connection for registration */
+    if (!nr->nr_tport)
+      /* note: nta_outgoing_transport() takes a ref */
+      nr->nr_tport = nta_outgoing_transport (cr->cr_orq); 
+
+    nua_registration_set_ready(nr, 1);
+  }
+  else if (du) {
+    nua_dialog_usage_set_refresh(du, 0);
+
+    su_free(nh->nh_home, nr->nr_route);
+    nr->nr_route = NULL;
+
+    outbound_stop_keepalive(nr->nr_ob);
+
+    /* release the persistant transport for registration */
+    if (nr->nr_tport)
+      tport_decref(&nr->nr_tport), nr->nr_tport = NULL;
+
+    nua_registration_set_ready(nr, 0);
+  }
+
+
+  return nua_base_client_response(cr, status, phrase, sip, NULL);
+}
+
+static void nua_register_usage_refresh(nua_handle_t *nh,
+                                      nua_dialog_state_t *ds,
+                                      nua_dialog_usage_t *du,
+                                      sip_time_t now)
+{
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr = du->du_cr;
+
+  if (cr) {
+    if (nua_client_resend_request(cr, 0) >= 0)
+      return;
+  }
+
+  /* Report that we have de-registered */
+  nua_stack_event(nua, nh, NULL, nua_r_register, NUA_INTERNAL_ERROR, NULL);
+  nua_dialog_usage_remove(nh, ds, du);
+}
+
+/** @interal Shut down REGISTER usage.
+ *
+ * @retval >0  shutdown done
+ * @retval 0   shutdown in progress
+ * @retval <0  try again later
+ */
+static int nua_register_usage_shutdown(nua_handle_t *nh,
+                                    nua_dialog_state_t *ds,
+                                    nua_dialog_usage_t *du)
+{
+  nua_client_request_t *cr = du->du_cr;
+  nua_registration_t *nr = nua_dialog_usage_private(du);
+
+  if (cr) {
+    if (nua_client_is_queued(cr)) /* Already registering. */
+      return -1;
+    cr->cr_event = nua_r_unregister;
+    if (nua_client_resend_request(cr, 1) >= 0)
+      return 0;
   }
 
-  nua_registration_set_ready(nr, ready);
+  /* release the persistant transport for registration */
+  if (nr->nr_tport)
+    tport_decref(&nr->nr_tport), nr->nr_tport = NULL;
 
-  return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+  nua_dialog_usage_remove(nh, ds, du);
+  return 200;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -984,7 +1008,8 @@ int process_response_to_register(nua_handle_t *nh,
 #endif
 
 static void nua_stack_tport_update(nua_t *nua, nta_agent_t *nta);
-static int nua_registration_add_contact_and_route(nua_registration_t *nr,
+static int nua_registration_add_contact_and_route(nua_handle_t *nh,
+                                                 nua_registration_t *nr,
                                                  msg_t *msg,
                                                  sip_t *sip,
                                                  int add_contact,
@@ -1081,9 +1106,7 @@ void nua_network_changed_cb(nua_t *nua, su_root_t *root)
 
   switch (nw_updates) {
   case NUA_NW_DETECT_ONLY_INFO:
-    nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
-                   SIP_200_OK, TAG_END());
-
+    nua_stack_event(nua, NULL, NULL, nua_i_network_changed, SIP_200_OK, NULL);
     break;
     
   case NUA_NW_DETECT_TRY_FULL:
@@ -1095,10 +1118,10 @@ void nua_network_changed_cb(nua_t *nua, su_root_t *root)
     if (nua_stack_init_transport(nua, nua->nua_args) < 0)
       /* We are hosed */
       nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
-                     900, "Internal Error", TAG_END());
+                     900, "Internal Error", NULL);
     else
       nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
-                     SIP_200_OK, TAG_END());
+                     SIP_200_OK, NULL);
 
     break;
     
@@ -1262,11 +1285,8 @@ int nua_registration_from_via(nua_registration_t **list,
 
     v2[1].v_next = NULL;
 
-#if 1
-    contact = nua_handle_contact_by_via(nh, home, NULL, v2, protocol, NULL);
-#else
-    contact = sip_contact_create_from_via_with_transport(home, v2, NULL, protocol);
-#endif
+    contact = nua_handle_contact_by_via(nh, home, 0, NULL, v2, protocol, NULL);
+
     v = sip_via_dup(home, v2);
 
     if (!contact || !v) {
@@ -1277,6 +1297,7 @@ int nua_registration_from_via(nua_registration_t **list,
     nr->nr_ready = 1, nr->nr_default = 1, nr->nr_public = public;
     nr->nr_secure = contact->m_url->url_type == url_sips;
     nr->nr_contact = contact;
+    *nr->nr_dcontact = *contact, nr->nr_dcontact->m_params = NULL;
     nr->nr_via = v;
     nr->nr_ip4 = host_is_ip4_address(contact->m_url->url_host);
     nr->nr_ip6 = !nr->nr_ip4 && host_is_ip6_reference(contact->m_url->url_host);
@@ -1446,7 +1467,10 @@ sip_contact_t const *nua_registration_contact(nua_registration_t const *nr)
       return m;
   }
 
-  return nr->nr_contact;
+  if (nr->nr_contact)
+    return nr->nr_dcontact;
+  else
+    return NULL;
 }
 
 /** Return initial route. */
@@ -1458,7 +1482,7 @@ sip_route_t const *nua_registration_route(nua_registration_t const *nr)
 sip_contact_t const *nua_stack_get_contact(nua_registration_t const *nr)
 {
   nr = nua_registration_by_aor(nr, NULL, NULL, 1);
-  return nr ? nr->nr_contact : NULL;
+  return nr && nr->nr_contact ? nr->nr_dcontact : NULL;
 }
 
 /** Add a Contact (and Route) header to request */
@@ -1482,7 +1506,7 @@ int nua_registration_add_contact_to_request(nua_handle_t *nh,
   if (nr == NULL)
     nr = nua_registration_for_request(nh->nh_nua->nua_registrations, sip);
 
-  return nua_registration_add_contact_and_route(nr, msg, sip, 
+  return nua_registration_add_contact_and_route(nh, nr, msg, sip, 
                                                add_contact, 
                                                add_service_route);
 }
@@ -1513,12 +1537,15 @@ int nua_registration_add_contact_to_response(nua_handle_t *nh,
     nr = nua_registration_for_response(nh->nh_nua->nua_registrations, sip,
                                       record_route, remote_contact);
 
-  return nua_registration_add_contact_and_route(nr, msg, sip, 1, 0);
+  return nua_registration_add_contact_and_route(nh, nr, msg, sip, 
+                                               1,
+                                               0);
 }
 
 /** Add a Contact (and Route) header to request */
 static 
-int nua_registration_add_contact_and_route(nua_registration_t *nr,
+int nua_registration_add_contact_and_route(nua_handle_t *nh,
+                                          nua_registration_t *nr,
                                           msg_t *msg,
                                           sip_t *sip,
                                           int add_contact,
@@ -1528,8 +1555,63 @@ int nua_registration_add_contact_and_route(nua_registration_t *nr,
     return -1;
 
   if (add_contact) {
-    sip_contact_t const *m = nua_registration_contact(nr);
-    if (!m || msg_header_add_dup(msg, (msg_pub_t *)sip, (void const *)m) < 0)
+    sip_contact_t const *m = NULL;
+    char const *m_display;
+    char const *m_username;
+    char const *m_params;
+    url_t const *u;
+
+    if (nr->nr_by_stack && nr->nr_ob) {
+      m = outbound_dialog_gruu(nr->nr_ob);
+
+      if (m)
+       return msg_header_add_dup(msg, (msg_pub_t *)sip, (void const *)m);
+
+      m = outbound_dialog_contact(nr->nr_ob);
+    }
+
+    if (m == NULL)
+      m = nr->nr_contact;
+
+    if (!m)
+      return -1;
+
+    u = m->m_url;
+
+    if (NH_PISSET(nh, m_display))
+      m_display = NH_PGET(nh, m_display);
+    else
+      m_display = m->m_display;
+
+    if (NH_PISSET(nh, m_username))
+      m_username = NH_PGET(nh, m_username);
+    else
+      m_username = m->m_url->url_user;
+
+    if (NH_PISSET(nh, m_params)) {
+      m_params = NH_PGET(nh, m_params);
+
+      if (u->url_params && m_params && strstr(u->url_params, m_params) == 0)
+       m_params = NULL;
+    }
+    else
+      m_params = NULL;
+
+    m = sip_contact_format(msg_home(msg),
+                          "%s<%s:%s%s%s%s%s%s%s%s%s>",
+                          m_display ? m_display : "",
+                          u->url_scheme,
+                          m_username ? m_username : "",
+                          m_username ? "@" : "",
+                          u->url_host,
+                          u->url_port ? ":" : "",
+                          u->url_port ? u->url_port : "",
+                          u->url_params ? ";" : "",
+                          u->url_params ? u->url_params : "",
+                          m_params ? ";" : "",
+                          m_params ? m_params : "");
+
+    if (msg_header_insert(msg, (msg_pub_t *)sip, (void *)m) < 0)
       return -1;
   }
 
@@ -1618,7 +1700,7 @@ int nua_registration_set_contact(nua_handle_t *nh,
 
     if (nr0 && nr0->nr_via) {
       char const *tport = nr0->nr_via->v_next ? NULL : nr0->nr_via->v_protocol;
-      m = nua_handle_contact_by_via(nh, nh->nh_home,
+      m = nua_handle_contact_by_via(nh, nh->nh_home, 0,
                                    NULL, nr0->nr_via, tport, NULL);
     }
   }
@@ -1627,6 +1709,7 @@ int nua_registration_set_contact(nua_handle_t *nh,
     return -1;
 
   nr->nr_contact = m;
+  *nr->nr_dcontact = *m, nr->nr_dcontact->m_params = NULL;
   nr->nr_ip4 = host_is_ip4_address(m->m_url->url_host);
   nr->nr_ip6 = !nr->nr_ip4 && host_is_ip6_reference(m->m_url->url_host);
   nr->nr_by_stack = !application_contact;
@@ -1639,8 +1722,10 @@ int nua_registration_set_contact(nua_handle_t *nh,
 /** Mark registration as ready */
 void nua_registration_set_ready(nua_registration_t *nr, int ready)
 {
-  assert(!ready || nr->nr_contact);
-  nr->nr_ready = ready;
+  if (nr) {
+    assert(!ready || nr->nr_contact);
+    nr->nr_ready = ready;
+  }
 }
 
 /** @internal Hook for processing incoming request by registration.
@@ -1670,48 +1755,6 @@ int nua_registration_process_request(nua_registration_t *list,
   return 481;                  /* Call/Transaction does not exist */
 }
 
-/**@internal
- * Fix contacts for un-REGISTER.
- *
- * Remove (possible non-zero) "expires" parameters from contacts and extra
- * contacts, add Expire: 0.
- */
-static
-void unregister_expires_contacts(msg_t *msg, sip_t *sip)
-{
-  sip_contact_t *m;
-  int unregister_all;
-
-  if (msg == NULL || sip == NULL)
-    return;
-
-  /* Remove payload */
-  while (sip->sip_payload)
-    sip_header_remove(msg, sip, (sip_header_t *)sip->sip_payload);
-  while (sip->sip_content_type)
-    sip_header_remove(msg, sip, (sip_header_t *)sip->sip_content_type);
-
-  for (m = sip->sip_contact; m; m = m->m_next) {
-    if (m->m_url->url_type == url_any)
-      break;
-    msg_header_remove_param(m->m_common, "expires");
-#if 0
-    msg_header_add_param(msg_home(msg), m->m_common, "expires=0");
-#endif
-  }
-
-  unregister_all = m && (m != sip->sip_contact || m->m_next);
-
-  sip_add_tl(msg, sip,
-             /* Remove existing contacts */
-             TAG_IF(unregister_all, SIPTAG_CONTACT(NONE)),
-             /* Add '*' contact: 0 */
-             TAG_IF(unregister_all, SIPTAG_CONTACT_STR("*")),
-             SIPTAG_EXPIRES_STR("0"),
-             TAG_END());
-}
-
-
 /** Outbound requests us to refresh registration */
 static int nua_stack_outbound_refresh(nua_handle_t *nh,
                                      outbound_t *ob)
@@ -1758,7 +1801,7 @@ static int nua_stack_outbound_status(nua_handle_t *nh, outbound_t *ob,
 
   nua_stack_event(nh->nh_nua, nh, NULL,
                  nua_i_outbound, status, phrase,
-                 ta_tags(ta));
+                 ta_args(ta));
 
   ta_end(ta);
 
@@ -1775,7 +1818,7 @@ static int nua_stack_outbound_failed(nua_handle_t *nh, outbound_t *ob,
 
   nua_stack_event(nh->nh_nua, nh, NULL,
                  nua_i_outbound, status, phrase,
-                 ta_tags(ta));
+                 ta_args(ta));
 
   ta_end(ta);
 
@@ -1795,6 +1838,7 @@ static int nua_stack_outbound_credentials(nua_handle_t *nh,
 /** @internal Generate a @Contact header. */
 sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
                                         su_home_t *home,
+                                        int in_dialog,
                                         char const *extra_username,
                                         sip_via_t const *v,
                                         char const *transport,
@@ -1841,10 +1885,11 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
     /* Make transport parameter lowercase */
     if (strlen(transport) < (sizeof _transport)) {
       char *s = strcpy(_transport, transport);
+      short c;
 
-      for (s = _transport; *s && *s != ';'; s++)
-       if (isupper(*s))
-         *s = tolower(*s);
+      for (s = _transport; (c = *s) && c != ';'; s++)
+       if (isupper(c))
+         *s = tolower(c);
 
       transport = _transport;
     }
@@ -1878,7 +1923,7 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
     su_strlst_append(l, ";comp="), su_strlst_append(l, comp);
   s = NH_PGET(nh, m_params);
   if (s) 
-    su_strlst_append(l, s[0] == ';' ? "" : ";"), su_strlst_append(l, s);
+    s[0] == ';' ? "" : su_strlst_append(l, ";"), su_strlst_append(l, s);
   su_strlst_append(l, ">");
 
   va_start(va, m_param);
@@ -1892,81 +1937,42 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
   
   va_end(va);
 
-  m = sip_contact_make(home, su_strlst_join(l, su_strlst_home(l), ""));
-  
-  su_strlst_destroy(l);
-  
-  return m;
-}
-
-/** @internal Return a string describing our features. */
-static char *nua_handle_features(nua_handle_t *nh)
-{
-  char *retval = NULL;
-  su_strlst_t *l = su_strlst_create(NULL);
-  su_home_t *home = su_strlst_home(l);
-
-  if (!l)
-    return NULL;
-
-  if (NH_PGET(nh, m_features)) {
-    char const *m_features = NH_PGET(nh, m_features);
-
-    if (m_features[0] != ';')
-      su_strlst_append(l, ";");
-
-    su_strlst_append(l, m_features);
-  }
-
-  if (NH_PGET(nh, callee_caps)) {
-    sip_allow_t const *allow = NH_PGET(nh, allow);
-
-    if (allow) {
-      /* Skip ";" if this is first one */
-      su_strlst_append(l, ";methods=\"" + (su_strlst_len(l) == 0));
-      if (allow->k_items) {
-        size_t i;
-        for (i = 0; allow->k_items[i]; i++) {
-          su_strlst_append(l, allow->k_items[i]);
-          if (allow->k_items[i + 1])
-            su_strlst_append(l, ",");
-        }
+  if (!in_dialog) {
+    s = NH_PGET(nh, m_features);
+    if (s) 
+      s[0] == ';' ? "" : su_strlst_append(l, ";"), su_strlst_append(l, s);
+
+    if (NH_PGET(nh, callee_caps)) {
+      sip_allow_t const *allow = NH_PGET(nh, allow);
+
+      if (allow) {
+       su_strlst_append(l, ";methods=\"");
+       if (allow->k_items) {
+         size_t i;
+         for (i = 0; allow->k_items[i]; i++) {
+           su_strlst_append(l, allow->k_items[i]);
+           if (allow->k_items[i + 1])
+             su_strlst_append(l, ",");
+         }
+       }
+       su_strlst_append(l, "\"");
       }
-      su_strlst_append(l, "\"");
-    }
-
-    if (nh->nh_soa) {
-      char **media = soa_media_features(nh->nh_soa, 0, home);
 
-      while (*media) {
-        if (su_strlst_len(l))
-          su_strlst_append(l, ";");
-        su_strlst_append(l, *media++);
+      if (nh->nh_soa) {
+       char **media = soa_media_features(nh->nh_soa, 0, home);
+       
+       while (*media) {
+         if (su_strlst_len(l))
+           su_strlst_append(l, ";");
+         su_strlst_append(l, *media++);
+       }
       }
     }
   }
 
-  if (su_strlst_len(l))
-    retval = su_strlst_join(l, nh->nh_home, "");
-
+  m = sip_contact_make(home, su_strlst_join(l, su_strlst_home(l), ""));
+  
   su_strlst_destroy(l);
-
-  return retval;
-}
-
-static int nua_stack_outbound_features(nua_handle_t *nh, outbound_t *ob)
-{
-  char *features;
-  int retval;
-
-  if (!nh)
-    return -1;
-  if (!ob)
-    return 0;
-
-  features = nua_handle_features(nh);
-  retval = outbound_set_features(ob, features);
-  su_free(nh->nh_home, features);
-
-  return retval;
+  
+  return m;
 }
index 847102b79f9f23edbe56787210a1c0d8dfd67299..088030717b9f65008c67d94d5067e023605d4b7a 100644 (file)
@@ -44,8 +44,6 @@
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/sip_util.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 #define NTA_INCOMING_MAGIC_T struct nua_handle_s
 #define NTA_RELIABLE_MAGIC_T struct nua_handle_s
 
@@ -62,7 +60,7 @@
  * the REGISTER method with NUTAG_ALLOW() tag.
  *
  * The nua_response() call responding to a REGISTER request must have
- * NUTAG_WITH() (or NUTAG_WITH_CURRENT()/NUTAG_WITH_SAVED()) tag. Note that
+ * NUTAG_WITH() (or NUTAG_WITH_THIS()/NUTAG_WITH_SAVED()) tag. Note that
  * a successful response to REGISTER @b MUST include the @Contact header
  * bound to the the AoR URI (in @To header).
  *
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_register(nua_t *nua,
-                              nua_handle_t *nh,
-                              nta_incoming_t *irq,
-                              sip_t const *sip)
-{
-  nua_server_request_t *sr, sr0[1];
-
-  sr = nua_server_request(nua, nh, irq, sip, SR_INIT(sr0), sizeof *sr,
-                         nua_default_respond, 0);
-
-  return nua_stack_server_event(nua, sr, nua_i_register, TAG_END());
-}
+nua_server_methods_t const nua_register_server_methods = 
+  {
+    SIP_METHOD_REGISTER,
+    nua_i_register,            /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      0,                       /* Initial request */
+      0,                       /* Not a target refresh request  */
+      0,                       /* Do not add Contact */
+    },
+    nua_base_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_base_server_respond,
+    nua_base_server_report,
+  };
index 60d4398f169604315883df754bfcd93ee0ce1404..fe02d064be08050d678a6453caba43b4a77deb10 100644 (file)
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/su_uniqueid.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 #define NTA_INCOMING_MAGIC_T struct nua_server_request
-#define NTA_RELIABLE_MAGIC_T struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_client_request
+#define NTA_RELIABLE_MAGIC_T struct nua_server_request
 
 #include "nua_stack.h"
 #include <sofia-sip/soa.h>
@@ -141,8 +140,7 @@ sip_response_terminates_dialog().
 /** Session-related state */
 typedef struct nua_session_usage
 {
-  /* enum nua_callstate */
-  unsigned        ss_state:4;          /**< Session status (enum nua_callstate) */
+  enum nua_callstate ss_state;         /**< Session status (enum nua_callstate) */
   
   unsigned        ss_100rel:1;         /**< Use 100rel, send 183 */
   unsigned        ss_alerting:1;       /**< 180 is sent/received */
@@ -151,18 +149,28 @@ typedef struct nua_session_usage
 
   unsigned        ss_precondition:1;   /**< Precondition required */
 
-  unsigned        ss_timer_set:1;       /**< We have active session timer. */
+  unsigned        ss_reporting:1;       /**< True if reporting state */
   unsigned        : 0;
-  
-  unsigned        ss_session_timer;    /**< Value of Session-Expires (delta) */
-  unsigned        ss_min_se;           /**< Minimum session expires */
-  enum nua_session_refresher ss_refresher; /**< none, local or remote */
 
-  char const     *ss_ack_needed;       /**< If non-null, need to send an ACK
-                                        * (do O/A, if "offer" or "answer")
-                                        */
+  struct session_timer {
+    unsigned  interval;                /**< Negotiated expiration time */
+    enum nua_session_refresher refresher; /**< Our Negotiated role */
+
+    struct {
+      unsigned expires, defaults; /**< Value of Session-Expires (delta) */
+      unsigned min_se; /**< Minimum session expires */
+      /** none, local or remote */
+      enum nua_session_refresher refresher;
+      unsigned    supported:1, require:1, :0;
+    } local, remote;
+
+    unsigned      timer_set:1;  /**< We have active session timer. */
+  } ss_timer[1];
+
+  char const     *ss_reason;           /**< Reason for termination. */
 
-  nua_client_request_t ss_crequest[1];  /* Outgoing invite */
+  /* Offer-Answer status */
+  char const     *ss_oa_recv, *ss_oa_sent;
 } nua_session_usage_t;
 
 static char const *nua_session_usage_name(nua_dialog_usage_t const *du);
@@ -180,6 +188,9 @@ static int nua_session_usage_shutdown(nua_owner_t *,
                                      nua_dialog_state_t *,
                                      nua_dialog_usage_t *);
 
+static int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags);
+static int nua_invite_client_deinit(nua_client_request_t *cr);
+
 static nua_usage_class const nua_session_usage[1] = {
   {
     sizeof (nua_session_usage_t),
@@ -202,14 +213,16 @@ int nua_session_usage_add(nua_handle_t *nh,
                           nua_dialog_state_t *ds,
                           nua_dialog_usage_t *du)
 {
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);  
 
   if (ds->ds_has_session)
     return -1;
   ds->ds_has_session = 1;
+  ds->ds_got_session = 1;
+
+  ss->ss_timer->local.refresher = nua_any_refresher;
+  ss->ss_timer->remote.refresher = nua_any_refresher;
 
-  nh->nh_ds->ds_cr->cr_next = ss->ss_crequest;
   return 0;
 }
 
@@ -219,17 +232,57 @@ void nua_session_usage_remove(nua_handle_t *nh,
                               nua_dialog_usage_t *du)
 {
   nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_client_request_t *cr, *cr_next;
+
+  cr = du->du_cr;
+
+  if (cr && cr->cr_orq && cr->cr_status >= 200) {
+    ss->ss_reporting = 1;
+    nua_invite_client_ack(cr, NULL);
+    ss->ss_reporting = 0;
+  }
+
+  /* Destroy queued INVITE transactions */
+  for (cr = ds->ds_cr; cr; cr = cr_next) {
+    cr_next = cr->cr_next;
+
+    if (cr->cr_method != sip_method_invite)
+      continue;
+    if (cr == du->du_cr)
+      continue;
+
+    nua_stack_event(nh->nh_nua, nh, 
+                   NULL,
+                   cr->cr_event,
+                   SIP_481_NO_TRANSACTION,
+                   NULL);
+
+    nua_client_request_destroy(cr);
+
+    cr_next = ds->ds_cr;
+  }
 
+  
   ds->ds_has_session = 0;
+  nh->nh_has_invite = 0;
+  nh->nh_active_call = 0;
+  nh->nh_hold_remote = 0;
+
+  if (nh->nh_soa)
+    soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
+}
 
-  if (ss->ss_crequest)
-    nua_creq_deinit(ss->ss_crequest, NULL);
+static
+nua_dialog_usage_t *nua_dialog_usage_for_session(nua_dialog_state_t const *ds)
+{
+  if (ds == ((nua_handle_t *)NULL)->nh_ds)
+    return NULL;
 
-  ds->ds_cr->cr_next = NULL;
+  return nua_dialog_usage_get(ds, nua_session_usage, NULL);
 }
 
 static
-nua_session_usage_t *nua_session_usage_get(nua_dialog_state_t const *ds)
+nua_session_usage_t *nua_session_usage_for_dialog(nua_dialog_state_t const *ds)
 {
   nua_dialog_usage_t *du;
 
@@ -241,63 +294,59 @@ nua_session_usage_t *nua_session_usage_get(nua_dialog_state_t const *ds)
   return (nua_session_usage_t *)nua_dialog_usage_private(du);
 }
 
+/** Zap the session associated with the handle */
+static
+void nua_session_usage_destroy(nua_handle_t *nh,
+                              nua_session_usage_t *ss)
+{
+  /* Remove usage */
+  nua_dialog_usage_remove(nh, nh->nh_ds, nua_dialog_usage_public(ss));
+
+  SU_DEBUG_5(("nua: terminated session %p\n", (void *)nh));
+}
+
 /* ======================================================================== */
 /* INVITE and call (session) processing */
 
-static int nua_stack_invite2(nua_t *, nua_handle_t *, nua_event_t e,
-                            int restarted, tagi_t const *tags);
-static int process_response_to_invite(nua_handle_t *nh,
-                                     nta_outgoing_t *orq,
-                                     sip_t const *sip);
-static void
-  session_timeout(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now);
+int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+                   tagi_t const *tags);
 
-static void restart_invite(nua_handle_t *nh, tagi_t *tags);
+static int session_timer_is_supported(struct session_timer const *t);
 
-static int process_100rel(nua_handle_t *nh,
-                         nua_session_usage_t *ss,
-                         nta_outgoing_t *orq,
-                         sip_t const *sip);
+static void session_timer_preferences(struct session_timer *t,
+                                     sip_t const *sip,
+                                     sip_supported_t const *supported,
+                                     unsigned expires, int isset,
+                                     enum nua_session_refresher refresher,
+                                     unsigned min_se);
 
-int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                   tagi_t const *tags);
+static void session_timer_store(struct session_timer *t,
+                               sip_t const *sip);
 
-static int process_response_to_prack(nua_handle_t *nh,
-                                    nta_outgoing_t *orq,
-                                    sip_t const *sip);
+static int session_timer_check_min_se(msg_t *msg, sip_t *sip,
+                                     sip_t const *request,
+                                     unsigned long min_se);
 
-static void nua_session_usage_destroy(nua_handle_t *, nua_session_usage_t *);
+static int session_timer_add_headers(struct session_timer *t,
+                                    int initial,
+                                    msg_t *msg, sip_t *sip);
 
-static void session_timer_preferences(nua_session_usage_t *ss,
-                                     unsigned expires,
-                                     unsigned min_se,
-                                     enum nua_session_refresher refresher);
-static int session_timer_is_supported(nua_handle_t const *nh);
-static int prefer_session_timer(nua_handle_t const *nh);
+static void session_timer_negotiate(struct session_timer *t);
 
-static int use_session_timer(nua_session_usage_t *ss, int uas, int always,
-                            msg_t *msg, sip_t *);
-static int init_session_timer(nua_session_usage_t *ss, sip_t const *, int refresher);
-static void set_session_timer(nua_session_usage_t *ss);
+static void session_timer_set(nua_session_usage_t *ss);
 
-static int
-check_session_timer_restart(nua_handle_t *nh,
-                           nua_session_usage_t *ss,
-                           nua_client_request_t *cr,
-                           nta_outgoing_t *orq,
-                           sip_t const *sip,
-                           nua_creq_restart_f *restart_function);
+static int session_timer_check_restart(nua_client_request_t *cr,
+                                      int status, char const *phrase,
+                                      sip_t const *sip);
 
 static int nh_referral_check(nua_handle_t *nh, tagi_t const *tags);
 static void nh_referral_respond(nua_handle_t *,
                                int status, char const *phrase);
 
 static void signal_call_state_change(nua_handle_t *nh,
-                                    nua_session_usage_t *ss,
-                                    int status, char const *phrase,
-                                    enum nua_callstate next_state,
-                                    char const *oa_recv,
-                                    char const *oa_sent);
+                                     nua_session_usage_t *ss,
+                                     int status, char const *phrase,
+                                     enum nua_callstate next_state);
 
 static
 int session_get_description(sip_t const *sip,
@@ -319,16 +368,9 @@ int session_make_description(su_home_t *home,
                             sip_payload_t **return_pl);
 
 static
-int session_process_response(nua_handle_t *nh,
-                            nua_client_request_t *cr,
-                            nta_outgoing_t *orq,
-                            sip_t const *sip,
-                            char const **return_received);
-
-static
-int respond_with_retry_after(nua_handle_t *nh, nta_incoming_t *irq,
-                            int status, char const *phrase,
-                            int min, int max);
+int nua_server_retry_after(nua_server_request_t *sr,
+                          int status, char const *phrase,
+                          int min, int max);
 
 /**@fn void nua_invite(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
@@ -475,128 +517,157 @@ int respond_with_retry_after(nua_handle_t *nh, nta_incoming_t *irq,
 /* Tags not implemented
  *    NUTAG_REFER_PAUSE() \n
  */
-int
-nua_stack_invite(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                tagi_t const *tags)
-{
-  char const *what;
-
-  if (nh_is_special(nh) || 
-      nua_stack_set_handle_special(nh, nh_has_invite, nua_i_error))
-    what = "Invalid handle for INVITE";
-  else if (nh_referral_check(nh, tags) < 0) {
-    what = "Invalid referral";
-  }
-  else if (nua_stack_init_handle(nua, nh, TAG_NEXT(tags)) < 0) {
-    what = "Handle initialization failed";
-  }
-  else
-    return nua_stack_invite2(nua, nh, e, 0, tags);
-
-  UA_EVENT2(e, 900, what);
 
-  signal_call_state_change(nh, NULL, 900, what, nua_callstate_init, 0, 0);
-
-  return e;
+static int nua_invite_client_init(nua_client_request_t *cr, 
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags);
+static int nua_invite_client_request(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags);
+static int nua_invite_client_preliminary(nua_client_request_t *cr,
+                                        int status, char const *phrase,
+                                        sip_t const *sip);
+static int nua_invite_client_response(nua_client_request_t *cr,
+                                     int status, char const *phrase,
+                                     sip_t const *sip);
+static int nua_session_client_response(nua_client_request_t *cr,
+                                      int status, char const *phrase,
+                                      sip_t const *sip);
+static int nua_invite_client_report(nua_client_request_t *cr,
+                                   int status, char const *phrase,
+                                   sip_t const *sip,
+                                   nta_outgoing_t *orq,
+                                   tagi_t const *tags);
+
+nua_client_methods_t const nua_invite_client_methods = {
+  SIP_METHOD_INVITE,
+  0,
+  { 
+    /* create_dialog */ 1,
+    /* in_dialog */ 1,
+    /* target refresh */ 1
+  },
+  NULL,
+  nua_invite_client_init,
+  nua_invite_client_request,
+  session_timer_check_restart,
+  nua_invite_client_response,
+  nua_invite_client_preliminary,
+  nua_invite_client_report,
+  nua_invite_client_deinit
+};
+
+extern nua_client_methods_t const nua_bye_client_methods;
+extern nua_client_methods_t const nua_cancel_client_methods;
+extern nua_client_methods_t const nua_info_client_methods;
+extern nua_client_methods_t const nua_update_client_methods;
+extern nua_client_methods_t const nua_prack_client_methods;
+
+int nua_stack_invite(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+                    tagi_t const *tags)
+{
+  return nua_client_create(nh, e, &nua_invite_client_methods, tags);
 }
 
-static int
-nua_stack_invite2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                 int restarted,
-                 tagi_t const *tags)
+static int nua_invite_client_init(nua_client_request_t *cr, 
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags)
 {
+  nua_handle_t *nh = cr->cr_owner;
   nua_dialog_usage_t *du;
   nua_session_usage_t *ss;
-  nua_client_request_t *cr;
-  int offer_sent = 0;
 
-  msg_t *msg = NULL;
-  sip_t *sip = NULL;
+  cr->cr_usage = du = nua_dialog_usage_for_session(nh->nh_ds);
+  /* Errors returned by nua_invite_client_init() 
+     are neutral to session state */
+  cr->cr_neutral = 1;  
+  
+  if (nh_is_special(nh) || 
+      nua_stack_set_handle_special(nh, nh_has_invite, nua_i_error))
+    return nua_client_return(cr, 900, "Invalid handle for INVITE", msg);
+  else if (nh_referral_check(nh, tags) < 0)
+    return nua_client_return(cr, 900, "Invalid referral", msg);
+
+  if (du) {
+    nua_server_request_t *sr;
+    for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
+      /* INVITE in progress? */
+      if (sr->sr_usage == du && sr->sr_method == sip_method_invite &&
+         nua_server_request_is_pending(sr))
+       return nua_client_return(cr, SIP_491_REQUEST_PENDING, msg);
+  }
+  else
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
 
-  char const *what;
+  if (!du)
+    return -1;
+
+  if (nua_client_bind(cr, du) < 0)
+    return nua_client_return(cr, 900, "INVITE already in progress", msg);
 
-  du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
   ss = nua_dialog_usage_private(du);
-  cr = ss->ss_crequest;
-  what = nua_internal_error;           /* Internal error */
 
-  if (du == NULL)
-    goto failure;
+  session_timer_preferences(ss->ss_timer,
+                           sip,
+                           NH_PGET(nh, supported),                  
+                           NH_PGET(nh, session_timer),
+                           NUA_PISSET(nh->nh_nua, nh, session_timer),
+                           NH_PGET(nh, refresher),
+                           NH_PGET(nh, min_se));
 
-  if (cr->cr_orq) {
-    what = "INVITE request already in progress";
-    goto failure;
-  }
+  cr->cr_neutral = 0;
 
-  if (ss->ss_state == nua_callstate_terminated)
-    ss->ss_state = nua_callstate_init;
+  return 0;
+}
 
-  if (!restarted) {
-    session_timer_preferences(ss, 
-                             NH_PGET(nh, session_timer),
-                             NH_PGET(nh, min_se),
-                             NH_PGET(nh, refresher));
-  }
+static int nua_invite_client_request(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  int offer_sent = 0, retval;
+  sip_time_t invite_timeout;
 
-  if (restarted && !cr->cr_msg) {
-    if (du->du_msg)
-      cr->cr_msg = msg_dup(du->du_msg);
-    else
-      restarted = 0;
-  }
+  if (du == NULL)              /* Call terminated */ 
+    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
 
-  msg = nua_creq_msg(nua, nh, cr, restarted,
-                    SIP_METHOD_INVITE,
-                    NUTAG_USE_DIALOG(1),
-                    NUTAG_ADD_CONTACT(1),
-                    TAG_NEXT(tags));
-  sip = sip_object(msg);
+  assert(ss);
 
-  if (!sip) {
-    what = "Cannot Initialize Request";
-    goto failure;
-  }
+  invite_timeout = NH_PGET(nh, invite_timeout);
+  if (invite_timeout == 0)
+    invite_timeout = UINT_MAX;
+  /* Send CANCEL if we don't get response within timeout*/
+  /* nua_dialog_usage_set_expires(du, invite_timeout); Xyzzy */
+  nua_dialog_usage_set_refresh(du, 0);
 
-  if (!restarted) {
-    msg_destroy(du->du_msg), du->du_msg = msg_dup(msg);
-  }
+  /* Add session timer headers */
+  if (session_timer_is_supported(ss->ss_timer))
+    session_timer_add_headers(ss->ss_timer, ss->ss_state == nua_callstate_init,
+                             msg, sip);
+
+  ss->ss_100rel = NH_PGET(nh, early_media);
+  ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition");
+  if (ss->ss_precondition)
+    ss->ss_update_needed = ss->ss_100rel = 1;
 
   if (nh->nh_soa) {
     soa_init_offer_answer(nh->nh_soa);
 
     if (sip->sip_payload)
-      offer_sent = 0;
+      offer_sent = 0;          /* XXX - kludge */
     else if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
-      offer_sent = -1;
+      return -1;
     else
       offer_sent = 1;
-  }
-
-  if (offer_sent >= 0) {
-    sip_time_t invite_timeout = NH_PGET(nh, invite_timeout);
-    if (invite_timeout == 0)
-      invite_timeout = UINT_MAX;
-    /* Cancel if we don't get response within timeout*/
-    nua_dialog_usage_set_expires(du, invite_timeout);
-    nua_dialog_usage_set_refresh(du, 0);
-
-    /* Add session timer headers */
-    if (session_timer_is_supported(nh))
-      use_session_timer(ss, 0, prefer_session_timer(nh), msg, sip);
-
-    ss->ss_100rel = NH_PGET(nh, early_media);
-    ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition");
-
-    if (ss->ss_precondition)
-      ss->ss_update_needed = ss->ss_100rel = 1;
 
     if (offer_sent > 0 &&
-       session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-      what = "Internal media error"; goto failure;
-    }
+       session_include_description(nh->nh_soa, 1, msg, sip) < 0)
+      return nua_client_return(cr, 900, "Internal media error", msg);
 
-    if (nh->nh_soa &&
-       NH_PGET(nh, media_features) && !nua_dialog_is_established(nh->nh_ds) &&
+    if (NH_PGET(nh, media_features) &&
+       !nua_dialog_is_established(nh->nh_ds) &&
        !sip->sip_accept_contact && !sip->sip_reject_contact) {
       sip_accept_contact_t ac[1];
       sip_accept_contact_init(ac);
@@ -609,188 +680,308 @@ nua_stack_invite2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
        sip_add_dup(msg, sip, (sip_header_t *)ac);
       }
     }
+  }
+  else {
+    offer_sent = session_get_description(sip, NULL, NULL);
+  }
 
-    if (nh->nh_auth) {
-      if (auc_authorize(&nh->nh_auth, msg, sip) < 0) {
-       what = "Internal authentication error"; goto failure;
-      }
-    }
-
-      cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                       process_response_to_invite, nh, NULL,
-                                       msg,
-                                       NTATAG_REL100(ss->ss_100rel),
-                                       SIPTAG_END(), TAG_NEXT(tags));
+  retval = nua_base_client_trequest(cr, msg, sip,
+                                   NTATAG_REL100(ss->ss_100rel),
+                                   TAG_NEXT(tags));
+  if (retval == 0) {
+    cr->cr_offer_sent = offer_sent;
+    ss->ss_oa_sent = offer_sent ? "offer" : NULL;
 
-    if (cr->cr_orq) {
-      cr->cr_offer_sent = offer_sent;
-      cr->cr_usage = du;
-      du->du_refresh = 0;
-      signal_call_state_change(nh, ss, 0, "INVITE sent",
-                              nua_callstate_calling, 0,
-                              offer_sent ? "offer" : 0);
-      return cr->cr_event = e;
-    }
+    if (!cr->cr_restarting)
+      signal_call_state_change(nh, ss, 0, "INVITE sent", 
+                              nua_callstate_calling);
   }
 
- failure:
+  return retval;
+}
 
-  msg_destroy(msg);
-  if (du && !du->du_ready)
-    nua_dialog_usage_remove(nh, nh->nh_ds, du), ss = NULL;
+static int nua_invite_client_response(nua_client_request_t *cr,
+                                     int status, char const *phrase,
+                                     sip_t const *sip)
+{
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+
+  if (ss == NULL || sip == NULL) {
+    /* Xyzzy */
+  }
+  else if (status < 300) {
+    du->du_ready = 1;
 
-  UA_EVENT2(e, 900, what);
-  signal_call_state_change(nh, ss, 900, what, nua_callstate_init, 0, 0);
+    if (session_timer_is_supported(ss->ss_timer))
+      session_timer_store(ss->ss_timer, sip);
 
-  return e;
+    session_timer_set(ss);
+  }
+  
+  return nua_session_client_response(cr, status, phrase, sip);
 }
 
-/** @NUA_EVENT nua_r_invite
- *
- * Answer to outgoing INVITE.
- *
- * The INVITE may be sent explicitly by nua_invite() or
- * implicitly by NUA state machine.
- *
- * @param status response status code
- *               (if the request is retried, @a status is 100, the @a
- *               sip->sip_status->st_status contain the real status code
- *               from the response message, e.g., 302, 401, or 407)
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle associated with the call
- * @param hmagic application context associated with the call
- * @param sip    response message to INVITE or NULL upon an error
- *               (status code is in @a status and 
- *                descriptive message in @a phrase parameters)
- * @param tags   empty
- *
- * @sa nua_invite(), @ref nua_call_model, #nua_i_state, #nua_i_invite, 
- * nua_ack(), NUTAG_AUTOACK()
- * 
- * @END_NUA_EVENT
- */
+static int nua_invite_client_preliminary(nua_client_request_t *cr,
+                                        int status, char const *phrase,
+                                        sip_t const *sip)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
 
-static int process_response_to_invite(nua_handle_t *nh,
-                                     nta_outgoing_t *orq,
-                                     sip_t const *sip)
+  assert(sip); assert(ss);
+
+  if (ss && sip && sip->sip_rseq) {
+    /* Handle 100rel responses */
+    sip_rseq_t *rseq = sip->sip_rseq;
+
+    /* Establish early dialog - we should fork here */
+    if (!nua_dialog_is_established(nh->nh_ds)) {
+      nta_outgoing_t *tagged;
+
+      nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+      nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+      
+      /* Tag the INVITE request */
+      tagged = nta_outgoing_tagged(cr->cr_orq,
+                                  nua_client_orq_response, cr,
+                                  sip->sip_to->a_tag, sip->sip_rseq);
+      if (tagged) {
+       nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = tagged;
+      }
+      else {
+       cr->cr_graceful = 1;
+       ss->ss_reason = "SIP;cause=500;text=\"Cannot Create Early Dialog\"";
+      }
+    }
+  
+    if (!rseq) {
+      SU_DEBUG_5(("nua(%p): 100rel missing RSeq\n", (void *)nh));
+    }
+    else if (nta_outgoing_rseq(cr->cr_orq) > rseq->rs_response) {
+      SU_DEBUG_5(("nua(%p): 100rel bad RSeq %u (got %u)\n", (void *)nh, 
+                 (unsigned)rseq->rs_response,
+                 nta_outgoing_rseq(cr->cr_orq)));
+      return 1;    /* Do not send event */
+    }
+    else if (nta_outgoing_setrseq(cr->cr_orq, rseq->rs_response) < 0) {
+      SU_DEBUG_1(("nua(%p): cannot set RSeq %u\n", (void *)nh, 
+                 (unsigned)rseq->rs_response));
+      cr->cr_graceful = 1;
+      ss->ss_reason = "SIP;cause=400;text=\"Bad RSeq\"";
+    }
+  }
+
+  return nua_session_client_response(cr, status, phrase, sip);
+}
+
+/** Process response to a session request (INVITE, PRACK, UPDATE) */
+static int nua_session_client_response(nua_client_request_t *cr,
+                                      int status, char const *phrase,
+                                      sip_t const *sip)
 {
-  nua_t *nua = nh->nh_nua;
-  nua_client_request_t *cr;
-  nua_dialog_usage_t *du;
-  nua_session_usage_t *ss;
-  int status = sip->sip_status->st_status;
-  char const *phrase = sip->sip_status->st_phrase;
-  int terminated = 0;
-  int gracefully = 1;
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+
+  char const *sdp = NULL;
+  size_t len;
   char const *received = NULL;
 
-  cr = nua_client_request_by_orq(nh->nh_ds->ds_cr, orq);
-  du = cr ? cr->cr_usage : NULL;
-  ss = nua_dialog_usage_private(du);
-  
-  assert(cr && du && ss);
+#define LOG3(m) \
+  SU_DEBUG_3(("nua(%p): %s: %s %s in %u %s\n", \
+             (void *)nh, cr->cr_method_name, (m),              \
+             received ? received : "SDP", status, phrase))
+#define LOG5(m) \
+  SU_DEBUG_5(("nua(%p): %s: %s %s in %u %s\n", \
+             (void *)nh, cr->cr_method_name, (m), received, status, phrase))
 
-  if (ss->ss_state == nua_callstate_terminating && 200 <= status) {
-    /*
-     * If the call is being terminated but re-INVITE was responded with 2XX
-     * re-send the BYE, otherwise terminate the call.
-     */
-    gracefully = status < 300, terminated = !gracefully;
+  if (!ss || !sip || 300 <= status)
+    /* Xyzzy */;
+  else if (!session_get_description(sip, &sdp, &len))
+    /* No SDP */;
+  else if (cr->cr_answer_recv) {
+    /* Ignore spurious answers after completing O/A */
+    LOG3("ignoring duplicate");
+    sdp = NULL;
   }
-  else if (status >= 300) {
-    if (sip->sip_retry_after)
-      gracefully = 0;
+  else if (cr->cr_offer_sent) {
+    /* case 1: incoming answer */
+    cr->cr_answer_recv = status;
+    received = "answer";
 
-    terminated = sip_response_terminates_dialog(status, sip_method_invite,
-                                               &gracefully);
-
-    if (!terminated) {
-      if (check_session_timer_restart(nh, ss, cr, orq, sip, restart_invite))
-       return 0;
+    if (nh->nh_soa == NULL)
+      LOG5("got SDP");
+    else if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
+      LOG3("error parsing SDP");
+      sdp = NULL;
+      cr->cr_graceful = 1;
+      ss->ss_reason = "SIP;cause=400;text=\"Malformed Session Description\"";
+    }
+    else if (soa_process_answer(nh->nh_soa, NULL) < 0) {
+      LOG5("error processing SDP");
+      /* XXX */
+      sdp = NULL;
+    }
+    else if (soa_activate(nh->nh_soa, NULL) < 0)
+      /* XXX - what about errors? */
+      LOG3("error activating media after");
+    else
+      LOG5("processed SDP");
+  }
+  else if (cr->cr_method != sip_method_invite) {
+    /* If non-invite request did not have offer, ignore SDP in response */
+    LOG3("ignoring extra");
+    sdp = NULL;
+  }
+  else {
+    /* case 2: answer to our offer */
+    cr->cr_offer_recv = 1, cr->cr_answer_sent = 0;
+    received = "offer";
 
-      if (ss->ss_state < nua_callstate_ready)
-       terminated = 1;
+    if (nh->nh_soa && soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
+      LOG3("error parsing SDP");
+      sdp = NULL;
+      cr->cr_graceful = 1;
+      ss->ss_reason = "SIP;cause=400;text=\"Malformed Session Description\"";
     }
+    else 
+      LOG5("got SDP");
   }
-  else if (status >= 200) {
-    du->du_ready = 1;
-    cr->cr_usage = NULL;
 
-    /* XXX - check remote tag, handle forks */
-    /* Set route, contact, nh_ds->ds_remote_tag */
-    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+  if (ss && received)
+    ss->ss_oa_recv = received;
+
+  if (sdp && nh->nh_soa)
+    return nua_base_client_tresponse(cr, status, phrase, sip,
+                                    NH_REMOTE_MEDIA_TAGS(1, nh->nh_soa),
+                                    TAG_END());
+  else
+    return nua_base_client_response(cr, status, phrase, sip, NULL);
+}
+
+static int nua_invite_client_report(nua_client_request_t *cr,
+                                   int status, char const *phrase,
+                                   sip_t const *sip,
+                                   nta_outgoing_t *orq,
+                                   tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  unsigned next_state;
+  int error;
+
+  nh_referral_respond(nh, status, phrase);
 
-    init_session_timer(ss, sip, NH_PGET(nh, refresher));
-    set_session_timer(ss);
+  nua_stack_event(nh->nh_nua, nh, 
+                 nta_outgoing_getresponse(orq),
+                 cr->cr_event,
+                 status, phrase,
+                 tags);
 
-    /* signal_call_state_change */
-    if (session_process_response(nh, cr, orq, sip, &received) >= 0) {
-      ss->ss_ack_needed = received ? received : "";
+  if (orq != cr->cr_orq && status != 100)
+    return 1;
 
-      if (NH_PGET(nh, auto_ack) ||
-         /* Auto-ACK response to re-INVITE unless auto_ack is set to 0 */
-         (ss->ss_state == nua_callstate_ready &&
-          !NH_PISSET(nh, auto_ack)))
-       nua_stack_ack(nua, nh, nua_r_ack, NULL);
-      else
-       signal_call_state_change(nh, ss, status, phrase,
-                                nua_callstate_completing, received, 0);
-      nh_referral_respond(nh, SIP_200_OK);
-      return 0;
-    }
+  if (ss == NULL) {
+    signal_call_state_change(nh, ss, status, phrase, nua_callstate_terminated);
+    return 1;
+  }
 
-    status = 500, phrase = "Malformed Session in Response";
+  ss->ss_reporting = 1;
 
-    nua_stack_ack(nua, nh, nua_r_ack, NULL);
-    gracefully = 1;
+  if (cr->cr_neutral) {
+    signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
+    ss->ss_reporting = 0;
+    return 1;
   }
-  else if (sip->sip_rseq) {
-    /* Reliable provisional response */
-    nh_referral_respond(nh, status, phrase);
 
-    return process_100rel(nh, ss, orq, sip); /* signal_call_state_change */
+  if (status == 100) {
+    next_state = nua_callstate_calling;
+  }
+  else if (status < 300 && cr->cr_graceful) {
+    next_state = nua_callstate_terminating;
+    if (200 <= status) {
+      nua_invite_client_ack(cr, NULL);
+    }
+  }
+  else if (status < 200) {
+    next_state = nua_callstate_proceeding;
+
+    if (sip && sip->sip_rseq && 
+       !SIP_IS_ALLOWED(NH_PGET(nh, appl_method), sip_method_prack)) {
+      sip_rack_t rack[1];
+
+      sip_rack_init(rack);
+      rack->ra_response    = sip->sip_rseq->rs_response;
+      rack->ra_cseq        = sip->sip_cseq->cs_seq;
+      rack->ra_method      = sip->sip_cseq->cs_method;
+      rack->ra_method_name = sip->sip_cseq->cs_method_name;
+
+      error = nua_client_tcreate(nh, nua_r_prack, &nua_prack_client_methods, 
+                                SIPTAG_RACK(rack),
+                                TAG_END());
+      if (error < 0) {
+       cr->cr_graceful = 1;
+       next_state = nua_callstate_terminating;
+      }
+    }
+  }
+  else if (status < 300) {
+    next_state = nua_callstate_completing;
+  }
+  else if (cr->cr_terminated) {
+    next_state = nua_callstate_terminated;
+  }
+  else if (cr->cr_graceful && ss->ss_state >= nua_callstate_completing) {
+    next_state = nua_callstate_terminating;
   }
   else {
-    /* Provisional response */
-    nh_referral_respond(nh, status, phrase);
-    session_process_response(nh, cr, orq, sip, &received);
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_proceeding, received, 0);
-    return 0;
+    next_state = nua_callstate_init;
   }
 
-  cr->cr_usage = NULL;
-
-  nh_referral_respond(nh, status, phrase);
-  nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+  if (next_state == nua_callstate_calling) {
+    if (sip && sip->sip_status && sip->sip_status->st_status == 100) {
+      ss->ss_reporting = 0;
+      return 1;
+    }
+  }
 
-  if (terminated)
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_terminated, 0, 0);
+  if (next_state == nua_callstate_completing) {
+    if (NH_PGET(nh, auto_ack) ||
+       /* Auto-ACK response to re-INVITE unless auto_ack is set to 0 */
+       (ss->ss_state == nua_callstate_ready &&
+        !NH_PISSET(nh, auto_ack))) {
 
-  if (terminated < 0) {
-    nua_dialog_terminated(nh, nh->nh_ds, status, phrase);
-  }
-  else if (terminated > 0) {
-    nua_dialog_usage_remove(nh, nh->nh_ds, du);
+      if (nua_invite_client_ack(cr, NULL) > 0)
+       next_state = nua_callstate_ready;
+      else
+       next_state = nua_callstate_terminating;
+    }
   }
-  else if (gracefully) {
-    char *reason =
-      su_sprintf(NULL, "SIP;cause=%u;text=\"%s\"", 
-                status > 699 ? 500 : status, phrase);
 
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_terminating, 0, 0);
-
-    nua_stack_post_signal(nh, nua_r_bye,
-                         SIPTAG_REASON_STR(reason),
-                         TAG_END());
+  if (next_state == nua_callstate_terminating) {
+    /* Send BYE or CANCEL */
+    /* XXX - Forking - send BYE to early dialog?? */
+    if (ss->ss_state > nua_callstate_proceeding || status >= 200)
+      error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
+    else
+      error = nua_client_create(nh, nua_r_cancel, 
+                               &nua_cancel_client_methods, tags);
 
-    su_free(NULL, reason);
+    if (error) {
+      next_state = nua_callstate_terminated;
+      cr->cr_terminated = 1;
+    }
+    cr->cr_graceful = 0;
   }
 
-  return 0;
+  ss->ss_reporting = 0;
+
+  signal_call_state_change(nh, ss, status, phrase, next_state);
+
+  return 1;
 }
 
 /**@fn void nua_ack(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
@@ -798,7 +989,7 @@ static int process_response_to_invite(nua_handle_t *nh,
  * Acknowledge a succesful response to INVITE request.
  *
  * Acknowledge a successful response (200..299) to INVITE request with the
- * SIP ACK request message. This function is need only if NUTAG_AUTOACK()
+ * SIP ACK request message. This function is needed only if NUTAG_AUTOACK()
  * parameter has been cleared.
  *
  * @param nh              Pointer to operation handle
@@ -820,201 +1011,200 @@ static int process_response_to_invite(nua_handle_t *nh,
 int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
                  tagi_t const *tags)
 {
-  nua_session_usage_t *ss;
-  nua_client_request_t *cr;
-  nta_outgoing_t *ack = NULL;
-  msg_t *msg;
-  sip_t *sip;
-  int status = 200;
-  char const *phrase = "OK", *reason = NULL, *sent = NULL;
-  char const *received;
-
-  ss = nua_session_usage_get(nh->nh_ds);
-  cr = ss->ss_crequest;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_client_request_t *cr = du ? du->du_cr : NULL;
+  int error;
 
-  received = ss ? ss->ss_ack_needed : NULL;
+  if (!cr || cr->cr_orq == NULL || cr->cr_status < 200) {
+    UA_EVENT2(nua_i_error, 900, "No response to ACK");
+    return 1;
+  }
 
-  if (!received)
-    return UA_EVENT2(nua_i_error, 900, "No response to ACK");
+  if (tags) {
+    nua_stack_set_params(nua, nh, nua_i_error, tags);
+    if (nh->nh_soa)
+      soa_set_params(nh->nh_soa, TAG_NEXT(tags));
+  }
 
-  ss->ss_ack_needed = 0;
+  error = nua_invite_client_ack(cr, tags);
+
+  if (error < 0) {
+    if (ss->ss_reason == NULL)
+      ss->ss_reason = "SIP;cause=500;text=\"Internal Error\"";
+    ss->ss_reporting = 1;      /* We report state here if BYE fails */
+    error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
+    ss->ss_reporting = 0;
+    signal_call_state_change(nh, ss, 500, "Internal Error", 
+                            error 
+                            ? nua_callstate_terminated
+                            : nua_callstate_terminating);
+  }
+  else if (ss)
+    signal_call_state_change(nh, ss, 200, "ACK sent", nua_callstate_ready);
 
-  if (!received[0])
-    received = NULL;
+  if (!nua_client_is_queued(cr) && !nua_client_is_bound(cr))
+    nua_client_request_destroy(cr);
 
-  if (tags)
-    nua_stack_set_params(nua, nh, nua_i_error, tags);
+  nua_client_next_request(nh->nh_ds->ds_cr, 1);
 
-  msg = nua_creq_msg(nua, nh, cr, 0,
-                    SIP_METHOD_ACK,
-                    /* NUTAG_COPY(0), */
-                    TAG_NEXT(tags));
-  sip = sip_object(msg);
+  return 0;
+}
 
-  if (sip && nh->nh_soa) {
-    if (tags)
-      soa_set_params(nh->nh_soa, TAG_NEXT(tags));
+/** Send ACK, destroy INVITE transaction.
+ *
+ *  @retval 1 if successful
+ *  @retval < 0 if an error occurred
+ */
+static
+int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
 
-    if (cr->cr_offer_recv && !cr->cr_answer_sent) {
-      if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
-         session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-       reason = soa_error_as_sip_reason(nh->nh_soa);
+  msg_t *msg;
+  sip_t *sip;
+  int error = -1;
+  sip_authorization_t *wa;
+  sip_proxy_authorization_t *pa;
+  sip_cseq_t *cseq;
+  nta_outgoing_t *ack;
+  int status = 200;
+  char const *phrase = "OK", *reason = NULL;
+
+  assert(ds->ds_leg);
+  assert(cr->cr_orq);
+
+  msg = nta_outgoing_getrequest(cr->cr_orq);
+  sip = sip_object(msg);  
+  if (!msg)
+    return -1;
+  
+  wa = sip_authorization(sip);
+  pa = sip_proxy_authorization(sip);
+  
+  msg_destroy(msg);
+
+  msg = nta_msg_create(nh->nh_nua->nua_nta, 0);
+  sip = sip_object(msg);  
+  if (!msg)
+    return -1;
+
+  cseq = sip_cseq_create(msg_home(msg), cr->cr_seq, SIP_METHOD_ACK);
+
+  if (!cseq)
+    ;
+  else if (nh->nh_tags && sip_add_tl(msg, sip, TAG_NEXT(nh->nh_tags)) < 0)
+    ;
+  else if (tags && sip_add_tl(msg, sip, TAG_NEXT(tags)) < 0)
+    ;
+  else if (wa && sip_add_dup(msg, sip, (sip_header_t *)wa) < 0)
+    ;
+  else if (pa && sip_add_dup(msg, sip, (sip_header_t *)pa) < 0)
+    ;
+  else if (sip_header_insert(msg, sip, (sip_header_t *)cseq) < 0)
+    ;
+  else if (nta_msg_request_complete(msg, ds->ds_leg, SIP_METHOD_ACK, NULL) < 0)
+    ;
+  else {
+    /* Remove extra headers */
+    while (sip->sip_allow)
+      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_allow);
+    while (sip->sip_priority)
+      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_priority);
+    while (sip->sip_proxy_require)
+      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_proxy_require);
+    while (sip->sip_require)
+      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_require);
+    while (sip->sip_subject)
+      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_subject);
+    while (sip->sip_supported)
+      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_supported);
+
+    if (ss == NULL || ss->ss_state >= nua_callstate_ready)
+      ;
+    else if (cr->cr_offer_recv && !cr->cr_answer_sent) {
+      if (nh->nh_soa == NULL) {
+       if (session_get_description(sip, NULL, NULL))
+         cr->cr_answer_sent = 1, ss->ss_oa_sent = "answer";
+      }
+      else if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
+         session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
        status = 900, phrase = "Internal media error";
        reason = "SIP;cause=500;text=\"Internal media error\"";
+       /* reason = soa_error_as_sip_reason(nh->nh_soa); */
       }
       else {
-       cr->cr_answer_sent = 1;
-       soa_activate(nh->nh_soa, NULL);
-
-       /* signal that O/A round is complete */
-       sent = "answer";
+       cr->cr_answer_sent = 1, ss->ss_oa_sent = "answer";
       }
     }
 
-    if (!reason &&
-       /* ss->ss_offer_sent && !ss->ss_answer_recv */
-       !soa_is_complete(nh->nh_soa)) {
-      /* No SDP answer in 2XX response -> terminate call */
+    if (ss == NULL || ss->ss_state >= nua_callstate_ready || reason)
+      ;
+    else if (nh->nh_soa
+            ? soa_is_complete(nh->nh_soa)
+            : !(cr->cr_offer_sent && !cr->cr_answer_recv)) {
+      /* signal that O/A round(s) is (are) complete */
+      if (nh->nh_soa) 
+       soa_activate(nh->nh_soa, NULL);
+    }
+    else {
+      /* No SDP answer -> terminate call */
       status = 988, phrase = "Incomplete offer/answer";
       reason = "SIP;cause=488;text=\"Incomplete offer/answer\"";
     }
-  }
-
-  if (sip) {
-    msg_t *imsg = nta_outgoing_getrequest(cr->cr_orq);
-    sip_t const *isip = sip_object(imsg);
-    if (isip->sip_proxy_authorization)
-      sip_add_dup(msg, sip, (void *)isip->sip_proxy_authorization);
-    if (isip->sip_authorization)
-      sip_add_dup(msg, sip, (void *)isip->sip_authorization);
-    msg_destroy(imsg);
-  }
-
-  if (sip)
-    ack = nta_outgoing_mcreate(nua->nua_nta, NULL, NULL, NULL, msg,
-                              SIPTAG_END(), TAG_NEXT(tags));
+    
+    if ((ack = nta_outgoing_mcreate(nh->nh_nua->nua_nta, NULL, NULL, NULL,
+                                   msg,
+                                   SIPTAG_END(),
+                                   TAG_NEXT(tags)))) {
+      nta_outgoing_destroy(ack);       /* TR engine keeps this around for T2 */
 
-  if (!ack) {
-    if (!reason) {
+      if (nh->nh_soa && reason && ss && ss->ss_state <= nua_callstate_ready)
+       nua_stack_event(nh->nh_nua, nh, NULL,
+                       nua_i_media_error, status, phrase,
+                       NULL);
+    }
+    else if (!reason) {
       status = 900, phrase = "Cannot send ACK";
       reason = "SIP;cause=500;text=\"Internal Error\"";
     }
-    msg_destroy(msg);
-  }
 
-  nua_creq_deinit(cr, NULL);   /* Destroy INVITE transaction */
-  nta_outgoing_destroy(ack);   /* TR engine keeps this around for T2 */
+    if (ss && reason)
+      ss->ss_reason = reason;
 
-  if (status < 300) {
-    signal_call_state_change(nh, ss, status, phrase, nua_callstate_ready,
-                            received, sent);
-  }
-  else {
-    signal_call_state_change(nh, ss, status, phrase, nua_callstate_terminating,
-                            0, 0);
-    nua_stack_post_signal(nh, nua_r_bye,
-                         SIPTAG_REASON_STR(reason),
-                         TAG_END());
+    if (status < 300)
+      error = 1;
+    else
+      error = -2;
   }
 
-  return 0;
-}
-
-
-/* Process reliable provisional response */
-static int
-process_100rel(nua_handle_t *nh,
-              nua_session_usage_t *ss,
-              nta_outgoing_t *orq,
-              sip_t const *sip)
-{
-  nua_client_request_t *cr_invite = ss->ss_crequest;
-  nua_client_request_t *cr_prack = nh->nh_ds->ds_cr;
-  
-  sip_rseq_t *rseq;
-  char const *recv = NULL;
-  int status; char const *phrase;
-
-  if (cr_prack->cr_orq) {
-    /* XXX - better luck next time */
-    SU_DEBUG_3(("nua(%p): cannot send PRACK because %s is pending\n", nh,
-               nta_outgoing_method_name(cr_prack->cr_orq)));
-    return 0; /* Wait until this response is re-transmitted */
-  }
+  if (error == -1)
+    msg_destroy(msg);
 
-  if (!nua_dialog_is_established(nh->nh_ds)) {
-    /* Establish early dialog */
-    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-    
-    /* Tag the INVITE request */
-    cr_invite->cr_orq =
-      nta_outgoing_tagged(orq, process_response_to_invite, nh,
-                         sip->sip_to->a_tag, sip->sip_rseq);
-    nta_outgoing_destroy(orq);
-    orq = cr_invite->cr_orq;
-  }
+  nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = NULL;
+  nua_client_request_remove(cr);
   
-  assert(sip);
-
-  status = sip->sip_status->st_status, phrase = sip->sip_status->st_phrase;
-  rseq = sip->sip_rseq;
-
-  if (!rseq) {
-    SU_DEBUG_5(("nua(%p): 100rel missing RSeq\n", nh));
-  }
-  else if (rseq->rs_response <= nta_outgoing_rseq(orq)) {
-    SU_DEBUG_5(("nua(%p): 100rel bad RSeq %u (got %u)\n", nh, 
-               (unsigned)rseq->rs_response,
-               nta_outgoing_rseq(orq)));
-    /* XXX - send nua_r_invite event or not? */
-    return 0;
-  }
-  else if (nta_outgoing_setrseq(orq, rseq->rs_response) < 0) {
-    SU_DEBUG_1(("nua(%p): cannot set RSeq %u\n", nh, 
-               (unsigned)rseq->rs_response));
-  }
-  else if (session_process_response(nh, cr_invite, orq, sip, &recv) < 0) {
-    assert(nh->nh_soa);
-    status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-    nua_stack_event(nh->nh_nua, nh, NULL,
-                   nua_i_media_error, status, phrase, TAG_END());
-  }
-  /* Here we could let application PRACK and just send state event */
-  else {
-    sip_rack_t rack[1];
-    tagi_t tags[] = {
-      { TAG_SKIP(nua_stack_prack) }, /* this is autoprack */
-      { NUTAG_STATUS(status), },
-      { NUTAG_PHRASE(phrase), },
-      { NUTAG_PHRASE(recv), },
-      { SIPTAG_RACK(rack) }, 
-      { TAG_END() }
-    };
-
-    sip_rack_init(rack);
-
-    rack->ra_response    = sip->sip_rseq->rs_response;
-    rack->ra_cseq        = sip->sip_cseq->cs_seq;
-    rack->ra_method      = sip->sip_cseq->cs_method;
-    rack->ra_method_name = sip->sip_cseq->cs_method_name;
-
-    nua_stack_prack(nh->nh_nua, nh, nua_r_prack, tags);
-
-    return 0;
-  }
+  return error;
+}
 
-  /* XXX - CANCEL INVITE or BYE this session? */
-  /* Because we don't do forking very well we just cancel INVITE */
-  nua_stack_cancel(nh->nh_nua, nh, nua_r_cancel, NULL);
+/** Deinitialize client request */
+static int nua_invite_client_deinit(nua_client_request_t *cr)
+{
+  if (cr->cr_orq == NULL)
+    /* Xyzzy */;
+  else if (cr->cr_status < 200)
+    nta_outgoing_cancel(cr->cr_orq);
+  else
+    nua_invite_client_ack(cr, NULL);
 
   return 0;
 }
 
-/**@fn void nua_prack(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
- * Send a PRACK request. 
+/**@fn void nua_cancel(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
- * PRACK is used to acknowledge receipt of 100rel responses. See @RFC3262.
+ * Cancel an INVITE operation 
  *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
@@ -1023,300 +1213,137 @@ process_100rel(nua_handle_t *nh,
  *    nothing
  *
  * @par Related Tags:
- *    Tags in <sofia-sip/soa_tag.h>, <sofia-sip/sip_tag.h>.
+ *    Tags in <sip_tag.h>
  *
  * @par Events:
- *    #nua_r_prack
+ *    #nua_r_cancel, #nua_i_state  (#nua_i_active, #nua_i_terminated)
+ *
+ * @sa @ref nua_call_model, nua_invite(), #nua_i_cancel
  */
 
-/** @NUA_EVENT nua_r_prack
+static int nua_cancel_client_request(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags);
+
+nua_client_methods_t const nua_cancel_client_methods = {
+  SIP_METHOD_CANCEL,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 1,
+    /* target refresh */ 0
+  },
+  NULL,
+  NULL,
+  nua_cancel_client_request,
+  /* nua_cancel_client_check_restart */ NULL,
+  /* nua_cancel_client_response */ NULL
+};
+
+int nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+                    tagi_t const *tags)
+{
+  return nua_client_create(nh, e, &nua_cancel_client_methods, tags);
+}
+
+static int nua_cancel_client_request(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+
+  if (!du || !du->du_cr || !du->du_cr->cr_orq || 
+      nta_outgoing_status(du->du_cr->cr_orq) >= 200) {
+    return nua_client_return(cr, 481, "No transaction to CANCEL", msg);
+  }
+
+  cr->cr_orq = nta_outgoing_tcancel(du->du_cr->cr_orq,
+                                   nua_client_orq_response, cr,
+                                   TAG_NEXT(tags));
+
+  return cr->cr_orq ? 0 : -1;
+}
+
+/** @NUA_EVENT nua_r_cancel
  *
- * Response to an outgoing @b PRACK request. PRACK request is used to
- * acknowledge reliable preliminary responses and it is usually sent
- * automatically by the nua stack.
+ * Answer to outgoing CANCEL.
  *
- * @param status response status code
- *               (if the request is retried, @a status is 100, the @a
- *               sip->sip_status->st_status contain the real status code
- *               from the response message, e.g., 302, 401, or 407)
+ * The CANCEL may be sent explicitly by nua_cancel() or implicitly by NUA
+ * state machine.
+ *
+ * @param status response status code 
  * @param phrase a short textual description of @a status code
  * @param nh     operation handle associated with the call
  * @param hmagic application context associated with the call
- * @param sip    response to @b PRACK or NULL upon an error
+ * @param sip    response to CANCEL request or NULL upon an error
  *               (status code is in @a status and 
  *                descriptive message in @a phrase parameters)
  * @param tags   empty
  *
- * @sa nua_prack(), #nua_i_prack, @RFC3262
+ * @sa nua_cancel(), @ref nua_uac_call_model, #nua_r_invite, nua_invite(),
+ * #nua_i_state
  *
  * @END_NUA_EVENT
  */
 
-
-int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                   tagi_t const *tags)
-{
-  nua_session_usage_t *ss;
-  nua_client_request_t *cr;
-  msg_t *msg;
-  sip_t *sip;
-  int offer_sent_in_prack = 0, answer_sent_in_prack = 0;
-
-  int status = 0; char const *phrase = "PRACK sent";
-  char const *recv = NULL, *sent = NULL;
-
-  int autoprack =              /* XXX - should have common indication */
-    tags && tags->t_tag == tag_skip && 
-    tags->t_value == (tag_value_t)nua_stack_prack;
-
-  if (autoprack) {
-    status = (int)tags[1].t_value; 
-    phrase = (char const *)tags[2].t_value;
-    recv = (char const *)tags[3].t_value;
-    tags += 4;
-  }
-
-  ss = nua_session_usage_get(nh->nh_ds);
-
-  if (!ss || !ss->ss_crequest || !nta_outgoing_rseq(ss->ss_crequest->cr_orq))
-    return UA_EVENT2(e, 900, "Nothing to PRACK");
-  else if (nh->nh_ds->ds_cr->cr_orq)
-    return UA_EVENT2(e, 900, "Request already in progress");
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  cr = nh->nh_ds->ds_cr;
-
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                    SIP_METHOD_PRACK,
-                    NUTAG_USE_DIALOG(1),
-                    NUTAG_ADD_CONTACT(1),
-                    TAG_NEXT(tags));
-
-  sip = sip_object(msg);
-
-  if (sip) {
-    nua_client_request_t *cri = ss->ss_crequest;
-    if (nh->nh_soa == NULL)
-      /* It is up to application to handle SDP */;
-    else if (sip->sip_payload)
-      /* XXX - we should just do MIME in session_include_description() */;
-    else if (cri->cr_offer_recv && !cri->cr_answer_sent) {
-
-      if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
-         session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-
-       status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-       SU_DEBUG_3(("nua(%p): PRACK answer: %d %s\n", nh, status, phrase));
-       nua_stack_event(nh->nh_nua, nh, NULL,
-                       nua_i_media_error, status, phrase, TAG_END());
-
-       goto error;
-      }
-      else {
-       answer_sent_in_prack = 1, sent = "answer";
-       soa_activate(nh->nh_soa, NULL);
-      }
-    }
-    /* When 100rel response status was 183 fake support for preconditions */
-    else if (autoprack && status == 183 && ss->ss_precondition) {
-
-      if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
-         session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-
-       status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-       SU_DEBUG_3(("nua(%p): PRACK offer: %d %s\n", nh, status, phrase));
-       nua_stack_event(nh->nh_nua, nh, NULL,
-                       nua_i_media_error, status, phrase, TAG_END());
-       goto error;
-      }
-      else {
-       offer_sent_in_prack = 1, sent = "offer";
-      }
-    }
-
-    if (nh->nh_auth) {
-      if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
-       /* xyzzy */;
-    }
-
-    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                     process_response_to_prack, nh, NULL,
-                                     msg,
-                                     SIPTAG_END(), TAG_NEXT(tags));
-    if (cr->cr_orq) {
-      cr->cr_usage = nua_dialog_usage_public(ss);
-      cr->cr_event = nua_r_prack;
-
-      if (answer_sent_in_prack)
-       cri->cr_answer_sent = 1;
-      else if (offer_sent_in_prack)
-       cr->cr_offer_sent = 1;
-
-      if (autoprack) 
-       signal_call_state_change(nh, ss, status, phrase,
-                                nua_callstate_proceeding, recv, sent);
-      else
-       signal_call_state_change(nh, ss, 0, "PRACK sent",
-                                nua_callstate_proceeding, NULL, sent);
-       
-
-      return cr->cr_event = e;
-    }
-  }
-
- error:
-  msg_destroy(msg);
-  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-}
-
-void restart_prack(nua_handle_t *nh, tagi_t *tags)
-{
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_prack, tags);
-}
-
-
-static int
-process_response_to_prack(nua_handle_t *nh,
-                         nta_outgoing_t *orq,
-                         sip_t const *sip)
-{
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
-  int status;
-  char const *phrase = "OK", *reason = NULL, *recv = NULL;
-
-  assert(cr->cr_usage && cr->cr_usage->du_class == nua_session_usage);
-
-  if (sip)
-    status = sip->sip_status->st_status, phrase = sip->sip_status->st_phrase;
-  else
-    status = 408, phrase = sip_408_Request_timeout;
-
-  SU_DEBUG_5(("nua: process_response_to_prack: %u %s\n", status, phrase));
-
-  if (nua_creq_check_restart(nh, cr, orq, sip, restart_prack))
-    return 0;
-
-  if (status < 200)
-    return 0;
-
-  cr->cr_usage = NULL;
-
-  if (status < 300) {
-    if (session_process_response(nh, cr, orq, sip, &recv) < 0) {
-      status = 900, phrase = "Malformed Session in Response";
-      reason = "SIP;status=400;phrase=\"Malformed Session in Response\"";
-    }
-  }
-  else
-    nua_stack_process_response(nh, cr, orq, sip, TAG_END());
-
-  if (recv)
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_proceeding, recv, NULL);
-
-  if (status < 300 && ss->ss_update_needed)
-    nua_stack_update(nh->nh_nua, nh, nua_r_update, NULL);
-
-  return 0;
-}
-
-/** Refresh session usage */
 static void nua_session_usage_refresh(nua_handle_t *nh,
                                      nua_dialog_state_t *ds,
                                      nua_dialog_usage_t *du,
                                      sip_time_t now)
 {
-  tagi_t const timer_tags[2] = {
-    { SIPTAG_SUBJECT_STR("Session refresh") }, 
-    { TAG_END() }
-  };
-  tagi_t const refresh_tags[2] = {
-    { SIPTAG_SUBJECT_STR("Dialog refresh") }, 
-    { TAG_END() }
-  };
-
-  nua_session_usage_t const *ss = nua_dialog_usage_private(du);
-  nua_client_request_t const *cri = ss->ss_crequest, *cro = ds->ds_cr;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_client_request_t const *cr = du->du_cr;
   nua_server_request_t const *sr;
 
+  if (ss->ss_state >= nua_callstate_terminating || 
+      /* INVITE is in progress or being authenticated */
+      (cr && (cr->cr_orq || cr->cr_wait_for_cred)))
+    return;
+
+  /* UPDATE has been queued */
+  for (cr = ds->ds_cr; cr; cr = cr->cr_next) 
+    if (cr->cr_method == sip_method_update)
+      return;
+
+  /* INVITE or UPDATE in progress on server side */
   for (sr = ds->ds_sr; sr; sr = sr->sr_next)
     if (sr->sr_usage == du && 
        (sr->sr_method == sip_method_invite || 
         sr->sr_method == sip_method_update))
-      break;
+      return;
 
-  /* INVITE or UPDATE in progress or being authenticated */
-  if ((cri && cri->cr_orq) || sr)      
-    return;
-  if (ss->ss_state >= nua_callstate_terminating)
+  if (ss->ss_timer->refresher == nua_remote_refresher) {
+    ss->ss_reason = "SIP;cause=408;text=\"Session timeout\""; 
+    nua_stack_bye(nh->nh_nua, nh, nua_r_bye, NULL);
     return;
-
-  if (!ss->ss_refresher) {
-    if (now >= du->du_expires)
-      session_timeout(nh, du, now);
-    else
-      /* Refreshing contact & route set */
-      nua_stack_invite2(nh->nh_nua, nh, nua_r_invite, 1, refresh_tags);
   }
   else if (NH_PGET(nh, update_refresh)) {
-    if (!cro->cr_orq)
-      nua_stack_update(nh->nh_nua, nh, nua_r_update, timer_tags);
-    else
-      nua_dialog_usage_refresh_range(du, 5, 15);
+    nua_stack_update(nh->nh_nua, nh, nua_r_update, NULL);
   }
-  else {
-    nua_stack_invite2(nh->nh_nua, nh, nua_r_invite, 1, timer_tags);
+  else if (du->du_cr) {
+    nua_client_resend_request(du->du_cr, 0);
   }
-}
-
-static
-char const reason_timeout[] = "SIP;cause=408;text=\"Session timeout\"";
-
-static void
-session_timeout(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now)
-{
-  if (now > 1) {
-    nua_session_usage_t *ss = nua_dialog_usage_private(du);
-
-    signal_call_state_change(nh, ss, 408, "Session Timeout",
-                            nua_callstate_terminating, NULL, NULL);
-
-    nua_stack_post_signal(nh, nua_r_bye,
-                         SIPTAG_REASON_STR(reason_timeout),
-                         TAG_END());
+  else {
+    nua_stack_invite(nh->nh_nua, nh, nua_r_invite, NULL);
   }
 }
 
-/** Terminate usage/dialog/handle/agent gracefully */
+/** @interal Shut down session usage. 
+ *
+ * @retval >0  shutdown done
+ * @retval 0   shutdown in progress
+ * @retval <0  try again later
+ */
 static int nua_session_usage_shutdown(nua_handle_t *nh,
                                      nua_dialog_state_t *ds,
                                      nua_dialog_usage_t *du)
 {
   nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  nua_client_request_t *cr;
   nua_server_request_t *sr, *sr_next;
-  int status;
+  nua_client_request_t *cri;
 
-  /* Zap client-side invite transaction */
-  if (ss->ss_crequest->cr_orq) {
-    cr = ss->ss_crequest;
-    status = nta_outgoing_status(cr->cr_orq);
-
-    if (status < 200) 
-      nta_outgoing_tcancel(cr->cr_orq, NULL, NULL, TAG_END());
-
-    if (ss->ss_ack_needed) {
-      msg_t *ack = nua_creq_msg(nh->nh_nua, nh, cr, 0,
-                               SIP_METHOD_ACK,
-                               TAG_END());
-      nta_outgoing_mcreate(nh->nh_nua->nua_nta, NULL, NULL, NULL, 
-                          ack, TAG_END());
-    }
-
-    nua_creq_deinit(cr, NULL);
-  }
+  assert(ss == nua_session_usage_for_dialog(nh->nh_ds));
 
   /* Zap server-side transactions */
   for (sr = ds->ds_sr; sr; sr = sr_next) {
@@ -1324,54 +1351,58 @@ static int nua_session_usage_shutdown(nua_handle_t *nh,
     if (sr->sr_usage == du) {
       assert(sr->sr_usage == du);
       sr->sr_usage = NULL;
-      if (sr->sr_respond) 
-       nua_server_respond(sr, SIP_480_TEMPORARILY_UNAVAILABLE, TAG_END());
+
+      if (nua_server_request_is_pending(sr)) {
+       SR_STATUS1(sr, SIP_480_TEMPORARILY_UNAVAILABLE);
+       nua_server_respond(sr, NULL);
+       if (nua_server_report(sr) >= 2)
+         return 480;
+      }
       else
        nua_server_request_destroy(sr);
     }
   }
 
-  assert(ss == nua_session_usage_get(nh->nh_ds));
+  cri = du->du_cr;
 
   switch (ss->ss_state) {
+  case nua_callstate_calling:
+  case nua_callstate_proceeding:
+    return nua_client_create(nh, nua_r_cancel, &nua_cancel_client_methods, NULL);
+
   case nua_callstate_completing:
-  case nua_callstate_ready:
   case nua_callstate_completed:
-    {
-      msg_t *bye;
-
-      cr = ds->ds_cr;
-      nua_creq_deinit(cr, NULL);
-      bye = nua_creq_msg(nh->nh_nua, nh, ds->ds_cr, 0, 
-                        SIP_METHOD_BYE,
-                        TAG_END());
-      cr->cr_orq = nta_outgoing_mcreate(nh->nh_nua->nua_nta,
-                                       NULL, NULL, NULL,
-                                       bye,
-                                       TAG_END());
-      nua_creq_deinit(cr, NULL);
+  case nua_callstate_ready:
+    if (cri && cri->cr_orq) {
+      if (cri->cr_status < 200)
+       nua_client_create(nh, nua_r_cancel, &nua_cancel_client_methods, NULL);
+      else if (cri->cr_status < 300)
+       nua_invite_client_ack(cri, NULL);
     }
-  }
+    if (nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL) != 0)
+      break;
 
-  nua_dialog_usage_remove(nh, ds, du);
+    signal_call_state_change(nh, ss, 487, "BYE sent",
+                            nua_callstate_terminating);
+    return 0;
 
-  return 0;
-}
+  case nua_callstate_terminating:
+  case nua_callstate_terminated: /* XXX */
+    return 0;
 
-/** Restart invite (e.g., after 302 or 407) */
-void
-restart_invite(nua_handle_t *nh, tagi_t *tags)
-{
-  nua_stack_invite2(nh->nh_nua, nh, nua_r_invite, 1, tags);
-}
+  default:
+    break;
+  }
+  
+  nua_dialog_usage_remove(nh, ds, du);
 
-static int process_response_to_cancel(nua_handle_t *nh,
-                                     nta_outgoing_t *orq,
-                                     sip_t const *sip);
+  return 200;
+}
 
-/**@fn void nua_cancel(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
+/**@fn void nua_prack(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
+ * Send a PRACK request. 
  *
- * Cancel an INVITE operation 
+ * PRACK is used to acknowledge receipt of 100rel responses. See @RFC3262.
  *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
@@ -1380,108 +1411,205 @@ static int process_response_to_cancel(nua_handle_t *nh,
  *    nothing
  *
  * @par Related Tags:
- *    Tags in <sip_tag.h>
+ *    Tags in <sofia-sip/soa_tag.h>, <sofia-sip/sip_tag.h>.
  *
  * @par Events:
- *    #nua_r_cancel, #nua_i_state  (#nua_i_active, #nua_i_terminated)
+ *    #nua_r_prack
+ */
+
+/** @NUA_EVENT nua_r_prack
  *
- * @sa @ref nua_call_model, nua_invite(), #nua_i_cancel
+ * Response to an outgoing @b PRACK request. PRACK request is used to
+ * acknowledge reliable preliminary responses and it is usually sent
+ * automatically by the nua stack.
+ *
+ * @param status response status code
+ *               (if the request is retried, @a status is 100, the @a
+ *               sip->sip_status->st_status contain the real status code
+ *               from the response message, e.g., 302, 401, or 407)
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle associated with the call
+ * @param hmagic application context associated with the call
+ * @param sip    response to @b PRACK or NULL upon an error
+ *               (status code is in @a status and 
+ *                descriptive message in @a phrase parameters)
+ * @param tags   empty
+ *
+ * @sa nua_prack(), #nua_i_prack, @RFC3262
+ *
+ * @END_NUA_EVENT
  */
 
-int
-nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                tagi_t const *tags)
+static int nua_prack_client_init(nua_client_request_t *cr, 
+                                msg_t *msg, sip_t *sip,
+                                tagi_t const *tags);
+static int nua_prack_client_request(nua_client_request_t *cr,
+                                   msg_t *msg, sip_t *sip,
+                                   tagi_t const *tags);
+static int nua_prack_client_response(nua_client_request_t *cr,
+                                    int status, char const *phrase,
+                                    sip_t const *sip);
+static int nua_prack_client_report(nua_client_request_t *cr,
+                                  int status, char const *phrase,
+                                  sip_t const *sip,
+                                  nta_outgoing_t *orq,
+                                  tagi_t const *tags);
+
+nua_client_methods_t const nua_prack_client_methods = {
+  SIP_METHOD_PRACK,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 1,
+    /* target refresh */ 0
+  },
+  NULL,
+  nua_prack_client_init,
+  nua_prack_client_request,
+  /* nua_prack_client_check_restart */ NULL,
+  nua_prack_client_response,
+  NULL,
+  nua_prack_client_report
+};
+
+int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+                    tagi_t const *tags)
 {
-  nua_session_usage_t *ss;
-  nua_client_request_t *cri, *crc;
+  return nua_client_create(nh, e, &nua_prack_client_methods, tags);
+}
+
+static int nua_prack_client_init(nua_client_request_t *cr, 
+                                msg_t *msg, sip_t *sip,
+                                tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+
+  cr->cr_usage = du;
+
+  return 0;
+}
 
-  ss = nua_session_usage_get(nh->nh_ds);
+static int nua_prack_client_request(nua_client_request_t *cr,
+                                   msg_t *msg, sip_t *sip,
+                                   tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_client_request_t *cri;
+  int offer_sent = 0, answer_sent = 0, retval;
+  int status = 0; char const *phrase = "PRACK Sent";
+  uint32_t rseq = 0;
 
-  if (!nh || !ss || !ss->ss_crequest->cr_usage ||
-      nta_outgoing_status(ss->ss_crequest->cr_orq) >= 200) {
-    return UA_EVENT2(e, 481, "No transaction to CANCEL");
-  }
+  if (du == NULL)              /* Call terminated */
+    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
+  assert(ss);
 
-  cri = ss->ss_crequest;
-  crc = nh->nh_ds->ds_cr;
+  cri = du->du_cr;
 
-  if (tags)
-    nua_stack_set_params(nua, nh, nua_i_error, tags);
+  if (sip->sip_rack)
+    rseq = sip->sip_rack->ra_response;
 
-  if (nh && cri->cr_orq && cri->cr_usage) {
-    nta_outgoing_t *orq;
+  if (cri->cr_offer_recv && !cri->cr_answer_sent) {
+    if (nh->nh_soa == NULL) 
+      /* It is up to application to handle SDP */
+      answer_sent = session_get_description(sip, NULL, NULL);
+    else if (sip->sip_payload)
+      /* XXX - we should just do MIME in session_include_description() */;
+    else if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
+            session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+      SU_DEBUG_3(("nua(%p): local response to PRACK: %d %s\n",
+                 (void *)nh, status, phrase));
+      nua_stack_event(nh->nh_nua, nh, NULL,
+                     nua_i_media_error, status, phrase,
+                     NULL);
+      return nua_client_return(cr, status, phrase, msg);
+    }
+    else {
+      answer_sent = 1;
+      soa_activate(nh->nh_soa, NULL);
+    }
+  }
+  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 (cri->cr_status == 183 && ss->ss_precondition) {
+    if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
+       session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+      SU_DEBUG_3(("nua(%p): PRACK offer: %d %s\n", (void *)nh,
+                 status, phrase));
+      nua_stack_event(nh->nh_nua, nh, NULL,
+                     nua_i_media_error, status, phrase, NULL);
+      return nua_client_return(cr, status, phrase, msg);
+    }
+    else {
+      offer_sent = 1;
+    }
+  }
 
-    /* nh_referral_respond(nh, SIP_487_REQUEST_TERMINATED); */
+  retval = nua_base_client_request(cr, msg, sip, NULL);
 
-    if (e)
-      orq = nta_outgoing_tcancel(cri->cr_orq, process_response_to_cancel, nh,
-                                TAG_NEXT(tags));
-    else
-      orq = nta_outgoing_tcancel(cri->cr_orq, NULL, NULL, TAG_NEXT(tags));
+  if (retval == 0) {
+    cr->cr_offer_sent = offer_sent;
+    cr->cr_answer_sent = answer_sent;
 
-    if (orq == NULL)
-      return nua_stack_event(nua, nh, NULL, e, 400, "Internal error",
-                            TAG_END());
+    if (!cr->cr_restarting) {
+      if (offer_sent) 
+       ss->ss_oa_sent = "offer";
+      else if (answer_sent)
+       ss->ss_oa_sent = "answer";
 
-    if (e && crc->cr_orq == NULL)
-      crc->cr_orq = orq, crc->cr_event = e;
+      if (!ss->ss_reporting)
+       signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
+    }
   }
 
-  return 0;
+  return retval;
 }
 
-/** @NUA_EVENT nua_r_cancel
- *
- * Answer to outgoing CANCEL.
- *
- * The CANCEL may be sent explicitly by nua_cancel() or implicitly by NUA
- * state machine.
- *
- * @param status response status code 
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle associated with the call
- * @param hmagic application context associated with the call
- * @param sip    response to CANCEL request or NULL upon an error
- *               (status code is in @a status and 
- *                descriptive message in @a phrase parameters)
- * @param tags   empty
- *
- * @sa nua_cancel(), @ref nua_uac_call_model, #nua_r_invite, nua_invite(),
- * #nua_i_state
- *
- * @END_NUA_EVENT
- */
-
+static int nua_prack_client_response(nua_client_request_t *cr,
+                                    int status, char const *phrase,
+                                    sip_t const *sip)
+{
+  /* XXX - fatal error cases? */
 
+  return nua_session_client_response(cr, status, phrase, sip);
+}
 
-static int process_response_to_cancel(nua_handle_t *nh,
-                                     nta_outgoing_t *orq,
-                                     sip_t const *sip)
+static int nua_prack_client_report(nua_client_request_t *cr,
+                                  int status, char const *phrase,
+                                  sip_t const *sip,
+                                  nta_outgoing_t *orq,
+                                  tagi_t const *tags)
 {
-  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
-}
+  nua_handle_t *nh = cr->cr_owner;
+  nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
 
-/* ---------------------------------------------------------------------- */
-/* UAS side of INVITE */
+  nua_stack_event(nh->nh_nua, nh, 
+                 nta_outgoing_getresponse(orq),
+                 cr->cr_event,
+                 status, phrase,
+                 tags);
 
-static int respond_to_invite(nua_server_request_t *sr, tagi_t const *tags);
+  if (!ss || orq != cr->cr_orq || cr->cr_terminated || cr->cr_graceful)
+    return 1;
 
-static int
-  preprocess_invite(nua_t *, nua_handle_t *, nua_server_request_t **, sip_t *),
-  session_check_request(nua_t *nua,
-                       nua_handle_t *nh,
-                       nta_incoming_t *irq,
-                       sip_t const *sip),
-  process_invite(nua_t *, nua_handle_t *, nua_server_request_t *, sip_t *),
-  process_prack(nua_handle_t *, nta_reliable_t *, nta_incoming_t *,
-               sip_t const *);
+  if (cr->cr_offer_sent)
+    signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
 
-static int
-  process_ack_or_cancel(nua_server_request_t *, nta_incoming_t *, 
-                       sip_t const *),
-  process_ack(nua_server_request_t *, nta_incoming_t *, sip_t const *),
-  process_cancel(nua_server_request_t *, nta_incoming_t *, sip_t const *),
-  process_timeout(nua_server_request_t *, nta_incoming_t *);
+  if (ss->ss_update_needed && 200 <= status && status < 300 &&
+      !SIP_IS_ALLOWED(NH_PGET(nh, appl_method), sip_method_update))
+    nua_client_create(nh, nua_r_update, &nua_update_client_methods, NULL);
+  
+  return 1;
+}
+
+/* ---------------------------------------------------------------------- */
+/* UAS side of INVITE */
 
 /** @NUA_EVENT nua_i_invite
  *
@@ -1528,16 +1656,18 @@ static int
  * the 2XX response. If @soa is not disabled with NUTAG_MEDIA_ENABLE(0), the
  * SDP should be included in the SOATAG_USER_SDP() or SOATAG_USER_SDP_STR()
  * parameter given to nua_respond(). If it is disabled, the SDP should be
- * included in message
+ * included in the response message using SIPTAG_PAYLOAD() or
+ * SIPTAG_PAYLOAD_STR(). Also, the @ContentType should be set using
+ * SIPTAG_CONTENT_TYPE() or SIPTAG_CONTENT_TYPE_STR().
  *
  * @par Preliminary Responses and 100rel
  *
  * Call progress can be signaled with preliminary responses (with status
  * code in the range 101..199). It is possible to conclude the SDP
  * Offer-Answer negotiation using preliminary responses, too. If
- * SOATAG_USER_SDP() or SOATAG_USER_SDP_STR() parameter is included with in
- * a preliminary nua_response(), the SDP answer is generated and sent with
- * the preliminary responses, too.
+ * NUTAG_EARLY_ANSWER(1), SOATAG_USER_SDP() or SOATAG_USER_SDP_STR()
+ * parameter is included with in a preliminary nua_response(), the SDP
+ * answer is generated and sent with the preliminary responses, too.
  *
  * The preliminary responses are sent reliably if feature tag "100rel" is
  * included in the @Require header of the response or if
@@ -1560,7 +1690,8 @@ static int
  *
  * @sa nua_respond(), @ref nua_uas_call_model, #nua_i_state,
  * NUTAG_MEDIA_ENABLE(), SOATAG_USER_SDP(), SOATAG_USER_SDP_STR(),
- * @RFC3262, NUTAG_EARLY_MEDIA(), NUTAG_ONLY183_100REL(), 
+ * @RFC3262, NUTAG_EARLY_ANSWER(), NUTAG_EARLY_MEDIA(), 
+ * NUTAG_ONLY183_100REL(), 
  * NUTAG_INCLUDE_EXTRA_SDP(),
  * #nua_i_prack, #nua_i_update, nua_update(),
  * nua_invite(), #nua_r_invite
@@ -1579,208 +1710,202 @@ static int
  * @END_NUA_EVENT
  */
 
-/** @internal Process incoming INVITE. */
-int nua_stack_process_invite(nua_t *nua,
-                            nua_handle_t *nh,
-                            nta_incoming_t *irq,
-                            sip_t const *sip)
-{
-  nua_server_request_t *sr, sr0[1];
-  int status;
-  
-  sr = SR_INIT(sr0);
-  sr->sr_irq = irq;
-
-  status = preprocess_invite(nua, nh, &sr, (sip_t *)sip);
+static int nua_invite_server_init(nua_server_request_t *sr);
+static int nua_session_server_init(nua_server_request_t *sr);
+static int nua_invite_server_preprocess(nua_server_request_t *sr);
+static int nua_invite_server_respond(nua_server_request_t *sr, tagi_t const *);
+static int nua_invite_server_is_100rel(nua_server_request_t *, tagi_t const *);
+static int nua_invite_server_report(nua_server_request_t *sr, tagi_t const *);
 
-  if (status) {
-    if (sr->sr_status > 100) 
-      nta_incoming_treply(irq, sr->sr_status, sr->sr_phrase,
-                         SIPTAG_USER_AGENT_STR(NUA_PGET(nua, nh, user_agent)),
-                         TAG_END());
-    nua_server_request_destroy(sr);
-    /* if something has failed, respond with 500 Internal Server Error */
-    return 500; 
-  }
+static int
+  process_ack_or_cancel(nua_server_request_t *, nta_incoming_t *, 
+                       sip_t const *),
+  process_ack(nua_server_request_t *, nta_incoming_t *, sip_t const *),
+  process_cancel(nua_server_request_t *, nta_incoming_t *, sip_t const *),
+  process_timeout(nua_server_request_t *, nta_incoming_t *),
+  process_prack(nua_server_request_t *,
+               nta_reliable_t *rel,
+               nta_incoming_t *irq,
+               sip_t const *sip);
 
-  assert(sr != sr0);
+nua_server_methods_t const nua_invite_server_methods = 
+  {
+    SIP_METHOD_INVITE,
+    nua_i_invite,              /* Event */
+    { 
+      1,                       /* Create dialog */
+      0,                       /* Initial request */
+      1,                       /* Target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_invite_server_init,
+    nua_invite_server_preprocess,
+    nua_base_server_params,
+    nua_invite_server_respond,
+    nua_invite_server_report,
+  };
 
-  return process_invite(nua, sr->sr_owner, sr, (sip_t *)sip);
-}
 
 /** @internal Preprocess incoming invite - sure we have a valid request. 
  * 
- * @return 0 if request is valid, or error statuscode when request has been 
- * responded.
+ * @return 0 if request is valid, or error statuscode otherwise
  */
-static
-int preprocess_invite(nua_t *nua,
-                     nua_handle_t *nh,
-                     nua_server_request_t **inout_sr,
-                     sip_t *sip)
-{
-  nua_dialog_state_t *ds;
-  nua_server_request_t *sr = *inout_sr;
-  nua_server_request_t const *sr0;
-  nua_dialog_usage_t *du;
-  nua_session_usage_t *ss;
-  int have_sdp;
-  char const *sdp;
-  size_t len;
-
-  if (nh) {
-    ds = nh->nh_ds;
-    du = nua_dialog_usage_get(ds, nua_session_usage, NULL);
-    ss = nua_dialog_usage_private(du);
-  }
-  else {
-    nh = nua->nua_dhandle, ds = NULL, du = NULL, ss = NULL;
-  }
+static int
+nua_invite_server_init(nua_server_request_t *sr)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_t *nua = nh->nh_nua;
 
-  sr->sr_usage = du;
+  sr->sr_neutral = 1;
 
   if (!NUA_PGET(nua, nh, invite_enable))
     return SR_STATUS1(sr, SIP_403_FORBIDDEN);
 
-  if (session_check_request(nua, nh, sr->sr_irq, sip))
-    return 500;
-
-  have_sdp = session_get_description(sip, &sdp, &len);
+  if (nua_session_server_init(sr))
+    return sr->sr_status;
+    
+  if (sr->sr_usage) {
+    /* Existing session - check for overlap and glare */ 
 
-  if (ss) {
-    /* Existing session */ 
+    nua_server_request_t const *sr0;
+    nua_client_request_t const *cr;
 
-    for (sr0 = ds->ds_sr; sr0; sr0 = sr0->sr_next) {
+    for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) {
       /* Final response have not been sent to previous INVITE */
-      if (sr0->sr_method == sip_method_invite && sr0->sr_respond)
+      if (sr0->sr_method == sip_method_invite && 
+         nua_server_request_is_pending(sr0))
        break;
-      /* Or we have sent offer but have not received answer */
-      if (have_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
+      /* Or we have sent offer but have not received an answer */
+      if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
        break;
-      /* Or we have received request with offer but not sent answer */
-      if (have_sdp && sr0->sr_offer_recv && !sr0->sr_answer_sent)
+      /* Or we have received request with offer but not sent an answer */
+      if (sr->sr_sdp && sr0->sr_offer_recv && !sr0->sr_answer_sent)
        break;
     }
     
-    if (sr0)
+    if (sr0) {
       /* Overlapping invites - RFC 3261 14.2 */
-      return respond_with_retry_after(nh, sr->sr_irq, 
-                                     500, "Overlapping Requests",
-                                     0, 10);
+      return nua_server_retry_after(sr, 500, "Overlapping Requests", 0, 10);
+    }
 
-    if ((ss->ss_crequest && ss->ss_crequest->cr_orq) ||
-       (have_sdp && ds && ds->ds_cr->cr_orq && ds->ds_cr->cr_offer_sent)) {
-      /* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
-      return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
+    for (cr = nh->nh_ds->ds_cr; cr; cr = cr->cr_next) {
+      if (cr->cr_usage == sr->sr_usage && cr->cr_orq && cr->cr_offer_sent)
+       /* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
+       return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
     }
   }
 
-  /* Create handle and server request structure when needed */
-  sr = nua_server_request(nua, nh, sr->sr_irq, sip, sr, sizeof *sr,
-                         respond_to_invite, create_dialog);
-  *inout_sr = sr;
+  sr->sr_neutral = 0;
 
-  if (sr->sr_status > 100)
-    return sr->sr_status;
+  return 0;
+}
+
+/** Initialize session server request.
+ *
+ * Ensure that the request is valid.
+ */
+static int
+nua_session_server_init(nua_server_request_t *sr)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_t *nua = nh->nh_nua;
+
+  msg_t *msg = sr->sr_response.msg;
+  sip_t *sip = sr->sr_response.sip;
 
-  nh = sr->sr_owner; assert(nh != nua->nua_dhandle);
-  ds = nh->nh_ds;
+  sip_t const *request = sr->sr_request.sip;
+
+  if (!sr->sr_initial)
+    sr->sr_usage = nua_dialog_usage_get(nh->nh_ds, nua_session_usage, NULL);
+
+  if (sr->sr_method != sip_method_invite && sr->sr_usage == NULL) {
+    /* UPDATE/PRACK sent within an existing dialog? */
+    return SR_STATUS(sr, 481, "Call Does Not Exist");
+  }
 
   if (nh->nh_soa) {
-    soa_init_offer_answer(nh->nh_soa);
+    sip_accept_t *a = nua->nua_invite_accept;
 
-    if (have_sdp) {
-      if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
-       SU_DEBUG_5(("nua(%p): error parsing SDP in INVITE\n", nh));
-       return SR_STATUS(sr, 400, "Bad Session Description");
-      }
-      else
-       sr->sr_offer_recv = 1;
+    /* XXX - soa should know what it supports */
+    sip_add_dup(msg, sip, (sip_header_t *)a);
+
+    /* Make sure caller uses application/sdp without compression */
+    if (nta_check_session_content(NULL, request, a, TAG_END())) {
+      sip_add_make(msg, sip, sip_accept_encoding_class, "");
+      return SR_STATUS1(sr, SIP_415_UNSUPPORTED_MEDIA);
     }
-  }
 
-  /* Add the session usage */
-  if (du == NULL)
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
+    /* Make sure caller accepts application/sdp */
+    if (nta_check_accept(NULL, request, a, NULL, TAG_END())) {
+      sip_add_make(msg, sip, sip_accept_encoding_class, "");
+      return SR_STATUS1(sr, SIP_406_NOT_ACCEPTABLE);
+    }
+  }
 
-  if (!du)
-    return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  if (request->sip_session_expires &&
+      sip_has_feature(NH_PGET(nh, supported), "timer") &&
+      session_timer_check_min_se(msg, sip, request, NH_PGET(nh, min_se))) {
+    if (sip->sip_min_se)
+      return SR_STATUS1(sr, SIP_422_SESSION_TIMER_TOO_SMALL);
+    else
+      return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
 
-  sr->sr_usage = du;
+  session_get_description(request, &sr->sr_sdp, &sr->sr_sdp_len);
 
   return 0;
 }
 
-static int
-session_check_request(nua_t *nua,
-                     nua_handle_t *nh,
-                     nta_incoming_t *irq,
-                     sip_t const *sip)
+/** Preprocess INVITE.
+ *
+ * This is called after a handle has been created for an incoming INVITE.
+ */
+int nua_invite_server_preprocess(nua_server_request_t *sr)
 {
-  char const *user_agent = NUA_PGET(nua, nh, user_agent);
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_session_usage_t *ss;
 
-  if (nh->nh_soa) {
-    /* Make sure caller uses application/sdp without compression */
-    if (nta_check_session_content(irq, sip,
-                                 nua->nua_invite_accept,
-                                 SIPTAG_USER_AGENT_STR(user_agent),
-                                 SIPTAG_ACCEPT_ENCODING_STR(""),
-                                 TAG_END()))
-      return 415;
+  sip_t const *request = sr->sr_request.sip;
 
-    /* Make sure caller accepts application/sdp */
-    if (nta_check_accept(irq, sip,
-                        nua->nua_invite_accept,
-                        NULL,
-                        SIPTAG_USER_AGENT_STR(user_agent),
-                        SIPTAG_ACCEPT_ENCODING_STR(""),
-                        TAG_END()))
-      return 406;
-  }
-
-  if (sip->sip_session_expires) {
-    unsigned min_se = NH_PGET(nh, min_se);
-    if (sip->sip_min_se && min_se < sip->sip_min_se->min_delta)
-      min_se = sip->sip_min_se->min_delta;
-    if (nta_check_session_expires(irq, sip,
-                                 min_se,
-                                 SIPTAG_USER_AGENT_STR(user_agent),
-                                 TAG_END()))
-      return 422;
+  assert(sr->sr_status == 100);
+  assert(nh != nh->nh_nua->nua_dhandle);
+
+  if (sr->sr_status > 100)
+    return sr->sr_status;
+
+  if (nh->nh_soa)
+    soa_init_offer_answer(nh->nh_soa);
+
+  if (sr->sr_sdp) {
+    if (nh->nh_soa && 
+       soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {
+      SU_DEBUG_5(("nua(%p): %s server: error parsing SDP\n", (void *)nh, 
+                 "INVITE"));
+      return SR_STATUS(sr, 400, "Bad Session Description");
+    }
+    else
+      sr->sr_offer_recv = 1;
   }
 
-  return 0;
-}
+  /* Add the session usage */
+  if (sr->sr_usage == NULL) {
+    sr->sr_usage = nua_dialog_usage_add(nh, ds, nua_session_usage, NULL);
+    if (sr->sr_usage == NULL)
+      return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
 
-/** @internal Process incoming invite - initiate media, etc. */
-static
-int process_invite(nua_t *nua,
-                  nua_handle_t *nh,
-                  nua_server_request_t *sr,
-                  sip_t *sip)
-{
-  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
+  ss = nua_dialog_usage_private(sr->sr_usage);
 
-  assert(ss); assert(status == 100);
+  if (sr->sr_offer_recv)
+    ss->ss_oa_recv = "offer";
 
   ss->ss_100rel = NH_PGET(nh, early_media);
-  ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition");
+  ss->ss_precondition = sip_has_feature(request->sip_require, "precondition");
   if (ss->ss_precondition)
     ss->ss_100rel = 1;
 
-  session_timer_preferences(ss, 
-                           NH_PGET(nh, session_timer),
-                           NH_PGET(nh, min_se),
-                           NH_PGET(nh, refresher));
-
-  /* Session Timer negotiation */
-  if (sip_has_supported(NH_PGET(nh, supported), "timer"))
-    init_session_timer(ss, sip, ss->ss_refresher);
-
-  nua_dialog_uas_route(nh, nh->nh_ds, sip, 1); /* Set route and tags */
-
-  nta_incoming_bind(sr->sr_irq, process_ack_or_cancel, sr);
+  session_timer_store(ss->ss_timer, request);
 
   assert(ss->ss_state >= nua_callstate_ready ||
         ss->ss_state == nua_callstate_init);
@@ -1793,269 +1918,253 @@ int process_invite(nua_t *nua,
        */
        nh->nh_soa &&
        !NH_PISSET(nh, auto_answer))) {
-    SET_STATUS1(SIP_200_OK);
+    SR_STATUS1(sr, SIP_200_OK);
   }
   else if (NH_PGET(nh, auto_alert)) {
     if (ss->ss_100rel &&
-       (sip_has_feature(nh->nh_ds->ds_remote_ua->nr_supported, "100rel") ||
-        sip_has_feature(nh->nh_ds->ds_remote_ua->nr_require, "100rel"))) {
-      SET_STATUS1(SIP_183_SESSION_PROGRESS);
+       (sip_has_feature(request->sip_supported, "100rel") ||
+        sip_has_feature(request->sip_require, "100rel"))) {
+      SR_STATUS1(sr, SIP_183_SESSION_PROGRESS);
     }
     else {
-      SET_STATUS1(SIP_180_RINGING);
+      SR_STATUS1(sr, SIP_180_RINGING);
     }
   }
 
-  /* Magical value indicating autoanswer within respond_to_invite() */
-#define AUTOANSWER ((void*)-1)
-
-  if (status > 100) {
-    sr->sr_auto = 1;
-    nua_server_respond(sr, status, phrase, TAG_END());
-    sr->sr_auto = 0;
-    return 0;
-  }
-
-  nta_incoming_treply(sr->sr_irq, SIP_100_TRYING, 
-                     SIPTAG_USER_AGENT_STR(NUA_PGET(nua, nh, user_agent)),
-                     TAG_END());
-
-  nua_stack_event(nh->nh_nua, nh, 
-                 sr->sr_msg = nta_incoming_getrequest(sr->sr_irq),
-                 nua_i_invite, SIP_100_TRYING,
-                 NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
-                 TAG_END());
-
-  signal_call_state_change(nh, ss, SIP_100_TRYING,
-                          nua_callstate_received,
-                          sr->sr_offer_recv ? "offer" : 0, 0);
-
   return 0;
 }
 
+
 /** @internal Respond to an INVITE request.
  *
- * XXX - use tags to indicate when to use reliable responses.
- * XXX - change prototype.
  */
 static
-int respond_to_invite(nua_server_request_t *sr, tagi_t const *tags)
+int nua_invite_server_respond(nua_server_request_t *sr, tagi_t const *tags)
 {
   nua_handle_t *nh = sr->sr_owner;
-  nua_t *nua = nh->nh_nua;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_dialog_usage_t *du;
-  nua_session_usage_t *ss;
-  msg_t *msg;
-  sip_t *sip;
-  int reliable;
-  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
-  sip_warning_t *warning = NULL;
+  nua_dialog_usage_t *du = sr->sr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  msg_t *msg = sr->sr_response.msg; 
+  sip_t *sip = sr->sr_response.sip; 
 
-  int offer = 0, answer = 0, early_answer = 0;
+  int reliable = 0, offer = 0, answer = 0, early_answer = 0, extra = 0;
 
   enter;
 
-  du = sr->sr_usage, ss = nua_dialog_usage_private(du);
-
-  if (du == NULL)
-    return nua_default_respond(sr, tags);
-
-  assert(ss == nua_session_usage_get(nh->nh_ds));
-
-  if (tags) {
-    nua_stack_set_params(nua, nh, nua_i_error, tags);
+  if (du == NULL) {
+    if (sr->sr_status < 300)
+      sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    return nua_base_server_respond(sr, tags);
+  }
 
-    if (!NHP_ISSET(nh->nh_prefs, early_answer)
-       && 100 < status && status < 200) {
-      sdp_session_t const *user_sdp = NULL;
-      char const *user_sdp_str = NULL;
+  if (nua_invite_server_is_100rel(sr, tags)) {
+    reliable = 1, early_answer = 1;
+  }
+  else if (!nh->nh_soa || sr->sr_status >= 300) {
+    
+  }
+  else if (tags && 100 < sr->sr_status && sr->sr_status < 200 && 
+          !NHP_ISSET(nh->nh_prefs, early_answer)) {
+    sdp_session_t const *user_sdp = NULL;
+    char const *user_sdp_str = NULL;
 
-      tl_gets(tags,
-             SOATAG_USER_SDP_REF(user_sdp),
-             SOATAG_USER_SDP_STR_REF(user_sdp_str),
-             TAG_END());
+    tl_gets(tags,
+           SOATAG_USER_SDP_REF(user_sdp),
+           SOATAG_USER_SDP_STR_REF(user_sdp_str),
+           TAG_END());
 
-      early_answer = user_sdp || user_sdp_str;
-    }
-    else
-      early_answer = NH_PGET(nh, early_answer);
-  }
-
-  msg = nua_server_response(sr,
-                           status, phrase,
-                           TAG_IF(status < 300, NUTAG_ADD_CONTACT(1)),
-                           SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
-                           TAG_NEXT(tags));
-  sip = sip_object(msg);
-
-  if (!sip) {
-    SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR), reliable = 0;
-    goto send_response;
-  }
-
-  reliable =
-    (status >= 200)
-    || (status > 100 && sip->sip_require &&
-       sip_has_feature(sip->sip_require, "100rel"))
-    || (status > 100 &&
-       ds->ds_remote_ua->nr_require &&
-       sip_has_feature(ds->ds_remote_ua->nr_require, "100rel"))
-    || (status > 100 && !NH_PGET(nh, only183_100rel) &&
-       (NH_PGET(nh, early_media) ||
-        (ds->ds_remote_ua->nr_require &&
-         sip_has_feature(ds->ds_remote_ua->nr_require, "precondition"))) &&
-       ds->ds_remote_ua->nr_supported &&
-       sip_has_feature(ds->ds_remote_ua->nr_supported, "100rel"))
-    || (status == 183 &&
-       ds->ds_remote_ua->nr_supported &&
-       sip_has_feature(ds->ds_remote_ua->nr_supported, "100rel"))
-    || (status == 183 &&
-       ds->ds_remote_ua->nr_require &&
-       sip_has_feature(ds->ds_remote_ua->nr_require, "precondition"))
-    || (status > 100 &&
-       ds->ds_remote_ua->nr_require &&
-       sip_has_feature(ds->ds_remote_ua->nr_require, "precondition") &&
-       sr->sr_offer_recv && !sr->sr_answer_sent);
-
-  if (!nh->nh_soa)
-    /* Xyzzy */;
-  else if (status >= 300) {
-    soa_clear_remote_sdp(nh->nh_soa);
+    early_answer = user_sdp || user_sdp_str;
   }
   else {
-    int extra = 0;
-
-    if (sr->sr_offer_sent && !sr->sr_answer_recv)
-      /* Wait for answer */;
-    else if (sr->sr_offer_recv && sr->sr_answer_sent > 1) {
-      /* We have sent answer */
-      /* ...  but we may want to send it again */
-      tagi_t const *t = tl_find_last(tags, nutag_include_extra_sdp);
-      extra = t && t->t_value;
-    }
-    else if (sr->sr_offer_recv && !sr->sr_answer_sent && 
-            (reliable || early_answer)) {
-      /* Generate answer */ 
-      if (soa_generate_answer(nh->nh_soa, NULL) >= 0) {
+    early_answer = NH_PGET(nh, early_answer);
+  }
+
+  if (!nh->nh_soa) {
+    if (session_get_description(sip, NULL, NULL)) {
+      if (sr->sr_offer_recv)
        answer = 1;
-       soa_activate(nh->nh_soa, NULL);
-       /* signal that O/A answer sent (answer to invite) */
-      }
-      else if (status >= 200) {
-       int wcode;
-       char const *text;
-       char const *host = "invalid.";
-       status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-
-       wcode = soa_get_warning(nh->nh_soa, &text);
-       if (wcode) {
-         if (sip->sip_contact)
-           host = sip->sip_contact->m_url->url_host;
-         warning = sip_warning_format(msg_home(msg), "%u %s \"%s\"",
-                                      wcode, host, text);
-       }
-      }
-      else {
-       /* 1xx - we don't have to send answer */
-      }
+      else if (sr->sr_offer_sent < 2)
+       offer = 1;
     }
-    else if (sr->sr_offer_recv && sr->sr_answer_sent == 1 && 
-            (reliable || early_answer)) {
-      /* The answer was sent unreliably, keep sending it */
+  }
+  else if (sr->sr_status >= 300) {
+    soa_clear_remote_sdp(nh->nh_soa);
+  }
+  else if (sr->sr_offer_sent && !sr->sr_answer_recv)
+    /* Wait for answer */;
+  else if (sr->sr_offer_recv && sr->sr_answer_sent > 1) {
+    /* We have sent answer */
+    /* ...  but we may want to send it again */
+    tagi_t const *t = tl_find_last(tags, nutag_include_extra_sdp);
+    extra = t && t->t_value;
+  }
+  else if (sr->sr_offer_recv && !sr->sr_answer_sent && early_answer) {
+    /* Generate answer */ 
+    if (soa_generate_answer(nh->nh_soa, NULL) >= 0) {
       answer = 1;
+      soa_activate(nh->nh_soa, NULL);
+      /* signal that O/A answer sent (answer to invite) */
     }
-    else if (!sr->sr_offer_recv && !sr->sr_offer_sent && reliable) {
-      /* Generate offer */
-      if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
-       status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-      else
-       offer = 1;
+    else if (sr->sr_status >= 200) {
+      sip_warning_t *warning = NULL;
+      int wcode;
+      char const *text;
+      char const *host = "invalid.";
+      
+      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
+      
+      wcode = soa_get_warning(nh->nh_soa, &text);
+      
+      if (wcode) {
+       if (sip->sip_contact)
+         host = sip->sip_contact->m_url->url_host;
+       warning = sip_warning_format(msg_home(msg), "%u %s \"%s\"",
+                                    wcode, host, text);
+       sip_header_insert(msg, sip, (sip_header_t *)warning);
+      }
     }
-
-    if (offer || answer || extra) {
-      if (session_include_description(nh->nh_soa, 1, msg, sip) < 0)
-       SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
+    else {
+      /* 1xx - we don't have to send answer */
     }
   }
+  else if (sr->sr_offer_recv && sr->sr_answer_sent == 1 && early_answer) {
+    /* The answer was sent unreliably, keep sending it */
+    answer = 1;
+  }
+  else if (!sr->sr_offer_recv && !sr->sr_offer_sent && reliable) {
+    /* Generate offer */
+    if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
+      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
+    else
+      offer = 1;
+  }
 
-  if (ss->ss_refresher && 200 <= status && status < 300)
-    if (session_timer_is_supported(nh))
-      use_session_timer(ss, 1, 1, msg, sip);
+  if (sr->sr_status < 300 && (offer || answer || extra)) {
+    if (nh->nh_soa && session_include_description(nh->nh_soa, 1, msg, sip) < 0)
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    else if (offer)
+      sr->sr_offer_sent = 1 + reliable, ss->ss_oa_sent = "offer";
+    else if (answer)
+      sr->sr_answer_sent = 1 + reliable, ss->ss_oa_sent = "answer";
+  }
 
-  if (reliable && status < 200) {
-    nta_reliable_t *rel;
-    rel = nta_reliable_mreply(sr->sr_irq,
-                             process_prack, nh, msg);
-    if (!rel)
-      SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
+  if (reliable && sr->sr_status < 200) {
+    sr->sr_response.msg = NULL, sr->sr_response.sip = NULL;
+    if (nta_reliable_mreply(sr->sr_irq, process_prack, sr, msg) == NULL)
+      return -1;
+    sr->sr_100rel = 1;
+    return 0;
   }
 
- send_response:
+  if (200 <= sr->sr_status && sr->sr_status < 300) {
+    session_timer_preferences(ss->ss_timer,
+                             sip,
+                             NH_PGET(nh, supported),                
+                             NH_PGET(nh, session_timer),
+                             NUA_PISSET(nh->nh_nua, nh, session_timer),
+                             NH_PGET(nh, refresher),
+                             NH_PGET(nh, min_se));
 
-  if (reliable && status < 200)
-    /* we are done */;
-  else if (status != sr->sr_status) {    /* Error responding */
-    assert(status >= 200);
-    sr->sr_respond = NULL;
-    nta_incoming_treply(sr->sr_irq,
-                       status, phrase,
-                       SIPTAG_WARNING(warning),
-                       SIPTAG_USER_AGENT_STR(NH_PGET(nh, user_agent)),
-                       TAG_END());
-    msg_destroy(msg), msg = NULL;
-  }
-  else {
-    if (status >= 200)
-      sr->sr_respond = NULL;
-    nta_incoming_mreply(sr->sr_irq, msg);
+    if (session_timer_is_supported(ss->ss_timer))
+      session_timer_add_headers(ss->ss_timer, 0, msg, sip);
   }
 
-  if (sr->sr_auto) {
-    msg_t *request = nta_incoming_getrequest(sr->sr_irq);
-    if (status < 200)
-      sr->sr_msg = request;
-    nua_stack_event(nh->nh_nua, nh, request,
-                   nua_i_invite, status, phrase,
-                   NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
-                   TAG_END());
+  return nua_base_server_respond(sr, tags);  
+}
+
+/** Check if the response should be sent reliably.
+ * XXX - use tags to indicate when to use reliable responses ???
+ */
+static
+int nua_invite_server_is_100rel(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  sip_t const *sip = sr->sr_response.sip;
+  sip_require_t *require = sr->sr_request.sip->sip_require;
+  sip_supported_t *supported = sr->sr_request.sip->sip_supported;
+
+  if (sr->sr_status >= 200)
+    return 1;
+  else if (sr->sr_status == 100)
+    return 0;
+
+  if (sip_has_feature(sip->sip_require, "100rel"))
+    return 1;
+
+  if (require == NULL && supported == NULL)
+    return 0;
+
+  if (sip_has_feature(require, "100rel"))
+    return 1;
+  if (!sip_has_feature(supported, "100rel"))
+    return 0;
+  if (sr->sr_status == 183)
+    return 1;
+
+  if (NH_PGET(nh, early_media) && !NH_PGET(nh, only183_100rel))
+    return 1;
+
+  if (sip_has_feature(require, "precondition")) {
+    if (!NH_PGET(nh, only183_100rel))
+      return 1;
+    if (sr->sr_offer_recv && !sr->sr_answer_sent)
+      return 1;
   }
-  else if (status != sr->sr_status)
-    nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, TAG_END());
 
-  sr->sr_status = status, sr->sr_phrase = phrase;
+  return 0;
+}
 
-  if (status >= 300)
-    offer = 0, answer = 0;
 
-  if (offer)
-    sr->sr_offer_sent = 1;
-  else if (answer)
-    sr->sr_answer_sent = 1 + reliable;
+int nua_invite_server_report(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_usage_t *du = sr->sr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  int initial = sr->sr_initial && !sr->sr_event;
+  int neutral = sr->sr_neutral;
+  int application = sr->sr_application;
+  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
+  int retval;
+
+  if (!sr->sr_event && status < 300) { /* Not reported yet */
+    nta_incoming_bind(sr->sr_irq, process_ack_or_cancel, sr);
+  }
+
+  retval = nua_base_server_report(sr, tags), sr = NULL; /* destroys sr */
+  
+  if (retval >= 2 || ss == NULL) {
+    /* Session has been terminated. */ 
+    if (!initial && !neutral)
+      signal_call_state_change(nh, NULL, status, phrase,
+                              nua_callstate_terminated);
+    return retval;
+  }
+
+  assert(ss);
 
   /* Update session state */
-  assert(ss->ss_state != nua_callstate_calling);
-  assert(ss->ss_state != nua_callstate_proceeding);
-
-  signal_call_state_change(nh, ss, status, phrase,
-                          status >= 300
-                          ? nua_callstate_init
-                          : status >= 200
-                          ? nua_callstate_completed
-                          : nua_callstate_early,
-                          sr->sr_auto && sr->sr_offer_recv ? "offer" : 0,
-                          offer ? "offer" : answer ? "answer" : 0);
+  if (status < 300 || application != 0) {
+    assert(ss->ss_state != nua_callstate_calling);
+    assert(ss->ss_state != nua_callstate_proceeding);
+    signal_call_state_change(nh, ss, status, phrase,
+                            status >= 300
+                            ? nua_callstate_init
+                            : status >= 200
+                            ? nua_callstate_completed
+                            : status > 100
+                            ? nua_callstate_early
+                            : nua_callstate_received);
+  }
 
   if (status == 180)
     ss->ss_alerting = 1;
   else if (status >= 200)
     ss->ss_alerting = 0;
 
-  if (status >= 200 && status < 300) {
-    du->du_ready = 1;
+  if (200 <= status && status < 300) {
+     du->du_ready = 1;
   }
-  else if (status >= 300) {
-    sr->sr_usage = NULL;
+  else if (300 <= status && !neutral) {
     if (nh->nh_soa)
       soa_init_offer_answer(nh->nh_soa);
   }
@@ -2065,10 +2174,9 @@ int respond_to_invite(nua_server_request_t *sr, tagi_t const *tags)
     nua_session_usage_destroy(nh, ss);
   }
 
-  return status >= 300 ? status : 0;
+  return retval;
 }
 
-
 /** @internal Process ACK or CANCEL or timeout (no ACK) for incoming INVITE */
 static
 int process_ack_or_cancel(nua_server_request_t *sr,
@@ -2088,139 +2196,6 @@ int process_ack_or_cancel(nua_server_request_t *sr,
     return process_timeout(sr, irq);
 }
 
-/** @NUA_EVENT nua_i_prack
- *
- * Incoming PRACK request. PRACK request is used to acknowledge reliable
- * preliminary responses and it is usually sent automatically by the nua
- * stack.
- *
- * @param status status code of response sent automatically by stack
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle associated with the call
- * @param hmagic application context associated with the call
- * @param sip    incoming INFO request
- * @param tags   empty
- *
- * @sa nua_prack(), #nua_r_prack, @RFC3262, NUTAG_EARLY_MEDIA()
- * 
- * @END_NUA_EVENT
- */
-
-/** @internal Process PRACK or (timeout from 100rel) */
-static
-int process_prack(nua_handle_t *nh,
-                 nta_reliable_t *rel,
-                 nta_incoming_t *irq,
-                 sip_t const *sip)
-{
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_dialog_usage_t *du;
-  nua_session_usage_t *ss;
-  nua_server_request_t *sri;
-  int status = 200; char const *phrase = sip_200_OK;
-  char const *recv = NULL, *sent = NULL;
-
-  nta_reliable_destroy(rel);
-
-  ss = nua_session_usage_get(ds); du = nua_dialog_usage_public(ss);
-
-  for (sri = ds->ds_sr; sri; sri = sri->sr_next) {
-    if (sri->sr_method == sip_method_invite && sri->sr_usage == du)
-      break;
-  }
-                     
-  if (!sri || !sri->sr_respond) /* XXX */
-    return 481;
-
-  if (sip)
-    /* received PRACK */;
-  else if (!sri || irq == NULL) { /* Final response interrupted 100rel */
-    /* Ignore */
-    return 200;
-  }
-  else if (sip == NULL) {
-    SET_STATUS(504, "Reliable Response Timeout");
-
-    nua_stack_event(nh->nh_nua, nh, NULL,
-                   nua_i_error, status, phrase,
-                   TAG_END());
-
-    nua_server_respond(sri, status, phrase, TAG_END());
-
-    return status;
-  }
-
-  if (nh->nh_soa) {
-    msg_t *msg = nta_incoming_getrequest(irq);
-    char const *sdp;
-    size_t len;
-
-    if (session_get_description(sip, &sdp, &len)) {
-      su_home_t home[1] = { SU_HOME_INIT(home) };
-
-      sip_content_disposition_t *cd = NULL;
-      sip_content_type_t *ct = NULL;
-      sip_payload_t *pl = NULL;
-
-      if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
-       SU_DEBUG_5(("nua(%p): error parsing SDP in INVITE\n", nh));
-       msg_destroy(msg);
-       status = 400, phrase = "Bad Session Description";
-      }
-
-      /* Respond to PRACK */
-
-      if (status >= 300)
-       ;
-      else if (sri->sr_offer_sent) {
-       recv = "answer";
-       sri->sr_answer_recv = 1;
-       if (soa_process_answer(nh->nh_soa, NULL) < 0)
-         status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-      }
-      else {
-       recv = "offer";
-       if (soa_generate_answer(nh->nh_soa, NULL) < 0) {
-         status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-       }
-       else {
-         if (session_make_description(home, nh->nh_soa, 1, &cd, &ct, &pl) > 0)
-           sent = "answer";
-       }
-      }
-
-      if (nta_incoming_treply(irq, status, phrase,
-                             SIPTAG_CONTENT_DISPOSITION(cd),
-                             SIPTAG_CONTENT_TYPE(ct),
-                             SIPTAG_PAYLOAD(pl),
-                             TAG_END()) < 0)
-       /* Respond with 500 if nta_incoming_treply() failed */
-       SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
-
-      su_home_deinit(home);
-    }
-
-    msg_destroy(msg);
-  }
-
-  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
-                 nua_i_prack, status, phrase, TAG_END());
-
-  if (status >= 300)
-    return status;
-
-  if (recv || sent) {
-    soa_activate(nh->nh_soa, NULL);
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_early, recv, sent);
-  }
-
-  if (NH_PGET(nh, auto_alert) && !ss->ss_alerting && !ss->ss_precondition)
-    nua_server_respond(sri, SIP_180_RINGING, TAG_END());
-
-  return status;
-}
-
 /** @NUA_EVENT nua_i_ack
  *
  * Final response to INVITE has been acknowledged by UAC with ACK. 
@@ -2249,39 +2224,54 @@ int process_ack(nua_server_request_t *sr,
   if (ss == NULL)
     return 0;
 
-  if (nh->nh_soa && sr->sr_offer_sent && !sr->sr_answer_recv) {
+  if (sr->sr_offer_sent && !sr->sr_answer_recv) {
     char const *sdp;
     size_t len;
+    int error;
+
+    if (session_get_description(sip, &sdp, &len))
+      recv = "answer";
 
-    if (!session_get_description(sip, &sdp, &len) ||
-       !(recv = "answer") ||
-       soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0 ||
-       soa_process_answer(nh->nh_soa, NULL) < 0 ||
-       soa_activate(nh->nh_soa, NULL)) {
+    if (recv) {
+      assert(ss->ss_oa_recv == NULL);
+      ss->ss_oa_recv = recv;
+    }
+
+    if (nh->nh_soa == NULL)
+      ;
+    else if (recv == NULL ||
+            soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0 ||
+            soa_process_answer(nh->nh_soa, NULL) < 0 ||
+            soa_activate(nh->nh_soa, NULL) < 0) {
       int status; char const *phrase, *reason;
 
       status = soa_error_as_sip_response(nh->nh_soa, &phrase);
       reason = soa_error_as_sip_reason(nh->nh_soa);
 
       nua_stack_event(nh->nh_nua, nh, msg,
-              nua_i_ack, status, phrase, TAG_END());
+                     nua_i_ack, status, phrase, NULL);
       nua_stack_event(nh->nh_nua, nh, NULL,
-              nua_i_media_error, status, phrase, TAG_END());
+                     nua_i_media_error, status, phrase, NULL);
+
+      ss->ss_reporting = 1;    /* We report state here if BYE fails */
+      error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
+      ss->ss_reporting = 0;
 
       signal_call_state_change(nh, ss, 488, "Offer-Answer Error",
-                              nua_callstate_terminating, recv, 0);
-      nua_stack_post_signal(nh, nua_r_bye,
-                           SIPTAG_REASON_STR(reason),
-                           TAG_END());
+                              error
+                              ? nua_callstate_terminated
+                              : nua_callstate_terminating);
 
       return 0;
     }
   }
 
-  soa_clear_remote_sdp(nh->nh_soa);
-  nua_stack_event(nh->nh_nua, nh, msg, nua_i_ack, SIP_200_OK, TAG_END());
-  signal_call_state_change(nh, ss, 200, "OK", nua_callstate_ready, recv, 0);
-  set_session_timer(ss);
+  if (nh->nh_soa)
+    soa_clear_remote_sdp(nh->nh_soa);
+
+  nua_stack_event(nh->nh_nua, nh, msg, nua_i_ack, SIP_200_OK, NULL);
+  signal_call_state_change(nh, ss, 200, "OK", nua_callstate_ready);
+  session_timer_set(ss);
 
   nua_server_request_destroy(sr);
 
@@ -2314,12 +2304,14 @@ int process_cancel(nua_server_request_t *sr,
   nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
   msg_t *cancel = nta_incoming_getrequest_ackcancel(irq);
 
-  assert(nta_incoming_status(irq) < 200);  assert(sr->sr_respond);
-  assert(ss); assert(ss == nua_session_usage_get(nh->nh_ds)); (void)ss;
+  assert(ss); assert(ss == nua_session_usage_for_dialog(nh->nh_ds)); (void)ss;
 
-  nua_stack_event(nh->nh_nua, nh, cancel, nua_i_cancel, SIP_200_OK, TAG_END());
+  assert(nta_incoming_status(irq) < 200);
 
-  nua_server_respond(sr, SIP_487_REQUEST_TERMINATED, TAG_END());
+  nua_stack_event(nh->nh_nua, nh, cancel, nua_i_cancel, SIP_200_OK, NULL);
+  sr->sr_application = SR_STATUS1(sr, SIP_487_REQUEST_TERMINATED);
+  nua_server_respond(sr, NULL);
+  nua_server_report(sr);
 
   return 0;
 }
@@ -2331,31 +2323,41 @@ int process_timeout(nua_server_request_t *sr,
 {
   nua_handle_t *nh = sr->sr_owner;
   nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  char const *phrase = "ACK Timeout";
+  char const *reason = "SIP;cause=408;text=\"ACK Timeout\"";
+  int error;
+
+  assert(ss); assert(ss == nua_session_usage_for_dialog(nh->nh_ds));
 
-  assert(ss); assert(ss == nua_session_usage_get(nh->nh_ds));
+  if (nua_server_request_is_pending(sr)) {
+    phrase = "PRACK Timeout";
+    reason = "SIP;cause=504;text=\"PRACK Timeout\"";
+  }
 
-  nua_stack_event(nh->nh_nua, nh, 0, nua_i_error,
-                 408, "Response timeout",
-                 TAG_END());
+  nua_stack_event(nh->nh_nua, nh, 0, nua_i_error, 408, phrase, NULL);
 
-  if (sr->sr_respond) {
+  if (nua_server_request_is_pending(sr)) {
     /* PRACK timeout */
-    nua_server_respond(sr, SIP_504_GATEWAY_TIME_OUT,
-                      SIPTAG_REASON_STR("SIP;cause=504;"
-                                        "text=\"PRACK Timeout\""),
-                      TAG_END());
-    ss = nua_session_usage_get(nh->nh_ds);
+    SR_STATUS1(sr, SIP_504_GATEWAY_TIME_OUT);
+    nua_server_trespond(sr, 
+                       SIPTAG_REASON_STR(reason),
+                       TAG_END());
+    if (nua_server_report(sr) >= 2)
+      return 0;                        /* Done */
     sr = NULL;
   }
 
-  if (ss) {
-    /* send BYE, too if 200 OK (or 183 to re-INVITE) timeouts  */
-    signal_call_state_change(nh, ss, 0, "Timeout",
-                            nua_callstate_terminating, 0, 0);
-    nua_stack_post_signal(nh, nua_r_bye,
-                         SIPTAG_REASON_STR("SIP;cause=408;text=\"ACK Timeout\""),
-                         TAG_END());
-  }
+  /* send BYE, too, if 200 OK (or 183 to re-INVITE) timeouts  */
+  ss->ss_reason = reason;
+
+  ss->ss_reporting = 1;                /* We report state here if BYE fails */
+  error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
+  ss->ss_reporting = 0;
+
+  signal_call_state_change(nh, ss, 0, phrase,
+                          error
+                          ? nua_callstate_terminated
+                          : nua_callstate_terminating);
 
   if (sr)
     nua_server_request_destroy(sr);
@@ -2364,176 +2366,219 @@ int process_timeout(nua_server_request_t *sr,
 }
 
 
-/* ---------------------------------------------------------------------- */
-/* Session timer - RFC 4028 */
+/** @NUA_EVENT nua_i_prack
+ *
+ * Incoming PRACK request. PRACK request is used to acknowledge reliable
+ * preliminary responses and it is usually sent automatically by the nua
+ * stack.
+ *
+ * @param status status code of response sent automatically by stack
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle associated with the call
+ * @param hmagic application context associated with the call
+ * @param sip    incoming PRACK request
+ * @param tags   empty
+ *
+ * @sa nua_prack(), #nua_r_prack, @RFC3262, NUTAG_EARLY_MEDIA()
+ * 
+ * @END_NUA_EVENT
+ */
 
-static int session_timer_is_supported(nua_handle_t const *nh)
-{
-  /* Is timer feature supported? */
-  return sip_has_supported(NH_PGET(nh, supported), "timer");
-}
+int nua_prack_server_init(nua_server_request_t *sr);
+int nua_prack_server_respond(nua_server_request_t *sr, tagi_t const *tags);
+int nua_prack_server_report(nua_server_request_t *sr, tagi_t const *tags);
 
-static int prefer_session_timer(nua_handle_t const *nh)
-{
-  return 
-    NH_PGET(nh, refresher) != nua_no_refresher || 
-    NH_PGET(nh, session_timer) != 0;
-}
+nua_server_methods_t const nua_prack_server_methods = 
+  {
+    SIP_METHOD_PRACK,
+    nua_i_prack,               /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      1,                       /* In-dialog request */
+      1,                       /* Target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_prack_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_prack_server_respond,
+    nua_prack_server_report,
+  };
 
-/* Initialize session timer */ 
-static
-void session_timer_preferences(nua_session_usage_t *ss,
-                              unsigned expires,
-                              unsigned min_se,
-                              enum nua_session_refresher refresher)
+/** @internal Process reliable response PRACK or (timeout from 100rel) */
+static int process_prack(nua_server_request_t *sr,
+                        nta_reliable_t *rel,
+                        nta_incoming_t *irq,
+                        sip_t const *sip)
 {
-  if (expires < min_se)
-    expires = min_se;
-  if (refresher && expires == 0)
-    expires = 3600;
-
-  ss->ss_min_se = min_se;
-  ss->ss_session_timer = expires;
-  ss->ss_refresher = refresher;
-}
+  nua_handle_t *nh;
+  nua_dialog_usage_t *du;
 
+  nta_reliable_destroy(rel);
+  if (irq == NULL)  
+    /* Final response interrupted 100rel, we did not actually receive PRACK */
+    return 200;
 
-/** Add timer featuretag and Session-Expires/Min-SE headers */
-static int
-use_session_timer(nua_session_usage_t *ss, int uas, int always,
-                 msg_t *msg, sip_t *sip)
-{
-  sip_min_se_t min_se[1];
-  sip_session_expires_t session_expires[1];
+  sr->sr_pracked = 1;
 
-  static sip_param_t const x_params_uac[] = {"refresher=uac", NULL};
-  static sip_param_t const x_params_uas[] = {"refresher=uas", NULL};
+  if (!nua_server_request_is_pending(sr)) /* There is no INVITE anymore */
+    return 481;
 
-  /* Session-Expires timer */
-  if (ss->ss_refresher == nua_no_refresher && !always)
-    return 0;
+  nh = sr->sr_owner;
 
-  sip_min_se_init(min_se)->min_delta = ss->ss_min_se;
-  sip_session_expires_init(session_expires)->x_delta = ss->ss_session_timer;
+  if (nh->nh_ds->ds_leg == NULL)
+    return 500;
 
-  if (ss->ss_refresher == nua_remote_refresher)
-    session_expires->x_params = uas ? x_params_uac : x_params_uas;
-  else if (ss->ss_refresher == nua_local_refresher)
-    session_expires->x_params = uas ? x_params_uas : x_params_uac;
+  du = nua_dialog_usage_for_session(nh->nh_ds);
+
+  if (sip == NULL) {
+    /* 100rel timeout */
+    SR_STATUS(sr, 504, "Reliable Response Timeout");
+    nua_stack_event(nh->nh_nua, nh, NULL, nua_i_error,
+                   sr->sr_status, sr->sr_phrase,
+                   NULL);
+    nua_server_trespond(sr,
+                       SIPTAG_REASON_STR("SIP;cause=504;"
+                                         "text=\"PRACK Timeout\""),
+                       TAG_END());
+    nua_server_report(sr);
+    return 504;
+  }
 
-  sip_add_tl(msg, sip,
-            TAG_IF(ss->ss_session_timer,
-                   SIPTAG_SESSION_EXPIRES(session_expires)),
-            TAG_IF(ss->ss_min_se != 0
-                   /* Min-SE: 0 is optional with initial INVITE */
-                   || ss->ss_state != nua_callstate_init,
-                   SIPTAG_MIN_SE(min_se)),
-            TAG_IF(ss->ss_refresher == nua_remote_refresher,
-                   SIPTAG_REQUIRE_STR("timer")),
-            TAG_END());
+  nta_incoming_bind(irq, NULL, (void *)sr);
 
-  return 1;
+  return nua_stack_process_request(nh, nh->nh_ds->ds_leg, irq, sip);
 }
 
-static int
-init_session_timer(nua_session_usage_t *ss,
-                  sip_t const *sip,
-                  int refresher)
+
+int nua_prack_server_init(nua_server_request_t *sr)
 {
-  int server;
+  nua_handle_t *nh = sr->sr_owner;
+  nua_server_request_t *sri = nta_incoming_magic(sr->sr_irq, NULL);
 
-  /* Session timer is not needed */
-  if (!sip->sip_session_expires) {
-    if (!sip_has_supported(sip->sip_supported, "timer"))
-      ss->ss_refresher = nua_local_refresher;
-    return 0;
+  if (sri == NULL)
+    return SR_STATUS(sr, 481, "No Such Preliminary Response");
+  
+  if (nua_session_server_init(sr))
+    return sr->sr_status;
+
+  if (sr->sr_sdp) {
+    nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+
+    /* XXX - check for overlap? */
+    
+    if (sri->sr_offer_sent)
+      sr->sr_answer_recv = 1, ss->ss_oa_recv = "answer";
+    else 
+      sr->sr_offer_recv = 1, ss->ss_oa_recv = "offer";
+
+    if (nh->nh_soa &&
+       soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {
+      SU_DEBUG_5(("nua(%p): %s server: error parsing %s\n", (void *)nh,
+                 "PRACK", "offer"));
+      return 
+       sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
+    }
   }
 
-  ss->ss_refresher = nua_no_refresher;
-  ss->ss_session_timer = sip->sip_session_expires->x_delta;
+  return 0;
+}
 
-  if (sip->sip_min_se != NULL
-      && sip->sip_min_se->min_delta > ss->ss_min_se)
-    ss->ss_min_se = sip->sip_min_se->min_delta;
+int nua_prack_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
 
-  server = sip->sip_request != NULL;
+  if (sr->sr_status < 200 || 300 <= sr->sr_status) 
+    return nua_base_server_respond(sr, tags);
 
-  if (!sip_has_supported(sip->sip_supported, "timer"))
-    ss->ss_refresher = nua_local_refresher;
-  else if (!str0casecmp("uac", sip->sip_session_expires->x_refresher))
-    ss->ss_refresher = server ? nua_remote_refresher : nua_local_refresher;
-  else if (!str0casecmp("uas", sip->sip_session_expires->x_refresher))
-    ss->ss_refresher = server ? nua_local_refresher : nua_remote_refresher;
-  else if (!server)
-    return 0;                  /* XXX */
-  /* User preferences */
-  else if (refresher == nua_local_refresher)
-    ss->ss_refresher = nua_local_refresher;
-  else
-    ss->ss_refresher = nua_remote_refresher;
+  if (sr->sr_sdp) {
+    nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+    msg_t *msg = sr->sr_response.msg;
+    sip_t *sip = sr->sr_response.sip;
 
-  SU_DEBUG_7(("nua session: session expires in %u refreshed by %s (%s %s)\n",
-             ss->ss_session_timer,
-             ss->ss_refresher == nua_local_refresher ? "local" : "remote",
-             server ? sip->sip_request->rq_method_name : "response to",
-             server ? "request" : sip->sip_cseq->cs_method_name));
+    if (nh->nh_soa == NULL) {
+      if (sr->sr_offer_recv && session_get_description(sip, NULL, NULL))
+       sr->sr_answer_sent = 1, ss->ss_oa_sent = "answer";
+    }
+    else if ((sr->sr_offer_recv && soa_generate_answer(nh->nh_soa, NULL) < 0) ||
+            (sr->sr_answer_recv && soa_process_answer(nh->nh_soa, NULL) < 0)) {
+      SU_DEBUG_5(("nua(%p): %s server: %s %s\n", 
+                 (void *)nh, "PRACK", 
+                 "error processing",
+                 sr->sr_offer_recv ? "offer" : "answer"));
+      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
+    }
+    else if (sr->sr_offer_recv) {
+      if (session_include_description(nh->nh_soa, 1, msg, sip) < 0)
+       sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
+      else
+      sr->sr_answer_sent = 1, ss->ss_oa_sent = "answer";
+    }
+  }
 
-  return 1;
+  return nua_base_server_respond(sr, tags);
 }
 
-static void
-set_session_timer(nua_session_usage_t *ss)
+int nua_prack_server_report(nua_server_request_t *sr, tagi_t const *tags)
 {
-  nua_dialog_usage_t *du = nua_dialog_usage_public(ss);
+  nua_handle_t *nh = sr->sr_owner;
+  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  nua_server_request_t *sri = nta_incoming_magic(sr->sr_irq, NULL);
+  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
+  int offer_recv_or_answer_sent = sr->sr_offer_recv || sr->sr_answer_sent;
+  int retval;
 
-  if (ss == NULL)
-    return;
+  retval = nua_base_server_report(sr, tags), sr = NULL; /* destroys sr */
 
-  if (ss->ss_refresher == nua_local_refresher) {
-    ss->ss_timer_set = 1;
-    nua_dialog_usage_set_expires(du, ss->ss_session_timer);
-  }
-  else if (ss->ss_refresher == nua_remote_refresher) {
-    ss->ss_timer_set = 1;
-    nua_dialog_usage_set_expires(du, ss->ss_session_timer + 32);
-    nua_dialog_usage_reset_refresh(du);
+  if (retval >= 2 || ss == NULL) {
+    signal_call_state_change(nh, NULL,
+                            status, phrase, 
+                            nua_callstate_terminated);
+    return retval;
   }
-  else {
-    ss->ss_timer_set = 0;
-    nua_dialog_usage_set_expires(du, UINT_MAX);
-    nua_dialog_usage_reset_refresh(du);
+
+  if (offer_recv_or_answer_sent) {
+    /* signal offer received, answer sent */
+    signal_call_state_change(nh, ss,
+                            status, phrase, 
+                            ss->ss_state);
+    if (nh->nh_soa)
+      soa_activate(nh->nh_soa, NULL);
   }
-}
 
-static int
-check_session_timer_restart(nua_handle_t *nh,
-                           nua_session_usage_t *ss,
-                           nua_client_request_t *cr,
-                           nta_outgoing_t *orq,
-                           sip_t const *sip,
-                           nua_creq_restart_f *restart_function)
-{
-  if (ss && sip && sip->sip_status->st_status == 422) {
-    if (sip->sip_min_se && ss->ss_min_se < sip->sip_min_se->min_delta)
-      ss->ss_min_se = sip->sip_min_se->min_delta;
-    if (ss->ss_min_se > ss->ss_session_timer)
-      ss->ss_session_timer = ss->ss_min_se;
-  
-    if (orq == cr->cr_orq)
-      cr->cr_orq = NULL;
+  if (status < 200 || 300 <= status)
+    return retval;
 
-    return nua_creq_restart_with(nh, cr, orq,
-                                100, "Re-Negotiating Session Timer",
-                                restart_function, TAG_END());
-  }
+  assert(sri);
 
-  return nua_creq_check_restart(nh, cr, orq, sip, restart_function);
-}
+  if (sri == NULL) {
+    
+  }
+  else if (su_msg_is_non_null(sri->sr_signal)) {
+    su_msg_r signal;
+    event_t *e;
+    
+    su_msg_save(signal, sri->sr_signal);
+    
+    e = su_msg_data(signal);
+    sri->sr_application = SR_STATUS(sri, e->e_status, e->e_phrase);
+    
+    nua_server_params(sri, e->e_tags);
+    nua_server_respond(sri, e->e_tags);
+    nua_server_report(sri);
+    
+    su_msg_destroy(signal);
+  }
+  else if (ss->ss_state < nua_callstate_ready
+          && !ss->ss_alerting
+          && !ss->ss_precondition
+          && NH_PGET(nh, auto_alert))  {
+    SR_STATUS1(sri, SIP_180_RINGING);
+    nua_server_respond(sri, NULL);
+    nua_server_report(sri);
+  }
 
-static inline int
-is_session_timer_set(nua_session_usage_t *ss)
-{
-  return ss->ss_timer_set;
+  return retval;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -2599,7 +2644,6 @@ nh_referral_check(nua_handle_t *nh, tagi_t const *tags)
   return 0;
 }
 
-
 static void
 nh_referral_respond(nua_handle_t *nh, int status, char const *phrase)
 {
@@ -2611,7 +2655,7 @@ nh_referral_respond(nua_handle_t *nh, int status, char const *phrase)
     if (ref) {
       if (ref->ref_handle)
        SU_DEBUG_1(("nh_handle_referral: stale referral handle %p\n",
-                   ref->ref_handle));
+                   (void *)ref->ref_handle));
       ref->ref_handle = NULL;
     }
     return;
@@ -2647,33 +2691,9 @@ nh_referral_respond(nua_handle_t *nh, int status, char const *phrase)
   nua_handle_unref(ref->ref_handle), ref->ref_handle = NULL;
 }
 
-
-/** Zap the session associated with the handle */
-static
-void nua_session_usage_destroy(nua_handle_t *nh,
-                              nua_session_usage_t *ss)
-{
-  nh->nh_has_invite = 0;
-  nh->nh_active_call = 0;
-  nh->nh_hold_remote = 0;
-
-  if (nh->nh_soa)
-    soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
-
-  /* Remove usage */
-  nua_dialog_usage_remove(nh, nh->nh_ds, nua_dialog_usage_public(ss));
-
-  SU_DEBUG_5(("nua: terminated session %p\n", nh));
-}
-
-
 /* ======================================================================== */
 /* INFO */
 
-static int process_response_to_info(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip);
-
 /**@fn void nua_info(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
  * Send an INFO request. 
@@ -2696,41 +2716,59 @@ static int process_response_to_info(nua_handle_t *nh,
  * @sa #nua_i_info
  */
 
+static int nua_info_client_init(nua_client_request_t *cr, 
+                               msg_t *msg, sip_t *sip,
+                               tagi_t const *tags);
+
+static int nua_info_client_request(nua_client_request_t *cr,
+                                  msg_t *msg, sip_t *sip,
+                                  tagi_t const *tags);
+
+nua_client_methods_t const nua_info_client_methods = {
+  SIP_METHOD_INFO,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 1,
+    /* target refresh */ 0
+  },
+  /*nua_info_client_template*/ NULL,
+  nua_info_client_init,
+  nua_info_client_request,
+  /*nua_info_client_check_restart*/ NULL,
+  /*nua_info_client_response*/ NULL
+};
+
 int
 nua_stack_info(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
-
-  if (nh_is_special(nh)) {
-    return UA_EVENT2(e, 900, "Invalid handle for INFO");
-  }
-  else if (cr->cr_orq) {
-    return UA_EVENT2(e, 900, "Request already in progress");
-  }
+  return nua_client_create(nh, e, &nua_info_client_methods, tags);
+}
 
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+static int nua_info_client_init(nua_client_request_t *cr, 
+                               msg_t *msg, sip_t *sip,
+                               tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
 
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                        SIP_METHOD_INFO ,
-                        NUTAG_ADD_CONTACT(1),
-                        TAG_NEXT(tags));
+  if (!ss || ss->ss_state >= nua_callstate_terminating)
+    return nua_client_return(cr, 900, "Invalid handle for INFO", msg);
 
-  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                   process_response_to_info, nh, NULL,
-                                   msg,
-                                   SIPTAG_END(), TAG_NEXT(tags));
-  if (!cr->cr_orq) {
-    msg_destroy(msg);
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-  }
+  cr->cr_usage = du;
 
-  return cr->cr_event = e;
+  return 0;
 }
 
-void restart_info(nua_handle_t *nh, tagi_t *tags)
+static int nua_info_client_request(nua_client_request_t *cr,
+                                  msg_t *msg, sip_t *sip,
+                                  tagi_t const *tags)
 {
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_info, tags);
+  if (cr->cr_usage == NULL)
+    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
+  else
+    return nua_base_client_request(cr, msg, sip, tags);
 }
 
 /** @NUA_EVENT nua_r_info
@@ -2754,15 +2792,6 @@ void restart_info(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_info(nua_handle_t *nh,
-                                   nta_outgoing_t *orq,
-                                   sip_t const *sip)
-{
-  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_info))
-    return 0;
-  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
-}
-
 /** @NUA_EVENT nua_i_info
  *
  * Incoming session INFO request.
@@ -2779,25 +2808,26 @@ static int process_response_to_info(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_info(nua_t *nua,
-                          nua_handle_t *nh,
-                          nta_incoming_t *irq,
-                          sip_t const *sip)
-{
-  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
-                 nua_i_info, SIP_200_OK, TAG_END());
-
-  return 200;          /* Respond automatically with 200 Ok */
-}
-
+nua_server_methods_t const nua_info_server_methods = 
+  {
+    SIP_METHOD_INFO,
+    nua_i_info,                        /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      1,                       /* In-dialog request */
+      0,                       /* Not a target refresh request  */
+      0,                       /* Do not add Contact */
+    },
+    nua_base_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_base_server_respond,
+    nua_base_server_report,
+  };
 
 /* ======================================================================== */
 /* UPDATE */
 
-static int process_response_to_update(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip);
-
 /**@fn void nua_update(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
  * Update a session. 
@@ -2826,91 +2856,166 @@ static int process_response_to_update(nua_handle_t *nh,
  * @sa @ref nua_call_model, @RFC3311, nua_update(), #nua_i_update
  */
 
+static int nua_update_client_init(nua_client_request_t *cr, 
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags);
+static int nua_update_client_request(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags);
+static int nua_update_client_response(nua_client_request_t *cr,
+                                     int status, char const *phrase,
+                                     sip_t const *sip);
+static int nua_update_client_report(nua_client_request_t *cr,
+                                   int status, char const *phrase,
+                                   sip_t const *sip,
+                                   nta_outgoing_t *orq,
+                                   tagi_t const *tags);
+
+nua_client_methods_t const nua_update_client_methods = {
+  SIP_METHOD_UPDATE,
+  0,                           /* size of private data */
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 1,
+    /* target refresh */ 1
+  },
+  NULL,
+  nua_update_client_init,
+  nua_update_client_request,
+  session_timer_check_restart,
+  nua_update_client_response,
+  NULL,
+  nua_update_client_report
+};
+
 int nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e,
                     tagi_t const *tags)
 {
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_session_usage_t *ss;
-  nua_client_request_t *cr;
-  msg_t *msg;
-  sip_t *sip;
-  char const *offer_sent = 0;
+  return nua_client_create(nh, e, &nua_update_client_methods, tags);
+}
 
-  ss = nua_session_usage_get(ds);
-  cr = ds->ds_cr;
+static int nua_update_client_init(nua_client_request_t *cr, 
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+
+  cr->cr_usage = du;
+
+  return 0;
+}
+
+static int nua_update_client_request(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_server_request_t *sr;
+  nua_client_request_t *cri;
+  int offer_sent = 0, retval;
+  
+  if (du == NULL)              /* Call terminated */
+    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
+  assert(ss);
 
-  if (!ss)
-    return UA_EVENT2(e, 900, "Invalid handle for UPDATE");
-  else if (cr->cr_orq)
-    return UA_EVENT2(e, 900, "Request already in progress");
+  cri = du->du_cr;
 
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
+    if ((sr->sr_offer_sent && !sr->sr_answer_recv) ||
+       (sr->sr_offer_recv && !sr->sr_answer_sent))
+      break;
 
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                    SIP_METHOD_UPDATE,
-                    NUTAG_USE_DIALOG(1),
-                    NUTAG_ADD_CONTACT(1),
-                    TAG_NEXT(tags));
+  if (sr ||
+      (cri && cri->cr_offer_sent && !cri->cr_answer_recv) ||
+      (cri && cri->cr_offer_recv && !cri->cr_answer_sent)) {
+    if (nh->nh_soa == NULL) {
+      if (session_get_description(sip, NULL, NULL))
+       return nua_client_return(cr, 500, "Overlapping Offer/Answer", msg);
+    }
+  }
+  else if (nh->nh_soa == NULL) {
+    offer_sent = session_get_description(sip, NULL, NULL);
+  }
+  else if (!sip->sip_payload) {
+    soa_init_offer_answer(nh->nh_soa);
 
-  sip = sip_object(msg);
+    if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
+       session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+      if (ss->ss_state < nua_callstate_ready) {
+       /* XXX - use soa_error_as_sip_reason(nh->nh_soa) */
+       cr->cr_graceful = 1;
+       ss->ss_reason = "SIP;cause=400;text=\"Local media failure\"";
+      }
+      return nua_client_return(cr, 900, "Local media failed", msg);
+    }
+    offer_sent = 1;
+  }
 
-  if (sip) {
-    nua_client_request_t *cri = ss->ss_crequest;
-    nua_server_request_t *sr;
+  /* Add session timer headers */
+  session_timer_preferences(ss->ss_timer,
+                           sip,
+                           NH_PGET(nh, supported),                  
+                           NH_PGET(nh, session_timer),
+                           NUA_PISSET(nh->nh_nua, nh, session_timer),
+                           NH_PGET(nh, refresher),
+                           NH_PGET(nh, min_se));
 
-    for (sr = ds->ds_sr; sr; sr = sr->sr_next)
-      if ((sr->sr_offer_sent && !sr->sr_answer_recv) ||
-         (sr->sr_offer_recv && !sr->sr_answer_sent))
-       break;
-    
-    if (nh->nh_soa && !sip->sip_payload && 
-       !sr &&
-       !(cri && cri->cr_offer_sent && !cri->cr_answer_recv) &&
-       !(cri && cri->cr_offer_recv && !cri->cr_answer_sent)) {
-      soa_init_offer_answer(nh->nh_soa);
+  if (session_timer_is_supported(ss->ss_timer))
+    session_timer_add_headers(ss->ss_timer, ss->ss_state < nua_callstate_ready,
+                             msg, sip);
 
-      if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
-         session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-       if (ss->ss_state < nua_callstate_ready) {
-         /* XXX */
-       }
-       msg_destroy(msg);
-       return UA_EVENT2(e, 900, "Local media failed");
-      }
+  retval = nua_base_client_request(cr, msg, sip, NULL);
 
-      offer_sent = "offer";
-    }
+  if (retval == 0) {
+    cr->cr_offer_sent = offer_sent;
+    ss->ss_update_needed = 0;
 
-    /* Add session timer headers */
-    if (session_timer_is_supported(nh))
-      use_session_timer(ss, 0, prefer_session_timer(nh), msg, sip);
+    if (!cr->cr_restarting) {
+      enum nua_callstate state = ss->ss_state;
 
-    if (nh->nh_auth) {
-      if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
-       /* xyzzy */;
-    }
+      if (state == nua_callstate_ready)
+       state = nua_callstate_calling;
 
-    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                     process_response_to_update, nh, NULL,
-                                     msg,
-                                     SIPTAG_END(), TAG_NEXT(tags));
-    if (cr->cr_orq) {
       if (offer_sent)
-       cr->cr_offer_sent = 1;
-      ss->ss_update_needed = 0;
-      signal_call_state_change(nh, ss, 0, "UPDATE sent",
-                              ss->ss_state, 0, offer_sent);
-      return cr->cr_event = e;
+       ss->ss_oa_sent = "offer";
+
+      signal_call_state_change(nh, ss, 0, "UPDATE sent", state);
     }
   }
 
-  msg_destroy(msg);
-  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  return retval;
 }
 
-void restart_update(nua_handle_t *nh, tagi_t *tags)
+static int nua_update_client_response(nua_client_request_t *cr,
+                                     int status, char const *phrase,
+                                     sip_t const *sip)
 {
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_update, tags);
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+
+  assert(200 <= status);
+
+  if (ss && sip && status < 300) {
+    if (session_timer_is_supported(ss->ss_timer)) {
+      nua_server_request_t *sr;
+
+      for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
+       if (sr->sr_method == sip_method_invite ||
+           sr->sr_method == sip_method_update)
+         break;
+
+      if (!sr && (!du->du_cr || !du->du_cr->cr_orq)) {
+       session_timer_store(ss->ss_timer, sip);
+       session_timer_set(ss);
+      }
+    }
+  }
+
+  return nua_session_client_response(cr, status, phrase, sip);
 }
 
 /** @NUA_EVENT nua_r_update
@@ -2937,134 +3042,74 @@ void restart_update(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_update(nua_handle_t *nh,
-                                      nta_outgoing_t *orq,
-                                      sip_t const *sip)
+static int nua_update_client_report(nua_client_request_t *cr,
+                                   int status, char const *phrase,
+                                   sip_t const *sip,
+                                   nta_outgoing_t *orq,
+                                   tagi_t const *tags)
 {
-  nua_t *nua = nh->nh_nua;
-  nua_session_usage_t *ss;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-
-  int status = sip->sip_status->st_status;
-  char const *phrase = sip->sip_status->st_phrase;
-  char const *recv = NULL;
-  int terminate = 0, gracefully = 1;
-
-  ss = nua_session_usage_get(nh->nh_ds); assert(ss);
-
-  if (status >= 300) {
-    if (sip->sip_retry_after)
-      gracefully = 0;
-
-    terminate = sip_response_terminates_dialog(status, sip_method_update,
-                                              &gracefully);
-
-    if (!terminate &&
-       check_session_timer_restart(nh, ss, cr, orq, sip, restart_update)) {
-      return 0;
-    }
-    /* XXX - if we have a concurrent INVITE, what we do with it? */
-  }
-  else if (status >= 200) {
-    /* XXX - check remote tag, handle forks */
-    /* Set (route), contact, (remote tag) */
-    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-
-    if (is_session_timer_set(ss)) {
-      init_session_timer(ss, sip, NH_PGET(nh, refresher));
-      set_session_timer(ss);
-    }
-
-    if (session_process_response(nh, cr, orq, sip, &recv) < 0) {
-      nua_stack_event(nua, nh, NULL, nua_i_error,
-              400, "Bad Session Description", TAG_END());
-    }
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
 
-    signal_call_state_change(nh, ss, status, phrase, ss->ss_state, recv, 0);
+  nua_stack_event(nh->nh_nua, nh, 
+                 nta_outgoing_getresponse(orq),
+                 cr->cr_event,
+                 status, phrase,
+                 tags);
 
-    return 0;
-  }
-  else
-    gracefully = 0;
+  if (!ss || orq != cr->cr_orq || 
+      cr->cr_terminated || cr->cr_graceful || !cr->cr_offer_sent)
+    return 1;
 
-  nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+  signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
 
-  if (!terminate && !gracefully)
-    return 0;
+  return 1;
+}
 
-  nh_referral_respond(nh, status, phrase);
-  
-  if (ss == NULL) {
+/* ---------------------------------------------------------------------- */
+/* UPDATE server */
 
-  } 
-  else if (terminate || 
-      (ss->ss_state < nua_callstate_completed &&
-       ss->ss_state != nua_callstate_completing)) {
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_terminated, recv, 0);
-    nua_session_usage_destroy(nh, ss);
-  }
-  else /* if (gracefully) */ {
-    signal_call_state_change(nh, ss, status, phrase,
-                            nua_callstate_terminating, recv, 0);
-#if 0
-    if (nh->nh_ss->ss_crequest->cr_orq)
-      nua_stack_post_signal(nh, nua_r_cancel, TAG_END());
-    else
-#endif
-      nua_stack_post_signal(nh, nua_r_bye, TAG_END());
-  }
+int nua_update_server_init(nua_server_request_t *sr);
+int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags);
+int nua_update_server_report(nua_server_request_t *, tagi_t const *);
 
-  return 0;
-}
+nua_server_methods_t const nua_update_server_methods = 
+  {
+    SIP_METHOD_UPDATE,
+    nua_i_update,              /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      1,                       /* In-dialog request */
+      1,                       /* Target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_update_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_update_server_respond,
+    nua_update_server_report,
+  };
 
-int nua_stack_process_update(nua_t *nua,
-                            nua_handle_t *nh,
-                            nta_incoming_t *irq,
-                            sip_t const *sip)
+int nua_update_server_init(nua_server_request_t *sr)
 {
-  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_handle_t *nh = sr->sr_owner;
   nua_session_usage_t *ss;
-  nua_dialog_usage_t *du;
-  msg_t *msg = nta_incoming_getrequest(irq);
-
-  char const *sdp;
-  size_t len;
 
-  int original_status = 200, status = 200;
-  char const *phrase = sip_200_OK;
+  sip_t const *request = sr->sr_request.sip;
 
-  char const *offer_recv = NULL, *answer_sent = NULL;
-  int use_timer = 0;
-
-  msg_t *rmsg;
-  sip_t *rsip;
-
-  ss = nua_session_usage_get(ds); du = nua_dialog_usage_public(ss);
-  if (!ss) {
-    /* RFC 3261 section 12.2.2:
-       If the UAS wishes to reject the request because it does not wish to
-       recreate the dialog, it MUST respond to the request with a 481
-       (Call/Transaction Does Not Exist) status code and pass that to the
-       server transaction.
-    */
-    return 481;
-  }
+  if (nua_session_server_init(sr))
+    return sr->sr_status;
 
-  if (session_check_request(nua, nh, irq, sip))
-    return 501;
+  ss = nua_dialog_usage_private(sr->sr_usage);
 
   /* Do session timer negotiation */
-  if (sip->sip_session_expires) {
-    use_timer = 1;
-    init_session_timer(ss, sip, NH_PGET(nh, refresher));
-  }
+  if (request->sip_session_expires)
+    session_timer_store(ss->ss_timer, request);
 
-  if (status < 300 && nh->nh_soa &&
-      session_get_description(sip, &sdp, &len)) {
+  if (sr->sr_sdp) {            /* Check for overlap */
     nua_client_request_t *cr;
-    nua_server_request_t *sr;
+    nua_server_request_t *sr0;
     int overlap = 0;
 
     /*
@@ -3082,71 +3127,91 @@ int nua_stack_process_update(nua_t *nua,
       reject the UPDATE with a 500 response, and MUST include a Retry-After
       header field with a randomly chosen value between 0 and 10 seconds.
     */
-    for (cr = ds->ds_cr; cr && !overlap; cr = cr->cr_next)
-      overlap = cr->cr_offer_sent && !cr->cr_answer_recv;
-    for (sr = ds->ds_sr; sr && !overlap; sr = sr->sr_next)
-      overlap = (sr->sr_offer_recv && !sr->sr_answer_sent) ||
-       (sr->sr_method == sip_method_update && sr->sr_respond);
+    for (cr = nh->nh_ds->ds_cr; cr; cr = cr->cr_next)
+      if ((overlap = cr->cr_offer_sent && !cr->cr_answer_recv))
+       break;
+
+    if (!overlap)
+      for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next)
+       if ((overlap = sr0->sr_offer_recv && !sr0->sr_answer_sent))
+         break;
 
     if (overlap)
-      return respond_with_retry_after(nh, irq, 
-                                     500, "Overlapping Offer/Answer",
-                                     0, 10);
+      return nua_server_retry_after(sr, 500, "Overlapping Offer/Answer", 1, 9);
+
+    if (nh->nh_soa &&
+       soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {
+      SU_DEBUG_5(("nua(%p): %s server: error parsing %s\n", (void *)nh,
+                 "UPDATE", "offer"));
+      return 
+       sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
+    }
 
-    offer_recv = "offer";
+    sr->sr_offer_recv = 1;
+    ss->ss_oa_recv = "offer";
+  }
 
-    if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
-      SU_DEBUG_5(("nua(%p): error parsing SDP in UPDATE\n", nh));
-      msg_destroy(msg);
-      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-      offer_recv = NULL;
+  return 0;
+}
+
+/** @internal Respond to an UPDATE request.
+ *
+ */
+int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  msg_t *msg = sr->sr_response.msg;
+  sip_t *sip = sr->sr_response.sip;
+
+  if (200 <= sr->sr_status && sr->sr_status < 300 && sr->sr_sdp) {
+    if (nh->nh_soa == NULL) {
+      sr->sr_answer_sent = 1, ss->ss_oa_sent = "answer";
     }
-    /* Respond to UPDATE */
     else if (soa_generate_answer(nh->nh_soa, NULL) < 0) {
-      SU_DEBUG_5(("nua(%p): error processing SDP in UPDATE\n", nh));
-      msg_destroy(msg);
-      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+      SU_DEBUG_5(("nua(%p): %s server: %s %s\n", 
+                 (void *)nh, "UPDATE", "error processing", "offer"));
+      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
     }
     else if (soa_activate(nh->nh_soa, NULL) < 0) {
-      SU_DEBUG_5(("nua(%p): error activating media after %s\n",
-                 nh, "UPDATE"));
+      SU_DEBUG_5(("nua(%p): %s server: error activating media\n",
+                 (void *)nh, "UPDATE"));
       /* XXX */
     }
+    else if (session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+      sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    }
     else {
-      answer_sent = "answer";
+      sr->sr_answer_sent = 1, ss->ss_oa_sent = "answer";
     }
   }
 
-  rmsg = nh_make_response(nua, nh, irq,
-                         status, phrase,
-                         TAG_IF(status < 300, NUTAG_ADD_CONTACT(1)),
-                         SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
-                         TAG_NEXT(NULL));
-  rsip = sip_object(rmsg);
-  assert(sip);                 /* XXX */
+  if (200 <= sr->sr_status && sr->sr_status < 300) {
+    session_timer_preferences(ss->ss_timer,
+                             sip,
+                             NH_PGET(nh, supported),                
+                             NH_PGET(nh, session_timer),
+                             NUA_PISSET(nh->nh_nua, nh, session_timer),
+                             NH_PGET(nh, refresher),
+                             NH_PGET(nh, min_se));
 
-  if (answer_sent && 
-      session_include_description(nh->nh_soa, 1, rmsg, rsip) < 0) {
-    status = 500, phrase = sip_500_Internal_server_error;
-    answer_sent = NULL;
-  }
+    if (ss && session_timer_is_supported(ss->ss_timer)) {
+      nua_server_request_t *sr0;
 
-  if (200 <= status && status < 300 && session_timer_is_supported(nh)) {
-    use_session_timer(ss, 1, use_timer, rmsg, rsip);
-    set_session_timer(ss);
-  }
+      session_timer_add_headers(ss->ss_timer, 0, msg, sip);
 
-  if (status == original_status) {
-    if (nta_incoming_mreply(irq, rmsg) < 0)
-      status = 500, phrase = sip_500_Internal_server_error;
-  }
+      for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next)
+       if (sr0->sr_method == sip_method_invite)
+         break;
 
-  if (status != original_status) {
-    nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, TAG_END());
-    nta_incoming_treply(irq, status, phrase, TAG_END());
-    msg_destroy(rmsg), rmsg = NULL;
+      if (!sr0 && (!sr->sr_usage->du_cr || !sr->sr_usage->du_cr->cr_orq))
+       session_timer_set(ss);
+    }
   }
 
+  return nua_base_server_respond(sr, tags);
+}
+
 /** @NUA_EVENT nua_i_update
  *
  * @brief Incoming session UPDATE request.
@@ -3163,39 +3228,58 @@ int nua_stack_process_update(nua_t *nua,
  * @END_NUA_EVENT
  */
 
-  nua_stack_event(nh->nh_nua, nh, msg, nua_i_update, status, phrase, TAG_END());
+int nua_update_server_report(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_usage_t *du = sr->sr_usage;
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
+  int offer_recv_or_answer_sent = sr->sr_offer_recv || sr->sr_answer_sent;
+  int retval;
+
+  retval = nua_base_server_report(sr, tags), sr = NULL; /* destroys sr */
+
+  if (retval >= 2 || ss == NULL) {
+    signal_call_state_change(nh, NULL, status, phrase, 
+                            nua_callstate_terminated);
+    return retval;
+  }
 
-  if (offer_recv || answer_sent)
+  if (offer_recv_or_answer_sent) {
     /* signal offer received, answer sent */
-    signal_call_state_change(nh, ss, 200, "OK", ss->ss_state,
-                            offer_recv, answer_sent);
+    enum nua_callstate state = ss->ss_state;
+    
+    if (state == nua_callstate_ready && status < 200)
+      state = nua_callstate_received;
+
+    signal_call_state_change(nh, ss, status, phrase, state);
+  }
 
-  if (NH_PGET(nh, auto_alert)
+  if (200 <= status && status < 300
       && ss->ss_state < nua_callstate_ready
+      && ss->ss_precondition 
       && !ss->ss_alerting
-      && ss->ss_precondition) {
-    nua_server_request_t *sr;
+      && NH_PGET(nh, auto_alert))  {
+    nua_server_request_t *sri;
     
-    for (sr = ds->ds_sr; sr; sr = sr->sr_next)
-      if (sr->sr_method == sip_method_invite && 
-         sr->sr_usage == du && sr->sr_respond)
+    for (sri = nh->nh_ds->ds_sr; sri; sri = sr->sr_next)
+      if (sri->sr_method == sip_method_invite && 
+         nua_server_request_is_pending(sri))
        break;
 
-    if (sr)
-      nua_server_respond(sr, SIP_180_RINGING, TAG_END());
+    if (sri) {
+      SR_STATUS1(sri, SIP_180_RINGING);
+      nua_server_respond(sri, NULL);
+      nua_server_report(sri);
+    }
   }
 
-  return status;
+  return retval;
 }
 
-
 /* ======================================================================== */
 /* BYE */
 
-static int process_response_to_bye(nua_handle_t *nh,
-                                  nta_outgoing_t *orq,
-                                  sip_t const *sip);
-
 /**@fn void nua_bye(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
  * Hangdown a call.
@@ -3217,87 +3301,95 @@ static int process_response_to_bye(nua_handle_t *nh,
  *    #nua_i_media_error
  */
 
+static int nua_bye_client_init(nua_client_request_t *cr, 
+                              msg_t *msg, sip_t *sip,
+                              tagi_t const *tags);
+static int nua_bye_client_request(nua_client_request_t *cr,
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags);
+static int nua_bye_client_report(nua_client_request_t *cr,
+                                int status, char const *phrase,
+                                sip_t const *sip,
+                                nta_outgoing_t *orq,
+                                tagi_t const *tags);
+
+nua_client_methods_t const nua_bye_client_methods = {
+  SIP_METHOD_BYE,
+  0,
+  { 
+    /* create_dialog */ 0,
+    /* in_dialog */ 1,
+    /* target refresh */ 0
+  },
+  NULL,
+  nua_bye_client_init,
+  nua_bye_client_request,
+  /*nua_bye_client_check_restart*/ NULL,
+  /*nua_bye_client_response*/ NULL,
+  /*nua_bye_client_preliminary*/ NULL,
+  nua_bye_client_report
+};
+
 int
 nua_stack_bye(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 {
-  nua_session_usage_t *ss;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
-  nta_outgoing_t *orq;
-
-  ss = nua_session_usage_get(nh->nh_ds);
-  
-  if (!ss || ss->ss_state >= nua_callstate_terminating)
-    return UA_EVENT2(e, 900, "Invalid handle for BYE");
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  if (!nua_dialog_is_established(nh->nh_ds)) {
-    nua_client_request_t *cri = ss->ss_crequest;
-
-    if (cri->cr_orq == NULL)
-      return UA_EVENT2(e, 900, "No session to BYE");
-
-    /* No (early) dialog. BYE is invalid action, do CANCEL instead */
-    orq = nta_outgoing_tcancel(cri->cr_orq,
-                              process_response_to_cancel, nh,
-                              TAG_NEXT(tags));
-    if (!cr->cr_orq)
-      cr->cr_orq = orq, cr->cr_event = e;
-
-    return 0;
-  }
+  nua_session_usage_t *ss = nua_session_usage_for_dialog(nh->nh_ds);
 
-  if (cr->cr_orq) {
-    if (cr->cr_usage == nua_dialog_usage_public(ss)) {
-      nua_creq_deinit(cr, cr->cr_orq);
-    }
-    else {
-      cr = ss->ss_crequest;
-      if (cr->cr_orq)
-       nua_creq_deinit(cr, cr->cr_orq);
-    }
-  }
+  if (ss && 
+      nua_callstate_calling <= ss->ss_state &&
+      ss->ss_state <= nua_callstate_proceeding)
+    return nua_client_create(nh, e, &nua_cancel_client_methods, tags);
+  else
+    return nua_client_create(nh, e, &nua_bye_client_methods, tags);
+}
 
-  assert(!cr->cr_orq);
+static int nua_bye_client_init(nua_client_request_t *cr, 
+                              msg_t *msg, sip_t *sip,
+                              tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
 
-  msg = nua_creq_msg(nua, nh, cr, 0, SIP_METHOD_BYE, TAG_NEXT(tags));
+  if (!ss || (ss->ss_state >= nua_callstate_terminating && !cr->cr_auto))
+    return nua_client_return(cr, 900, "Invalid handle for BYE", msg);
 
-  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                   process_response_to_bye, nh, NULL,
-                                   msg,
-                                   SIPTAG_END(), TAG_NEXT(tags));
+  if (!cr->cr_auto)
+    /* Implicit state transition by nua_bye() */
+    ss->ss_state = nua_callstate_terminating;
 
-  ss->ss_state = nua_callstate_terminating;
   if (nh->nh_soa)
     soa_terminate(nh->nh_soa, 0);
-
-  if (cr->cr_orq) {
-    cr->cr_event = e;
-  }
-  else {
-    msg_destroy(msg);
-    UA_EVENT2(e, 400, "Internal error");
-    signal_call_state_change(nh, ss, 400, "Failure sending BYE",
-                            nua_callstate_terminated, 0, 0);
-    nua_session_usage_destroy(nh, ss);
-  }
+  cr->cr_usage = du;
 
   return 0;
 }
 
-
-void restart_bye(nua_handle_t *nh, tagi_t *tags)
+static int nua_bye_client_request(nua_client_request_t *cr,
+                                 msg_t *msg, sip_t *sip,
+                                 tagi_t const *tags)
 {
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_bye, tags);
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_session_usage_t *ss;
+  char const *reason = NULL;
+
+  if (du == NULL)
+    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
+
+  ss = nua_dialog_usage_private(du);
+  reason = ss->ss_reason;
+
+  return nua_base_client_trequest(cr, msg, sip,
+                                 SIPTAG_REASON_STR(reason),
+                                 TAG_NEXT(tags));
 }
 
 /** @NUA_EVENT nua_r_bye
  *
  * Answer to outgoing BYE.
  *
- * The BYE may be sent explicitly by nua_bye() or
- * implicitly by NUA state machine.
+ * The BYE may be sent explicitly by nua_bye() or implicitly by NUA state
+ * machine.
  *
  * @param status response status code
  *               (if the request is retried, @a status is 100, the @a
@@ -3316,45 +3408,47 @@ void restart_bye(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_bye(nua_handle_t *nh,
-                                  nta_outgoing_t *orq,
-                                  sip_t const *sip)
+static int nua_bye_client_report(nua_client_request_t *cr,
+                                int status, char const *phrase,
+                                sip_t const *sip,
+                                nta_outgoing_t *orq,
+                                tagi_t const *tags)
 {
-  nua_client_request_t *cr = NULL;
-  nua_session_usage_t *ss;
-  int status = sip ? sip->sip_status->st_status : 400;
-  char const *phrase = sip ? sip->sip_status->st_phrase : "";
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
 
-  cr = nua_client_request_by_orq(nh->nh_ds->ds_cr, orq); assert(cr);
+  nua_stack_event(nh->nh_nua, nh, 
+                 nta_outgoing_getresponse(orq),
+                 cr->cr_event,
+                 status, phrase,
+                 tags);
 
-  if (cr) {
-    if (nua_creq_check_restart(nh, cr, orq, sip, restart_bye))
-      return 0;
-    nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+  if (du == NULL) {
+    /* No more session */
   }
-  else {                       /* No cr for BYE */
-    msg_t *msg = nta_outgoing_getresponse(orq);
-    nua_stack_event(nh->nh_nua, nh, msg, nua_r_bye, status, phrase, TAG_END());
-    nta_outgoing_destroy(orq);
+  else if (status < 200) {
+    /* Preliminary */
   }
+  else {
+    nua_session_usage_t *ss = nua_dialog_usage_private(du);
 
-  ss = nua_session_usage_get(nh->nh_ds);
+    signal_call_state_change(nh, ss, status, "to BYE", 
+                            nua_callstate_terminated);
 
-  if (status >= 200 && ss) {
-    if (ss->ss_crequest->cr_orq) {
-      /* Do not destroy usage while INVITE is alive */
-    }
-    else {
-      signal_call_state_change(nh, ss, status, "to BYE",
-                              nua_callstate_terminated, 0, 0);
-      nua_session_usage_destroy(nh, ss);
+    if (ss && !ss->ss_reporting) {
+      if (du->du_cr == NULL ||
+         !nua_client_is_queued(du->du_cr) ||
+         du->du_cr->cr_status >= 200) {
+       /* INVITE is completed, we can zap the session... */;
+       cr->cr_usage = NULL;
+       nua_session_usage_destroy(nh, ss);
+      }
     }
   }
 
-  return 0;
+  return 1;
 }
 
-
 /** @NUA_EVENT nua_i_bye
  *
  * Incoming BYE request, call hangup.
@@ -3371,52 +3465,144 @@ static int process_response_to_bye(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_bye(nua_t *nua,
-                         nua_handle_t *nh,
-                         nta_incoming_t *irq,
-                         sip_t const *sip)
+int nua_bye_server_init(nua_server_request_t *sr);
+int nua_bye_server_report(nua_server_request_t *sr, tagi_t const *tags);
+
+nua_server_methods_t const nua_bye_server_methods = 
+  {
+    SIP_METHOD_BYE,
+    nua_i_bye,                 /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      1,                       /* In-dialog request */
+      0,                       /* Not a target refresh request  */
+      0,                       /* Do not add Contact */
+    },
+    nua_bye_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_base_server_respond,
+    nua_bye_server_report,
+  };
+
+
+int nua_bye_server_init(nua_server_request_t *sr)
 {
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_session_usage_t *ss;
-  nua_server_request_t *sr, *sr_next;
-  int early = 0;
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
 
-  ss = nua_session_usage_get(ds);
-  if (!ss)
-    return 481;
+  sr->sr_terminating = 1;
 
-  assert(nh && ss);
+  if (du)
+    sr->sr_usage = du;
+  else
+    return SR_STATUS(sr, 481, "No Such Call");
 
-  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
-                 nua_i_bye, SIP_200_OK, TAG_END());
-  nta_incoming_treply(irq, SIP_200_OK, TAG_END());
-  nta_incoming_destroy(irq), irq = NULL;
+  return 0;
+}
 
-  for (sr = ds->ds_sr; sr; sr = sr_next) {
-    sr_next = sr->sr_next;
-    if (sr->sr_respond && sr->sr_usage == nua_dialog_usage_public(ss)) {
-      char const *phrase;
-      early = ss->ss_state < nua_callstate_ready;
-      phrase = early ? "Early Session Terminated" : "Session Terminated";
-      sr->sr_usage = NULL;
-      if (sr->sr_respond)
-       nua_server_respond(sr, 487, phrase, TAG_END());
-      else
-       nua_server_request_destroy(sr);
+int nua_bye_server_report(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  int early = 0, retval;
+
+  if (sr->sr_status < 200)
+    return nua_base_server_report(sr, tags);
+
+  if (ss) {
+    nua_server_request_t *sr0 = NULL, *sr_next;
+    char const *phrase;
+
+    early = ss->ss_state < nua_callstate_ready;
+    phrase = early ? "Early Session Terminated" : "Session Terminated";
+    
+    for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr_next) {
+      sr_next = sr0->sr_next;
+
+      if (sr == sr0 || sr0->sr_usage != sr->sr_usage)
+       continue;
+
+      if (nua_server_request_is_pending(sr0)) {
+       SR_STATUS(sr0, 487, phrase);
+       nua_server_respond(sr0, NULL);
+      }
+      nua_server_request_destroy(sr0);
     }
   }
 
-  signal_call_state_change(nh, ss, 200,
-                          early ? "Received early BYE" : "Received BYE",
-                          nua_callstate_terminated, 0, 0);
+  retval = nua_base_server_report(sr, tags);
 
-  nua_session_usage_destroy(nh, ss);
+  assert(2 <= retval && retval < 4);
 
-  return 0;
+  if (ss)
+    signal_call_state_change(nh, NULL, 200,
+                            early ? "Received early BYE" : "Received BYE",
+                            nua_callstate_terminated);
+
+  return retval;
 }
 
 /* ---------------------------------------------------------------------- */
 
+/** @NUA_EVENT nua_i_state
+ *
+ * @brief Call state has changed.
+ *
+ * This event will be sent whenever the call state changes. 
+ *
+ * In addition to basic changes of session status indicated with enum
+ * ::nua_callstate, the @RFC3264 SDP Offer/Answer negotiation status is also
+ * included. The tags NUTAG_OFFER_RECV() or NUTAG_ANSWER_RECV() indicate
+ * whether the remote SDP that was received was considered as an offer or an
+ * answer. Tags NUTAG_OFFER_SENT() or NUTAG_ANSWER_SENT() indicate whether
+ * the local SDP which was sent was considered as an offer or answer.
+ *
+ * If the @b soa SDP negotiation is enabled (by default or with
+ * NUTAG_MEDIA_ENABLE(1)), the received remote SDP is included in tags
+ * SOATAG_REMOTE_SDP() and SOATAG_REMOTE_SDP_STR(). The SDP negotiation
+ * result from @b soa is included in the tags SOATAG_LOCAL_SDP() and
+ * SOATAG_LOCAL_SDP_STR().
+ *
+ * SOATAG_ACTIVE_AUDIO() and SOATAG_ACTIVE_VIDEO() are informational tags
+ * used to indicate what is the status of audio or video.
+ *
+ * Note that #nua_i_state also covers the information relayed in call
+ * establisment (#nua_i_active) and termination (#nua_i_terminated) events.
+ *
+ * @param status protocol status code \n
+ *               (always present)
+ * @param phrase short description of status code \n
+ *               (always present)
+ * @param nh     operation handle associated with the call
+ * @param hmagic application context associated with the call
+ * @param sip    NULL
+ * @param tags   NUTAG_CALLSTATE(), 
+ *               SOATAG_LOCAL_SDP(), SOATAG_LOCAL_SDP_STR(),
+ *               NUTAG_OFFER_SENT(), NUTAG_ANSWER_SENT(),
+ *               SOATAG_REMOTE_SDP(), SOATAG_REMOTE_SDP_STR(),
+ *               NUTAG_OFFER_RECV(), NUTAG_ANSWER_RECV(),
+ *               SOATAG_ACTIVE_AUDIO(), SOATAG_ACTIVE_VIDEO(),
+ *               SOATAG_ACTIVE_IMAGE(), SOATAG_ACTIVE_CHAT().
+ *
+ * @sa @ref nua_call_model, #nua_i_active, #nua_i_terminated,
+ * nua_invite(), #nua_r_invite, #nua_i_invite, nua_respond(), 
+ * NUTAG_MEDIA_ENABLE(),
+ * NUTAG_AUTOALERT(), NUTAG_AUTOANSWER(), NUTAG_EARLY_MEDIA(),
+ * NUTAG_EARLY_ANSWER(), NUTAG_INCLUDE_EXTRA_SDP(),
+ * nua_ack(), NUTAG_AUTOACK(), nua_bye(), #nua_r_bye, #nua_i_bye,
+ * nua_cancel(), #nua_r_cancel, #nua_i_cancel,
+ * nua_prack(), #nua_r_prack, #nua_i_prack,
+ * nua_update(), #nua_r_update, #nua_i_update
+ *
+ * @par History
+ * Prior @VERSION_1_12_6 the tags NUTAG_OFFER_RECV(), NUTAG_ANSWER_RECV(),
+ * NUTAG_ANSWER_SENT(), NUTAG_OFFER_SENT() were not included with
+ * nua_i_state eventif media was disabled.
+ *
+ * @END_NUA_EVENT
+ */
+
 /**
  * Delivers call state changed event to the nua client. @internal
  *
@@ -3430,65 +3616,68 @@ int nua_stack_process_bye(nua_t *nua,
 static void signal_call_state_change(nua_handle_t *nh,
                                     nua_session_usage_t *ss,
                                     int status, char const *phrase,
-                                    enum nua_callstate next_state,
-                                    char const *oa_recv,
-                                    char const *oa_sent)
+                                    enum nua_callstate next_state)
 {
-  enum nua_callstate ss_state;
+  enum nua_callstate ss_state = nua_callstate_init;
 
-  sdp_session_t const *remote_sdp = NULL;
-  char const *remote_sdp_str = NULL;
-  sdp_session_t const *local_sdp = NULL;
-  char const *local_sdp_str = NULL;
+  char const *oa_recv = NULL;
+  char const *oa_sent = NULL;
 
   int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0;
 
-  ss_state = ss ? ss->ss_state : nua_callstate_init;
+  if (ss) {
+    if (ss->ss_reporting)
+      return;
+
+    ss_state = ss->ss_state;
+    oa_recv = ss->ss_oa_recv, ss->ss_oa_recv = NULL;
+    oa_sent = ss->ss_oa_sent, ss->ss_oa_sent = NULL;
+
+    if (oa_recv) {
+      offer_recv = strcasecmp(oa_recv, "offer") == 0;
+      answer_recv = strcasecmp(oa_recv, "answer") == 0;
+    }
+
+    if (oa_sent) {
+      offer_sent = strcasecmp(oa_sent, "offer") == 0;
+      answer_sent = strcasecmp(oa_sent, "answer") == 0;
+    }
+  }
 
   if (ss_state < nua_callstate_ready || next_state > nua_callstate_ready)
     SU_DEBUG_5(("nua(%p): call state changed: %s -> %s%s%s%s%s\n",
-               nh, nua_callstate_name(ss_state),
+               (void *)nh, nua_callstate_name(ss_state),
                nua_callstate_name(next_state),
                oa_recv ? ", received " : "", oa_recv ? oa_recv : "",
                oa_sent && oa_recv ? ", and sent " :
                oa_sent ? ", sent " : "", oa_sent ? oa_sent : ""));
   else
     SU_DEBUG_5(("nua(%p): ready call updated: %s%s%s%s%s\n",
-               nh, nua_callstate_name(next_state),
+               (void *)nh, nua_callstate_name(next_state),
                oa_recv ? " received " : "", oa_recv ? oa_recv : "",
                oa_sent && oa_recv ? ", sent " :
                oa_sent ? " sent " : "", oa_sent ? oa_sent : ""));
 
-  if (oa_recv) {
-    soa_get_remote_sdp(nh->nh_soa, &remote_sdp, &remote_sdp_str, 0);
-    offer_recv = strcasecmp(oa_recv, "offer") == 0;
-    answer_recv = strcasecmp(oa_recv, "answer") == 0;
-  }
-
-  if (oa_sent) {
-    soa_get_local_sdp(nh->nh_soa, &local_sdp, &local_sdp_str, 0);
-    offer_sent = strcasecmp(oa_sent, "offer") == 0;
-    answer_sent = strcasecmp(oa_sent, "answer") == 0;
-  }
-
-  if (answer_recv || answer_sent) {
-    /* Update nh_hold_remote */
-
-    char const *held;
-
-    soa_get_params(nh->nh_soa, SOATAG_HOLD_REF(held), TAG_END());
-
-    nh->nh_hold_remote = held && strlen(held) > 0;
-  }
+  if (next_state == nua_callstate_terminating &&
+      ss_state >= nua_callstate_terminating)
+    return;
 
   if (ss) {
     /* Update state variables */
-    if (next_state > ss_state)
+    if (next_state == nua_callstate_init) {
+      if (ss_state < nua_callstate_ready)
+       ss->ss_state = next_state;
+      else
+       /* Do not change state - we are ready, terminating, or terminated */
+       next_state = ss_state;
+    }
+    else if (next_state > ss_state)
       ss->ss_state = next_state;
-    else if (next_state == nua_callstate_init && ss_state < nua_callstate_ready)
-      ss->ss_state = nua_callstate_init, next_state = nua_callstate_terminated;
   }
 
+  if (next_state == nua_callstate_init) 
+    next_state = nua_callstate_terminated;
+
   if (ss && ss->ss_state == nua_callstate_ready)
     nh->nh_active_call = 1;
   else if (next_state == nua_callstate_terminated)
@@ -3498,69 +3687,56 @@ static void signal_call_state_change(nua_handle_t *nh,
   if (phrase == NULL)
     phrase = "Call state";
 
-/** @NUA_EVENT nua_i_state
- *
- * @brief Call state has changed.
- *
- * This event will be sent whenever the call state changes. 
- *
- * In addition to basic changes of session status indicated with enum
- * ::nua_callstate, the @RFC3264 SDP Offer/Answer negotiation status is also
- * included if it is enabled (by default or with NUTAG_MEDIA_ENABLE(1)). The
- * received remote SDP is included in tag SOATAG_REMOTE_SDP(). The tags
- * NUTAG_OFFER_RECV() or NUTAG_ANSWER_RECV() indicate whether the remote SDP
- * was an offer or an answer. The SDP negotiation result is included in the
- * tags SOATAG_LOCAL_SDP() and SOATAG_LOCAL_SDP_STR() and tags
- * NUTAG_OFFER_SENT() or NUTAG_ANSWER_SENT() indicate whether the local SDP
- * was an offer or answer.
- *
- * SOATAG_ACTIVE_AUDIO() and SOATAG_ACTIVE_VIDEO() are informational tags
- * used to indicate what is the status of audio or video.
- *
- * Note that #nua_i_state also covers call establisment events
- * (#nua_i_active) and termination (#nua_i_terminated).
- *
- * @param status protocol status code \n
- *               (always present)
- * @param phrase short description of status code \n
- *               (always present)
- * @param nh     operation handle associated with the call
- * @param hmagic application context associated with the call
- * @param sip    NULL
- * @param tags   NUTAG_CALLSTATE(), 
- *               SOATAG_LOCAL_SDP(), SOATAG_LOCAL_SDP_STR(),
- *               NUTAG_OFFER_SENT(), NUTAG_ANSWER_SENT(),
- *               SOATAG_REMOTE_SDP(), SOATAG_REMOTE_SDP_STR(),
- *               NUTAG_OFFER_RECV(), NUTAG_ANSWER_RECV(),
- *               SOATAG_ACTIVE_AUDIO(), SOATAG_ACTIVE_VIDEO(),
- *               SOATAG_ACTIVE_IMAGE(), SOATAG_ACTIVE_CHAT().
- *
- * @sa @ref nua_call_model, #nua_i_active, #nua_i_terminated,
- * nua_invite(), #nua_r_invite, #nua_i_invite, nua_respond(), 
- * NUTAG_AUTOALERT(), NUTAG_AUTOANSWER(), NUTAG_EARLY_MEDIA(),
- * NUTAG_EARLY_ANSWER(), NUTAG_INCLUDE_EXTRA_SDP(),
- * nua_ack(), NUTAG_AUTOACK(), nua_bye(), #nua_r_bye, #nua_i_bye,
- * nua_cancel(), #nua_r_cancel, #nua_i_cancel,
- * nua_prack(), #nua_r_prack, #nua_i_prack,
- * nua_update(), #nua_r_update, #nua_i_update
- *
- * @END_NUA_EVENT
- */
+  {
+    sdp_session_t const *remote_sdp = NULL;
+    char const *remote_sdp_str = NULL;
+    sdp_session_t const *local_sdp = NULL;
+    char const *local_sdp_str = NULL;
+
+    if (nh->nh_soa) {
+      if (oa_recv)
+       soa_get_remote_sdp(nh->nh_soa, &remote_sdp, &remote_sdp_str, 0);
+      if (oa_sent)
+       soa_get_local_sdp(nh->nh_soa, &local_sdp, &local_sdp_str, 0);
+
+      if (answer_recv || answer_sent) {      /* Update nh_hold_remote */
+       char const *held = NULL;
+       soa_get_params(nh->nh_soa, SOATAG_HOLD_REF(held), TAG_END());
+       nh->nh_hold_remote = held && strlen(held) > 0;
+      }
+    }
+    else
+      oa_recv = NULL, oa_sent = NULL;
+
+    nua_stack_tevent(nh->nh_nua, nh, NULL, nua_i_state,
+                    status, phrase,
+                    NUTAG_CALLSTATE(next_state),
+                    NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
+                    /* NUTAG_SOA_SESSION(nh->nh_soa), */
+                    TAG_IF(offer_recv, NUTAG_OFFER_RECV(offer_recv)),
+                    TAG_IF(answer_recv, NUTAG_ANSWER_RECV(answer_recv)),
+                    TAG_IF(offer_sent, NUTAG_OFFER_SENT(offer_sent)),
+                    TAG_IF(answer_sent, NUTAG_ANSWER_SENT(answer_sent)),
+                    TAG_IF(oa_recv, SOATAG_REMOTE_SDP(remote_sdp)),
+                    TAG_IF(oa_recv, SOATAG_REMOTE_SDP_STR(remote_sdp_str)),
+                    TAG_IF(oa_sent, SOATAG_LOCAL_SDP(local_sdp)),
+                    TAG_IF(oa_sent, SOATAG_LOCAL_SDP_STR(local_sdp_str)),
+                    TAG_END());
+  }
 
-  nua_stack_event(nh->nh_nua, nh, NULL, nua_i_state,
-                 status, phrase,
-                 NUTAG_CALLSTATE(next_state),
-                 NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
-                 /* NUTAG_SOA_SESSION(nh->nh_soa), */
-                 TAG_IF(offer_recv, NUTAG_OFFER_RECV(offer_recv)),
-                 TAG_IF(answer_recv, NUTAG_ANSWER_RECV(answer_recv)),
-                 TAG_IF(offer_sent, NUTAG_OFFER_SENT(offer_sent)),
-                 TAG_IF(answer_sent, NUTAG_ANSWER_SENT(answer_sent)),
-                 TAG_IF(oa_recv, SOATAG_REMOTE_SDP(remote_sdp)),
-                 TAG_IF(oa_recv, SOATAG_REMOTE_SDP_STR(remote_sdp_str)),
-                 TAG_IF(oa_sent, SOATAG_LOCAL_SDP(local_sdp)),
-                 TAG_IF(oa_sent, SOATAG_LOCAL_SDP_STR(local_sdp_str)),
-                 TAG_END());
+  if (next_state == nua_callstate_ready && ss_state <= nua_callstate_ready) {
+    nua_stack_tevent(nh->nh_nua, nh, NULL, nua_i_active, status, "Call active",
+                    NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
+                    /* NUTAG_SOA_SESSION(nh->nh_soa), */
+                    TAG_END());
+  }
+
+  else if (next_state == nua_callstate_terminated) {
+    nua_stack_event(nh->nh_nua, nh, NULL,
+                   nua_i_terminated, status, phrase,
+                   NULL);
+  }
+}
 
 /** @NUA_EVENT nua_i_active
  *
@@ -3583,13 +3759,6 @@ static void signal_call_state_change(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-  if (next_state == nua_callstate_ready && ss_state <= nua_callstate_ready) {
-    nua_stack_event(nh->nh_nua, nh, NULL, nua_i_active, status, "Call active",
-            NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
-            /* NUTAG_SOA_SESSION(nh->nh_soa), */
-            TAG_END());
-  }
-
 /** @NUA_EVENT nua_i_terminated
  *
  * A call has been terminated.
@@ -3614,18 +3783,13 @@ static void signal_call_state_change(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-  else if (next_state == nua_callstate_terminated) {
-    nua_stack_event(nh->nh_nua, nh, NULL, nua_i_terminated, status, phrase,
-            TAG_END());
-  }
-}
 
 /* ======================================================================== */
 
 static
-int respond_with_retry_after(nua_handle_t *nh, nta_incoming_t *irq,
-                            int status, char const *phrase,
-                            int min, int max)
+int nua_server_retry_after(nua_server_request_t *sr,
+                          int status, char const *phrase,
+                          int min, int max)
 {
   sip_retry_after_t af[1];
 
@@ -3633,17 +3797,299 @@ int respond_with_retry_after(nua_handle_t *nh, nta_incoming_t *irq,
   af->af_delta = (unsigned)su_randint(min, max);
   af->af_comment = phrase;
 
-  nta_incoming_treply(irq, status, phrase,
-                     SIPTAG_RETRY_AFTER(af),
-                     SIPTAG_USER_AGENT_STR(NH_PGET(nh, user_agent)),
-                     TAG_END());
+  sip_add_dup(sr->sr_response.msg, sr->sr_response.sip, (sip_header_t *)af);
+
+  return sr_status(sr, status, phrase);
+}
+
+/* ======================================================================== */
+/* Session timer - RFC 4028 */
+
+static int session_timer_is_supported(struct session_timer const *t)
+{
+  return t->local.supported;
+}
+
+/** Set session timer preferences  */ 
+static
+void session_timer_preferences(struct session_timer *t,
+                              sip_t const *sip,
+                              sip_supported_t const *supported,
+                              unsigned expires,
+                              int isset,
+                              enum nua_session_refresher refresher,
+                              unsigned min_se)
+{
+  memset(&t->local, 0, sizeof t->local);
+
+  t->local.require = sip_has_feature(sip->sip_require, "timer");
+  t->local.supported =
+    sip_has_feature(supported, "timer") ||
+    sip_has_feature(sip->sip_supported, "timer");
+  if (isset || refresher != nua_no_refresher)
+    t->local.expires = expires;
+  else
+    t->local.defaults = expires;
+  t->local.min_se = min_se;
+  t->local.refresher = refresher;
+}
+
+static int session_timer_check_restart(nua_client_request_t *cr,
+                                      int status, char const *phrase,
+                                      sip_t const *sip)
+{
+  if (status == 422) {
+    nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
+
+    if (ss && session_timer_is_supported(ss->ss_timer)) {
+      struct session_timer *t = ss->ss_timer;
+
+      if (sip->sip_min_se && t->local.min_se < sip->sip_min_se->min_delta)
+       t->local.min_se = sip->sip_min_se->min_delta;
+      if (t->local.expires != 0 && t->local.min_se > t->local.expires)
+       t->local.expires = t->local.min_se;
+  
+      return nua_client_restart(cr, 100, "Re-Negotiating Session Timer");
+    }
+  }
+
+  return nua_base_client_check_restart(cr, status, phrase, sip);
+}
+
+/** Check that received Session-Expires is longer than Min-SE */
+static
+int session_timer_check_min_se(msg_t *msg,
+                              sip_t *sip,
+                              sip_t const *request,
+                              unsigned long min)
+{
+  if (min == 0)
+    min = 1;
+
+  /*
+   If an incoming request contains a Supported header field with a value
+   'timer' and a Session Expires header field, the UAS MAY reject the
+   INVITE request with a 422 (Session Interval Too Small) response if
+   the session interval in the Session-Expires header field is smaller
+   than the minimum interval defined by the UAS' local policy.  When
+   sending the 422 response, the UAS MUST include a Min-SE header field
+   with the value of its minimum interval.  This minimum interval MUST
+   NOT be lower than 90 seconds.
+  */
+  if (request->sip_session_expires &&
+      sip_has_feature(request->sip_supported, "timer") &&
+      request->sip_session_expires->x_delta < min) {
+    sip_min_se_t min_se[1];
+
+    if (min < 90)
+      min = 90;
+
+    sip_min_se_init(min_se)->min_delta = min;
+
+    /* Include extension parameters, if any */
+    if (request->sip_min_se)
+      min_se->min_params = request->sip_min_se->min_params;
+    
+    sip_add_dup(msg, sip, (sip_header_t *)min_se);
+
+    return 422;
+  }
+
+  return 0;
+}
+
+/** Store session timer parameters in request from uac / response from uas */ 
+static
+void session_timer_store(struct session_timer *t,
+                        sip_t const *sip)
+{
+  sip_require_t const *require = sip->sip_require;
+  sip_supported_t const *supported = sip->sip_supported;
+  sip_session_expires_t const *x = sip->sip_session_expires;
+
+  t->remote.require = require && sip_has_feature(require, "timer");
+  t->remote.supported =
+    t->remote.supported || (supported && sip_has_feature(supported, "timer"));
+
+  t->remote.expires = 0;
+  t->remote.refresher = nua_any_refresher;
+  t->remote.min_se = 0;
+
+  if (x) {
+    t->remote.expires = x->x_delta;
+
+    if (x->x_refresher) {
+      int uas = sip->sip_request != NULL;
+
+      if (strcasecmp(x->x_refresher, "uac") == 0)
+       t->remote.refresher = uas ? nua_remote_refresher : nua_local_refresher;
+      else if (strcasecmp(x->x_refresher, "uas") == 0)
+       t->remote.refresher = uas ? nua_local_refresher : nua_remote_refresher;
+    }
+  }
+
+  if (sip->sip_min_se)
+    t->remote.min_se = sip->sip_min_se->min_delta;
+}
+
+/** Add timer feature and Session-Expires/Min-SE headers to request/response
+ * 
+ */
+static int
+session_timer_add_headers(struct session_timer *t,
+                         int initial,
+                         msg_t *msg, sip_t *sip)
+{
+  unsigned long expires, min;
+  sip_min_se_t min_se[1];
+  sip_session_expires_t x[1];
+  int uas;
+
+  enum nua_session_refresher refresher = nua_any_refresher;
+
+  static sip_param_t const x_params_uac[] = {"refresher=uac", NULL};
+  static sip_param_t const x_params_uas[] = {"refresher=uas", NULL};
+
+  if (!t->local.supported)
+    return 0;
+
+  uas = sip->sip_status != NULL;
+
+  min = t->local.min_se;
+  if (min < t->remote.min_se)
+    min = t->remote.min_se;
+
+  if (uas) {
+    session_timer_negotiate(t);
+    
+    refresher = t->refresher;
+    expires = t->interval;
+  }
+  else {
+    /* RFC 4028:
+     * The UAC MAY include the refresher parameter with value 'uac' if it
+     * wants to perform the refreshes.  However, it is RECOMMENDED that the
+     * parameter be omitted so that it can be selected by the negotiation
+     * mechanisms described below.
+     */
+    if (t->local.refresher == nua_local_refresher)
+      refresher = nua_local_refresher;
+
+    expires = t->local.expires;
+    if (expires != 0 && expires < min)
+      expires = min;
+  }
+
+  sip_min_se_init(min_se)->min_delta = min;
+
+  sip_session_expires_init(x)->x_delta = expires;
+  if (refresher == nua_remote_refresher)
+    x->x_params = uas ? x_params_uac : x_params_uas;
+  else if (refresher == nua_local_refresher)
+    x->x_params = uas ? x_params_uas : x_params_uac;
+
+  sip_add_tl(msg, sip,
+            TAG_IF(expires != 0, SIPTAG_SESSION_EXPIRES(x)),
+            TAG_IF(min != 0
+                   /* Min-SE: 0 is optional with initial INVITE */
+                   || !initial,
+                   SIPTAG_MIN_SE(min_se)),
+            TAG_IF(refresher == nua_remote_refresher && expires != 0,
+                   SIPTAG_REQUIRE_STR("timer")),
+            TAG_END());
+
+  return 1;
+}
+
+static
+void session_timer_negotiate(struct session_timer *t)
+{
+  if (!t->local.supported)
+    t->refresher = nua_no_refresher;
+  else if (!t->remote.supported)
+    t->refresher = nua_local_refresher;
+  else if (t->remote.refresher == nua_local_refresher)
+    t->refresher = nua_local_refresher;
+  else if (t->remote.refresher == nua_remote_refresher)
+    t->refresher = nua_remote_refresher;
+  else if (t->local.refresher == nua_local_refresher)
+    t->refresher = nua_local_refresher;
+  else
+    t->refresher = nua_remote_refresher;
+
+  t->interval = t->remote.expires;
+  if (t->interval == 0)
+    t->interval = t->local.expires;
+  if (t->local.expires != 0 && t->interval > t->local.expires)
+    t->interval = t->local.expires;
+  if (t->local.defaults != 0 && t->interval > t->local.defaults)
+    t->interval = t->local.defaults;
+    
+  if (t->interval != 0) {
+    if (t->interval < t->local.min_se)
+      t->interval = t->local.min_se;
+    if (t->interval < t->remote.min_se)
+      t->interval = t->remote.min_se;
+  }
+
+  if (t->interval == 0)
+    t->refresher = nua_no_refresher;
+}
+
+static void
+session_timer_set(nua_session_usage_t *ss)
+{
+  nua_dialog_usage_t *du = nua_dialog_usage_public(ss);
+  struct session_timer *t;
+
+  if (ss == NULL)
+    return;
+
+  t = ss->ss_timer;
+
+  session_timer_negotiate(t);
+
+  if (t->refresher == nua_local_refresher) {
+    unsigned low = t->interval / 2, high = t->interval / 2;
+
+    if (t->interval >= 90)
+      low -=5, high += 5;
 
-  return 500;
+    nua_dialog_usage_refresh_range(du, low, high);
+    t->timer_set = 1;
+  }
+  else if (t->refresher == nua_remote_refresher) {
+    /* if the side not performing refreshes does not receive a
+       session refresh request before the session expiration, it SHOULD send
+       a BYE to terminate the session, slightly before the session
+       expiration.  The minimum of 32 seconds and one third of the session
+       interval is RECOMMENDED. */
+    unsigned interval = t->interval;
+
+    interval -= 32 > interval / 6 ? interval / 3 : 32 + interval / 3;
+
+    nua_dialog_usage_refresh_range(du, interval, interval);
+    t->timer_set = 1;
+  }
+  else {
+    nua_dialog_usage_reset_refresh(du);
+    t->timer_set = 0;
+  }
+}
+
+static inline int
+session_timer_has_been_set(struct session_timer const *t)
+{
+  return t->timer_set;
 }
 
 /* ======================================================================== */
 
-/** Get SDP from a SIP message */
+/** Get SDP from a SIP message.
+ *
+ * @retval 1 if message contains SDP
+ * @retval 0 if message does not contain valid SDP
+ */
 static
 int session_get_description(sip_t const *sip,
                            char const **return_sdp,
@@ -3680,8 +4126,10 @@ int session_get_description(sip_t const *sip,
       return 0;
   }
 
-  *return_sdp = pl->pl_data;
-  *return_len = pl->pl_len;
+  if (return_sdp && return_len) {
+    *return_sdp = pl->pl_data;
+    *return_len = pl->pl_len;
+  }
 
   return 1;
 }
@@ -3746,7 +4194,7 @@ int session_make_description(su_home_t *home,
     else
       *return_cd = NULL;
 
-    if (!*return_pl || !*return_cd)
+    if (!*return_pl || !*return_ct)
       return -1;
 
     if (session && !*return_cd)
@@ -3756,145 +4204,7 @@ int session_make_description(su_home_t *home,
   return retval;
 }
 
-/**
- * Stores and processes SDP from incoming response, then calls
- * nua_stack_process_response().
- *
- * @retval 1 if there was SDP to process.
- */
-static
-int session_process_response(nua_handle_t *nh,
-                            nua_client_request_t *cr,
-                            nta_outgoing_t *orq,
-                            sip_t const *sip,
-                            char const **return_received)
-{
-  char const *method = nta_outgoing_method_name(orq);
-  msg_t *msg = nta_outgoing_getresponse(orq);
-  int retval = 0;
-  char const *sdp = NULL;
-  size_t len;
-
-  if (nh->nh_soa == NULL)
-    /* Xyzzy */;
-  else if (!session_get_description(sip, &sdp, &len))
-    /* No SDP */;
-  else if (cr->cr_answer_recv) {
-    /* Ignore spurious answers after completing O/A */
-    SU_DEBUG_3(("nua(%p): %s: ignoring duplicate SDP in %u %s\n",
-               nh, method,
-               sip->sip_status->st_status, sip->sip_status->st_phrase));
-    sdp = NULL;
-  }
-  else if (!cr->cr_offer_sent &&
-          nta_outgoing_method(orq) != sip_method_invite) {
-    /* If non-invite request did not have offer, ignore SDP in response */
-    SU_DEBUG_3(("nua(%p): %s: ignoring extra SDP in %u %s\n",
-               nh, method,
-               sip->sip_status->st_status, sip->sip_status->st_phrase));
-    sdp = NULL;
-  }
-  else {
-    if (cr->cr_offer_sent) {
-      cr->cr_answer_recv = sip->sip_status->st_status;
-      *return_received = "answer";
-    }
-    else {
-      cr->cr_offer_recv = 1, cr->cr_answer_sent = 0;
-      *return_received = "offer";
-    }
-
-    if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
-      SU_DEBUG_5(("nua(%p): %s: error parsing SDP in %u %s\n",
-                 nh, method,
-                 sip->sip_status->st_status,
-                 sip->sip_status->st_phrase));
-      retval = -1;
-      sdp = NULL;
-    }
-    else if (cr->cr_offer_recv) {
-      /* note: case 1: incoming offer */
-      SU_DEBUG_5(("nua(%p): %s: get SDP %s in %u %s\n",
-                 nh, method, "offer",
-                 sip->sip_status->st_status,
-                 sip->sip_status->st_phrase));
-      retval = 1;
-    }
-    else if (soa_process_answer(nh->nh_soa, NULL) < 0) {
-      SU_DEBUG_5(("nua(%p): %s: error processing SDP answer in %u %s\n",
-                 nh, method,
-                 sip->sip_status->st_status,
-                 sip->sip_status->st_phrase));
-      sdp = NULL;
-    }
-    else {
-      /* note: case 2: answer to our offer */
-      if (soa_activate(nh->nh_soa, NULL) < 0) {
-       SU_DEBUG_3(("nua(%p): %s: error activating media after %u %s\n",
-                   nh, method,
-                   sip->sip_status->st_status,
-                   sip->sip_status->st_phrase));
-       /* XXX */
-      }
-      else {
-       SU_DEBUG_5(("nua(%p): %s: processed SDP answer in %u %s\n",
-                   nh, method,
-                   sip->sip_status->st_status,
-                   sip->sip_status->st_phrase));
-      }
-
-      assert(!cr->cr_offer_recv);
-    }
-  }
-
-  msg_destroy(msg);            /* unref */
-
-  nua_stack_process_response(nh, cr, orq, sip,
-                            NH_REMOTE_MEDIA_TAGS(sdp != NULL, nh->nh_soa),
-                            TAG_END());
-
-  return retval;
-}
-
-#if 0
-/** Parse and store SDP from incoming request */
-static
-int session_process_request(nua_handle_t *nh,
-                           nta_incoming_t *irq,
-                           sip_t const *sip)
-{
-  char const *sdp = NULL;
-  isize_t len;
-
-  if (nh->nh_soa) {
-    msg_t *msg = nta_outgoing_getresponse(irq);
-
-    if (session_get_description(msg, sip, &sdp, &len)) {
-      if (soa_is_complete(nh->nh_soa)) {
-       /* Ignore spurious answers after completing O/A */
-       SU_DEBUG_5(("nua: ignoring duplicate SDP in %u %s\n",
-                   sip->sip_status->st_status, sip->sip_status->st_phrase));
-       sdp = NULL;
-      }
-      else if (soa_parse_sdp(nh->nh_soa, sdp, len) < 0) {
-       SU_DEBUG_5(("nua: error parsing SDP in %u %s\n",
-                   sip->sip_status->st_status,
-                   sip->sip_status->st_phrase));
-       sdp = NULL;
-      }
-    }
-
-    msg_destroy(msg);
-  }
-
-  return
-    nua_stack_process_response(nh, cr, orq, sip,
-                              NH_REMOTE_MEDIA_TAGS(sdp != NULL, nh->nh_soa),
-                              TAG_END());
-}
-#endif
-
-static int respond_to_options(nua_server_request_t *sr, tagi_t const *tags);
+/* ====================================================================== */
 
 /** @NUA_EVENT nua_i_options
  *
@@ -3924,50 +4234,38 @@ static int respond_to_options(nua_server_request_t *sr, tagi_t const *tags);
  * @END_NUA_EVENT
  */
 
-int nua_stack_process_options(nua_t *nua,
-                             nua_handle_t *nh,
-                             nta_incoming_t *irq,
-                             sip_t const *sip)
-{
-  nua_server_request_t *sr, sr0[1];
-  int done;
-
-  /* Hook to outbound */
-  done = nua_registration_process_request(nua->nua_registrations, irq, sip);
-  if (done)
-    return done;
+int nua_options_server_respond(nua_server_request_t *sr, tagi_t const *tags);
 
-  sr = nua_server_request(nua, nh, irq, sip, SR_INIT(sr0), sizeof *sr,
-                         respond_to_options, 0);
-
-  SR_STATUS1(sr, SIP_200_OK);
-
-  return nua_stack_server_event(nua, sr, nua_i_options, TAG_END());
-}
+nua_server_methods_t const nua_options_server_methods = 
+  {
+    SIP_METHOD_OPTIONS,
+    nua_i_options,             /* Event */
+    { 
+      0,                       /* Do not create dialog */
+      0,                       /* Initial request */
+      0,                       /* Not a target refresh request  */
+      1,                       /* Add Contact */
+    },
+    nua_base_server_init,
+    nua_base_server_preprocess,
+    nua_base_server_params,
+    nua_options_server_respond,
+    nua_base_server_report,
+  };
 
 /** @internal Respond to an OPTIONS request.
  *
  */
-static int respond_to_options(nua_server_request_t *sr, tagi_t const *tags)
+int nua_options_server_respond(nua_server_request_t *sr, tagi_t const *tags)
 {
   nua_handle_t *nh = sr->sr_owner;
   nua_t *nua = nh->nh_nua;
-  msg_t *msg;
-  int final;
 
-  msg = nua_server_response(sr,
-                           sr->sr_status, sr->sr_phrase,
-                           SIPTAG_ALLOW(NH_PGET(nh, allow)),
-                           SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
-                           TAG_IF(NH_PGET(nh, path_enable),
-                                  SIPTAG_SUPPORTED_STR("path")),
-                           SIPTAG_ACCEPT_STR(SDP_MIME_TYPE),
-                           TAG_NEXT(tags));
+  if (200 <= sr->sr_status && sr->sr_status < 300) {
+    msg_t *msg = sr->sr_response.msg;
+    sip_t *sip = sr->sr_response.sip;
 
-  final = sr->sr_status >= 200;
-
-  if (msg) {
-    sip_t *sip = sip_object(msg);
+    sip_add_tl(msg, sip, SIPTAG_ACCEPT(nua->nua_invite_accept), TAG_END());
 
     if (!sip->sip_payload) {   /* XXX - do MIME multipart? */
       soa_session_t *soa = nh->nh_soa;
@@ -3977,10 +4275,7 @@ static int respond_to_options(nua_server_request_t *sr, tagi_t const *tags)
 
       session_include_description(soa, 0, msg, sip);
     }
-
-    if (nta_incoming_mreply(sr->sr_irq, msg) < 0)
-      final = 1;
   }
 
-  return final;
+  return nua_base_server_respond(sr, tags);
 }
index 202b90b54c6fb6d6afdfe5ac91bf9f58f14bcf5b..e00111a5c16324c65617f19b6e7d671047a85a54 100644 (file)
@@ -37,7 +37,7 @@
 #include "config.h"
 
 #include <sofia-sip/su_tag_class.h>
-#include <sofia-sip/su_tag_class.h>
+#include <sofia-sip/su_tag_inline.h>
 #include <sofia-sip/su_tagarg.h>
 #include <sofia-sip/su_strlst.h>
 #include <sofia-sip/su_uniqueid.h>
@@ -51,8 +51,7 @@
 
 #define NTA_AGENT_MAGIC_T    struct nua_s
 #define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-#define NTA_INCOMING_MAGIC_T struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_client_request
 
 #include <sofia-sip/sip.h>
 #include <sofia-sip/sip_header.h>
@@ -91,8 +90,6 @@ static void nh_remove(nua_t *nua, nua_handle_t *nh);
 static int nh_authorize(nua_handle_t *nh,
                        tag_type_t tag, tag_value_t value, ...);
 
-static int nh_challenge(nua_handle_t *nh, sip_t const *sip);
-
 static void nua_stack_timer(nua_t *nua, su_timer_t *t, su_timer_arg_t *a);
 
 /* ---------------------------------------------------------------------- */
@@ -147,7 +144,7 @@ int nua_stack_init(su_root_t *root, nua_t *nua)
     return -1;
 
   dnh->nh_prefs = (void *)(dnh + 1);
-  dnh->nh_valid = nua_handle;
+  dnh->nh_valid = nua_valid_handle_cookie;
   dnh->nh_nua = nua;
   nua_handle_ref(dnh); dnh->nh_ref_by_stack = 1; 
   nua_handle_ref(dnh); dnh->nh_ref_by_user = 1;
@@ -226,29 +223,40 @@ void
 int nh_notifier_shutdown(nua_handle_t *nh, nea_event_t *ev,
                         tag_type_t t, tag_value_t v, ...);
 
+int nua_stack_tevent(nua_t *nua, nua_handle_t *nh, msg_t *msg,
+                    nua_event_t event, int status, char const *phrase,
+                    tag_type_t tag, tag_value_t value, ...)
+{
+  ta_list ta;
+  int retval;
+  ta_start(ta, tag, value);
+  retval = nua_stack_event(nua, nh, msg, event, status, phrase, ta_args(ta));
+  ta_end(ta);
+  return retval;
+}
+
 /** @internal Send an event to the application. */
 int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
                    nua_event_t event, int status, char const *phrase,
-                   tag_type_t tag, tag_value_t value, ...)
+                   tagi_t const *tags)
 {
   su_msg_r sumsg = SU_MSG_R_INIT;
-
-  ta_list ta;
   size_t e_len, len, xtra, p_len;
 
   if (event == nua_r_ack || event == nua_i_none)
     return event;
 
-  enter;
+  if (nh == nua->nua_dhandle)
+    nh = NULL;
 
   if (nua_log->log_level >= 5) {
     char const *name = nua_event_name(event) + 4;
     char const *p = phrase ? phrase : "";
 
     if (status == 0)
-      SU_DEBUG_5(("nua(%p): %s %s\n", nh, name, p));
+      SU_DEBUG_5(("nua(%p): event %s %s\n", (void *)nh, name, p));
     else
-      SU_DEBUG_5(("nua(%p): %s %u %s\n", nh, name, status, p));
+      SU_DEBUG_5(("nua(%p): event %s %u %s\n", (void *)nh, name, status, p));
   }
 
   if (event == nua_r_destroy) {
@@ -269,36 +277,42 @@ int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
     return event;
   }
 
-  ta_start(ta, tag, value);
-
-  e_len = offsetof(event_t, e_tags);
-  len = tl_len(ta_args(ta));
-  xtra = tl_xtra(ta_args(ta), len);
+  if (tags) {
+    e_len = offsetof(event_t, e_tags);
+    len = tl_len(tags);
+    xtra = tl_xtra(tags, len);
+  }
+  else {
+    e_len = sizeof(event_t), len = 0, xtra = 0;
+  }
   p_len = phrase ? strlen(phrase) + 1 : 1;
 
   if (su_msg_create(sumsg, nua->nua_client, su_task_null,
                    nua_event, e_len + len + xtra + p_len) == 0) {
     event_t *e = su_msg_data(sumsg);
+    void *p;
 
-    tagi_t *t = e->e_tags, *t_end = (tagi_t *)((char *)t + len);
-    void *b = t_end, *end = (char *)b + xtra;
+    if (tags) {
+      tagi_t *t = e->e_tags, *t_end = (tagi_t *)((char *)t + len);
+      void *b = t_end, *end = (char *)b + xtra;
 
-    t = tl_dup(t, ta_args(ta), &b);
-    assert(t == t_end); assert(b == end);
+      t = tl_dup(t, tags, &b); p = b;
+      assert(t == t_end); assert(b == end); (void)end;
+    }
+    else
+      p = e + 1;
 
     e->e_event = event;
     e->e_nh = nh ? nua_handle_ref(nh) : nua->nua_dhandle;
     e->e_status = status;
-    e->e_phrase = strcpy(end, phrase ? phrase : "");
+    e->e_phrase = strcpy(p, phrase ? phrase : "");
     if (msg)
       e->e_msg = msg, su_home_threadsafe(msg_home(msg));
 
-    if (su_msg_send(sumsg) != 0)
+    if (su_msg_send(sumsg) != 0 && nh)
       nua_handle_unref(nh);
   }
 
-  ta_end(ta);
-
   return event;
 }
 
@@ -322,9 +336,16 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_event_data_t *e)
 {
   nua_handle_t *nh = e->e_nh;
   tagi_t *tags = e->e_tags;
+  nua_event_t event;
+  int error = 0;
 
   assert(tags);
 
+  if (nua_log->log_level >= 7) {
+    char const *name = nua_event_name(e->e_event) + 4;
+    SU_DEBUG_7(("nua(%p): recv %s\n", (void *)nh, name));
+  }
+
   if (nh) {
     if (!nh->nh_prev)
       nh_append(nua, nh);
@@ -338,98 +359,105 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_event_data_t *e)
   if (nua_log->log_level >= 5) {
     char const *name = nua_event_name(e->e_event);
     if (e->e_status == 0)
-      SU_DEBUG_5(("nua(%p): signal %s\n", nh, name + 4));
+      SU_DEBUG_5(("nua(%p): signal %s\n", (void *)nh, name + 4));
     else
       SU_DEBUG_5(("nua(%p): signal %s %u %s\n",
-                 nh, name + 4, e->e_status, e->e_phrase ? e->e_phrase : ""));
+                 (void *)nh, name + 4,
+                 e->e_status, e->e_phrase ? e->e_phrase : ""));
   }
 
   su_msg_save(nua->nua_signal, msg);
 
+  event = e->e_event;
+
   if (nua->nua_shutdown && !e->e_always) {
     /* Shutting down */
-    nua_stack_event(nua, nh, NULL, e->e_event,
+    nua_stack_event(nua, nh, NULL, event,
                    901, "Stack is going down",
-                   TAG_END());
+                   NULL);
   }
-
-  else switch (e->e_event) {
+  else switch (event) {
   case nua_r_get_params:
-    nua_stack_get_params(nua, nh ? nh : nua->nua_dhandle, e->e_event, tags);
+    nua_stack_get_params(nua, nh ? nh : nua->nua_dhandle, event, tags);
     break;
   case nua_r_set_params:
-    nua_stack_set_params(nua, nh ? nh : nua->nua_dhandle, e->e_event, tags);
+    nua_stack_set_params(nua, nh ? nh : nua->nua_dhandle, event, tags);
     break;
   case nua_r_shutdown:
     nua_stack_shutdown(nua);
     break;
   case nua_r_register:
   case nua_r_unregister:
-    nua_stack_register(nua, nh, e->e_event, tags);
+    nua_stack_register(nua, nh, event, tags);
     break;
   case nua_r_invite:
-    nua_stack_invite(nua, nh, e->e_event, tags);
+    error = nua_stack_invite(nua, nh, event, tags);
     break;
   case nua_r_cancel:
-    nua_stack_cancel(nua, nh, e->e_event, tags);
+    error = nua_stack_cancel(nua, nh, event, tags);
     break;
   case nua_r_bye:
-    nua_stack_bye(nua, nh, e->e_event, tags);
+    error = nua_stack_bye(nua, nh, event, tags);
     break;
   case nua_r_options:
-    nua_stack_options(nua, nh, e->e_event, tags);
+    error = nua_stack_options(nua, nh, event, tags);
     break;
   case nua_r_refer:
-    nua_stack_refer(nua, nh, e->e_event, tags);
+    error = nua_stack_refer(nua, nh, event, tags);
     break;
   case nua_r_publish:
   case nua_r_unpublish:
-    nua_stack_publish(nua, nh, e->e_event, tags);
+    error = nua_stack_publish(nua, nh, event, tags);
     break;
   case nua_r_info:
-    nua_stack_info(nua, nh, e->e_event, tags);
+    error = nua_stack_info(nua, nh, event, tags);
     break;
   case nua_r_update:
-    nua_stack_update(nua, nh, e->e_event, tags);
+    error = nua_stack_update(nua, nh, event, tags);
     break;
   case nua_r_message:
-    nua_stack_message(nua, nh, e->e_event, tags);
+    error = nua_stack_message(nua, nh, event, tags);
     break;
   case nua_r_subscribe:
   case nua_r_unsubscribe:
-    nua_stack_subscribe(nua, nh, e->e_event, tags);
+    error = nua_stack_subscribe(nua, nh, event, tags);
     break;
   case nua_r_notify:
-    nua_stack_notify(nua, nh, e->e_event, tags);
+    error = nua_stack_notify(nua, nh, event, tags);
     break;
   case nua_r_notifier:
-    nua_stack_notifier(nua, nh, e->e_event, tags);
+    nua_stack_notifier(nua, nh, event, tags);
     break;
   case nua_r_terminate:
-    nua_stack_terminate(nua, nh, e->e_event, tags);
+    nua_stack_terminate(nua, nh, event, tags);
     break;
   case nua_r_method:
-    nua_stack_method(nua, nh, e->e_event, tags);
+    error = nua_stack_method(nua, nh, event, tags);
     break;
   case nua_r_authenticate:
-    nua_stack_authenticate(nua, nh, e->e_event, tags);
+    nua_stack_authenticate(nua, nh, event, tags);
     break;
   case nua_r_authorize:
-    nua_stack_authorize(nua, nh, e->e_event, tags);
+    nua_stack_authorize(nua, nh, event, tags);
     break;
   case nua_r_ack:
-    nua_stack_ack(nua, nh, e->e_event, tags);
+    error = nua_stack_ack(nua, nh, event, tags);
     break;
   case nua_r_respond:
     nua_stack_respond(nua, nh, e->e_status, e->e_phrase, tags);
     break;
-  case nua_r_destroy:
+  case nua_r_destroy: 
     nua_stack_destroy_handle(nua, nh, tags);
-    break;
+    su_msg_destroy(nua->nua_signal);
+    return;
   default:
     break;
   }
 
+  if (error < 0) {
+    nua_stack_event(nh->nh_nua, nh, NULL, event, NUA_INTERNAL_ERROR, NULL);
+  }
+
   if (su_msg_is_non_null(nua->nua_signal))
     su_msg_destroy(nua->nua_signal);
 
@@ -512,6 +540,7 @@ int nh_call_pending(nua_handle_t *nh, sip_time_t now)
 }
 
 
+
 /* ====================================================================== */
 
 /**Shutdown a @nua stack.
@@ -581,15 +610,11 @@ void nua_stack_shutdown(nua_t *nua)
     for (sr = ds->ds_sr; sr; sr = sr_next) {
       sr_next = sr->sr_next;
 
-      if (sr->sr_respond) {
-       SR_STATUS1(sr, SIP_410_GONE);
-       sr->sr_usage = NULL;
-       sr->sr_respond(sr, NULL);
-       sr->sr_respond = NULL;
-       busy++;
+      if (nua_server_request_is_pending(sr)) {
+       SR_STATUS1(sr, SIP_410_GONE); /* 410 terminates dialog */
+       nua_server_respond(sr, NULL);
+       nua_server_report(sr);
       }
-       
-      nua_server_request_destroy(sr);
     }
 
     busy += nh_call_pending(nh, 0);
@@ -625,7 +650,7 @@ void nua_stack_shutdown(nua_t *nua)
     nta_agent_destroy(nua->nua_nta), nua->nua_nta = NULL;
   }
 
-  nua_stack_event(nua, NULL, NULL, nua_r_shutdown, status, phrase, TAG_END());
+  nua_stack_event(nua, NULL, NULL, nua_r_shutdown, status, phrase, NULL);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -650,7 +675,7 @@ nua_handle_t *nh_create(nua_t *nua, tag_type_t tag, tag_value_t value, ...)
   return nh;
 }
 
-/** @internal Append an handle to the list of handles */
+/** @internal Append a handle to the list of handles */
 void nh_append(nua_t *nua, nua_handle_t *nh)
 {
   nh->nh_next = NULL;
@@ -673,17 +698,15 @@ nua_handle_t *nh_validate(nua_t *nua, nua_handle_t *maybe)
 
 void nua_stack_destroy_handle(nua_t *nua, nua_handle_t *nh, tagi_t const *tags)
 {
-  nh_call_pending(nh, 0);      /* Call pending operations with 0 */
-
   if (nh->nh_notifier)
     nua_stack_terminate(nua, nh, 0, NULL);
 
-#if 0
+  nua_dialog_shutdown(nh, nh->nh_ds);
+
   if (nh->nh_ref_by_user) {
     nh->nh_ref_by_user = 0;
     nua_handle_unref(nh);
   }
-#endif
 
   nh_destroy(nua, nh);
 }
@@ -712,12 +735,14 @@ void nh_destroy(nua_t *nua, nua_handle_t *nh)
 {
   assert(nh); assert(nh != nua->nua_dhandle);
 
-  nh_enter;
-
   if (nh->nh_notifier)
     nea_server_destroy(nh->nh_notifier), nh->nh_notifier = NULL;
 
-  nua_creq_deinit(nh->nh_ds->ds_cr, NULL);
+  while (nh->nh_ds->ds_cr)
+    nua_client_request_destroy(nh->nh_ds->ds_cr);
+
+  while (nh->nh_ds->ds_sr)
+    nua_server_request_destroy(nh->nh_ds->ds_sr);
 
   nua_dialog_deinit(nh, nh->nh_ds);
 
@@ -733,7 +758,7 @@ void nh_destroy(nua_t *nua, nua_handle_t *nh)
 /* ======================================================================== */
 
 /**@internal
- * Initialize handle Allow and authentication info, save parameters.
+ * Save handle parameters and initial authentication info.
  *
  * @retval -1 upon an error
  * @retval 0 when successful
@@ -912,1202 +937,1838 @@ int nh_authorize(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
   return retval;
 }
 
-/**@internal
- * Collect challenges from response.
+static inline
+int can_redirect(sip_contact_t const *m, sip_method_t method)
+{
+  if (m && m->m_url->url_host) {
+    enum url_type_e type = m->m_url->url_type;
+    return
+      type == url_sip ||
+      type == url_sips ||
+      (type == url_tel &&
+       (method == sip_method_invite || method == sip_method_message)) ||
+      (type == url_im && method == sip_method_message) ||
+      (type == url_pres && method == sip_method_subscribe);
+  }
+  return 0;
+}
+
+/* ======================================================================== */
+/* Authentication */
+
+/** @NUA_EVENT nua_r_authenticate
+ *
+ * Response to nua_authenticate(). Under normal operation, this event is
+ * never sent but rather the unauthenticated operation is completed. 
+ * However, if there is no operation to authentication or if there is an
+ * authentication error the #nua_r_authenticate event is sent to the
+ * application with the status code as follows:
+ * - <i>202 No operation to restart</i>:\n
+ *   The authenticator associated with the handle was updated, but there was
+ *   no operation to retry with the new credentials.
+ * - <i>900 Cannot add credentials</i>:\n
+ *   There was internal problem updating authenticator.
+ * - <i>904 No matching challenge</i>:\n
+ *   There was no challenge matching with the credentials provided by
+ *   nua_authenticate(), e.g., their realm did not match with the one 
+ *   received with the challenge.
+ * 
+ * @param status status code from authentication 
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle authenticated
+ * @param hmagic application context associated with the handle
+ * @param sip    NULL
+ * @param tags   empty
+ * 
+ * @sa nua_terminate(), nua_handle_destroy()
  *
- * @return Number of updated challenges, 0 if no updates found.
- * @retval -1 upon error.
+ * @END_NUA_EVENT
  */
-static
-int nh_challenge(nua_handle_t *nh, sip_t const *sip)
+
+void
+nua_stack_authenticate(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+                      tagi_t const *tags)
 {
-  int server = 0, proxy = 0;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  int status = nh_authorize(nh, TAG_NEXT(tags));
 
-  if (sip->sip_www_authenticate)
-    server = auc_challenge(&nh->nh_auth, nh->nh_home,
-                          sip->sip_www_authenticate,
-                          sip_authorization_class);
+  if (status > 0) {
+    if (cr && cr->cr_wait_for_cred) {
+      nua_client_restart_request(cr, cr->cr_terminating, tags);
+    }
+    else {
+      nua_stack_event(nua, nh, NULL, e, 
+                     202, "No operation to restart",
+                     NULL);
+    }
+  }
+  else if (cr && cr->cr_wait_for_cred) {
+    cr->cr_wait_for_cred = 0;
 
-  if (sip->sip_proxy_authenticate)
-    proxy = auc_challenge(&nh->nh_auth, nh->nh_home,
-                         sip->sip_proxy_authenticate,
-                         sip_proxy_authorization_class);
+    if (status < 0)
+      nua_client_response(cr, 900, "Cannot add credentials", NULL);
+    else
+      nua_client_response(cr, 904, "No matching challenge", NULL);
+  }
+  else if (status < 0) {
+    nua_stack_event(nua, nh, NULL, e, 900, "Cannot add credentials", NULL);
+  }
+  else {
+    nua_stack_event(nua, nh, NULL, e, 904, "No matching challenge", NULL);
+  }
+}
 
-  if (server < 0 || proxy < 0)
-    return -1;
 
-  return server + proxy;
-}
+/* ======================================================================== */
+/*
+ * Process incoming requests
+ */
 
-#include <sofia-sip/su_tag_inline.h>
+nua_server_methods_t const *nua_server_methods[] = {
+  /* These must be in same order as in sip_method_t */
+  &nua_extension_server_methods,
+  &nua_invite_server_methods,  /**< INVITE */
+  NULL,                                /**< ACK */
+  NULL,                                /**< CANCEL */
+  &nua_bye_server_methods,     /**< BYE */
+  &nua_options_server_methods, /**< OPTIONS */
+  &nua_register_server_methods,        /**< REGISTER */
+  &nua_info_server_methods,    /**< INFO */
+  &nua_prack_server_methods,   /**< PRACK */
+  &nua_update_server_methods,  /**< UPDATE */
+  &nua_message_server_methods, /**< MESSAGE */
+  &nua_subscribe_server_methods,/**< SUBSCRIBE */
+  &nua_notify_server_methods,  /**< NOTIFY */
+  &nua_refer_server_methods,   /**< REFER */
+  &nua_publish_server_methods, /**< PUBLISH */
+  NULL
+};
 
-/** Check if tag list has contact */
-int nua_tagis_have_contact_tag(tagi_t const *t)
-{
-  for (; t && t->t_tag; t = t_next(t))
-    if (t->t_tag == siptag_contact ||
-       t->t_tag == siptag_contact_str)
-      return 1;
-  return 0;
-}
 
-/**@internal
- * Create a request message.
- *
- * @param nua
- * @param nh
- * @param cr
- * @param restart
- * @param method
- * @param name
- * @param tag, value, ... list of tag-value pairs
- */
-msg_t *nua_creq_msg(nua_t *nua,
-                   nua_handle_t *nh,
-                   nua_client_request_t *cr,
-                   int restart,
-                   sip_method_t method, char const *name,
-                   tag_type_t tag, tag_value_t value, ...)
+int nua_stack_process_request(nua_handle_t *nh,
+                             nta_leg_t *leg,
+                             nta_incoming_t *irq,
+                             sip_t const *sip)
 {
-  struct nua_dialog_state *ds = nh->nh_ds;
-  msg_t *msg = NULL;
-  sip_t *sip;
-  ta_list ta;
-  url_string_t const *url = NULL;
-  long seq = -1;
-  int copy = 1;
-
-  /* If restarting, use existing message */
-  if (restart) {
-    msg = cr->cr_msg; sip = sip_object(msg);
-
-    /* Trying to restart different method? */
-    if (sip && method && sip->sip_request->rq_method != method) {
-      SU_DEBUG_3(("nua(%p): trying to %s "
-                 "but there is already %s waiting to restart\n",
-                 nh, name, sip->sip_request->rq_method_name));
-      restart = 0, msg = NULL; sip = NULL;
-    }
+  nua_t *nua = nh->nh_nua;
+  sip_method_t method = sip->sip_request->rq_method;
+  char const *name = sip->sip_request->rq_method_name;
+  nua_server_methods_t const *sm;
+  nua_server_request_t *sr, sr0[1];
+  int status, initial = 1;
+  int create_dialog;
 
-    /* Remove CSeq */
-    if (sip && sip->sip_cseq)
-      sip_header_remove(msg, sip, (sip_header_t *)sip->sip_cseq);
-    if (sip && sip->sip_request)
-      method = sip->sip_request->rq_method,
-       name = sip->sip_request->rq_method_name;
-  }
-
-  if (!restart) {
-    if (cr->cr_msg) {
-      /* If method is ACK or CANCEL, use existing CSeq */
-      if (method == sip_method_ack || method == sip_method_cancel) {
-       sip_t *nh_sip = sip_object(cr->cr_msg);
-       if (nh_sip && nh_sip->sip_cseq)
-         seq = nh_sip->sip_cseq->cs_seq;
-       /* ACK/CANCEL cannot be restarted so we do not copy message */
-       copy = 0;
-      }
-      else
-       msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
-    }
-    msg = nta_msg_create(nua->nua_nta, 0);
+  char const *user_agent = NH_PGET(nh, user_agent);
+  sip_supported_t const *supported = NH_PGET(nh, supported);
+  sip_allow_t const *allow = NH_PGET(nh, allow);
+
+  enter;
+
+  nta_incoming_tag(irq, NULL);
+
+  if (method == sip_method_cancel)
+    return 481;
 
-    /**@par Populating SIP Request Message with Tagged Arguments
-     *
-     * The tagged arguments can be used to pass values for any SIP headers
-     * to the stack. When the INVITE message (or any other SIP message) is
-     * created, the tagged values saved with nua_handle() are used first,
-     * next the tagged values given with the operation (nua_invite()) are
-     * added.
-     *
-     * When multiple tags for the same header are specified, the behaviour
-     * depends on the header type. If only a single header field can be
-     * included in a SIP message, the latest non-NULL value is used, e.g.,
-     * @Subject. However, if the SIP header can consist of multiple lines or
-     * header fields separated by comma, e.g., @Accept, all the tagged
-     * values are concatenated.
-     *
-     * However, if a tag value is #SIP_NONE (-1 casted as a void pointer),
-     * the values from previous tags are ignored.
-     */
-    tl_gets(nh->nh_tags, NUTAG_URL_REF(url), TAG_END());
-    sip_add_tl(msg, sip_object(msg), TAG_NEXT(nh->nh_tags));
+  /* Hook to outbound */
+  if (method == sip_method_options) {
+    status = nua_registration_process_request(nua->nua_registrations,
+                                             irq, sip);
+    if (status)
+      return status;
   }
 
-  ta_start(ta, tag, value);
+  if (nta_check_method(irq, sip, allow,
+                      SIPTAG_SUPPORTED(supported),
+                      SIPTAG_USER_AGENT_STR(user_agent),
+                      TAG_END()))
+    return 405;
 
-  sip = sip_object(msg);
-  if (!sip)
-    goto error;
-  if (sip_add_tl(msg, sip, ta_tags(ta)) < 0)
-    goto error;
+  switch (sip->sip_request->rq_url->url_type) {
+  case url_sip:
+  case url_sips:
+  case url_im:
+  case url_pres:
+  case url_tel:
+    break;
+  default:
+    nta_incoming_treply(irq, status = SIP_416_UNSUPPORTED_URI,
+                       SIPTAG_ALLOW(allow),
+                       SIPTAG_SUPPORTED(supported),
+                       SIPTAG_USER_AGENT_STR(user_agent),
+                       TAG_END());
+    return status;
+  }
 
-  if (method != sip_method_ack) {
-    /**
-     * Next, values previously set with nua_set_params() or nua_set_hparams()
-     * are used: @Allow, @Supported, @Organization, and @UserAgent headers are
-     * added to the request if they are not already set. 
-     */
-    if (!sip->sip_allow && !ds->ds_remote_tag)
-      sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow));
-
-    if (!sip->sip_supported && NH_PGET(nh, supported))
-      sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, supported));
-    
-    if (method == sip_method_register && NH_PGET(nh, path_enable) &&
-       !sip_has_feature(sip->sip_supported, "path") &&
-       !sip_has_feature(sip->sip_require, "path"))
-      sip_add_make(msg, sip, sip_supported_class, "path");
+  if (nta_check_required(irq, sip, supported,
+                        SIPTAG_ALLOW(allow),
+                        SIPTAG_USER_AGENT_STR(user_agent),
+                        TAG_END()))
+    return 420;
 
-    if (!sip->sip_organization && NH_PGET(nh, organization))
-      sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, organization));
+  if (method > sip_method_unknown && method <= sip_method_publish)
+    sm = nua_server_methods[method];
+  else
+    sm = nua_server_methods[0];
+
+  initial = nh == nua->nua_dhandle;
+
+  if (sm == NULL) {
+    SU_DEBUG_1(("nua(%p): strange %s from <" URL_PRINT_FORMAT ">\n",
+               (void *)nh, sip->sip_request->rq_method_name,
+               URL_PRINT_ARGS(sip->sip_from->a_url)));
+  }
+  else if (initial && sm->sm_flags.in_dialog) {
+    /* These must be in-dialog */
+    sm = NULL;
+  }
+  else if (initial && sip->sip_to->a_tag) {
+    /* RFC 3261 section 12.2.2:
+       
+       If the UAS wishes to reject the request because it does not wish to
+       recreate the dialog, it MUST respond to the request with a 481
+       (Call/Transaction Does Not Exist) status code and pass that to the
+       server transaction.
+    */
+    if (method != sip_method_message || !NH_PGET(nh, win_messenger_enable))
+      sm = NULL;
+  }
 
-    if (!sip->sip_user_agent && NH_PGET(nh, user_agent))
-      sip_add_make(msg, sip, sip_user_agent_class, NH_PGET(nh, user_agent));
+  if (!sm) {
+    nta_incoming_treply(irq,
+                       status = 481, "Call Does Not Exist",
+                       SIPTAG_ALLOW(allow),
+                       SIPTAG_SUPPORTED(supported),
+                       SIPTAG_USER_AGENT_STR(user_agent),
+                       TAG_END());
+    return 481;
   }
-         
-  {
-    int add_contact = 0, use_dialog = 0, add_service_route, has_contact = 0;
-    tagi_t const *t;
 
-    for (t = ta_args(ta); t; t = t_next(t)) {
-      if (t->t_tag == siptag_contact ||
-         t->t_tag == siptag_contact_str)
-       has_contact = 1;
-      else if (t->t_tag == nutag_url)
-       url = (url_string_t const *)t->t_value;
-      else if (t->t_tag == nutag_method && method == sip_method_unknown)
-       name = (char const *)t->t_value;
-      else if (t->t_tag == nutag_use_dialog)
-       use_dialog = t->t_value != 0;
-      else if (t->t_tag == _nutag_add_contact)
-       add_contact = t->t_value != 0;
-    }
+  create_dialog = sm->sm_flags.create_dialog;
+  if (method == sip_method_message && NH_PGET(nh, win_messenger_enable))
+    create_dialog = 1;
+  sr = memset(sr0, 0, (sizeof sr0));
+
+  sr->sr_methods = sm;
+  sr->sr_method = method = sip->sip_request->rq_method;
+  sr->sr_add_contact = sm->sm_flags.add_contact;
+  sr->sr_target_refresh = sm->sm_flags.target_refresh;
 
-    if (!restart)
-      cr->cr_has_contact = has_contact;
+  sr->sr_owner = nh;
+  sr->sr_initial = initial;
 
-    if (has_contact) add_contact = 0;
+  sr->sr_irq = irq;
 
-    if (method == sip_method_register && url == NULL)
-      url = (url_string_t const *)NH_PGET(nh, registrar);
+  SR_STATUS1(sr, SIP_100_TRYING);
 
-    if (seq != -1) {
-      sip_cseq_t *cseq;
-     
-      assert(method != sip_method_unknown || name || sip->sip_request);
-      
-      if (method || name)
-       cseq = sip_cseq_create(msg_home(msg), seq, method, name);
-      else 
-       cseq = sip_cseq_create(msg_home(msg), seq, 
-                              sip->sip_request->rq_method, 
-                              sip->sip_request->rq_method_name);
+  sr->sr_request.msg = nta_incoming_getrequest(irq);
+  sr->sr_request.sip = sip;
+  assert(sr->sr_request.msg);
 
-      sip_header_insert(msg, sip, (sip_header_t *)cseq);
-    }
+  sr->sr_response.msg = nta_incoming_create_response(irq, 0, NULL);
+  sr->sr_response.sip = sip_object(sr->sr_response.msg);
 
-    /**
-     * Now, the target URI for the request needs to be determined.
-     *
-     * For initial requests, values from tags are used. If NUTAG_URL() is
-     * given, it is used as target URI. Otherwise, if SIPTAG_TO() is given,
-     * it is used as target URI. If neither is given, the complete request
-     * line already specified using SIPTAG_REQUEST() or SIPTAG_REQUEST_STR()
-     * is used. At this point, the target URI is stored in the request line,
-     * together with method name and protocol version ("SIP/2.0"). The
-     * initial dialog information is also created: @CallID, @CSeq headers
-     * are generated, if they do not exist, and a tag is added to the @From
-     * header.
-     */
-    if (!ds->ds_leg) {
-      nta_leg_t *leg = nua->nua_dhandle->nh_ds->ds_leg;
-
-      if ((ds->ds_remote_tag && ds->ds_remote_tag[0] && 
-          sip_to_tag(nh->nh_home, sip->sip_to, ds->ds_remote_tag) < 0)
-         || 
-         (sip->sip_from == NULL &&
-          sip_add_dup(msg, sip, (sip_header_t *)nua->nua_from) < 0))
-       goto error;
+  if (sr->sr_response.msg == NULL) {
+    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
+  else if (sm->sm_init && sm->sm_init(sr)) {
+    if (sr->sr_status < 200)    /* Init may have set response status */
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
+  /* Create handle if request does not fail */
+  else if (initial && sr->sr_status < 300) {
+    if ((nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog)))
+      sr->sr_owner = nh;
+    else
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
 
-      if (use_dialog) {
-       ds->ds_leg = nta_leg_tcreate(nua->nua_nta,
-                                    nua_stack_process_request, nh,
-                                    SIPTAG_CALL_ID(sip->sip_call_id),
-                                    SIPTAG_FROM(sip->sip_from),
-                                    SIPTAG_TO(sip->sip_to),
-                                    SIPTAG_CSEQ(sip->sip_cseq),
-                                    TAG_END());
-       if (!ds->ds_leg)
-         goto error;
-
-       leg = ds->ds_leg;
-
-       if (!sip->sip_from->a_tag &&
-           sip_from_tag(msg_home(msg), sip->sip_from,
-                        nta_leg_tag(ds->ds_leg, NULL)) < 0)
-         goto error;
-      }
+  if (sr->sr_status < 300 && sm->sm_preprocess && sm->sm_preprocess(sr)) {
+    if (sr->sr_status < 200)    /* Set response status if preprocess did not */
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
 
-      if (nta_msg_request_complete(msg, leg, method, name, url) < 0)
-       goto error;
+  if (sr->sr_status < 300) {
+    if (sr->sr_target_refresh)
+      nua_dialog_uas_route(nh, nh->nh_ds, sip, 1); /* Set route and tags */
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+  }
 
-      add_service_route = !restart;
-    }
-    else {
-      /**
-       * For in-dialog requests, the request URI is taken from the @Contact
-       * header received from the remote party during dialog establishment, 
-       * and the NUTAG_URL() is ignored.
-       */
-      if (ds->ds_route)
-       url = NULL;
-
-      /**Also, the @CallID and @CSeq headers and @From and @To tags are
-       * generated based on the dialog information and added to the request. 
-       * If the dialog has a route, it is added to the request, too.
-       */
-      if (nta_msg_request_complete(msg, ds->ds_leg, method, name, url) < 0)
-       goto error;
-      add_service_route = 0;
-    }
-    /***
-     * @MaxForwards header (with default value set by NTATAG_MAX_FORWARDS()) is
-     * also added now, if it does not exist.
-     */
-
-    /**
-     * Next, the stack generates a @Contact header for the request (unless
-     * the application already gave a @Contact header or it does not want to
-     * use @Contact and indicates that by including SIPTAG_CONTACT(NULL) or
-     * SIPTAG_CONTACT(SIP_NONE) in the tagged parameters.) If the
-     * application has registered the URI in @From header, the @Contact
-     * header used with registration is used. Otherwise, the @Contact header
-     * is generated from the local IP address and port number.
-     */
-    if (!add_contact ||
-       sip->sip_contact ||
-       nua_tagis_have_contact_tag(nh->nh_tags) ||
-       nua_tagis_have_contact_tag(ta_args(ta)))
-      add_contact = 0;
-
-    /**For the initial requests, @ServiceRoute set received from the registrar
-     * is also added to the request message.
-     */
-    if (add_contact || add_service_route) {
-      if (nua_registration_add_contact_to_request(nh, msg, sip, 
-                                                 add_contact, 
-                                                 add_service_route) < 0)
-       goto error;
-    }
+  if (sr->sr_status == 100 && method != sip_method_unknown &&
+      !sip_is_allowed(NH_PGET(sr->sr_owner, appl_method), method, name)) {
+    if (method == sip_method_refer || method == sip_method_subscribe)
+      SR_STATUS1(sr, SIP_202_ACCEPTED);
+    else
+      SR_STATUS1(sr, SIP_200_OK);
+  }
 
-    if (method != sip_method_ack) {
-      if (nh->nh_auth) {
-       nh_authorize(nh, ta_tags(ta));
+  /* INVITE server request is not finalized after 2XX response */
+  if (sr->sr_status < (method == sip_method_invite ? 300 : 200)) {
+    sr = su_alloc(nh->nh_home, (sizeof *sr));
 
-       if (method != sip_method_invite &&
-           method != sip_method_update &&
-           method != sip_method_prack &&
-           /* auc_authorize() removes existing authentication headers */
-           auc_authorize(&nh->nh_auth, msg, sip) < 0)
-         goto error;
-      }
+    if (sr) {
+      *sr = *sr0;
+
+      if ((sr->sr_next = nh->nh_ds->ds_sr))
+       *(sr->sr_prev = sr->sr_next->sr_prev) = sr,
+         sr->sr_next->sr_prev = &sr->sr_next;
+      else
+       *(sr->sr_prev = &nh->nh_ds->ds_sr) = sr;
     }
-    else /* ACK */ {
-      while (sip->sip_allow)
-       sip_header_remove(msg, sip, (sip_header_t*)sip->sip_allow);
-      while (sip->sip_priority)
-       sip_header_remove(msg, sip, (sip_header_t*)sip->sip_priority);
-      while (sip->sip_proxy_require)
-       sip_header_remove(msg, sip, (sip_header_t*)sip->sip_proxy_require);
-      while (sip->sip_require)
-       sip_header_remove(msg, sip, (sip_header_t*)sip->sip_require);
-      while (sip->sip_subject)
-       sip_header_remove(msg, sip, (sip_header_t*)sip->sip_subject);
-      while (sip->sip_supported)
-       sip_header_remove(msg, sip, (sip_header_t*)sip->sip_supported);
+    else {
+      sr = sr0;
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
     }
+  }
 
-    ta_end(ta);
-
-    if (!ds->ds_remote)
-      ds->ds_remote = sip_to_dup(nh->nh_home, sip->sip_to);
-    if (!ds->ds_local)
-      ds->ds_local = sip_from_dup(nh->nh_home, sip->sip_from);
-
-    if (copy) {
-      cr->cr_msg = msg;
-      msg = msg_copy(msg);
+  if (sr->sr_status <= 100) {
+    SR_STATUS1(sr, SIP_100_TRYING);
+    if (method == sip_method_invite || sip->sip_timestamp) {
+      nta_incoming_treply(irq, SIP_100_TRYING,
+                         SIPTAG_USER_AGENT_STR(user_agent),
+                         TAG_END());
     }
   }
+  else {
+    /* Note that this may change the sr->sr_status */
+    nua_server_respond(sr, NULL);
+  }
 
-  return msg;
+  if (nua_server_report(sr) == 0)
+    return 0;
 
- error:
-  ta_end(ta);
-  msg_destroy(msg);
-  return NULL;
-}
+  return 501;
+}               
 
-/* ---------------------------------------------------------------------- */
-nua_client_request_t *
-nua_client_request_pending(nua_client_request_t const *cr)
-{
-  for (;cr;cr = cr->cr_next)
-    if (cr->cr_orq)
-      return (nua_client_request_t *)cr;
+#undef nua_base_server_init
+#undef nua_base_server_preprocess
 
-  return NULL;
+int nua_base_server_init(nua_server_request_t *sr)
+{
+  return 0;
 }
 
-nua_client_request_t *
-nua_client_request_restarting(nua_client_request_t const *cr)
+int nua_base_server_preprocess(nua_server_request_t *sr)
 {
-  for (;cr;cr = cr->cr_next)
-    if (cr->cr_restart)
-      return (nua_client_request_t *)cr;
-
-  return NULL;
+  return 0;
 }
 
-nua_client_request_t *
-nua_client_request_by_orq(nua_client_request_t const *cr,
-                         nta_outgoing_t const *orq)
+void nua_server_request_destroy(nua_server_request_t *sr)
 {
-  for (;cr;cr = cr->cr_next)
-    if (cr->cr_orq == orq)
-      return (nua_client_request_t *)cr;
+  if (sr == NULL)
+    return;
 
-  return NULL;
+  if (sr->sr_irq)
+    nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL;
+
+  su_msg_destroy(sr->sr_signal);
+
+  if (sr->sr_request.msg)
+    msg_destroy(sr->sr_request.msg), sr->sr_request.msg = NULL;
+
+  if (sr->sr_response.msg)
+    msg_destroy(sr->sr_response.msg), sr->sr_response.msg = NULL;
+
+  if (sr->sr_prev) {
+    /* Allocated from heap */
+    if ((*sr->sr_prev = sr->sr_next))
+      sr->sr_next->sr_prev = sr->sr_prev;
+    su_free(sr->sr_owner->nh_home, sr);
+  }
 }
 
-void nua_creq_deinit(nua_client_request_t *cr, nta_outgoing_t *orq)
+/** Respond to a request with given status. 
+ *
+ * When nua protocol engine receives an incoming SIP request, it can either
+ * respond to the request automatically or let it up to application to
+ * respond to the request. The automatic response is returned to the client
+ * if the request fails syntax check, or the method, SIP extension or
+ * content negotiation fails.
+ *
+ * When responding to an incoming INVITE request, the nua_respond() can be
+ * called without NUTAG_WITH() (or NUTAG_WITH_THIS() or
+ * NUTAG_WITH_SAVED()). Otherwise, NUTAG_WITH() will contain an indication
+ * of the request being responded.
+ *
+ * In order to simplify the simple applications, most requests are responded
+ * automatically. The BYE and CANCEL requests are always responded by the
+ * stack. Likewise, the NOTIFY requests associated with an event
+ * subscription are responded by the stack.
+ *
+ * The application can add methods that it likes to handle by itself with
+ * NUTAG_APPL_METHOD(). The default set of NUTAG_APPL_METHOD() includes
+ * INVITE, PUBLISH, REGISTER and SUBSCRIBE. Note that unless the method is
+ * also included in the set of allowed methods with NUTAG_ALLOW(), the stack
+ * will respond to the incoming methods with <i>405 Not Allowed</i>.
+ *
+ * Note that certain methods are rejected outside a SIP session (created
+ * with INVITE transaction). They include BYE, UPDATE, PRACK and INFO. Also
+ * the auxiliary methods ACK and CANCEL are rejected by stack if there is no
+ * ongoing INVITE transaction corresponding to them.
+ *
+ * @param nh              Pointer to operation handle
+ * @param status          SIP response status (see RFCs of SIP)
+ * @param phrase          free text (default response phrase used if NULL)
+ * @param tag, value, ... List of tagged parameters
+ *
+ * @return 
+ *    nothing
+ *
+ * @par Related Tags:
+ *    NUTAG_WITH(), NUTAG_WITH_THIS(), NUTAG_WITH_SAVED() \n
+ *    NUTAG_EARLY_ANSWER() \n
+ *    SOATAG_ADDRESS() \n
+ *    SOATAG_AF() \n
+ *    SOATAG_HOLD() \n
+ *    Tags in <sip_tag.h>.
+ *
+ * @par Events:
+ *    #nua_i_state \n
+ *    #nua_i_media_error \n
+ *    #nua_i_error \n
+ *    #nua_i_active \n
+ *    #nua_i_terminated \n
+ *
+ * @sa #nua_i_invite, #nua_i_register, #nua_i_subscribe, #nua_i_publish
+ */
+void
+nua_stack_respond(nua_t *nua, nua_handle_t *nh,
+                 int status, char const *phrase, tagi_t const *tags)
 {
-  if (orq == NULL || orq == cr->cr_orq) {
-    cr->cr_retry_count = 0;
-    cr->cr_offer_sent = cr->cr_answer_recv = 0;
+  nua_server_request_t *sr;
+  tagi_t const *t;
+  msg_t const *request = NULL;
 
-    if (cr->cr_msg)
-      msg_destroy(cr->cr_msg);
-    cr->cr_msg = NULL;
+  t = tl_find_last(tags, nutag_with);
 
-    if (cr->cr_orq)
-      nta_outgoing_destroy(cr->cr_orq);
-    cr->cr_orq = NULL;
+  if (t)
+    request = (msg_t const *)t->t_value;
+
+  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next) {
+    if (request && sr->sr_request.msg == request)
+      break;
+    /* nua_respond() to INVITE can be used without NUTAG_WITH() */
+    if (!t && sr->sr_method == sip_method_invite)
+      break;
+  }
+
+  if (sr == NULL) {
+    nua_stack_event(nua, nh, NULL, nua_i_error,
+                   500, "Responding to a Non-Existing Request", NULL);
+    return;
+  }
+  else if (!nua_server_request_is_pending(sr)) {
+    nua_stack_event(nua, nh, NULL, nua_i_error,
+                   500, "Already Sent Final Response", NULL);
+    return;
+  }
+  else if (sr->sr_100rel && !sr->sr_pracked && 200 <= status && status < 300) {
+    /* Save signal until we have received PRACK */
+    if (tags && nua_stack_set_params(nua, nh, nua_i_none, tags) < 0) {
+      sr->sr_application = status;
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    }
+    else {
+      su_msg_save(sr->sr_signal, nh->nh_nua->nua_signal);
+      return;
+    }
   }
   else {
-    nta_outgoing_destroy(orq);
+    sr->sr_application = status;
+    if (tags && nua_stack_set_params(nua, nh, nua_i_none, tags) < 0)
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    else
+      sr->sr_status = status, sr->sr_phrase = phrase;
   }
-}
 
+  nua_server_params(sr, tags);
+  nua_server_respond(sr, tags);
+  nua_server_report(sr);
+}
 
-/**@internal
- * Get remote contact header for @a irq */
-static inline
-sip_contact_t const *incoming_contact(nta_incoming_t *irq)
+int nua_server_params(nua_server_request_t *sr, tagi_t const *tags)
 {
-  sip_contact_t const *retval = NULL;
-  msg_t *request;
-  sip_t *sip;
+  if (sr->sr_methods->sm_params)
+    return sr->sr_methods->sm_params(sr, tags);
+  return 0;
+}
 
-  request = nta_incoming_getrequest(irq);
-  sip = sip_object(request);
-  if (sip)
-    retval = sip->sip_contact;
-  msg_destroy(request);
+#undef nua_base_server_params
 
-  return retval;
+int nua_base_server_params(nua_server_request_t *sr, tagi_t const *tags) 
+{
+  return 0;
 }
 
-/**@internal
- * Create a response message.
+/** Return the response to the client.
+ *
+ * @retval 0 when successfully sent
+ * @retval -1 upon an error
  */
-msg_t *nh_make_response(nua_t *nua,
-                       nua_handle_t *nh,
-                       nta_incoming_t *irq,
-                       int status, char const *phrase,
+int nua_server_trespond(nua_server_request_t *sr,
                        tag_type_t tag, tag_value_t value, ...)
 {
+  int retval;
   ta_list ta;
-  msg_t *msg = nta_msg_create(nua->nua_nta, 0);
-  sip_t *sip = sip_object(msg);
-  msg_t *retval = NULL;
-  tagi_t const *t;
-
   ta_start(ta, tag, value);
+  retval = nua_server_respond(sr, ta_args(ta));
+  ta_end(ta);
+  return retval;
+}
+
+/** Return the response to the client.
+ *
+ * @retval 0 when successfully sent
+ * @retval -1 upon an error
+ */
+int nua_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  sip_method_t method = sr->sr_method;
+  struct { msg_t *msg; sip_t *sip; } next = { NULL, NULL };
+  tagi_t next_tags[2] = {{ SIPTAG_END() }, { TAG_NEXT(tags) }};
+  int retval;
+
+  msg_t *msg = sr->sr_response.msg;
+  sip_t *sip = sr->sr_response.sip;
+  sip_contact_t *m = sr->sr_request.sip->sip_contact;
+
+  if (sr->sr_response.msg == NULL) {
+    assert(sr->sr_status == 500);
+    goto internal_error;
+  }
 
-  if (!msg)
-    /* retval is NULL */;
-  else if (nta_msg_response_complete(msg, irq, status, phrase) < 0)
-    msg_destroy(msg);
-  else if (sip_add_tl(msg, sip, ta_tags(ta)) < 0)
-    msg_destroy(msg);
-  else if (sip_complete_message(msg) < 0)
-    msg_destroy(msg);
+  if (sr->sr_status < 200) {
+    next.msg = nta_incoming_create_response(sr->sr_irq, 0, NULL);
+    next.sip = sip_object(next.msg);
+    if (next.sip == NULL)
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
+
+  if (nta_incoming_complete_response(sr->sr_irq, msg,
+                                    sr->sr_status,
+                                    sr->sr_phrase,
+                                    TAG_NEXT(tags)) < 0)
+    ;
   else if (!sip->sip_supported && NH_PGET(nh, supported) &&
           sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, supported)) < 0)
-    msg_destroy(msg);
+    ;
   else if (!sip->sip_user_agent && NH_PGET(nh, user_agent) &&
           sip_add_make(msg, sip, sip_user_agent_class, 
                        NH_PGET(nh, user_agent)) < 0)
-    msg_destroy(msg);
+    ;
   else if (!sip->sip_organization && NH_PGET(nh, organization) &&
-          sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, organization)) < 0)
-    msg_destroy(msg);
+          sip_add_dup(msg, sip, (void *)NH_PGET(nh, organization)) < 0)
+    ;
   else if (!sip->sip_allow && NH_PGET(nh, allow) &&
-          sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow)) < 0)
-    msg_destroy(msg);
+          sip_add_dup(msg, sip, (void *)NH_PGET(nh, allow)) < 0)
+    ;
   else if (!sip->sip_allow_events && 
-          (sip->sip_cseq && 
-           (sip->sip_cseq->cs_method == sip_method_publish ||
-            sip->sip_cseq->cs_method == sip_method_subscribe)) &&
+          (method == sip_method_publish || method == sip_method_subscribe) &&
           NH_PGET(nh, allow_events) &&
-          sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow_events)) < 0)
-    msg_destroy(msg);
-  else if (!sip->sip_contact &&
-          (t = tl_find(ta_args(ta), _nutag_add_contact)) &&
-          t->t_value && 
-          nua_registration_add_contact_to_response(nh, msg, sip, NULL, 
-                                                   incoming_contact(irq)) < 0)
-    msg_destroy(msg);
-  else
-    retval = msg;
+          sip_add_dup(msg, sip, (void *)NH_PGET(nh, allow_events)) < 0)
+    ;
+  else if (!sip->sip_contact && sr->sr_status < 300 && sr->sr_add_contact &&
+          nua_registration_add_contact_to_response(nh, msg, sip, NULL, m) < 0)
+    ;
+  else {
+    int term;
+    
+    term = sip_response_terminates_dialog(sr->sr_status, sr->sr_method, NULL);
 
-  ta_end(ta);
+    sr->sr_terminating = (term < 0) ? -1 : (term > 0 || sr->sr_terminating);
 
-  return retval;
-}
+    retval = sr->sr_methods->sm_respond(sr, next_tags);
 
+    if (sr->sr_status < 200) 
+      sr->sr_response.msg = next.msg, sr->sr_response.sip = next.sip;
+    else if (next.msg)
+      msg_destroy(next.msg);
 
-/* ======================================================================== */
-/* Generic processing */
+    assert(sr->sr_status >= 200 || sr->sr_response.msg);
 
-int nua_stack_process_unknown(nua_t *nua,
-                             nua_handle_t *nh,
-                             nta_incoming_t *irq,
-                             sip_t const *sip)
-{
-  return 501;
-}
+    return retval;
+  }
 
-/**@internal
- * Relay response message to the application.
- *
- * If handle has already been marked as destroyed by nua_handle_destroy(),
- * release the handle with nh_destroy().
- */
-int nua_stack_process_response(nua_handle_t *nh,
-                              nua_client_request_t *cr,
-                              nta_outgoing_t *orq,
-                              sip_t const *sip,
-                              tag_type_t tag, tag_value_t value, ...)
-{
-  msg_t *msg = nta_outgoing_getresponse(orq);
-  int status = sip->sip_status->st_status;
-  char const *phrase = sip->sip_status->st_phrase;
-  ta_list ta;
-  int final;
+  if (next.msg)
+    msg_destroy(next.msg);
 
-  if (status >= 200 && status < 300)
-    nh_challenge(nh, sip);  /* Collect nextnonce */
+  SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
 
-  if (nta_outgoing_method(orq) == sip_method_invite)
-    final = status >= 300;
-  else
-    final = status >= 200;
+  msg_destroy(msg);
 
-  if (final && cr) {
-    nua_creq_deinit(cr, orq);
+ internal_error:
+  sr->sr_response.msg = NULL, sr->sr_response.sip = NULL;
+  nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
 
-    if (cr->cr_usage && nh->nh_ds->ds_cr == cr) {
-      if ((status >= 300 && !cr->cr_usage->du_ready) ||
-         cr->cr_usage->du_terminating)
-       nua_dialog_usage_remove(nh, nh->nh_ds, cr->cr_usage);
-    }
+  return 0;
+}
 
-    cr->cr_usage = NULL;
+/** Return the response to the client.
+ *
+ * @retval 0 when successfully sent
+ * @retval -1 upon an error
+ */
+int nua_base_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+{
+  msg_t *response = sr->sr_response.msg;
+  sip_t *sip = sr->sr_response.sip;
+
+  sr->sr_response.msg = NULL, sr->sr_response.sip = NULL;
+
+  if (sr->sr_status != sip->sip_status->st_status) {
+    msg_header_remove(response, (msg_pub_t *)sip,
+                     (msg_header_t *)sip->sip_status);
+    nta_incoming_complete_response(sr->sr_irq, response,
+                                  sr->sr_status,
+                                  sr->sr_phrase,    
+                                  TAG_END());
   }
 
-  ta_start(ta, tag, value);
-
-  nua_stack_event(nh->nh_nua, nh, msg, cr->cr_event, status, phrase,
-                 ta_tags(ta));
-
-  if (final)
-    cr->cr_event = nua_i_error;
-
-  ta_end(ta);
+  if (sr->sr_status != sip->sip_status->st_status) {
+    msg_destroy(response);
+    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
+    return 0;
+  }
 
-  return 0;
+  return nta_incoming_mreply(sr->sr_irq, response);
 }
 
-static inline
-int can_redirect(sip_contact_t const *m, sip_method_t method)
+int nua_server_report(nua_server_request_t *sr)
 {
-  if (m && m->m_url->url_host) {
-    enum url_type_e type = m->m_url->url_type;
-    return
-      type == url_sip ||
-      type == url_sips ||
-      (type == url_tel &&
-       (method == sip_method_invite || method == sip_method_message)) ||
-      (type == url_im && method == sip_method_message) ||
-      (type == url_pres && method == sip_method_subscribe);
-  }
-  return 0;
+  if (sr)
+    return sr->sr_methods->sm_report(sr, NULL);
+  else
+    return 1;
 }
 
-int nua_creq_restart_with(nua_handle_t *nh,
-                         nua_client_request_t *cr,
-                         nta_outgoing_t *orq,
-                         int status, char const *phrase,
-                         nua_creq_restart_f *f,
-                         TAG_LIST)
+int nua_base_server_treport(nua_server_request_t *sr,
+                           tag_type_t tag, tag_value_t value,
+                           ...)
 {
+  int retval;
   ta_list ta;
-  msg_t *msg = nta_outgoing_getresponse(orq);
+  ta_start(ta, tag, value);
+  retval = nua_base_server_report(sr, ta_args(ta));
+  ta_end(ta);
+  return retval;
+}
+
+/**Report request event to the application.
+ *
+ * @retval 0 request lives
+ * @retval 1 request was destroyed
+ * @retval 2 request and its usage was destroyed
+ * @retval 3 request, all usages and dialog was destroyed
+ * @retval 4 request, all usages, dialog, and handle was destroyed
+ */
+int nua_base_server_report(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_t *nua = nh->nh_nua;
+  nua_dialog_usage_t *usage = sr->sr_usage;
+  int initial = sr->sr_initial;
+  int status = sr->sr_status;
+  char const *phrase = sr->sr_phrase;
 
-  nua_stack_event(nh->nh_nua, nh, msg, cr->cr_event, status, phrase,
-                 TAG_END());
+  int terminated;
+  int handle_can_be_terminated = initial && !sr->sr_event;
 
-  nta_outgoing_destroy(orq);
+  assert(nh);
 
-  if (f) {
-    ta_start(ta, tag, value);
-    f(nh, ta_args(ta));
-    ta_end(ta);
+  if (sr->sr_application) {
+    /* There was an error sending response */
+    if (sr->sr_application != sr->sr_status)
+      nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, tags);
+    sr->sr_application = 0;
+  }
+  else if (status < 300 && !sr->sr_event) {
+    msg_t *msg = msg_ref_create(sr->sr_request.msg);
+    nua_event_t e = sr->sr_methods->sm_event;
+    sr->sr_event = 1;
+    nua_stack_event(nua, nh, msg, e, status, phrase, tags);
   }
 
-  return 1;
-}
+  if (status < 200)
+    return 0;                  /* sr lives on until final response is sent */
 
+  if (sr->sr_method == sip_method_invite && status < 300)
+    return 0;                  /* INVITE lives on until ACK is received */
 
-/** @internal Save operation until it can be restarted */
-int nua_creq_save_restart(nua_handle_t *nh,
-                         nua_client_request_t *cr,
-                         nta_outgoing_t *orq,
-                         int status, char const *phrase,
-                         nua_creq_restart_f *restart_function)
-{
-  nua_dialog_usage_t *du = cr->cr_usage;
-  msg_t *msg = nta_outgoing_getresponse(orq);
+  if (initial && 300 <= status)
+    terminated = 1;
+  else if (sr->sr_terminating && status < 300)
+    terminated = 1;
+  else
+    terminated = sip_response_terminates_dialog(status, sr->sr_method, NULL);
 
-  nua_stack_event(nh->nh_nua, nh, msg, cr->cr_event,
-                 status, phrase, 
-                 TAG_END());
-  nta_outgoing_destroy(orq);
+  nua_server_request_destroy(sr);
 
-  if (du)
-    du->du_refresh = 0;
+  if (!terminated)
+    return 1;
 
-  cr->cr_restart = restart_function;
-  return 1;
+  if (usage)
+    nua_dialog_usage_remove(nh, nh->nh_ds, usage);
+
+  if (!initial) {
+    if (terminated > 0)
+      return 2;
+
+    /* Remove all usages of the dialog */
+    nua_dialog_deinit(nh, nh->nh_ds);
+
+    return 3;
+  }
+  else if (!handle_can_be_terminated) {
+    return 3;
+  }
+  else {
+    if (nh != nh->nh_nua->nua_dhandle)
+      nh_destroy(nh->nh_nua, nh);
+
+    return 4;
+  }
 }
 
+/* ---------------------------------------------------------------------- */
 
-/**@internal
- * Check response, return true if we can restart the request.
+/** @class nua_client_request
+ *
+ * Each handle has a queue of client-side requests; if a request is pending,
+ * a new request from API is added to the queue. After the request is
+ * complete, it is removed from the queue and destroyed by the default. The
+ * exception is the client requests bound to a dialog usage: they are saved
+ * and re-used when the dialog usage is refreshed (and sometimes when the
+ * usage is terminated).
+ * 
+ * The client request is subclassed and its behaviour modified using virtual
+ * function table in #nua_client_methods_t.
+ * 
+ * The first three methods (crm_template(), crm_init(), crm_send()) are
+ * called when the request is sent first time.
+ * 
+ * The crm_template() is called if a template request message is needed (for
+ * example, in case of unregister, unsubscribe and unpublish, the template
+ * message is taken from the request establishing the usage).
+ * 
+ * The crm_init() is called when the template message and dialog leg has
+ * been created and populated by the tags procided by the application. Its
+ * parameters msg and sip are pointer to the template request message that
+ * is saved in the nua_client_request::cr_msg field.
+ *
+ * The crm_send() is called with a copy of the template message that has
+ * been populated with all the fields included in the request, including
+ * @CSeq and @MaxForwards. The crm_send() function, such as
+ * nua_publish_client_request(), usually calls nua_base_client_trequest() that
+ * then creates the nta-level transaction.
+ *
+ * The response to the request is processed by crm_check_restart(), which
+ * modifies and restarts the request when needed (e.g., when negotiating
+ * expiration time). After the request has been suitably modified, e.g., the
+ * expiration time has been increased, the restart function calls
+ * nua_client_restart(), which restarts the request and relays the
+ * intermediate response to the application with nua_client_restart() and
+ * crm_report().
+ *
+ * The final responses are processed by crm_recv() and and preliminary ones
+ * by crm_preliminary(). Both functions call nua_base_client_response() after
+ * method-specific processing.
+ *
+ * The nua_base_client_response() relays the response to the application with
+ * nua_client_restart() and crm_report().
  *
+ * @par Terminating Dialog Usages and Dialogs
+ *
+ * The response can be marked as terminating with nua_client_terminating(). 
+ * When a terminating request completes the dialog usage is removed and the
+ * dialog is destroyed (unless there is an another active usage).
+ */
+static int nua_client_request_try(nua_client_request_t *cr);
+static int nua_client_request_sendmsg(nua_client_request_t *cr,
+                                     msg_t *msg, sip_t *sip);
+
+/**Create a client request.
+ *
+ * @retval 0 if request is pending
+ * @retval > 0 if error event has been sent
+ * @retval < 0 upon an error
  */
-int nua_creq_check_restart(nua_handle_t *nh,
-                          nua_client_request_t *cr,
-                          nta_outgoing_t *orq,
-                          sip_t const *sip,
-                          nua_creq_restart_f *restart_function)
+int nua_client_create(nua_handle_t *nh, 
+                     int event,
+                     nua_client_methods_t const *methods,
+                     tagi_t const * const tags)
 {
-  int status = sip->sip_status->st_status;
-  sip_method_t method = nta_outgoing_method(orq);
+  su_home_t *home = nh->nh_home;
+  nua_client_request_t *cr;
+  sip_method_t method;
+  char const *name;
+
+  method = methods->crm_method, name = methods->crm_method_name;
+  if (!name) {
+    tagi_t const *t = tl_find_last(tags, nutag_method);
+    if (t)
+      name = (char const *)t->t_value;
+  }
 
-  nua_dialog_usage_t *du = cr->cr_usage;
+  cr = su_zalloc(home, sizeof *cr + methods->crm_extra);
+  if (!cr) {
+    return nua_stack_event(nh->nh_nua, nh, 
+                          NULL,
+                          event,
+                          NUA_INTERNAL_ERROR,
+                          NULL);
+  }
+
+  cr->cr_owner = nh;
+  cr->cr_methods = methods;
+  cr->cr_event = event;
+  cr->cr_method = method;
+  cr->cr_method_name = name;
+  cr->cr_contactize = methods->crm_flags.target_refresh;
+  cr->cr_dialog = methods->crm_flags.create_dialog;
+  cr->cr_auto = 1;
+
+  if (su_msg_is_non_null(nh->nh_nua->nua_signal)) {
+    nua_event_data_t const *e = su_msg_data(nh->nh_nua->nua_signal);
+
+    if (tags == e->e_tags && event == e->e_event) {
+      cr->cr_auto = 0;
+      if (tags) {
+       su_msg_save(cr->cr_signal, nh->nh_nua->nua_signal);
+       cr->cr_tags = tags;
+      }
+    }
+  }
 
-  assert(restart_function);
+  if (tags && cr->cr_tags == NULL)
+    cr->cr_tags = tl_tlist(nh->nh_home, TAG_NEXT(tags));
 
-  if (orq != cr->cr_orq)
+  if (nua_client_request_queue(cr))
     return 0;
 
-  cr->cr_orq = NULL;
-  cr->cr_restart = NULL;
+  return nua_client_init_request(cr);
+}
 
-  if (cr->cr_msg == NULL || status < 200)
-    ;
-  else if (++cr->cr_retry_count > NH_PGET(nh, retry_count))
-    ;
-  else if (status == 302) {
-    if (can_redirect(sip->sip_contact, method)) {
-      return
-       nua_creq_restart_with(nh, cr, orq, 100, "Redirected",
-                             restart_function,
-                             NUTAG_URL(sip->sip_contact->m_url),
-                             TAG_END());
-    }
-  }
-  else if (status == 423) {
-    sip_t *req = sip_object(cr->cr_msg);
-    unsigned my_expires = 0;
+int nua_client_tcreate(nua_handle_t *nh, 
+                      int event,
+                      nua_client_methods_t const *methods,
+                      tag_type_t tag, tag_value_t value, ...)
+{
+  int retval;
+  ta_list ta;
+  ta_start(ta, tag, value);
+  retval = nua_client_create(nh, event, methods, ta_args(ta));
+  ta_end(ta);
+  return retval;
+}
 
-    if (req->sip_expires)
-      my_expires = req->sip_expires->ex_delta;
+int nua_client_request_queue(nua_client_request_t *cr)
+{
+  int queued = 0;
+  nua_client_request_t **queue = &cr->cr_owner->nh_ds->ds_cr;
 
-    if (sip->sip_min_expires &&
-       sip->sip_min_expires->me_delta > my_expires) {
-      sip_expires_t ex[1];
-      sip_expires_init(ex);
-      ex->ex_delta = sip->sip_min_expires->me_delta;
+  assert(cr->cr_prev == NULL && cr->cr_next == NULL);
+
+  cr->cr_status = 0;
 
-      return
-       nua_creq_restart_with(nh, cr, orq,
-                             100, "Re-Negotiating Expiration",
-                             restart_function, 
-                             SIPTAG_EXPIRES(ex),
-                             TAG_END());
+  if (cr->cr_method != sip_method_invite &&
+      cr->cr_method != sip_method_cancel) {
+    while (*queue) {
+      if ((*queue)->cr_method == sip_method_invite ||
+         (*queue)->cr_method == sip_method_cancel)
+       break;
+      queue = &(*queue)->cr_next;
+      queued = 1;
     }
   }
-  else if (method != sip_method_ack && method != sip_method_cancel &&
-          ((status == 401 && sip->sip_www_authenticate) ||
-           (status == 407 && sip->sip_proxy_authenticate)) &&
-          nh_challenge(nh, sip) > 0) {
-    msg_t *request = nta_outgoing_getrequest(orq);
-    sip_t *rsip = sip_object(request);
-    int done;
-
-    /* XXX - check for instant restart */
-    done = auc_authorization(&nh->nh_auth, cr->cr_msg, (msg_pub_t*)NULL,
-                            rsip->sip_request->rq_method_name,
-                            rsip->sip_request->rq_url,
-                            rsip->sip_payload);
-
-    msg_destroy(request);
-
-    if (done > 0) {
-      return
-       nua_creq_restart_with(nh, cr, orq,
-                             100, "Request Authorized by Cache",
-                             restart_function, TAG_END());
-    }
-    else if (done == 0) {
-      /* Operation waits for application to call nua_authenticate() */
-      return nua_creq_save_restart(nh, cr, orq, 
-                                  status, sip->sip_status->st_phrase, 
-                                  restart_function);
-    }
-    else {
-      SU_DEBUG_5(("nua(%p): auc_authorization failed\n", nh));
+  else {
+    while (*queue) {
+      queue = &(*queue)->cr_next;
+      if (cr->cr_method == sip_method_invite)
+       queued = 1;
     }
   }
 
-  /* This was final response that cannot be restarted. */
-  cr->cr_orq = orq;
-
-  if (du)
-    du->du_refresh = 0;
-  cr->cr_retry_count = 0;
+  if ((cr->cr_next = *queue))
+    cr->cr_next->cr_prev = &cr->cr_next;
 
-  if (cr->cr_msg)
-    msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
+  cr->cr_prev = queue, *queue = cr;
 
-  return 0;
+  return queued;
 }
 
-/** @internal Restart a request */
-int nua_creq_restart(nua_handle_t *nh,
-                    nua_client_request_t *cr,
-                    nta_response_f *cb,
-                    tagi_t *tags)
+nua_client_request_t *nua_client_request_remove(nua_client_request_t *cr)
 {
-  msg_t *msg;
+  if (cr->cr_prev)
+    if ((*cr->cr_prev = cr->cr_next))
+      cr->cr_next->cr_prev = cr->cr_prev;
+  cr->cr_prev = NULL, cr->cr_next = NULL;
+  return cr;
+}
 
-  cr->cr_restart = NULL;
+void nua_client_request_destroy(nua_client_request_t *cr)
+{
+  nua_handle_t *nh;
+  
+  if (cr == NULL)
+    return;
 
-  if (!cr->cr_msg)
-    return 0;
+  if (cr->cr_methods->crm_deinit)
+    cr->cr_methods->crm_deinit(cr);
 
-  msg = nua_creq_msg(nh->nh_nua, nh, cr, 1, SIP_METHOD_UNKNOWN,
-                    TAG_NEXT(tags));
+  nh = cr->cr_owner;
 
-  cr->cr_orq = nta_outgoing_mcreate(nh->nh_nua->nua_nta, cb, nh, NULL, msg,
-                                   SIPTAG_END(), TAG_NEXT(tags));
+  su_msg_destroy(cr->cr_signal);
 
-  if (!cr->cr_orq) {
-    msg_destroy(msg);
+  nua_client_request_remove(cr);
+  nua_client_bind(cr, NULL);
+  
+  if (cr->cr_msg)
+    msg_destroy(cr->cr_msg);
+  cr->cr_msg = NULL, cr->cr_sip = NULL;
+
+  if (cr->cr_orq)
+    nta_outgoing_destroy(cr->cr_orq);
+
+  cr->cr_orq = NULL;
+
+  if (cr->cr_target)
+    su_free(nh->nh_home, cr->cr_target);
+
+  su_free(nh->nh_home, cr);
+}
+
+/** Bind client request to a dialog usage */ 
+int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du)
+{
+  assert(cr);
+  if (cr == NULL)
+    return -1;
+
+  if (du == NULL) {
+    if (cr->cr_usage && cr->cr_usage->du_cr == cr)
+      cr->cr_usage->du_cr = NULL;
+    cr->cr_usage = NULL;
     return 0;
   }
 
-  return 1;
-}
+  if (du->du_cr && cr != du->du_cr) {
+    assert(!nua_client_is_queued(du->du_cr));
+    if (nua_client_is_queued(du->du_cr))
+      return -1;
+    if (nua_client_is_reporting(du->du_cr)) {
+      du->du_cr->cr_usage = NULL;
+      du->du_cr = NULL;
+    }
+    else
+      nua_client_request_destroy(du->du_cr);
+  }
 
-/* ======================================================================== */
-/* Authentication */
+  du->du_cr = cr, cr->cr_usage = du;
 
-/** @NUA_EVENT nua_r_authenticate
+  return 0;
+}
+
+/**Initialize client request for sending.
  *
- * Response to nua_authenticate(). Under normal operation, this event is
- * never sent but rather the unauthenticated operation is completed. 
- * However, if there is no operation to authentication or if there is an
- * authentication error the #nua_r_authenticate event is sent to the
- * application with the status code as follows:
- * - <i>202 No operation to restart</i>:\n
- *   The authenticator associated with the handle was updated, but there was
- *   no operation to retry with the new credentials.
- * - <i>900 Cannot add credentials</i>:\n
- *   There was internal problem updating authenticator.
- * - <i>904 No matching challenge</i>:\n
- *   There was no challenge matching with the credentials provided by
- *   nua_authenticate(), e.g., their realm did not match with the one 
- *   received with the challenge.
- * 
- * @param status status code from authentication 
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle authenticated
- * @param hmagic application context associated with the handle
- * @param sip    NULL
- * @param tags   empty
- * 
- * @sa nua_terminate(), nua_handle_destroy()
+ * This function is called only first time the request is sent.
  *
- * @END_NUA_EVENT
+ * @retval 0 if request is pending
+ * @retval >=1 if error event has been sent
  */
-
-void
-nua_stack_authenticate(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-                      tagi_t const *tags)
+int nua_client_init_request(nua_client_request_t *cr)
 {
-  int status = nh_authorize(nh, TAG_NEXT(tags));
+  nua_handle_t *nh = cr->cr_owner;
+  nua_t *nua = nh->nh_nua;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  msg_t *msg = NULL;
+  sip_t *sip;
+  url_string_t const *url = NULL;
+  tagi_t const *t;
+  int has_contact = 0;
+  int error = 0;
+  
+  if (!cr->cr_method_name)
+    return nua_client_return(cr, NUA_INTERNAL_ERROR, NULL);
 
-  if (status > 0) {
-    nua_client_request_t *cr;
-    nua_creq_restart_f *restart = NULL;
+  if (cr->cr_msg)
+    return nua_client_request_try(cr);
 
-    cr = nua_client_request_restarting(nh->nh_ds->ds_cr);
+  cr->cr_answer_recv = 0, cr->cr_offer_sent = 0;
+  cr->cr_offer_recv = 0, cr->cr_answer_sent = 0;
+  cr->cr_terminated = 0, cr->cr_graceful = 0;
 
-    if (cr) 
-      restart = cr->cr_restart, cr->cr_restart = NULL;
+  nua_stack_init_handle(nua, nh, TAG_NEXT(cr->cr_tags));
 
-    if (restart) {
-      /* nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END()); */
-      restart(nh, (tagi_t *)tags);     /* Restart operation */
+  if (cr->cr_method == sip_method_cancel) {
+    if (cr->cr_methods->crm_init) {
+      error = cr->cr_methods->crm_init(cr, NULL, NULL, cr->cr_tags);
+      if (error)
+       return error;
     }
-    else {
-      nua_stack_event(nua, nh, NULL, e, 
-                     202, "No operation to restart",
-                     TAG_END());
+
+    if (cr->cr_methods->crm_send)
+      return cr->cr_methods->crm_send(cr, NULL, NULL, cr->cr_tags);
+    else
+      return nua_base_client_request(cr, NULL, NULL, cr->cr_tags);
+  }
+
+  if (!cr->cr_methods->crm_template ||
+      !cr->cr_methods->crm_template(cr, &msg, cr->cr_tags))
+    msg = nta_msg_create(nua->nua_nta, 0);
+
+  sip = sip_object(msg);
+  if (!sip)
+    return nua_client_return(cr, NUA_INTERNAL_ERROR, msg);
+
+  /**@par Populating SIP Request Message with Tagged Arguments
+   *
+   * The tagged arguments can be used to pass values for any SIP headers
+   * to the stack. When the INVITE message (or any other SIP message) is
+   * created, the tagged values saved with nua_handle() are used first,
+   * next the tagged values given with the operation (nua_invite()) are
+   * added.
+   *
+   * When multiple tags for the same header are specified, the behaviour
+   * depends on the header type. If only a single header field can be
+   * included in a SIP message, the latest non-NULL value is used, e.g.,
+   * @Subject. However, if the SIP header can consist of multiple lines or
+   * header fields separated by comma, e.g., @Accept, all the tagged
+   * values are concatenated.
+   *
+   * However, if a tag value is #SIP_NONE (-1 casted as a void pointer),
+   * the values from previous tags are ignored.
+   */
+  if (nh->nh_tags) {
+    for (t = nh->nh_tags; t; t = t_next(t)) {
+      if (t->t_tag == siptag_contact ||
+         t->t_tag == siptag_contact_str)
+       has_contact = 1;
+      else if (t->t_tag == nutag_url)
+       url = (url_string_t const *)t->t_value;
     }
+
+    t = nh->nh_tags, sip_add_tagis(msg, sip, &t);
   }
-  else if (status < 0) {
-    nua_stack_event(nua, nh, NULL, e, 900, "Cannot add credentials", TAG_END());
+
+  for (t = cr->cr_tags; t; t = t_next(t)) {
+    if (t->t_tag == siptag_contact ||
+       t->t_tag == siptag_contact_str)
+      has_contact = 1;
+    else if (t->t_tag == nutag_url)
+      url = (url_string_t const *)t->t_value;
+    else if (t->t_tag == nutag_dialog) {
+      cr->cr_dialog = t->t_value > 1;
+      cr->cr_contactize = t->t_value >= 1;
+    }
+    else if (t->t_tag == nutag_auth && t->t_value) {
+      /* XXX ignoring errors */
+      if (nh->nh_auth)
+       auc_credentials(&nh->nh_auth, nh->nh_home, (char *)t->t_value);
+    }
+  }
+
+  if (cr->cr_method == sip_method_register && url == NULL)
+    url = (url_string_t const *)NH_PGET(nh, registrar);
+  
+  if ((t = cr->cr_tags)) {
+    if (sip_add_tagis(msg, sip, &t) < 0)
+      goto error;
+  }
+
+  /**
+   * Now, the target URI for the request needs to be determined.
+   *
+   * For initial requests, values from tags are used. If NUTAG_URL() is
+   * given, it is used as target URI. Otherwise, if SIPTAG_TO() is given,
+   * it is used as target URI. If neither is given, the complete request
+   * line already specified using SIPTAG_REQUEST() or SIPTAG_REQUEST_STR()
+   * is used. At this point, the target URI is stored in the request line,
+   * together with method name and protocol version ("SIP/2.0"). The
+   * initial dialog information is also created: @CallID, @CSeq headers
+   * are generated, if they do not exist, and a tag is added to the @From
+   * header.
+   */
+
+  if (!ds->ds_leg) {
+    if (ds->ds_remote_tag && ds->ds_remote_tag[0] && 
+       sip_to_tag(nh->nh_home, sip->sip_to, ds->ds_remote_tag) < 0)
+      goto error;
+
+    if (sip->sip_from == NULL && 
+       sip_add_dup(msg, sip, (sip_header_t *)nua->nua_from) < 0)
+      goto error;
+
+    if (cr->cr_dialog) {
+      ds->ds_leg = nta_leg_tcreate(nua->nua_nta,
+                                  nua_stack_process_request, nh,
+                                  SIPTAG_CALL_ID(sip->sip_call_id),
+                                  SIPTAG_FROM(sip->sip_from),
+                                  SIPTAG_TO(sip->sip_to),
+                                  SIPTAG_CSEQ(sip->sip_cseq),
+                                  TAG_END());
+      if (!ds->ds_leg)
+       goto error;
+
+      if (!sip->sip_from->a_tag &&
+         sip_from_tag(msg_home(msg), sip->sip_from,
+                      nta_leg_tag(ds->ds_leg, NULL)) < 0)
+       goto error;
+    }
   }
   else {
-    nua_stack_event(nua, nh, NULL, e, 904, "No matching challenge", TAG_END());
+    if (ds->ds_route)
+      url = NULL;
   }
+
+  if (url && nua_client_set_target(cr, (url_t *)url) < 0)
+    goto error;
+
+  cr->cr_has_contact = has_contact;
+
+  if (cr->cr_methods->crm_init) {
+    error = cr->cr_methods->crm_init(cr, msg, sip, cr->cr_tags);
+    if (error < -1)
+      msg = NULL;
+    if (error < 0)
+      goto error;
+    if (error != 0)
+      return error;
+  }
+
+  cr->cr_msg = msg;
+  cr->cr_sip = sip;
+
+  return nua_client_request_try(cr);
+
+ error:
+  return nua_client_return(cr, NUA_INTERNAL_ERROR, msg);
 }
 
-/* ======================================================================== */
-/*
- * Process incoming requests
- */
 
-int nua_stack_process_request(nua_handle_t *nh,
-                             nta_leg_t *leg,
-                             nta_incoming_t *irq,
-                             sip_t const *sip)
+/** Restart the request message.
+ *
+ * A restarted request has not completed successfully.
+ *
+ * @retval 0 if request is pending
+ * @retval >=1 if error event has been sent
+ */
+int nua_client_restart_request(nua_client_request_t *cr,
+                             int terminating,
+                             tagi_t const *tags)
 {
-  nua_t *nua = nh->nh_nua;
-  sip_method_t method = sip->sip_request->rq_method;
-  char const *user_agent = NH_PGET(nh, user_agent);
-  sip_supported_t const *supported = NH_PGET(nh, supported);
-  sip_allow_t const *allow = NH_PGET(nh, allow);
-  enter;
+  if (cr) {
+    assert(nua_client_is_queued(cr));
 
-  nta_incoming_tag(irq, NULL);
+    if (tags && cr->cr_msg)
+      if (sip_add_tagis(cr->cr_msg, NULL, &tags) < 0)
+       /* XXX */;
 
-  if (nta_check_method(irq, sip, allow,
-                      SIPTAG_SUPPORTED(supported),
-                      SIPTAG_USER_AGENT_STR(user_agent),
-                      TAG_END()))
-    return 405;
+    cr->cr_terminating = terminating;
 
-  switch (sip->sip_request->rq_url->url_type) {
-  case url_sip:
-  case url_sips:
-  case url_im:
-  case url_pres:
-  case url_tel:
-    break;
-  default:
-    nta_incoming_treply(irq, SIP_416_UNSUPPORTED_URI,
-                       SIPTAG_ALLOW(allow),
-                       SIPTAG_SUPPORTED(supported),
-                       SIPTAG_USER_AGENT_STR(user_agent),
-                       TAG_END());
+    return nua_client_request_try(cr);
   }
+  return 0;
+}
 
-  if (nta_check_required(irq, sip, supported,
-                        SIPTAG_ALLOW(allow),
-                        SIPTAG_USER_AGENT_STR(user_agent),
-                        TAG_END()))
-    return 420;
+/** Resend the request message.
+ *
+ * A resent request has completed once successfully - restarted has not.
+ *
+ * @retval 0 if request is pending
+ * @retval >=1 if error event has been sent
+ */
+int nua_client_resend_request(nua_client_request_t *cr,
+                             int terminating)
+{
+  if (cr) {
+    cr->cr_retry_count = 0;
+    cr->cr_challenged = 0;
 
-  if (nh == nua->nua_dhandle) {
-    if (!sip->sip_to->a_tag)
-      ;
-    else if (method == sip_method_message && NH_PGET(nh, win_messenger_enable))
-      ;
-    else {
-      nta_incoming_treply(irq, 481, "Initial transaction with a To tag",
-                         TAG_END());
-      return 481;
+    if (nua_client_is_queued(cr)) {
+      if (terminating)
+       cr->cr_graceful = 1;
+      return 0;
     }
-    nh = NULL;
+
+    if (terminating)
+      cr->cr_terminating = terminating;
+
+    if (nua_client_request_queue(cr))
+      return 0;
+    if (nua_dialog_is_reporting(cr->cr_owner->nh_ds))
+      return 0;
+    return nua_client_request_try(cr);
   }
+  return 0;
+}
 
-  if (sip->sip_timestamp)
-    nta_incoming_treply(irq, SIP_100_TRYING, TAG_END());
 
-  switch (method) {
-  case sip_method_invite:
-    return nua_stack_process_invite(nua, nh, irq, sip);
+/** Create a request message and send it.
+ *
+ * If an error occurs, send error event to the application.
+ *
+ * @retval 0 if request is pending
+ * @retval >=1 if error event has been sent
+ */
+static
+int nua_client_request_try(nua_client_request_t *cr)
+{
+  int error = -1;
+  msg_t *msg = msg_copy(cr->cr_msg);
+  sip_t *sip = sip_object(msg);
 
-  case sip_method_info:
-    if (nh) return nua_stack_process_info(nua, nh, irq, sip);
-    /*FALLTHROUGH*/
+  cr->cr_answer_recv = 0, cr->cr_offer_sent = 0;
+  cr->cr_offer_recv = 0, cr->cr_answer_sent = 0;
 
-  case sip_method_update:
-    if (nh) return nua_stack_process_update(nua, nh, irq, sip);
-    /*FALLTHROUGH*/
+  if (msg && sip) {
+    error = nua_client_request_sendmsg(cr, msg, sip);
+    if (!error)
+      return 0;
 
-  case sip_method_bye:
-    if (nh) return nua_stack_process_bye(nua, nh, irq, sip);
+    if (error == -1)
+      msg_destroy(msg);
+  }
 
-    nta_incoming_treply(irq,
-                       481, "Call Does Not Exist",
-                       SIPTAG_ALLOW(allow),
-                       SIPTAG_SUPPORTED(supported),
-                       SIPTAG_USER_AGENT_STR(user_agent),
-                       TAG_END());
-    return 481;
+  if (error < 0)
+    error = nua_client_response(cr, NUA_INTERNAL_ERROR, NULL);
 
-  case sip_method_message:
-    return nua_stack_process_message(nua, nh, irq, sip);
+  assert(error > 0);
+  return error;
+}
+
+/**Send a request message.
+ *
+ * @retval 0 if request is pending
+ * @retval >=1 if error event has been sent
+ * @retval -1 if error occurred but event has not been sent,
+               and @a msg has not been destroyed
+ * @retval -2 if error occurred, event has not been sent,
+ *            but @a msg has been destroyed
+ */
+static
+int nua_client_request_sendmsg(nua_client_request_t *cr, msg_t *msg, sip_t *sip)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  sip_method_t method = cr->cr_method;
+  char const *name = cr->cr_method_name;
+  url_string_t const *url = (url_string_t *)cr->cr_target;
+  nta_leg_t *leg;
 
-  case sip_method_notify:
-    return nua_stack_process_notify(nua, nh, irq, sip);
+  assert(cr->cr_orq == NULL);
 
-  case sip_method_subscribe:
-    return nua_stack_process_subscribe(nua, nh, irq, sip);
+  cr->cr_retry_count++;
 
-  case sip_method_register:
-    return nua_stack_process_register(nua, nh, irq, sip);
+  if (ds->ds_leg)
+    leg = ds->ds_leg;
+  else
+    leg = nh->nh_nua->nua_dhandle->nh_ds->ds_leg; /* Default leg */
 
-  case sip_method_options:
-    return nua_stack_process_options(nua, nh, irq, sip);
+  if (nua_dialog_is_established(ds)) {
+    while (sip->sip_route)
+      sip_route_remove(msg, sip);
+  }
+  
+  /**
+   * For in-dialog requests, the request URI is taken from the @Contact
+   * header received from the remote party during dialog establishment, 
+   * and the NUTAG_URL() is ignored.
+   *
+   * Also, the @CallID and @CSeq headers and @From and @To tags are
+   * generated based on the dialog information and added to the request. 
+   * If the dialog has a route, it is added to the request, too.
+   */
+  if (nta_msg_request_complete(msg, leg, method, name, url) < 0)
+    return -1;
 
-  case sip_method_refer:
-    return nua_stack_process_refer(nua, nh, irq, sip);
+  /**@MaxForwards header (with default value set by NTATAG_MAX_FORWARDS()) is
+   * also added now, if it does not exist.
+   */
+
+  if (!ds->ds_remote)
+    ds->ds_remote = sip_to_dup(nh->nh_home, sip->sip_to);
+  if (!ds->ds_local)
+    ds->ds_local = sip_from_dup(nh->nh_home, sip->sip_from);
+
+  /**
+   * Next, values previously set with nua_set_params() or nua_set_hparams()
+   * are used: @Allow, @Supported, @Organization, and @UserAgent headers are
+   * added to the request if they are not already set. 
+   */
+  if (!sip->sip_allow)
+    sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow));
+  
+  if (!sip->sip_supported && NH_PGET(nh, supported))
+    sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, supported));
+  
+  if (method == sip_method_register && NH_PGET(nh, path_enable) &&
+      !sip_has_feature(sip->sip_supported, "path") &&
+      !sip_has_feature(sip->sip_require, "path"))
+    sip_add_make(msg, sip, sip_supported_class, "path");
+  
+  if (!sip->sip_organization && NH_PGET(nh, organization))
+    sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, organization));
+
+  if (!sip->sip_user_agent && NH_PGET(nh, user_agent))
+    sip_add_make(msg, sip, sip_user_agent_class, NH_PGET(nh, user_agent));
+
+  /**
+   * Next, the stack generates a @Contact header for the request (unless
+   * the application already gave a @Contact header or it does not want to
+   * use @Contact and indicates that by including SIPTAG_CONTACT(NULL) or
+   * SIPTAG_CONTACT(SIP_NONE) in the tagged parameters.) If the
+   * application has registered the URI in @From header, the @Contact
+   * header used with registration is used. Otherwise, the @Contact header
+   * is generated from the local IP address and port number.
+   */
+
+  /**For the initial requests, @ServiceRoute set that was received from the
+   * registrar is also added to the request message.
+   */
+  if (cr->cr_method != sip_method_register) {
+    if (nua_registration_add_contact_to_request(nh, msg, sip,
+                                               cr->cr_contactize &&
+                                               !cr->cr_has_contact,
+                                               !ds->ds_route) < 0)
+      return -1;
+  }
 
-  case sip_method_publish:
-    return nua_stack_process_publish(nua, nh, irq, sip);
+  cr->cr_wait_for_cred = 0;
 
-  case sip_method_ack:
-  case sip_method_cancel:
-    SU_DEBUG_1(("nua(%p): strange %s from <" URL_PRINT_FORMAT ">\n", nh,
-               sip->sip_request->rq_method_name,
-               URL_PRINT_ARGS(sip->sip_from->a_url)));
-    /* Send nua_i_error ? */
-    return 481;
+  if (cr->cr_methods->crm_send)
+    return cr->cr_methods->crm_send(cr, msg, sip, NULL);
 
-  case sip_method_unknown:
-    return nua_stack_process_method(nua, nh, irq, sip);
+  return nua_base_client_request(cr, msg, sip, NULL);
+}
 
-  default:
-    return nua_stack_process_unknown(nua, nh, irq, sip);
-  }
+/**Add tags to request message and send it, 
+ *
+ * @retval 0 success
+ * @retval -1 if error occurred, but event has not been sent
+ * @retval -2 if error occurred, event has not been sent,
+ *            and @a msg has been destroyed
+ * @retval >=1 if error event has been sent
+ */
+int nua_base_client_trequest(nua_client_request_t *cr,
+                            msg_t *msg, sip_t *sip,
+                            tag_type_t tag, tag_value_t value, ...)
+{
+  int retval;
+  ta_list ta;
+  ta_start(ta, tag, value);
+  retval = nua_base_client_request(cr, msg, sip, ta_args(ta));
+  ta_end(ta);
+  return retval;
 }
 
-nua_server_request_t *nua_server_request(nua_t *nua,
-                                        nua_handle_t *nh,
-                                        nta_incoming_t *irq,
-                                        sip_t const *sip,
-                                        nua_server_request_t *sr,
-                                        size_t size,
-                                        nua_server_respond_f *respond,
-                                        int create_dialog)
+/** Send request.
+ *
+ * @retval 0 success
+ * @retval -1 if error occurred, but event has not been sent
+ * @retval -2 if error occurred, event has not been sent,
+ *            and @a msg has been destroyed
+ * @retval >=1 if error event has been sent
+ */
+int nua_base_client_request(nua_client_request_t *cr, msg_t *msg, sip_t *sip,
+                           tagi_t const *tags)
 {
-  int initial = 1, final = 200;
+  nua_handle_t *nh = cr->cr_owner;
 
-  assert(nua && irq && sip && sr);
+  if (nh->nh_auth) {
+    if (cr->cr_challenged || 
+       NH_PGET(nh, auth_cache) == nua_auth_cache_dialog) {
+      if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
+       return nua_client_return(cr, 900, "Cannot add credentials", msg);
+    }
+  }
 
-  initial = nh == NULL || nh == nua->nua_dhandle;
+  cr->cr_seq = sip->sip_cseq->cs_seq; /* Save last sequence number */
 
-  /* INVITE server request is not finalized after 2XX response */
-  if (sip->sip_request->rq_method == sip_method_invite)
-    final = 300;
+  cr->cr_orq = nta_outgoing_mcreate(nh->nh_nua->nua_nta,
+                                   nua_client_orq_response, cr,
+                                   NULL, 
+                                   msg,
+                                   TAG_NEXT(tags));
 
-  /* Create handle if request does not fail */
-  if (sr->sr_status >= 300)
-    ;
-  else if (initial) {
-    if (!(nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog)))
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  return cr->cr_orq ? 0 : -1;
+}
+
+/** Callback for nta client transaction */
+int nua_client_orq_response(nua_client_request_t *cr,
+                           nta_outgoing_t *orq,
+                           sip_t const *sip)
+{
+  int status;
+  char const *phrase;
+
+  if (sip && sip->sip_status) {
+    status = sip->sip_status->st_status;
+    phrase = sip->sip_status->st_phrase;
   }
-  else if (create_dialog) {
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-    nua_dialog_uas_route(nh, nh->nh_ds, sip, 1);
+  else {
+    status = nta_outgoing_status(orq);
+    phrase = "";
   }
 
-  if (nh == NULL)
-    nh = nua->nua_dhandle;
+  nua_client_response(cr, status, phrase, sip);
+
+  return 0;
+}
+
+/**Return response to the client request.
+ *
+ * Return a response generated by the stack. This function is used to return
+ * a error response within @a nua_client_methods_t#crm_init or @a
+ * nua_client_methods_t#crm_send functions. It takes care of disposing the @a
+ * to_be_destroyed that cannot be sent.
+ *
+ * @retval 0 if response event was preliminary
+ * @retval 1 if response event was final
+ * @retval 2 if response event destroyed the handle, too.
+ */
+int nua_client_return(nua_client_request_t *cr,
+                     int status,
+                     char const *phrase,
+                     msg_t *to_be_destroyed)
+{
+  if (to_be_destroyed)
+    msg_destroy(to_be_destroyed);
+  nua_client_response(cr, status, phrase, NULL);
+  return 1;
+}
 
-  if (sr->sr_status < final) {
-    nua_server_request_t *sr0 = sr;
+/** Process response to the client request.
+ *
+ * The response can be generated by the stack (@a sip is NULL) or
+ * returned by the remote server.
+ *
+ * @retval 0 if response event was preliminary
+ * @retval 1 if response event was final
+ * @retval 2 if response event destroyed the handle, too.
+ */
+int nua_client_response(nua_client_request_t *cr,
+                       int status,
+                       char const *phrase,
+                       sip_t const *sip)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
 
-    if (size < (sizeof *sr))
-      size = sizeof *sr;
+  if (cr->cr_restarting)
+    return 0;
 
-    sr = su_zalloc(nh->nh_home, size);
+  cr->cr_status = status;
 
-    if (sr) {
-      if ((sr->sr_next = nh->nh_ds->ds_sr))
-       *(sr->sr_prev = sr->sr_next->sr_prev) = sr,
-         sr->sr_next->sr_prev = &sr->sr_next;
-      else
-       *(sr->sr_prev = &nh->nh_ds->ds_sr) = sr;
-      SR_STATUS(sr, sr0->sr_status, sr0->sr_phrase);
+  if (status < 200) {
+    /* Xyzzy */
+  }
+  else if (sip && nua_client_check_restart(cr, status, phrase, sip)) {
+    return 0;
+  }
+  else if (status < 300) {
+    if (cr->cr_terminating) {
+      cr->cr_terminated = 1;
     }
     else {
-      sr = sr0;
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+      if (sip) {
+       if (cr->cr_contactize)
+         nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+       nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+      }
+
+      if (du && du->du_cr == cr)
+       du->du_ready = 1;
     }
   }
+  else {
+    sip_method_t method = cr->cr_method;
+    int terminated, graceful = 1;
 
-  sr->sr_owner = nh;
-  sr->sr_method = sip->sip_request->rq_method;
-  sr->sr_respond = respond;
-  sr->sr_irq = irq;
-  sr->sr_initial = initial;
+    if (status < 700)
+      terminated = sip_response_terminates_dialog(status, method, &graceful);
+    else
+      /* XXX - terminate usage by all internal error responses */
+      terminated = 0, graceful = 1;
+
+    if (terminated < 0)
+      cr->cr_terminated = terminated;      
+    else if (cr->cr_terminating || terminated)
+      cr->cr_terminated = 1;
+    else if (graceful)
+      cr->cr_graceful = 1;
+  }
+  
+  if (status < 200) {
+    if (cr->cr_methods->crm_preliminary)
+      cr->cr_methods->crm_preliminary(cr, status, phrase, sip);
+    else
+      nua_base_client_response(cr, status, phrase, sip, NULL);
+    return 0;
+  }  
 
-  return sr;
-}               
+  if (cr->cr_methods->crm_recv)
+    return cr->cr_methods->crm_recv(cr, status, phrase, sip);
+  else
+    return nua_base_client_response(cr, status, phrase, sip, NULL);
+}
 
-void nua_server_request_destroy(nua_server_request_t *sr)
+/** Check if request should be restarted.
+ *
+ * @retval 1 if restarted or waring for restart
+ * @retval 0 otherwise
+ */
+int nua_client_check_restart(nua_client_request_t *cr,
+                            int status,
+                            char const *phrase,
+                            sip_t const *sip)
 {
-  if (sr->sr_irq)
-    nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL;
+  nua_handle_t *nh = cr->cr_owner;
 
-  sr->sr_msg = NULL;
+  assert(cr && status >= 200 && phrase && sip);
 
-  if (sr->sr_prev) {
-    if ((*sr->sr_prev = sr->sr_next))
-      sr->sr_next->sr_prev = sr->sr_prev;
+  if (cr->cr_retry_count > NH_PGET(nh, retry_count))
+    return 0;
 
-    if (sr->sr_owner)
-      su_free(sr->sr_owner->nh_home, sr);
-  }
+  if (cr->cr_methods->crm_check_restart)
+    return cr->cr_methods->crm_check_restart(cr, status, phrase, sip);
+  else
+    return nua_base_client_check_restart(cr, status, phrase, sip);
 }
 
-/** Send server event (nua_i_*) to the application. */
-int nua_stack_server_event(nua_t *nua,
-                          nua_server_request_t *sr,
-                          nua_event_t event,
-                          tag_type_t tag, tag_value_t value, ...)
+int nua_base_client_check_restart(nua_client_request_t *cr,
+                                 int status,
+                                 char const *phrase,
+                                 sip_t const *sip)
 {
-  nua_handle_t *nh = sr->sr_owner; 
-  int status, final = 0;
-
-  if (nh == NULL) nh = nua->nua_dhandle;
+  nua_handle_t *nh = cr->cr_owner; 
 
-  if (sr->sr_status > 100)
-    /* Note that this may change the sr->sr_status */
-    final = sr->sr_respond(sr, NULL);
+  /* XXX - handle Retry-After */
 
-  status = sr->sr_status;
+  if (status == 302 || status == 305) {
+    sip_route_t r[1];
 
-  if (status >= 200)
-    sr->sr_respond = NULL;
-  
-  if (status < 300 || !sr->sr_initial) {
-    ta_list ta;
-    msg_t *request;
+    if (!can_redirect(sip->sip_contact, cr->cr_method))
+      return 0;
 
-    ta_start(ta, tag, value);
+    switch (status) {
+    case 302:
+      if (nua_client_set_target(cr, sip->sip_contact->m_url) >= 0)
+       return nua_client_restart(cr, 100, "Redirected");
+      break;
 
-    assert(sr->sr_owner);
-    request = nta_incoming_getrequest(sr->sr_irq);
-    nua_stack_event(nua, sr->sr_owner, request, event, 
-                   sr->sr_status, sr->sr_phrase, 
-                   ta_tags(ta));
-    ta_end(ta);
+    case 305:
+      sip_route_init(r);
+      *r->r_url = *sip->sip_contact->m_url;
+      if (sip_add_dup(cr->cr_msg, cr->cr_sip, (sip_header_t *)r) >= 0)
+       return nua_client_restart(cr, 100, "Redirected via a proxy");
+      break;
 
-    if (final)
-      nua_server_request_destroy(sr);
-    else if (sr->sr_status < 200)
-      sr->sr_msg = request;
+    default:
+      break;
+    }
   }
-  else {
-    nh = sr->sr_owner;
 
-    nua_server_request_destroy(sr);
 
-    if (nh && nh != nua->nua_dhandle)
-      nh_destroy(nua, nh);
+  if (status == 423) {
+    unsigned my_expires = 0;
+    
+    if (cr->cr_sip->sip_expires)
+      my_expires = cr->cr_sip->sip_expires->ex_delta;
+
+    if (sip->sip_min_expires &&
+       sip->sip_min_expires->me_delta > my_expires) {
+      sip_expires_t ex[1];
+      sip_expires_init(ex);
+      ex->ex_delta = sip->sip_min_expires->me_delta;
+
+      if (sip_add_dup(cr->cr_msg, NULL, (sip_header_t *)ex) < 0)
+       return 0;
+
+      return nua_client_restart(cr, 100, "Re-Negotiating Expiration");
+    }
   }
 
-  return 0;
-}
+  if ((status == 401 && sip->sip_www_authenticate) ||
+      (status == 407 && sip->sip_proxy_authenticate)) {
+    int server = 0, proxy = 0;
+    nta_outgoing_t *orq;
 
-/** Respond to a request. */
-int nua_server_respond(nua_server_request_t *sr,
-                      int status, char const *phrase,
-                      tag_type_t tag, tag_value_t value, ...)
-{
-  ta_list ta;
-  int final;
+    if (sip->sip_www_authenticate)
+      server = auc_challenge(&nh->nh_auth, nh->nh_home,
+                            sip->sip_www_authenticate,
+                            sip_authorization_class);
 
-  assert(sr && sr->sr_respond);
-  SR_STATUS(sr, status, phrase);
+    if (sip->sip_proxy_authenticate)
+      proxy = auc_challenge(&nh->nh_auth, nh->nh_home,
+                           sip->sip_proxy_authenticate,
+                           sip_proxy_authorization_class);
 
-  ta_start(ta, tag, value);
-  final = sr->sr_respond(sr, ta_args(ta));
-  ta_end(ta);
+    if (server >= 0 && proxy >= 0) {
+      int invalid = cr->cr_challenged && server + proxy == 0;
 
-  if (final) {
-    nua_server_request_destroy(sr);    
-    return final;
-  }
+      cr->cr_challenged = 1;
 
-  if (sr->sr_status >= 200)
-    sr->sr_respond = NULL;
+      if (invalid)
+       /* Bad username/password */
+       auc_clear_credentials(&nh->nh_auth, NULL, NULL);
+      else if (auc_has_authorization(&nh->nh_auth)) 
+       return nua_client_restart(cr, 100, "Request Authorized by Cache");
 
-  return 0;
+      orq = cr->cr_orq, cr->cr_orq = NULL;
+      cr->cr_wait_for_cred = 1;
+      nua_client_report(cr, status, phrase, NULL, orq, NULL);
+      nta_outgoing_destroy(orq);
+
+      return 1;
+    }
+  }
+
+  return 0;  /* This was a final response that cannot be restarted. */
 }
 
-msg_t *nua_server_response(nua_server_request_t *sr,
-                          int status, char const *phrase,
-                          tag_type_t tag, tag_value_t value, ...)
+/** Restart request.
+ *
+ * @retval 1 if restarted
+ * @retval 0 otherwise
+ */
+int nua_client_restart(nua_client_request_t *cr,
+                      int status, char const *phrase)
 {
+  nua_handle_t *nh = cr->cr_owner;
+  nta_outgoing_t *orq;
+  int error = -1, terminated, graceful;
   msg_t *msg;
-  ta_list(ta);
+  sip_t *sip;
 
-  assert(sr && sr->sr_owner && sr->sr_owner->nh_nua);
+  if (cr->cr_retry_count > NH_PGET(nh, retry_count))
+    return 0;
 
-  ta_start(ta, tag, value);
+  orq = cr->cr_orq, cr->cr_orq = NULL;  assert(orq);
+  terminated = cr->cr_terminated, cr->cr_terminated = 0;
+  graceful = cr->cr_graceful, cr->cr_graceful = 0;
 
-  msg = nh_make_response(sr->sr_owner->nh_nua, sr->sr_owner, sr->sr_irq,
-                        sr->sr_status, sr->sr_phrase,
-                        ta_tags(ta));
-  
-  ta_end(ta);
+  msg = msg_copy(cr->cr_msg);
+  sip = sip_object(msg);
+
+  if (msg && sip) {
+    cr->cr_restarting = 1;
+    error = nua_client_request_sendmsg(cr, msg, sip);
+    cr->cr_restarting = 0;
+    if (error !=0 && error != -2)
+      msg_destroy(msg);
+  }
+
+
+  if (error) {
+    cr->cr_graceful = graceful;
+    cr->cr_terminated = terminated;
+    assert(cr->cr_orq == NULL);
+    cr->cr_orq = orq;
+    return 0;
+  }
+
+  nua_client_report(cr, status, phrase, NULL, orq, NULL);
+
+  nta_outgoing_destroy(orq);
 
-  return msg;
+  return 1;
 }
 
-int nua_default_respond(nua_server_request_t *sr,
-                       tagi_t const *tags)
+int nua_client_set_target(nua_client_request_t *cr, url_t const *target)
 {
-  msg_t *m;
+  url_t *new_target, *old_target = cr->cr_target;
 
-  assert(sr && sr->sr_owner && sr->sr_owner->nh_nua);
+  if (!target || target == old_target)
+    return 0;
 
-  m = nh_make_response(sr->sr_owner->nh_nua, sr->sr_owner, 
-                      sr->sr_irq,
-                      sr->sr_status, sr->sr_phrase,
-                      TAG_NEXT(tags));
+  new_target = url_hdup(cr->cr_owner->nh_home, (url_t *)target);
+  if (!new_target)
+    return -1;
+  cr->cr_target = new_target;
+  if (old_target)
+    su_free(cr->cr_owner->nh_home, old_target);
 
-  if (m) {
-    if (nta_incoming_mreply(sr->sr_irq, m) < 0)
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);      
-  }
-  
-  return sr->sr_status >= 200 ? sr->sr_status : 0;
+  return 0;
 }
 
-/** Respond to an request with given status. 
- *
- * When nua protocol engine receives an incoming SIP request, it can either
- * respond to the request automatically or let it up to application to
- * respond to the request. The automatic answer is sent if the request fails
- * because of method, SIP extension or, in some times, MIME content
- * negotiation fails.
- *
- * When responding to an incoming INVITE request, the nua_respond() can be
- * called without NUTAG_WITH() (or NUTAG_WITH_CURRENT() or
- * NUTAG_WITH_SAVED()). Otherwise, NUTAG_WITH() will contain an indication
- * of the request being responded.
- *
- * In order to simplify the simple applications, most requests are responded
- * automatically. The set of requests always responded by the stack include
- * BYE, CANCEL and NOTIFY. The application can add methods that it likes to
- * handle by itself with NUTAG_APPL_METHOD(). The default set of
- * NUTAG_APPL_METHOD() includes INVITE, PUBLISH, REGISTER and SUBSCRIBE. 
- * Note that unless the method is also included in the set of allowed
- * methods with NUTAG_ALLOW(), the stack will respond to the incoming
- * methods with <i>405 Not Allowed</i>.
- *
- * Note that certain methods are rejected outside a SIP session (created
- * with INVITE transaction). They include BYE, UPDATE, PRACK and INFO. Also
- * the auxiliary methods ACK and CANCEL are rejected by stack if there is no
- * ongoing INVITE transaction corresponding to them.
- *
- * @param nh              Pointer to operation handle
- * @param status          SIP response status (see RFCs of SIP)
- * @param phrase          free text (default response phrase used if NULL)
- * @param tag, value, ... List of tagged parameters
+/**@internal
+ * Relay response event to the application.
  *
- * @return 
- *    nothing
+ * @todo 
+ * If handle has already been marked as destroyed by nua_handle_destroy(),
+ * release the handle with nh_destroy().
  *
- * @par Related Tags:
- *    NUTAG_WITH(), NUTAG_WITH_CURRENT(), NUTAG_WITH_SAVED() \n
- *    NUTAG_EARLY_ANSWER() \n
- *    SOATAG_ADDRESS() \n
- *    SOATAG_AF() \n
- *    SOATAG_HOLD() \n
- *    Tags in <sip_tag.h>.
+ * @retval 0 if event was preliminary
+ * @retval 1 if event was final
+ * @retval 2 if event destroyed the handle, too.
+ */
+int nua_base_client_tresponse(nua_client_request_t *cr,
+                             int status, char const *phrase,
+                             sip_t const *sip,
+                             tag_type_t tag, tag_value_t value, ...)
+{
+  ta_list ta;
+  int retval;
+
+  if (cr->cr_event == nua_r_destroy)
+    return nua_base_client_response(cr, status, phrase, sip, NULL);
+
+  ta_start(ta, tag, value);
+  retval = nua_base_client_response(cr, status, phrase, sip, ta_args(ta));
+  ta_end(ta);
+
+  return retval;
+}
+
+/**@internal
+ * Relay response event to the application.
  *
- * @par Events:
- *    #nua_i_state \n
- *    #nua_i_media_error \n
- *    #nua_i_error \n
- *    #nua_i_active \n
- *    #nua_i_terminated \n
+ * @todo 
+ * If handle has already been marked as destroyed by nua_handle_destroy(),
+ * release the handle with nh_destroy().
  *
- * @sa #nua_i_invite, #nua_i_register, #nua_i_subscribe, #nua_i_publish
+ * @retval 0 if event was preliminary
+ * @retval 1 if event was final
+ * @retval 2 if event destroyed the handle, too.
  */
-void
-nua_stack_respond(nua_t *nua, nua_handle_t *nh,
-                 int status, char const *phrase, tagi_t const *tags)
+int nua_base_client_response(nua_client_request_t *cr,
+                            int status, char const *phrase,
+                            sip_t const *sip,
+                            tagi_t const *tags)
 {
-  nua_server_request_t *sr;
-  tagi_t const *t;
-  msg_t const *request = NULL;
+  nua_handle_t *nh = cr->cr_owner;
+  sip_method_t method = cr->cr_method;
+  nua_dialog_usage_t *du;
 
-  t = tl_find_last(tags, nutag_with);
+  cr->cr_reporting = 1, nh->nh_ds->ds_reporting = 1;
+
+  if (nh->nh_auth && sip &&
+      (sip->sip_authentication_info || sip->sip_proxy_authentication_info)) {
+    /* Collect nextnonce */
+    if (sip->sip_authentication_info)
+      auc_info(&nh->nh_auth,
+              sip->sip_authentication_info,
+              sip_authorization_class);
+    if (sip->sip_proxy_authentication_info) 
+      auc_info(&nh->nh_auth,
+              sip->sip_proxy_authentication_info,
+              sip_proxy_authorization_class);
+  }
 
-  if (t)
-    request = (msg_t const *)t->t_value;
+  if ((method != sip_method_invite && status >= 200) || status >= 300)
+    nua_client_request_remove(cr);
 
-  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next) {
-    if (request && sr->sr_msg == request)
-      break;
-    /* nua_respond() to INVITE can be used without NUTAG_WITH() */
-    if (!t && sr->sr_method == sip_method_invite && sr->sr_respond)
-      break;
+  nua_client_report(cr, status, phrase, sip, cr->cr_orq, tags);
+
+  if (status < 200 ||
+      /* Un-ACKed 2XX response to INVITE */
+      (method == sip_method_invite && status < 300 && cr->cr_orq)) {
+    cr->cr_reporting = 0, nh->nh_ds->ds_reporting = 0;
+    return 1;
   }
-  
-  if (sr && sr->sr_respond) {
-    int final;
-    SR_STATUS(sr, status, phrase);
-    final = sr->sr_respond(sr, tags);
-    if (final)
-      nua_server_request_destroy(sr);    
-    else if (sr->sr_status >= 200)
-      sr->sr_respond = NULL;
-    return;
+
+  if (cr->cr_orq)
+    nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = NULL;
+
+  du = cr->cr_usage;
+
+  if (cr->cr_terminated < 0) {
+    /* XXX - dialog has been terminated */;
+    nua_dialog_deinit(nh, nh->nh_ds), cr->cr_usage = NULL;
   }
-  else if (sr) {
-    nua_stack_event(nua, nh, NULL, nua_i_error,
-                   500, "Already Sent Final Response", TAG_END());
-    return;
+  else if (du) {
+    if (cr->cr_terminated ||
+       (!du->du_ready && status >= 300 && nua_client_is_bound(cr))) {
+      /* Usage has been destroyed */
+      nua_dialog_usage_remove(nh, nh->nh_ds, du), cr->cr_usage = NULL;
+    }
+    else if (cr->cr_graceful) {
+      /* Terminate usage gracefully */
+      if (nua_dialog_usage_shutdown(nh, nh->nh_ds, du) > 0)
+       cr->cr_usage = NULL;
+    }
+  }
+  else if (cr->cr_terminated) {
+    if (nh->nh_ds->ds_usage == NULL)
+      nua_dialog_remove(nh, nh->nh_ds, NULL), cr->cr_usage = NULL;
+  }
+
+  cr->cr_reporting = 0, nh->nh_ds->ds_reporting = 0;
+
+  if (!nua_client_is_queued(cr) && !nua_client_is_bound(cr))
+    nua_client_request_destroy(cr);
+
+  if (method == sip_method_cancel)
+    return 1;
+
+  return
+    nua_client_next_request(nh->nh_ds->ds_cr, method == sip_method_invite);
+}
+
+/** Send event, zap transaction but leave cr in list */
+int nua_client_report(nua_client_request_t *cr,
+                     int status, char const *phrase,
+                     sip_t const *sip,
+                     nta_outgoing_t *orq,
+                     tagi_t const *tags)
+{
+  nua_handle_t *nh;
+
+  if (cr->cr_event == nua_r_destroy)
+    return 1;
+
+  if (cr->cr_methods->crm_report)
+    return cr->cr_methods->crm_report(cr, status, phrase, sip, orq, tags);
+
+  nh = cr->cr_owner;
+  
+  nua_stack_event(nh->nh_nua, nh, 
+                 nta_outgoing_getresponse(orq),
+                 cr->cr_event,
+                 status, phrase,
+                 tags);
+  return 1;
+}
+
+int nua_client_treport(nua_client_request_t *cr,
+                      int status, char const *phrase,
+                      sip_t const *sip,
+                      nta_outgoing_t *orq,
+                      tag_type_t tag, tag_value_t value, ...)
+{
+  int retval;
+  ta_list ta;
+  ta_start(ta, tag, value);
+  retval = nua_client_report(cr, status, phrase, sip, orq, ta_args(ta));
+  ta_end(ta);
+  return retval;
+}
+
+int nua_client_next_request(nua_client_request_t *cr, int invite)
+{
+  for (; cr; cr = cr->cr_next) {
+    if (cr->cr_method == sip_method_cancel)
+      continue;
+    
+    if (invite 
+       ? cr->cr_method == sip_method_invite
+       : cr->cr_method != sip_method_invite)
+      break;
   }
 
-  nua_stack_event(nua, nh, NULL, nua_i_error,
-                 500, "Responding to a Non-Existing Request", TAG_END());
+  if (cr && cr->cr_orq == NULL) 
+    nua_client_init_request(cr);
+
+  return 1;
+}
+
+nua_client_request_t *
+nua_client_request_pending(nua_client_request_t const *cr)
+{
+  for (;cr;cr = cr->cr_next)
+    if (cr->cr_orq)
+      return (nua_client_request_t *)cr;
+
+  return NULL;
 }
index e9c0afcdc76659ba402848385ee67c1c9252a8e7..d7ec5c2c4b7fa99d807f8ff813ea2c3547b10964 100644 (file)
@@ -103,6 +103,32 @@ typedef struct register_usage nua_registration_t;
   TAG_IF((include) && (soa) && soa_is_remote_chat_active(soa) >= 0,    \
         SOATAG_ACTIVE_CHAT(soa_is_remote_chat_active(soa)))
 
+#if HAVE_NUA_HANDLE_DEBUG
+
+#define nua_handle_ref(nh) nua_handle_ref_by((nh), __func__)
+#define nua_handle_unref(nh) nua_handle_unref_by((nh), __func__)
+
+static inline nua_handle_t *nua_handle_ref_by(nua_handle_t *nh,
+                                             char const *by)
+{
+  if (nh)
+    SU_DEBUG_0(("nua_handle_ref(%p) => "MOD_ZU" by %s\n", nh, 
+               su_home_refcount((su_home_t *)nh) + 1,
+               by));
+  return (nua_handle_t *)su_home_ref((su_home_t *)nh);
+}
+
+static inline int nua_handle_unref_by(nua_handle_t *nh, char const *by)
+{
+  if (nh)
+    SU_DEBUG_0(("nua_handle_unref(%p) => "MOD_ZU" by %s\n", nh, 
+               su_home_refcount((su_home_t *)nh) - 1,
+               by));
+  return su_home_unref((su_home_t *)nh);
+}
+
+#endif
+
 /** NUA handle. 
  *
  */
@@ -113,7 +139,8 @@ struct nua_handle_s
   nua_handle_t  **nh_prev;
 
   nua_t                 *nh_nua;       /**< Pointer to NUA object  */
-  void           *nh_valid;
+  void           *nh_valid;    /**< Cookie */
+#define nua_valid_handle_cookie ((void *)(intptr_t)nua_handle)
   nua_hmagic_t          *nh_magic;     /**< Application context */
 
   tagi_t         *nh_tags;     /**< Initial tags */
@@ -154,7 +181,8 @@ struct nua_handle_s
   nea_server_t   *nh_notifier; /**< SIP notifier */
 };
 
-#define NH_IS_VALID(nh) ((nh) && (nh)->nh_valid)
+#define NH_IS_VALID(nh) \
+  ((nh) && (nh)->nh_valid == nua_valid_handle_cookie)
 
 #define NH_STATUS(nh) \
   (nh)->nh_status, \
@@ -285,28 +313,29 @@ nua_stack_signal_handler
   nua_stack_method;
 
 #define UA_EVENT1(e, statusphrase) \
-  nua_stack_event(nua, nh, NULL, e, statusphrase, TAG_END())
+  nua_stack_event(nua, nh, NULL, e, statusphrase, NULL)
 
 #define UA_EVENT2(e, status, phrase)                   \
-  nua_stack_event(nua, nh, NULL, e, status, phrase, TAG_END())
+  nua_stack_event(nua, nh, NULL, e, status, phrase, NULL)
 
 #define UA_EVENT3(e, status, phrase, tag)                      \
-  nua_stack_event(nua, nh, NULL, e, status, phrase, tag, TAG_END())
+  nua_stack_event(nua, nh, NULL, e, status, phrase, tag, NULL)
+
+int nua_stack_tevent(nua_t *nua, nua_handle_t *nh, msg_t *msg,
+                    nua_event_t event, int status, char const *phrase,
+                    tag_type_t tag, tag_value_t value, ...);
 
 int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
                    nua_event_t event, int status, char const *phrase,
-                   tag_type_t tag, tag_value_t value, ...);
+                   tagi_t const *tags);
 
-nua_handle_t *nh_create_handle(nua_t *nua, nua_hmagic_t *hmagic,
-                              tagi_t *tags);
+nua_handle_t *nh_create_handle(nua_t *nua, nua_hmagic_t *hmagic, tagi_t *tags);
 
 nua_handle_t *nua_stack_incoming_handle(nua_t *nua,
                                        nta_incoming_t *irq,
                                        sip_t const *sip,
                                        int create_dialog);
 
-enum { create_dialog = 1 };
-
 int nua_stack_init_handle(nua_t *nua, nua_handle_t *nh, 
                          tag_type_t tag, tag_value_t value, ...);
 
@@ -349,48 +378,8 @@ int nua_stack_process_request(nua_handle_t *nh,
                              nta_incoming_t *irq,
                              sip_t const *sip);
 
-int nua_stack_process_response(nua_handle_t *nh,
-                              nua_client_request_t *cr,
-                              nta_outgoing_t *orq,
-                              sip_t const *sip,
-                              tag_type_t tag, tag_value_t value, ...);
-
 int nua_stack_launch_network_change_detector(nua_t *nua);
 
-msg_t *nua_creq_msg(nua_t *nua, nua_handle_t *nh,
-                   nua_client_request_t *cr,
-                   int restart, 
-                   sip_method_t method, char const *name,
-                   tag_type_t tag, tag_value_t value, ...);
-
-int nua_tagis_have_contact_tag(tagi_t const *t);
-
-int nua_creq_check_restart(nua_handle_t *nh,
-                          nua_client_request_t *cr,
-                          nta_outgoing_t *orq,
-                          sip_t const *sip,
-                          nua_creq_restart_f *f);
-
-int nua_creq_restart_with(nua_handle_t *nh,
-                         nua_client_request_t *cr,
-                         nta_outgoing_t *orq,
-                         int status, char const *phrase,
-                         nua_creq_restart_f *f, 
-                         tag_type_t tag, tag_value_t value, ...);
-
-int nua_creq_save_restart(nua_handle_t *nh,
-                         nua_client_request_t *cr,
-                         nta_outgoing_t *orq,
-                         int status, char const *phrase,
-                         nua_creq_restart_f *f);
-
-int nua_creq_restart(nua_handle_t *nh,
-                    nua_client_request_t *cr,
-                    nta_response_f *cb,
-                    tagi_t *tags);
-
-void nua_creq_deinit(nua_client_request_t *cr, nta_outgoing_t *orq);
-
 sip_contact_t const *nua_stack_get_contact(nua_registration_t const *nr);
 
 int nua_registration_add_contact_to_request(nua_handle_t *nh,
@@ -405,51 +394,6 @@ int nua_registration_add_contact_to_response(nua_handle_t *nh,
                                             sip_record_route_t const *,
                                             sip_contact_t const *remote);
 
-msg_t *nh_make_response(nua_t *nua, nua_handle_t *nh, 
-                       nta_incoming_t *irq,
-                       int status, char const *phrase,
-                       tag_type_t tag, tag_value_t value, ...);
-
-
-typedef int nua_stack_process_request_t(nua_t *nua,
-                                       nua_handle_t *nh,
-                                       nta_incoming_t *irq,
-                                       sip_t const *sip);
-
-nua_stack_process_request_t nua_stack_process_invite;
-nua_stack_process_request_t nua_stack_process_info;
-nua_stack_process_request_t nua_stack_process_update;
-nua_stack_process_request_t nua_stack_process_bye;
-nua_stack_process_request_t nua_stack_process_message;
-nua_stack_process_request_t nua_stack_process_options;
-nua_stack_process_request_t nua_stack_process_publish;
-nua_stack_process_request_t nua_stack_process_subscribe;
-nua_stack_process_request_t nua_stack_process_notify;
-nua_stack_process_request_t nua_stack_process_refer;
-nua_stack_process_request_t nua_stack_process_unknown;
-nua_stack_process_request_t nua_stack_process_register;
-nua_stack_process_request_t nua_stack_process_method;
-
-nua_client_request_t
-  *nua_client_request_pending(nua_client_request_t const *),
-  *nua_client_request_restarting(nua_client_request_t const *),
-  *nua_client_request_by_orq(nua_client_request_t const *cr,
-                            nta_outgoing_t const *orq);
-
-nua_server_request_t *nua_server_request(nua_t *nua,
-                                        nua_handle_t *nh,
-                                        nta_incoming_t *irq,
-                                        sip_t const *sip,
-                                        nua_server_request_t *sr,
-                                        size_t size,
-                                        nua_server_respond_f *respond,
-                                        int create_dialog);
-
-int nua_stack_server_event(nua_t *nua,
-                          nua_server_request_t *sr,
-                          nua_event_t event,
-                          tag_type_t tag, tag_value_t value, ...);
-
 /* ---------------------------------------------------------------------- */
 
 #ifndef SDP_MIME_TYPE
@@ -466,15 +410,6 @@ extern char const nua_application_sdp[];
 #define NUTAG_ADD_CONTACT(v) _nutag_add_contact, tag_bool_v(v)
 extern tag_typedef_t _nutag_add_contact;
 
-#define NUTAG_ADD_CONTACT_REF(v) _nutag_add_contact_ref, tag_bool_vr(&v)
-extern tag_typedef_t _nutag_add_contact_ref;
-
-#define NUTAG_COPY(v) _nutag_copy, tag_bool_v(v)
-extern tag_typedef_t _nutag_copy;
-
-#define NUTAG_COPY_REF(v) _nutag_copy_ref, tag_bool_vr(&v)
-extern tag_typedef_t _nutag_copy_ref;
-
 /* ---------------------------------------------------------------------- */
 
 typedef unsigned longlong ull;
index cb26ff966e4a2e9abfb8eb9d2e6e41c567fda314..e33da8cc6e688a3b927abfc4366fe69fabcd4427 100644 (file)
 #include <sofia-sip/string0.h>
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
+#include <sofia-sip/sip_extra.h>
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/su_uniqueid.h>
 
-#define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
-
 #include "nua_stack.h"
 
 /* ---------------------------------------------------------------------- */
 
 struct event_usage
 {
-  enum nua_substate  eu_substate;      /**< Subscription state */
+  enum nua_substate eu_substate;       /**< Subscription state */
   sip_time_t eu_expires;               /**< Proposed expiration time */
   unsigned eu_notified;                        /**< Number of NOTIFYs received */
+  unsigned eu_unsolicited:1;           /**< Not SUBSCRIBEd or REFERed */
+  unsigned eu_refer:1;                 /**< Implied subscription by refer */
   unsigned eu_final_wait:1;            /**< Waiting for final NOTIFY */
   unsigned eu_no_id:1;                 /**< Do not use "id" (even if we have one) */
 };
@@ -105,6 +105,7 @@ int nua_subscribe_usage_add(nua_handle_t *nh,
 {
   ds->ds_has_events++;
   ds->ds_has_subscribes++;
+
   return 0;
 }
 
@@ -167,134 +168,128 @@ void nua_subscribe_usage_remove(nua_handle_t *nh,
  * @sa NUTAG_SUBSTATE(), @RFC3265
  */
 
-static int process_response_to_subscribe(nua_handle_t *nh,
-                                        nta_outgoing_t *orq,
+static int nua_subscribe_client_init(nua_client_request_t *cr, 
+                                    msg_t *, sip_t *,
+                                    tagi_t const *tags);
+static int nua_subscribe_client_request(nua_client_request_t *cr,
+                                       msg_t *, sip_t *,
+                                       tagi_t const *tags);
+static int nua_subscribe_client_response(nua_client_request_t *cr,
+                                        int status, char const *phrase,
                                         sip_t const *sip);
 
+static nua_client_methods_t const nua_subscribe_client_methods = {
+  SIP_METHOD_SUBSCRIBE,
+  0,
+  { 
+    /* create_dialog */ 1,
+    /* in_dialog */ 1,
+    /* target refresh */ 1
+  },
+  NULL,
+  nua_subscribe_client_init,
+  nua_subscribe_client_request,
+  /* nua_subscribe_client_check_restart */ NULL,
+  nua_subscribe_client_response
+};
 
 int
 nua_stack_subscribe(nua_t *nua, nua_handle_t *nh, nua_event_t e,
                    tagi_t const *tags)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  nua_dialog_usage_t *du = NULL;
-  struct event_usage *eu;
-  msg_t *msg;
-  sip_t *sip;
-
-  if (nua_stack_set_handle_special(nh, nh_has_subscribe, nua_r_subscribe) < 0)
-    return UA_EVENT3(e, 500, "Invalid handle for SUBSCRIBE", 
-                    NUTAG_SUBSTATE(nua_substate_terminated));
-  else if (cr->cr_orq)
-    return UA_EVENT2(e, 900, "Request already in progress");
-
-  /* Initialize allow and auth */
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  msg = nua_creq_msg(nua, nh, cr, 0,
-                    SIP_METHOD_SUBSCRIBE,
-                    NUTAG_USE_DIALOG(1),
-                    NUTAG_ADD_CONTACT(1),
-                    TAG_NEXT(tags));
-  sip = sip_object(msg);
-
-  if (sip) {
-    sip_event_t *o = sip->sip_event;
+  return nua_client_create(nh, e, &nua_subscribe_client_methods, tags);
+}
+
+static int nua_subscribe_client_init(nua_client_request_t *cr,
+                                    msg_t *msg, sip_t *sip,
+                                    tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du;
+  sip_event_t *o = sip->sip_event;
 
-    du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, o);
+  du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, o);
 
-    if (du == NULL && o == NULL)
-      du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, NONE);
+  if (du == NULL && o == NULL)
+    du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, NONE);
 
-    eu = nua_dialog_usage_private(du);
+  if (du) {
+    if (du->du_event && o == NULL)
+      /* Add Event header */
+      sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
+  }
+  else if (cr->cr_event == nua_r_subscribe) {  
+    /* Create dialog usage */
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, o);
+    /* Note that we allow SUBSCRIBE without event */
+  }
 
-    if (du && du->du_event && (o == NULL || (o->o_id && eu->eu_no_id))) {
-      if (eu->eu_no_id)                /* No id (XXX - nor other parameters) */
-       sip_add_make(msg, sip, sip_event_class, du->du_event->o_type);
-      else
-       sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
-    }
+  cr->cr_usage = du;
 
-    if (e == nua_r_subscribe) {        
-      if (du == NULL)          /* Create dialog usage */
-       /* We allow here SUBSCRIBE without event */
-       du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, o);
+  return 0;
+}
+
+static int nua_subscribe_client_request(nua_client_request_t *cr,
+                                       msg_t *msg, sip_t *sip,
+                                       tagi_t const *tags)
+{
+  nua_dialog_usage_t *du = cr->cr_usage; 
+  sip_time_t expires = 0;
+
+  if (cr->cr_event != nua_r_subscribe ||
+      (du && du->du_shutdown) ||
+      (sip->sip_expires && sip->sip_expires->ex_delta == 0))
+    cr->cr_terminating = 1;
+
+  if (du) {
+    struct event_usage *eu = nua_dialog_usage_private(du);
+    sip_event_t *o = sip->sip_event;
+
+    if (nua_client_bind(cr, du) < 0)
+      return -1;
+
+    if (eu->eu_no_id && o && o->o_id) {
+      /* Notifier does not handle id properly, remove it */
+      msg_header_remove_param(o->o_common, "id");
     }
-    else if (du) { /* Unsubscribe */
-      /* Embryonic subscription is just a placeholder */
+
+#if 0
+    if (cr->cr_terminating) {
+      /* Already terminated subscription? */
       if (eu->eu_substate == nua_substate_terminated ||
          eu->eu_substate == nua_substate_embryonic) {
-       nua_dialog_usage_remove(nh, nh->nh_ds, du);
-       msg_destroy(msg);
-       return UA_EVENT3(e, SIP_200_OK, 
-                        NUTAG_SUBSTATE(nua_substate_terminated),
-                        TAG_END());
+       return nua_client_return(cr, SIP_200_OK, msg);
       }
     }
-  }
-
-  /* Store message template with supported features (eventlist) */
-  if (du && sip) {
-    if (du->du_msg)
-      msg_destroy(du->du_msg);
-    du->du_msg = msg_ref_create(cr->cr_msg);
-  }
+#endif
 
-  if (du)
-    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                     process_response_to_subscribe, nh, NULL,
-                                     msg,
-                                     TAG_IF(e != nua_r_subscribe,
-                                            SIPTAG_EXPIRES_STR("0")),
-                                     SIPTAG_END(), TAG_NEXT(tags));
-
-  eu = nua_dialog_usage_private(du);
-
-  if (!cr->cr_orq) {
-    int substate = nua_substate_terminated;
-
-    if (du == NULL)
-      ;
-    else if (du->du_ready)
-      substate = eu->eu_substate; /* No change in subscription state  */
+    nua_dialog_usage_reset_refresh(du); /* during SUBSCRIBE transaction */
+    
+    if (cr->cr_terminating)
+      expires = eu->eu_expires = 0;
+    else if (sip->sip_expires)
+      /* Use value specified by application or negotiated with Min-Expires */
+      expires = eu->eu_expires = sip->sip_expires->ex_delta;
     else
-      nua_dialog_usage_remove(nh, nh->nh_ds, du);
-
-    msg_destroy(msg);
-
-    return UA_EVENT3(e, NUA_INTERNAL_ERROR, 
-                    NUTAG_SUBSTATE(substate), TAG_END());
-  }
-
-  nua_dialog_usage_reset_refresh(du); /* during SUBSCRIBE transaction */
-  du->du_terminating = e != nua_r_subscribe; /* Unsubscribe or destroy */
-
-  if (du->du_terminating)
-    eu->eu_expires = 0;
-  else if (sip->sip_expires)
-    eu->eu_expires = sip->sip_expires->ex_delta;
-  else
     /* We just use common default value, but the default is actually
        package-specific according to the RFC 3265 section 4.4.4:
        [Event] packages MUST also define a
        default "Expires" value to be used if none is specified. */
-    eu->eu_expires = 3600;
+      expires = eu->eu_expires = 3600;
 
-  eu->eu_final_wait = 0;
-    
-  if (sip->sip_expires && sip->sip_expires->ex_delta == 0)
-    du->du_terminating = 1;
+    eu->eu_final_wait = 0;
 
-  if (eu->eu_substate == nua_substate_terminated)
-    eu->eu_substate = nua_substate_embryonic;
+    if (eu->eu_substate == nua_substate_terminated)
+      eu->eu_substate = nua_substate_embryonic;
+  }
 
-  cr->cr_usage = du;
-  return cr->cr_event = e;
-}
+  if (!sip->sip_expires || sip->sip_expires->ex_delta != expires) {
+    sip_expires_t ex[1];
+    sip_expires_init(ex)->ex_delta = expires;
+    sip_add_dup(msg, sip, (sip_header_t *)ex);
+  }
 
-static void restart_subscribe(nua_handle_t *nh, tagi_t *tags)
-{
-  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_subscribe, tags);
+  return nua_base_client_request(cr, msg, sip, tags);
 }
 
 /** @NUA_EVENT nua_r_subscribe
@@ -342,51 +337,41 @@ static void restart_subscribe(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_subscribe(nua_handle_t *nh,
-                                        nta_outgoing_t *orq,
+static int nua_subscribe_client_response(nua_client_request_t *cr,
+                                        int status, char const *phrase,
                                         sip_t const *sip)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_handle_t *nh = cr->cr_owner;
   nua_dialog_usage_t *du = cr->cr_usage; 
   struct event_usage *eu = nua_dialog_usage_private(du);
-  int status = sip ? sip->sip_status->st_status : 408;
-  int gracefully = 0;
-  int substate = nua_substate_embryonic;
+  enum nua_substate substate;
 
-  assert(du); assert(du->du_class == nua_subscribe_usage);
-
-  if (status < 200)
-    ;
-  else if (du == NULL) {
-    /* NOTIFY already removed du */
-  }
-  /* We have not received NOTIFY. */
-  else if (status < 300) {
+  if (eu == NULL || cr->cr_terminated)
+    substate = nua_substate_terminated;
+  else if (status >= 300)
+    substate = eu->eu_substate;
+  else {
     int win_messenger_enable = NH_PGET(nh, win_messenger_enable);
     sip_time_t delta, now = sip_now();
 
     du->du_ready = 1;
-    substate = eu->eu_substate;
-    
-    if (du->du_terminating)
-      delta = 0;
-    else
-      /* If there is no expires header,
+
+    if (eu->eu_substate != nua_substate_terminated)
+      /* If there is no @Expires header, 
         use default value stored in eu_expires */
       delta = sip_contact_expires(NULL, sip->sip_expires, sip->sip_date, 
                                  eu->eu_expires, now);
+    else
+      delta = 0;
 
     if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) {
       /* Notify from messanger does not match with dialog tag */ 
       nh->nh_ds->ds_remote_tag = su_strdup(nh->nh_home, "");
     }
 
-    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-
     if (delta > 0) {
       nua_dialog_usage_set_refresh(du, delta);
-    }
+    } 
     else if (!eu->eu_notified) {
       /* This is a fetch: subscription was really terminated
         but we wait 32 seconds for NOTIFY. */
@@ -396,51 +381,26 @@ static int process_response_to_subscribe(nua_handle_t *nh,
        delta = 4 * 60;         /* Wait 4 minutes for NOTIFY from Messenger */
 
       eu->eu_final_wait = 1;
-
-      /* Do not remove usage in nua_stack_process_response  */
-      cr->cr_usage = NULL;     
+       
+      if (eu->eu_substate == nua_substate_terminated)
+       eu->eu_substate = nua_substate_embryonic;
 
       nua_dialog_usage_refresh_range(du, delta, delta);
     }
     else {
-      eu->eu_substate = substate = nua_substate_terminated;
+      eu->eu_substate = nua_substate_terminated;
     }
-  }
-  else /* if (status >= 300) */ {
-    int terminated;
-
-    if (nua_creq_check_restart(nh, cr, orq, sip, restart_subscribe))
-      return 0;
-
-    cr->cr_usage = NULL; /* We take care of removing/not removing usage */
 
     substate = eu->eu_substate;
 
-    if (!sip || !sip->sip_retry_after)
-      gracefully = 1;
-
-    terminated = 
-      sip_response_terminates_dialog(status, sip_method_subscribe, 
-                                    &gracefully);
-
-    /* XXX - zap dialog if terminated < 0 ? */
-
-    if (terminated || !du->du_ready || du->du_terminating) {
-      substate = nua_substate_terminated;
-      nua_dialog_usage_remove(nh, nh->nh_ds, du);
-    }
-    else if (gracefully && substate != nua_substate_terminated) 
-      /* Post un-subscribe event */
-      nua_stack_post_signal(nh, nua_r_unsubscribe, 
-                           SIPTAG_EVENT(du->du_event), 
-                           SIPTAG_EXPIRES_STR("0"),
-                           TAG_END());
+    if (substate == nua_substate_terminated)
+      /* let nua_base_client_tresponse to remove usage */
+      cr->cr_terminated = 1;   
   }
-
-  nua_stack_process_response(nh, cr, orq, sip, 
-                            TAG_IF(substate >= 0, NUTAG_SUBSTATE(substate)),
-                            TAG_END());
-  return 0;
+  
+  return nua_base_client_tresponse(cr, status, phrase, sip, 
+                                  NUTAG_SUBSTATE(substate),
+                                  TAG_END());
 }
 
 /** Refresh subscription */
@@ -449,120 +409,72 @@ static void nua_subscribe_usage_refresh(nua_handle_t *nh,
                                        nua_dialog_usage_t *du,
                                        sip_time_t now)
 {
-  nua_t *nua = nh->nh_nua;
-  nua_client_request_t *cr = ds->ds_cr;
+  nua_client_request_t *cr = du->du_cr;
   struct event_usage *eu = nua_dialog_usage_private(du);
-  msg_t *msg;
-
+  
   assert(eu);
   
   if (eu->eu_final_wait) {
-    /* Did not receive NOTIFY for fetch... */
+    /* Did not receive NOTIFY for fetch */
     sip_event_t const *o = du->du_event;
     char const *id = o ? o->o_id : NULL;
 
-    SU_DEBUG_3(("nua(%p): fetch event %s%s%s timeouts\n",
-               nh, o ? o->o_type : "(empty)",
+    SU_DEBUG_3(("nua(%p): event %s%s%s fetch timeouts\n",
+               (void *)nh, o ? o->o_type : "(empty)",
                id ? "; id=" : "", id ? id : ""));
 
-    nua_stack_event(nh->nh_nua, nh,  NULL,
-                   nua_i_notify, 408, "Fetch Timeouts without NOTIFY", 
-                   NUTAG_SUBSTATE(nua_substate_terminated),
-                   SIPTAG_EVENT(o),
-                   TAG_END());
-
+    nua_stack_tevent(nh->nh_nua, nh,  NULL,
+                    nua_i_notify, 408, "Fetch Timeouts without NOTIFY", 
+                    NUTAG_SUBSTATE(nua_substate_terminated),
+                    SIPTAG_EVENT(du->du_event),
+                    TAG_END());
     nua_dialog_usage_remove(nh, ds, du);
 
     return;
   }
 
-  if (du->du_terminating)      /* No need to refresh. */
-    return;
-
-  if (cr->cr_msg) {
-    /* Already doing something, delay 5..15 seconds? */
-    if (cr->cr_usage != du)
-      nua_dialog_usage_refresh_range(du, 5, 15);
-    return;
+  if (cr) {
+    if (nua_client_resend_request(cr, 0) >= 0)
+      return;
   }
-
-  cr->cr_msg = msg_copy(du->du_msg);
-
-  msg = nua_creq_msg(nua, nh, cr, 1,
-                    SIP_METHOD_SUBSCRIBE,
-                    NUTAG_USE_DIALOG(1),
-                    NUTAG_ADD_CONTACT(1),
-                    /* If dialog is established, remove initial route */
-                    TAG_IF(nua_dialog_is_established(nh->nh_ds),
-                           SIPTAG_ROUTE(NONE)),
-                    TAG_END());
-
-  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                   process_response_to_subscribe, nh, NULL,
-                                   msg,
-                                   SIPTAG_END(), TAG_NEXT(NULL));
-  if (cr->cr_orq) {
-    cr->cr_usage = du;
-    cr->cr_event = nua_r_subscribe;
-    return;
+  else if (eu->eu_refer) {
+    /*
+     * XXX - If we have received a NOTIFY, we should try to terminate
+     * subscription
+     */
   }
 
-  if (du->du_terminating)
-    nua_dialog_usage_remove(nh, nh->nh_ds, du);
-  else   /* Try again later? */
-    nua_dialog_usage_refresh_range(du, 5, 15);
+  if (!eu->eu_unsolicited)
+    nua_stack_tevent(nh->nh_nua, nh, NULL,
+                    nua_i_notify, NUA_INTERNAL_ERROR,
+                    NUTAG_SUBSTATE(nua_substate_terminated),
+                    SIPTAG_EVENT(du->du_event),
+                    TAG_END());
 
-  msg_destroy(msg);
-  UA_EVENT3(nua_r_subscribe, NUA_INTERNAL_ERROR, 
-           NUTAG_SUBSTATE(eu->eu_substate),
-           TAG_END());
+  nua_dialog_usage_remove(nh, ds, du);
 }
 
-
-/** Terminate subscription */
+/** Terminate subscription.
+ *
+ * @retval >0  shutdown done
+ * @retval 0   shutdown in progress
+ * @retval <0  try again later
+ */
 static int nua_subscribe_usage_shutdown(nua_handle_t *nh,
                                        nua_dialog_state_t *ds,
                                        nua_dialog_usage_t *du)
 {
-  nua_t *nua = nh->nh_nua;
-  nua_client_request_t *cr = ds->ds_cr;
   struct event_usage *eu = nua_dialog_usage_private(du);
-  msg_t *msg;
+  nua_client_request_t *cr = du->du_cr;
 
   assert(eu); (void)eu;
 
-  if (du->du_terminating)
-    return 100;                        /* ...in progress */
-  
-  if (cr->cr_msg)
-    /* XXX - already doing something else? */
-    return 100;
-
-  cr->cr_msg = msg_copy(du->du_msg);
-
-  msg = nua_creq_msg(nua, nh, cr, 1,
-                    SIP_METHOD_SUBSCRIBE,
-                    NUTAG_USE_DIALOG(1),
-                    NUTAG_ADD_CONTACT(1),
-                    SIPTAG_EXPIRES_STR("0"),
-                    /* If dialog is established, remove initial route */
-                    TAG_IF(nua_dialog_is_established(nh->nh_ds),
-                           SIPTAG_ROUTE(NONE)),
-                    TAG_END());
-
-  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                   process_response_to_subscribe, nh, NULL,
-                                   msg,
-                                   SIPTAG_END(), TAG_NEXT(NULL));
-  if (cr->cr_orq) {
-    cr->cr_usage = du;
-    cr->cr_event = nua_r_destroy;
-    return 100;
+  if (cr) {
+    if (nua_client_resend_request(cr, 1) >= 0)
+      return 0;
   }
-
-  /* Too bad. */
+  
   nua_dialog_usage_remove(nh, ds, du);
-  msg_destroy(msg);
   return 200;
 }
 
@@ -585,178 +497,195 @@ static int nua_subscribe_usage_shutdown(nua_handle_t *nh,
  * @END_NUA_EVENT
  */
 
-/** @internal Process incoming NOTIFY. */
-int nua_stack_process_notify(nua_t *nua,
-                            nua_handle_t *nh,
-                            nta_incoming_t *irq,
-                            sip_t const *sip)
-{
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_dialog_usage_t *du;
-  struct event_usage *eu;
-  sip_subscription_state_t *subs = sip ? sip->sip_subscription_state : NULL;
-  sip_subscription_state_t ss0[1];
-  msg_t *response;
-  char expires[32];
-  int retry = -1;
-  char const *what = NULL, *why = NULL;
+int nua_notify_server_init(nua_server_request_t *sr);
+int nua_notify_server_preprocess(nua_server_request_t *sr);
+int nua_notify_server_report(nua_server_request_t *, tagi_t const *);
 
-  enter;
+nua_server_methods_t const nua_notify_server_methods = 
+  {
+    SIP_METHOD_NOTIFY,
+    nua_i_notify,              /* Event */
+    { 
+      /* create_dialog: */ 1,  /* Do create dialog */
+      /* in_dialog: */ 0,      /* Not always in-dialog request */
+      /* target_refresh: */ 1, /* Target refresh request  */
+      /* add_contact: */ 1,    /* Add Contact to response */
+    },
+    nua_notify_server_init,
+    nua_notify_server_preprocess,
+    nua_base_server_params,
+    nua_base_server_respond,
+    nua_notify_server_report,
+  };
+
+
+int nua_notify_server_init(nua_server_request_t *sr)
+{
+  if (!sr->sr_initial) {
+    nua_dialog_state_t *ds = sr->sr_owner->nh_ds;
+
+    /* Check for forked subscription. */
+    if (ds->ds_remote_tag && ds->ds_remote_tag[0] && 
+       str0cmp(ds->ds_remote_tag, sr->sr_request.sip->sip_from->a_tag)) {
+      sip_contact_t const *m = NULL;
+
+      m = nua_stack_get_contact(sr->sr_owner->nh_nua->nua_registrations);
+      
+      if (m) {
+       sip_warning_t w[1];
+       
+       sip_warning_init(w)->w_code = 399;
+       w->w_host = m->m_url->url_host;
+       w->w_port = m->m_url->url_port;
+       w->w_text = "Forking SUBSCRIBEs are not supported";
+
+       sip_add_dup(sr->sr_response.msg, NULL, (sip_header_t*)w);
+      }
 
-  if (nh == NULL) {
-    nta_incoming_treply(irq, 481, "Subscription Does Not Exist", 
-                       TAG_END());
-    return 481;
-  }
-  assert(nh);
-
-  if (/* XXX - support forking of subscriptions?... */
-      ds->ds_remote_tag && ds->ds_remote_tag[0] && 
-      sip && sip->sip_from->a_tag &&
-      strcmp(ds->ds_remote_tag, sip->sip_from->a_tag)) {
-    sip_contact_t const *m = NULL;
-    sip_warning_t *w = NULL, w0[1];
-
-    m = nua_stack_get_contact(nua->nua_registrations);
-    if (m) {
-      w = sip_warning_init(w0);
-      w->w_code = 399;
-      w->w_host = m->m_url->url_host;
-      w->w_port = m->m_url->url_port;
-      w->w_text = "Forking SUBSCRIBEs are not supported";
+      return SR_STATUS(sr, 481, "Subscription Does Not Exist");
     }
-
-    nta_incoming_treply(irq, 481, "Subscription Does Not Exist", 
-                       SIPTAG_WARNING(w),
-                       TAG_END());
-    return 481;
   }
 
-  du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, sip->sip_event);
+  return 0;
+}
+
+int nua_notify_server_preprocess(nua_server_request_t *sr)
+{
+  nua_dialog_state_t *ds = sr->sr_owner->nh_ds;
+  nua_dialog_usage_t *du;
+  struct event_usage *eu;
+  sip_t const *sip = sr->sr_request.sip;
+  sip_event_t *o = sip->sip_event;
+  enum nua_substate substate = nua_substate_terminated;
+  sip_subscription_state_t *subs = sip->sip_subscription_state;
+  char const *what = "", *reason = NULL;
+  int solicited = 1;
+
+  du = nua_dialog_usage_get(ds, nua_subscribe_usage, o);
 
   if (du == NULL) {
-    nta_incoming_treply(irq, 481, "Subscription Does Not Exist", TAG_END());
-    return 481;
-  }
+    if (!sip_is_allowed(NH_PGET(sr->sr_owner, appl_method), SIP_METHOD_NOTIFY))
+      return SR_STATUS(sr, 481, "Subscription Does Not Exist");
 
+    solicited = 0;    /* Let application to handle unsolicited NOTIFY */
+    du = nua_dialog_usage_add(sr->sr_owner, ds, nua_subscribe_usage, o);
+    if (!du)
+      return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
+  
+  sr->sr_usage = du;
   eu = nua_dialog_usage_private(du); assert(eu);
   eu->eu_notified++;
-
-  if (!sip->sip_event->o_id) {
+  if (!o->o_id) 
     eu->eu_no_id = 1;
-  }
 
   if (subs == NULL) {
-    /* Do some compatibility stuff here */
-    unsigned long delta;
-
-    sip_subscription_state_init(subs = ss0);
-
-    delta = sip->sip_expires ? sip->sip_expires->ex_delta : eu->eu_expires;
+    /* Compatibility */
+    unsigned long delta = eu->eu_expires;
+    if (sip->sip_expires) 
+      delta = sip->sip_expires->ex_delta;
 
     if (delta == 0)
-      subs->ss_substate = "terminated";
+      substate = nua_substate_terminated, what = "terminated";
     else
-      subs->ss_substate = "active";
+      substate = nua_substate_active, what = "active";
+  }
+  else if (strcasecmp(subs->ss_substate, what = "terminated") == 0) {
+    substate = nua_substate_terminated;
+    reason = subs->ss_reason;
 
-    if (delta > 0 && sip->sip_expires) {
-      snprintf(expires, sizeof expires, "%lu", delta);
-      subs->ss_expires = expires;
-    }
+    if (str0casecmp(reason, "deactivated") == 0 ||
+       str0casecmp(reason, "probation") == 0) 
+      substate = nua_substate_embryonic;
+  }
+  else if (strcasecmp(subs->ss_substate, what = "pending") == 0) {
+    substate = nua_substate_pending;
+  }
+  else /* if (strcasecmp(subs->ss_substate, what = "active") == 0) */ {
+    /* Any extended state is considered as active */
+    what = subs->ss_substate;
+    substate = nua_substate_active;
   }
 
-  nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-  nua_dialog_uas_route(nh, nh->nh_ds, sip, 1);
+  eu->eu_substate = substate;
+  if (!solicited)
+    eu->eu_unsolicited = 1;
 
-  if (strcasecmp(subs->ss_substate, what = "terminated") == 0) {
-    eu->eu_substate = nua_substate_terminated;
+  SU_DEBUG_5(("nua(%p): %s: %s (%s)\n", 
+             (void *)sr->sr_owner, "nua_notify_server_preprocess",
+             what, reason ? reason : ""));
 
-    if (str0casecmp(subs->ss_reason, why = "deactivated") == 0) {
-      eu->eu_substate = nua_substate_embryonic;
-      retry = 0;               /* retry immediately */
-    } 
-    else if (str0casecmp(subs->ss_reason, why = "probation") == 0) {
-      eu->eu_substate = nua_substate_embryonic;
-      retry = 30;
-      if (subs->ss_retry_after)
-       retry = strtoul(subs->ss_retry_after, NULL, 10);
-      if (retry > 3600)
-       retry = 3600;
+  if (solicited)
+    return SR_STATUS1(sr, SIP_200_OK);
+
+  return 0;
+}
+
+
+int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_usage_t *du = sr->sr_usage;
+  struct event_usage *eu = nua_dialog_usage_private(du);
+  sip_t const *sip = sr->sr_request.sip;
+  enum nua_substate substate = nua_substate_terminated;
+  sip_time_t delta = SIP_TIME_MAX;
+  int retry = -1;
+  int retval;
+
+  if (eu) {
+    sip_subscription_state_t *subs = sip->sip_subscription_state;
+
+    substate = eu->eu_substate;
+
+    if (substate == nua_substate_active || substate == nua_substate_pending) {
+      if (subs && subs->ss_expires)
+       delta = strtoul(subs->ss_expires, NULL, 10);
+      else
+       delta = eu->eu_expires;
+    }
+    else if (substate == nua_substate_embryonic) {
+      if (subs && subs->ss_reason) {
+       if (str0casecmp(subs->ss_reason, "deactivated") == 0) {
+         retry = 0;            /* retry immediately */
+       } 
+       else if (str0casecmp(subs->ss_reason, "probation") == 0) {
+         retry = 30;
+         if (subs->ss_retry_after)
+           retry = strtoul(subs->ss_retry_after, NULL, 10);
+         if (retry > 3600)
+           retry = 3600;
+       }
+      }
+    }
+    else if (substate == nua_substate_terminated) {
+      sr->sr_terminating = 1;
     }
-    else
-      why = subs->ss_reason;
-  }
-  else if (strcasecmp(subs->ss_substate, what = "pending") == 0)
-    eu->eu_substate = nua_substate_pending;
-  else /* if (strcasecmp(subs->ss_substate, "active") == 0) */ {
-    /* Any extended state is considered as active */
-    what = subs->ss_substate ? subs->ss_substate : "active";
-    eu->eu_substate = nua_substate_active;
   }
-
-  if (du->du_terminating)
-    retry = -1;
   
-  response = nh_make_response(nua, nh, irq, SIP_200_OK,
-                             SIPTAG_ALLOW(NH_PGET(nh, allow)),
-                             SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
-                             TAG_END());
-
-  if (response && 
-      nua_registration_add_contact_to_response(nh, response, NULL, 
-                                              sip->sip_record_route,
-                                              sip->sip_contact) >= 0)
-    nta_incoming_mreply(irq, response);
-  else
-    nta_incoming_treply(irq, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
-
-  if (eu->eu_substate == nua_substate_terminated && retry > 0)
-    eu->eu_substate = nua_substate_embryonic;
-
-  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
-                 nua_i_notify, SIP_200_OK, 
-                 NUTAG_SUBSTATE(eu->eu_substate),
-                 TAG_END());
-
-  nta_incoming_destroy(irq), irq = NULL;
-
-  SU_DEBUG_5(("nua(%p): nua_stack_process_notify: %s (%s)\n", 
-             nh, what, why ? why : ""));
-
-  if (eu->eu_substate == nua_substate_terminated) {
-    if (du != nh->nh_ds->ds_cr->cr_usage)
-      nua_dialog_usage_remove(nh, nh->nh_ds, du);
-    else
-      nua_dialog_usage_reset_refresh(du);
-  }
-  else if (eu->eu_substate == nua_substate_embryonic) {
-    if (retry >= 0) {
-      /* Try to subscribe again */
-      nua_dialog_remove(nh, nh->nh_ds, du); /* tear down */
-      nua_dialog_usage_refresh_range(du, retry, retry + 5);
-    }
-    else if (du != nh->nh_ds->ds_cr->cr_usage)
-      nua_dialog_usage_remove(nh, nh->nh_ds, du);
-    else
-      nua_dialog_usage_reset_refresh(du);
+  retval = nua_base_server_treport(sr, /* can destroy sr */
+                                  NUTAG_SUBSTATE(substate),
+                                  TAG_NEXT(tags)); 
+
+  if (retval != 1 || du == NULL)
+    return retval;
+
+  if (eu->eu_unsolicited) {
+    /* Xyzzy */;
   }
-  else if (du->du_terminating) {
-    nua_dialog_usage_reset_refresh(du);
+  else if (retry >= 0) {               /* Try to subscribe again */
+    /* XXX - this needs through testing */
+    nua_dialog_remove(nh, nh->nh_ds, du); /* tear down */
+    nua_dialog_usage_refresh_range(du, retry, retry + 5);
   }
   else {
-    sip_time_t delta;
-
-    if (subs->ss_expires)
-      delta = strtoul(subs->ss_expires, NULL, 10);
-    else
-      delta = eu->eu_expires;
-    
     nua_dialog_usage_set_refresh(du, delta);
   }
 
-  return 0;
+  return retval;
 }
 
+
 /* ======================================================================== */
 /* REFER */
 
@@ -802,81 +731,6 @@ int nua_stack_process_notify(nua_t *nua,
  * @RFC3515, @ReferTo, @RFC3892, @ReferredBy
  */
 
-static int process_response_to_refer(nua_handle_t *nh,
-                                    nta_outgoing_t *orq,
-                                    sip_t const *sip);
-
-int
-nua_stack_refer(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
-{
-  nua_dialog_usage_t *du = NULL;
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  msg_t *msg;
-  sip_t *sip;
-  sip_referred_by_t by[1];
-  sip_event_t *event = NULL;
-
-  if (nua_stack_set_handle_special(nh, nh_has_subscribe, nua_r_subscribe) < 0)
-    return UA_EVENT2(e, 900, "Invalid handle for REFER");
-  else if (cr->cr_orq)
-    return UA_EVENT2(e, 900, "Request already in progress");
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
-
-  sip_referred_by_init(by);
-  by->b_display = nua->nua_from->a_display;
-  *by->b_url = *nua->nua_from->a_url;
-
-  /* Now we create a REFER request message */
-  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
-                        SIP_METHOD_REFER,
-                        NUTAG_USE_DIALOG(1),
-                        SIPTAG_EVENT(SIP_NONE), /* remove event */
-                        SIPTAG_REFERRED_BY(by), /* Overriden by user tags */
-                        NUTAG_ADD_CONTACT(1),
-                        TAG_NEXT(tags));
-  sip = sip_object(msg);
-
-  if (sip && sip->sip_cseq)
-    event = sip_event_format(nh->nh_home, "refer;id=%u", 
-                            sip->sip_cseq->cs_seq);
-
-  if (event)
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, event);
-  
-  if (du)
-    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
-                                     process_response_to_refer, nh, NULL,
-                                     msg,
-                                     SIPTAG_END(), TAG_NEXT(tags));
-  
-  if (!cr->cr_orq) {
-    if (du)
-      nua_dialog_usage_remove(nh, nh->nh_ds, du);
-    su_free(nh->nh_home, event);
-    msg_destroy(msg);
-    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
-  }
-
-  /*
-   * We send a 100 trying event so that application gets a event 
-   * it can use to match NOTIFYs with its REFER
-   */
-  nua_stack_event(nua, nh, NULL, e, SIP_100_TRYING, 
-          NUTAG_REFER_EVENT(event),
-          TAG_END());
-  su_free(nh->nh_home, event);
-
-  cr->cr_usage = du;
-
-  return cr->cr_event = e;
-}
-
-void restart_refer(nua_handle_t *nh, tagi_t *tags)
-{
-  nua_stack_refer(nh->nh_nua, nh, nh->nh_ds->ds_cr->cr_event, tags);
-}
-
 /**@NUA_EVENT nua_r_refer
  *
  * @brief Response to outgoing REFER.
@@ -900,27 +754,130 @@ void restart_refer(nua_handle_t *nh, tagi_t *tags)
  * @END_NUA_EVENT
  */
 
-static int process_response_to_refer(nua_handle_t *nh,
-                                    nta_outgoing_t *orq,
-                                    sip_t const *sip)
+static int nua_refer_client_init(nua_client_request_t *cr, 
+                                msg_t *, sip_t *,
+                                tagi_t const *tags);
+static int nua_refer_client_request(nua_client_request_t *cr,
+                                   msg_t *, sip_t *,
+                                   tagi_t const *tags);
+static int nua_refer_client_response(nua_client_request_t *cr,
+                                    int status, char const *phrase,
+                                    sip_t const *sip);
+
+static nua_client_methods_t const nua_refer_client_methods = {
+  SIP_METHOD_REFER,
+  0,
+  { 
+    /* create_dialog */ 1,
+    /* in_dialog */ 1,
+    /* target refresh */ 1
+  },
+  /*nua_refer_client_template*/ NULL,
+  nua_refer_client_init,
+  nua_refer_client_request,
+  /* nua_refer_client_check_restart */ NULL,
+  nua_refer_client_response,
+  nua_refer_client_response,   /* Preliminary */
+  NULL
+};
+
+int
+nua_stack_refer(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+                   tagi_t const *tags)
 {
-  nua_client_request_t *cr = nh->nh_ds->ds_cr;
-  int status = sip ? sip->sip_status->st_status : 408;
-
-  if (status < 200)
-    ;
-  else if (status < 300) {
-    if (cr->cr_usage)
-      cr->cr_usage->du_ready = 1;
-    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+  return nua_client_create(nh, e, &nua_refer_client_methods, tags);
+}
+
+static int nua_refer_client_init(nua_client_request_t *cr,
+                                msg_t *msg, sip_t *sip,
+                                tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+
+  if (sip->sip_referred_by == NULL) {
+    sip_from_t *a = sip->sip_from;
+    sip_referred_by_t by[1];
+
+    sip_referred_by_init(by);
+
+    if (a == NULL)
+      a = nh->nh_nua->nua_from;
+    by->b_display = a->a_display;
+    *by->b_url = *a->a_url;
+
+    sip_add_dup(msg, sip, (sip_header_t *)by);
   }
-  else /* if (status >= 300) */ {
-    if (cr->cr_usage)
-      nua_dialog_usage_remove(nh, nh->nh_ds, cr->cr_usage), cr->cr_usage = NULL;
-    if (nua_creq_check_restart(nh, cr, orq, sip, restart_refer))
-      return 0;
+
+  if (sip->sip_event)
+    sip_header_remove(msg, sip, (sip_header_t *)sip->sip_event);
+
+  return 0;
+}
+
+static int nua_refer_client_request(nua_client_request_t *cr,
+                                   msg_t *msg, sip_t *sip,
+                                   tagi_t const *tags)
+{
+  nua_handle_t *nh = cr->cr_owner;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  struct event_usage *eu;
+  sip_event_t *event;
+  int error;
+
+  cr->cr_usage = NULL;
+
+  if (du)
+    nua_dialog_usage_remove(nh, nh->nh_ds, du);
+
+  event = sip_event_format(nh->nh_home, "refer;id=%u", sip->sip_cseq->cs_seq);
+  if (!event)
+    return -1;
+  du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, event);
+  if (!du)
+    return -1;
+
+  eu = nua_dialog_usage_private(cr->cr_usage = du);
+  eu ->eu_refer = 1;
+
+  error = nua_base_client_request(cr, msg, sip, tags);
+
+  if (!error) {
+    /* Give application an Event header for matching NOTIFYs with REFER */
+    nua_stack_tevent(nh->nh_nua, nh, NULL,
+                    cr->cr_event, SIP_100_TRYING,
+                    NUTAG_REFER_EVENT(event),
+                    TAG_END());
+    su_free(nh->nh_home, event);
   }
 
-  return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+  return error;
+}
+
+static int nua_refer_client_response(nua_client_request_t *cr,
+                                    int status, char const *phrase,
+                                    sip_t const *sip)
+{
+  nua_dialog_usage_t *du = cr->cr_usage; 
+  enum nua_substate substate = nua_substate_terminated;
+
+  if (du) {
+    struct event_usage *eu = nua_dialog_usage_private(du);
+
+    if (status < 200) {
+      substate = eu->eu_substate;      
+    } 
+    else if (status < 300) {
+      sip_refer_sub_t const *rs = sip_refer_sub(sip);
+
+      if (rs && strcasecmp("false", rs->rs_value) == 0)
+       cr->cr_terminated = 1;
+
+      if (!cr->cr_terminated)
+       substate = eu->eu_substate;
+    }
+  }
+  
+  return nua_base_client_tresponse(cr, status, phrase, sip, 
+                                  NUTAG_SUBSTATE(substate),
+                                  TAG_END());
 }
index b900f666e0560dac38aad704e85c72c99fd578b2..c320348bf1f19cae50a6e6590ccc0e1b5bc6f118 100644 (file)
@@ -68,6 +68,7 @@ tag_typedef_t nutag_answer_recv = BOOLTAG_TYPEDEF(answer_recv);
 tag_typedef_t nutag_offer_sent = BOOLTAG_TYPEDEF(offer_sent);
 tag_typedef_t nutag_answer_sent = BOOLTAG_TYPEDEF(answer_sent);
 tag_typedef_t nutag_substate = INTTAG_TYPEDEF(substate);
+tag_typedef_t nutag_newsub = BOOLTAG_TYPEDEF(newsub);
 tag_typedef_t nutag_invite_timer = UINTTAG_TYPEDEF(invite_timer);
 tag_typedef_t nutag_session_timer = UINTTAG_TYPEDEF(session_timer);
 tag_typedef_t nutag_min_se = UINTTAG_TYPEDEF(min_se);
@@ -143,10 +144,9 @@ tag_typedef_t nutag_supported = STRTAG_TYPEDEF(supported);
 tag_typedef_t nutag_path_enable = BOOLTAG_TYPEDEF(path_enable);
 tag_typedef_t nutag_service_route_enable = 
   BOOLTAG_TYPEDEF(service_route_enable);
+tag_typedef_t nutag_auth_cache = INTTAG_TYPEDEF(auth_cache);
 
 tag_typedef_t nutag_detect_network_updates = UINTTAG_TYPEDEF(detect_network_updates);
 
 tag_typedef_t nutag_with = PTRTAG_TYPEDEF(with);
-
-tag_typedef_t _nutag_add_contact = BOOLTAG_TYPEDEF(add_contact);
-tag_typedef_t _nutag_copy = BOOLTAG_TYPEDEF(copy);
+tag_typedef_t nutag_dialog = UINTTAG_TYPEDEF(dialog);
index eb86716cbe963936e60656fac580cd651d64c6c4..526cdf381043d4f7fed00ab5cb6d03e1d104c03f 100644 (file)
@@ -117,7 +117,6 @@ struct outbound {
 
   char const *ob_instance;     /**< Our instance ID */
   int32_t ob_reg_id;           /**< Flow-id */
-  char const *ob_features;     /**< Feature parameters for rcontact */
   sip_contact_t *ob_rcontact;  /**< Our contact */
   sip_contact_t *ob_dcontact;  /**< Contact for dialogs */
   sip_contact_t *ob_previous;  /**< Stale contact */
@@ -294,7 +293,8 @@ int outbound_set_options(outbound_t *ob,
     else if (MATCH(use-upnp) || MATCH(use_upnp)) prefs->use_upnp = value;
     else if (MATCH(use-stun) || MATCH(use_stun)) prefs->use_stun = value;
     else
-      SU_DEBUG_1(("outbound_t: unknown option \"%.*s\"\n", (int)len, s));
+      SU_DEBUG_1(("outbound(%p): unknown option \"%.*s\"\n",
+                 (void *)ob->ob_owner, (int)len, s));
 
     s += len;
     len = strspn(s, " \t\n\r,;");
@@ -304,7 +304,8 @@ int outbound_set_options(outbound_t *ob,
   }
 
   if (s && s[0]) {
-    SU_DEBUG_1(("outbound_t: invalid options \"%s\"\n", options));
+    SU_DEBUG_1(("outbound(%p): invalid options \"%s\"\n", 
+               (void *)ob->ob_owner, options));
     return -1;
   }
 
@@ -315,7 +316,8 @@ int outbound_set_options(outbound_t *ob,
        prefs->use_socks ||
        prefs->use_upnp ||
        prefs->use_stun)) {
-    SU_DEBUG_1(("outbound(%p): no nat traversal method given\n", ob->ob_owner));
+    SU_DEBUG_1(("outbound(%p): no nat traversal method given\n",
+               (void *)ob->ob_owner));
   }
 
   ob->ob_prefs = *prefs;
@@ -324,60 +326,27 @@ int outbound_set_options(outbound_t *ob,
   return 0;
 }
 
-/** Set the feature string (added to the Contact header when registering). */
-int outbound_set_features(outbound_t *ob, char *features)
-{
-  char *old_features = (char *)ob->ob_features;
-  char *new_features = su_strdup(ob->ob_home, features);
-
-  if (features && !new_features)
-    return -1;
-
-  ob->ob_features = new_features;
-  su_free(ob->ob_home, old_features);
-  return 0;
-}
-
 /* ---------------------------------------------------------------------- */
 
-/** Hook for sending register request with extra outbound-ish headers. */
-nta_outgoing_t *outbound_register_request(outbound_t *ob, int terminating, 
-                                         sip_contact_t *stack_contact,
-                                         nta_agent_t *nta,
-                                         nta_response_f *callback,
-                                         nta_outgoing_magic_t *magic,
-                                         url_string_t *next_hop,
-                                         msg_t *msg,
-                                         tag_type_t tag, tag_value_t value,
-                                         ...)
+/** Obtain contacts for REGISTER */
+int outbound_get_contacts(outbound_t *ob, 
+                         sip_contact_t **return_current_contact, 
+                         sip_contact_t **return_previous_contact)
 {
-  sip_contact_t *previous_contact = NULL;
-  ta_list ta;
-  nta_outgoing_t *orq;
-
-  if (stack_contact) {
-    if (ob) {
-      if (ob->ob_contacts)
-       stack_contact = ob->ob_rcontact;
-      previous_contact = ob->ob_previous;
-    }
+  if (ob) {
+    if (ob->ob_contacts)
+      *return_current_contact = ob->ob_rcontact;
+    *return_previous_contact = ob->ob_previous;
   }
+  return 0;
+}
 
-  ta_start(ta, tag, value);
-
-  orq = nta_outgoing_mcreate(nta, callback, magic, next_hop, msg,
-                            TAG_IF(previous_contact,
-                                   SIPTAG_CONTACT(previous_contact)),
-                            TAG_IF(stack_contact,
-                                   SIPTAG_CONTACT(stack_contact)),
-                            ta_tags(ta));
-
-  ta_end(ta);
-
-  if (orq && ob)
+/** REGISTER request has been sent */
+int outbound_start_registering(outbound_t *ob)
+{
+  if (ob)
     ob->ob_registering = 1;
-
-  return orq;
+  return 0;
 }
 
 /** Process response to REGISTER request */
@@ -391,17 +360,16 @@ int outbound_register_response(outbound_t *ob,
   if (!ob)
     return 0;
 
-  assert(!request || request->sip_request);
-  assert(!response || response->sip_status);
-  
-  if (!response || !request)
-    return 0;
-
   if (terminating) {
-    ob->ob_registered = ob->ob_registering = 0;
+    ob->ob_registering = ob->ob_registered = 0;
     return 0;                  /* Cleanup is done separately */
   }  
 
+  if (!response || !request)
+    return 0;
+
+  assert(request->sip_request); assert(response->sip_status);
+  
   reregister = outbound_check_for_nat(ob, request, response);
   if (reregister)
     return reregister;
@@ -423,7 +391,13 @@ int outbound_register_response(outbound_t *ob,
 }
 
 
-/** @internal Check if there is a NAT between us and registrar */
+/** @internal Check if there is a NAT between us and registrar.
+ *
+ * @retval -1 upon an error
+ * @retval #ob_register_ok (0) if the registration was OK
+ * @retval #ob_reregister (1) if client needs to re-register
+ * @retval #ob_reregister_now (2) if client needs to re-register immediately
+ */
 static
 int outbound_check_for_nat(outbound_t *ob,
                           sip_t const *request,
@@ -457,18 +431,18 @@ int outbound_check_for_nat(outbound_t *ob,
   if (!m || binding_changed >= ob_nat_changed) {
     if (ob->ob_stun) {
       /* Use STUN? */
-      return 1;
+      return ob_reregister;
     }
     else if (ob->ob_upnp) {
       /* Use UPnP */
-      return 1;
+      return ob_reregister;
     }
     else {
       if (outbound_contacts_from_via(ob, response->sip_via) < 0)
         return -1;
     }
 
-    return 2;
+    return ob_reregister_now;
   }
 
   return 0;
@@ -512,7 +486,7 @@ int outbound_nat_detect(outbound_t *ob,
   if (!host_is_ip_address(received)) {
     if (received[0])
       SU_DEBUG_3(("outbound(%p): Via with invalid received=%s\n",
-                 ob->ob_owner, received));
+                 (void *)ob->ob_owner, received));
     return 0;
   }
 
@@ -530,14 +504,14 @@ int outbound_nat_detect(outbound_t *ob,
 
   if (!nat_detected) {
     SU_DEBUG_1(("outbound(%p): detected NAT: %s != %s\n",
-               ob->ob_owner, v->v_host, received));
+               (void *)ob->ob_owner, v->v_host, received));
     if (ob->ob_oo && ob->ob_oo->oo_status)
       ob->ob_oo->oo_status(ob->ob_owner, ob, 101, "NAT detected", TAG_END());
   }
   else {
     SU_DEBUG_1(("outbound(%p): NAT binding changed: "
                "[%s]:%s != [%s]:%s\n",
-               ob->ob_owner, nat_detected, nat_port, received, rport));
+               (void *)ob->ob_owner, nat_detected, nat_port, received, rport));
     if (ob->ob_oo && ob->ob_oo->oo_status)
       ob->ob_oo->oo_status(ob->ob_owner, ob, 102, "NAT binding changed", TAG_END());
   }
@@ -709,21 +683,32 @@ static int create_keepalive_message(outbound_t *ob, sip_t const *regsip)
 {
   msg_t *msg = nta_msg_create(ob->ob_nta, MSG_FLG_COMPACT), *previous;
   sip_t *osip = sip_object(msg);
-  sip_accept_contact_t *ac;
-
-  char const *p1 = ob->ob_instance;
-  char const *p2 = ob->ob_features;
+  sip_contact_t *m = ob->ob_rcontact;
 
   unsigned d = ob->ob_keepalive.interval;
 
   assert(regsip); assert(regsip->sip_request);
 
-  if (p1 || p2) {
-    ac = sip_accept_contact_format(msg_home(msg), "*;require;explicit;%s%s%s",
-                                  p1 ? p1 : "",
-                                  p2 && p2 ? ";" : "",
-                                  p2 ? p2 : "");
-    msg_header_insert(msg, NULL, (void *)ac);
+  if (m && m->m_params) {
+    sip_accept_contact_t *ac;
+    size_t i;
+    int features = 0;
+
+    ac = sip_accept_contact_make(msg_home(msg), "*;require;explicit");
+
+    for (i = 0; m->m_params[i]; i++) {
+      char const *s = m->m_params[i];
+      if (!sip_is_callerpref(s))
+       continue;
+      features++;
+      s = su_strdup(msg_home(msg), s);
+      msg_header_add_param(msg_home(msg), ac->cp_common, s);
+    }
+    
+    if (features)
+      msg_header_insert(msg, NULL, (void *)ac);
+    else
+      msg_header_free(msg_home(msg), (void *)ac);
   }
 
   if (0 >
@@ -877,18 +862,19 @@ static int response_to_keepalive_options(outbound_t *ob,
     if (loglevel >= SU_LOG->log_level) {
       su_llog(SU_LOG, loglevel,       
              "outbound(%p): %s <" URL_PRINT_FORMAT ">\n",
-             ob->ob_owner, failed ? "FAILED to validate" : "validated", 
+             (void *)ob->ob_owner,
+             failed ? "FAILED to validate" : "validated",
              URL_PRINT_ARGS(ob->ob_rcontact->m_url));
       if (failed)
        su_llog(SU_LOG, loglevel, "outbound(%p): FAILED with %u %s\n", 
-               ob->ob_owner, status, phrase);
+               (void *)ob->ob_owner, status, phrase);
     }
 
     if (failed) 
       ob->ob_oo->oo_probe_error(ob->ob_owner, ob, status, phrase, TAG_END());
   }
   else if (status == 408) {
-    SU_DEBUG_1(("outbound(%p): keepalive timeout\n", ob->ob_owner));
+    SU_DEBUG_1(("outbound(%p): keepalive timeout\n", (void *)ob->ob_owner));
     ob->ob_oo->oo_keepalive_error(ob->ob_owner, ob, status, phrase, TAG_END());
     return 0;
   }
@@ -982,7 +968,7 @@ int outbound_process_request(outbound_t *ob,
 
   if (ob->ob_keepalive.validating) {
     SU_DEBUG_1(("outbound(%p): registration check OPTIONS received\n", 
-               ob->ob_owner));
+               (void *)ob->ob_owner));
     ob->ob_keepalive.validated = 1;
   }
 
@@ -1018,48 +1004,16 @@ int outbound_contacts_from_via(outbound_t *ob, sip_via_t const *via)
 
   v = v0; *v0 = *via; v0->v_next = NULL;
 
-  dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
+  dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 1,
                                   NULL, v, v->v_protocol, NULL);
 
   if (ob->ob_instance && ob->ob_reg_id != 0)
     snprintf(reg_id_param, sizeof reg_id_param, ";reg-id=%u", ob->ob_reg_id);
 
-  rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
+  rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 0,
                                   NULL, v, v->v_protocol, 
-                                  ob->ob_features ? ob->ob_features : "",
                                   ob->ob_instance, reg_id_param, NULL);
     
-#if 0
-  char *uri;
-
-  /* uri contains < > */
-  uri = sip_contact_string_from_via(NULL, via, NULL, v->v_protocol);
-
-  dcontact = sip_contact_make(home, uri);
-
-
-
-  if (ob->ob_instance) {
-    char reg_id[20];
-
-    if (ob->ob_instance && ob->ob_reg_id)
-      snprintf(reg_id, sizeof reg_id, ";reg-id=%u", ob->ob_reg_id);
-    else
-      strcpy(reg_id, "");
-
-    rcontact = sip_contact_format(home, "%s;%s%s%s%s",
-                                 uri, ob->ob_instance, reg_id,
-                                 ob->ob_features ? ";" : "",
-                                 ob->ob_features ? ob->ob_features : "");
-  }
-  else if (ob->ob_features)
-    rcontact = sip_contact_format(home, "%s;%s", uri, ob->ob_features);
-  else
-    rcontact = dcontact;
-
-  free(uri);
-#endif
-
   v = sip_via_dup(home, v);
 
   if (!rcontact || !dcontact || !v) {
@@ -1137,6 +1091,9 @@ int outbound_set_contact(outbound_t *ob,
   m3 = ob->ob_previous;
 
   if (terminating) {
+    if (ob->ob_by_stack && application_contact == NULL)
+      return 0;
+    
     if (ob->ob_contacts)
       previous = ob->ob_rcontact;
   }
@@ -1147,11 +1104,14 @@ int outbound_set_contact(outbound_t *ob,
       previous = ob->ob_contacts ? ob->ob_rcontact : NULL;
     }
   }
+  else if (ob->ob_by_stack) {
+    return 0;    /* Xyzzy - nothing happens */
+  }
   else if (v) {
     char const *tport = !v->v_next ? v->v_protocol : NULL; 
     char reg_id_param[20];
 
-    dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
+    dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 1, 
                                     NULL, v, tport, NULL);
     if (!dcontact)
       return -1;
@@ -1159,9 +1119,8 @@ int outbound_set_contact(outbound_t *ob,
     if (ob->ob_instance && ob->ob_reg_id != 0)
       snprintf(reg_id_param, sizeof reg_id_param, ";reg-id=%u", ob->ob_reg_id);
 
-    rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
+    rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 0,
                                     NULL, v, v->v_protocol, 
-                                    ob->ob_features ? ob->ob_features : "",
                                     ob->ob_instance, reg_id_param, NULL);
     if (!rcontact)
       return -1;
@@ -1172,9 +1131,11 @@ int outbound_set_contact(outbound_t *ob,
       previous = ob->ob_contacts ? ob->ob_rcontact : NULL;
     }
   }
-
+    
   ob->ob_by_stack = application_contact == NULL;
 
+  ob->ob_contacts = rcontact != NULL;
+
   ob->ob_rcontact = rcontact;
   ob->ob_dcontact = dcontact;
   ob->ob_previous = previous;
@@ -1205,6 +1166,11 @@ sip_contact_t const *outbound_dialog_contact(outbound_t const *ob)
     return ob->ob_dcontact;
 }
 
+sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob)
+{
+  return ob ? ob->ob_gruu : NULL;
+}
+
 /* ---------------------------------------------------------------------- */
 
 
index b6561fedbf73d27252b4b74d8ec4f9f7917d4b06..ef9d1d4cc345ff4419def539e16194309f6293bb 100644 (file)
@@ -70,17 +70,11 @@ int outbound_set_options(outbound_t *ob,
                         unsigned dgram_interval,
                         unsigned stream_interval);
 
-int outbound_set_features(outbound_t *ob, char *features);
-
-nta_outgoing_t *outbound_register_request(outbound_t *ob, int terminating, 
-                                         sip_contact_t *stack_contact,
-                                         nta_agent_t *nta,
-                                         nta_response_f *callback,
-                                         nta_outgoing_magic_t *magic,
-                                         url_string_t *next_hop,
-                                         msg_t *msg,
-                                         tag_type_t tag, tag_value_t value,
-                                         ...);
+int outbound_get_contacts(outbound_t *ob, 
+                         sip_contact_t **return_current_contact, 
+                         sip_contact_t **return_previous_contact);
+
+int outbound_start_registering(outbound_t *ob);
 
 int outbound_register_response(outbound_t *ob,
                               int terminating,
@@ -102,6 +96,8 @@ int outbound_set_contact(outbound_t *ob,
 
 sip_contact_t const *outbound_dialog_contact(outbound_t const *ob);
 
+sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob);
+
 int outbound_gruuize(outbound_t *ob, sip_t const *sip);
 
 void outbound_start_keepalive(outbound_t *ob,
@@ -122,6 +118,7 @@ struct outbound_owner_vtable
   int oo_size;
   sip_contact_t *(*oo_contact)(outbound_owner_t *,
                               su_home_t *home,
+                              int used_in_dialog,
                               char const *extra_username,
                               sip_via_t const *v,
                               char const *transport,
index 277e606c32f1b487f968d65bc2ec60aa84da34eb..b16cfe47460920fff04495d8100d15c54e61fb3a 100644 (file)
@@ -262,6 +262,12 @@ SOFIAPUBFUN char const *nua_event_name(nua_event_t event);
 /** Get name for NUA callstate. */
 SOFIAPUBFUN char const *nua_callstate_name(enum nua_callstate state);
 
+/** Return name of subscription state. @NEW_1_12_5. */
+SOFIAPUBFUN char const *nua_substate_name(enum nua_substate substate);
+
+/** Convert string to enum nua_substate. @NEW_1_12_5. */
+SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
+
 /** Send SIP REGISTER request to the registrar. */ 
 SOFIAPUBFUN void nua_register(nua_handle_t *nh, tag_type_t, tag_value_t, ...);
 
@@ -340,6 +346,9 @@ SOFIAPUBFUN void nua_respond(nua_handle_t *nh,
                             tag_type_t, tag_value_t, 
                             ...);
 
+/** Check if event can be responded with nua_respond() */
+SOFIAPUBFUN int nua_event_is_incoming_request(nua_event_t e);
+
 #define nua_handle_home(nh) ((su_home_t *)(nh))
 
 /** Generate an instance identifier */
index 059cc92c5c3694a57eebab16a8258229df3f8031..34fab1a8d1d116af7d11e2425e95b0bbcd76c763 100644 (file)
@@ -157,6 +157,9 @@ SOFIAPUBVAR tag_typedef_t nutag_with;
  */
 #define NUTAG_WITH_THIS(nua) nutag_with, tag_ptr_v(nua_current_request((nua)))
 
+#define NUTAG_WITH_CURRENT(nua) \
+   nutag_with, tag_ptr_v(nua_current_request((nua)))
+
 /**Specify request to respond to.
  *
  * @par Used with
@@ -174,6 +177,26 @@ SOFIAPUBVAR tag_typedef_t nutag_with;
  */
 #define NUTAG_WITH_SAVED(e) nutag_with, tag_ptr_v(nua_saved_event_request((e)))
 
+/**An (extension) method is used to create dialog or refresh target.
+ *
+ * @par Used with
+ *    nua_method()
+ *
+ * @par Parameter type
+ *    unsigned int (0, 1, 2) 
+ *
+ * @par Values
+ *   - 0 if dialog target is not refreshed
+ *   - 1 if dialog target is refreshed
+ *   - > 1 if dialog is to be created 
+ *
+ * @NEW_1_12_6.
+ *
+ * @sa nua_method(), #nua_i_method
+ */
+#define NUTAG_DIALOG(b) nutag_dialog, tag_uint_v((b))
+SOFIAPUBVAR tag_typedef_t nutag_dialog;
+
 /**Set request retry count.
  *
  * Retry count determines how many times stack will automatically retry
@@ -451,8 +474,8 @@ SOFIAPUBVAR tag_typedef_t nutag_include_extra_sdp_ref;
  *
  * @par Used with
  *    nua_invite() \n
- *    nua_set_params() \n
- *    nua_get_params()
+ *    nua_set_params(), nua_set_hparams(),
+ *    nua_get_params(), nua_get_hparams()
  *
  * @par Parameter type
  *    int (enum nua_af)
@@ -471,40 +494,48 @@ SOFIAPUBVAR tag_typedef_t nutag_invite_timer_ref;
 
 /**Default session timer in seconds.
  *
- * Set default session timer in seconds when using session timer extension. 
- * The value given here is the proposed session expiration time in seconds.
- * Note that the session timer extension is ponly used 
+ * Set default value for session timer in seconds when the session timer
+ * extension is used. The tag value is the proposed session expiration time
+ * in seconds, the session is refreshed twice during the expiration time.
  *
  * @par Sending INVITE and UPDATE Requests 
  *
- * If NUTAG_SESSION_TIMER() is used with non-zero value, the value is
- * used in the @SessionExpires header included in the INVITE or UPDATE
- * requests. The intermediate proxies or the ultimate destination can lower
- * the interval in @SessionExpires header. If the value is too low, they can
+ * If NUTAG_SESSION_TIMER() is used with non-zero value, the value is used
+ * in the @SessionExpires header included in the INVITE or UPDATE requests. 
+ * The intermediate proxies or the ultimate destination can lower the
+ * interval in @SessionExpires header. If the value is too low, they can
  * reject the request with the status code <i>422 Session Timer Too
- * Small</i>. When Re-INVITE will be sent in given intervals. In that case,
- * @b nua retries the request automatically.
- * 
- * @par Returning Response to the INVITE and UPDATE Requests 
+ * Small</i>. In that case, @b nua increases the value of @SessionExpires
+ * header and retries the request automatically.
+ *
+ * @par Returning Response to the INVITE and UPDATE Requests 
  *
  * The NUTAG_SESSION_TIMER() value is also used when sending the final
  * response to the INVITE or UPDATE requests. If the NUTAG_SESSION_TIMER()
- * value is 0 or the value in the @SessionExpires header of the requeast is
+ * value is 0 or the value in the @SessionExpires header of the request is
  * lower than the value in NUTAG_SESSION_TIMER(), the value from the
  * incoming @SessionExpires header is used. However, if the value in
  * @SessionExpires is lower than the minimal acceptable session expiration
  * interval specified with the tag NUTAG_MIN_SE() the request is
  * automatically rejected with <i>422 Session Timer Too Small</i>.
  *
+ * @par Refreshes
+ *
+ * After the initial INVITE request, the SIP session is refreshed at the
+ * intervals indicated by the @SessionExpires header returned in the 2XX
+ * response. The party indicated with the "refresher" parameter of the
+ * @SessionExpires header sends a re-INVITE requests (or an UPDATE
+ * request if NUTAG_UPDATE_REFRESH(1) parameter tag has been set).
+ * 
  * @par When to Use NUTAG_SESSION_TIMER()?
  *
  * The session time extension is enabled ("timer" feature tag is included in
  * @Supported header) but not activated by default (no @SessionExpires
  * header is included in the requests or responses by default). Using
- * non-zero value with NUTAG_SESSION_TIMER() activates it. When the
- * extension is activated, @nua refreshes the call state by sending periodic
- * re-INVITE or UPDATE requests unless the remote end indicated that it will
- * take care of refreshes.
+ * non-zero value with NUTAG_SESSION_TIMER() or NUTAG_SESSION_REFRESHER()
+ * activates it. When the extension is activated, @nua refreshes the call
+ * state by sending periodic re-INVITE or UPDATE requests unless the remote
+ * end indicated that it will take care of refreshes.
  *
  * The session timer extension is mainly useful for proxies or back-to-back
  * user agents that keep call state. The call state is "soft" meaning that
@@ -512,6 +543,10 @@ SOFIAPUBVAR tag_typedef_t nutag_invite_timer_ref;
  * will be destroyed. An ordinary user-agent can also make use of session
  * timer if it cannot get any activity feedback from RTP or other media.
  *
+ * @note The session timer extension is used only if the feature
+ * tag "timer" is listed in the @Supported header, set by NUTAG_SUPPORTED(),
+ * SIPTAG_SUPPORTED(), or SIPTAG_SUPPORTED_STR() tags.
+ *
  * @par Used with
  *    nua_invite(), nua_update(), nua_respond() \n
  *    nua_set_params() or nua_set_hparams() \n
@@ -530,8 +565,8 @@ SOFIAPUBVAR tag_typedef_t nutag_invite_timer_ref;
  * Corresponding tag taking reference parameter is NUTAG_SESSION_TIMER_REF()
  *
  * @sa NUTAG_SUPPORTED(), NUTAG_MIN_SE(), NUTAG_SESSION_REFRESHER(),
- * nua_invite(), #nua_r_invite, #nua_i_invite, nua_update(), #nua_r_update,
- * #nua_i_update, 
+ * nua_invite(), #nua_r_invite, #nua_i_invite, nua_respond(), 
+ * nua_update(), #nua_r_update, #nua_i_update, 
  * NUTAG_UPDATE_REFRESH(), @RFC4028, @SessionExpires, @MinSE
  */
 #define NUTAG_SESSION_TIMER(x)  nutag_session_timer, tag_uint_v((x))
@@ -571,6 +606,7 @@ SOFIAPUBVAR tag_typedef_t nutag_min_se;
 #define NUTAG_MIN_SE_REF(x)     nutag_min_se_ref, tag_uint_vr((&(x)))
 SOFIAPUBVAR tag_typedef_t nutag_min_se_ref;
 
+/** Enumeration type of NUTAG_SESSION_REFRESHER(). */
 enum nua_session_refresher {
   nua_no_refresher,            /**< Disable session timer. */
   nua_local_refresher,         /**< Session refresh by local end. */
@@ -1074,7 +1110,7 @@ SOFIAPUBVAR tag_typedef_t nutag_registrar_ref;
  *
  * The outbound option string can specify how the NAT traversal is handled.
  * The option tokens are as follows:
- * - "gruuize": try to generate a GRUU
+ * - "gruuize": try to generate a GRUU contact from REGISTER response
  * - "outbound": use SIP outbound extension (off by default)
  * - "validate": validate registration behind a NAT by sending OPTIONS to self
  * - "natify": try to traverse NAT
@@ -1084,6 +1120,10 @@ SOFIAPUBVAR tag_typedef_t nutag_registrar_ref;
  * An option token with "no-" or "not-" prefix turns the option off. For
  * example, if you want to try to traverse NATs but not to use OPTIONS
  * keepalive, use NUTAG_OUTBOUND("natify no-options-keepalive").
+ * 
+ * An empty string can be passed to let the stack choose the
+ * default values for outbound usage (in the 1.12.5 release, the
+ * defaults are: "gruuize no-outbound validate use-port options-keepalive").
  *
  * @note
  * Options string is used so that no new tags need to be added when the
@@ -1207,7 +1247,7 @@ SOFIAPUBVAR tag_typedef_t nutag_outbound_set4_ref;
  *    nua_create()
  *
  * @par Parameter type
- *    msg_mclass_t *
+ *    msg_mclass_t const *
  *
  * @par Values
  *    Pointer to an extended SIP parser.
@@ -1242,7 +1282,44 @@ SOFIAPUBVAR tag_typedef_t nutag_auth;
 #define NUTAG_AUTH_REF(x)          nutag_auth_ref, tag_str_vr(&(x))
 SOFIAPUBVAR tag_typedef_t nutag_auth_ref;
 
+/** Authentication caching policy
+ *
+ * @par Used with
+ *    nua_set_params(), nua_set_hparams() \n
+ *    nua_get_params(), nua_get_hparams() \n
+ *    @NUA_HPARAM_CALLS 
+ *
+ * @par Parameter type
+ *    enum nua_auth_cache
+ *
+ * @par Values
+ *    - nua_auth_cache_dialog (0) - include credentials within dialog
+ *    - nua_auth_cache_challenged (1) - include credentials only when 
+ *                                      challenged
+ *    
+ * Corresponding tag taking reference parameter is NUTAG_AUTH_CACHE_REF().
+ *
+ * @NEW_1_12_6
+ */
+#define NUTAG_AUTH_CACHE(x)   nutag_auth_cache, tag_int_v(x)
+SOFIAPUBVAR tag_typedef_t nutag_auth_cache;
+
+#define NUTAG_AUTH_CACHE_REF(x) nutag_auth_cache_ref, tag_int_vr(&(x))
+SOFIAPUBVAR tag_typedef_t nutag_auth_cache_ref;
+
+/** Authentication caching policy. @NEW_1_12_6 */
+enum nua_auth_cache {
+  /** Include credentials within dialog (default) */
+  nua_auth_cache_dialog = 0,
+  /** Include credentials only when challenged */
+  nua_auth_cache_challenged = 1,
+  _nua_auth_cache_invalid
+};
+
 /** Keepalive interval in milliseconds.
+ *
+ * This setting applies to OPTIONS/STUN keepalives. See documentation 
+ * for nua_register() for more detailed information.
  *
  * @par Used with
  *    nua_register()   \n
@@ -1268,6 +1345,8 @@ SOFIAPUBVAR tag_typedef_t nutag_keepalive;
 SOFIAPUBVAR tag_typedef_t nutag_keepalive_ref;
 
 /** Transport-level keepalive interval for streams.
+ *
+ * See documentation for nua_register() for more detailed information.
  *
  * @par Used with
  *    nua_register()   \n
@@ -1327,6 +1406,7 @@ SOFIAPUBVAR tag_typedef_t nutag_authtime_ref;
  *
  * @par Used with
  *    nua_register(), nua_set_hparams(), nua_set_params().
+ *    nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
  *
  * @par Parameter type
  *    string (char *)
@@ -1358,6 +1438,7 @@ SOFIAPUBVAR tag_typedef_t nutag_m_display_ref;
  *
  * @par Used with
  *    nua_register(), nua_set_hparams(), nua_set_params().
+ *    nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
  *
  * @par Parameter type
  *    string (char *)
@@ -1388,7 +1469,8 @@ SOFIAPUBVAR tag_typedef_t nutag_m_username_ref;
  * user-agent.
  *
  * @par Used with
- *    nua_register(), nua_set_hparams(), nua_set_params().
+ *    nua_register(), nua_set_hparams(), nua_set_params(), 
+ *    nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
  *
  * @par Parameter type
  *    string (char *)
@@ -1735,7 +1817,8 @@ SOFIAPUBVAR tag_typedef_t nutag_allow_ref;
  *
  * Corresponding tag taking reference parameter is NUTAG_APPL_METHOD_REF()
  *
- * @since Working since @VERSION_1_12_5. 
+ * @since Working since @VERSION_1_12_5. Handling of client-side PRACK and
+ * UPDATE was fixed in @VERSION_1_12_6.
  */
 #define NUTAG_APPL_METHOD(x)     nutag_appl_method, tag_str_v(x)
 SOFIAPUBVAR tag_typedef_t nutag_appl_method;
@@ -1859,26 +1942,39 @@ enum nua_callstate {
 /** Get name for NUA call state */
 SOFIAPUBFUN char const *nua_callstate_name(enum nua_callstate state);
 
-/** Subscription state
+/**Subscription state.
  *
  * @par Used with
+ *    #nua_notify() \n
  *    #nua_r_subscribe \n
- *    #nua_i_notify
+ *    #nua_i_notify \n
+ *    #nua_i_subscribe \n
+ *    #nua_r_notify \n
+ *    nua_notify() \n
+ *    nua_respond() to SUBSCRIBE
  *
  * @par Parameter type
  *    int
  *
  * @par Values
- *   @c nua_substate_embryonic (0) \n
- *   @c nua_substate_pending (1) \n
- *   @c nua_substate_active (2) \n
- *   @c nua_substate_terminated        (3) \n
+ *   - #nua_substate_embryonic (0)
+ *   - #nua_substate_pending (1)
+ *   - #nua_substate_active (2)
+ *   - #nua_substate_terminated (3)
+ *
+ * Note that the @SubscriptionState or @Expires headers specified by
+ * application overrides the subscription state specified by
+ * NUTAG_SUBSTATE(). Application can terminate subscription by including
+ * NUTAG_SUBSTATE(nua_substate_terminated), @SubscriptionState with value
+ * "terminated" or @Expires header with value 0 in the NOTIFY request sent
+ * by nua_notify().
  *
- * see
- * <a href="http://www.ietf.org/rfc/rfc3265.txt">RFC 3265</a>
+ * @sa @RFC3265, @SubscriptionState, SIPTAG_SUBSCRIPTION_STATE(),
+ * SIPTAG_SUBSCRIPTION_STATE_STR(), #nua_r_subscribe, #nua_i_subscribe,
+ * #nua_i_refer, #nua_r_notify, #nua_i_notify.
  *
  * Corresponding tag taking reference parameter is NUTAG_SUBSTATE_REF()
-*/
+ */
 #define NUTAG_SUBSTATE(x) nutag_substate, tag_int_v(x)
 SOFIAPUBVAR tag_typedef_t nutag_substate;
 
@@ -1896,6 +1992,46 @@ enum nua_substate {
   nua_substate_terminated = nea_terminated /**< Terminated subscription */
 };
 
+/** Return name of subscription state. @NEW_1_12_5. */
+SOFIAPUBFUN char const *nua_substate_name(enum nua_substate substate);
+
+/** Convert string to enum nua_substate. @NEW_1_12_5. */
+SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
+
+/**Send unsolicited NOTIFY request.
+ *
+ * Some applications may require sending unsolicited NOTIFY requests, that
+ * is, NOTIFY without SUBSCRIBE or REFER request sent by event watcher. 
+ * However, sending NOTIFY request requires an existing dialog usage by
+ * default. If NUTAG_NEWSUB(1) is included in the nua_notify() the usage
+ * is create the usage by itself.
+ *
+ * If you want to create a subscription that does not terminate immediately
+ * include SIPTAG_SUBSCRIPTION_STATE_STR() with an "expires" parameter in
+ * the argument list, too.
+ *
+ * @par Used with
+ *    nua_notify()
+ *
+ * @par Parameter type
+ *    int (boolean)
+ *
+ * @par Values
+ *   - 0 - false (default) - do not create new subscription 
+ *         but reject NOTIFY with 481 locally \n
+ *   - 1 - true - create a subscription if it does not exist \n
+ *
+ * Corresponding tag taking reference parameter is NUTAG_NEWSUB().
+ *
+ * @since @NEW_1_12_5.
+ */
+#define NUTAG_NEWSUB(x)   nutag_newsub, tag_bool_v(x)
+SOFIAPUBVAR tag_typedef_t nutag_newsub;
+
+#define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x))
+SOFIAPUBVAR tag_typedef_t nutag_newsub_ref;
+
+
 /**Default lifetime for implicit subscriptions created by REFER.
  *
  * Default expiration time in seconds for implicit subscriptions created by
index 420031ce2865e2e448c83f6d4e3d5c4532eceb28..37840dd762fc165cc3df5d339e7085bd75f3a408 100644 (file)
@@ -101,24 +101,17 @@ int accept_pracked2(CONDITION_PARAMS)
 
   save_event_in_list(ctx, event, ep, call);
 
-  switch (event) {
-  case nua_i_prack:
-    if (200 <= status && status < 300) {
-      RESPOND(ep, call, nh, SIP_200_OK, 
-             NUTAG_INCLUDE_EXTRA_SDP(1),
-             TAG_END());
-      ep->next_condition = until_ready;
-    }
-  default:
-    break;
-  }
-
   switch (callstate(tags)) {
   case nua_callstate_received:
     RESPOND(ep, call, nh, SIP_180_RINGING,
            TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
            TAG_END());
+    RESPOND(ep, call, nh, SIP_200_OK, 
+           NUTAG_INCLUDE_EXTRA_SDP(1),
+           TAG_END());
     return 0;
+  case nua_callstate_ready:
+    return 1;
   case nua_callstate_terminated:
     if (call)
       nua_handle_destroy(call->nh), call->nh = NULL;
@@ -170,6 +163,7 @@ int test_180rel(struct context *ctx)
 
   nua_set_params(ctx->b.nua,
                 NUTAG_EARLY_MEDIA(1),
+                NUTAG_SESSION_TIMER(180),
                 TAG_END());
   run_b_until(ctx, nua_r_set_params, until_final_response);
 
@@ -411,17 +405,21 @@ int test_prack_auth(struct context *ctx)
   TEST_1(is_answer_recv(e->data->e_tags));
   TEST_1(!is_offer_sent(e->data->e_tags));
 
-  if (md5 && !md5sess) {
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
-    TEST(e->data->e_status, 407);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
+
+  if (e->data->e_status != 200 && md5 && !md5sess) {
+    if (e->data->e_status != 100) {
+      TEST(e->data->e_status, 407);
+    }
 
     TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
     TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
     TEST_1(!is_answer_recv(e->data->e_tags));
     TEST_1(!is_offer_sent(e->data->e_tags));
+
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
   }
 
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
   TEST(e->data->e_status, 200);
 
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
@@ -552,6 +550,8 @@ int ringing_pracked(CONDITION_PARAMS)
   }
 }
 
+int respond_483_to_prack(CONDITION_PARAMS);
+
 int test_183rel(struct context *ctx)
 {
   BEGIN();
@@ -661,29 +661,109 @@ int test_183rel(struct context *ctx)
   if (print_headings)
     printf("TEST NUA-10.2.1: PASSED\n");
 
+  /* Test for graceful termination by client because 483 sent to PRACK */
   if (print_headings)
-    printf("TEST NUA-10.2.2: terminate call\n");
+    printf("TEST NUA-10.2.2: graceful termination because PRACK fails\n");
 
-  BYE(b, b_call, b_call->nh, TAG_END());
-  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+  nua_set_hparams(b_call->nh, NUTAG_APPL_METHOD("PRACK"),
+                 NUTAG_AUTOANSWER(0), TAG_END());
+  run_b_until(ctx, nua_r_set_params, NULL);
 
-  /* B transitions:
-   READY --(T2)--> TERMINATING: nua_bye()
-   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+  INVITE(a, a_call, a_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated, -1, respond_483_to_prack);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> TERMINATING: nua_r_invite, nua_i_state, 
+                                  nua_r_prack, nua_i_state
+     TERMINATING -(T1)-> TERMINATED: nua_r_invite, nua_i_state
   */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 183);
+
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
+  TEST(e->data->e_status, 483);
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminating);
+
+  {
+    int bye = 1, cancel = 1, invite = 1;
+
+    while (bye || cancel || invite) {
+      TEST_1(e = e->next); 
+      if (e->data->e_event == nua_r_bye) {
+       TEST_E(e->data->e_event, nua_r_bye);
+       TEST(e->data->e_status, 200);
+       TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+       TEST(callstate(e->data->e_tags), nua_callstate_terminated);
+       bye = 0;
+      }
+      else if (e->data->e_event == nua_r_invite) {
+       TEST_E(e->data->e_event, nua_r_invite);
+       TEST(e->data->e_status, 487);
+       invite = 0;
+      }
+      else if (e->data->e_event == nua_r_cancel) {
+       TEST_E(e->data->e_event, nua_r_cancel);
+       TEST_1(e->data->e_status == 200 || e->data->e_status == 481);
+       cancel = 0;
+      }
+    }
+  }
   TEST_1(!e->next);
-  free_events_in_list(ctx, b->events);
 
-  /* A: READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
-  TEST(e->data->e_status, 200);
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state, nua_respond(to PRACK)
+   EARLY -(S3b)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+
+  /* Responded with 183 Session Progress */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(e->data->e_status, 183);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(is_answer_sent(e->data->e_tags));
+
+  /* 183 is PRACKed, PRACK is responded with 483 */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_prack);
+
+  /* Client terminates the call 
+     - we may (it is received before BYE) or may not (received after BYE) 
+       get CANCEL request 
+  */
+  TEST_1(e = e->next);
+  if (e->data->e_event == nua_i_cancel) {
+    TEST_E(e->data->e_event, nua_i_cancel);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_ready);
+    TEST_1(e = e->next);
+  }
+
+  TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated);
   TEST_1(!e->next);
-  free_events_in_list(ctx, a->events);
+
+  free_events_in_list(ctx, b->events);
 
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
@@ -694,6 +774,39 @@ int test_183rel(struct context *ctx)
   END();
 }
 
+int respond_483_to_prack(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  switch (event) {
+  case nua_i_prack:
+    if (status <= 200) {
+      RESPOND(ep, call, nh, 483, "Foo",
+             NUTAG_WITH_THIS(nua),
+             TAG_END());
+    }
+  default:
+    break;
+  }
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_183_SESSION_PROGRESS,
+           TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
+           TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
 /*
  X  ringing_updated   ep
  |-------INVITE------>|
@@ -858,6 +971,8 @@ int test_preconditions(struct context *ctx)
 
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_update);
   TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_session_expires);
 
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
@@ -1085,14 +1200,14 @@ int test_preconditions2(struct context *ctx)
 
   nua_set_params(ctx->a.nua,
                 NUTAG_EARLY_MEDIA(1),
-                SIPTAG_SUPPORTED_STR("100rel, precondition"),
+                SIPTAG_SUPPORTED_STR("100rel, precondition, timer"),
                 TAG_END());
   run_a_until(ctx, nua_r_set_params, until_final_response);
 
   nua_set_params(ctx->b.nua,
                 NUTAG_EARLY_MEDIA(1),
                 NUTAG_ONLY183_100REL(1),
-                SIPTAG_SUPPORTED_STR("100rel, precondition"),
+                SIPTAG_SUPPORTED_STR("100rel, precondition, timer"),
                 TAG_END());
   run_b_until(ctx, nua_r_set_params, until_final_response);
 
@@ -1578,6 +1693,310 @@ int test_update_by_uas(struct context *ctx)
   END();
 }
  
+int cancel_when_pracked(CONDITION_PARAMS);
+int alert_call(CONDITION_PARAMS);
+
+int test_180rel_cancel1(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  if (print_headings)
+    printf("TEST NUA-10.6: CANCEL after PRACK\n");
+
+/* Test for 100rel:
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<-------180---------|
+   |-------PRACK------->|
+   |<-------200---------|
+   |                   |
+   |------CANCEL------->|
+   |<------200 OK-------|
+   |                   |
+   |<-------487---------|
+   |--------ACK-------->|
+   |                   |
+
+*/
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+  nua_set_params(ctx->a.nua,
+                NUTAG_EARLY_MEDIA(1),
+                NUTAG_ONLY183_100REL(0),
+                TAG_END());
+  run_a_until(ctx, nua_r_set_params, until_final_response);
+
+  nua_set_params(ctx->b.nua,
+                NUTAG_EARLY_MEDIA(1),
+                NUTAG_ONLY183_100REL(0),
+                TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+
+  run_ab_until(ctx, -1, cancel_when_pracked, -1, alert_call);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state, nua_r_prack
+     PROCEEDING -(C3+C4)-> TERMINATED: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_cancel);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 487);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   Option A:
+   EARLY -(S10)-> TERMINATED: nua_i_cancel, nua_i_state
+   Option B:
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+   READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state   
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+
+  /* Responded with 180 Ringing */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(is_answer_sent(e->data->e_tags));
+
+  /* 180 is PRACKed */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_prack);
+  /* Does not have effect on call state */
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_cancel);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-10.6: PASSED\n");
+  
+  END();
+}
+
+int cancel_when_pracked(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_r_prack)
+    CANCEL(ep, call, nh, TAG_END());
+
+  switch (callstate(tags)) {
+  case nua_callstate_proceeding:
+    return 0;
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+int test_180rel_cancel2(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  if (print_headings)
+    printf("TEST NUA-10.7: CANCEL after 100rel 180\n");
+
+/* Test for 100rel:
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<-------180---------|
+   |-------PRACK------->|
+   |<-------200---------|
+   |                   |
+   |------CANCEL------->|
+   |<------200 OK-------|
+   |                   |
+   |<-------487---------|
+   |--------ACK-------->|
+   |                   |
+
+*/
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+  nua_set_params(ctx->a.nua,
+                NUTAG_EARLY_MEDIA(1),
+                NUTAG_ONLY183_100REL(0),
+                TAG_END());
+  run_a_until(ctx, nua_r_set_params, until_final_response);
+
+  nua_set_params(ctx->b.nua,
+                NUTAG_EARLY_MEDIA(1),
+                NUTAG_ONLY183_100REL(0),
+                TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+
+  run_ab_until(ctx, -1, cancel_when_ringing, -1, accept_pracked2);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state, nua_r_prack
+     PROCEEDING -(C3+C4)-> TERMINATED: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!is_offer_sent(e->data->e_tags));
+
+#define NEXT_SKIP_PRACK_CANCEL() \
+  do { TEST_1(e = e->next); } \
+  while (e->data->e_event == nua_r_prack || e->data->e_event == nua_r_cancel)
+
+  NEXT_SKIP_PRACK_CANCEL();
+
+  TEST_E(e->data->e_event, nua_r_invite);
+  if (e->data->e_status == 487) {
+    TEST(e->data->e_status, 487);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_terminated);
+    TEST_1(!e->next);
+  }
+  else {
+    TEST(e->data->e_status, 200);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_ready);
+
+    BYE(a, a_call, a_call->nh, TAG_END());
+    run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+    NEXT_SKIP_PRACK_CANCEL(); TEST_E(e->data->e_event, nua_r_bye);
+    TEST(e->data->e_status, 200);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+    TEST_1(!e->next);
+  }
+
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   Option A:
+   EARLY -(S10)-> TERMINATED: nua_i_cancel, nua_i_state
+   Option B:
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+   READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state   
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+
+  /* Responded with 180 Ringing */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(is_answer_sent(e->data->e_tags));
+
+  /* 180 is PRACKed */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_prack);
+  /* Does not have effect on call state */
+
+  if (e->next->data->e_event == nua_i_cancel) {
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_cancel);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  }
+  else {
+    /* Respond with 200 OK */
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+    TEST_1(!is_offer_answer_done(e->data->e_tags));
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+    TEST_1(!is_offer_answer_done(e->data->e_tags));
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+    TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  }
+
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-10.7: PASSED\n");
+  
+  END();
+}
+
 
 int test_100rel(struct context *ctx)
 {
@@ -1589,6 +2008,28 @@ int test_100rel(struct context *ctx)
   retval = test_preconditions(ctx); RETURN_ON_SINGLE_FAILURE(retval);
   retval = test_preconditions2(ctx); RETURN_ON_SINGLE_FAILURE(retval);
   retval = test_update_by_uas(ctx); RETURN_ON_SINGLE_FAILURE(retval);
+  retval = test_180rel_cancel1(ctx); RETURN_ON_SINGLE_FAILURE(retval);
+  retval = test_180rel_cancel2(ctx); RETURN_ON_SINGLE_FAILURE(retval);
+
+  nua_set_params(ctx->a.nua,
+                NUTAG_EARLY_MEDIA(0),
+                SIPTAG_SUPPORTED(ctx->a.supported),
+                TAG_END());
+  run_a_until(ctx, nua_r_set_params, until_final_response);
+
+  nua_set_params(ctx->b.nua,
+                NUTAG_EARLY_MEDIA(0),
+                NUTAG_ONLY183_100REL(0),
+                SIPTAG_SUPPORTED(ctx->b.supported),
+                TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  nua_set_params(ctx->c.nua,
+                NUTAG_EARLY_MEDIA(0),
+                NUTAG_ONLY183_100REL(0),
+                SIPTAG_SUPPORTED(ctx->c.supported),
+                TAG_END());
+  run_c_until(ctx, nua_r_set_params, until_final_response);
 
   return retval;
 }
index d48d11732a94aee83e9b41022a8ed3686bec1dcb..2cd8548e4515f52c1f861d4f98bffa17fcb6ab25 100644 (file)
@@ -117,6 +117,8 @@ int accept_call_with_early_sdp(CONDITION_PARAMS)
   case nua_callstate_received:
     RESPOND(ep, call, nh, SIP_180_RINGING, 
            TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
+           NUTAG_M_DISPLAY("Bob"),
+           NUTAG_M_USERNAME("b+b"),
            TAG_END());
     return 0;
   case nua_callstate_early:
@@ -203,9 +205,16 @@ int test_basic_call_1(struct context *ctx)
   sip_replaces_t *repa, *repb;
   nua_handle_t *nh;
 
+  static int once = 0;
+  sip_time_t se, min_se;
+
   if (print_headings)
     printf("TEST NUA-3.1: Basic call\n");
 
+  /* Disable session timer from proxy */
+  test_proxy_get_session_timer(ctx->p, &se, &min_se); 
+  test_proxy_set_session_timer(ctx->p, 0, 0); 
+
   a_call->sdp = "m=audio 5008 RTP/AVP 8";
   b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
 
@@ -217,6 +226,8 @@ int test_basic_call_1(struct context *ctx)
   INVITE(a, a_call, a_call->nh,
         TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
         SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_M_USERNAME("a+a"),
+        NUTAG_M_DISPLAY("Alice"),
         TAG_END());
 
   run_ab_until(ctx, -1, until_ready, -1, accept_call_with_early_sdp);
@@ -263,8 +274,15 @@ int test_basic_call_1(struct context *ctx)
   TEST_1(is_answer_recv(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
   TEST(e->data->e_status, 200);
-  TEST_1(sip->sip_payload);
   TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_payload);
+  TEST_1(sip->sip_contact);
+  TEST_S(sip->sip_contact->m_display, "Bob");
+  TEST_S(sip->sip_contact->m_url->url_user, "b+b");
+  if (!once) {
+    /* The session expiration is not used by default. */
+    TEST_1(sip->sip_session_expires == NULL);
+  }
   /* Test that B uses application-specific contact */
   if (ctx->proxy_tests)
     TEST_1(sip->sip_contact->m_url->url_user);
@@ -282,6 +300,14 @@ int test_basic_call_1(struct context *ctx)
   */
   TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
   TEST(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_contact);
+  TEST_S(sip->sip_contact->m_display, "Alice");
+  TEST_S(sip->sip_contact->m_url->url_user, "a+a");
+  if (!once++) {
+    /* The Session-Expires header is not used by default. */
+    TEST_1(sip->sip_session_expires == NULL);
+  }
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
@@ -331,6 +357,8 @@ int test_basic_call_1(struct context *ctx)
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
+  test_proxy_set_session_timer(ctx->p, se, min_se); 
+
   if (print_headings)
     printf("TEST NUA-3.1: PASSED\n");
 
@@ -404,6 +432,7 @@ int test_basic_call_2(struct context *ctx)
   INVITE(a, a_call, a_call->nh,
         NUTAG_URL(b->contact->m_url),
         SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_ALLOW("INFO"),
         TAG_END());
 
   run_ab_until(ctx, -1, until_ready, -1, accept_early_answer);
@@ -466,32 +495,96 @@ int test_basic_call_2(struct context *ctx)
   TEST_1(nua_handle_has_active_call(b_call->nh));
   TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
 
+  /* Send a NOTIFY from B to A */
+  if (print_headings)
+    printf("TEST NUA-3.2.2: send a NOTIFY within a dialog\n");
+
+  /* Make A to accept NOTIFY */
+  nua_set_params(a->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
+  run_a_until(ctx, nua_r_set_params, until_final_response);
+
+  NOTIFY(b, b_call, b_call->nh,
+        NUTAG_NEWSUB(1),
+        SIPTAG_SUBJECT_STR("NUA-3.2.2"),
+        SIPTAG_EVENT_STR("message-summary"),
+        SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+        SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
+        TAG_END());
+
+  run_ab_until(ctx, -1, accept_notify, -1, save_until_final_response);
+
+  /* Notifier events: nua_r_notify */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_notify);
+  TEST(e->data->e_status, 200);
+  TEST_1(tl_find(e->data->e_tags, nutag_substate));
+  TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
+       nua_substate_terminated);
+
+  /* watcher events: nua_i_notify */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_notify);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+  TEST_1(tl_find(e->data->e_tags, nutag_substate));
+  TEST(tl_find(e->data->e_tags, nutag_substate)->t_value, 
+       nua_substate_terminated);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST NUA-3.2.2: PASSED\n");
+
+  INFO(b, b_call, b_call->nh, TAG_END());
   BYE(b, b_call, b_call->nh, TAG_END());
+  INFO(b, b_call, b_call->nh, TAG_END());
+
   run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
 
+  while (!b->events->head || /* r_info */
+        !b->events->head->next || /* r_bye */
+        !b->events->head->next->next || /* i_state */
+        !b->events->head->next->next->next) /* r_info */
+    run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
+
   /* B transitions:
+   nua_info()
    READY --(T2)--> TERMINATING: nua_bye()
+   nua_r_info with 200
    TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+   nua_r_info with 481/900
   */
-  TEST_1(e = b->events->head);  TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_info);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_info);
+  TEST_1(e->data->e_status >= 900 || e->data->e_status == 481);
   TEST_1(!e->next);
   free_events_in_list(ctx, b->events);
 
   TEST_1(!nua_handle_has_active_call(b_call->nh));
 
   /* A transitions:
+     nua_i_info
      READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
   */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_info);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
   TEST(e->data->e_status, 200);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
 
-  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  BYE(a, a_call, a_call->nh, TAG_END());
+  run_a_until(ctx, -1, save_until_final_response);
+
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e->data->e_status >= 900);
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
 
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
@@ -502,8 +595,376 @@ int test_basic_call_2(struct context *ctx)
   END();
 }
 
+/* ====================================================================== */
+
+/* Basic calls with soa disabled */
+
+int accept_call_no_media(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_180_RINGING, 
+           NUTAG_MEDIA_ENABLE(0),
+           TAG_END());
+    return 0;
+  case nua_callstate_early:
+    RESPOND(ep, call, nh, SIP_200_OK,
+           TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
+           TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
+           TAG_END());
+    return 0;
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+int test_basic_call_3(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t const *sip;
+
+  if (print_headings)
+    printf("TEST NUA-3.3: Basic call with media disabled\n");
+
+  a_call->sdp = "v=0\r\n"
+    "o=- 1 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5008 RTP/AVP 8\r\n";
+
+  b_call->sdp = 
+    "v=0\r\n"
+    "o=- 2 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5010 RTP/AVP 0 8\r\n";
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, 
+                                SIPTAG_TO_STR("<sip:b@x.org>"),
+                                TAG_END()));
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  INVITE(a, a_call, a_call->nh,
+        NUTAG_MEDIA_ENABLE(0),
+        NUTAG_URL(b->contact->m_url),
+        SIPTAG_CONTENT_TYPE_STR("application/sdp"),
+        SIPTAG_PAYLOAD_STR(a_call->sdp),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_call_no_media);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
+     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(!is_answer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_content_type); 
+  TEST_S(sip->sip_content_type->c_type, "application/sdp");
+  TEST_1(sip->sip_payload);    /* there is sdp in 200 OK */
+  TEST_1(sip->sip_contact);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(nua_handle_has_active_call(b_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
+
+  BYE(b, b_call, b_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+  /* B transitions:
+   READY --(T2)--> TERMINATING: nua_bye()
+   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+
+  /* A transitions:
+     nua_i_info
+     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-3.3: PASSED\n");
+
+  END();
+}
+
+int ack_when_completing_no_media(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_completing:
+    ACK(ep, call, nh, 
+       TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
+       TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
+       TAG_END());
+    return 0;
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+int accept_call_no_media2(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_180_RINGING, 
+           NUTAG_MEDIA_ENABLE(0),
+           TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
+           TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
+           TAG_END());
+    return 0;
+  case nua_callstate_early:
+    RESPOND(ep, call, nh, SIP_200_OK,
+           TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
+           TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
+           TAG_END());
+    return 0;
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+/* Media disabled, offer/answer in 200 OK/ACK */
+int test_basic_call_4(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t const *sip;
+
+  if (print_headings)
+    printf("TEST NUA-3.4: 3pcc call with media disabled\n");
+
+  a_call->sdp = "v=0\r\n"
+    "o=- 1 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5008 RTP/AVP 8\r\n";
+
+  b_call->sdp = 
+    "v=0\r\n"
+    "o=- 2 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5010 RTP/AVP 0 8\r\n";
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, 
+                                SIPTAG_TO_STR("<sip:b@x.org>"),
+                                TAG_END()));
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  INVITE(a, a_call, a_call->nh,
+        NUTAG_MEDIA_ENABLE(0),
+        NUTAG_URL(b->contact->m_url),
+        NUTAG_AUTOACK(0),
+        TAG_END());
+
+  run_ab_until(ctx, -1, ack_when_completing_no_media,
+              -1, accept_call_no_media2);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
+     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(!is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(!is_answer_recv(e->data->e_tags));
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_content_type); 
+  TEST_S(sip->sip_content_type->c_type, "application/sdp");
+  TEST_1(sip->sip_payload);    /* there is sdp in 200 OK */
+  TEST_1(sip->sip_contact);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(!is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(nua_handle_has_active_call(b_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
+
+  BYE(b, b_call, b_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+  /* B transitions:
+   READY --(T2)--> TERMINATING: nua_bye()
+   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+
+  /* A transitions:
+     nua_i_info
+     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-3.4: PASSED\n");
+
+  END();
+}
 
 int test_basic_call(struct context *ctx)
 {
-  return test_basic_call_1(ctx) || test_basic_call_2(ctx);
+  return test_basic_call_1(ctx) || test_basic_call_2(ctx) || 
+    test_basic_call_3(ctx) || test_basic_call_4(ctx);
 }
index 2f5fb07eea9fa44b0afdd4943a8564326d5cfb54..c3cbd5dcb07e37e6d1ac2013edf13318533dd445 100644 (file)
@@ -467,7 +467,7 @@ int test_call_hold(struct context *ctx)
   */
 
   if (print_headings)
-    printf("TEST NUA-7.6: re-INVITE without auto-ack\n");
+    printf("TEST NUA-7.6.1: re-INVITE without auto-ack\n");
 
   /* Turn off auto-ack */
   nua_set_hparams(b_call->nh, NUTAG_AUTOACK(0), TAG_END());
@@ -517,7 +517,7 @@ int test_call_hold(struct context *ctx)
   free_events_in_list(ctx, a->events);
 
   if (print_headings)
-    printf("TEST NUA-7.6: PASSED\n");
+    printf("TEST NUA-7.6.1: PASSED\n");
 
 
   /* ---------------------------------------------------------------------- */
@@ -528,7 +528,7 @@ int test_call_hold(struct context *ctx)
    */
 
   if (print_headings)
-    printf("TEST NUA-7.6: terminate call\n");
+    printf("TEST NUA-7.6.2: terminate call\n");
 
   BYE(a, a_call, a_call->nh, TAG_END());
   run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
@@ -555,7 +555,7 @@ int test_call_hold(struct context *ctx)
   free_events_in_list(ctx, b->events);
 
   if (print_headings)
-    printf("TEST NUA-7.6: PASSED\n");
+    printf("TEST NUA-7.6.2: PASSED\n");
 
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
@@ -725,9 +725,6 @@ int test_reinvite(struct context *ctx)
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
-  if (print_headings)
-    printf("TEST NUA-7.8: PASSED\n");
-
   END();
 }
 
@@ -784,6 +781,211 @@ int ringing_until_terminated(CONDITION_PARAMS)
   }
 }
 
+/* ======================================================================== */
+
+int accept_and_attempt_reinvite(CONDITION_PARAMS);
+int until_ready2(CONDITION_PARAMS);
+
+/* test_reinvite2 message sequence looks like this:
+
+ A                    B
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |                    |
+ |<----180 Ringing----|
+ |                    |
+ |           /-INVITE-|
+ |           \---900->|
+ |                    |
+ |<--------200--------|
+ |---------ACK------->|
+ :                    :
+ :   queue INVITE     :
+ :                    :
+ |-----re-INVITE----->|
+ |<--------200--------|
+ |---------ACK------->|
+ |-----re-INVITE----->|
+ |<--------200--------|
+ |---------ACK------->|
+ :                    :
+ :        glare       :
+ :                    :
+ |-----re-INVITE----->|
+ |<----re-INVITE------|
+ |<--------491--------|
+ |---------491------->|
+ |---------ACK------->|
+ |<--------ACK--------|
+ :                    :
+ |---------BYE------->|
+ |<--------200--------|
+*/
+
+int test_reinvite2(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a, *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  if (print_headings)
+    printf("TEST NUA-7.8.1: Test re-INVITE glare\n");
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 0 8\n";
+  b_call->sdp = "m=audio 5010 RTP/AVP 8\n";
+
+  TEST_1(a_call->nh = 
+        nua_handle(a->nua, a_call, 
+                   SIPTAG_FROM_STR("Alice <sip:alice@example.com>"),
+                   SIPTAG_TO(b->to),
+                   TAG_END()));
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_and_attempt_reinvite);
+
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+  TEST_1(nua_handle_has_active_call(b_call->nh));
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  /* Check that we can queue INVITEs */
+  INVITE(a, a_call, a_call->nh, TAG_END());
+  INVITE(a, a_call, a_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, until_ready2, -1, until_ready2);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  /* Check that INVITE glare works */
+  INVITE(a, a_call, a_call->nh, TAG_END());
+  INVITE(b, b_call, b_call->nh, TAG_END());
+
+  a->flags.n = 0, b->flags.n = 0;
+  run_ab_until(ctx, -1, until_ready2, -1, until_ready2);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST NUA-7.8.1: PASSED\n");
+
+
+
+  /* ---------------------------------------------------------------------- */
+  /*
+ A                    B
+ |---------BYE------->|
+ |<--------200--------|
+   */
+
+  if (print_headings)
+    printf("TEST NUA-7.8.2: terminate call\n");
+
+  BYE(a, a_call, a_call->nh, TAG_END());
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+  /*
+   Transitions of A:
+   READY --(T2)--> TERMINATING: nua_bye()
+   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  /* Transitions of B:
+     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_bye);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST NUA-7.8.2: PASSED\n");
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  END();
+}
+
+int accept_and_attempt_reinvite(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_i_prack) {
+    INVITE(ep, call, nh, TAG_END());
+    RESPOND(ep, call, nh, SIP_200_OK,
+           TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
+           TAG_END());
+  }
+  else switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_180_RINGING, 
+           SIPTAG_REQUIRE_STR("100rel"),
+           TAG_END());
+    return 0;
+  case nua_callstate_early:
+    return 0;
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+  return 0;
+}
+
+/*
+ X      INVITE
+ |                    |
+ |-------INVITE------>|
+ |<--------200--------|
+ |---------ACK------->|
+*/
+int until_ready2(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_r_invite && status == 491) {
+    if (ep == &ctx->a && ++ctx->b.flags.n >= 2) ctx->b.running = 0;
+    if (ep == &ctx->b && ++ctx->a.flags.n >= 2) ctx->a.running = 0;
+  }
+
+  switch (callstate(tags)) {
+  case nua_callstate_ready:
+    return ++ep->flags.n >= 2;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
 int test_reinvites(struct context *ctx)
 {
   int retval = 0;
@@ -794,7 +996,10 @@ int test_reinvites(struct context *ctx)
   retval = test_call_hold(ctx);
   
   if (retval == 0)
-    retval |= test_reinvite(ctx);
+    retval = test_reinvite(ctx);
+
+  if (retval == 0)
+    retval = test_reinvite2(ctx);
 
   if (print_headings && retval == 0)
     printf("TEST NUA-7: PASSED\n");
index a3f18ff9e1e68860230499c5e1b27469aed2e2ed..f5e40b6fee40a7fb984267df4e49bad93af638d6 100644 (file)
@@ -261,7 +261,8 @@ int test_reject_b(struct context *ctx)
 
 /* ------------------------------------------------------------------------ */
 
-int reject_302(CONDITION_PARAMS);
+int reject_302(CONDITION_PARAMS), reject_305(CONDITION_PARAMS);
+int redirect_always(CONDITION_PARAMS);
 int reject_604(CONDITION_PARAMS);
 
 /*
@@ -281,6 +282,7 @@ int reject_604(CONDITION_PARAMS);
  |<---604 Nowhere-----|
  |--------ACK-------->|
 */
+
 int reject_302(CONDITION_PARAMS)
 {
   if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
@@ -298,6 +300,33 @@ int reject_302(CONDITION_PARAMS)
              SIPTAG_CONTACT(m), TAG_END());
     }
     return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    ep->next_condition = reject_305;
+    return 0;
+  default:
+    return 0;
+  }
+}
+
+int reject_305(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    {
+      sip_contact_t m[1];
+      *m = *ep->contact;
+      m->m_url->url_user = "305";
+      m->m_url->url_params = "lr=1";
+      RESPOND(ep, call, nh, SIP_305_USE_PROXY, SIPTAG_CONTACT(m), TAG_END());
+    }
+    return 0;
   case nua_callstate_terminated:
     if (call)
       nua_handle_destroy(call->nh), call->nh = NULL;
@@ -308,6 +337,27 @@ int reject_302(CONDITION_PARAMS)
   }
 }
 
+int redirect_always(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  if (event == nua_i_invite) {
+    char user[30];
+    sip_contact_t m[1];
+    *m = *ep->contact;
+    snprintf(user, sizeof user, "user-%u", ep->flags.n++);
+    m->m_url->url_user = user;
+    RESPOND(ep, call, nh, SIP_302_MOVED_TEMPORARILY,
+           SIPTAG_CONTACT(m), TAG_END());
+    nua_handle_destroy(nh);
+    call->nh = NULL;
+    return 1;
+  }
+
+  return 0;
+}
+
 int reject_604(CONDITION_PARAMS)
 {
   if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
@@ -338,6 +388,7 @@ int test_reject_302(struct context *ctx)
   struct endpoint *a = &ctx->a, *b = &ctx->b;
   struct call *a_call = a->call, *b_call = b->call;
   struct event *e;
+  sip_t const *sip;
 
   /* Make call reject-3 */
   if (print_headings)
@@ -388,6 +439,12 @@ int test_reject_302(struct context *ctx)
   TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
   TEST_1(is_offer_sent(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 100);
+  TEST(sip_object(e->data->e_msg)->sip_status->st_status, 305);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
   TEST(e->data->e_status, 180);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
@@ -415,6 +472,18 @@ int test_reject_302(struct context *ctx)
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_request);
+  TEST_S(sip->sip_request->rq_url->url_user, "302");
+  TEST_1(sip->sip_route);
+  TEST_S(sip->sip_route->r_url->url_user, "305");
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
@@ -425,6 +494,25 @@ int test_reject_302(struct context *ctx)
   free_events_in_list(ctx, b->events);
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
+  if (print_headings)
+    printf("TEST NUA-4.3: PASSED\n");
+
+  if (print_headings)
+    printf("TEST NUA-4.3.1: redirect until retry count is exceeded\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("redirect always"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+  run_ab_until(ctx, -1, until_terminated, -1, redirect_always);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
   if (print_headings)
     printf("TEST NUA-4.3: PASSED\n");
 
@@ -638,11 +726,12 @@ int test_reject_401(struct context *ctx)
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
   TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_proxy_authorization);
+  /* Ensure that nua_authenticate() tags get added to the request */
   TEST_1(sip->sip_subject);
   TEST_S(sip->sip_subject->g_value, "Got 407");
-  TEST_1(sip->sip_proxy_authorization);
-  TEST(e->data->e_status, 100);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
@@ -723,7 +812,7 @@ int test_reject_401_aka(struct context *ctx)
   sip_t const *sip;
 
   if (print_headings)
-    printf("TEST NUA-4.6: invalid challenge \n");
+    printf("TEST NUA-4.6.1: invalid challenge \n");
 
   a_call->sdp = "m=audio 5008 RTP/AVP 8";
   b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
@@ -772,7 +861,161 @@ int test_reject_401_aka(struct context *ctx)
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-4.6: PASSED\n");
+    printf("TEST NUA-4.6.1: PASSED\n");
+
+  END();
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/* Reject call with 401, twice */
+
+/*
+ A   reject-401-bad   B
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |<--------401--------|
+ |---------ACK------->|
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |<--------401--------|
+ |---------ACK------->|
+*/
+
+int reject_401_bad(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_401_UNAUTHORIZED,
+           /* Send a challenge that we do not grok */
+           SIPTAG_WWW_AUTHENTICATE_STR("Digest realm=\"No hope\", "
+                                       "nonce=\"goO541ftNrw327aWpu2\", "
+                                       "algorithm=MD5, "
+                                       "qop=\"auth\""),
+           TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    if (ep->flags.bit0)                /* Terminate 2 calls */
+      return 1;
+    ep->flags.bit0 = 1;
+    return 0;
+  default:
+    return 0;
+  }
+}
+
+int authenticate_bad(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_r_invite && status == 401) {
+    AUTHENTICATE(ep, call, nh, NUTAG_AUTH("Digest:\"No hope\":jaska:secret"),
+                SIPTAG_SUBJECT_STR("Bad password"),
+                TAG_END());
+    return 0;
+  }
+
+  switch (callstate(tags)) {
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+
+int test_reject_401_bad(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a, *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event const *e;
+  sip_t const *sip;
+
+  if (print_headings)
+    printf("TEST NUA-4.6.2: bad username/password\n");
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("reject-401-bad"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+
+
+  run_ab_until(ctx, -1, authenticate_bad, -1, reject_401_bad);
+
+  /*
+   Client transitions
+   INIT -(C1)-> CALLING -(C6a)-> TERMINATED/INIT
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(sip_object(e->data->e_msg)->sip_status->st_status, 401);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(sip_object(e->data->e_msg)->sip_status->st_status, 401);
+  /* nua_authenticate() fails and INVITE returns an internal error response */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 904);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next); 
+
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED -(S6a)-> TERMINATED
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-4.6.2: PASSED\n");
 
   END();
 }
@@ -911,7 +1154,7 @@ int test_mime_negotiation(struct context *ctx)
 
   /*
    Client transitions in reject-3:
-   INIT -(C1)-> PROCEEDING -(C6a)-> TERMINATED
+   INIT -(C1)-> CALLING -(C6a)-> TERMINATED
   */
 
   TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
@@ -927,7 +1170,7 @@ int test_mime_negotiation(struct context *ctx)
   /* No content-encoding is supported */
   TEST_S(sip->sip_accept_encoding->aa_value, "");
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* CALLING */
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(!e->next);
 
   free_events_in_list(ctx, a->events);
@@ -944,3 +1187,340 @@ int test_mime_negotiation(struct context *ctx)
 
   END();
 }
+
+/* ---------------------------------------------------------------------- */
+
+size_t filter_200_OK(void *arg, void *message, size_t len)
+{
+  (void)arg;
+
+  if (len >= 11 && strncasecmp(message, "SIP/2.0 200", 11) == 0)
+    return 0;
+  return len;
+}
+
+size_t filter_ACK(void *arg, void *message, size_t len)
+{
+  (void)arg;
+
+  if (len >= 7 && strncasecmp(message, "ACK sip", 7) == 0) 
+    return 0;
+  return len;
+}
+
+int call_with_bad_ack(CONDITION_PARAMS);
+int accept_call_with_bad_contact(CONDITION_PARAMS);
+
+int test_call_timeouts(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a, *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  struct nat_filter *f, *f2;
+
+  if (print_headings)
+    printf("TEST NUA-4.7: check for error and timeout handling\n");
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+  if (!ctx->nat)
+    goto completed_4_7_1;
+
+  if (print_headings)
+    printf("TEST NUA-4.7.1: ACK timeout (200 OK filtered)\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  TEST_1(f = test_nat_add_filter(ctx->nat, filter_200_OK, NULL, nat_inbound));
+  TEST_1(f2 = test_nat_add_filter(ctx->nat, filter_200_OK,
+                                 NULL, nat_outbound));
+  
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("NUA-4.7.1"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+  run_ab_until(ctx, -1, until_terminated, -1, accept_call);
+
+  /*
+ A     accept_call    B
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |                    |
+ |<----180 Ringing----|
+ |                    |
+ |   X-----200--------|
+ |   X-----200--------|
+ |   X-----200--------|
+ |                    |
+ |<--------BYE--------|
+ |--------200 OK---X  |
+
+  */
+
+  /*
+    Client transitions:
+  */
+
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  /*
+   Server transitions:
+   -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S5)-> TERMINATING
+   -(S10)-> TERMINATED -X
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_error);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST(e->data->e_status, 408);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
+  TEST_1(test_nat_remove_filter(ctx->nat, f2) == 0);
+
+  if (print_headings)
+    printf("TEST NUA-4.7.1: PASSED\n");
+
+ completed_4_7_1:
+
+  if (!ctx->nat)
+    goto completed_4_7_2;
+
+  if (print_headings)
+    printf("TEST NUA-4.7.2: ACK timeout (ACK filtered)\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  TEST_1(f = test_nat_add_filter(ctx->nat, filter_ACK, NULL, nat_outbound));
+  
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("NUA-4.7.2"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+  run_ab_until(ctx, -1, until_terminated, -1, accept_call);
+
+  /*
+ A     accept_call    B
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |                    |
+ |<----180 Ringing----|
+ |                    |
+ |<--------200--------|
+ |--------ACK-----X   |
+ |                    |
+ |<--------200--------|
+ |--------ACK-----X   |
+ |                    |
+ |<--------200--------|
+ |--------ACK-----X   |
+ |                    |
+ |<--------BYE--------|
+ |--------200 OK----->|
+
+  */
+
+  /*
+  */
+
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); 
+  TEST_1(!e->next);
+
+  /*
+   Server transitions:
+   -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S5)-> TERMINATING
+   -(S10)-> TERMINATED -X
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_error);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
+
+  if (print_headings)
+    printf("TEST NUA-4.7.2: PASSED\n");
+
+ completed_4_7_2:
+
+  if (print_headings)
+    printf("TEST NUA-4.7.3: sending ACK fails\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("NUA-4.7.3"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_AUTOACK(0),
+        TAG_END());
+  run_ab_until(ctx, -1, call_with_bad_ack, -1, accept_call);
+
+  /*
+ A     accept_call    B
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |                    |
+ |<----180 Ringing----|
+ |                    |
+ |<--------200--------|
+ |--ACK-X             |
+ |                    |
+ |---------BYE------->|
+ |<-------200 OK------|
+
+  */
+
+  /*
+  */
+
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
+  /* try to send ACK */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminating);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); 
+  TEST_1(!e->next);
+
+  /*
+   Server transitions:
+   -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S5)-> TERMINATING
+   -(S10)-> TERMINATED -X
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-4.7.3: PASSED\n");
+
+  /* XXX - PRACK timeout, PRACK failing, media failing, re-INVITEs */
+
+  if (print_headings)
+    printf("TEST NUA-4.7: PASSED\n");
+
+  END();
+}
+
+int call_with_bad_ack(CONDITION_PARAMS)
+{
+  if (!check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_r_invite && 200 <= status && status < 300) {
+    ACK(ep, call, nh,
+       /* Syntax error - sending ACK fails, we send BYE */
+       SIPTAG_MAX_FORWARDS_STR("blue"),
+       TAG_END());
+  }
+
+  return event == nua_i_state && callstate(tags) == nua_callstate_terminated;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int test_rejects(struct context *ctx)
+{
+  return
+    test_reject_401_bad(ctx) ||
+    test_reject_a(ctx) ||
+    test_reject_b(ctx) ||
+    test_reject_302(ctx) ||
+    test_reject_401(ctx) ||
+    test_mime_negotiation(ctx) ||
+    test_call_timeouts(ctx) ||
+    test_reject_401_aka(ctx) ||
+    0;
+}
index 76f9a9575f81026d9f1f4dbffc9193c025b8ef35..87fc11867c882c13e900db173d37d8b953615f38 100644 (file)
@@ -118,6 +118,8 @@ int cancel_when_ringing(CONDITION_PARAMS)
   case nua_callstate_proceeding:
     CANCEL(ep, call, nh, TAG_END());
     return 0;
+  case nua_callstate_ready:
+    return 1;
   case nua_callstate_terminated:
     return 1;
   default:
@@ -144,6 +146,7 @@ int alert_call(CONDITION_PARAMS)
   }
 }
 
+int accept_after_183(CONDITION_PARAMS);
 
 int test_call_cancel(struct context *ctx)
 {
@@ -211,7 +214,7 @@ int test_call_cancel(struct context *ctx)
   /* ------------------------------------------------------------------------ */
 
   if (print_headings)
-    printf("TEST NUA-5.2: cancel call when ringing\n");
+    printf("TEST NUA-5.2.1: cancel call when ringing\n");
 
   TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
 
@@ -278,11 +281,56 @@ int test_call_cancel(struct context *ctx)
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-5.2: PASSED\n");
+    printf("TEST NUA-5.2.1: PASSED\n");
+
+  /* ------------------------------------------------------------------------ */
+  if (print_headings)
+    printf("TEST NUA-5.2.2: CANCEL call when server waits for PRACK\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_APPL_METHOD("PRACK"),
+        /*SIPTAG_REJECT_CONTACT_STR("*;audio=FALSE"),*/
+        TAG_END());
+
+  run_ab_until(ctx, -1, cancel_when_ringing, -1, accept_after_183);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-5.2.2: PASSED\n");
+
 
   END();
 }
 
+int accept_after_183(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_183_SESSION_PROGRESS, TAG_END());
+    RESPOND(ep, call, nh, SIP_200_OK, TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+
 /* ======================================================================== */
 /* Destroy call handle */
 
@@ -496,13 +544,13 @@ int destroy_when_early(CONDITION_PARAMS)
     return 0;
   case nua_callstate_early:
     if (call)
-      nua_handle_destroy(call->nh), call->nh = NULL;
+      DESTROY(ep, call, nh), call->nh = NULL;
     return 1;
   case nua_callstate_completed:
   case nua_callstate_ready:
   case nua_callstate_terminated:
     if (call)
-      nua_handle_destroy(call->nh), call->nh = NULL;
+      DESTROY(ep, call, nh), call->nh = NULL;
     return 1;
   default:
     return 0;
@@ -594,7 +642,7 @@ int destroy_when_completed(CONDITION_PARAMS)
   case nua_callstate_ready:
   case nua_callstate_terminated:
     if (call)
-      nua_handle_destroy(call->nh), call->nh = NULL;
+      DESTROY(ep, call, nh), call->nh = NULL;
     return 1;
   default:
     return 0;
@@ -673,6 +721,82 @@ int test_call_destroy_4(struct context *ctx)
   END();
 }
 
+/* Destroy when one INVITE is queued. */
+int test_call_destroy_5(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  if (print_headings)
+    printf("TEST NUA-5.7: destroy when re-INVITE is queued\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        NUTAG_AUTOACK(0),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        TAG_END());
+
+  INVITE(a, a_call, a_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated, -1, destroy_when_completed);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), ...
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 481);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state ... DESTROY
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(!e->next);  
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-5.7: PASSED\n");
+
+  END();
+}
+
 int test_call_destroy(struct context *ctx)
 {
   struct endpoint *a = &ctx->a,  *b = &ctx->b;
@@ -685,10 +809,12 @@ int test_call_destroy(struct context *ctx)
     test_call_destroy_1(ctx) ||
     test_call_destroy_2(ctx) ||
     test_call_destroy_3(ctx) ||
-    test_call_destroy_4(ctx);
+    test_call_destroy_4(ctx) ||
+    test_call_destroy_5(ctx);
 }
 
 /* ======================================================================== */
+
 /* Early BYE
 
    A                   B
@@ -731,13 +857,30 @@ int bye_when_ringing(CONDITION_PARAMS)
   }
 }
 
-int test_early_bye(struct context *ctx)
+int bye_when_completing(CONDITION_PARAMS);
+
+static int ack_sent = 0;
+
+size_t count_acks(void *arg, void *message, size_t len)
+{
+  (void)arg;
+
+  if (strncasecmp(message, "ACK sip:", 8) == 0)
+    ack_sent++;
+
+  return len;
+}
+
+int test_bye_before_200(struct context *ctx)
 {
   BEGIN();
   struct endpoint *a = &ctx->a,  *b = &ctx->b;
   struct call *a_call = a->call, *b_call = b->call;
   struct event *e;
 
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
   if (print_headings)
     printf("TEST NUA-6.1: BYE call when ringing\n");
 
@@ -809,3 +952,513 @@ int test_early_bye(struct context *ctx)
   END();
 }
 
+
+int bye_when_completing(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_completing:
+    ack_sent = 0;
+    BYE(ep, call, nh, TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+
+int test_bye_before_ack(struct context *ctx)
+{
+  BEGIN();
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  struct nat_filter *f = NULL;
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+/* Early BYE 2
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<----180 Ringing----|
+   |<-------200---------|
+   |                   |
+   |--------BYE-------->|
+   |<------200 OK-------|
+   |--------ACK-------->|
+   |                   |
+   |                   |
+*/
+  if (print_headings)
+    printf("TEST NUA-6.2: BYE call when completing\n");
+
+  if (ctx->nat)
+    TEST_1(f = test_nat_add_filter(ctx->nat, count_acks, NULL, nat_outbound));
+  ack_sent = 0;
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_AUTOACK(0),
+        TAG_END());
+
+  run_ab_until(ctx, -1, bye_when_completing, -1, accept_until_terminated);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite(180, nua_i_state, nua_cancel()
+     PROCEEDING -(C6b)-> TERMINATED: nua_r_invite(487), nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling);
+  TEST_1(is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completing); 
+  TEST_1(e = e->next);
+
+  TEST_E(e->data->e_event, nua_r_bye); TEST(e->data->e_status, 200);
+  TEST_1(e->data->e_msg);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  if (ctx->nat) {
+    while (ack_sent == 0)
+      su_root_step(ctx->root, 100);
+    TEST_1(ack_sent > 0);
+    TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
+  }
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(180), nua_i_state
+   EARLY -(S6b)--> TERMINATED: nua_i_cancel, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.2: PASSED\n");
+
+  END();
+}
+
+int reject_reinvite_401(CONDITION_PARAMS);
+
+int test_bye_after_receiving_401(struct context *ctx)
+{
+  BEGIN();
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+/* BYE after receiving 401
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<----180 Ringing----|
+   |<-------200---------|
+   |--------ACK-------->|
+   |                   |
+   |<------INVITE-------|
+   |--------401-------->|
+   |<--------ACK--------|
+   |                   |
+   |<--------BYE--------|
+   |------200 OK------->|
+   |                   |
+*/
+  if (print_headings)
+    printf("TEST NUA-6.3: BYE after receiving 401\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("NUA-6.3"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_AUTOANSWER(0),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_call);
+
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  free_events_in_list(ctx, b->events);
+
+  /* re-INVITE A. */
+  INVITE(b, b_call, b_call->nh, 
+        SIPTAG_SUBJECT_STR("NUA-6.3 re-INVITE"),
+        TAG_END());
+  run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response);
+
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+  TEST_1(nua_handle_has_active_call(b_call->nh));
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  BYE(b, b_call, b_call->nh, TAG_END());
+  
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.3: PASSED\n");
+
+  END();
+}
+
+int test_bye_after_sending_401(struct context *ctx)
+{
+  BEGIN();
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+/* BYE after sending 401
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<----180 Ringing----|
+   |<-------200---------|
+   |--------ACK-------->|
+   |                   |
+   |<------INVITE-------|
+   |--------401-------->|
+   |<--------ACK--------|
+   |                   |
+   |--------BYE-------->|
+   |<------200 OK-------|
+   |                   |
+*/
+  if (print_headings)
+    printf("TEST NUA-6.4.1: BYE after sending 401\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("NUA-6.4.1"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_AUTOANSWER(0),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_call);
+
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  free_events_in_list(ctx, b->events);
+
+  /* re-INVITE A. */
+  INVITE(b, b_call, b_call->nh, 
+        SIPTAG_SUBJECT_STR("NUA-6.4.1 re-INVITE"),
+        TAG_END());
+  run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response);
+
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+  TEST_1(nua_handle_has_active_call(b_call->nh));
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  BYE(a, a_call, a_call->nh, TAG_END());
+  
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.4.1: PASSED\n");
+
+  END();
+}
+
+int test_bye_after_receiving_401_to_update(struct context *ctx)
+{
+  BEGIN();
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+/* BYE after receiving 401
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<----180 Ringing----|
+   |<-------200---------|
+   |--------ACK-------->|
+   |                   |
+   |<------UPDATE-------|
+   |--------401-------->|
+   |                   |
+   |<--------BYE--------|
+   |------200 OK------->|
+   |                   |
+*/
+  if (print_headings)
+    printf("TEST NUA-6.4.2: BYE after receiving 401 to UPDATE\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SIPTAG_SUBJECT_STR("NUA-6.4.2"),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_AUTOANSWER(0),
+        NUTAG_APPL_METHOD("UPDATE"),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_call);
+
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  free_events_in_list(ctx, b->events);
+
+  /* UPDATE A. */
+  UPDATE(b, b_call, b_call->nh, 
+        SIPTAG_SUBJECT_STR("NUA-6.4.2 UPDATE"),
+        TAG_END());
+  BYE(b, b_call, b_call->nh, TAG_END()); /* Queued until nua_authenticate */
+  run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response);
+
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+  TEST_1(nua_handle_has_active_call(b_call->nh));
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  AUTHENTICATE(b, b_call, b_call->nh, TAG_END());
+  
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.4.2: PASSED\n");
+
+  END();
+}
+
+int reject_reinvite_401(CONDITION_PARAMS)
+{
+  void *request = nua_current_request(nua);
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  if (status < 200 && (event == nua_i_invite || event == nua_i_update)) {
+    RESPOND(ep, call, nh, SIP_401_UNAUTHORIZED,
+           NUTAG_WITH(request),
+           SIPTAG_WWW_AUTHENTICATE_STR("Digest realm=\"test_nua\", "
+                                       "nonce=\"nsdhfuds\", algorithm=MD5, "
+                                       "qop=\"auth\""),
+           TAG_END());
+    return 0;
+  }
+
+  if (event == nua_i_state) switch (callstate(tags)) {
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+
+  return 0;
+}
+
+int test_bye_to_invalid_contact(struct context *ctx)
+{
+  BEGIN();
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+
+/* Early BYE 2
+
+   A                   B
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<----180 Ringing----|
+   |<-------200---------|
+   |                   |
+   |--------BYE-------->|
+   |<------200 OK-------|
+   |--------ACK-------->|
+   |                   |
+   |                   |
+*/
+  if (print_headings)
+    printf("TEST NUA-6.4.3: BYE call when completing\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        SIPTAG_CONTACT(NULL),
+        SIPTAG_HEADER_STR("Contact: <<sip:xyzzy@com.invalid>"),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_call);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite(180, nua_i_state, nua_cancel()
+     PROCEEDING -(C6b)-> TERMINATED: nua_r_invite(487), nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling);
+  TEST_1(is_offer_sent(e->data->e_tags));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); 
+  TEST_1(!e->next);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(180), nua_i_state
+   EARLY -(S6b)--> TERMINATED: nua_i_cancel, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  BYE(b, b_call, b_call->nh, TAG_END());
+  
+  run_b_until(ctx, -1, until_terminated);
+
+  /* B transitions:
+   READY --(T2)--> TERMINATING: nua_bye()
+   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+  */
+  TEST_1(e = b->events->head);  TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+  TEST_1(nua_handle_has_active_call(a_call->nh));
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.4.3: PASSED\n");
+
+  END();
+}
+
+int test_early_bye(struct context *ctx)
+{
+  return 
+    test_bye_before_200(ctx) ||
+    test_bye_before_ack(ctx) ||
+    test_bye_after_receiving_401(ctx) ||
+    test_bye_after_sending_401(ctx) ||
+    test_bye_after_receiving_401_to_update(ctx) ||
+    test_bye_to_invalid_contact(ctx) ||
+    0;
+}
index e1460e1460315051e1d3f70458071c34980081bb..79aac676cbc5a247792db626f95d0bdc6054917f 100644 (file)
@@ -167,6 +167,13 @@ int test_extension(struct context *ctx)
   free_events_in_list(ctx, b->events);
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
+  nua_set_params(b->nua,
+                SIPTAG_ALLOW(b->allow),
+                NUTAG_APPL_METHOD(NULL),
+                NUTAG_APPL_METHOD(b->appl_method),
+                TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
   if (print_headings)
     printf("TEST NUA-13.1: PASSED\n");
   END();
index 2b960d1a7be443ebe78030a64871d7cac5c5cb0c..b389b9d92750e6803ea142862beb35bcf0ab6e32 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "test_nua.h"
 
+#include <sofia-sip/tport_tag.h>
+
 #if HAVE_FUNC
 #elif HAVE_FUNCTION
 #define __func__ __FUNCTION__
@@ -65,6 +67,9 @@ int test_nua_init(struct context *ctx,
   struct event *e;
   sip_contact_t const *m = NULL;
   sip_from_t const *sipaddress = NULL;
+  sip_allow_t const *allow = NULL;
+  sip_supported_t const *supported = NULL;
+  char const *appl_method = NULL;
   url_t const *p_uri, *a_uri;          /* Proxy URI */
   char const *a_bind, *a_bind2;
 
@@ -105,7 +110,9 @@ int test_nua_init(struct context *ctx,
                               AUTHTAG_OPAQUE("kuik"),
                               AUTHTAG_DB(passwd_name),
                               AUTHTAG_QOP("auth-int"),
-                              AUTHTAG_ALGORITHM("md5-sess"),
+                              AUTHTAG_ALGORITHM("md5"),
+                              AUTHTAG_NEXT_EXPIRES(60),
+                              TAG_IF(ctx->proxy_logging, TPTAG_LOG(1)),
                               TAG_END());
 
     ctx->proxy_tests = ctx->p != NULL;
@@ -218,22 +225,29 @@ int test_nua_init(struct context *ctx,
                          NUTAG_URL(a_bind),
                          TAG_IF(a_bind != a_bind2, NUTAG_SIPS_URL(a_bind2)),
                          SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
-                         NTATAG_SIP_T1X64(4000),
+                         NTATAG_SIP_T1X64(2000),
                          NUTAG_INSTANCE(ctx->a.instance),
+                         TAG_IF(ctx->a.logging, TPTAG_LOG(1)),
                          TAG_END());
   TEST_1(ctx->a.nua);
 
   nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
   run_a_until(ctx, nua_r_get_params, save_until_final_response);
-  TEST_1(e = ctx->a.events->head);
+  TEST_1(e = ctx->a.specials->head);
   TEST(tl_gets(e->data->e_tags,
               NTATAG_CONTACT_REF(m),
               SIPTAG_FROM_REF(sipaddress),
-              TAG_END()), 2); TEST_1(m);
+              SIPTAG_ALLOW_REF(allow),
+              NUTAG_APPL_METHOD_REF(appl_method),
+              SIPTAG_SUPPORTED_REF(supported),
+              TAG_END()), 5); TEST_1(m);
   TEST_1(ctx->a.contact = sip_contact_dup(ctx->home, m));
   TEST_1(ctx->a.to = sip_to_dup(ctx->home, sipaddress));
+  TEST_1(ctx->a.allow = sip_allow_dup(ctx->home, allow));
+  TEST_1(ctx->a.appl_method = su_strdup(ctx->home, appl_method));
+  TEST_1(ctx->a.supported = sip_supported_dup(ctx->home, supported));
 
-  free_events_in_list(ctx, ctx->a.events);
+  free_events_in_list(ctx, ctx->a.specials);
 
   if (print_headings)
     printf("TEST NUA-2.2.1: PASSED\n");
@@ -249,19 +263,30 @@ int test_nua_init(struct context *ctx,
                          NUTAG_URL("sip:0.0.0.0:*"),
                          SOATAG_USER_SDP_STR("m=audio 5006 RTP/AVP 8 0"),
                          NUTAG_INSTANCE(ctx->b.instance),
+                         /* Quicker timeout */
+                         NTATAG_SIP_T1X64(2000),
+                         TAG_IF(ctx->b.logging, TPTAG_LOG(1)),
                          TAG_END());
   TEST_1(ctx->b.nua);
 
   nua_get_params(ctx->b.nua, TAG_ANY(), TAG_END());
   run_b_until(ctx, nua_r_get_params, save_until_final_response);
-  TEST_1(e = ctx->b.events->head);
+  TEST_1(e = ctx->b.specials->head);
   TEST(tl_gets(e->data->e_tags,
               NTATAG_CONTACT_REF(m),
               SIPTAG_FROM_REF(sipaddress),
-              TAG_END()), 2); TEST_1(m);
+              SIPTAG_ALLOW_REF(allow),
+              NUTAG_APPL_METHOD_REF(appl_method),
+              SIPTAG_SUPPORTED_REF(supported),
+              TAG_END()), 5); TEST_1(m);
+
   TEST_1(ctx->b.contact = sip_contact_dup(ctx->home, m));
   TEST_1(ctx->b.to = sip_to_dup(ctx->home, sipaddress));
-  free_events_in_list(ctx, ctx->b.events);
+  TEST_1(ctx->b.allow = sip_allow_dup(ctx->home, allow));
+  TEST_1(ctx->b.appl_method = su_strdup(ctx->home, appl_method));
+  TEST_1(ctx->b.supported = sip_supported_dup(ctx->home, supported));
+
+  free_events_in_list(ctx, ctx->b.specials);
 
   if (print_headings)
     printf("TEST NUA-2.2.2: PASSED\n");
@@ -277,19 +302,26 @@ int test_nua_init(struct context *ctx,
                          NUTAG_URL("sip:0.0.0.0:*"),
                          SOATAG_USER_SDP_STR("m=audio 5400 RTP/AVP 8 0"),
                          NUTAG_INSTANCE(ctx->c.instance),
+                         TAG_IF(ctx->c.logging, TPTAG_LOG(1)),
                          TAG_END());
   TEST_1(ctx->c.nua);
 
   nua_get_params(ctx->c.nua, TAG_ANY(), TAG_END());
   run_c_until(ctx, nua_r_get_params, save_until_final_response);
-  TEST_1(e = ctx->c.events->head);
+  TEST_1(e = ctx->c.specials->head);
   TEST(tl_gets(e->data->e_tags,
               NTATAG_CONTACT_REF(m),
               SIPTAG_FROM_REF(sipaddress),
-              TAG_END()), 2); TEST_1(m);
+              SIPTAG_ALLOW_REF(allow),
+              NUTAG_APPL_METHOD_REF(appl_method),
+              SIPTAG_SUPPORTED_REF(supported),
+              TAG_END()), 5); TEST_1(m);
   TEST_1(ctx->c.contact = sip_contact_dup(ctx->home, m));
   TEST_1(ctx->c.to = sip_to_dup(ctx->home, sipaddress));
-  free_events_in_list(ctx, ctx->c.events);
+  TEST_1(ctx->c.allow = sip_allow_dup(ctx->home, allow));
+  TEST_1(ctx->c.appl_method = su_strdup(ctx->home, appl_method));
+  TEST_1(ctx->c.supported = sip_supported_dup(ctx->home, supported));
+  free_events_in_list(ctx, ctx->c.specials);
 
   if (print_headings)
     printf("TEST NUA-2.2.3: PASSED\n");
index 936810132d56858751e28c2eb555b16f729fd19b..0f3763f2e6e873d4d7c93af42621aa3eece3ac05 100644 (file)
@@ -91,6 +91,8 @@ struct nat {
 
   struct binding *bindings;
 
+  struct nat_filter *in_filters, *out_filters;
+
   /* True if we act in symmetric way */
   int symmetric;
   /* True if we do logging */
@@ -153,6 +155,15 @@ static int tcp_out_to_in(struct nat *, su_wait_t *wait, struct binding *);
 
 static int invalidate_binding(struct binding *b);
 
+LIST_PROTOS(static, nat_filter, struct nat_filter);
+
+struct nat_filter
+{
+  struct nat_filter *next, **prev;
+  size_t (*condition)(void *arg, void *message, size_t len);
+  void *arg;
+};
+
 /* nat entry point */
 static int
 test_nat_init(su_root_t *root, struct nat *nat)
@@ -670,19 +681,35 @@ static int udp_in_to_out(struct nat *nat, su_wait_t *wait, struct binding *b)
 {
   int events;
   ssize_t n, m;
+  size_t len, filtered;
+  struct nat_filter *f;
 
   events = su_wait_events(wait, b->in_socket);
 
   n = su_recv(b->in_socket, nat->buffer, sizeof nat->buffer, 0);
-  if (n < 0) {
+  if (n == -1) {
     su_perror("udp_in_to_out: recv");
     return 0;
   }
 
+  len = (size_t)n;
+
+  for (f = nat->out_filters; f; f = f->next) {
+    filtered = f->condition(f->arg, nat->buffer, len);
+    if (filtered != len) {
+      if (nat->logging)
+       printf("nat: udp filtered "MOD_ZU" from %s => "MOD_ZU" to %s\n",
+              len, b->in_name, filtered, b->out_name);
+      if (filtered == 0)
+       return 0;
+      len = filtered;
+    }
+  }
+
   if (nat->symmetric)
-    m = su_send(b->out_socket, nat->buffer, n, 0);
+    m = su_send(b->out_socket, nat->buffer, len, 0);
   else
-    m = su_sendto(b->out_socket, nat->buffer, n, 0,
+    m = su_sendto(b->out_socket, nat->buffer, len, 0,
                  nat->out_address, nat->out_addrlen);
 
   if (nat->logging)
@@ -696,6 +723,8 @@ static int udp_out_to_in(struct nat *nat, su_wait_t *wait, struct binding *b)
 {
   int events;
   ssize_t n, m;
+  size_t len, filtered;
+  struct nat_filter *f;
 
   events = su_wait_events(wait, b->out_socket);
 
@@ -705,6 +734,20 @@ static int udp_out_to_in(struct nat *nat, su_wait_t *wait, struct binding *b)
     return 0;
   }
 
+  len = (size_t)n;
+
+  for (f = nat->in_filters; f; f = f->next) {
+    filtered = f->condition(f->arg, nat->buffer, len);
+    if (filtered != len) {
+      if (nat->logging)
+       printf("nat: udp filtered "MOD_ZU" from %s => "MOD_ZU" to %s\n",
+              len, b->out_name, filtered, b->in_name);
+      if (filtered == 0)
+       return 0;
+      len = filtered;
+    }
+  }
+
   m = su_send(b->in_socket, nat->buffer, n, 0);
 
   if (nat->logging)
@@ -882,3 +925,75 @@ static int invalidate_binding(struct binding *b)
 
   return 0;
 }
+
+LIST_BODIES(static, nat_filter, struct nat_filter, next, prev);
+
+struct args {
+  struct nat *nat;
+  struct nat_filter *f;
+  int outbound;
+};
+
+int execute_nat_filter_insert(void *_args)
+{
+  struct args *a = (struct args *)_args;
+  if (a->outbound)
+    nat_filter_insert(&a->nat->out_filters, a->f);
+  else
+    nat_filter_insert(&a->nat->in_filters, a->f);
+  return 0;
+}
+
+int execute_nat_filter_remove(void *_args)
+{
+  struct args *a = (struct args *)_args;
+  nat_filter_remove(a->f);
+  return 0;
+}
+
+struct nat_filter *test_nat_add_filter(struct nat *nat,
+                                      size_t (*condition)(void *arg,
+                                                          void *message,
+                                                          size_t len),
+                                      void *arg,
+                                      int outbound)
+{
+  struct args a[1];
+
+  if (nat == NULL)
+    return su_seterrno(EFAULT), NULL;
+
+  a->nat = nat;
+  a->f = su_zalloc(nat->home, sizeof *a->f);
+  a->outbound = outbound;
+
+  if (a->f) {
+    a->f->condition = condition;
+    a->f->arg = arg;
+    if (su_task_execute(su_clone_task(nat->clone),
+                       execute_nat_filter_insert, a, NULL) < 0)
+      su_free(nat->home, a->f), a->f = NULL;
+  }
+
+  return a->f;
+}
+
+
+int test_nat_remove_filter(struct nat *nat,
+                          struct nat_filter *filter)
+{
+  struct args a[1];
+
+  if (nat == NULL)
+    return su_seterrno(EFAULT);
+
+  a->nat = nat;
+  a->f = filter;
+  
+  if (su_task_execute(su_clone_task(nat->clone),
+                     execute_nat_filter_remove, a, NULL) < 0)
+    return -1;
+
+  su_free(nat->home, filter);
+  return 0;
+}
index 08f98efa7d961ba3cbcd06a029d2658dc35cf805..3cc3c855b78d2a3da256b87f09922e5c54b5b77a 100644 (file)
@@ -31,6 +31,7 @@
 SOFIA_BEGIN_DECLS
 
 struct nat;
+struct nat_filter;
 
 struct nat *test_nat_create(su_root_t *, int family, 
                            tag_type_t, tag_value_t, ...);
@@ -42,6 +43,18 @@ int test_nat_public(struct nat *nat, void const *address, int addrlen);
 
 int test_nat_flush(struct nat *nat);
 
+struct nat_filter *test_nat_add_filter(struct nat *nat,
+                                      size_t (*condition)(void *arg,
+                                                          void *message,
+                                                          size_t len),
+                                      void *arg,
+                                      int outbound);
+
+enum { nat_inbound, nat_outbound };
+
+int test_nat_remove_filter(struct nat *nat,
+                          struct nat_filter *filter);
+
 /* Tags */
 
 /** If true, act as symmetric nat. */
index 9741da223d75029c61e5d59a09a4e80bb084206a..9e633cb36168e2ed8ea6a93b857121ed7206daa1 100644 (file)
@@ -72,20 +72,29 @@ static RETSIGTYPE sig_alarm(int s)
 static char const options_usage[] =
   "   -v | --verbose    be verbose\n"
   "   -q | --quiet      be quiet\n"
+  "   -a | --abort      abort on error\n" 
   "   -s                use only single thread\n"
   "   -l level          set logging level (0 by default)\n"
   "   -e | --events     print nua events\n"
   "   -A                print nua events for A\n"
   "   -B                print nua events for B\n"
   "   -C                print nua events for C\n"
+  "   --log=a           log messages for A\n"
+  "   --log=b           log messages for B\n"
+  "   --log=c           log messages for C\n"
+  "   --log=proxy       log messages for proxy\n"
   "   --attach          print pid, wait for a debugger to be attached\n"
   "   --no-proxy        do not use internal proxy\n"
   "   --no-nat          do not use internal \"nat\"\n"
   "   --symmetric       run internal \"nat\" in symmetric mode\n"
   "   -N                print events from internal \"nat\"\n"
+  "   --loop            loop main tests for ever\n"
   "   --no-alarm        don't ask for guard ALARM\n"
   "   -p uri            specify uri of outbound proxy (implies --no-proxy)\n"
   "   --proxy-tests     run tests involving proxy, too\n"
+#if SU_HAVE_OSX_CF_API /* If compiled with CoreFoundation events */
+  "   --osx-runloop     use OSX CoreFoundation runloop instead of poll() loop\n"
+#endif
   "   -k                do not exit after first error\n"
   ;
 
@@ -99,7 +108,7 @@ void usage(int exitcode)
 int main(int argc, char *argv[])
 {
   int retval = 0;
-  int i, o_quiet = 0, o_attach = 0, o_alarm = 1;
+  int i, o_quiet = 0, o_attach = 0, o_alarm = 1, o_loop = 0;
   int o_events_init = 0, o_events_a = 0, o_events_b = 0, o_events_c = 0;
   int o_iproxy = 1, o_inat = 1;
   int o_inat_symmetric = 0, o_inat_logging = 0, o_expensive = 0;
@@ -199,6 +208,21 @@ int main(int argc, char *argv[])
     else if (strcmp(argv[i], "--no-alarm") == 0) {
       o_alarm = 0;
     }
+    else if (strcmp(argv[i], "--loop") == 0) {
+      o_alarm = 0, o_loop = 1;
+    }
+    else if (strcmp(argv[i], "--log=a") == 0) {
+      ctx->a.logging = 1;
+    }
+    else if (strcmp(argv[i], "--log=b") == 0) {
+      ctx->b.logging = 1;
+    }
+    else if (strcmp(argv[i], "--log=c") == 0) {
+      ctx->c.logging = 1;
+    }
+    else if (strcmp(argv[i], "--log=proxy") == 0) {
+      ctx->proxy_logging = 1;
+    }
 #if SU_HAVE_OSX_CF_API /* If compiled with CoreFoundation events */
     else if (strcmp(argv[i], "--osx-runloop") == 0) {
       ctx->osx_runloop = 1;
@@ -210,8 +234,10 @@ int main(int argc, char *argv[])
     else if (argv[i][0] != '-') {
       break;
     }
-    else
+    else {
+      fprintf(stderr, "test_nua: unknown argument \"%s\"\n\n", argv[i]);
       usage(1);
+    }
   }
 
   if (o_attach) {
@@ -222,8 +248,15 @@ int main(int argc, char *argv[])
   }
 #if HAVE_ALARM
   else if (o_alarm) {
-    alarm(o_expensive ? 60 : 120);
     signal(SIGALRM, sig_alarm);
+    if (o_expensive) {
+      printf("%s: extending timeout to %u because expensive tests\n",
+            name, 240);
+      alarm(240);
+    }
+    else {
+      alarm(120);
+    }
   }
 #endif
 
@@ -279,17 +312,12 @@ int main(int argc, char *argv[])
     if (retval == 0 && o_inat)
       retval |= test_nat_timeout(ctx);
 
-    if (retval == 0) {
-      retval |= test_extension(ctx); SINGLE_FAILURE_CHECK();
+    while (retval == 0) {
       retval |= test_basic_call(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_a(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_b(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_302(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_401(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_mime_negotiation(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_401_aka(ctx); SINGLE_FAILURE_CHECK();
+      retval |= test_rejects(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_call_cancel(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_call_destroy(ctx); SINGLE_FAILURE_CHECK();
+      retval |= test_offer_answer(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_early_bye(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_reinvites(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_session_timer(ctx); SINGLE_FAILURE_CHECK();
@@ -297,6 +325,9 @@ int main(int argc, char *argv[])
       retval |= test_100rel(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_simple(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_events(ctx); SINGLE_FAILURE_CHECK();
+      retval |= test_extension(ctx); SINGLE_FAILURE_CHECK();
+      if (!o_loop)
+       break;
     }
 
     if (ctx->proxy_tests && (retval == 0 || !ctx->p))
index b90464902cca2596726bef2339d2f81c16a6e945..dd97a164d539fef19d7a3a77373853af4604b2ca 100644 (file)
@@ -126,10 +126,14 @@ struct context
   int threading, proxy_tests, expensive, quit_on_single_failure, osx_runloop;
   char const *external_proxy;
 
+  int proxy_logging;
+
   struct endpoint {
     char name[4];
     struct context *ctx;       /* Backpointer */
 
+    int logging;
+
     int running;
 
     condition_function *next_condition;
@@ -138,6 +142,10 @@ struct context
     sip_contact_t *contact;
     sip_from_t *to;
 
+    sip_allow_t *allow;
+    char const *appl_method;
+    sip_supported_t *supported;
+
     printer_function *printer;
 
     char const *instance;
@@ -158,12 +166,11 @@ struct context
     struct eventlist specials[1];
 
     /* State flags for complex scenarios */
-    union {
-      struct {
-       unsigned bit0:1, bit1:1, bit2:1, bit3:1;
-       unsigned bit4:1, bit5:1, bit6:1, bit7:1;
-      } b;
+    struct {
       unsigned n;
+      unsigned bit0:1, bit1:1, bit2:1, bit3:1;
+      unsigned bit4:1, bit5:1, bit6:1, bit7:1;
+      unsigned :0;
     } flags;
 
   } a, b, c;
@@ -185,6 +192,9 @@ int save_event_in_list(struct context *,
                       struct call *);
 void free_events_in_list(struct context *,
                         struct eventlist *);
+void free_event_in_list(struct context *ctx,
+                       struct eventlist *list,
+                       struct event *e);
 
 #define CONDITION_PARAMS                       \
   nua_event_t event,                           \
@@ -204,6 +214,9 @@ int save_until_special(CONDITION_PARAMS);
 int until_terminated(CONDITION_PARAMS);
 int until_ready(CONDITION_PARAMS);
 int accept_call(CONDITION_PARAMS);
+int cancel_when_ringing(CONDITION_PARAMS);
+
+int accept_notify(CONDITION_PARAMS);
 
 void a_callback(nua_event_t event,
                int status, char const *phrase,
@@ -316,11 +329,10 @@ int test_nat_timeout(struct context *ctx);
 int test_unregister(struct context *ctx);
 
 int test_basic_call(struct context *ctx);
-int test_reject_a(struct context *ctx);
-int test_reject_b(struct context *ctx);
-int test_reject_302(struct context *ctx);
-int test_reject_401(struct context *ctx);
+int test_offer_answer(struct context *ctx);
+int test_rejects(struct context *ctx);
 int test_mime_negotiation(struct context *ctx);
+int test_call_timeouts(struct context *ctx);
 int test_reject_401_aka(struct context *ctx);
 int test_call_cancel(struct context *ctx);
 int test_call_destroy(struct context *ctx);
index ea62e5500b0b768206d6405e43c49176ba0e52c4..604d7475d1128d4de3dc3023ad1b2f1557108833 100644 (file)
@@ -210,7 +210,10 @@ int test_stack_errors(struct context *ctx)
   run_a_until(ctx, -1, save_until_final_response);
 
   TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_unregister);
-  TEST(e->data->e_status, 401);
+  if (e->data->e_status == 401)
+    TEST(e->data->e_status, 401);
+  else
+    TEST(e->data->e_status, 406);
   TEST_1(!e->next);
 
   free_events_in_list(ctx, a->events);
index 5483fc28a375142d0a59367dd53a30aba895e7d4..4cd3aee05364c0226caf909407c52665f04d2159 100644 (file)
@@ -117,12 +117,12 @@ int test_nua_params(struct context *ctx)
   nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
   run_a_until(ctx, nua_r_get_params, save_until_final_response);
 
-  TEST_1(e = ctx->a.events->head);
+  TEST_1(e = ctx->a.specials->head);
   TEST_E(e->data->e_event, nua_r_get_params);
   for (n = 0, t = e->data->e_tags; t; n++, t = tl_next(t))
     ;
   TEST_1(n > 32);
-  free_events_in_list(ctx, ctx->a.events);
+  free_events_in_list(ctx, ctx->a.specials);
 
   nh = nua_handle(ctx->a.nua, NULL, TAG_END()); TEST_1(nh);
   nua_handle_unref(nh);
@@ -148,9 +148,12 @@ int test_nua_params(struct context *ctx)
 
                 SIPTAG_SUPPORTED_STR("test"),
                 SIPTAG_ALLOW_STR("DWIM, OPTIONS, INFO"),
+                NUTAG_APPL_METHOD(NULL),
+                NUTAG_APPL_METHOD("INVITE, REGISTER, PUBLISH, SUBSCRIBE"),
                 SIPTAG_ALLOW_EVENTS_STR("reg"),
                 SIPTAG_USER_AGENT_STR("test_nua/1.0"),
 
+
                 SIPTAG_ORGANIZATION_STR("Open Laboratory"),
                 
                 NUTAG_M_DISPLAY("XXX"),
@@ -190,6 +193,7 @@ int test_nua_params(struct context *ctx)
                 NUTAG_MEDIA_FEATURES(1),
                 NUTAG_SERVICE_ROUTE_ENABLE(0),
                 NUTAG_PATH_ENABLE(0),
+                NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
                 NUTAG_REFER_EXPIRES(333),
                 NUTAG_REFER_WITH_ID(0),
                 NUTAG_SUBSTATE(nua_substate_pending),
@@ -211,10 +215,13 @@ int test_nua_params(struct context *ctx)
                 SIPTAG_ALLOW(sip_allow_make(tmphome, "INFO")),
                 NUTAG_ALLOW("ACK, INFO"),
 
+                NUTAG_APPL_METHOD("NOTIFY"),
+
                 SIPTAG_ALLOW_EVENTS_STR("reg"),
                 SIPTAG_ALLOW_EVENTS(sip_allow_events_make(tmphome, "presence")),
                 NUTAG_ALLOW_EVENTS("presence.winfo"),
 
+
                 SIPTAG_USER_AGENT(sip_user_agent_make(tmphome, "test_nua")),
 
                 SIPTAG_ORGANIZATION(sip_organization_make(tmphome, "Pussy Galore's Flying Circus")),
@@ -262,12 +269,14 @@ int test_nua_params(struct context *ctx)
     int media_features = -1;
     int service_route_enable = -1;
     int path_enable = -1;
+    int auth_cache = -1;
     unsigned refer_expires = (unsigned)-1;
     int refer_with_id = -1;
     int substate = -1;
 
     sip_allow_t const *allow = NONE;
     char const *allow_str = "NONE";
+    char const *appl_method = "NONE";
     sip_allow_events_t const *allow_events = NONE;
     char const *allow_events_str = "NONE";
     sip_supported_t const *supported = NONE;
@@ -291,7 +300,7 @@ int test_nua_params(struct context *ctx)
     nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
     run_a_until(ctx, nua_r_get_params, save_until_final_response);
 
-    TEST_1(e = ctx->a.events->head);
+    TEST_1(e = ctx->a.specials->head);
     TEST_E(e->data->e_event, nua_r_get_params);
 
     n = tl_gets(e->data->e_tags,
@@ -324,6 +333,7 @@ int test_nua_params(struct context *ctx)
                NUTAG_MEDIA_FEATURES_REF(media_features),
                NUTAG_SERVICE_ROUTE_ENABLE_REF(service_route_enable),
                NUTAG_PATH_ENABLE_REF(path_enable),
+               NUTAG_AUTH_CACHE_REF(auth_cache),
                NUTAG_REFER_EXPIRES_REF(refer_expires),
                NUTAG_REFER_WITH_ID_REF(refer_with_id),
                NUTAG_SUBSTATE_REF(substate),
@@ -332,6 +342,7 @@ int test_nua_params(struct context *ctx)
                SIPTAG_SUPPORTED_STR_REF(supported_str),
                SIPTAG_ALLOW_REF(allow),
                SIPTAG_ALLOW_STR_REF(allow_str),
+               NUTAG_APPL_METHOD_REF(appl_method),
                SIPTAG_ALLOW_EVENTS_REF(allow_events),
                SIPTAG_ALLOW_EVENTS_STR_REF(allow_events_str),
                SIPTAG_USER_AGENT_REF(user_agent),
@@ -353,7 +364,7 @@ int test_nua_params(struct context *ctx)
                NUTAG_INSTANCE_REF(instance),
 
                TAG_END());
-    TEST(n, 46);
+    TEST(n, 48);
 
     TEST_S(sip_header_as_string(tmphome, (void *)from), Alice);
     TEST_S(from_str, Alice);
@@ -383,12 +394,14 @@ int test_nua_params(struct context *ctx)
     TEST(media_features, 1);
     TEST(service_route_enable, 0);
     TEST(path_enable, 0);
+    TEST(auth_cache, nua_auth_cache_challenged);
     TEST(refer_expires, 333);
     TEST(refer_with_id, 0);
     TEST(substate, nua_substate_pending);
 
     TEST_S(sip_header_as_string(tmphome, (void *)allow), "OPTIONS, INFO, ACK");
     TEST_S(allow_str, "OPTIONS, INFO, ACK");
+    TEST_S(appl_method, "INVITE, REGISTER, PUBLISH, SUBSCRIBE, NOTIFY");
     TEST_S(sip_header_as_string(tmphome, (void *)allow_events), 
           "reg, presence, presence.winfo");
     TEST_S(allow_events_str, "reg, presence, presence.winfo");
@@ -414,7 +427,7 @@ int test_nua_params(struct context *ctx)
     TEST_S(m_features, expect_m_features); }
     TEST_S(outbound, "foo");
 
-    free_events_in_list(ctx, ctx->a.events);
+    free_events_in_list(ctx, ctx->a.specials);
   }
 
   /* Test that only those tags that have been set per handle are returned by nua_get_hparams() */
@@ -446,6 +459,7 @@ int test_nua_params(struct context *ctx)
     int media_features = -1;
     int service_route_enable = -1;
     int path_enable = -1;
+    int auth_cache = -1;
     unsigned refer_expires = (unsigned)-1;
     int refer_with_id = -1;
     int substate = -1;
@@ -504,6 +518,7 @@ int test_nua_params(struct context *ctx)
                NUTAG_MEDIA_FEATURES_REF(media_features),
                NUTAG_SERVICE_ROUTE_ENABLE_REF(service_route_enable),
                NUTAG_PATH_ENABLE_REF(path_enable),
+               NUTAG_AUTH_CACHE_REF(auth_cache),
                NUTAG_SUBSTATE_REF(substate),
 
                SIPTAG_SUPPORTED_REF(supported),
@@ -556,6 +571,7 @@ int test_nua_params(struct context *ctx)
     TEST(media_features, -1);
     TEST(service_route_enable, -1);
     TEST(path_enable, -1);
+    TEST(auth_cache, -1);
     TEST(refer_expires, (unsigned)-1);
     TEST(refer_with_id, -1);
     TEST(substate, -1);
diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/test_offer_answer.c b/libs/sofia-sip/libsofia-sip-ua/nua/test_offer_answer.c
new file mode 100644 (file)
index 0000000..3fa5afe
--- /dev/null
@@ -0,0 +1,479 @@
+/*
+ * 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
+ *
+ */
+
+/**@CFILE test_offer_answer.c
+ * @brief Test offer/answer failures.
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ *
+ * @date Created: Wed Aug 17 12:12:12 EEST 2005 ppessi
+ */
+
+#include "config.h"
+
+#include "test_nua.h"
+#include <sofia-sip/su_tag_class.h>
+
+#if HAVE_FUNC
+#elif HAVE_FUNCTION
+#define __func__ __FUNCTION__
+#else
+#define __func__ "test_offer_answer"
+#endif
+
+
+/* ======================================================================== */
+
+/* Send offer in INVITE, no answer:
+
+                          A                    B
+          --nua_invite()-->|                    |
+                           |-------INVITE------>|
+          <--nua_i_state---|                    |
+                           |<----100 Trying-----|
+                           |                    |
+                           |<--------180--------|
+          <--nua_r_invite--|                    |
+          <--nua_i_state---|                    |
+                           |<------200 OK-------|
+          <--nua_r_invite--|                    |
+                           |--------ACK-------->|
+                           |--------BYE-------->|
+          <--nua_i_state---|                    |
+                           |<-------200 OK------|
+          <--nua_r_bye-----|                    |
+          <--nua_i_state---|                    |
+
+   Client transitions:
+   INIT -(C1)-> CALLING -(C2a)-> PROCEEDING -(C3+C4)-> 
+   TERMINATING -> TERMINATED
+   Server transitions:
+   INIT -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S4)-> READY
+   -> TERMINATED
+
+*/
+
+int no_media_terminated(CONDITION_PARAMS);
+
+int test_no_answer_1(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t *sip;
+
+  if (print_headings)
+    printf("TEST NUA-6.5: No SDP answer from callee\n");
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = NULL;
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  INVITE(a, a_call, a_call->nh,
+        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+        SOATAG_USER_SDP_STR(a_call->sdp),
+        NUTAG_M_USERNAME("a+a"),
+        NUTAG_M_DISPLAY("Alice"),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated, -1, no_media_terminated);
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C3)-> PROCEEDING: nua_r_invite, nua_i_state 
+     PROCEEDING -(C3a+C5)-> TERMINATING: nua_r_invite, nua_i_state 
+     TERMINATING -(C12)-> TERMINATED: nua_r_bye, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(!sip->sip_payload);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(!is_answer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(!sip->sip_payload);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_media_error);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+   READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_contact);
+  TEST_S(sip->sip_contact->m_display, "Alice");
+  TEST_S(sip->sip_contact->m_url->url_user, "a+a");
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(!is_answer_recv(e->data->e_tags));
+  TEST_1(!is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.5: PASSED\n");
+
+  END();
+}
+
+int no_media_terminated(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_180_RINGING, 
+           NUTAG_MEDIA_ENABLE(0),
+           TAG_END());
+    return 0;
+  case nua_callstate_early:
+    RESPOND(ep, call, nh, SIP_200_OK,
+           NUTAG_MEDIA_ENABLE(0),
+           TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+int accept_call_until_terminated(CONDITION_PARAMS);
+
+/* No offer in INVITE, offer in 200 OK, no answer in ACK */
+int test_no_answer_2(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t const *sip;
+
+  if (print_headings)
+    printf("TEST NUA-6.6: No SDP offer from caller\n");
+
+  a_call->sdp = "v=0\r\n"
+    "o=- 1 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5008 RTP/AVP 8\r\n";
+
+  b_call->sdp = 
+    "v=0\r\n"
+    "o=- 2 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5010 RTP/AVP 0 8\r\n";
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, 
+                                SIPTAG_TO_STR("<sip:b@x.org>"),
+                                TAG_END()));
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  INVITE(a, a_call, a_call->nh,
+        NUTAG_MEDIA_ENABLE(0),
+        NUTAG_URL(b->contact->m_url),
+        NUTAG_AUTOACK(1),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated,
+              -1, accept_call_until_terminated);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
+     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(!is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(!is_answer_recv(e->data->e_tags));
+  TEST_1(!is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_content_type); 
+  TEST_S(sip->sip_content_type->c_type, "application/sdp");
+  TEST_1(sip->sip_payload);    /* there is sdp in 200 OK */
+  TEST_1(sip->sip_contact);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* READY */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(!is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_media_error);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-6.6: PASSED\n");
+
+  END();
+}
+
+int accept_call_until_terminated(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_180_RINGING, 
+           TAG_END());
+    return 0;
+  case nua_callstate_early:
+    RESPOND(ep, call, nh, SIP_200_OK,
+           NUTAG_MEDIA_ENABLE(1),
+           TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
+           TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+
+/* No offer in INVITE, no user SDP in 200 OK */
+int test_missing_user_sdp(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+
+  if (print_headings)
+    printf("TEST NUA-6.6.2: No SDP offer from caller\n");
+
+  a_call->sdp = "v=0\r\n"
+    "o=- 1 1 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 5008 RTP/AVP 8\r\n";
+
+  b_call->sdp = NULL;
+
+  nua_set_params(b->nua, NUTAG_MEDIA_ENABLE(0), TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, 
+                                SIPTAG_TO_STR("<sip:b@x.org>"),
+                                TAG_END()));
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  INVITE(a, a_call, a_call->nh,
+        NUTAG_MEDIA_ENABLE(0),
+        NUTAG_URL(b->contact->m_url),
+        NUTAG_AUTOACK(1),
+        TAG_END());
+
+  run_ab_until(ctx, -1, until_terminated,
+              -1, accept_call_until_terminated);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
+     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(!is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(!is_answer_recv(e->data->e_tags));
+  TEST_1(!is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 500);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* READY */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(!is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(!is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_error);
+  TEST(e->data->e_status, 500);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* COMPLETED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  TEST_1(!nua_handle_has_active_call(b_call->nh));
+  TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  nua_set_params(b->nua,
+                NUTAG_MEDIA_ENABLE(1), 
+                SOATAG_USER_SDP_STR("m=audio 5006 RTP/AVP 8 0"),
+                TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  if (print_headings)
+    printf("TEST NUA-6.6.2: PASSED\n");
+
+  END();
+}
+
+
+
+int test_offer_answer(struct context *ctx)
+{
+  return
+    test_no_answer_1(ctx) ||
+    test_no_answer_2(ctx) ||
+    test_missing_user_sdp(ctx) ||
+    0;
+}
index ecf9fd2185ab6f60809cf9c8a377bfb3f09ca243..ec7700975c82f1cb10c25fb677dd82fee14e01b7 100644 (file)
@@ -44,7 +44,7 @@
 
 int save_events(CONDITION_PARAMS)
 {
-  return save_event_in_list(ctx, event, ep, ep->call) == event_is_normal;
+  return save_event_in_list(ctx, event, ep, call) == event_is_normal;
 }
 
 int until_final_response(CONDITION_PARAMS)
@@ -54,7 +54,7 @@ int until_final_response(CONDITION_PARAMS)
 
 int save_until_final_response(CONDITION_PARAMS)
 {
-  save_event_in_list(ctx, event, ep, ep->call);
+  save_event_in_list(ctx, event, ep, call);
   return event >= nua_r_set_params && status >= 200;
 }
 
@@ -64,13 +64,13 @@ int save_until_final_response(CONDITION_PARAMS)
  */
 int save_until_received(CONDITION_PARAMS)
 {
-  return save_event_in_list(ctx, event, ep, ep->call) == event_is_normal;
+  return save_event_in_list(ctx, event, ep, call) == event_is_normal;
 }
 
 /** Save events until nua_i_outbound is received.  */
 int save_until_special(CONDITION_PARAMS)
 {
-  return save_event_in_list(ctx, event, ep, ep->call) == event_is_special;
+  return save_event_in_list(ctx, event, ep, call) == event_is_special;
 }
 
 /* Return call state from event tag list */
@@ -143,34 +143,49 @@ void print_event(nua_event_t event,
                 sip_t const *sip,
                 tagi_t tags[])
 {
+  tagi_t const *t;
+
   if (event == nua_i_state) {
     fprintf(stderr, "%s.nua(%p): event %s %s\n",
-           ep->name, nh, nua_event_name(event),
+           ep->name, (void *)nh, nua_event_name(event),
            nua_callstate_name(callstate(tags)));
   }
   else if ((int)event >= nua_r_set_params) {
-    fprintf(stderr, "%s.nua(%p): event %s status %u %s\n",
-           ep->name, nh, nua_event_name(event), status, phrase);
+    t = tl_find(tags, nutag_substate);
+    if (t) {
+      fprintf(stderr, "%s.nua(%p): event %s status %u %s (%s)\n",
+             ep->name, (void*)nh, nua_event_name(event), status, phrase,
+             nua_substate_name(t->t_value));
+    }
+    else {
+      fprintf(stderr, "%s.nua(%p): event %s status %u %s\n",
+             ep->name, (void *)nh, nua_event_name(event), status, phrase);
+    }
+  }
+  else if (event == nua_i_notify) {
+    t = tl_find(tags, nutag_substate);
+    fprintf(stderr, "%s.nua(%p): event %s %s (%s)\n",
+           ep->name, (void *)nh, nua_event_name(event), phrase,
+           nua_substate_name(t ? t->t_value : 0));
   }
   else if ((int)event >= 0) {
     fprintf(stderr, "%s.nua(%p): event %s %s\n",
-           ep->name, nh, nua_event_name(event), phrase);
+           ep->name, (void *)nh, nua_event_name(event), phrase);
   }
   else if (status > 0) {
     fprintf(stderr, "%s.nua(%p): call %s() with status %u %s\n",
-           ep->name, nh, operation, status, phrase);
+           ep->name, (void *)nh, operation, status, phrase);
   }
   else {
-    tagi_t const *t;
     t = tl_find(tags, siptag_subject_str);
     if (t && t->t_value) {
       char const *subject = (char const *)t->t_value;
       fprintf(stderr, "%s.nua(%p): call %s() \"%s\"\n",
-             ep->name, nh, operation, subject);
+             ep->name, (void *)nh, operation, subject);
     }
     else
       fprintf(stderr, "%s.nua(%p): call %s()\n",
-             ep->name, nh, operation);
+             ep->name, (void *)nh, operation);
   }
 
   if ((tstflags & tst_verbatim) && tags)
@@ -202,10 +217,11 @@ void ep_callback(nua_event_t event,
     }
   }
 
-  if ((ep->next_event == -1 || ep->next_event == event) &&
-      (ep->next_condition == NULL ||
+  if ((ep->next_condition == NULL ||
        ep->next_condition(event, status, phrase,
-                         nua, ctx, ep, nh, call, sip, tags)))
+                         nua, ctx, ep, nh, call, sip, tags))
+      &&
+      (ep->next_event == -1 || ep->next_event == event))
     ep->running = 0;
 
   ep->last_event = event;
@@ -256,21 +272,21 @@ void run_abc_until(struct context *ctx,
   a->last_event = -1;
   a->running = a_condition != NULL && a_condition != save_events;
   a->running |= a_event != -1;
-  a->flags.n = 0;
+  memset(&a->flags, 0, sizeof a->flags);
 
   b->next_event = b_event;
   b->next_condition = b_condition;
   b->last_event = -1;
   b->running = b_condition != NULL && b_condition != save_events;
   b->running |= b_event != -1;
-  b->flags.n = 0;
+  memset(&b->flags, 0, sizeof b->flags);
 
   c->next_event = c_event;
   c->next_condition = c_condition;
   c->last_event = -1;
   c->running = c_condition != NULL && c_condition != save_events;
   c->running |= c_event != -1;
-  c->flags.n = 0;
+  memset(&c->flags, 0, sizeof c->flags);
 
   for (; a->running || b->running || c->running;) {
     su_root_step(ctx->root, 1000);
@@ -379,7 +395,7 @@ int RESPOND(struct endpoint *ep,
   return 0;
 }
 
-/* Destroy an handle */
+/* Destroy a handle */
 int DESTROY(struct endpoint *ep,
            struct call *call,
            nua_handle_t *nh)
@@ -450,7 +466,7 @@ int save_event_in_list(struct context *ctx,
   return action;
 }
 
-/* Save nua event in endpoint list */
+/* Free nua events from endpoint list */
 void free_events_in_list(struct context *ctx,
                         struct eventlist *list)
 {
@@ -466,6 +482,21 @@ void free_events_in_list(struct context *ctx,
   list->tail = &list->head;
 }
 
+void free_event_in_list(struct context *ctx,
+                       struct eventlist *list,
+                       struct event *e)
+{
+  if (e) {
+    if ((*e->prev = e->next))
+      e->next->prev = e->prev;
+    nua_destroy_event(e->saved_event);
+    su_free(ctx->home, e);
+
+    if (list->head == NULL)
+      list->tail = &list->head;
+  }
+}                            
+
 int is_special(nua_event_t e)
 {
   if (e == nua_i_active || e == nua_i_terminated)
index 198f7ad914c6219d91cfdebd0348b431b5c4bc73..5cf9e8a4afaf50f5627871b9024e2e27abbffcd6 100644 (file)
@@ -52,6 +52,7 @@ struct binding;
 #include <sofia-sip/auth_module.h>
 #include <sofia-sip/su_tagarg.h>
 #include <sofia-sip/msg_addr.h>
+#include <sofia-sip/hostdomain.h>
 
 #include <stdlib.h>
 #include <assert.h>
@@ -228,9 +229,10 @@ test_proxy_init(su_root_t *root, struct proxy *proxy)
                                  URL_STRING_MAKE("sip:0.0.0.0:*"),
                                  NULL, NULL,
                                  NTATAG_UA(0),
+                                 NTATAG_CANCEL_487(0),
                                  NTATAG_SERVER_RPORT(1),
                                  NTATAG_CLIENT_RPORT(1),
-                                 TAG_END());
+                                 TAG_NEXT(proxy->tags));
 
   proxy->transport_contacts = create_transport_contacts(proxy);
 
@@ -308,7 +310,7 @@ test_proxy_deinit(su_root_t *root, struct proxy *proxy)
   free(proxy->tags);
 }
 
-/* Create tst proxy object */
+/* Create test proxy object */
 struct proxy *test_proxy_create(su_root_t *root,
                                tag_type_t tag, tag_value_t value, ...)
 {
@@ -373,6 +375,27 @@ void test_proxy_get_expiration(struct proxy *p,
   }
 }
 
+void test_proxy_set_session_timer(struct proxy *p,
+                                 sip_time_t session_expires, 
+                                 sip_time_t min_se)
+{
+  if (p) {
+    p->prefs.session_expires = session_expires;
+    p->prefs.min_se = min_se;
+  }
+}
+
+void test_proxy_get_session_timer(struct proxy *p,
+                                 sip_time_t *return_session_expires,
+                                 sip_time_t *return_min_se)
+{
+  if (p) {
+    if (return_session_expires)
+      *return_session_expires = p->prefs.session_expires;
+    if (return_min_se) *return_min_se = p->prefs.min_se;
+  }
+}
+
 /* ---------------------------------------------------------------------- */
 
 static sip_contact_t *create_transport_contacts(struct proxy *p)
@@ -425,6 +448,7 @@ int proxy_request(struct proxy *proxy,
 
   sip_session_expires_t *x = NULL, x0[1];
   sip_min_se_t *min_se = NULL, min_se0[1];
+  char const *require = NULL;
 
   mf = sip->sip_max_forwards;
 
@@ -445,24 +469,33 @@ int proxy_request(struct proxy *proxy,
   }
 
   if (method == sip_method_invite) {
-    if (!sip->sip_min_se || 
-       sip->sip_min_se->min_delta < proxy->prefs.min_se) {
-      min_se = sip_min_se_init(min_se0);
-      min_se->min_delta = proxy->prefs.min_se;
-    }
+    if (proxy->prefs.min_se) {
+      if (!sip->sip_min_se || 
+         sip->sip_min_se->min_delta < proxy->prefs.min_se) {
+       min_se = sip_min_se_init(min_se0);
+       min_se->min_delta = proxy->prefs.min_se;
+      }
 
-    if (!sip->sip_session_expires) {
-      x = sip_session_expires_init(x0);
-      x->x_delta = proxy->prefs.session_expires;
+      if (sip->sip_session_expires
+         && sip->sip_session_expires->x_delta < proxy->prefs.min_se
+         && sip_has_supported(sip->sip_supported, "timer")) {
+       if (min_se == NULL)
+         min_se = sip->sip_min_se; assert(min_se);
+       nta_incoming_treply(irq, SIP_422_SESSION_TIMER_TOO_SMALL,
+                           SIPTAG_MIN_SE(min_se),
+                           TAG_END());
+       return 422;
+      }
     }
-    else if (sip->sip_session_expires->x_delta < proxy->prefs.min_se
-            && sip_has_supported(sip->sip_supported, "timer")) {
-      if (min_se == NULL)
-       min_se = sip->sip_min_se; assert(min_se);
-      nta_incoming_treply(irq, SIP_422_SESSION_TIMER_TOO_SMALL,
-                         SIPTAG_MIN_SE(min_se),
-                         TAG_END());
-      return 422;
+
+    if (proxy->prefs.session_expires) {
+      if (!sip->sip_session_expires ||
+         sip->sip_session_expires->x_delta > proxy->prefs.session_expires) {
+       x = sip_session_expires_init(x0);
+       x->x_delta = proxy->prefs.session_expires;
+       if (!sip_has_supported(sip->sip_supported, "timer"))
+         require = "timer";
+      }
     }
   }
 
@@ -526,6 +559,7 @@ int proxy_request(struct proxy *proxy,
                                   SIPTAG_REQUEST(rq),
                                   SIPTAG_SESSION_EXPIRES(x),
                                   SIPTAG_MIN_SE(min_se),
+                                  SIPTAG_REQUIRE_STR(require),
                                   TAG_END());
   if (t->client == NULL) {
     proxy_transaction_destroy(t);
@@ -707,8 +741,8 @@ static int binding_update(struct proxy *p,
 sip_contact_t *binding_contacts(su_home_t *home, struct binding *bindings);
 
 int process_register(struct proxy *proxy,
-                     nta_incoming_t *irq,
-                     sip_t const *sip)
+                    nta_incoming_t *irq,
+                    sip_t const *sip)
 {
   auth_status_t *as;
   msg_t *msg;
@@ -751,6 +785,13 @@ static int process_register2(struct proxy *p,
                             sip_t const *sip)
 {
   struct registration_entry *e = NULL;
+  sip_contact_t *m = sip->sip_contact;
+  sip_via_t *v = sip->sip_via;
+
+  if (m && v && v->v_received && m->m_url->url_host
+      && strcasecmp(v->v_received, m->m_url->url_host) 
+      && host_is_ip_address(m->m_url->url_host))
+    return set_status(as, 406, "Unacceptable Contact");
 
   auth_mod_check_client(p->auth, as, sip->sip_authorization,
                        registrar_challenger);
index f12f5cb5c0e1332966ed32211865ef520a142db3..bd7551ea616244392ccd48449f06317d49f3e438 100644 (file)
@@ -48,6 +48,14 @@ void test_proxy_get_expiration(struct proxy *,
                               sip_time_t *return_expires, 
                               sip_time_t *return_max_expires);
 
+void test_proxy_set_session_timer(struct proxy *p,
+                                 sip_time_t session_expires, 
+                                 sip_time_t min_se);
+
+void test_proxy_get_session_timer(struct proxy *p,
+                                 sip_time_t *return_session_expires,
+                                 sip_time_t *return_min_se);
+
 SOFIA_END_DECLS
 
 #endif
index 402d37ace21681716daa4af52b691d55e8bb3f2a..8cc97c1d597affaafde1c5d406e8eb4e9aab3ce9 100644 (file)
 #define __func__ "test_call_hold"
 #endif
 
-int accept_call_immediately(CONDITION_PARAMS);
-
 /* ======================================================================== */
 /* NUA-9 tests: REFER */
 
-int test_refer0(struct context *ctx, int refer_with_id, char const *tests);
-int test_refer1(struct context *ctx, int refer_with_id, char const *tests);
+int test_refer0(struct context *ctx, char const *tests,
+               int refer_with_id, int notify_by_appl);
+
+int notify_until_terminated(CONDITION_PARAMS);
 
 int test_refer(struct context *ctx)
 {
   /* test twice, once without id and once with id */
   return
-    test_refer0(ctx, 0, "NUA-9.1") ||
-    test_refer0(ctx, 1, "NUA-9.2") ||
-    test_refer1(ctx, 0, "NUA-9.3");
+    test_refer0(ctx, "NUA-9.1", 0, 0) ||
+    test_refer0(ctx, "NUA-9.2", 1, 0) ||
+    test_refer0(ctx, "NUA-9.3", 0, 1) ||
+    test_refer0(ctx, "NUA-9.4", 1, 1);
 }
 
 /* Referred call:
@@ -103,13 +104,15 @@ int test_refer(struct context *ctx)
 
 */
 
-int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
+int test_refer0(struct context *ctx, char const *tests,
+               int refer_with_id, int notify_by_appl)
 {
   BEGIN();
 
   struct endpoint *a = &ctx->a,  *b = &ctx->b, *c = &ctx->c;
   struct call *a_call = a->call, *b_call = b->call, *c_call = c->call;
-  struct call *a_c2;
+  struct call *a_refer, *a_c2, *b_refer;
+  struct eventlist *a_revents, *b_revents;
   struct event *e;
   sip_t const *sip;
   sip_event_t const *a_event, *b_event;
@@ -124,7 +127,10 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   su_home_auto(tmphome, sizeof(tmphome));
 
   if (print_headings)
-    printf("TEST %s: REFER: refer A to C\n", tests);
+    printf("TEST %s: REFER: refer A to C%s%s%s\n", tests,
+          refer_with_id ? " with Event id" : "",
+          refer_with_id && !notify_by_appl ? " and" : "",
+          !notify_by_appl ? " nua generating the NOTIFYs" : "");
 
   if (print_headings)
     printf("TEST %s.1: REFER: make a call between A and B\n", tests);
@@ -133,6 +139,28 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   nua_set_params(ctx->a.nua, NUTAG_REFER_WITH_ID(refer_with_id), TAG_END());
   run_a_until(ctx, nua_r_set_params, until_final_response);
 
+  if (refer_with_id) {
+    TEST_1(a_refer = calloc(1, (sizeof *a_refer) + (sizeof *a_refer->events)));
+    call_init(a_refer);
+    a_refer->events = (void *)(a_refer + 1);
+    eventlist_init(a_refer->events);
+
+    a_call->next = a_refer;
+    a_revents = a_refer->events;
+
+    TEST_1(b_refer = calloc(1, (sizeof *b_refer) + (sizeof *b_refer->events)));
+    call_init(b_refer);
+    b_refer->events = (void *)(b_refer + 1);
+    eventlist_init(b_refer->events);
+
+    b_call->next = b_refer;
+    b_revents = b_refer->events;
+  }
+  else {
+    a_refer = a_call, b_refer = b_call;
+    a_revents = a->events, b_revents = b->events;
+  }
+
   TEST_1(a_c2 = calloc(1, (sizeof *a_c2) + (sizeof *a_c2->events)));
   call_init(a_c2);
   a_c2->events = (void *)(a_c2 + 1);
@@ -198,7 +226,7 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
     printf("TEST %s.1: PASSED\n", tests);
 
   /* ---------------------------------------------------------------------- */
-  /* REFER (initial NOTIFY is no more sent)
+  /* REFER (initial NOTIFY is no more sent unless REFER creates a new dialog)
    A                    B
    |<------REFER--------|
    |-------200 OK------>|
@@ -207,13 +235,20 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
    */
 
   if (print_headings)
-    printf("TEST %s.2: refer A to C\n", tests);
+    printf("TEST %s.2: B refers A to C\n", tests);
+
+  if (b_refer != b_call)
+    TEST_1(b_refer->nh = 
+          nua_handle(b->nua, b_refer, SIPTAG_TO(a->to), TAG_END()));
 
   *sip_refer_to_init(r0)->r_url = *c->contact->m_url;
   r0->r_url->url_headers = "subject=referred";
   r0->r_display = "C";
 
-  REFER(b, b_call, b_call->nh, SIPTAG_REFER_TO(r0), TAG_END());
+  REFER(b, b_refer, b_refer->nh, SIPTAG_REFER_TO(r0),
+       TAG_IF(!ctx->proxy_tests && b_refer != b_call,
+              NUTAG_URL(a->contact->m_url)),
+       TAG_END());
   run_ab_until(ctx, -1, save_until_received,
               -1, save_until_final_response);
 
@@ -221,7 +256,7 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
     Events in A:
     nua_i_refer
   */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_refer);
+  TEST_1(e = a_revents->head); TEST_E(e->data->e_event, nua_i_refer);
   TEST(e->data->e_status, 202);
   a_event = NULL;
   TEST(tl_gets(e->data->e_tags,
@@ -233,17 +268,12 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   TEST_1(refer_to = sip_refer_to_dup(tmphome, sip->sip_refer_to));
   TEST_1(sip->sip_referred_by);
   TEST_1(referred_by = sip_referred_by_dup(tmphome, sip->sip_referred_by));
-  if (e->next) {
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
-  TEST_1(!e->next);
-  }
-  free_events_in_list(ctx, a->events);
 
   /*
      Events in B after nua_refer():
      nua_r_refer
   */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_refer);
+  TEST_1(e = b_revents->head); TEST_E(e->data->e_event, nua_r_refer);
   TEST(e->data->e_status, 100);
   TEST(tl_gets(e->data->e_tags,
               NUTAG_REFER_EVENT_REF(b_event),
@@ -254,22 +284,32 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   TEST(e->data->e_status, 202);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_SIZE(strtoul(b_event->o_id, NULL, 10), sip->sip_cseq->cs_seq);
-#if 0
-  if (!e->next)
-    run_b_until(ctx, -1, save_until_received);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
-  TEST(e->data->e_status, 200);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_event);
-  if (refer_with_id)
-    TEST_S(sip->sip_event->o_id, b_event->o_id);
-  TEST_1(sip->sip_subscription_state);
-  TEST_S(sip->sip_subscription_state->ss_substate, "pending");
-  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
-  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
-  TEST_1(!e->next);
-#endif
-  free_events_in_list(ctx, b->events);
+
+  if (a_refer != a_call) {
+    if (b_revents->head->next->next == NULL)
+      run_ab_until(ctx, -1, save_until_received, nua_i_notify, save_events);
+    else if (a_revents->head->next == NULL)
+      run_a_until(ctx, -1, save_until_received);
+
+    TEST_1(e = a_revents->head->next); TEST_E(e->data->e_event, nua_r_notify);
+    TEST_1(!e->next);
+
+    TEST_1(e = b_revents->head->next->next);
+    TEST_E(e->data->e_event, nua_i_notify);
+    TEST(e->data->e_status, 200);
+    TEST_1(sip = sip_object(e->data->e_msg));
+    TEST_1(sip->sip_event);
+    if (refer_with_id)
+      TEST_S(sip->sip_event->o_id, b_event->o_id);
+    TEST_1(sip->sip_subscription_state);
+    TEST_S(sip->sip_subscription_state->ss_substate, "pending");
+    TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
+    TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
+    TEST_1(!e->next);
+  }
+
+  free_events_in_list(ctx, a_revents);
+  free_events_in_list(ctx, b_revents);
 
   if (print_headings)
     printf("TEST %s.2: PASSED\n", tests);
@@ -371,42 +411,43 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   *sip_to_init(to)->a_url = *refer_to->r_url;
   to->a_display = refer_to->r_display;
 
-  a->call->next = a_c2;
+  a_refer->next = a_c2;
 
   TEST_1(a_c2->nh = nua_handle(a->nua, a_c2, SIPTAG_TO(to), TAG_END()));
 
   INVITE(a, a_c2, a_c2->nh, /* NUTAG_URL(refer_to->r_url), */
-        NUTAG_REFER_EVENT(a_event),
-        NUTAG_NOTIFY_REFER(a_call->nh),
+        TAG_IF(!notify_by_appl, NUTAG_REFER_EVENT(a_event)),
+        TAG_IF(!notify_by_appl, NUTAG_NOTIFY_REFER(a_refer->nh)),
         SOATAG_USER_SDP_STR(a_c2->sdp),
         SIPTAG_REFERRED_BY(referred_by),
         TAG_END());
 
   run_abc_until(ctx,
-               -1, until_ready,
+               -1, notify_by_appl ? notify_until_terminated : until_ready,
                -1, save_until_received,
-               -1, accept_call_immediately);
-  /* XXX - we should use accept_call instead of accept_call_immediately but
-     nua has a problem with automatically generated NOTIFYs:
-     3rd NOTIFY is not sent because 2nd is still in progress
-  */
+               -1, accept_call);
+
+  /* Wait until both NOTIFY has been responded */
+  while (a_revents->head == NULL || a_revents->head->next == NULL)
+    run_ab_until(ctx, -1, save_until_received, -1, save_events);
+  while (b_revents->head == NULL || b_revents->head->next == NULL)
+    run_ab_until(ctx, -1, save_events, -1, save_until_received);
 
   /* Client A transitions:
      INIT -(C1)-> CALLING: nua_invite(), nua_i_state
-     CALLING -(C2a+C4)-> READY: nua_r_invite, nua_i_state
-     nua_i_notify
-
-     XXX should be:
      CALLING -(C2+C4)-> PROCEEDING: nua_r_invite, nua_i_state
-     optional: nua_i_notify
+     nua_r_notify
      PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
-     nua_i_notify
-     optional: nua_i_notify
+     nua_r_notify
   */
   TEST_1(e = a_c2->events->head); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
   TEST_1(is_offer_sent(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
   TEST(e->data->e_status, 200);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
@@ -414,19 +455,32 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   TEST_1(!e->next);
   free_events_in_list(ctx, a_c2->events);
 
-  if (a->events->head == NULL)
-    run_a_until(ctx, -1, save_until_received);
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a->events);
+  TEST_1(e = a_revents->head); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  if (a_refer == a_call && notify_by_appl) {
+    free_event_in_list(ctx, a_revents, a_revents->head);
+    free_event_in_list(ctx, a_revents, a_revents->head);
+  }
+  else {
+    TEST_1(!e->next);
+    free_events_in_list(ctx, a_revents);
+  }
 
   /*
      Events in B after nua_refer():
      nua_i_notify
   */
-  if (b->events->head == NULL)
-    run_b_until(ctx, -1, save_until_received);
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
+  TEST_1(e = b_revents->head); TEST_E(e->data->e_event, nua_i_notify);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "active");
+  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
+  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 180 Ringing\r\n");
+  TEST_1(sip->sip_event);
+  if (refer_with_id)
+    TEST_S(sip->sip_event->o_id, b_event->o_id);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
   TEST(e->data->e_status, 200);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_subscription_state);
@@ -436,13 +490,20 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   TEST_1(sip->sip_event);
   if (refer_with_id)
     TEST_S(sip->sip_event->o_id, b_event->o_id);
-  TEST_1(!e->next);
-  free_events_in_list(ctx, b->events);
+  if (b_refer == b_call && notify_by_appl) {
+    free_event_in_list(ctx, b_revents, b_revents->head);
+    free_event_in_list(ctx, b_revents, b_revents->head);
+  }
+  else {
+    TEST_1(!e->next);
+    free_events_in_list(ctx, b_revents);
+  }
 
   /*
    C transitions:
    INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
    COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
   */
   TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_i_invite);
@@ -451,6 +512,8 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
   TEST_1(is_answer_sent(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
@@ -472,20 +535,28 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   if (print_headings)
     printf("TEST %s.5.1: terminate call between A and B\n", tests);
 
-  BYE(a, a_call, a_call->nh, TAG_END());
-  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+  if (notify_by_appl) {
+    if (!a->events->head || !a->events->head->next)
+      run_ab_until(ctx, -1, until_terminated, -1, save_events);
+    if (!b->events->head || !b->events->head->next)
+      run_ab_until(ctx, -1, save_events, -1, until_terminated);
+  }
+  else {
+    BYE(a, a_call, a_call->nh, TAG_END());
+    run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+  }
 
   /*
-   Transitions of A:
-   READY --(T2)--> TERMINATING: nua_bye()
-   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+    Transitions of A:
+    READY --(T2)--> TERMINATING: nua_bye()
+    TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
   */
   TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
-
+  
   /* Transitions of B:
      READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
   */
@@ -540,10 +611,20 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
   if (print_headings)
     printf("TEST %s.5.2: PASSED\n", tests);
 
+  nua_handle_destroy(c_call->nh), c_call->nh = NULL;
+
   nua_handle_destroy(a_c2->nh), a_c2->nh = NULL;
-  a->call->next = NULL; free(a_c2);
+  a_refer->next = NULL; free(a_c2);
 
-  nua_handle_destroy(c_call->nh), c_call->nh = NULL;
+  if (a_refer != a_call) {
+    nua_handle_destroy(a_refer->nh), a_refer->nh = NULL;
+    a_call->next = NULL; free(a_refer);
+  }
+
+  if (b_refer != b_call) {
+    nua_handle_destroy(b_refer->nh), b_refer->nh = NULL;
+    b_call->next = NULL; free(b_refer);
+  }
 
   if (print_headings)
     printf("TEST %s: PASSED\n", tests);
@@ -554,40 +635,6 @@ int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
 }
 
 
-/*
- accept_call_immediately
-                      X
- |                    |
- |-------INVITE------>|
- |<----100 Trying-----|
- |                    |
- |<--------200--------|
- |---------ACK------->|
-*/
-int accept_call_immediately(CONDITION_PARAMS)
-{
-  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  switch (callstate(tags)) {
-  case nua_callstate_received:
-    RESPOND(ep, call, nh, SIP_200_OK,
-           TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
-           TAG_END());
-    return 0;
-  case nua_callstate_ready:
-    return 1;
-  case nua_callstate_terminated:
-    if (call)
-      nua_handle_destroy(call->nh), call->nh = NULL;
-    return 1;
-  default:
-    return 0;
-  }
-}
-
 /*
  X      INVITE
  |                    |
@@ -610,18 +657,31 @@ int notify_until_terminated(CONDITION_PARAMS)
   if (event == nua_r_invite) {
     sip_status_t *st = sip->sip_status;
     sip_payload_t *pl;
+    struct call *r_call;
+
+    if (!nua_handle_has_events(ep->call->nh))
+      r_call = ep->call->next;
+    else
+      r_call = ep->call;
+
+    assert(nua_handle_has_events(r_call->nh));
 
     pl = sip_payload_format(NULL, "SIP/2.0 %u %s\r\n", 
                            st->st_status, st->st_phrase);
 
-    NOTIFY(ep, ep->call, ep->call->nh,
+    NOTIFY(ep, r_call, r_call->nh,
           SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
           SIPTAG_PAYLOAD(pl),
-          TAG_IF(st->st_status >= 200,
-                 NUTAG_SUBSTATE(nua_substate_terminated)),
+          NUTAG_SUBSTATE(st->st_status >= 200
+                         ? nua_substate_terminated
+                         : nua_substate_active),
           TAG_END());
 
-    BYE(ep, ep->call, ep->call->nh, TAG_END());
+    su_free(NULL, pl);
+
+    if (st->st_status >= 200)
+      BYE(ep, ep->call, ep->call->nh, TAG_END());
+
     return 0;
   }
 
@@ -635,392 +695,3 @@ int notify_until_terminated(CONDITION_PARAMS)
     return 0;
   }
 }
-
-/* Referred call - NOTIFY and BYE are overlapped
-
-   A                   B
-   |                   |
-   |-------INVITE------>|
-   |<----100 Trying-----|
-   |                   |
-   |<----180 Ringing----|
-   |                   |
-   |<------200 OK-------|
-   |--------ACK-------->|
-   |                   |
-   |<------REFER--------|
-   |-------200 OK------>|                      C
-  [|-------NOTIFY------>|]                     |
-  [|<------200 OK-------|]                     |
-   |                   |                       |
-   |                   |                       |
-   |<-----SUBSCRIBE-----|                       |
-   |-------200 OK------>|                      |
-   |                   |                       |
-   |                   |                       |
-   |-----------------INVITE-------------------->|
-   |                   |                       |
-   |                   |                       |
-   |<------------------200----------------------|
-   |-------NOTIFY------>|                      |
-   |--------BYE-------->|                      |
-   |-------------------ACK--------------------->|
-   |<------200 OK-------|                      |
-   |<------200 OK-------|                      |
-   |                   X                       |
-   |                                           |
-   |-------------------BYE--------------------->|
-   |<------------------200----------------------|
-   |                                           |
-
-*/
-
-int test_refer1(struct context *ctx, int refer_with_id, char const *tests)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a,  *b = &ctx->b, *c = &ctx->c;
-  struct call *a_call = a->call, *b_call = b->call, *c_call = c->call;
-  struct call *a_c2;
-  struct event *e;
-  sip_t const *sip;
-  sip_event_t const *a_event, *b_event;
-  sip_refer_to_t const *refer_to;
-  sip_referred_by_t const *referred_by;
-
-  sip_refer_to_t r0[1];
-  sip_to_t to[1];
-
-  su_home_t tmphome[SU_HOME_AUTO_SIZE(16384)];
-
-  su_home_auto(tmphome, sizeof(tmphome));
-
-  if (print_headings)
-    printf("TEST %s: REFER: refer A to C\n", tests);
-
-  if (print_headings)
-    printf("TEST %s.1: REFER: make a call between A and B\n", tests);
-
-  /* Do (not) include id with first implicit Event: refer */
-  nua_set_params(ctx->a.nua, NUTAG_REFER_WITH_ID(refer_with_id), TAG_END());
-  run_a_until(ctx, nua_r_set_params, until_final_response);
-
-  TEST_1(a_c2 = calloc(1, (sizeof *a_c2) + (sizeof *a_c2->events)));
-  call_init(a_c2);
-  a_c2->events = (void *)(a_c2 + 1);
-  eventlist_init(a_c2->events);
-
-  a_call->sdp = "m=audio 5008 RTP/AVP 8";
-  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
-  a_c2->sdp   = "m=audio 5012 RTP/AVP 8";
-  c_call->sdp = "m=audio 5014 RTP/AVP 0 8";
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  INVITE(a, a_call, a_call->nh,
-        TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-        SOATAG_USER_SDP_STR(a_call->sdp),
-        TAG_END());
-
-  run_ab_until(ctx, -1, until_ready, -1, accept_call);
-
-  /* Client transitions:
-     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
-     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
-     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(is_offer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
-  TEST_1(is_answer_recv(e->data->e_tags));
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a->events);
-
-  /*
-   Server transitions:
-   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
-   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
-   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-  TEST_1(is_answer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, b->events);
-
-  if (print_headings)
-    printf("TEST %s.1: PASSED\n", tests);
-
-  /* ---------------------------------------------------------------------- */
-  /* REFER (initial NOTIFY is no more sent)
-   A                    B
-   |<------REFER--------|
-   |-------200 OK------>|
-  [|-------NOTIFY------>|]                     |
-  [|<------200 OK-------|]                     |
-   */
-
-  if (print_headings)
-    printf("TEST %s.2: refer A to C\n", tests);
-
-  *sip_refer_to_init(r0)->r_url = *c->contact->m_url;
-  r0->r_url->url_headers = "subject=referred";
-  r0->r_display = "C";
-
-  REFER(b, b_call, b_call->nh, SIPTAG_REFER_TO(r0), TAG_END());
-  run_ab_until(ctx, -1, save_until_received,
-              -1, save_until_final_response);
-
-  /*
-    Events in A:
-    nua_i_refer
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_refer);
-  TEST(e->data->e_status, 202);
-  a_event = NULL;
-  TEST(tl_gets(e->data->e_tags,
-              NUTAG_REFER_EVENT_REF(a_event),
-              TAG_END()), 1);
-  TEST_1(a_event); TEST_1(a_event = sip_event_dup(tmphome, a_event));
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_refer_to);
-  TEST_1(refer_to = sip_refer_to_dup(tmphome, sip->sip_refer_to));
-  TEST_1(sip->sip_referred_by);
-  TEST_1(referred_by = sip_referred_by_dup(tmphome, sip->sip_referred_by));
-  if (e->next) {
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
-  TEST_1(!e->next);
-  }
-  free_events_in_list(ctx, a->events);
-
-  /*
-     Events in B after nua_refer():
-     nua_r_refer
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_refer);
-  TEST(e->data->e_status, 100);
-  TEST(tl_gets(e->data->e_tags,
-              NUTAG_REFER_EVENT_REF(b_event),
-              TAG_END()), 1);
-  TEST_1(b_event); TEST_1(b_event->o_id);
-  TEST_1(b_event = sip_event_dup(tmphome, b_event));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_refer);
-  TEST(e->data->e_status, 202);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_SIZE(strtoul(b_event->o_id, NULL, 10), sip->sip_cseq->cs_seq);
-#if 0
-  if (!e->next)
-    run_b_until(ctx, -1, save_until_received);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
-  TEST(e->data->e_status, 200);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_event);
-  if (refer_with_id)
-    TEST_S(sip->sip_event->o_id, b_event->o_id);
-  TEST_1(sip->sip_subscription_state);
-  TEST_S(sip->sip_subscription_state->ss_substate, "pending");
-  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
-  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
-  TEST_1(!e->next);
-#endif
-  free_events_in_list(ctx, b->events);
-
-  if (print_headings)
-    printf("TEST %s.2: PASSED\n", tests);
-
-
-  /* ---------------------------------------------------------------------- */
-  /*
-   A                    B                       C
-   |                   |                       |
-   |-----------------INVITE-------------------->|
-   |                   |                       |
-  XXX                  |                       |
-   |                   |                       |
-   |<------------------200----------------------|
-   |-------NOTIFY------>|                      |
-   |---------BYE------->|                      |
-   |-------------------ACK--------------------->|
-   |<--------200--------|                      |
-   |<------200 OK-------|                      |
-   |                    X
-     */
-
-  if (print_headings)
-    printf("TEST %s.4: A invites C\n", tests);
-
-  *sip_to_init(to)->a_url = *refer_to->r_url;
-  to->a_display = refer_to->r_display;
-
-  a->call->next = a_c2;
-
-  TEST_1(a_c2->nh = nua_handle(a->nua, a_c2, SIPTAG_TO(to), TAG_END()));
-
-  INVITE(a, a_c2, a_c2->nh, /* NUTAG_URL(refer_to->r_url), */
-        NUTAG_REFER_EVENT(a_event),
-        /* NUTAG_NOTIFY_REFER(a_call->nh), */
-        SOATAG_USER_SDP_STR(a_c2->sdp),
-        SIPTAG_REFERRED_BY(referred_by),
-        TAG_END());
-
-  run_abc_until(ctx,
-               -1, notify_until_terminated,
-               -1, until_terminated,
-               -1, accept_call_immediately);
-
-  /* XXX - we should use accept_call instead of accept_call_immediately but
-     nua has a problem with automatically generated NOTIFYs:
-     3rd NOTIFY is not sent because 2nd is still in progress
-  */
-
-  /* Client A transitions:
-     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
-     CALLING -(C2a+C4)-> READY: nua_r_invite, nua_i_state
-     nua_r_notify
-
-     Transitions of first call:
-     READY --(T2)--> TERMINATING: nua_bye()
-     TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
-
-     XXX should be:
-     CALLING -(C2+C4)-> PROCEEDING: nua_r_invite, nua_i_state
-     optional: nua_i_notify
-     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
-     nua_i_notify
-     optional: nua_i_notify
-  */
-  TEST_1(e = a_c2->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(is_offer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
-  TEST_1(is_answer_recv(e->data->e_tags));
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a_c2->events);
-
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  free_events_in_list(ctx, a->events);
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
-  /*
-     Events in B after nua_refer():
-     nua_i_notify
-     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
-  */
-  if (b->events->head == NULL)
-    run_b_until(ctx, -1, save_until_received);
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
-  TEST(e->data->e_status, 200);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_subscription_state);
-  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
-  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
-  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 200 OK\r\n");
-  TEST_1(sip->sip_event);
-  if (refer_with_id)
-    TEST_S(sip->sip_event->o_id, b_event->o_id);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, b->events);
-
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  /*
-   C transitions:
-   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S3b)-> COMPLETED: nua_respond(), nua_i_state
-   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
-  */
-  TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-  TEST_1(is_answer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, c->events);
-
-  if (print_headings)
-    printf("TEST %s.4: PASSED\n", tests);
-
-  /* ---------------------------------------------------------------------- */
-  /*
-   A                                            C
-   |-------------------BYE--------------------->|
-   |<------------------200----------------------|
-   */
-
-  if (print_headings)
-    printf("TEST %s.5.2: terminate call between A and C\n", tests);
-
-  BYE(a, a_c2, a_c2->nh, TAG_END());
-  run_abc_until(ctx, -1, until_terminated, -1, NULL, -1, until_terminated);
-
-  /*
-   Transitions of A:
-   READY --(T2)--> TERMINATING: nua_bye()
-   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
-  */
-  TEST_1(e = a_c2->events->head); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a_c2->events);
-
-  /* Transitions of B:
-     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
-  */
-  TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_i_bye);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, c->events);
-
-  if (print_headings)
-    printf("TEST %s.5.2: PASSED\n", tests);
-
-  nua_handle_destroy(a_c2->nh), a_c2->nh = NULL;
-  a->call->next = NULL; free(a_c2);
-
-  nua_handle_destroy(c_call->nh), c_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST %s: PASSED\n", tests);
-
-  su_home_deinit(tmphome);
-
-  END();
-}
index fd5757cdb7a8b12e8b45f69dc2999a4a3c54eaa9..d5ea676c92679320c6e72b452c4ba38997673e5a 100644 (file)
@@ -55,6 +55,7 @@ int test_register_to_proxy(struct context *ctx)
   struct event *e;
   sip_t const *sip;
   sip_cseq_t cseq[1];
+  int seen_401;
 
   if (ctx->p)
     test_proxy_set_expiration(ctx->p, 5, 5, 10);
@@ -133,16 +134,32 @@ int test_register_to_proxy(struct context *ctx)
           NUTAG_KEEPALIVE(1000),
           NUTAG_M_DISPLAY("A&A"),
           NUTAG_M_USERNAME("a"),
+          NUTAG_M_PARAMS("foo=bar"),
+          NUTAG_M_FEATURES("q=0.9"),
           SIPTAG_CSEQ(cseq),
           TAG_END());
   run_a_until(ctx, -1, save_until_final_response);
 
   TEST_1(e = a->events->head);
-  TEST_E(e->data->e_event, nua_r_register);
   TEST_1(sip = sip_object(e->data->e_msg));
+  if (ctx->nat) {
+    TEST_E(e->data->e_event, nua_r_register);
+    TEST(e->data->e_status, 100);
+    TEST(sip->sip_status->st_status, 406);
+    /* Check that CSeq included in tags is actually used in the request */
+    TEST(sip->sip_cseq->cs_seq, 13);
+    TEST_1(!sip->sip_contact);
+    TEST_1(e = e->next);
+    TEST_1(sip = sip_object(e->data->e_msg));
+    TEST(sip->sip_cseq->cs_seq, 14);
+  }
+  else {
+    /* Check that CSeq included in tags is actually used in the request */
+    TEST(sip->sip_cseq->cs_seq, 13);
+  }
+  TEST_E(e->data->e_event, nua_r_register);
   TEST(e->data->e_status, 401);
   TEST(sip->sip_status->st_status, 401);
-  TEST(sip->sip_cseq->cs_seq, 13);
   TEST_1(!sip->sip_contact);
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
@@ -160,7 +177,8 @@ int test_register_to_proxy(struct context *ctx)
     /* VC does not dig \" with TEST_S() */
   TEST_S(sip->sip_contact->m_display, expect_m_display); }
   TEST_S(sip->sip_contact->m_url->url_user, "a");
-  TEST(sip->sip_cseq->cs_seq, 14);
+  TEST_1(strstr(sip->sip_contact->m_url->url_params, "foo=bar"));
+  TEST_S(sip->sip_contact->m_q, "0.9");
 
   if (ctx->nat) {
     TEST_1(e = a->specials->head);
@@ -184,6 +202,8 @@ int test_register_to_proxy(struct context *ctx)
 
     REGISTER(b, b_reg, b_reg->nh, SIPTAG_TO(b->to), 
             SIPTAG_CONTACT(m),
+            /* Do not include credentials unless challenged */
+            NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
             TAG_END());
   }
   run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
@@ -208,7 +228,7 @@ int test_register_to_proxy(struct context *ctx)
   TEST_1(sip->sip_contact);
   TEST_S(sip->sip_contact->m_display, "B");
   TEST_S(sip->sip_contact->m_url->url_user, "b");
-
+  free_events_in_list(ctx, b->events);
   if (print_headings)
     printf("TEST NUA-2.3.2: PASSED\n");
 
@@ -221,8 +241,12 @@ int test_register_to_proxy(struct context *ctx)
   TEST_1(c_reg->nh = nua_handle(c->nua, c_reg, TAG_END()));
 
   REGISTER(c, c_reg, c_reg->nh, SIPTAG_TO(c->to), 
+          NUTAG_OUTBOUND(NULL),
           NUTAG_M_DISPLAY("C"),
           NUTAG_M_USERNAME("c"),
+          NUTAG_M_PARAMS("c=1"),
+          NUTAG_M_FEATURES("q=0.987;expires=5"),
+          NUTAG_CALLEE_CAPS(1),
           SIPTAG_EXPIRES_STR("5"), /* Test 423 negotiation */
           TAG_END());
   run_abc_until(ctx, -1, save_events, -1, save_events, 
@@ -253,6 +277,9 @@ int test_register_to_proxy(struct context *ctx)
   TEST_1(sip->sip_contact);
   TEST_S(sip->sip_contact->m_display, "C");
   TEST_S(sip->sip_contact->m_url->url_user, "c");
+  TEST_1(strstr(sip->sip_contact->m_url->url_params, "c=1"));
+  TEST_S(sip->sip_contact->m_q, "0.987");
+  TEST_1(msg_header_find_param(sip->sip_contact->m_common, "methods="));
   TEST_1(!e->next);
   free_events_in_list(ctx, c->events);
 
@@ -306,11 +333,21 @@ int test_register_to_proxy(struct context *ctx)
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
 
+  seen_401 = 0;
+
   for (e = b->events->head; e; e = e->next) {
     TEST_E(e->data->e_event, nua_r_register);
-    TEST(e->data->e_status, 200);
     TEST_1(sip = sip_object(e->data->e_msg));
-    TEST_1(sip->sip_contact);
+
+    if (e->data->e_status == 200) {
+      TEST(e->data->e_status, 200);
+      TEST_1(seen_401);
+      TEST_1(sip->sip_contact);
+    }
+    else if (sip->sip_status && sip->sip_status->st_status == 401) {
+      seen_401 = 1;
+    }
+
     if (!e->next)
       break;
   }
@@ -349,7 +386,7 @@ int test_register_to_c(struct context *ctx)
   sip_t const *sip;
 
   if (print_headings)
-    printf("TEST NUA-2.3.2: REGISTER b to c\n");
+    printf("TEST NUA-2.6.1: REGISTER b to c\n");
 
   nua_set_params(ctx->c.nua,
                 NUTAG_ALLOW("REGISTER"),
@@ -372,9 +409,6 @@ int test_register_to_c(struct context *ctx)
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(!sip->sip_contact);
 
-  if (print_headings)
-    printf("TEST NUA-2.6.1: PASSED\n");
-
   free_events_in_list(ctx, b->events);
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
@@ -388,7 +422,7 @@ int test_register_to_c(struct context *ctx)
   nua_handle_destroy(c_call->nh), c_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-2.3.4: PASSED\n");
+    printf("TEST NUA-2.6.1: PASSED\n");
 
   END();
 }
@@ -552,7 +586,8 @@ int test_nat_timeout(struct context *ctx)
 
   BEGIN();
 
-  struct endpoint *a = &ctx->a,  *b = &ctx->b, *c = &ctx->c;
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
   struct event *e;
   sip_t const *sip;
 
@@ -586,7 +621,38 @@ int test_nat_timeout(struct context *ctx)
   if (print_headings)
     printf("TEST NUA-2.5.1: PASSED\n");
   
-  (void)b; (void)c; (void)sip;
+  if (print_headings)
+    printf("TEST NUA-2.5.2: OPTIONS from B to A\n");
+
+  TEST_1(b_call->nh = nua_handle(b->nua, b_call, SIPTAG_TO(a->to), TAG_END()));
+
+  OPTIONS(b, b_call, b_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, save_until_received,
+              -1, save_until_final_response);
+
+  /* Client events: nua_options(), nua_r_options */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_options);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_allow); TEST_1(sip->sip_accept); TEST_1(sip->sip_supported);
+  /* TEST_1(sip->sip_content_type); */
+  /* TEST_1(sip->sip_payload); */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  /* Server events: nua_i_options */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_options);
+  TEST(e->data->e_status, 200);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-2.5.2: PASSED\n");
 
   END();
 }
@@ -619,6 +685,10 @@ int test_unregister(struct context *ctx)
     run_a_until(ctx, -1, save_until_final_response);
     TEST_1(e = a->events->head);
     TEST_E(e->data->e_event, nua_r_unregister);
+    if (e->data->e_status == 100) {
+      TEST_1(e = e->next);
+      TEST_E(e->data->e_event, nua_r_unregister);
+    }
     TEST(e->data->e_status, 200);
     TEST_1(sip = sip_object(e->data->e_msg));
     TEST_1(!sip->sip_contact);
@@ -639,6 +709,10 @@ int test_unregister(struct context *ctx)
     run_b_until(ctx, -1, save_until_final_response);
     TEST_1(e = b->events->head);
     TEST_E(e->data->e_event, nua_r_unregister);
+    if (e->data->e_status == 100) {
+      TEST_1(e = e->next);
+      TEST_E(e->data->e_event, nua_r_unregister);
+    }
     TEST(e->data->e_status, 200);
     TEST_1(sip = sip_object(e->data->e_msg));
     TEST_1(!sip->sip_contact);
@@ -658,6 +732,7 @@ int test_unregister(struct context *ctx)
   UNREGISTER(c, c->call, c->call->nh, SIPTAG_TO(c->to), 
             NUTAG_M_DISPLAY("C"),
             NUTAG_M_USERNAME("c"),
+            NUTAG_M_PARAMS("c=1"),
             TAG_END());
   run_c_until(ctx, -1, save_until_final_response);
 
index def81ed76ba761281cabd5715715b255343bbae8..d18069206b2b79c9927f99a33011c3bceb6355ef 100644 (file)
@@ -22,7 +22,7 @@
  *
  */
 
-/**@CFILE test_nua_re_invite.c
+/**@CFILE test_session_timer.c
  * @brief NUA-8 tests: Session timer, UPDATE
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 #elif HAVE_FUNCTION
 #define __func__ __FUNCTION__
 #else
-#define __func__ "test_call_hold"
+#define __func__ "test_session_timer"
 #endif
 
 /* ======================================================================== */
 
+static size_t remove_update(void *a, void *message, size_t len);
+
 int test_session_timer(struct context *ctx)
 {
   BEGIN();
@@ -69,22 +71,6 @@ int test_session_timer(struct context *ctx)
    |--INVITE->|        |
    |<--422----|                |
    |---ACK--->|                |
-   |                   |
-   |-------INVITE------>|
-   |<-------422---------|
-   |--------ACK-------->|
-   |                   |
-   |-------INVITE------>|
-   |<----100 Trying-----|
-   |                   |
-   |<----180 Ringing----|
-   |                   |
-   |<------200 OK-------|
-   |--------ACK-------->|
-   |                   |
-   |<-------BYE---------|
-   |-------200 OK-------|
-   |                   |
 
 */
 
@@ -94,8 +80,15 @@ int test_session_timer(struct context *ctx)
   a_call->sdp = "m=audio 5008 RTP/AVP 8";
   b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
 
+  /* We negotiate session timer of 6 second */
+  /* Disable session timer from proxy */
+  test_proxy_set_session_timer(ctx->p, 0, 0); 
+
   nua_set_params(ctx->b.nua,
                 NUTAG_SESSION_REFRESHER(nua_any_refresher),
+                NUTAG_MIN_SE(1),
+                NUTAG_SESSION_TIMER(6),
+                NTATAG_SIP_T1X64(8000),
                 TAG_END());
 
   run_b_until(ctx, nua_r_set_params, until_final_response);
@@ -159,23 +152,132 @@ int test_session_timer(struct context *ctx)
   if (print_headings)
     printf("TEST NUA-8.1.1: PASSED\n");
 
+  if (ctx->expensive) {
+    nua_set_hparams(a_call->nh,
+                   NUTAG_SUPPORTED("timer"),
+                   NUTAG_MIN_SE(1),
+                   NUTAG_SESSION_TIMER(5),
+                   TAG_END());
+    run_a_until(ctx, nua_r_set_params, until_final_response);
+
+    if (print_headings)
+      printf("TEST NUA-8.1.2: Wait for refresh using INVITE\n");
+
+    run_ab_until(ctx, -1, until_ready, -1, until_ready);
+
+    free_events_in_list(ctx, a->events);
+    free_events_in_list(ctx, b->events);
+
+    if (print_headings)
+      printf("TEST NUA-8.1.2: PASSED\n");
+
+    nua_set_hparams(b_call->nh,
+                   NUTAG_UPDATE_REFRESH(1),
+                   TAG_END());
+    run_b_until(ctx, nua_r_set_params, until_final_response);
+
+    if (print_headings)
+      printf("TEST NUA-8.1.3: Wait for refresh using UPDATE\n");
+
+    run_ab_until(ctx, -1, until_ready, -1, until_ready);
+
+    TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_update);
+
+    free_events_in_list(ctx, a->events);
+    free_events_in_list(ctx, b->events);
+
+    if (print_headings)
+      printf("TEST NUA-8.1.3: PASSED\n");
+
+    if (ctx->nat) {
+      struct nat_filter *f;
+
+      if (print_headings)
+       printf("TEST NUA-8.1.4: filter UPDATE, wait until session expires\n");
+
+      f = test_nat_add_filter(ctx->nat, remove_update, NULL, nat_inbound);
+      TEST_1(f);
+
+      run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+      
+      TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
+
+      free_events_in_list(ctx, a->events);
+      free_events_in_list(ctx, b->events);
+
+      nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+      nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+      test_nat_remove_filter(ctx->nat, f);
+
+      if (print_headings)
+       printf("TEST NUA-8.1.4: PASSED\n");
+    }
+  }
+
+  if (b_call->nh) {
+    if (print_headings)
+      printf("TEST NUA-8.1.9: Terminate first session timer call\n");
+
+    BYE(b, b_call, b_call->nh, TAG_END());
+    run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
+    free_events_in_list(ctx, a->events);
+    free_events_in_list(ctx, b->events);
+
+    nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+    nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+    if (print_headings)
+      printf("TEST NUA-8.1.9: PASSED\n");
+  }
+
+  /*
+   |                   |
+   |-------INVITE------>|
+   |<-------422---------|
+   |--------ACK-------->|
+   |                   |
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |                   |
+   |<----180 Ringing----|
+   |                   |
+   |<------200 OK-------|
+   |--------ACK-------->|
+   |                   |
+   |<-------BYE---------|
+   |-------200 OK-------|
+   |                   |
+  */
+
   if (print_headings)
-    printf("TEST NUA-8.1.2: Session timers negotiation\n");
+    printf("TEST NUA-8.2: Session timers negotiation\n");
+
+  test_proxy_set_session_timer(ctx->p, 180, 90);
+
+  nua_set_params(a->nua,
+                NUTAG_SUPPORTED("timer"),
+                TAG_END());
+
+  run_a_until(ctx, nua_r_set_params, until_final_response);
 
-  nua_set_hparams(b_call->nh,
-                 NUTAG_AUTOANSWER(0),
-                 NUTAG_MIN_SE(120),
-                 TAG_END());
+  nua_set_params(b->nua,
+                NUTAG_AUTOANSWER(0),
+                NUTAG_MIN_SE(120),
+                NTATAG_SIP_T1X64(2000),
+                TAG_END());
 
   run_b_until(ctx, nua_r_set_params, until_final_response);
 
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to),
+                                TAG_END()));
 
   INVITE(a, a_call, a_call->nh,
         TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
         SOATAG_USER_SDP_STR(a_call->sdp),
         SIPTAG_SUPPORTED_STR("100rel, timer"),
-        NUTAG_SESSION_TIMER(15),
-        NUTAG_MIN_SE(5),
+        NUTAG_SESSION_TIMER(4),
+        NUTAG_MIN_SE(3),
         TAG_END());
 
   run_ab_until(ctx, -1, until_ready, -1, accept_call);
@@ -252,17 +354,17 @@ int test_session_timer(struct context *ctx)
   free_events_in_list(ctx, b->events);
 
   if (print_headings)
-    printf("TEST NUA-8.1: PASSED\n");
+    printf("TEST NUA-8.2: PASSED\n");
 
   if (print_headings)
-    printf("TEST NUA-8.2: use UPDATE\n");
+    printf("TEST NUA-8.3: UPDATE with session timer headers\n");
 
   UPDATE(b, b_call, b_call->nh, TAG_END());
   run_ab_until(ctx, -1, until_ready, -1, until_ready);
 
   /* Events from B (who sent UPDATE) */
   TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
   TEST_1(is_offer_sent(e->data->e_tags));
   if (!e->next)
     run_b_until(ctx, -1, until_ready);
@@ -313,7 +415,20 @@ int test_session_timer(struct context *ctx)
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-8.2: PASSED\n");
+    printf("TEST NUA-8.3: PASSED\n");
 
   END();
 }
+
+static
+size_t remove_update(void *a, void *message, size_t len)
+{
+  (void)a;
+
+  if (strncmp("UPDATE ", message, 7) == 0) {
+    return 0;
+  }
+
+  return len;
+}
+
index d8377313d76638ec9754dc32d0457933847e4ba4..41f84b671186bdc6df8f5433d6c7fca4f215ca34 100644 (file)
@@ -43,6 +43,8 @@
 #define __func__ "test_simple"
 #endif
 
+extern int accept_request(CONDITION_PARAMS);
+
 int test_message(struct context *ctx)
 {
   BEGIN();
@@ -62,7 +64,7 @@ int test_message(struct context *ctx)
 
 */
   if (print_headings)
-    printf("TEST NUA-11.1: MESSAGE\n");
+    printf("TEST NUA-11.1.1: MESSAGE\n");
 
   if (ctx->proxy_tests)
     *url = *b->to->a_url;
@@ -76,7 +78,7 @@ int test_message(struct context *ctx)
 
   MESSAGE(a, a_call, a_call->nh,
          NUTAG_URL(url),
-         SIPTAG_SUBJECT_STR("NUA-11.1"),
+         SIPTAG_SUBJECT_STR("NUA-11.1.1"),
          SIPTAG_CONTENT_TYPE_STR("text/plain"),
          SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
          TAG_END());
@@ -98,7 +100,7 @@ int test_message(struct context *ctx)
   TEST(e->data->e_status, 200);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_subject && sip->sip_subject->g_string);
-  TEST_S(sip->sip_subject->g_string, "NUA-11.1");
+  TEST_S(sip->sip_subject->g_string, "NUA-11.1.1");
   TEST_1(sip->sip_organization);
   TEST_S(sip->sip_organization->g_string, "United Testers");
   TEST_1(!e->next);
@@ -110,7 +112,64 @@ int test_message(struct context *ctx)
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-11.1: PASSED\n");
+    printf("TEST NUA-11.1.1: PASSED\n");
+
+/* MESSAGE as application method
+
+   A                   B
+   |-------MESSAGE----->|
+   |<-------202---------|
+   |                   |
+*/
+
+  if (print_headings)
+    printf("TEST NUA-11.1.2: MESSAGE\n");
+
+  nua_set_params(b->nua, NUTAG_APPL_METHOD("MESSAGE"), TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, TAG_END()));
+
+  MESSAGE(a, a_call, a_call->nh,
+         NUTAG_URL(url),
+         SIPTAG_SUBJECT_STR("NUA-11.1.2"),
+         SIPTAG_CONTENT_TYPE_STR("text/plain"),
+         SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
+         TAG_END());
+
+  run_ab_until(ctx, -1, save_until_final_response, -1, accept_request);
+
+  /* Client events:
+     nua_message(), nua_r_message
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_message);
+  TEST(e->data->e_status, 202);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip_user_agent(sip)); 
+  TEST_S(sip_user_agent(sip)->g_value, "007");
+  TEST_1(!e->next);
+
+  /*
+   Server events:
+   nua_i_message
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_message);
+  TEST(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_subject && sip->sip_subject->g_string);
+  TEST_S(sip->sip_subject->g_string, "NUA-11.1.2");
+  TEST_1(sip->sip_organization);
+  TEST_S(sip->sip_organization->g_string, "United Testers");
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  free_events_in_list(ctx, b->events);
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-11.1.2: PASSED\n");
 
 
 /* Message test
@@ -131,7 +190,7 @@ int test_message(struct context *ctx)
   MESSAGE(a, a_call, a_call->nh,
          /* We cannot reach us by using our contact! */
          NUTAG_URL(!ctx->p && !ctx->proxy_tests ? a->contact->m_url : NULL),
-         SIPTAG_SUBJECT_STR("NUA-11.1b"),
+         SIPTAG_SUBJECT_STR("NUA-11.2"),
          SIPTAG_CONTENT_TYPE_STR("text/plain"),
          SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
          TAG_END());
@@ -141,16 +200,21 @@ int test_message(struct context *ctx)
   /* Events:
      nua_message(), nua_i_message, nua_r_message
   */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_message);
+  TEST_1(e = a->specials->head);
+  while (e->data->e_event == nua_i_outbound)
+    e = e->next;
+  TEST_E(e->data->e_event, nua_i_message);
   TEST(e->data->e_status, 200);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_subject && sip->sip_subject->g_string);
-  TEST_S(sip->sip_subject->g_string, "NUA-11.1b");
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_message);
+  TEST_S(sip->sip_subject->g_string, "NUA-11.2");
+
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_message);
   TEST(e->data->e_status, 200);
   TEST_1(!e->next);
 
   free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, a->specials);
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
 
   if (print_headings)
@@ -159,12 +223,32 @@ int test_message(struct context *ctx)
   END();
 }
 
+int accept_request(CONDITION_PARAMS)
+{
+  msg_t *with = nua_current_request(nua);
+  
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (status < 200) {
+    RESPOND(ep, call, nh, SIP_202_ACCEPTED,
+           NUTAG_WITH(with),
+           SIPTAG_USER_AGENT_STR("007"),
+           TAG_END());
+    return 1;
+  }
+
+  return 0;
+}
+
 int respond_with_etag(CONDITION_PARAMS)
 {
   msg_t *with = nua_current_request(nua);
 
   if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
+    return 1;
 
   save_event_in_list(ctx, event, ep, call);
 
@@ -191,6 +275,14 @@ int respond_with_etag(CONDITION_PARAMS)
   }
 }
 
+static int close_handle(CONDITION_PARAMS)
+{
+  if (call->nh == nh)
+    call->nh = NULL;
+  nua_handle_destroy(nh);
+  return 1;
+}
+
 int test_publish(struct context *ctx)
 {
   BEGIN();
@@ -357,8 +449,60 @@ int test_publish(struct context *ctx)
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  /* Let server close handle without responding to PUBLISH */ 
+  PUBLISH(a, a_call, a_call->nh,
+         TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+         SIPTAG_EVENT_STR("presence"),
+         SIPTAG_CONTENT_TYPE_STR("text/urllist"),
+         SIPTAG_PAYLOAD_STR("sip:example.com\n"),
+         TAG_END());
+
+  run_ab_until(ctx, -1, save_until_final_response, -1, close_handle);
+
+  /* Client events:
+     nua_publish(), nua_r_publish
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_publish);
+  TEST(e->data->e_status, 500);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  /* No Event header */
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  PUBLISH(a, a_call, a_call->nh,
+         TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+         SIPTAG_CONTENT_TYPE_STR("text/urllist"),
+         SIPTAG_PAYLOAD_STR("sip:example.com\n"),
+         TAG_END());
+
+  run_ab_until(ctx, -1, save_until_final_response, -1, save_events);
+
+  /* Client events:
+     nua_publish(), nua_r_publish
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_publish);
+  TEST(e->data->e_status, 489);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server events: nothing
+  */
+  TEST_1(!b->events->head);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
   if (print_headings)
     printf("TEST NUA-11.3: PASSED\n");
+
   END();
 }
 
@@ -429,7 +573,10 @@ int test_subscribe_notify(struct context *ctx)
   tagi_t const *n_tags, *r_tags;
 
   if (print_headings)
-    printf("TEST NUA-11.4: establishing subscription without notifier\n");
+    printf("TEST NUA-11.4: notifier server using nua_notify()\n");
+
+  if (print_headings)
+    printf("TEST NUA-11.4.1: establishing subscription\n");
 
   TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
 
@@ -489,7 +636,7 @@ int test_subscribe_notify(struct context *ctx)
   free_events_in_list(ctx, b->events);
 
   if (print_headings)
-    printf("TEST NUA-11.4: PASSED\n");
+    printf("TEST NUA-11.4.1: PASSED\n");
 
   /* ---------------------------------------------------------------------- */
 
@@ -502,7 +649,7 @@ int test_subscribe_notify(struct context *ctx)
    |                    |
 */
   if (print_headings)
-    printf("TEST NUA-11.5: send NOTIFY\n");
+    printf("TEST NUA-11.4.2: send NOTIFY\n");
 
   /* Update presence data */
 
@@ -542,7 +689,7 @@ int test_subscribe_notify(struct context *ctx)
   free_events_in_list(ctx, b->events);
 
   if (print_headings)
-    printf("TEST NUA-11.5: PASSED\n");
+    printf("TEST NUA-11.4.2: PASSED\n");
 
   /* ---------------------------------------------------------------------- */
 
@@ -557,7 +704,7 @@ int test_subscribe_notify(struct context *ctx)
    |                    |
 */
   if (print_headings)
-    printf("TEST NUA-11.6: un-SUBSCRIBE\n");
+    printf("TEST NUA-11.4.3: un-SUBSCRIBE\n");
 
   UNSUBSCRIBE(a, a_call, a_call->nh, TAG_END());
 
@@ -614,11 +761,538 @@ int test_subscribe_notify(struct context *ctx)
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-11.6: PASSED\n");
+    printf("TEST NUA-11.4.3: PASSED\n");
+
+  if (print_headings)
+    printf("TEST NUA-11.4: PASSED\n");
+
+  END();
+}
+
+/* ---------------------------------------------------------------------- */
+/* Subscriber gracefully terminates dialog upon 483 */
+
+static
+size_t change_status_to_483(void *a, void *message, size_t len);
+int save_until_notified_and_responded_twice(CONDITION_PARAMS);
+int save_until_notify_responded_twice(CONDITION_PARAMS);
+
+int test_subscribe_notify_graceful(struct context *ctx)
+{
+  if (!ctx->nat)
+    return 0;
+
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t const *sip;
+  tagi_t const *n_tags, *r_tags;
+  struct nat_filter *f;
+
+  if (print_headings)
+    printf("TEST NUA-11.5.1: establishing subscription\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  SUBSCRIBE(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
+           SIPTAG_EVENT_STR("presence"),
+           SIPTAG_ACCEPT_STR("application/xpidf, application/pidf+xml"),
+           TAG_END());
+
+  run_ab_until(ctx, -1, save_until_notified_and_responded,
+              -1, accept_and_notify);
+
+  /* Client events:
+     nua_subscribe(), nua_i_notify/nua_r_subscribe
+  */
+  TEST_1(e = a->events->head);
+  if (e->data->e_event == nua_i_notify) {
+    TEST_E(e->data->e_event, nua_i_notify);
+    TEST_1(sip = sip_object(e->data->e_msg));
+    n_tags = e->data->e_tags;
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
+    r_tags = e->data->e_tags;
+    TEST_1(tl_find(r_tags, nutag_substate));
+    TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_pending);
+  }
+  else {
+    TEST_E(e->data->e_event, nua_r_subscribe);
+    TEST(e->data->e_status, 202);
+    r_tags = e->data->e_tags;
+    TEST_1(tl_find(r_tags, nutag_substate));
+    TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_embryonic);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+    TEST_1(sip = sip_object(e->data->e_msg));
+    n_tags = e->data->e_tags;
+  }
+  TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
+  TEST_1(sip->sip_content_type);
+  TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "pending");
+  TEST_1(sip->sip_subscription_state->ss_expires);
+  TEST_1(tl_find(n_tags, nutag_substate));
+  TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_pending);
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  /* Server events: nua_i_subscribe, nua_r_notify */
+  TEST_1(e = b->events->head);
+  TEST_E(e->data->e_event, nua_i_subscribe);
+  TEST_E(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  r_tags = e->data->e_tags;
+  TEST_1(tl_find(r_tags, nutag_substate));
+  TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_pending);
+
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST NUA-11.5.1: PASSED\n");
+
+  if (print_headings)
+    printf("TEST NUA-11.5.2: terminate gracefully upon 483\n");
+
+  TEST_1(f = test_nat_add_filter(ctx->nat,
+                                change_status_to_483, NULL,
+                                nat_inbound));
+
+  SUBSCRIBE(a, a_call, a_call->nh, TAG_END());
+
+  run_ab_until(ctx, -1, save_until_notified_and_responded_twice, 
+              -1, save_until_notify_responded_twice);
+
+#if 0
+  /* Client events:
+     nua_unsubscribe(), nua_i_notify/nua_r_unsubscribe
+  */
+  TEST_1(e = a->events->head);
+  if (e->data->e_event == nua_i_notify) {
+    TEST_E(e->data->e_event, nua_i_notify);
+    n_tags = e->data->e_tags;
+    TEST_1(sip = sip_object(e->data->e_msg));
+    TEST_1(sip->sip_event);
+    TEST_1(sip->sip_subscription_state);
+    TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+    TEST_1(!sip->sip_subscription_state->ss_expires);
+    TEST_1(tl_find(n_tags, nutag_substate));
+    TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_unsubscribe);
+    TEST(e->data->e_status, 200);
+    r_tags = e->data->e_tags;
+    TEST_1(tl_find(r_tags, nutag_substate));
+    TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+  }
+  else {
+    TEST_E(e->data->e_event, nua_r_unsubscribe);
+    TEST(e->data->e_status, 200);
+    r_tags = e->data->e_tags;
+    TEST_1(tl_find(r_tags, nutag_substate));
+    TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+  }
+  TEST_1(!e->next);
+
+  /* Notifier events: nua_r_notify */
+  TEST_1(e = b->events->head);
+  TEST_E(e->data->e_event, nua_i_subscribe);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(tl_find(e->data->e_tags, nutag_substate));
+  TEST(tl_find(e->data->e_tags, nutag_substate)->t_value, 
+       nua_substate_terminated);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(e->data->e_status >= 200);
+  r_tags = e->data->e_tags;
+  TEST_1(tl_find(r_tags, nutag_substate));
+  TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+#endif
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  test_nat_remove_filter(ctx->nat, f);
+
+  if (print_headings)
+    printf("TEST NUA-11.5.2: PASSED\n");
+
+  END();
+}
+
+static
+size_t change_status_to_483(void *a, void *message, size_t len)
+{
+  (void)a;
+
+  if (strncmp("SIP/2.0 2", message, 9) == 0) {
+    memcpy(message, "SIP/2.0 483", 11);
+  }
+  return len;
+}
+
+int save_until_notified_and_responded_twice(CONDITION_PARAMS)
+{
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_i_notify) {
+    if (ep->flags.bit0)
+      ep->flags.bit1 = 1;
+    ep->flags.bit0 = 1;
+  }
+
+  if (event == nua_r_subscribe || event == nua_r_unsubscribe) {
+    if (status >= 300)
+      return 1;
+    else if (status >= 200) {
+      if (ep->flags.bit2)
+       ep->flags.bit3 = 1;
+      ep->flags.bit2 = 1;
+    }
+  }
+
+  return ep->flags.bit0 && ep->flags.bit1 && ep->flags.bit2 && ep->flags.bit3;
+}
+
+int save_until_notify_responded_twice(CONDITION_PARAMS)
+{
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_r_notify) {
+    if (ep->flags.bit0)
+      ep->flags.bit1 = 1;
+    ep->flags.bit0 = 1;
+  }
+
+  return ep->flags.bit0 && ep->flags.bit1;
+}
+
+
+/* ---------------------------------------------------------------------- */
+/* Unsolicited NOTIFY */
+
+int accept_notify(CONDITION_PARAMS);
+
+int test_newsub_notify(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t const *sip;
+  sip_call_id_t *i;
+  tagi_t const *n_tags, *r_tags;
+
+  if (print_headings)
+    printf("TEST NUA-11.7.1: rejecting NOTIFY without subscription locally\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  NOTIFY(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
+        SIPTAG_SUBJECT_STR("NUA-11.7.1"),
+        SIPTAG_EVENT_STR("message-summary"),
+        SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+        SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+        TAG_END());
+
+  run_a_until(ctx, -1, save_until_final_response);
+
+  /* Client events:
+     nua_notify(), nua_r_notify
+  */
+  TEST_1(e = a->events->head);
+  TEST_E(e->data->e_event, nua_r_notify);
+  TEST(e->data->e_status, 481);
+  TEST_1(!e->data->e_msg);
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  if (print_headings)
+    printf("TEST NUA-11.7.1: PASSED\n");
+
+  if (print_headings)
+    printf("TEST NUA-11.7.2: rejecting NOTIFY without subscription\n");
+
+  TEST_1(i = sip_call_id_create(nua_handle_home(a_call->nh), NULL));
+
+  NOTIFY(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
+        NUTAG_NEWSUB(1),
+        SIPTAG_SUBJECT_STR("NUA-11.7.2 first"),
+        SIPTAG_FROM_STR("<sip:alice@example.com>;tag=nua-11.7.2"),
+        SIPTAG_CALL_ID(i),
+        SIPTAG_CSEQ_STR("1 NOTIFY"),
+        SIPTAG_EVENT_STR("message-summary"),
+        SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+        SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+        TAG_END());
+
+  run_a_until(ctx, -1, save_until_final_response);
+
+  /* Client events:
+     nua_notify(), nua_r_notify
+  */
+  TEST_1(e = a->events->head);
+  TEST_E(e->data->e_event, nua_r_notify);
+  TEST(e->data->e_status, 481);
+  TEST_1(e->data->e_msg);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  
+  /* 2nd NOTIFY using same dialog */
+  /* Check that server really discards the dialog */
+
+  NOTIFY(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
+        NUTAG_NEWSUB(1),
+        SIPTAG_SUBJECT_STR("NUA-11.7.2 second"),
+        SIPTAG_FROM_STR("<sip:alice@example.com>;tag=nua-11.7.2"),
+        SIPTAG_CALL_ID(i),
+        SIPTAG_CSEQ_STR("2 NOTIFY"),
+        SIPTAG_EVENT_STR("message-summary"),
+        SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+        SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+        TAG_END());
+
+  run_a_until(ctx, -1, save_until_final_response);
+
+  /* Client events:
+     nua_notify(), nua_r_notify
+  */
+  TEST_1(e = a->events->head);
+  TEST_E(e->data->e_event, nua_r_notify);
+  TEST(e->data->e_status, 481);
+  TEST_1(e->data->e_msg);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+
+  if (print_headings)
+    printf("TEST NUA-11.7.2: PASSED\n");
+
+  /* ---------------------------------------------------------------------- */
+
+  if (print_headings)
+    printf("TEST NUA-11.7.3: accept NOTIFY\n");
+
+  nua_set_params(b->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
+  run_b_until(ctx, nua_r_set_params, until_final_response);
+
+  NOTIFY(a, a_call, a_call->nh,
+        NUTAG_URL(b->contact->m_url),
+        NUTAG_NEWSUB(1),
+        SIPTAG_SUBJECT_STR("NUA-11.7.3"),
+        SIPTAG_EVENT_STR("message-summary"),
+        SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+        SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+        TAG_END());
+
+  run_ab_until(ctx, -1, save_until_final_response, -1, accept_notify);
+
+  /* Notifier events: nua_r_notify */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
+  TEST(e->data->e_status, 200);
+  r_tags = e->data->e_tags;
+  TEST_1(tl_find(r_tags, nutag_substate));
+  TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+
+  /* subscriber events:
+     nua_i_notify
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+  n_tags = e->data->e_tags;
+  TEST_1(tl_find(n_tags, nutag_substate));
+  TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST NUA-11.7.3: PASSED\n");
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-11.7: PASSED\n");
+
+  END();
+}
+
+/**Terminate when received notify. 
+ * Respond to NOTIFY with 200 OK if it has not been responded.
+ * Save events (except nua_i_active or terminated).
+ */
+int accept_notify(CONDITION_PARAMS)
+{
+  if (event == nua_i_notify && status < 200)
+    RESPOND(ep, call, nh, SIP_200_OK, 
+           NUTAG_WITH_THIS(ep->nua),
+           TAG_END());
+
+  save_event_in_list(ctx, event, ep, call);
+
+  return event == nua_i_notify;
+}
+
+/* ======================================================================== */
+
+int save_until_subscription_terminated(CONDITION_PARAMS);
+int accept_subscription_until_terminated(CONDITION_PARAMS);
+
+/* Timeout subscription */
+int test_subscription_timeout(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event *e;
+  sip_t const *sip;
+  tagi_t const *n_tags, *r_tags;
+
+  if (print_headings)
+    printf("TEST NUA-11.8: subscribe and wait until subscription times out\n");
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  METHOD(a, a_call, a_call->nh,
+        NUTAG_METHOD("SUBSCRIBE"),
+        NUTAG_URL(b->contact->m_url),
+        SIPTAG_EVENT_STR("presence"),
+        SIPTAG_ACCEPT_STR("application/xpidf, application/pidf+xml"),
+        SIPTAG_EXPIRES_STR("2"),
+        NUTAG_APPL_METHOD("NOTIFY"),
+        NUTAG_DIALOG(2),
+        TAG_END());
+
+  run_ab_until(ctx,
+              -1, save_until_subscription_terminated,
+              -1, accept_subscription_until_terminated);
+
+  /* Client events:
+     nua_method(), nua_i_notify/nua_r_method, nua_i_notify
+  */
+  TEST_1(e = a->events->head);
+  if (e->data->e_event == nua_i_notify) {
+    TEST_E(e->data->e_event, nua_i_notify);
+    TEST_1(sip = sip_object(e->data->e_msg));
+    n_tags = e->data->e_tags;
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
+    r_tags = e->data->e_tags;
+  }
+  else {
+    TEST_E(e->data->e_event, nua_r_method);
+    TEST(e->data->e_status, 202);
+    r_tags = e->data->e_tags;
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+    TEST_1(sip = sip_object(e->data->e_msg));
+    n_tags = e->data->e_tags;
+  }
+  TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
+  TEST_1(sip->sip_content_type);
+  TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "pending");
+  TEST_1(sip->sip_subscription_state->ss_expires);
+  TEST_1(tl_find(n_tags, nutag_substate));
+  TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_pending);
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+  n_tags = e->data->e_tags;
+  TEST_1(tl_find(n_tags, nutag_substate));
+  TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_event);
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+  TEST_1(!sip->sip_subscription_state->ss_expires);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+
+  /* Server events: nua_i_subscribe, nua_r_notify */
+  TEST_1(e = b->events->head);
+  TEST_E(e->data->e_event, nua_i_subscribe);
+  TEST_E(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  r_tags = e->data->e_tags;
+  TEST_1(tl_find(r_tags, nutag_substate));
+  TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_pending);
+
+  /* Notifier events: 2nd nua_r_notify */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(e->data->e_status >= 200);
+  r_tags = e->data->e_tags;
+  TEST_1(tl_find(r_tags, nutag_substate));
+  TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-11.8: PASSED\n");
 
   END();
 }
 
+int save_until_subscription_terminated(CONDITION_PARAMS)
+{
+  void *with = nua_current_request(nua);
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_i_notify) {
+    if (status < 200)
+      RESPOND(ep, call, nh, SIP_200_OK, NUTAG_WITH(with), TAG_END());
+
+    tags = tl_find(tags, nutag_substate);
+    return tags && tags->t_value == nua_substate_terminated;
+  }
+
+  return 0;
+}
+
+int accept_subscription_until_terminated(CONDITION_PARAMS)
+{
+  void *with = nua_current_request(nua);
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_i_subscribe && status < 200) {
+    RESPOND(ep, call, nh, SIP_202_ACCEPTED,
+           NUTAG_WITH(with),
+           SIPTAG_EXPIRES_STR("360"),
+           TAG_END());
+    NOTIFY(ep, call, nh, 
+          SIPTAG_EVENT(sip->sip_event),
+          SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"),
+          SIPTAG_PAYLOAD_STR(presence_closed),
+          NUTAG_SUBSTATE(nua_substate_pending),
+          TAG_END());
+  }
+  else if (event == nua_r_notify) {
+    tags = tl_find(tags, nutag_substate);
+    return tags && tags->t_value == nua_substate_terminated;
+  }
+
+  return 0;
+}
+
+
 /* ======================================================================== */
 /* Test simple methods: MESSAGE, PUBLISH, SUBSCRIBE/NOTIFY */
 
@@ -628,5 +1302,8 @@ int test_simple(struct context *ctx)
     test_message(ctx)
     || test_publish(ctx)
     || test_subscribe_notify(ctx)
+    || test_subscribe_notify_graceful(ctx)
+    || test_newsub_notify(ctx)
+    || test_subscription_timeout(ctx)
     ;
 }
index 90524a58edf93b6e31bf7bd40ff555f6b80f20f0..34b5ee85fee2d0c61f8e864cbd4074ea8281a901 100644 (file)
@@ -64,15 +64,15 @@ int save_until_notified(CONDITION_PARAMS)
 int save_until_notified_and_responded(CONDITION_PARAMS)
 {
   save_event_in_list(ctx, event, ep, call);
-  if (event == nua_i_notify) ep->flags.b.bit0 = 1;
+  if (event == nua_i_notify) ep->flags.bit0 = 1;
   if (event == nua_r_subscribe || event == nua_r_unsubscribe) {
     if (status >= 300)
       return 1;
     else if (status >= 200)
-      ep->flags.b.bit1 = 1;
+      ep->flags.bit1 = 1;
   }
 
-  return ep->flags.b.bit0 && ep->flags.b.bit1;
+  return ep->flags.bit0 && ep->flags.bit1;
 }
 
 
index e39a2941cdfaeda7c2f2b27497d57c7c0a647c46..cf140477414246bffe712a3ee0beb31c441cc859 100644 (file)
@@ -58,4 +58,5 @@ EXTRA_DIST =          Doxyfile sdp.docs $(BUILT_SOURCES) \
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index 9ac9c3d02036dc9490d0874e29384a396a83a9ce..fa8102d65125114df5a7ec855877a94af734201e 100644 (file)
@@ -6,7 +6,8 @@
 #
 
 test_sdp="${1:-./test_sdp}"
-tests="${2:-tests}"
+sdp_path=`dirname $0`
+tests="${2:-${sdp_path}/tests}"
 
 if test -r $tests/message-1.sdp ; then
 
@@ -17,6 +18,6 @@ do
 done
 
 else 
-    echo "sdp run-tests: no tests found, skipping."
+    echo "sdp run-tests: no tests found in $tests, skipping."
+    exit 77
 fi
-
index fa8285a33f584d155805fe52edf8942fa6b23a9c..b64a7d8db2b099c198d830943a13f4e6d13c8a64 100644 (file)
@@ -1061,7 +1061,7 @@ tagi_t *sdptag_session_dup(tagi_t *dst, tagi_t const *src, void **bb)
   b += STRUCT_ALIGN(b);
   srcsdp = (sdp_session_t *)src->t_value;
 
-  sdp = session_dup(&b, srcsdp);
+  sdp = srcsdp ? session_dup(&b, srcsdp) : NULL;
 
   dst->t_tag = src->t_tag;
   dst->t_value = (tag_value_t)sdp;
index ef230457e584f194c4b7f86fb5079868b11661cf..7fdb2dfa0f54c573938dd5986ab446a02478c123 100644 (file)
@@ -848,9 +848,10 @@ static int test_build(void)
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v]\n", name);
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -861,8 +862,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   null = fopen("/dev/null", "ab");
index 5e5a8515279a820cd7e75001fb49a5a146c937cd..d7b12c3e22f78f493c08c909fe1e4680edcf1539 100644 (file)
@@ -25,4 +25,6 @@ ALIASES += \
 
 @INCLUDE = sip.doxyaliases
 
+PREDEFINED += SU_HAVE_EXPERIMENTAL=1
+
 IMAGE_PATH           += images
index 7ff975e0b596a55716d336274096f3f5b12910df..bd75d83888e90e6f4215fe205709d66c8b5a13cc 100644 (file)
@@ -25,6 +25,7 @@ check_PROGRAMS =       torture_sip \
 GENERATED_H =          sofia-sip/sip_hclasses.h \
                        sofia-sip/sip_protos.h sofia-sip/sip_tag.h \
                        sofia-sip/sip_extra.h
+
 H_IN =                         sofia-sip/sip_hclasses.h.in \
                        sofia-sip/sip_protos.h.in sofia-sip/sip_tag.h.in \
                        sofia-sip/sip_extra.h.in
@@ -33,9 +34,9 @@ PUBLIC_H = sofia-sip/sip.h sofia-sip/sip_util.h \
            sofia-sip/sip_header.h sofia-sip/sip_parser.h \
           sofia-sip/sip_tag_class.h sofia-sip/sip_status.h
 
-GENERATED_C = sip_tag.c sip_tag_ref.c sip_parser_table.c
+GENERATED_C = sip_tag.c sip_parser_table.c
 
-BUILT_SOURCES =        $(GENERATED_H) $(GENERATED_C)
+BUILT_SOURCES =        $(GENERATED_H) $(GENERATED_C) sip_tag_ref.c
 
 nobase_include_sofia_HEADERS = $(GENERATED_H) $(PUBLIC_H) $(H_IN)
 
@@ -46,8 +47,8 @@ libsip_la_SOURCES =   $(INTERNAL_H) \
                        sip_refer.c sip_session.c \
                        sip_caller_prefs.c sip_reason.c \
                        sip_status.c sip_time.c \
-                       sip_tag_class.c \
-                       $(GENERATED_C)
+                       sip_tag_class.c sip_inlined.c \
+                       $(BUILT_SOURCES)
 
 COVERAGE_INPUT =       $(libsip_la_SOURCES) $(include_sofia_HEADERS)
 
@@ -55,6 +56,7 @@ LDADD =               libsip.la \
                        ../msg/libmsg.la \
                        ../bnf/libbnf.la \
                        ../url/liburl.la \
+                       ../ipt/libipt.la \
                        ../su/libsu.la
 
 torture_sip_LDFLAGS =  -static
@@ -93,62 +95,53 @@ EXTRA_DIST =                Doxyfile sip.docs sip_parser.docs sip.doxyaliases \
 # ----------------------------------------------------------------------
 # Tests
 
-#TESTS = torture_sip run_test_sip_msg run_test_date
+TESTS = torture_sip run_test_sip_msg run_test_date
 
-#dist_noinst_SCRIPTS =         run_test_sip_msg run_test_date
+dist_noinst_SCRIPTS =  run_test_sip_msg run_test_date
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 MSG_PARSER_AWK = $(srcdir)/../msg/msg_parser.awk
 
 AWK_SIP_AWK = $(AWK) -f $(MSG_PARSER_AWK) module=sip
 
-#
-# Note: sip_bad_mask is used by nta to weed out bad messages
-#
-sip_parser_table.c: sip_bad_mask
+SS_SIP_H = ${srcdir}/sofia-sip/sip.h
 
-sofia-sip/sip_hclasses.h: sofia-sip/sip_hclasses.h.in
-sofia-sip/sip_protos.h: sofia-sip/sip_protos.h.in
-sofia-sip/sip_tag.h: sofia-sip/sip_tag.h.in
+EXTRA = ${srcdir}/sip_extra_headers.txt
 
-$(GENERATED_H): $(MSG_PARSER_AWK)
+${GENERATED_H} ${GENERATED_C}: ${SS_SIP_H} ${MSG_PARSER_AWK}
 
-sip_parser_table.c: sip_parser_table.c.in $(MSG_PARSER_AWK)
-sip_tag.c: sip_tag.c.in $(MSG_PARSER_AWK)
-
-EXTRA = $(srcdir)/sip_extra_headers.txt
-
-sofia-sip/sip_hclasses.h: sofia-sip/sip.h
+sofia-sip/sip_hclasses.h: ${srcdir}/sofia-sip/sip_hclasses.h.in
        @-mkdir sofia-sip 2>/dev/null || true
-       $(AWK_SIP_AWK) PR=$@ TEMPLATE=$(srcdir)/sofia-sip/sip_hclasses.h.in $<
+       ${AWK_SIP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_SIP_H}
 
-sofia-sip/sip_protos.h: sofia-sip/sip.h
+sofia-sip/sip_protos.h: ${srcdir}/sofia-sip/sip_protos.h.in
        @-mkdir sofia-sip 2>/dev/null || true
-       $(AWK_SIP_AWK) PR=$@ TEMPLATE=$(srcdir)/sofia-sip/sip_protos.h.in $<
+       ${AWK_SIP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_SIP_H}
 
-sofia-sip/sip_tag.h: sofia-sip/sip.h
+sofia-sip/sip_tag.h: ${srcdir}/sofia-sip/sip_tag.h.in
        @-mkdir sofia-sip 2>/dev/null || true
-       $(AWK_SIP_AWK) PR=$@ TEMPLATE=$(srcdir)/sofia-sip/sip_tag.h.in $<
+       ${AWK_SIP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_SIP_H}
 
-sip_tag.c: sofia-sip/sip.h sip_extra_headers.txt
-       $(AWK_SIP_AWK) PR=$@ TEMPLATE=$(srcdir)/sip_tag.c.in $< $(EXTRA)
+sip_tag.c: ${srcdir}/sip_tag.c.in ${EXTRA}
+       ${AWK_SIP_AWK} PR=$@ TEMPLATE=${srcdir}/$@.in ${SS_SIP_H} ${EXTRA}
 
-sip_parser_table.c: sip_extra_headers.txt
+# Note: sip_bad_mask is used by nta to weed out bad messages
 
-sip_parser_table.c: sofia-sip/sip.h
-       $(AWK_SIP_AWK) PT=$@ TEMPLATE=$(srcdir)/sip_parser_table.c.in \
-               FLAGFILE=$(srcdir)/sip_bad_mask \
-               MC_HASH_SIZE=127 MC_SHORT_SIZE=26 $< $(EXTRA)
+sip_parser_table.c: ${srcdir}/sip_parser_table.c.in ${EXTRA} sip_bad_mask
+       ${AWK_SIP_AWK} PT=$@ TEMPLATE=${srcdir}/$@.in \
+               FLAGFILE=${srcdir}/sip_bad_mask \
+               MC_HASH_SIZE=127 MC_SHORT_SIZE=26 \
+               ${SS_SIP_H} ${EXTRA}
 
-sofia-sip/sip_extra.h: sofia-sip/sip_extra.h.in sip_extra_headers.txt
+sofia-sip/sip_extra.h: ${srcdir}/sofia-sip/sip_extra.h.in ${EXTRA}
        @-mkdir -p sofia-sip 2>/dev/null
        ${AWK_SIP_AWK} PR=$@ NO_FIRST=1 NO_LAST=1 \
                PACKAGE_NAME="${PACKAGE_NAME}" \
                PACKAGE_VERSION="${PACKAGE_VERSION}" \
                TEMPLATE1=${srcdir}/sofia-sip/sip_hclasses.h.in \
                TEMPLATE2=${srcdir}/sofia-sip/sip_protos.h.in \
-               TEMPLATE=$< $(EXTRA)
+               TEMPLATE=${srcdir}/$@.in ${EXTRA}
diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/run_test_date b/libs/sofia-sip/libsofia-sip-ua/sip/run_test_date
new file mode 100644 (file)
index 0000000..f92bb64
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./test_date "Sun, 18 Mar 2001 23:01:00 GMT"
diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg b/libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg
new file mode 100755 (executable)
index 0000000..4fa9282
--- /dev/null
@@ -0,0 +1,88 @@
+#! /bin/bash
+#
+# Run the parser tests
+#
+# usage: env srcdir=dir run_sip_test_msg
+#
+# --------------------------------------------------------------------
+#
+# 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
+#
+# --------------------------------------------------------------------
+#
+
+rc=0
+
+if test ! -d "${srcdir:=.}/tests"
+then
+    echo Please set environment variable srcdir
+    exit 77
+fi
+
+test=./test_sip_msg
+
+# These are messages that the parser should pass
+good="-t test1.txt test2.txt test3.txt test4.txt 
+      -u test5.txt -t test6.txt test7.txt -u test8.txt -t test9.txt 
+      test14.txt test20.txt test23.txt test24.txt test31.txt 
+      own1.txt own2.txt own3.txt own4.txt own5.txt own6.txt"
+# These are messages that the parser should fail
+bad="test10.txt test11.txt test12.txt test13.txt test15.txt 
+     test16.txt test17.txt test18.txt test19.txt 
+     test21.txt test22.txt 
+     test26.txt test29.txt test33.txt
+     test35.txt 
+     test40.txt"
+# These are ugly messages that parser should pass
+ugly="-t test25.txt -u test27.txt test28.txt -t test30.txt 
+      -u test32.txt test34.txt -t test36.txt -u test37.txt 
+      test38.txt test39.txt test41.txt test42.txt"
+
+# These are messages that parser should pass, but it does not
+goodish=""
+# These are messages that parser should not pass, but it does
+baddish=""
+
+flag=-t
+for n in $good $ugly;
+do 
+    if test $n = -t ; then
+       flag=$n
+    elif test $n = -u ; then
+       flag=
+    elif "$test" $flag < "$srcdir/tests/$n" > /dev/null ; then 
+       echo "PASS: $n"
+    else
+       echo "ERROR: $n"; rc=1
+    fi
+done
+
+for n in $bad;
+do 
+    if "$test" -t < "$srcdir/tests/$n" > /dev/null 2>/dev/null ; then 
+       echo "ERROR: $n (no error detected)"; rc=1
+    else
+       echo "PASS: $n"
+    fi
+done
+
+exit $rc
index 26125f24aea75a37393c4619bf9ab9ffaa8a40c4..25a9cea6ac0cfdfa3b2e9ca15c819c66a8766fcb 100644 (file)
@@ -899,7 +899,7 @@ sip_addr_make_url(su_home_t *home, msg_hclass_t *hc, url_string_t const *us)
   sip_header_t *h;
 
   n = url_xtra(us->us_url);
-  h = sip_header_alloc(home, sip_to_class, n);    
+  h = sip_header_alloc(home, hc, n);    
 
   if (h) {
     sip_addr_t *a = h->sh_to;
index 7bf1dd673f94b838a503f8886318923a522f2acf..fbdaaddb831a18089748a5a9cf8153066913a9c1 100644 (file)
@@ -44,6 +44,8 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
+
 #include <assert.h>
 
 /* ====================================================================== */
index 2b08adf31f7925c62d172ed44b74be4575df754c..03274f36d88a5e2344b8f9d9115cb5a9b79f79ab 100644 (file)
@@ -46,6 +46,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 
 #include <assert.h>
 
@@ -757,6 +758,8 @@ char *sip_info_dup_one(sip_header_t *dst,
 
 /* ====================================================================== */
 
+#if SU_HAVE_EXPERIMENTAL
+
 /**@SIP_HEADER sip_suppress_body_if_match Suppress-Body-If-Match Header
  *
  * The @b Suppress-Body-If-Match header field identifies a SIP event content
@@ -773,7 +776,7 @@ char *sip_info_dup_one(sip_header_t *dst,
  *
  * @sa @RFC3265, draft-niemi-sip-subnot-etags-01.txt
  *
- * @NEW_1_12_5. Note that #sip_t does not contain @a
+ * @EXP_1_12_5. Note that #sip_t does not contain @a
  * sip_suppress_body_if_match field, but sip_suppress_body_if_match()
  * function should be used for accessing the @b Suppress-Body-If-Match
  * header structure.
@@ -839,7 +842,7 @@ issize_t sip_suppress_body_if_match_e(char b[], isize_t bsiz,
  *
  * @sa @RFC3265, draft-niemi-sip-subnot-etag-01
  *
- * @NEW_1_12_5. Note that #sip_t does not contain @a
+ * @EXP_1_12_5. Note that #sip_t does not contain @a
  * sip_suppress_notify_if_match field, but sip_suppress_notify_if_match()
  * function should be used for accessing the @b Suppress-Notify-If-Match
  * header structure.
@@ -887,4 +890,4 @@ issize_t sip_suppress_notify_if_match_e(char b[], isize_t bsiz,
   return msg_generic_e(b, bsiz, h, f);
 }
 
-
+#endif
index 163a92f7f1225d7f1b771753a0eab6efa0060629..7c49732d16c2c12826f271b1a413fef133a6eb47 100644 (file)
@@ -4,10 +4,15 @@
 # The line format is: 
 # C-name @SINCE sip_t-like-comment
 #
+# Put all experimental things after EXPERIMENTAL HEADER LIST STARTS HERE...
+#
 #### EXTRA HEADER LIST STARTS HERE ####
 
-refer_sub @VERSION_1_12_5 /**< Refer-Sub header */
-suppress_body_if_match @VERSION_1_12_5 /**< Suppress-Body-If-Match header */
-suppress_notify_if_match @VERSION_1_12_5 /**< Suppress-Notify-If-Match header*/
+refer_sub @NEW_1_12_5 /**< Refer-Sub header */
+
+#### EXPERIMENTAL HEADER LIST STARTS HERE ####
+
+suppress_body_if_match @EXP_1_12_5 /**< Suppress-Body-If-Match header */
+suppress_notify_if_match @EXP_1_12_5 /**< Suppress-Notify-If-Match header */
 
 #### EXTRA HEADER LIST ENDS HERE ####
index 92a1d5ac46fa3795ba820e5edbe1022fd4a27ae3..6030b45c2c561bbd2658e14d9cf3baf8d3a96eda 100644 (file)
@@ -336,7 +336,7 @@ issize_t sip_unsupported_e(char b[], isize_t bsiz, sip_header_t const *h, int f)
   return msg_list_e(b, bsiz, h, f);
 }
 
-/** Check if required feature is supported.
+/** Check if required feature is not supported.
  *
  * @retval NULL if all the required features are supported
  * @retval pointer to a @Unsupported header or
@@ -351,7 +351,7 @@ sip_unsupported_t *sip_has_unsupported(su_home_t *home,
 }
 
 
-/** Check if required feature is supported.
+/** Check if required feature is not supported.
  *
  * @retval NULL if all the required features are supported
  * @retval pointer to a @Unsupported header or
@@ -370,7 +370,7 @@ sip_has_unsupported2(su_home_t *home,
 }
 
 
-/** Ensure that required features are supported.
+/** Check if required features are not supported.
  *
  * The supported features can be listed in @Supported, @Require or 
  * @ProxyRequire headers (in @a supported, @a by_require, or @a
diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sip_inlined.c b/libs/sofia-sip/libsofia-sip-ua/sip/sip_inlined.c
new file mode 100644 (file)
index 0000000..55ec8d6
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2007 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
+ *
+ */
+
+/**@CFILE sip_inlined.c
+ *
+ * Expand inlined sip functions non-inline.
+ *
+ */
+
+#include "config.h"
+
+#include <sofia-sip/su_config.h>
+
+#if SU_HAVE_INLINE
+extern int xyzzy;
+#else
+#include "sofia-sip/msg_header.h"
+#include "sofia-sip/su_tag.h"
+
+#undef SU_HAVE_INLINE
+#undef su_inline
+
+#define SU_HAVE_INLINE 1
+#define su_inline
+
+#include "sofia-sip/sip_protos.h"
+#include "sofia-sip/sip_extra.h"
+
+#endif
index 8d3e8e328d88b14fe0f61c64662a7681ddf57a3d..f0938be6303ce1f676aaf1844d3af804ef7c8ecc 100644 (file)
@@ -43,6 +43,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 #include <assert.h>
 
 /* ====================================================================== */
index eab35a7351e219a1cbaf522a5fa7ed945ca192a8..8905c6a507e91f209925e1b3c9f6f76b4d7ac9ee 100644 (file)
@@ -60,9 +60,9 @@ char const sip_parser_version[] = VERSION;
 char const sip_version_2_0[] = "SIP/2.0";
 
 /** Default message class */
-extern msg_mclass_t sip_mclass[];
+extern msg_mclass_t const sip_mclass[];
 
-msg_mclass_t *sip_default_mclass(void)
+msg_mclass_t const *sip_default_mclass(void)
 {
   return sip_mclass;
 }
index e1923a4f44059a71f787eec63e6ef49213c38d48..2f321c6135a1d6059bca5e09866a45de1ba604a3 100644 (file)
@@ -46,6 +46,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
+#include <limits.h>
 
 /* ====================================================================== */
 
index bb0787f1da1a51278441cbd4d5e14a306c0b6668..ee2157cdc7f40e3f6e6095c76b1e611bffc61d64 100644 (file)
@@ -42,6 +42,8 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
+
 #include <assert.h>
 
 /**@SIP_HEADER sip_reason Reason Header
index da80d3d9da37ed376e8bd6eeda26b3156fed1858..057f469d8826b3e425c8773446a4d46e99b8b5cd 100644 (file)
@@ -45,6 +45,8 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
+
 #include <assert.h>
 
 /* ====================================================================== */
index f1e62274976863d0758630d12b0c0b9185dcb5ec..2b763769167634bd5d171d640c19e495c7332379 100644 (file)
@@ -46,6 +46,7 @@
 #include <assert.h>
 #include <stddef.h>
 #include <string.h>
+#include <limits.h>
 
 /** Tag class for SIP header tags. @HIDE */
 tag_class_t siphdrtag_class[1] = 
index ff2fb2bc6e354baa4f8634a08b187ce8e504e06c..6127e6e5cc36b6ff101cb4d3de19f06f2d707823 100644 (file)
@@ -247,8 +247,8 @@ sip_contact_string_from_via(su_home_t *home,
     if (port || host_is_ip_address(host))
       transport = NULL;
   }
-  else if (port && host_is_ip_address(host) &&
-          strcmp(port, SIP_DEFAULT_SERV) == 0) {
+  else if (port && strcmp(port, SIP_DEFAULT_SERV) == 0 &&
+          (host_is_ip_address(host) || host_has_domain_invalid(host))) {
     port = NULL;
   }
 
@@ -258,10 +258,11 @@ sip_contact_string_from_via(su_home_t *home,
   /* Make transport parameter lowercase */
   if (transport && strlen(transport) < (sizeof _transport)) {
     char *s = strcpy(_transport, transport);
+    short c;
 
-    for (s = _transport; *s && *s != ';'; s++)
-      if (isupper(*s))
-       *s = tolower(*s);
+    for (s = _transport; (c = *s) && c != ';'; s++)
+      if (isupper(c))
+       *s = tolower(c);
 
     transport = _transport;
   }
index 70045d860936b6dbc2e5d5c6774f55416ea02d3b..86962b77fc9cd2b9159c64ed63aa2c21fe2635be 100644 (file)
@@ -58,7 +58,7 @@
 SOFIA_BEGIN_DECLS
 
 /** Return built-in SIP parser object. */
-SOFIAPUBFUN msg_mclass_t *sip_default_mclass(void);
+SOFIAPUBFUN msg_mclass_t const *sip_default_mclass(void);
 
 /** Check that sip_t is a SIP structure (not RTSP or HTTP). @HIDE */
 #define sip_is_sip(sip) ((sip) && (sip)->sip_ident == SIP_PROTOCOL_TAG)
@@ -345,9 +345,15 @@ int sip_has_supported(sip_supported_t const *support, char const *feature);
 SOFIAPUBFUN
 int sip_has_feature(msg_list_t const *supported, char const *feature);
 
+/** Return true if the method is listed in @Allow header. */
 SOFIAPUBFUN int sip_is_allowed(sip_allow_t const *allow, 
                               sip_method_t method, char const *name);
 
+/** Check if the well-known method is listed in @Allow header. @NEW_1_12_6 */
+#define SIP_IS_ALLOWED(allow, method) \
+  (sip_method_unknown < (method) && (method) < 32 && \
+   (allow) && ((allow)->k_bitmap & (1 << (method))) != 0)
+
 /* ---------------------------------------------------------------------------
  * Bitmasks for header classifications
  */
index bf9c77a659ba87b8a14505aada8afae97b13c2a3..f39b72d05ddc7c74d82f46b817490e5a0c4294fd 100644 (file)
@@ -192,10 +192,6 @@ SOFIAPUBFUN issize_t sip_name_addr_e(char b[], isize_t bsiz,
 #define sip_params_copy_xtra   msg_params_copy_xtra
 #define sip_params_copy                msg_params_copy
 
-#define sip_params_add         msg_params_add
-#define sip_params_cmp         msg_params_cmp
-#define sip_params_replace     msg_params_replace
-
 SOFIAPUBFUN int sip_generic_xtra(sip_generic_t const *g);
 
 SOFIAPUBFUN sip_generic_t *sip_generic_dup(su_home_t *home, 
index 999c09d9c9ef6b93771b06e343c7c760385c5c10..ccdd72fc4d0a8198bd792360975b5d0791c7ad36 100644 (file)
 #include <sofia-sip/string0.h>
 #endif
 
-SOFIA_BEGIN_DECLS
+#ifndef MSG_HEADER_H
+#include <sofia-sip/msg_header.h>
+#endif
 
-/* @deprecated
- * These are just wrappers around msg_params_*() functions. 
- *
- * Use msg_header_*_param() functions instead.
- */
-SOFIAPUBFUN char const *sip_params_find(sip_param_t const pp[],
-                                       char const *token);
-SOFIAPUBFUN int sip_params_add(su_home_t *sh, 
-                              sip_param_t **pparams,
-                              char const *param);
-SOFIAPUBFUN int sip_params_cmp(sip_param_t const a[], sip_param_t const b[]);
-SOFIAPUBFUN int sip_params_replace(su_home_t *,
-                                  sip_param_t **pparams, char const *param);
+SOFIA_BEGIN_DECLS
 
 SOFIAPUBFUN
 sip_contact_t *
@@ -210,6 +200,13 @@ sip_security_client_t const *
 sip_security_client_select(sip_security_client_t const *client,
                           sip_security_server_t const *server);
 
+/* Compatibility stuff */
+
+#define sip_params_add         msg_params_add
+#define sip_params_cmp         msg_params_cmp
+#define sip_params_replace     msg_params_replace
+#define sip_params_find         msg_params_find
+
 SOFIA_END_DECLS
 
 #endif /** !defined(SIP_UTIL_H) */
index 3d840e10210d3f4ef213973454d4ff788adb062d..84613a30bbfb426b9c77e92d814edc6903fb540c 100644 (file)
@@ -33,6 +33,8 @@
  * @date Wed Mar 21 19:12:13 2001 ppessi
  */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <sofia-sip/string0.h>
 #include <stddef.h>
 #include <sofia-sip/sip_header.h>
 #include <sofia-sip/msg_date.h>
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
          "usage: test_date [SIP-date] "
          "[YYYYy][DDd][HHh][MMm][SS[s]]\n");
-  exit(1);
+  exit(exitcode);
 }
 
 int main(int ac, char *av[])
@@ -83,7 +85,7 @@ int main(int ac, char *av[])
        case 's': delta += t2; break;
        default:
          fprintf(stderr, "test_date: %s is not valid time offset\n" , av[2]);
-         usage();
+         usage(1);
          break;
        }
       }
index 8139330e98ba6426c563d23fbe0e236e83022526..3a973afc62dbc4479b45703772ced90df63b67b0 100644 (file)
@@ -65,7 +65,7 @@ int diff(const char *olds, const char *news, int *linep, int *pos)
   return *o != *n;
 }
 
-int test_msg_class(msg_mclass_t *mc)
+int test_msg_class(msg_mclass_t const *mc)
 {
   int i, j, N;
 
@@ -159,7 +159,7 @@ int main(int argc, char *argv[])
   int m, tcp;
   sip_t *sip;
   int exitcode = 0; 
-  msg_mclass_t *sip_mclass = sip_default_mclass();
+  msg_mclass_t const *sip_mclass = sip_default_mclass();
   msg_t *msg = msg_create(sip_mclass, MSG_FLG_EXTRACT_COPY);
   msg_iovec_t iovec[1];
 
diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt b/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt
new file mode 100644 (file)
index 0000000..5d0c4a4
--- /dev/null
@@ -0,0 +1,20 @@
+INVITE sip:1234@10.50.71.28 SIP/2.0\r
+To: <sip:1234@10.50.71.28>\r
+From: "Displayname" <sip:1234@testaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.example.local:5060>;tag=10052\r
+Via: SIP/2.0/UDP 10.50.71.29:5060;branch=z9hG4bK10052t1174659568681\r
+Call-ID: s0c00010052i0t1174659568681@10.50.71.29\r
+Contact: "999" <sip:999@10.50.71.29;transport=udp>\r
+Content-Length: 180\r
+Content-Type: application/sdp\r
+CSeq: 1 INVITE\r
+Max-Forwards: 70\r
+\r
+v=0\r
+o=999 1 1 IN IP4 10.50.71.29\r
+s=Codenomicon SIP UAS Test Tool 3.0.2 (http://www.codenomicon.com/)\r
+c=IN IP4 10.50.71.29\r
+t=0 0\r
+m=audio 49152 RTP/AVP 0\r
+a=rtpmap:0 PCMU/8000
\ No newline at end of file
index cd9d5ceee856ce6baa55397cd7c20b07c35e5c4f..6c8c568c0a5f3b234468cb6b73affa6bacde25e1 100644 (file)
@@ -354,7 +354,7 @@ int test_basic(void)
     su_home_t home[1] = { SU_HOME_INIT(home) };
     char const *display;
     url_t url[1];
-    char const * const *params;
+    msg_param_t const *params;
     char const *comment;
     char const na[] = "Raaka Arska <tel:+358501970>;param=1;humppa (test) ";
     char const na2[] = "tel:+358501970;param=1;humppa (test) ";
@@ -412,7 +412,12 @@ int test_basic(void)
     TEST_1(sip_from_tag(home, f, "tag=jxahudsf") == 0);
     su_free(home, f);
 
+    TEST_1(f = sip_from_create(home, (void *)"<sip:joe@bar;tag=bar> (joe)"));
+    TEST_1(sip_is_from((sip_header_t*)f));
+    su_free(home, f);
+
     TEST_1(t = sip_to_create(home, (void *)"<sip:joe@bar;tag=bar> (joe)"));
+    TEST_1(sip_is_to((sip_header_t*)t));
     TEST_1(sip_to_tag(home, t, "tag=jxahudsf") == 0);
     TEST_S(t->a_tag, "jxahudsf");
     TEST(msg_header_replace_param(home, t->a_common, "tag=bar"), 1);
@@ -511,7 +516,7 @@ int test_basic(void)
 
     v = sip_via_make(home, "SIP/2.0/UDP domain.invalid:5060"); TEST_1(v);
     s = sip_contact_string_from_via(home, v, NULL, v->v_protocol);
-    TEST_S(s, "<sip:domain.invalid:5060;transport=udp>");
+    TEST_S(s, "<sip:domain.invalid;transport=udp>");
     su_free(home, v), su_free(home, s);
 
     TEST_1(sip_transport_has_tls("SIP/2.0/TLS-SCTP"));
@@ -739,8 +744,6 @@ int test_sip_msg_class(msg_mclass_t const *mc)
   }
 
   END();
-
-  return 0;
 }
 
 msg_t *read_message(int flags, char const buffer[])
@@ -1653,7 +1656,11 @@ static int sip_header_test(void)
   TEST(count(sip->sip_content_type->c_common), 1);
   TEST(count(sip->sip_route->r_common), 0);
   TEST(count(sip->sip_record_route->r_common), 4);
+#if SU_HAVE_EXPERIMENTAL
   TEST(count(sip->sip_unknown->un_common), 2);
+#else
+  TEST(count(sip->sip_unknown->un_common), 4);
+#endif
   TEST(count(sip->sip_error->er_common), 1);
   TEST(count(sip->sip_max_forwards->mf_common), 1);
   TEST(count(sip->sip_min_expires->me_common), 1);
@@ -1667,6 +1674,7 @@ static int sip_header_test(void)
   TEST(sip->sip_max_forwards->mf_count, 12);
   TEST(sip->sip_min_expires->me_delta, 150);
 
+#if SU_HAVE_EXPERIMENTAL
   {
     sip_suppress_body_if_match_t *sbim;
     sip_suppress_notify_if_match_t *snim;
@@ -1683,6 +1691,7 @@ static int sip_header_test(void)
     TEST_SIZE(offsetof(msg_generic_t, g_value),
              offsetof(sip_suppress_notify_if_match_t, snim_tag));
   }
+#endif
 
   TEST_1(sip->sip_from->a_display);
   TEST_S(sip->sip_from->a_display, "h");
@@ -3206,11 +3215,12 @@ static int test_utils(void)
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v]\n", 
+         "usage: %s [-v] [-a]\n", 
          name);
+  exit(exitcode);
 }
 
 char *lastpart(char *path)
@@ -3231,8 +3241,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   if (!test_mclass)
index 2741eef7c859d22508abf42cd42a6af221d5b5ee..5bcb4ffdbaebc0fe41a20fefd20b26726aed0827 100644 (file)
@@ -180,7 +180,7 @@ char *lastpart(char *path)
     return path;
 }
 
-msg_mclass_t *mclass = NULL;
+msg_mclass_t const *mclass = NULL;
 
 int validate_file(int fd, char const *name, context_t *ctx);
 int validate_dump(char *, off_t, context_t *ctx);
index 56946772006b7cd2605e5b1e020a31dbd843c1a6..17925afe9af86a09ac43163aee301e293ce888b0 100644 (file)
@@ -58,6 +58,6 @@ EXTRA_DIST =          Doxyfile soa.docs $(BUILT_SOURCES)
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 TAG_DLL_FLAGS =                LIST=soa_tag_list
\ No newline at end of file
index 4a5b66a439eab0ee84dcd0d05d149b98173f4fac..3dba70d9233f1e99e2f779a4376d1c6f0c047d91 100644 (file)
@@ -167,7 +167,7 @@ int soa_add(char const *name,
   struct soa_namenode const *n;
   struct soa_namenode *e;
 
-  SU_DEBUG_9(("soa_add(%s%s%s, %p) called\n", NICE(name), actions));
+  SU_DEBUG_9(("soa_add(%s%s%s, %p) called\n", NICE(name), (void *)actions));
 
   if (name == NULL || actions == NULL)
     return su_seterrno(EFAULT);
@@ -227,7 +227,7 @@ soa_session_t *soa_create(char const *name,
   size_t namelen;
 
   SU_DEBUG_9(("soa_create(\"%s\", %p, %p) called\n",
-             name ? name : "default", root, magic));
+             name ? name : "default", (void *)root, (void *)magic));
 
   if (name && name[0]) {
     struct soa_namenode const *n;
@@ -276,7 +276,7 @@ soa_session_t *soa_clone(soa_session_t *parent_ss,
 
   SU_DEBUG_9(("soa_clone(%s::%p, %p, %p) called\n",
              parent_ss ? parent_ss->ss_actions->soa_name : "",
-             parent_ss, root, magic));
+             (void *)parent_ss, (void *)root, (void *)magic));
 
   if (parent_ss == NULL || root == NULL)
     return (void)su_seterrno(EFAULT), NULL;
@@ -302,7 +302,7 @@ soa_session_t *soa_clone(soa_session_t *parent_ss,
 soa_session_t *soa_session_ref(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_session_ref(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
   return su_home_ref(ss->ss_home);
 }
 
@@ -310,7 +310,7 @@ soa_session_t *soa_session_ref(soa_session_t *ss)
 void soa_session_unref(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_session_unref(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
   su_home_unref(ss->ss_home);
 }
 
@@ -350,7 +350,7 @@ int soa_base_init(char const *name,
 void soa_destroy(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_destroy(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss) {
     ss->ss_active = 0;
@@ -396,7 +396,7 @@ int soa_set_params(soa_session_t *ss, tag_type_t tag, tag_value_t value, ...)
   int n;
 
   SU_DEBUG_9(("soa_set_params(%s::%p, ...) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss == NULL)
     return su_seterrno(EFAULT), -1;
@@ -606,7 +606,7 @@ int soa_get_params(soa_session_t const *ss,
   int n;
 
   SU_DEBUG_9(("soa_get_params(%s::%p, ...) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss == NULL)
     return su_seterrno(EFAULT), -1;
@@ -688,7 +688,7 @@ tagi_t *soa_get_paramlist(soa_session_t const *ss,
   tagi_t *params = NULL;
 
   SU_DEBUG_9(("soa_get_paramlist(%s::%p, ...) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss) {
     ta_start(ta, tag, value);
@@ -756,7 +756,7 @@ int soa_error_as_sip_response(soa_session_t *ss,
                              char const **return_phrase)
 {
   SU_DEBUG_9(("soa_error_as_sip_response(%s::%p, ...) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss == NULL || ss->ss_status < 400 || ss->ss_status >= 700) {
     if (return_phrase)
@@ -777,7 +777,7 @@ char const *soa_error_as_sip_reason(soa_session_t *ss)
   char *reason;
 
   SU_DEBUG_9(("soa_error_as_sip_reason(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss == NULL)
     return "SIP;cause=500;text=\"Internal Server Error\"";
@@ -832,8 +832,8 @@ int soa_get_capability_sdp(soa_session_t const *ss,
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_capability_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss,
-             return_sdp, return_sdp_str, return_len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss,
+             (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -878,7 +878,7 @@ int soa_set_capability_sdp(soa_session_t *ss,
                           char const *str, issize_t len)
 {
   SU_DEBUG_9(("soa_set_capability_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)sdp, (void *)str, (ssize_t)len));
 
   return soa_set_sdp(ss, soa_capability_sdp_kind, sdp, str, len);
 }
@@ -964,8 +964,8 @@ int soa_get_user_sdp(soa_session_t const *ss,
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_user_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss,
-             return_sdp, return_sdp_str, return_len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss,
+                         (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -1036,7 +1036,7 @@ int soa_set_user_sdp(soa_session_t *ss,
                     char const *str, issize_t len)
 {
   SU_DEBUG_9(("soa_set_user_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)sdp, (void *)str, (ssize_t)len));
 
   return soa_set_sdp(ss, soa_user_sdp_kind, sdp, str, len);
 }
@@ -1081,8 +1081,8 @@ int soa_get_remote_sdp(soa_session_t const *ss,
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_remote_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss,
-             return_sdp, return_sdp_str, return_len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss,
+                         (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -1155,7 +1155,7 @@ int soa_set_remote_sdp(soa_session_t *ss,
                       char const *str, issize_t len)
 {
   SU_DEBUG_9(("soa_set_remote_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)sdp, (void *)str, (ssize_t)len));
 
   return soa_set_sdp(ss, soa_remote_sdp_kind, sdp, str, len);
 }
@@ -1198,7 +1198,7 @@ int soa_base_set_remote_sdp(soa_session_t *ss,
 int soa_clear_remote_sdp(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_clear_remote_sdp(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (!ss)
     return (void)su_seterrno(EFAULT), -1;
@@ -1253,8 +1253,8 @@ int soa_get_local_sdp(soa_session_t const *ss,
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_local_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss,
-             return_sdp, return_sdp_str, return_len));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss,
+                         (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -1286,7 +1286,7 @@ int soa_init_offer_answer(soa_session_t *ss)
   int complete;
 
   SU_DEBUG_9(("soa_init_offer_answer(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (!ss)
     return 0;
@@ -1308,7 +1308,7 @@ int soa_init_offer_answer(soa_session_t *ss)
 char **soa_media_features(soa_session_t *ss, int live, su_home_t *home)
 {
   SU_DEBUG_9(("soa_media_features(%s::%p, %u, %p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, live, home));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, live, (void *)home));
 
   if (ss)
     return ss->ss_actions->soa_media_features(ss, live, home);
@@ -1324,7 +1324,7 @@ char **soa_base_media_features(soa_session_t *ss, int live, su_home_t *home)
 char const * const * soa_sip_require(soa_session_t const *ss)
 {
   SU_DEBUG_9(("soa_sip_require(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss)
     return ss->ss_actions->soa_sip_require(ss);
@@ -1341,7 +1341,7 @@ char const * const * soa_base_sip_require(soa_session_t const *ss)
 char const * const * soa_sip_supported(soa_session_t const *ss)
 {
   SU_DEBUG_9(("soa_sip_supported(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   if (ss)
     return ss->ss_actions->soa_sip_supported(ss);
@@ -1360,7 +1360,7 @@ int soa_remote_sip_features(soa_session_t *ss,
                            char const * const * require)
 {
   SU_DEBUG_9(("soa_remote_sip_features(%s::%p, %p, %p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, supported, require));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)supported, (void *)require));
 
   if (ss)
     return ss->ss_actions->soa_remote_sip_features(ss, supported, require);
@@ -1405,8 +1405,8 @@ int soa_generate_offer(soa_session_t *ss,
                       int always,
                       soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_generate_offer(%s::%p, %u, %p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, always, completed));
+  SU_DEBUG_9(("soa_generate_offer(%s::%p, %u) called\n",
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, always));
 
   /** @ERROR EFAULT Bad address. */
   if (ss == NULL)
@@ -1493,8 +1493,8 @@ int soa_base_generate_offer(soa_session_t *ss,
 int soa_generate_answer(soa_session_t *ss,
                        soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_generate_answer(%s::%p, %p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, completed));
+  SU_DEBUG_9(("soa_generate_answer(%s::%p) called\n",
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1573,8 +1573,8 @@ int soa_base_generate_answer(soa_session_t *ss,
 int soa_process_answer(soa_session_t *ss,
                       soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_process_answer(%s::%p, %p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, completed));
+  SU_DEBUG_9(("soa_process_answer(%s::%p) called\n",
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1654,8 +1654,8 @@ int soa_base_process_answer(soa_session_t *ss,
 int soa_process_reject(soa_session_t *ss,
                       soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_process_reject(%s::%p, %p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, completed));
+  SU_DEBUG_9(("soa_process_reject(%s::%p) called\n",
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1711,7 +1711,7 @@ int soa_base_process_reject(soa_session_t *ss,
 int soa_activate(soa_session_t *ss, char const *option)
 {
   SU_DEBUG_9(("soa_activate(%s::%p, %s%s%s) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, NICE(option)));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, NICE(option)));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1741,7 +1741,7 @@ int soa_base_activate(soa_session_t *ss, char const *option)
 int soa_deactivate(soa_session_t *ss, char const *option)
 {
   SU_DEBUG_9(("soa_deactivate(%s::%p, %s%s%s) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss, NICE(option)));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss, NICE(option)));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1763,7 +1763,7 @@ int soa_base_deactivate(soa_session_t *ss, char const *option)
 void soa_terminate(soa_session_t *ss, char const *option)
 {
   SU_DEBUG_9(("soa_terminate(%s::%p) called\n",
-             ss ? ss->ss_actions->soa_name : "", ss));
+             ss ? ss->ss_actions->soa_name : "", (void *)ss));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1799,49 +1799,65 @@ int soa_is_complete(soa_session_t const *ss)
 /** Return true if audio has been activated. */
 int soa_is_audio_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_local_activity->ma_audio : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_local_activity->ma_audio : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if video has been activated. */
 int soa_is_video_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_local_activity->ma_video : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_local_activity->ma_video : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if image sharing has been activated. */
 int soa_is_image_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_local_activity->ma_image : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_local_activity->ma_image : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if messaging session has been activated. */
 int soa_is_chat_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_local_activity->ma_chat : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_local_activity->ma_chat : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if remote audio is active (not on hold). */
 int soa_is_remote_audio_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_remote_activity->ma_audio : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_remote_activity->ma_audio : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if remote video is active (not on hold). */
 int soa_is_remote_video_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_remote_activity->ma_video : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_remote_activity->ma_video : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if image sharing is active (not on hold). */
 int soa_is_remote_image_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_remote_activity->ma_image : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_remote_activity->ma_image : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /** Return true if chat session is active (not on hold). */
 int soa_is_remote_chat_active(soa_session_t const *ss)
 {
-  return ss ? ss->ss_remote_activity->ma_chat : SOA_ACTIVE_DISABLED;
+  int ma = ss ? ss->ss_remote_activity->ma_chat : SOA_ACTIVE_DISABLED;
+  if (ma >= 4) ma |= -8;
+  return ma;
 }
 
 /* ======================================================================== */
index 4e6b57258cdfe7898a516019cf44f7c0ba45577c..47a74fb3dd7406356a9f98d163bbbd2a9f4f7010 100644 (file)
@@ -822,7 +822,7 @@ int soa_sdp_mode_set_is_needed(sdp_session_t const *session,
   sdp_mode_t recv_mode;
 
   SU_DEBUG_7(("soa_sdp_mode_set_is_needed(%p, %p, \"%s\"): called\n",
-             session, remote, hold ? hold : ""));
+             (void *)session, (void *)remote, hold ? hold : ""));
 
   if (!session )
     return 0;
@@ -865,7 +865,7 @@ int soa_sdp_mode_set(sdp_session_t *session,
   sdp_mode_t send_mode, recv_mode;
 
   SU_DEBUG_7(("soa_sdp_mode_set(%p, %p, \"%s\"): called\n",
-             session, remote, hold ? hold : ""));
+             (void *)session, (void *)remote, hold ? hold : ""));
 
   if (!session || !session->sdp_media)
     return 0;
@@ -928,7 +928,8 @@ static int offer_answer_step(soa_session_t *ss,
 
   su_home_auto(tmphome, sizeof tmphome);
 
-  SU_DEBUG_7(("soa_static_offer_answer_action(%p, %s): called\n", ss, by));
+  SU_DEBUG_7(("soa_static_offer_answer_action(%p, %s): called\n",
+             (void *)ss, by));
 
   if (user == NULL)
     return soa_set_status(ss, 500, "No session set by user");
@@ -954,7 +955,8 @@ static int offer_answer_step(soa_session_t *ss,
   if (local == NULL) switch (action) {
   case generate_offer:
   case generate_answer:
-    SU_DEBUG_7(("soa_static(%p, %s): generating local description\n", ss, by));
+    SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
+               "generating local description"));
 
     local = local0;
     *local = *user, local->sdp_media = NULL;
@@ -987,7 +989,7 @@ static int offer_answer_step(soa_session_t *ss,
       break;
     if (local != local0)
       *local0 = *local, local = local0;
-    SU_DEBUG_7(("soa_static(%p, %s): %s\n", ss, by, 
+    SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by, 
                "upgrade with local description"));
     soa_sdp_upgrade(ss, tmphome, local, user, user);
     break;
@@ -999,7 +1001,7 @@ static int offer_answer_step(soa_session_t *ss,
     if (1) {
       if (local != local0)
        *local0 = *local, local = local0;
-      SU_DEBUG_7(("soa_static(%p, %s): %s\n", ss, by,
+      SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
                  "upgrade with remote description"));
       soa_sdp_upgrade(ss, tmphome, local, user, remote);
     }
@@ -1032,7 +1034,8 @@ static int offer_answer_step(soa_session_t *ss,
        } while (0)
        DUP_LOCAL(local);
       }
-      SU_DEBUG_7(("soa_static(%p, %s): marking rejected media\n", ss, by));
+      SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by, 
+                 "marking rejected media"));
       soa_sdp_reject(tmphome, local, remote);
     }
     break;
@@ -1065,7 +1068,7 @@ static int offer_answer_step(soa_session_t *ss,
     if (ss->ss_local_remote_version == remote_version)
       break;
     if (1 /* We don't have good test for codecs */) {
-      SU_DEBUG_7(("soa_static(%p, %s): %s\n", ss, by,
+      SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
                  "upgrade codecs with remote description"));
       if (local != local0) {
        *local0 = *local, local = local0; 
@@ -1143,7 +1146,8 @@ static int offer_answer_step(soa_session_t *ss,
       ss->ss_previous_remote_version = ss->ss_local_remote_version;
     }
 
-    SU_DEBUG_7(("soa_static(%p, %s): storing local description\n", ss, by));
+    SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
+               "storing local description"));
 
     /* Update the unparsed and pretty-printed descriptions  */
     if (soa_description_set(ss, ss->ss_local, local, NULL, 0) < 0) {
index 542799fc5ef13ddb477d68be9f995bcf50b6394b..8ff75d0773431d3ce4dff19ed7c96e53f6502510 100644 (file)
@@ -163,10 +163,10 @@ struct soa_session
 
   struct soa_media_activity
   {
-    int ma_audio:4; /**< Audio activity (send/recv) */
-    int ma_video:4; /**< Video activity (send/recv) */
-    int ma_image:4; /**< Image activity (send/recv) for JPIP */
-    int ma_chat:4;  /**< Chat activity (send/recv) */
+    unsigned ma_audio:4; /**< Audio activity (send/recv) */
+    unsigned ma_video:4; /**< Video activity (send/recv) */
+    unsigned ma_image:4; /**< Image activity (send/recv) for JPIP */
+    unsigned ma_chat:4;  /**< Chat activity (send/recv) */
   } ss_local_activity[1], ss_remote_activity[1];
 
   /** Capabilities as specified by application */
index 762633c7e56bc1a47d13d0974f53f7469dfbfdc9..4bd0dbce8b5830bc674b6ccd5781a3e71f6c1d34 100644 (file)
@@ -353,7 +353,9 @@ int test_static_offer_answer(struct context *ctx)
   soa_session_t *a, *b;
 
   char const *caps = NONE, *offer = NONE, *answer = NONE;
-  isize_t capslen = -1, offerlen = -1, answerlen = -1;
+  isize_t capslen = (isize_t)-1;
+  isize_t offerlen = (isize_t)-1;
+  isize_t answerlen = (isize_t)-1;
 
   su_home_t home[1] = { SU_HOME_INIT(home) };
 
@@ -611,7 +613,7 @@ int test_codec_selection(struct context *ctx)
   soa_session_t *a, *b;
 
   char const *offer = NONE, *answer = NONE;
-  isize_t offerlen = -1, answerlen = -1;
+  isize_t offerlen = (isize_t)-1, answerlen = (isize_t)-1;
 
   sdp_session_t const *a_sdp, *b_sdp;
   sdp_media_t const *m;
@@ -1243,12 +1245,12 @@ static RETSIGTYPE sig_alarm(int s)
 }
 #endif
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v|-q] [-l level] [-p outbound-proxy-uri]\n", 
+         "usage: %s [-v|-q] [-a] [-l level] [-p outbound-proxy-uri]\n", 
          name);
-  exit(1);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -1261,6 +1263,8 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else if (strcmp(argv[i], "-q") == 0)
       tstflags &= ~tst_verbatim;
     else if (strcmp(argv[i], "-1") == 0)
@@ -1277,7 +1281,7 @@ int main(int argc, char *argv[])
        level = 3, rest = "";
 
       if (rest == NULL || *rest)
-       usage();
+       usage(1);
       
       su_log_set_level(soa_log, level);
     }
@@ -1294,7 +1298,7 @@ int main(int argc, char *argv[])
       break;
     }
     else
-      usage();
+      usage(1);
   }
 
   if (o_attach) {
index 285985a4f55ba69104fabe33ef91a3124e3efb6d..01e4c7717d4401c354ba7d6181f1673dc641b344 100644 (file)
@@ -3,6 +3,8 @@ OUTPUT_DIRECTORY     = ../docs/html/sresolv
 
 INPUT               =  sofia-sip sofia-resolv sresolv.docs .
 
+EXCLUDE                     = resolve_sip.c
+
 @INCLUDE            = ../docs/Doxyfile.conf
 
 ALIASES             += CFILE="@internal @file" IFILE="@internal @file"
index 2c0f342a0a5edfea588f3de7934f12b03aefffab..b77a8b2493499953ca24d04412cd368dac694092 100644 (file)
@@ -61,4 +61,5 @@ dist_noinst_DATA = run_test_sresolv \
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index ca015a69a5fd620baad3d375a899cbe5e1b7d3ee..26a1832aa0a830636795e5ae7130a5149a527d6e 100644 (file)
@@ -55,8 +55,13 @@ if netstat --ip >/dev/null 2>&1 ; then
     done
 fi
 
-# No named, no fun
-type -p named >/dev/null || exit 77
+# No BIND 9, no fun
+{ type -p named >/dev/null &&
+  named -v | grep -q BIND.*9 
+} || {
+echo test_sresolv: there is no BIND 9 named in you path, skipping
+exit 77
+} 
 
 if eval $ipv6
 then
index 002b0c246cd33dd69a835fc7478c4ecd2f291f61..a0e99fb094d14c8d55851b2f41e28cf8b44ac866 100644 (file)
@@ -70,6 +70,10 @@ typedef int socklen_t;
 #endif
 #endif
 
+#if HAVE_IPHLPAPI_H
+#include <iphlpapi.h>
+#endif
+
 #include <time.h>
 
 #include "sofia-resolv/sres.h"
@@ -159,6 +163,7 @@ struct sockaddr_storage {
 #define INVALID_SOCKET ((sres_socket_t)-1)
 #endif
 
+#define SRES_TIME_MAX ((time_t)LONG_MAX)
 
 #if !HAVE_INET_PTON
 int inet_pton(int af, char const *src, void *dst);
@@ -211,7 +216,10 @@ struct sres_server {
 
   /** ICMP/temporary error received, zero when successful. */
   time_t                  dns_icmp;
-  /** Persisten error, zero when successful. */
+  /** Persistent error, zero when successful or timeout. 
+   *
+   * Never selected if dns_error is SRES_TIME_MAX.
+   */
   time_t                  dns_error;
 };
 
@@ -434,7 +442,7 @@ sres_config_t *sres_parse_resolv_conf(sres_resolver_t *res,
 static
 sres_server_t *sres_next_server(sres_resolver_t *res, 
                                uint8_t *in_out_i,
-                               int timeout);
+                               int always);
 
 static
 int sres_send_dns_query(sres_resolver_t *res, sres_query_t *q);
@@ -541,7 +549,8 @@ static int m_get_domain(char *d, int n, sres_message_t *m, uint16_t offset);
 #include <winreg.h>
 #endif
 
-/**@var SRESOLV_DEBUG
+#if DOXYGEN_ONLY
+/**@ingroup sresolv_env
  *
  * Environment variable determining the debug log level for @b sresolv
  * module.
@@ -551,7 +560,8 @@ static int m_get_domain(char *d, int n, sres_message_t *m, uint16_t offset);
  * 
  * @sa <su_debug.h>, sresolv_log, SOFIA_DEBUG
  */
-extern char const SRESOLV_DEBUG[];
+extern SRESOLV_DEBUG;
+#endif
 
 /**Debug log for @b sresolv module. 
  * 
@@ -626,7 +636,7 @@ sres_resolver_t *sres_resolver_copy(sres_resolver_t *res)
  *                       (overriding options in conf_file)
  *
  * @par Environment Variables
- * - LOCALDOMAIN overrides @c domain or @c search directives
+ * - #LOCALDOMAIN overrides @c domain or @c search directives
  * - #RES_OPTIONS overrides values of @a options in resolv.conf
  * - #SRES_OPTIONS overrides values of @a options in resolv.conf, #RES_OPTIONS,
  *   and @a options, ... list given as argument for this function
@@ -923,8 +933,8 @@ sres_query(sres_resolver_t *res,
   size_t dlen;
   
   char b[8];
-  SU_DEBUG_9(("sres_query(%p, %p, %p, %s, \"%s\") called\n",
-             res, callback, context, sres_record_type(type, b), domain));
+  SU_DEBUG_9(("sres_query(%p, %p, %s, \"%s\") called\n",
+                         (void *)res, (void *)context, sres_record_type(type, b), domain));
 
   if (res == NULL || domain == NULL)
     return su_seterrno(EFAULT), (void *)NULL;
@@ -990,8 +1000,8 @@ sres_search(sres_resolver_t *res,
   unsigned dots; char const *dot;
   char b[8];
 
-  SU_DEBUG_9(("sres_search(%p, %p, %p, %s, \"%s\") called\n",
-             res, callback, context, sres_record_type(type, b), domain));
+  SU_DEBUG_9(("sres_search(%p, %p, %s, \"%s\") called\n",
+                         (void *)res, (void *)context, sres_record_type(type, b), domain));
 
   if (res == NULL || domain == NULL)
     return su_seterrno(EFAULT), (void *)NULL;
@@ -1235,7 +1245,7 @@ sres_search_cached_answers(sres_resolver_t *res,
   int i;
 
   SU_DEBUG_9(("sres_search_cached_answers(%p, %s, \"%s\") called\n",
-             res, sres_record_type(type, rooted_domain), domain));
+             (void *)res, sres_record_type(type, rooted_domain), domain));
 
   if (!res || !name)
     return su_seterrno(EFAULT), (void *)NULL;
@@ -1894,6 +1904,36 @@ int sres_update_config(sres_resolver_t *res, int always, time_t now)
 #define QUERY_DATALEN         1024
 #define MAX_DATALEN           65535
 
+/**
+ * Uses IP Helper IP to get DNS servers list.
+ */
+static int sres_parse_win32_ip(sres_config_t *c)
+{
+  int ret = -1;
+
+#if HAVE_IPHLPAPI_H
+  DWORD dw;
+  su_home_t *home = c->c_home;
+  ULONG size = sizeof(FIXED_INFO);
+
+  do {
+    FIXED_INFO *info = (FIXED_INFO *)su_alloc(home, size);
+    dw = GetNetworkParams(info, &size);
+    if (dw == ERROR_SUCCESS) {
+      IP_ADDR_STRING* addr = &info->DnsServerList;
+      for (; addr; addr = addr->Next) {
+       SU_DEBUG_3(("Adding nameserver: %s\n", addr->IpAddress.String));
+       sres_parse_nameserver(c, addr->IpAddress.String);
+      }
+      ret = 0;
+    }
+    su_free(home, info);
+  } while (dw == ERROR_BUFFER_OVERFLOW);
+#endif
+
+  return ret;
+}
+
 /**
  * Parses name servers listed in registry key 'key+lpValueName'. The
  * key is expected to contain a whitespace separate list of
@@ -2072,7 +2112,7 @@ sres_config_t *sres_parse_resolv_conf(sres_resolver_t *res,
 #if _WIN32    
     /* note: no 127.0.0.1 on win32 systems */
     /* on win32, query the registry for nameservers */
-    if (sres_parse_win32_reg(c) == 0) 
+    if (sres_parse_win32_ip(c) == 0 || sres_parse_win32_reg(c) == 0)
       /* success */;
     else
       /* now what? */;
@@ -2203,21 +2243,24 @@ int sres_parse_config(sres_config_t *c, FILE *f)
   return i;
 }
 
-/**Environment variable containing options for Sofia resolver. The options
+#if DOXYGEN_ONLY
+/**@ingroup sresolv_env
+ *
+ * Environment variable containing options for Sofia resolver. The options
  * recognized by Sofia resolver are as follows:
- * - debug           turn on debugging (no effect)
- * - ndots:<i>n</i>  when searching, try first to query name as absolute
- *                   domain if it contains at least <i>n</i> dots
- * - timeout:<i>secs</i> timeout in seconds
- * - attempts:<i>n</i> fail after <i>n</i> retries
- * - rotate          use round robin selection of nameservers
- * - no-check-names  do not check names for invalid characters
- * - inet6           (no effect) 
- * - ip6-dotint      IPv6 addresses are resolved using suffix ".ip6.int"
- *                   instead of the standard ".ip6.arpa" suffix
- * - ip6-bytestring  (no effect)
+ * - @b debug           turn on debugging (no effect)
+ * - @b ndots:<i>n</i>  when searching, try first to query name as absolute
+ *                      domain if it contains at least <i>n</i> dots
+ * - @b timeout:<i>secs</i> timeout in seconds
+ * - @b attempts:<i>n</i> fail after <i>n</i> retries
+ * - @b rotate          use round robin selection of nameservers
+ * - @b no-check-names  do not check names for invalid characters
+ * - @b inet6           (no effect) 
+ * - @b ip6-dotint      IPv6 addresses are resolved using suffix ".ip6.int"
+ *                      instead of the standard ".ip6.arpa" suffix
+ * - @b ip6-bytestring  (no effect)
  * The following option is a Sofia-specific extension:
- * - no-edns0        do not try to use EDNS0 extension (@RFC2671)
+ * - @b no-edns0        do not try to use EDNS0 extension (@RFC2671)
  *
  * The same options can be listed in @b options directive in resolv.conf, or
  * in #RES_OPTIONS environment variable. Note that options given in
@@ -2228,15 +2271,26 @@ int sres_parse_config(sres_config_t *c, FILE *f)
  *
  * @sa Manual page for resolv.conf, #RES_OPTIONS.
  */
-extern char const SRES_OPTIONS[];
+extern SRES_OPTIONS;
 
-/**Environment variable containing resolver options. This environment
+/**@ingroup sresolv_env
+ *
+ * Environment variable containing resolver options. This environment
  * variable is also used by standard BIND resolver.
  *
  * @sa Manual page for resolv.conf, #SRES_OPTIONS.
  */
-extern char const RES_OPTIONS[];
+extern RES_OPTIONS;
 
+/**@ingroup sresolv_env
+ *
+ * Environment variable containing search domain. This environment
+ * variable is also used by standard BIND resolver.
+ *
+ * @sa Manual page for resolv.conf, #RES_OPTIONS, #SRES_OPTIONS.
+ */
+extern LOCALDOMAIN;
+#endif
 
 /* Parse options line or #SRES_OPTIONS or #RES_OPTIONS environment variable. */
 static int 
@@ -2263,7 +2317,7 @@ sres_parse_options(sres_config_t *c, char const *value)
       value += strspn(value, " \t");
 
     if (n > 65536) {
-      SU_DEBUG_3(("sres: %s: invalid %*.s\n", c->c_filename,
+      SU_DEBUG_3(("sres: %s: invalid %*.0s\n", c->c_filename,
                  (int)(len + extra), b));
       continue;
     }
@@ -2288,7 +2342,7 @@ sres_parse_options(sres_config_t *c, char const *value)
     else if (MATCH("no-edns0")) c->c_opt.edns = edns_not_supported;
     else if (MATCH("edns0")) c->c_opt.edns = edns0_configured;
     else {
-      SU_DEBUG_3(("sres: %s: unknown option %*.s\n",
+      SU_DEBUG_3(("sres: %s: unknown option %*.0s\n",
                  c->c_filename, (int)(len + extra), b));
     }
   }
@@ -2437,7 +2491,7 @@ void sres_servers_close(sres_resolver_t *res,
     if (!servers[i])
       break;
 
-    if (servers[i]->dns_socket != -1) {
+    if (servers[i]->dns_socket != INVALID_SOCKET) {
       if (res->res_updcb)
        res->res_updcb(res->res_async, INVALID_SOCKET, servers[i]->dns_socket);
       sres_close(servers[i]->dns_socket);
@@ -2467,14 +2521,13 @@ sres_socket_t sres_server_socket(sres_resolver_t *res, sres_server_t *dns)
   int family = dns->dns_addr->ss_family;
   sres_socket_t s;
 
-  if (dns->dns_socket != -1)
+  if (dns->dns_socket != INVALID_SOCKET)
     return dns->dns_socket;
 
   s = socket(family, SOCK_DGRAM, IPPROTO_UDP);
   if (s == -1) {
     SU_DEBUG_1(("%s: %s: %s\n", "sres_server_socket", "socket",
                su_strerror(su_errno())));
-    dns->dns_error = time(NULL);
     return s;
   }
 
@@ -2517,7 +2570,6 @@ sres_socket_t sres_server_socket(sres_resolver_t *res, sres_server_t *dns)
                su_strerror(su_errno()), lb, ipaddr, rb,
                ntohs(((struct sockaddr_in *)dns->dns_addr)->sin_port)));
     sres_close(s);
-    dns->dns_error = time(NULL);
     return INVALID_SOCKET;
   }
   
@@ -2526,7 +2578,6 @@ sres_socket_t sres_server_socket(sres_resolver_t *res, sres_server_t *dns)
       SU_DEBUG_1(("%s: %s: %s\n", "sres_server_socket", "update callback",
                  su_strerror(su_errno())));
       sres_close(s);
-      dns->dns_error = time(NULL);
       return INVALID_SOCKET;
     }
   }
@@ -2547,7 +2598,7 @@ sres_send_dns_query(sres_resolver_t *res,
   sres_message_t m[1];
   uint8_t i, i0, N = res->res_n_servers;
   sres_socket_t s;
-  int transient, error = 0;
+  int error = 0;
   ssize_t size, no_edns_size, edns_size;
   uint16_t id = q->q_id;
   uint16_t type = q->q_type;
@@ -2558,7 +2609,7 @@ sres_send_dns_query(sres_resolver_t *res,
 
   if (now == 0) time(&now);
 
-  SU_DEBUG_9(("sres_send_dns_query(%p, %p) called\n", res, q));
+  SU_DEBUG_9(("sres_send_dns_query(%p, %p) called\n", (void *)res, (void *)q));
 
   if (domain == NULL)
     return -1;
@@ -2600,17 +2651,14 @@ sres_send_dns_query(sres_resolver_t *res,
     return -1;
   }
 
-  transient = 0;
-
-  i0 = q->q_i_server; if (i0 > N) i0 = 0; /* Number of DNS servers reduced */
+  i0 = q->q_i_server;
+  if (i0 > N) i0 = 0; /* Number of DNS servers reduced */
+  dns = servers[i = i0];
 
-  if (res->res_config->c_opt.rotate || 
-      servers[i0]->dns_error || servers[i0]->dns_icmp)
-    dns = sres_next_server(res, &q->q_i_server, 0), i = q->q_i_server;
-  else 
-    dns = servers[i0], i = i0;
+  if (res->res_config->c_opt.rotate || dns->dns_error || dns->dns_icmp)
+    dns = sres_next_server(res, &q->q_i_server, 1), i = q->q_i_server;
 
-  for (; dns; dns = sres_next_server(res, &i, 0)) {
+  for (; dns; dns = sres_next_server(res, &i, 1)) {
     /* If server supports EDNS, include EDNS0 record */
     q->q_edns = dns->dns_edns;
     /* 0 (no EDNS) or 1 (EDNS supported) additional data records */
@@ -2620,17 +2668,18 @@ sres_send_dns_query(sres_resolver_t *res,
 
     s = sres_server_socket(res, dns);
 
+    if (s == INVALID_SOCKET) {
+      dns->dns_icmp = now;
+      dns->dns_error = SRES_TIME_MAX;
+      continue;
+    }
+
     /* Send the DNS message via the UDP socket */
-    if (s != INVALID_SOCKET && sres_send(s, m->m_data, size, 0) == size)
+    if (sres_send(s, m->m_data, size, 0) == size)
       break;
-
     error = su_errno();
-    dns->dns_icmp = now;
-    /* EINVAL is returned if destination address is bad */
-    if (transient++ < 3 && error != EINVAL && s != -1)
-      continue;
-    transient = 0;
 
+    dns->dns_icmp = now;
     dns->dns_error = now;      /* Mark as a bad destination */
   }
 
@@ -2645,46 +2694,76 @@ sres_send_dns_query(sres_resolver_t *res,
 
   SU_DEBUG_5(("%s(%p, %p) id=%u %s %s (to [%s]:%u)\n", 
              "sres_send_dns_query",
-             res, q, id, sres_record_type(type, b), domain, 
+             (void *)res, (void *)q, id, sres_record_type(type, b), domain, 
              dns->dns_name, 
              htons(((struct sockaddr_in *)dns->dns_addr)->sin_port)));
 
   return 0;
 }
 
+/** Retry time after ICMP error */
+#define DNS_ICMP_TIMEOUT 60
+
+/** Retry time after immediate error */
+#define DNS_ERROR_TIMEOUT 10
 
-/** Select next server */
+/** Select next server.
+ *
+ * @param res resolver object
+ * @param[in,out] in_out_i index to DNS server table
+ * @param always return always a server
+ */
 static
 sres_server_t *sres_next_server(sres_resolver_t *res, 
                                uint8_t *in_out_i,
-                               int timeout)
+                               int always)
 {
   int i, j, N;
-  sres_server_t **servers;
-
-  assert(res && in_out_i);
+  sres_server_t *dns, **servers;
+  time_t now = res->res_now;
 
   N = res->res_n_servers;
   servers = res->res_servers;
   i = *in_out_i;
 
   assert(res->res_servers && res->res_servers[i]);
+
+  for (j=0; j < N; j++) {
+    dns = servers[j]; if (!dns) continue;
+    if (dns->dns_icmp + DNS_ICMP_TIMEOUT < now)
+      dns->dns_icmp = 0;
+    if (dns->dns_error + DNS_ERROR_TIMEOUT < now &&
+       dns->dns_error != SRES_TIME_MAX)
+      dns->dns_error = 0;
+  }
   
   /* Retry using another server? */
   for (j = (i + 1) % N; (j != i); j = (j + 1) % N) {
-    if (servers[j]->dns_icmp == 0) {
-      return *in_out_i = j, servers[j];
+    dns = servers[j]; if (!dns) continue;
+    if (dns->dns_icmp == 0) {
+      return *in_out_i = j, dns;
     }
   }
 
   for (j = (i + 1) % N; (j != i); j = (j + 1) % N) {
-    if (servers[j]->dns_error == 0) {
-      return *in_out_i = j, servers[j];
+    dns = servers[j]; if (!dns) continue;
+    if (dns->dns_error == 0) {
+      return *in_out_i = j, dns;
     }
   }
 
-  if (timeout)
-    return servers[i];
+  if (!always)
+    return NULL;
+
+  dns = servers[i]; 
+  if (dns && dns->dns_error < now && dns->dns_error != SRES_TIME_MAX)
+    return dns;
+
+  for (j = (i + 1) % N; j != i; j = (j + 1) % N) {
+    dns = servers[j]; if (!dns) continue;
+    if (dns->dns_error < now && dns->dns_error != SRES_TIME_MAX)
+      return *in_out_i = j, dns;
+  }
   
   return NULL;
 }
@@ -2763,7 +2842,7 @@ sres_query_report_error(sres_query_t *q,
     }
 
     SU_DEBUG_5(("sres(q=%p): reporting errors for %u %s\n",
-               q, q->q_type, q->q_name));
+               (void *)q, q->q_type, q->q_name));
  
     sres_remove_query(q->q_res, q, 1);
     (q->q_callback)(q->q_context, q, answers);
@@ -2822,15 +2901,21 @@ void sres_resolver_timer(sres_resolver_t *res, int dummy)
   sres_cache_clean(res->res_cache, res->res_now);
 }
 
-/** Resend DNS query, report error if cannot resend any more. */
+/** Resend DNS query, report error if cannot resend any more.
+ * 
+ * @param res  resolver object
+ * @param q    query object
+ * @param timeout  true if resent because of timeout
+ *                (false if because icmp error report)
+ */
 static void
 sres_resend_dns_query(sres_resolver_t *res, sres_query_t *q, int timeout)
 {
   uint8_t i, N;
   sres_server_t *dns;
-
-  SU_DEBUG_9(("sres_resend_dns_query(%p, %p, %u) called\n",
-             res, q, timeout));
+  
+  SU_DEBUG_9(("sres_resend_dns_query(%p, %p, %s) called\n",
+             (void *)res, (void *)q, timeout ? "timeout" : "error"));
   
   N = res->res_n_servers;
 
@@ -2956,6 +3041,11 @@ int sres_resolver_sockets(sres_resolver_t *res,
 
     s = sres_server_socket(res, dns);
 
+    if (s == INVALID_SOCKET) { /* Mark as a bad destination */
+      dns->dns_icmp = SRES_TIME_MAX;
+      dns->dns_error = SRES_TIME_MAX;  
+    }
+
     return_sockets[i++] = s;
   }
 
@@ -2998,7 +3088,8 @@ int sres_resolver_error(sres_resolver_t *res, int socket)
   int n;
   char info[128] = "";
 
-  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error", res, socket));
+  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error",
+             (void *)res, socket));
 
   msg->msg_name = name, msg->msg_namelen = sizeof(name);
   msg->msg_iov = iov, msg->msg_iovlen = 1;
@@ -3111,7 +3202,8 @@ int sres_resolver_error(sres_resolver_t *res, int socket)
   int errcode = 0;
   socklen_t errorlen = sizeof(errcode);
 
-  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error", res, socket));
+  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error",
+             (void *)res, socket));
 
   getsockopt(socket, SOL_SOCKET, SO_ERROR, (void *)&errcode, &errorlen);
 
@@ -3176,7 +3268,7 @@ sres_resolver_report_error(sres_resolver_t *res,
          continue;
 
        /* Resend query/report error to application */
-       sres_resend_dns_query(res, q, 1);
+       sres_resend_dns_query(res, q, 0);
 
        if (q != res->res_queries->qt_table[i])
          i--;
@@ -3203,7 +3295,8 @@ sres_resolver_receive(sres_resolver_t *res, int socket)
   struct sockaddr_storage from[1];
   socklen_t fromlen = sizeof from;
 
-  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_receive", res, socket));
+  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_receive",
+             (void *)res, socket));
 
   memset(m, 0, offsetof(sres_message_t, m_data)); 
   
@@ -3282,7 +3375,7 @@ void sres_log_response(sres_resolver_t const *res,
 #endif
 
     SU_DEBUG_5(("sres_resolver_receive(%p, %p) id=%u (from [%s]:%u)\n", 
-               res, query, m->m_id, 
+               (void *)res, (void *)query, m->m_id, 
                host, ntohs(((struct sockaddr_in *)from)->sin_port)));
   }
 }
index 8d3d82a2868c84b03b0e24a63ec7735ae64fdb8c..58751b13235d9b07d448213f1e6b967ecf3365ff 100644 (file)
@@ -86,7 +86,13 @@ struct sres_blocking_s
 #elif HAVE_SELECT
   struct { sres_socket_t fd; } fds[SRES_MAX_NAMESERVERS];
 #else
-#error No wait mechanism!
+#warning No guaranteed wait mechanism!
+/* typedef struct os_specific su_wait_t; */
+struct _pollfd {
+  sres_socket_t fd;   /* file descriptor */
+  short events;     /* requested events */
+  short revents;    /* returned events */
+} fds[SRES_MAX_NAMESERVERS];
 #endif
   sres_record_t ***return_records;  
 };
index 1b1ae11ed4c10572bf06ceadedf1e8ae17baeea5..2620cc9e645e037e8d5af38c9f4cbce2afde1d0d 100644 (file)
@@ -178,7 +178,7 @@ int sres_cache_get(sres_cache_t *cache,
   *return_cached = NULL;
 
   SU_DEBUG_9(("%s(%p, %s, \"%s\") called\n", "sres_cache_get",
-             cache, sres_record_type(type, b), domain));
+             (void *)cache, sres_record_type(type, b), domain));
 
   hash = sres_hash_key(domain);
 
@@ -241,7 +241,7 @@ int sres_cache_get(sres_cache_t *cache,
   UNLOCK(cache);
 
   SU_DEBUG_9(("%s(%p, %s, \"%s\") returned %d entries\n", "sres_cache_get", 
-             cache, sres_record_type(type, b), domain, rr_count));
+             (void *)cache, sres_record_type(type, b), domain, rr_count));
 
   *return_cached = result;
 
index 22b55e1a613cc7ada36282448fd5d7fc04ac7c38..d1385bd3a05e9b5462c2514caa359adad1a78b9f 100644 (file)
@@ -186,8 +186,8 @@ static int sres_sofia_update(sres_sofia_t *srs,
   int i, index = -1, error = 0;
   int N = SRES_MAX_NAMESERVERS;
 
-  SU_DEBUG_9(("sres_sofia_update(%p, %d, %d)\n", srs, 
-             (int)new_socket, (int)old_socket));
+  SU_DEBUG_9(("sres_sofia_update(%p, %d, %d)\n",
+             (void *)srs, (int)new_socket, (int)old_socket));
 
   if (srs == NULL)
     return 0;
@@ -297,7 +297,7 @@ su_socket_t sres_resolver_root_socket(sres_resolver_t *res)
   if (!srs)
     return su_seterrno(EINVAL);
 
-  if (sres_resolver_set_async(res, sres_sofia_update, srs, 1) < 0)
+  if (sres_resolver_set_async(res, sres_sofia_update, srs, 1) == NULL)
     return INVALID_SOCKET;
 
   if (srs->srs_socket != INVALID_SOCKET)
index 9320e5e9114947f37b180aca9815e39ec6a3b413..9e8bd93a3fed034fc6087a6daf68f5802d0fe9e4 100644 (file)
@@ -261,3 +261,10 @@ void process_natpr(sres_context_t *context,
 @endcode
 
 */
+
+/** @defgroup sresolv_env Environment Variables Used by sresolv Module
+
+In addition to the standard #RES_OPTIONS and #LOCALDOMAIN environment
+variables, the #SRES_OPTIONS and #SRESOLV_DEBUG variables are supported.
+
+*/
\ No newline at end of file
index ef05a0b78be366fd240d479a63871faa7fd613d8..9215bc4d29df2c5fca881070d8349e53f7ef8fe5 100644 (file)
@@ -64,7 +64,6 @@ typedef unsigned _int32 uint32_t;
 #include <sofia-resolv/sres_async.h>
 #include <sofia-resolv/sres_record.h>
 
-#include <sofia-sip/su.h>
 #include <sofia-sip/su_alloc.h>
 
 #include <assert.h>
@@ -101,7 +100,7 @@ struct sres_context_s
   sres_record_t  **result;
 
   int              timeout;
-  int              sink;
+  sres_socket_t    sink;
   int              sinkidx;
   char const      *sinkconf;
   
@@ -120,6 +119,84 @@ static void test_answer_multi(sres_context_t *ctx, sres_query_t *query,
 
 static int tstflags = 0;
 
+#if HAVE_WINSOCK2_H
+
+/* Posix send() */
+static inline 
+ssize_t sres_send(sres_socket_t s, void *b, size_t length, int flags)
+{
+  if (length > INT_MAX)
+    length = INT_MAX;
+  return (ssize_t)send(s, b, (int)length, flags);
+}
+
+static inline 
+ssize_t sres_sendto(sres_socket_t s, void *b, size_t length, int flags,
+                   struct sockaddr const *sa, socklen_t salen)
+{
+  if (length > INT_MAX)
+    length = INT_MAX;
+  return (ssize_t)sendto(s, b, (int)length, flags, (void *)sa, (int)salen);
+}
+
+/* Posix recvfrom() */
+static inline 
+ssize_t sres_recvfrom(sres_socket_t s, void *buffer, size_t length, int flags,
+                     struct sockaddr *from, socklen_t *fromlen)
+{
+  int retval, ilen;
+
+  if (fromlen)
+    ilen = *fromlen;
+
+  if (length > INT_MAX)
+    length = INT_MAX;
+
+  retval = recvfrom(s, buffer, (int)length, flags, 
+                   (void *)from, fromlen ? &ilen : NULL);
+
+  if (fromlen)
+    *fromlen = ilen;
+
+  return (ssize_t)retval;
+}
+
+static sres_socket_t sres_socket(int af, int socktype, int protocol)
+{
+  return socket(af, socktype, protocol);
+}
+
+static inline
+int sres_close(sres_socket_t s)
+{
+  return closesocket(s);
+}
+
+#if !defined(IPPROTO_IPV6)
+#if HAVE_SIN6
+#include <tpipv6.h>
+#else
+#if !defined(__MINGW32__)
+struct sockaddr_storage {
+    short ss_family;
+    char ss_pad[126];
+};
+#endif
+#endif
+#endif
+#else
+
+#define sres_send(s,b,len,flags) send((s),(b),(len),(flags))
+#define sres_sendto(s,b,len,flags,a,alen) \
+  sendto((s),(b),(len),(flags),(a),(alen))
+#define sres_recvfrom(s,b,len,flags,a,alen) \
+  recvfrom((s),(b),(len),(flags),(a),(alen))
+#define sres_close(s) close((s))
+#define SOCKET_ERROR   (-1)
+#define INVALID_SOCKET ((sres_socket_t)-1)
+#define sres_socket(x,y,z) socket((x),(y),(z))
+#endif
+
 #if 1
 
 #if HAVE_POLL && 0
@@ -145,7 +222,7 @@ static
 int test_socket(sres_context_t *ctx)
 {
   int af;
-  su_sockeet_t s1, s2, s3, s4;
+  sres_socket_t s1, s2, s3, s4;
   struct sockaddr_storage a[1];
   struct sockaddr_storage a1[1], a2[1], a3[1], a4[1];
   struct sockaddr_in *sin = (void *)a;
@@ -160,10 +237,10 @@ int test_socket(sres_context_t *ctx)
   af = AF_INET;
 
   for (;;) {
-    TEST_1((s1 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
-    TEST_1((s2 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
-    TEST_1((s3 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
-    TEST_1((s4 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s1 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s2 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s3 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s4 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
 
     TEST_1(setblocking(s1, 0) == 0);
     TEST_1(setblocking(s2, 0) == 0);
@@ -212,13 +289,13 @@ int test_socket(sres_context_t *ctx)
     TEST(connect(s2, sa4, a4len), 0);
     TEST(getsockname(s2, (struct sockaddr *)a2, &a2len), 0);
 
-    TEST(sendto(s1, "foo", 3, 0, sa4, a4len), 3);
-    TEST(recvfrom(s4, buf, sizeof buf, 0, sa, &alen), 3);
-    TEST(sendto(s4, "bar", 3, 0, sa, alen), 3);
-    TEST(recvfrom(s2, buf, sizeof buf, 0, sa, &alen), -1);
-    TEST(recvfrom(s1, buf, sizeof buf, 0, sa, &alen), 3);
+    TEST(sres_sendto(s1, "foo", 3, 0, sa4, a4len), 3);
+    TEST(sres_recvfrom(s4, buf, sizeof buf, 0, sa, &alen), 3);
+    TEST(sres_sendto(s4, "bar", 3, 0, sa, alen), 3);
+    TEST(sres_recvfrom(s2, buf, sizeof buf, 0, sa, &alen), -1);
+    TEST(sres_recvfrom(s1, buf, sizeof buf, 0, sa, &alen), 3);
 
-    su_close(s1), su_close(s2), su_close(s3), su_close(s4);
+    sres_close(s1), sres_close(s2), sres_close(s3), sres_close(s4);
 
     break;
   }
@@ -1356,14 +1433,15 @@ int sink_make(sres_context_t *ctx)
 {
   char *tmpdir = getenv("TMPDIR");
   char *template;
-  int fd, sink;
+  int fd;
+  sres_socket_t sink;
   struct sockaddr_in sin[1];
   socklen_t sinsize = sizeof sin;
   FILE *f;
   
   BEGIN();
 
-  sink = socket(AF_INET, SOCK_DGRAM, 0); TEST_1(sink != -1);
+  sink = socket(AF_INET, SOCK_DGRAM, 0); TEST_1(sink != INVALID_SOCKET);
   TEST(getsockname(sink, (struct sockaddr *)sin, &sinsize), 0);
   sin->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   TEST(bind(sink, (struct sockaddr *)sin, sinsize), 0);
@@ -1427,7 +1505,7 @@ int sink_deinit(sres_context_t *ctx)
   if (ctx->sinkidx)
     su_root_deregister(ctx->root, ctx->sinkidx);
   ctx->sinkidx = 0;
-  su_close(ctx->sink), ctx->sink = -1;
+  sres_close(ctx->sink), ctx->sink = INVALID_SOCKET;
 
   END();
 }
@@ -1452,7 +1530,7 @@ int test_timeout(sres_context_t *ctx)
 
   result = sres_cached_answers(res, sres_type_a, domain);
 
-#if 0
+#if 0  /* Currently, we do not create error records */
   TEST_1(result); TEST_1(result[0] != NULL);
 
   rr_soa = result[0]->sr_soa;
@@ -1463,7 +1541,6 @@ int test_timeout(sres_context_t *ctx)
 
   sres_free_answers(res, result);
 #else
-  /* Currently, we do not create error records */
   TEST_1(result == NULL);
 #endif
 
@@ -1541,12 +1618,12 @@ int test_expiration(sres_context_t *ctx)
 /* Convert lowercase hex to binary */
 static
 void *hex2bin(char const *test_name,
-             char const *hex1, char const *hex2, unsigned *binsize)
+             char const *hex1, char const *hex2, size_t *binsize)
 {
   char output[2048];
   char *bin;
   char const *b;
-  int j;
+  size_t j;
 
   if (hex1 == NULL || binsize == NULL)
     return NULL;
@@ -1619,18 +1696,19 @@ int test_net(sres_context_t *ctx)
 {
   sres_resolver_t *res = ctx->resolver;
   sres_query_t *q = NULL;
-  int c = ctx->sink;
+  sres_socket_t c = ctx->sink;
   struct sockaddr_storage ss[1];
   struct sockaddr *sa = (void *)ss;
-  socklen_t salen = sizeof ss, binlen;
+  socklen_t salen = sizeof ss;
   char *bin;
-  int i, n;
+  size_t i, binlen;
+  ssize_t n;
   char const *domain = "example.com";
   char query[512];
 
   BEGIN();
 
-  TEST_1(ctx->sink != -1 && ctx->sink != 0);
+  TEST_1(ctx->sink != INVALID_SOCKET && ctx->sink != (sres_socket_t)0);
 
   /* Prepare for test_answer() callback */
   sres_free_answers(ctx->resolver, ctx->result); 
@@ -1641,19 +1719,19 @@ int test_net(sres_context_t *ctx)
   TEST_1(bin = hex2bin(__func__, hextest, NULL, &binlen));
 
   /* Send responses with one erroneus byte */
-  for (i = 1; i < (int)binlen; i++) {
+  for (i = 1; i < binlen; i++) {
     if (!q) {
       /* We got an error => make new query */
       TEST_1(q = sres_query(res, test_answer, ctx, /* Send query */
                                 sres_type_naptr, domain));
-      TEST_1((n = recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
+      TEST_1((n = sres_recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
       memcpy(bin, query, 2); /* Copy ID */
     }
     if (i != 1)
       bin[i] ^= 0xff;
     else
       bin[3] ^= SRES_FORMAT_ERR; /* format error -> EDNS0 failure */
-    n = sendto(c, bin, binlen, 0, sa, salen);
+    n = sres_sendto(c, bin, binlen, 0, sa, salen);
     if (i != 1)
       bin[i] ^= 0xff;
     else
@@ -1669,15 +1747,15 @@ int test_net(sres_context_t *ctx)
   }
 
   /* Send runt responses */
-  for (i = 1; i <= (int)binlen; i++) {
+  for (i = 1; i <= binlen; i++) {
     if (!q) {
       /* We got an error => make new query */
       TEST_1(q = sres_query(res, test_answer, ctx, /* Send query */
                                 sres_type_naptr, domain));
-      TEST_1((n = recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
+      TEST_1((n = sres_recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
       memcpy(bin, query, 2); /* Copy ID */
     }
-    n = sendto(c, bin, i, 0, sa, salen);
+    n = sres_sendto(c, bin, i, 0, sa, salen);
     if (n == -1)
       perror("sendto");
     while (!poll_sockets(ctx))
@@ -1848,8 +1926,8 @@ int test_conf_errors(sres_context_t *ctx, char const *conf_file)
     
   TEST(sres_resolver_sockets(res, &socket, 1), n);
 
-#if HAVE_SA_LEN                        
-  /* We fail this test in BSD systems */
+#if !__linux
+  /* We fail this test in most systems */
   /* conf_file looks like this:
 --8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
 nameserver 0.0.0.2
@@ -1886,11 +1964,16 @@ static RETSIGTYPE sig_alarm(int s)
 }
 #endif
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v] [-l level] [-] [conf-file] [error-conf-file]\n", 
+         "usage: %s OPTIONS [-] [conf-file] [error-conf-file]\n"
+         "\twhere OPTIONS are\n"
+         "\t    -v be verbose\n"
+         "\t    -a abort on error\n"
+         "\t    -l level\n",
          name);
+  exit(exitcode);
 }
 
 #include <sofia-sip/su_log.h>
@@ -1912,6 +1995,8 @@ int main(int argc, char **argv)
     }
     else if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else if (strcmp(argv[i], "--no-alarm") == 0) {
       o_alarm = 0;
     }
@@ -1930,20 +2015,20 @@ int main(int argc, char **argv)
        level = 3, rest = "";
 
       if (rest == NULL || *rest)
-       usage();
+       usage(1);
       
       su_log_set_level(sresolv_log, level);
     } else
-      usage();
+      usage(1);
   }
 
   if (o_attach) {
-    char buf[8];
+    char buf[8], *line;
 
     fprintf(stderr, "test_sresolv: started with pid %u"
            " (press enter to continue)\n", getpid());
 
-    fgets(buf, sizeof buf, stdin);
+    line = fgets(buf, sizeof buf, stdin); (void) line;
   }
 #if HAVE_ALARM
   else if (o_alarm) {
index 73ed61eb8b441ab8aba011ae03e1ca584c123fe5..df642cb784fce7bbbb1e65e6fcf136caf6ee36ae 100644 (file)
@@ -38,14 +38,7 @@ BUILT_SOURCES =              stun_tag_ref.c
 
 COVERAGE_INPUT =       $(libstun_la_SOURCES) $(include_sofia_HEADERS)
 
-LDADD =                        \
-                       libstun.la
-                       ../sresolv/libsresolv.la \
-                       ../su/libsu.la
-
-stunc_LDADD = libstun.la ../sresolv/libsresolv.la ../su/libsu.la
-
-lookup_stun_server_LDADD = libstun.la ../sresolv/libsresolv.la ../su/libsu.la
+LDADD =                libstun.la ../sresolv/libsresolv.la ../su/libsu.la
 
 # ----------------------------------------------------------------------
 # tests
@@ -58,6 +51,6 @@ EXTRA_DIST =          Doxyfile stun.docs cert.pem key.pem
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 TAG_DLL_FLAGS =                LIST=stun_tag_list
index 478a315becb9d40c0ae10b207c67bda467b20bbb..d4d224d3debfb99f735db0fc95fac57406a72b8b 100644 (file)
@@ -57,7 +57,7 @@
 #include <ws2tcpip.h>
 #endif
 
-#if defined(HAVE_OPENSSL)
+#if HAVE_OPENSSL
 #include <openssl/opensslv.h>
 #endif
 
@@ -181,7 +181,7 @@ struct stun_request_s {
   su_sockaddr_t     sr_local_addr[1];   /**< local address */
   su_sockaddr_t     sr_destination[1];
 
-  stun_state_t      sr_state;           /**< Progress states */
+  stun_req_state_t  sr_state;           /**< Progress states */
   int               sr_retry_count;     /**< current retry number */
   long              sr_timeout;         /**< timeout for next sendto() */
 
@@ -218,7 +218,7 @@ struct stun_handle_s
   stun_discovery_magic_t *sh_dns_pend_ctx;
   tagi_t             *sh_dns_pend_tags;
 
-#if defined(HAVE_OPENSSL)
+#if HAVE_OPENSSL
   SSL_CTX        *sh_ctx;           /**< SSL context for TLS */
   SSL            *sh_ssl;           /**< SSL handle for TLS */
 #else
@@ -316,7 +316,7 @@ int stun_lifetime(stun_discovery_t *sd)
 }
 
 
-#if defined(HAVE_OPENSSL)
+#if HAVE_OPENSSL
 char const stun_version[] = 
  "sofia-sip-stun using " OPENSSL_VERSION_TEXT;
 #else
@@ -325,7 +325,9 @@ char const stun_version[] =
 #endif
 
 static int do_action(stun_handle_t *sh, stun_msg_t *binding_response);
+#if HAVE_OPENSSL
 static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg);
+#endif
 static int process_binding_request(stun_request_t *req, stun_msg_t *binding_response);
 static stun_discovery_t *stun_discovery_create(stun_handle_t *sh,
                                               stun_action_t action,
@@ -349,9 +351,11 @@ static int get_localinfo(int family, su_sockaddr_t *su, socklen_t *return_len);
 static void stun_sendto_timer_cb(su_root_magic_t *magic, 
                                 su_timer_t *t,
                                 su_timer_arg_t *arg);
+#if HAVE_OPENSSL
 static void stun_tls_connect_timer_cb(su_root_magic_t *magic, 
                                      su_timer_t *t,
                                      su_timer_arg_t *arg);
+#endif
 static void stun_test_lifetime_timer_cb(su_root_magic_t *magic, 
                                        su_timer_t *t,
                                        su_timer_arg_t *arg);
@@ -526,7 +530,7 @@ int stun_obtain_shared_secret(stun_handle_t *sh,
                              stun_discovery_magic_t *magic,
                              tag_type_t tag, tag_value_t value, ...)
 {
-#if defined(HAVE_OPENSSL)
+#if HAVE_OPENSSL
   int events = -1;
   int one, err = -1;
   su_wait_t wait[1] = { SU_WAIT_INIT };
@@ -1280,8 +1284,9 @@ int stun_test_nattype(stun_handle_t *sh,
  * Internal functions
  *******************************************************************/
 
-#if defined(HAVE_OPENSSL)
-static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
+#if HAVE_OPENSSL
+static 
+int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
 {
   stun_discovery_t *sd = arg;
   stun_handle_t *self = sd->sd_handle;
@@ -1298,7 +1303,7 @@ static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *
 
   enter;
 
-  SU_DEBUG_7(("%s(%p): events%s%s%s%s\n", __func__, self,
+  SU_DEBUG_7(("%s(%p): events%s%s%s%s\n", __func__, (void *)self,
              events & SU_WAIT_CONNECT ? " CONNECTED" : "",
              events & SU_WAIT_ERR     ? " ERR"       : "",
              events & SU_WAIT_IN      ? " IN"        : "",
@@ -1528,15 +1533,11 @@ static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *
 
   return 0;
 }
-#else
-static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
-{
-  return 0;
-}
+
 #endif /* HAVE_OPENSSL */
 
 
-#if defined(HAVE_OPENSSL)
+#if HAVE_OPENSSL
 static void stun_tls_connect_timer_cb(su_root_magic_t *magic, 
                                      su_timer_t *t,
                                      su_timer_arg_t *arg)
@@ -1566,12 +1567,7 @@ static void stun_tls_connect_timer_cb(su_root_magic_t *magic,
 
   return;
 }
-#else
-static void stun_tls_connect_timer_cb(su_root_magic_t *magic, 
-                                     su_timer_t *t,
-                                     su_timer_arg_t *arg)
-{
-}
+
 #endif /* HAVE_OPENSSL */
 
 /** Compose a STUN message of the format defined by stun_msg_t
@@ -1664,7 +1660,7 @@ static int stun_bind_callback(stun_magic_t *m, su_wait_t *w, su_wakeup_arg_t *ar
 
   enter;
 
-  SU_DEBUG_7(("%s(%p): events%s%s%s\n", __func__, self,
+  SU_DEBUG_7(("%s(%p): events%s%s%s\n", __func__, (void *)self,
              events & SU_WAIT_IN ? " IN" : "",
              events & SU_WAIT_OUT ? " OUT" : "",
              events & SU_WAIT_ERR ? " ERR" : ""));
@@ -1846,7 +1842,7 @@ static int process_binding_request(stun_request_t *req, stun_msg_t *binding_resp
     if (stun_process_error_response(binding_response) < 0) {
       SU_DEBUG_3(("%s: Error in Binding Error Response.\n", __func__));
     }
-    req->sr_state = stun_discovery_error;
+    req->sr_state = stun_req_error;
       
     break;
   }
@@ -1936,7 +1932,7 @@ static int process_test_lifetime(stun_request_t *req, stun_msg_t *binding_respon
     return 0;
   }
   else if (req->sr_from_y == 0) {
-    if (req->sr_state != stun_discovery_timeout) {
+    if (req->sr_state != stun_req_timeout) {
       /* mapping with X still valid */
       sd->sd_lt_cur = sd->sd_lt;
       sd->sd_lt = (int) (sd->sd_lt + sd->sd_lt_max) / 2;
@@ -2322,8 +2318,6 @@ static void stun_sendto_timer_cb(su_root_magic_t *magic,
 
     default:
       break;
-      
-      return;
     }
 
     /* Destroy me immediately */
index 2e5745858b472c4f1559d16de39bd124613e2be3..8ae20033318b7207712ecdc33288d434af4a4f99 100644 (file)
@@ -77,7 +77,11 @@ libsu_la_SOURCES = \
        su_alloc.c su_alloc_lock.c su_strdup.c su_sprintf.c \
        su_strlst.c su_vector.c \
        su_time.c su_time0.c \
-       su_wait.c su_root.c su_timer.c su_port.c su_port.h \
+       su_wait.c su_root.c su_timer.c \
+       su_port.c  su_port.h \
+       su_base_port.c su_pthread_port.c su_socket_port.c \
+       su_poll_port.c su_epoll_port.c su_select_port.c su_kqueue_port.c \
+       su_devpoll_port.c \
        su_localinfo.c \
        su_os_nw.c \
        su_taglist.c su_tag.c su_tag_io.c \
@@ -88,8 +92,8 @@ libsu_la_SOURCES = \
 EXTRA_libsu_la_SOURCES = \
                        memmem.c strtoull.c strcasestr.c \
                        memspn.c memcspn.c memccpy.c \
-                       inet_ntop.c inet_pton.c getopt.c \
-                       su_tag_ref.c
+                       inet_ntop.c inet_pton.c poll.c getopt.c \
+                       su_tag_ref.c su_win32_port.c
 
 libsu_la_LIBADD =      $(REPLACE_LIBADD)
 libsu_la_DEPENDENCIES = $(REPLACE_LIBADD)
@@ -116,4 +120,4 @@ AUTOMAKE_OPTIONS =  foreign
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
index b9e73ab95052ba74cd55bcba93764cf329c2b7b5..3b92077d84f619e1988b3465eaa93103bd885894 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the Sofia-SIP package
  *
- * Copyright (C) 2005 Nokia Corporation.
+ * Copyright (C) 2005,2007 Nokia Corporation.
  *
  * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  *
  * 
  * @section synopsis Synopsis
  *
- * <tt>addrinfo [-pcn46] host service</tt>
+ * <tt>addrinfo [-pcn46] service-name host</tt>
  *
  * @section description Description
  * 
  * The @em addrinfo utility will use su_getaddrinfo() to resolve the network
- * services and print resolved names.
+ * services and print resolved names. See sect 6.1 of RFC3493 and the getaddrinfo(3)
+ * manual page of POSIX 1003.1g, for more information.
  *
  * @section options Options
  *
@@ -56,7 +57,7 @@
  * Written by Pekka Pessi <pekka -dot pessi -at- nokia -dot- com>
  *
  * @section copyright Copyright
- * Copyright (C) 2005 Nokia Corporation.
+ * Copyright (C) 2005,2007 Nokia Corporation.
  *
  * This program is free software; see the source for copying conditions.
  * There is @b NO warranty; not even for @b MERCHANTABILITY or <b>FITNESS
@@ -72,7 +73,7 @@
 #include "sofia-sip/su.h"
 
 char const help[] =
-"usage: addrinfo [-pnc46] [domainname]\n"
+"usage: addrinfo [-pnc46] <servicename> <domainname>\n"
 "\t-p query for passive open\n"
 "\t-n use numeric host names\n"
 "\t-c ask for canonic names\n"
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/poll.c b/libs/sofia-sip/libsofia-sip-ua/su/poll.c
new file mode 100644 (file)
index 0000000..dbaf935
--- /dev/null
@@ -0,0 +1,250 @@
+/* This file is part of the Sofia-SIP package.
+
+   Copyright (C) 2005 Nokia Corporation.
+
+   Contact: Pekka Pessi <pekka.pessi@nokia.com>
+
+   This file is originally from GNU C library.
+
+   Copyright (C) 1994,1996,1997,1998,1999,2001,2002
+   Free Software Foundation, Inc.
+   
+   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 the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include "config.h"
+
+#if HAVE_SELECT
+
+#include "sofia-sip/su.h"
+
+#include <alloca.h>
+#include <string.h>
+
+#include "sofia-sip/su_wait.h"
+
+#undef NBBY
+#undef NFDBITS
+#undef FDSETSIZE
+#undef roundup
+
+#define        NBBY  8                                 /* bits in a byte */
+#define NFDBITS        (sizeof(long) * NBBY)           /* bits per mask */
+
+#define FDSETSIZE(n) (((n) + NFDBITS - 1) / NFDBITS * (NFDBITS / NBBY))
+#define roundup(n, x) (((n) + (x) - 1) / (x) * (x))
+
+/* Emulated poll() using select(). 
+
+This is used by su_wait().
+
+Poll the file descriptors described by the NFDS structures starting at
+FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+an event to occur; if TIMEOUT is -1, block until an event occurs.
+Returns the number of file descriptors with events, zero if timed out,
+or -1 for errors.  */
+
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+  struct timeval tv;
+  struct pollfd *f;
+  int ready;
+  int maxfd = 0;
+
+#if HAVE_ALLOCA_H
+  static int max_fd_size;
+  int bytes;
+  fd_set *rset, *wset, *xset;
+
+  if (!max_fd_size)
+    max_fd_size = getdtablesize ();
+
+  bytes = FDSETSIZE (max_fd_size);
+
+  rset = alloca (bytes);
+  wset = alloca (bytes);
+  xset = alloca (bytes);
+
+  /* We can't call FD_ZERO, since FD_ZERO only works with sets
+     of exactly __FD_SETSIZE size.  */
+  memset (rset, 0, bytes);
+  memset (wset, 0, bytes);
+  memset (xset, 0, bytes);
+#else
+  fd_set rset[1], wset[1], xset[1];
+
+  FD_ZERO(rset);
+  FD_ZERO(wset);
+  FD_ZERO(xset);
+#endif
+
+  for (f = fds; f < &fds[nfds]; ++f)
+    {
+      f->revents = 0;
+      if (f->fd >= 0)
+       {
+#if HAVE_ALLOCA_H
+         if (f->fd >= max_fd_size)
+           {
+             /* The user provides a file descriptor number which is higher
+                than the maximum we got from the `getdtablesize' call.
+                Maybe this is ok so enlarge the arrays.  */
+             fd_set *nrset, *nwset, *nxset;
+             int nbytes;
+
+             max_fd_size = roundup (f->fd, NFDBITS);
+             nbytes = FDSETSIZE (max_fd_size);
+
+             nrset = alloca (nbytes);
+             nwset = alloca (nbytes);
+             nxset = alloca (nbytes);
+
+             memset ((char *) nrset + bytes, 0, nbytes - bytes);
+             memset ((char *) nwset + bytes, 0, nbytes - bytes);
+             memset ((char *) nxset + bytes, 0, nbytes - bytes);
+
+             rset = memcpy (nrset, rset, bytes);
+             wset = memcpy (nwset, wset, bytes);
+             xset = memcpy (nxset, xset, bytes);
+
+             bytes = nbytes;
+           }
+#else
+         if (f->fd >= FD_SETSIZE) {
+           errno = EBADF;
+           return -1;
+         }
+#endif /* HAVE_ALLOCA_H */
+
+         if (f->events & POLLIN)
+           FD_SET (f->fd, rset);
+         if (f->events & POLLOUT)
+           FD_SET (f->fd, wset);
+         if (f->events & POLLPRI)
+           FD_SET (f->fd, xset);
+         if (f->fd > maxfd && (f->events & (POLLIN|POLLOUT|POLLPRI)))
+           maxfd = f->fd;
+       }
+    }
+
+  tv.tv_sec = timeout / 1000;
+  tv.tv_usec = (timeout % 1000) * 1000;
+
+  while (1)
+    {
+      ready = select (maxfd + 1, rset, wset, xset,
+                     timeout == -1 ? NULL : &tv);
+
+      /* It might be that one or more of the file descriptors is invalid.
+        We now try to find and mark them and then try again.  */
+      if (ready == -1 && errno == EBADF)
+       {
+         struct timeval sngl_tv;
+#if HAVE_ALLOCA_H
+         fd_set *sngl_rset = alloca (bytes);
+         fd_set *sngl_wset = alloca (bytes);
+         fd_set *sngl_xset = alloca (bytes);
+
+         /* Clear the original set.  */
+         memset (rset, 0, bytes);
+         memset (wset, 0, bytes);
+         memset (xset, 0, bytes);
+#else
+         fd_set sngl_rset[1];
+         fd_set sngl_wset[1];
+         fd_set sngl_xset[1];
+
+         FD_ZERO(rset);
+         FD_ZERO(wset);
+         FD_ZERO(xset);
+#endif
+
+         /* This means we don't wait for input.  */
+         sngl_tv.tv_sec = 0;
+         sngl_tv.tv_usec = 0;
+
+         maxfd = -1;
+
+         /* Reset the return value.  */
+         ready = 0;
+
+         for (f = fds; f < &fds[nfds]; ++f)
+           if (f->fd != -1 && (f->events & (POLLIN|POLLOUT|POLLPRI))
+               && (f->revents & POLLNVAL) == 0)
+             {
+               int n;
+
+#if HAVE_ALLOCA_H
+               memset (sngl_rset, 0, bytes);
+               memset (sngl_wset, 0, bytes);
+               memset (sngl_xset, 0, bytes);
+#else
+               FD_ZERO(rset);
+               FD_ZERO(wset);
+               FD_ZERO(xset);
+#endif
+
+               if (f->events & POLLIN)
+                 FD_SET (f->fd, sngl_rset);
+               if (f->events & POLLOUT)
+                 FD_SET (f->fd, sngl_wset);
+               if (f->events & POLLPRI)
+                 FD_SET (f->fd, sngl_xset);
+
+               n = select (f->fd + 1, sngl_rset, sngl_wset, sngl_xset,
+                           &sngl_tv);
+               if (n != -1)
+                 {
+                   /* This descriptor is ok.  */
+                   if (f->events & POLLIN)
+                     FD_SET (f->fd, rset);
+                   if (f->events & POLLOUT)
+                     FD_SET (f->fd, wset);
+                   if (f->events & POLLPRI)
+                     FD_SET (f->fd, xset);
+                   if (f->fd > maxfd)
+                     maxfd = f->fd;
+                   if (n > 0)
+                     /* Count it as being available.  */
+                     ++ready;
+                 }
+               else if (errno == EBADF)
+                 f->revents |= POLLNVAL;
+             }
+         /* Try again.  */
+         continue;
+       }
+
+      break;
+    }
+
+  if (ready > 0) 
+    for (f = fds; f < &fds[nfds]; ++f)
+      {
+       if (f->fd >= 0)
+         {
+           if (FD_ISSET (f->fd, rset))
+             f->revents |= POLLIN;
+           if (FD_ISSET (f->fd, wset))
+             f->revents |= POLLOUT;
+           if (FD_ISSET (f->fd, xset))
+             f->revents |= POLLPRI;
+         }
+      }
+
+  return ready;
+}
+
+#endif
index a89e626dce21011ee399ba2453896a6764e56f38..f5b05de0c95cd6cd517e6d1031bff6a31ed1fe5d 100644 (file)
@@ -2,18 +2,33 @@
 
 rc=0
 
+run=no
+
+for SU_PORT in select kqueue devpoll epoll poll ; do
+
+export SU_PORT
+
+egrep -q -i '^#define have_(sys_)?'$SU_PORT ../../config.h ||
+continue
+
+run=yes
+
 if $VALGRIND ./test_su ; then
-    echo PASS: multithread test_su
+    echo PASS: multithread test_su with $SU_PORT
 else
-    echo FAIL: multithread test_su failed
+    echo FAIL: multithread test_su with $SU_PORT failed
     rc=1
 fi
 
 if $VALGRIND ./test_su -s ; then
-    echo PASS: singlethread test_su
+    echo PASS: singlethread test_su with $SU_PORT
 else
-    echo FAIL: singlethread test_su failed
+    echo FAIL: singlethread test_su with $SU_PORT failed
     rc=1
 fi
 
+done
+
+test $run = no && exit 77
+
 exit $rc
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx b/libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx
new file mode 100644 (file)
index 0000000..be0d8b5
--- /dev/null
@@ -0,0 +1,24 @@
+#! /bin/bash
+
+rc=0
+
+run=no
+
+export SU_PORT=CoreFoundation
+
+
+if $VALGRIND ./test_su_osx ; then
+    echo PASS: multithread test_su_osx with $SU_PORT
+else
+    echo FAIL: multithread test_su_osx with $SU_PORT failed
+    rc=1
+fi
+
+if $VALGRIND ./test_su_osx -s ; then
+    echo PASS: singlethread test_su_osx with $SU_PORT
+else
+    echo FAIL: singlethread test_su_osx with $SU_PORT failed
+    rc=1
+fi
+
+exit $rc
index 198b36fe942c2d2e390e8ed6d09a8482b95ebbfa..1a0890f709a5c8e42bc20fda33d156e7336cb00c 100644 (file)
@@ -106,7 +106,7 @@ HTABLE_SCOPE entry_t **prefix##_hash(prefix##_t const *, hash_value_t hv); \
 HTABLE_SCOPE entry_t **prefix##_next(prefix##_t const *, entry_t * const *ee); \
 HTABLE_SCOPE void prefix##_append(prefix##_t *pr, entry_t const *e); \
 HTABLE_SCOPE void prefix##_insert(prefix##_t *pr, entry_t const *e); \
-HTABLE_SCOPE void prefix##_remove(prefix##_t *, entry_t const *e)
+HTABLE_SCOPE int prefix##_remove(prefix##_t *, entry_t const *e)
 
 /** Hash table implementation.
  *
@@ -220,13 +220,13 @@ void prefix##_insert(prefix##_t *pr, entry_t const *e) \
 } \
 \
 HTABLE_SCOPE \
-void prefix##_remove(prefix##_t *pr, entry_t const *e) \
+int prefix##_remove(prefix##_t *pr, entry_t const *e) \
 { \
   size_t i, j, k; \
   size_t size = pr->pr##_size; \
   entry_t **htable = pr->pr##_table; \
 \
-  if (!e) return; \
+  if (!e) return -1; \
 \
   /* Search for entry */ \
   for (i = hfun(e) % size; htable[i]; i = (i + 1) % size) \
@@ -234,7 +234,7 @@ void prefix##_remove(prefix##_t *pr, entry_t const *e) \
       break; \
 \
   /* Entry is not in table? */ \
-  assert(htable[i]); if (!e) return; \
+  if (!htable[i]) return -1; \
 \
   /* Move table entries towards their primary place  */ \
   for (j = (i + 1) % size; htable[j]; j = (j + 1) % size) { \
@@ -252,6 +252,8 @@ void prefix##_remove(prefix##_t *pr, entry_t const *e) \
   pr->pr##_used--; \
 \
   htable[i] = NULL; \
+\
+  return 0; \
 } \
 extern int prefix##_dummy
 
index 2c5bb5cf795b6c60fa96246dfa58c130b0e218e9..9803916ca61bf656317997fe61467095e1ad9384 100644 (file)
@@ -240,7 +240,7 @@ int prefix##_remove(type *pr, entrytype const e) \
     if (is_equal(e, htable[i])) \
       break; \
 \
-  assert(is_used(htable[i])); if (!is_used(htable[i])) return -1; \
+  if (!is_used(htable[i])) return -1; \
 \
   /* Move table entries towards their primary place  */ \
   for (j = (i + 1) % size; is_used(htable[j]); j = (j + 1) % size) { \
index 95565463521d0acf6fbb613f5bdc8144e5446a72..b9851a9459876ea2ca1339c2e9f2b6c079dbfbb1 100644 (file)
@@ -220,13 +220,15 @@ typedef size_t su_ioveclen_t;
  * } WSABUF, *LPWSABUF;
  * @endcode
  *
- * @note Ordering of the fields is reversed on Windows. Do not initialize this
- * structure with static initializer, but assign both fields separately.
+ * @note Ordering of the fields is reversed on Windows. Do not initialize
+ * this structure with static initializer, but assign both fields
+ * separately. Note that the type of the siv_len is #su_ioveclen_t which is
+ * defined as u_long on Windows and size_t on POSIX.
  *
  * For historical reasons, the structure is known as #msg_iovec_t in @msg
  * module.
  *
- * @sa #su_iovec_t, #su_ioveclen_t, SU_IOVECLEN_MAX, su_vsend(), su_vrecv(), 
+ * @sa #su_ioveclen_t, SU_IOVECLEN_MAX, su_vsend(), su_vrecv(), 
  * #msg_iovec_t, msg_iovec(), msg_recv_iovec(), 
  * @c struct @c iovec defined in <sys/uio.h>, writev(2), readv(2),
  * sendmsg(), recvmsg(),
index 0e7915ba3e68eb8c08aec7c9b9bc220d5e5bea06..a9ee6ba991efb95688dcf2e14d81cf66a96894ba 100644 (file)
@@ -45,15 +45,15 @@ typedef struct bw_fwd_table bm_fwd_table_t;
 
 SOFIAPUBFUN bm_fwd_table_t *bm_memmem_study(char const *needle, size_t nlen);
 
-SOFIAPUBFUN char const* bm_memmem(char const *haystack, size_t hlen,
-                                 char const *needle, size_t nlen,
-                                 bm_fwd_table_t *fwd);
+SOFIAPUBFUN char *bm_memmem(char const *haystack, size_t hlen,
+                           char const *needle, size_t nlen,
+                           bm_fwd_table_t *fwd);
 
 SOFIAPUBFUN bm_fwd_table_t *bm_memcasemem_study(char const *needle, size_t);
 
-SOFIAPUBFUN char const* bm_memcasemem(char const *haystack, size_t hlen,
-                                     char const *needle, size_t nlen,
-                                     bm_fwd_table_t *fwd);
+SOFIAPUBFUN char *bm_memcasemem(char const *haystack, size_t hlen,
+                               char const *needle, size_t nlen,
+                               bm_fwd_table_t *fwd);
 
 SOFIA_END_DECLS
 
index 814fea2a4312086e7f026a51418cb737b359356d..687463a883ec864757576d0b3f9f6906646c8bdb 100644 (file)
 /** Define as 1 if you have OSX CoreFoundation interface */
 #undef SU_HAVE_OSX_CF_API
 
+/** Define as 1 if you want to enable experimental features.
+ *
+ * Use --enable-experimental with ./configure
+ */
+#undef SU_HAVE_EXPERIMENTAL
+
 /** Define as 1 if you have inline functions */
 #undef SU_HAVE_INLINE
 /** Define as suitable declarator inline functions */
index 424124b12baa9e695cf2d17833d888622016e59d..86c6e5b243e839c7e75dccfff7057fbcdede6b6b 100644 (file)
@@ -74,9 +74,9 @@ SOFIAPUBVAR su_log_t SU_LOG[];
 #endif
 
 #define SU_DEBUG_DEF(level) \
-  static SU_INLINE void su_debug_##level(char const *fmt, ...) \
+  su_inline void su_debug_##level(char const *fmt, ...) \
     __attribute__ ((__format__ (printf, 1, 2))); \
-  void su_debug_##level(char const *fmt, ...) \
+  su_inline void su_debug_##level(char const *fmt, ...) \
     { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
 
 SU_DEBUG_DEF(0)
index 73d37adefa35bfec73ca4e55c6b2509a79a94c98..6945ef56f9598d830fa6876247969abfc0f41380 100644 (file)
@@ -174,7 +174,7 @@ SOFIAPUBFUN void    tl_vfree(tagi_t *t);
 #if SU_HAVE_INLINE
 su_inline tag_value_t tag_int_v(int v) { return (tag_value_t)v; }
 su_inline tag_value_t tag_int_vr(int *vp) { return (tag_value_t)vp; }
-su_inline tag_value_t tag_uint_v(size_t v) { return (tag_value_t)v; }
+su_inline tag_value_t tag_uint_v(unsigned v) { return (tag_value_t)v; }
 su_inline tag_value_t tag_uint_vr(unsigned *vp) { return (tag_value_t)vp; }
 su_inline tag_value_t tag_usize_v(usize_t v) { return (tag_value_t)v; }
 su_inline tag_value_t tag_usize_vr(usize_t *vp) { return (tag_value_t)vp; }
@@ -197,9 +197,9 @@ extern "C++" {
   static inline tag_value_t tag_ptr_v(void const *v)
   { return (tag_value_t)v; }
   static inline tag_value_t tag_ptr_vr(void *vp, void const *p) 
-  { return(tag_value_t)vp; }
+  { return (tag_value_t)vp; }
   static inline tag_value_t tag_str_v(char *v) { return (tag_value_t)v; }
-  static inline tag_value_t tag_str_vr(char **vp) {return(tag_value_t)vp;}
+  static inline tag_value_t tag_str_vr(char **vp) {return (tag_value_t)vp;}
 }
 #endif
 su_inline tag_value_t tag_filter_v(tag_filter_f *v) {return(tag_value_t)v;}
@@ -208,10 +208,14 @@ su_inline tag_value_t tag_filter_v(tag_filter_f *v) {return(tag_value_t)v;}
 #define tag_int_vr(v)  (tag_value_t)(v)
 #define tag_uint_v(v)  (tag_value_t)(v)
 #define tag_uint_vr(v) (tag_value_t)(v)
+#define tag_usize_v(v) (tag_value_t)(v)
+#define tag_usize_vr(v) (tag_value_t)(v)
 #define tag_bool_v(v)  (tag_value_t)(v != 0)
 #define tag_bool_vr(v) (tag_value_t)(v)
 #define tag_ptr_v(v)   (tag_value_t)(v)
 #define tag_ptr_vr(v,x) (tag_value_t)(v)
+#define tag_cptr_v(v)   (tag_value_t)(v)
+#define tag_cptr_vr(v,x) (tag_value_t)(v)
 #define tag_cstr_v(v)  (tag_value_t)(v)
 #define tag_cstr_vr(v) (tag_value_t)(v)
 #define tag_str_v(v)   (tag_value_t)(v)
index c6c30ec20c49132bd2f3016ad8eccfae47d26dd8..5989744a08942b22e1587f9333cfd592644b921a 100644 (file)
@@ -104,9 +104,8 @@ SOFIAPUBFUN uint32_t su_ntp_mw(su_ntp_t ntp);
 SOFIAPUBFUN uint32_t su_ntp_fraq(su_time_t t);
 SOFIAPUBFUN uint32_t su_time_ms(su_time_t t);
 #else
-static SU_INLINE
 /** Middle 32 bit of NTP timestamp. */
-uint32_t su_ntp_fraq(su_time_t t)
+su_inline uint32_t su_ntp_fraq(su_time_t t)
 {
   /*
    * Multiply usec by 0.065536 (ie. 2**16 / 1E6)
@@ -116,9 +115,8 @@ uint32_t su_ntp_fraq(su_time_t t)
   return (t.tv_sec << 16) + (1024 * t.tv_usec + 7812) / 15625;
 }
 
-static SU_INLINE
 /** Time as milliseconds. */
-uint32_t su_time_ms(su_time_t t)
+su_inline uint32_t su_time_ms(su_time_t t)
 {
   return t.tv_sec * 1000 + (t.tv_usec + 500) / 1000;
 }
index 1b22eb0d8c7f2e8d165496a20e668d78ddcc5370..89b002aa76af62b9d62816ca3a99004d8fa6c4d2 100644 (file)
@@ -30,6 +30,7 @@
  * @file sofia-sip/su_wait.h Syncronization and threading interface.
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Martti Mela <Martti.Mela@nokia.com>
  * 
  * @date Created: Tue Sep 14 15:51:04 1999 ppessi
  */
@@ -44,6 +45,7 @@
 #ifndef SU_TIME_H
 #include "sofia-sip/su_time.h"
 #endif
+
 #if SU_HAVE_POLL
 #include <sys/poll.h>
 #endif
@@ -53,7 +55,36 @@ SOFIA_BEGIN_DECLS
 /* ---------------------------------------------------------------------- */
 /* Constants */
 
-#if SU_HAVE_POLL || DOCUMENTATION_ONLY
+#if SU_HAVE_KQUEUE
+/** Compare wait object. @HI */
+#define SU_WAIT_CMP(x, y) \
+ (((x).ident - (y).ident) ? ((x).ident - (y).ident) : ((x).flags - (y).flags))
+
+/** Incoming data is available on socket. @HI */
+#define SU_WAIT_IN      (EVFILT_READ)
+/** Data can be sent on socket. @HI */
+#define SU_WAIT_OUT     (EVFILT_WRITE)
+/** Socket is connected. @HI */
+#define SU_WAIT_CONNECT (EVFILT_WRITE)
+/** An error occurred on socket. @HI */
+#define SU_WAIT_ERR     (EV_ERROR)
+/** The socket connection was closed. @HI */
+#define SU_WAIT_HUP     (EV_EOF)
+/** A listening socket accepted a new connection. @HI */
+#define SU_WAIT_ACCEPT  (EVFILT_READ)
+
+/** No timeout for su_wait(). */
+#define SU_WAIT_FOREVER (-1)
+/** The return value of su_wait() if timeout occurred. */
+#define SU_WAIT_TIMEOUT (-2)
+
+/** Initializer for a wait object. @HI */
+#define SU_WAIT_INIT    { INVALID_SOCKET, 0, 0, 0, 0, NULL }
+
+/** Maximum number of sources supported by su_wait() */
+#define SU_WAIT_MAX    (0x7fffffff)
+
+#elif SU_HAVE_POLL || DOCUMENTATION_ONLY
 /** Compare wait object. @HI */
 #define SU_WAIT_CMP(x, y) \
  (((x).fd - (y).fd) ? ((x).fd - (y).fd) : ((x).events - (y).events))
@@ -101,35 +132,73 @@ SOFIA_BEGIN_DECLS
 #define SU_WAIT_MAX    (64)
 
 #else
-#define SU_WAIT_CMP(x, y) 
-#define SU_WAIT_IN      
-#define SU_WAIT_OUT     
-#define SU_WAIT_ERR     
-#define SU_WAIT_HUP     
-#define SU_WAIT_ACCEPT  
-#define SU_WAIT_FOREVER 
-#define SU_WAIT_TIMEOUT 
+/* If nothing works, try these */
+
+#define        POLLIN          0x001
+#define        POLLPRI         0x002
+#define        POLLOUT         0x004
+
+#ifdef __USE_XOPEN
+#define        POLLRDNORM      0x040
+#define        POLLRDBAND      0x080
+#define        POLLWRNORM      0x100
+#define        POLLWRBAND      0x200
+#endif
+
+/* These for pollfd.revents */
+#define POLLERR         0x008
+#define POLLHUP         0x010
+#define POLLNVAL        0x020
+
+#define SU_WAIT_CMP(x, y) \
+ (((x).fd - (y).fd) ? ((x).fd - (y).fd) : ((x).events - (y).events))
+
+#define SU_WAIT_IN      POLLIN
+#define SU_WAIT_OUT     POLLOUT
+#define SU_WAIT_CONNECT POLLOUT
+#define SU_WAIT_ERR     POLLERR
+#define SU_WAIT_HUP     POLLHUP
+#define SU_WAIT_ACCEPT  POLLIN
+#define SU_WAIT_FOREVER (-1)
+#define SU_WAIT_TIMEOUT (-2)
 
-#define SU_WAIT_INIT
+#define SU_WAIT_INIT    { INVALID_SOCKET, 0, 0 }
+
+/** Maximum number of sources supported by su_wait() */
+#define SU_WAIT_MAX    (0x7fffffff)
 
 #endif
 
 /* ---------------------------------------------------------------------- */
 /* Types */
 
-#if 0
-typedef struct _pollfd {
-  su_socket_t fd;           /* file descriptor */
-  short events;     /* requested events */
-  short revents;    /* returned events */
-} su_wait_t;
+/** Wait object. */
+#if SU_HAVE_KQUEUE
+typedef struct kevent su_wait_t;
 #elif SU_HAVE_POLL
 typedef struct pollfd su_wait_t;
 #elif SU_HAVE_WINSOCK
 typedef HANDLE su_wait_t;
 #else
-/** Wait object. */
-typedef struct os_specific su_wait_t;
+/* typedef struct os_specific su_wait_t; */
+typedef struct pollfd su_wait_t;
+struct pollfd {
+  su_socket_t fd;   /* file descriptor */
+  short events;     /* requested events */
+  short revents;    /* returned events */
+};
+
+
+/* Type used for the number of file descriptors.  */
+typedef unsigned long int nfds_t;
+
+/* Poll the file descriptors described by the NFDS structures starting at
+   FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+   an event to occur; if TIMEOUT is -1, block until an event occurs.
+   Returns the number of file descriptors with events, zero if timed out,
+   or -1 for errors.  */
+int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
+
 #endif
 
 /* Used by AD */
@@ -191,7 +260,7 @@ typedef SU_ROOT_MAGIC_T su_root_magic_t;
  */
 typedef SU_WAKEUP_ARG_T su_wakeup_arg_t;
 
-/** Wakeup callback function prototype. 
+/** Wakeup callback function pointer type. 
  *
  * Whenever a registered wait object receives an event, the @link
  * ::su_wakeup_f callback function @endlink is invoked.
@@ -316,9 +385,13 @@ typedef su_msg_t * const su_msg_cr[1];
 #define SU_MSG_R_INIT   { NULL }
 
 /** Message delivery function type. */
-typedef void (*su_msg_f)(su_root_magic_t *magic, 
-                        su_msg_r msg,
-                        su_msg_arg_t *arg);
+typedef void su_msg_function(su_root_magic_t *magic, 
+                            su_msg_r msg,
+                            su_msg_arg_t *arg);
+
+/** Message delivery function pointer type. */
+typedef su_msg_function *su_msg_f;
+
 
 /* ---------------------------------------------------------------------- */
 
@@ -350,11 +423,15 @@ SOFIAPUBFUN int su_wait(su_wait_t waits[], unsigned n, su_duration_t timeout);
 SOFIAPUBFUN int su_wait_events(su_wait_t *wait, su_socket_t s);
 SOFIAPUBFUN int su_wait_mask(su_wait_t *dst, su_socket_t s, int events);
 
-#if SU_HAVE_POLL
+#if !HAVE_WIN32 && (SU_HAVE_POLL || HAVE_SELECT)
 static inline
 su_socket_t su_wait_socket(su_wait_t *wait)
 {
+#if SU_HAVE_KQUEUE
+  return wait->ident;
+#else
   return wait->fd;
+#endif
 }
 #endif
 
@@ -362,6 +439,7 @@ su_socket_t su_wait_socket(su_wait_t *wait)
 SOFIAPUBFUN su_root_t *su_root_create(su_root_magic_t *magic)
   __attribute__((__malloc__));
 SOFIAPUBFUN void su_root_destroy(su_root_t*);
+SOFIAPUBFUN char const *su_root_name(su_root_t *self);
 SOFIAPUBFUN int su_root_set_magic(su_root_t *self, su_root_magic_t *magic);
 SOFIAPUBFUN su_root_magic_t *su_root_magic(su_root_t *root);
 SOFIAPUBFUN int su_root_register(su_root_t*, su_wait_t *, 
@@ -472,6 +550,34 @@ SOFIAPUBFUN void su_clone_wait(su_root_t *root, su_clone_r clone);
 SOFIAPUBFUN int su_clone_pause(su_clone_r);
 SOFIAPUBFUN int su_clone_resume(su_clone_r);
 
+/* ---------------------------------------------------------------------- */
+/* Different su_root_t implementations */
+
+typedef su_port_t *su_port_create_f(void);
+typedef int su_clone_start_f(su_root_t *parent,
+                           su_clone_r return_clone,
+                           su_root_magic_t *magic,
+                           su_root_init_f init,
+                           su_root_deinit_f deinit);
+
+SOFIAPUBFUN void su_port_prefer(su_port_create_f *f, su_clone_start_f *);
+
+SOFIAPUBFUN su_port_create_f su_default_port_create;
+SOFIAPUBFUN su_port_create_f su_epoll_port_create;
+SOFIAPUBFUN su_port_create_f su_poll_port_create;
+SOFIAPUBFUN su_port_create_f su_wsaevent_port_create;
+SOFIAPUBFUN su_port_create_f su_select_port_create;
+SOFIAPUBFUN su_port_create_f su_kqueue_port_create;
+SOFIAPUBFUN su_port_create_f su_devpoll_port_create;
+
+SOFIAPUBFUN su_clone_start_f su_default_clone_start;
+SOFIAPUBFUN su_clone_start_f su_epoll_clone_start;
+SOFIAPUBFUN su_clone_start_f su_poll_clone_start;
+SOFIAPUBFUN su_clone_start_f su_wsaevent_clone_start;
+SOFIAPUBFUN su_clone_start_f su_select_clone_start;
+SOFIAPUBFUN su_clone_start_f su_kqueue_clone_start;
+SOFIAPUBFUN su_clone_start_f su_devpoll_clone_start;
+
 SOFIA_END_DECLS
 
 #endif /* SU_WAIT_H */
index 8ee6cb26ddaebaa78090e1cb9d9371ff6cc19bc9..d43bd0f587d6c9447f63eb7ad67b5b1aa8a8e76d 100644 (file)
@@ -145,13 +145,14 @@ enum {
   tst_verbatim = 1,
   /** If (TSTFLAGS & tst_abort) is non-zero, abort() when failed. */
   tst_abort = 2,
+  /** If (TSTFLAGS & tst_log) is non-zero, log intermediate results. */
+  tst_log = 4
 };
 
 #ifndef TSTFLAGS
 #error <TSTFLAGS is not defined>
 #endif
 
-#ifdef TSTFLAGS
 /** Begin a test function. @HIDE */
 #define BEGIN() BEGIN_(TSTFLAGS); { extern int tstdef_dummy
 /** End a test function. @HIDE */
@@ -179,17 +180,12 @@ enum {
 /** Test that @a suite has same size as @a expected. @HIDE */
 #define TEST_SIZE(suite, expected) TEST_SIZE_(TSTFLAGS, suite, expected)
 
-#else
-/* Deprecated */
-#define TEST0(flags, suite) TEST_1_(flags, suite)
-#define TEST_1(flags, suite) TEST_1_(flags, suite)
-#define TEST_VOID(flags, suite) TEST_VOID_(flags, suite)
-#define TEST(flags, suite, expect) TEST_(flags, suite, expect)
-#define TEST64(flags, suite, expect) TEST64_(flags, suite, expect)
-#define TEST_S(flags, suite, expect) TEST_S_(flags, suite, expect)
-#define BEGIN(flags) BEGIN_(flags) { extern int tstdef_dummy
-#define END(flags) (void) tstdef_dummy;  } END_(flags) 
-#endif
+/** Print in torture test with -l option */
+#define TEST_LOG(x)                   \
+  do {                                \
+    if (tstflags & tst_log)           \
+      printf x;                               \
+  } while(0)
 
 #define TEST_FAILED(flags) \
   ((flags) & tst_abort) ? abort() : (void)0; return 1
index 9dd78f023b0c1ac663f469ad6480cb633dcce24e..1b97828341c334448ca0c2a4b8d49cd4de880945 100644 (file)
 
 #include "config.h" 
 
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-
 #include "sofia-sip/su.h"
 #include "sofia-sip/su_log.h"
 #include "sofia-sip/su_alloc.h"
 
+#include <stdio.h>
+#include <string.h>
+#if HAVE_SIGNAL
+#include <signal.h>
+#endif
+
 #if !SU_HAVE_BSDSOCK && !SU_HAVE_WINSOCK
 #error Bad configuration
 #endif
@@ -67,7 +69,9 @@ int su_init(void)
 {
   su_home_threadsafe(NULL);
 
+#if HAVE_SIGPIPE
   signal(SIGPIPE, SIG_IGN);    /* we want to get EPIPE instead */
+#endif
 
   su_log_init(su_log_default);
   su_log_init(su_log_global);
index 7a2afbcb659647fd5122f4c966b05f846cf507c3..88a97b945330671e66f45dc993b09d52dbe38fe4 100644 (file)
@@ -887,10 +887,16 @@ int su_getaddrinfo(char const *node, char const *service,
                   su_addrinfo_t const *hints,
                   su_addrinfo_t **res)
 {
+  int retval;
+  su_addrinfo_t *ai;
+
+  if (!service || service[0] == '\0')
+    service = "0";
+
 #if HAVE_SCTP
   if (res && hints && hints->ai_protocol == IPPROTO_SCTP) {
-    su_addrinfo_t *ai, system_hints[1];
-    int retval, socktype;
+    su_addrinfo_t system_hints[1];
+    int socktype;
 
     socktype = hints->ai_socktype;
     
@@ -920,7 +926,31 @@ int su_getaddrinfo(char const *node, char const *service,
   }
 #endif
 
-  return getaddrinfo(node, service, hints, res);
+  retval = getaddrinfo(node, service, hints, res);
+
+  if (retval == 0) {
+    for (ai = *res; ai; ai = ai->ai_next) {
+      if (ai->ai_protocol)
+       continue;
+
+      if (hints && hints->ai_protocol) {
+       ai->ai_protocol = hints->ai_protocol;
+       continue;
+      }
+
+      if (ai->ai_family != AF_INET 
+#if SU_HAVE_IN6
+         && ai->ai_family != AF_INET6
+#endif
+         ) continue;
+
+      if (ai->ai_socktype == SOCK_STREAM)
+       ai->ai_protocol = IPPROTO_TCP;
+      else if (ai->ai_socktype == SOCK_DGRAM)
+       ai->ai_protocol = IPPROTO_UDP;
+    }
+  }
+  return retval;
 }
 
 /** Free su_addrinfo_t structure allocated by su_getaddrinfo(). */
index 9b02edb2372456c90ed270ea64778c650096c095..5ba7f3a9803386a3c93ef47870e4eaef35a28c54 100644 (file)
@@ -87,8 +87,8 @@
  *
  * As you might have guessed, it is also possible to use reference counting
  * with home objects. The function su_home_ref() increases the reference
- * count, su_home_unref() decreases. A newly allocated home object has
- * reference count of 1.
+ * count, su_home_unref() decreases it. A newly allocated or initialized
+ * home object has reference count of 1.
  *
  * @note Please note that while it is possible to create new references to
  * secondary home objects which have a parent home, the secondary home
  * @note
  *
  * The su_home_destroy() function is deprecated as it does not free the home
- * object itself.
+ * object itself. Like su_home_deinit(), it should be called only on home
+ * objects with reference count of 1.
  *
- * The function su_home_init() initializes a home object with infinite
- * reference count. It must be deinitialized with su_home_deinit().
+ * The function su_home_init() initializes a home object structure. When the
+ * initialized home object is destroyed or deinitialized or its reference
+ * count reaches zero, the memory allocate thorugh it reclaimed but the home
+ * object structure itself is not freed.
  *
  * @section su_home_destructor_usage Destructors
  *
  * @section su_alloc_threadsafe Threadsafe Operation
  *
  * If multiple threads need to access same home object, it must be marked as
- * @c threadsafe by calling su_home_threadsafe() with the home pointer as
+ * @e threadsafe by calling su_home_threadsafe() with the home pointer as
  * argument. The threadsafeness is not inherited by clones.
  *
  * The threadsafe home objects can be locked and unlocked with
- * su_home_mutex_lock() and su_home_mutex_unlock().
+ * su_home_mutex_lock() and su_home_mutex_unlock(). These operations are
+ * no-op on home object that is not threadsafe.
  *
  * @section su_alloc_preloading Preloading a Memory Home
  *
- * In some situations there is quite heavy overhead when using the global
- * heap allocator. The overhead caused by the large number of small
+ * In some situations there is quite heavy overhead if the global heap
+ * allocator is used. The overhead caused by the large number of small
  * allocations can be reduced by using su_home_preload(): it allocates or
  * preloads some a memory to home to be used as a kind of private heap. The
- * preloaded memory area is then used to satisfy small enough allocations.
+ * preloaded memory area is then used to satisfy small enough allocations. 
  * For instance, the SIP parser typically preloads some 2K of memory when it
  * starts to parse the message.
  *
  * far as possible; if it is not enough, allocation is made from heap.
  *
  * The word @e auto refers to the automatic scope; however, the home object
- * initialized with su_home_auto() must be explicitly deinitialized with
- * su_home_deinit() when the program exits the scope where the stack frame
- * used in su_home_auto() was allocate.
- * 
+ * that was initialized with su_home_auto() must be explicitly deinitialized
+ * with su_home_deinit() or su_home_unref() when the program exits the scope
+ * where the stack frame used in su_home_auto() was allocated.
  */
 
 #include <sofia-sip/su_config.h>
@@ -196,6 +199,8 @@ void (*su_home_unlocker)(void *mutex);
 void (*su_home_mutex_locker)(void *mutex);
 void (*su_home_mutex_unlocker)(void *mutex);
 
+void (*su_home_destroy_mutexes)(void *mutex);
+
 #define MEMLOCK(h)   \
   (((h) && (h)->suh_lock ? su_home_locker((h)->suh_lock) : (void)0), (h)->suh_blocks)
 #define UNLOCK(h) (((h) && (h)->suh_lock ? su_home_unlocker((h)->suh_lock) : (void)0), NULL)
@@ -221,10 +226,10 @@ enum {
 
 #define ALIGNMENT (8)
 #define ALIGN(n) (size_t)(((n) + (ALIGNMENT - 1)) & (size_t)~(ALIGNMENT - 1))
-#define SIZEBITS (sizeof (size_t) * 8 - 1)
+#define SIZEBITS (sizeof (unsigned) * 8 - 1)
 
 typedef struct {
-  size_t   sua_size:SIZEBITS;  /**< Size of the block */
+  unsigned sua_size:SIZEBITS;  /**< Size of the block */
   unsigned sua_home:1;         /**< Is this another home? */
   unsigned :0;
   void    *sua_data;           /**< Data pointer */
@@ -242,8 +247,9 @@ struct su_block_s {
 
   unsigned    sub_prsize:16;   /**< Preload size */
   unsigned    sub_prused:16;   /**< Used from preload */
-  unsigned    sub_auto:1;      /**< struct su_block_s is from stack! */
-  unsigned    sub_preauto:1;   /**< Preload is from stack! */
+  unsigned    sub_hauto:1;      /**< "Home" is not from malloc */
+  unsigned    sub_auto:1;      /**< struct su_block_s is not from malloc */
+  unsigned    sub_preauto:1;   /**< Preload is not from malloc */
   unsigned    sub_auto_all:1;  /**< Everything is from stack! */
   unsigned :0;
 
@@ -255,7 +261,7 @@ static void su_home_check_blocks(su_block_t const *b);
 static void su_home_stats_alloc(su_block_t *, void *p, void *preload,
                                size_t size, int zero);
 static void su_home_stats_free(su_block_t *sub, void *p, void *preload,
-                              size_t size);
+                              unsigned size);
 
 static void _su_home_deinit(su_home_t *home);
 
@@ -345,7 +351,7 @@ static inline int su_alloc_check(su_block_t const *sub, su_alloc_t const *sua)
   size_t size, term;
   assert(sua);
   if (sua) {
-    size = sua->sua_size;
+    size = (size_t)sua->sua_size;
     memcpy(&term, (char *)sua->sua_data + size, sizeof (term));
     assert(size - term == 0);
     return size - term == 0;
@@ -358,8 +364,9 @@ static inline int su_alloc_check(su_block_t const *sub, su_alloc_t const *sua)
 
 /** Allocate the block hash table.
  *
- * The function su_hash_alloc() allocates a block hash table of @a n
- * elements.
+ * @internal
+ *
+ * Allocate a block hash table of @a n elements.
  *
  * @param home  pointer to home object
  * @param n     number of buckets in hash table
@@ -372,8 +379,12 @@ static inline su_block_t *su_hash_alloc(size_t n)
 {
   su_block_t *b = calloc(1, offsetof(su_block_t, sub_nodes[n]));
 
-  if (b)
+  if (b) {
+    /* Implicit su_home_init(); */
+    b->sub_ref = 1;
+    b->sub_hauto = 1;
     b->sub_n = n;
+  }
 
   return b;
 }
@@ -381,6 +392,8 @@ static inline su_block_t *su_hash_alloc(size_t n)
 enum sub_zero { do_malloc, do_calloc, do_clone };
 
 /** Allocate a memory block.
+ *
+ * @internal
  *
  * Precondition: locked home
  *
@@ -399,7 +412,10 @@ void *sub_alloc(su_home_t *home,
 {
   void *data, *preload = NULL;
   
-  assert (size < (1UL << SIZEBITS));
+  assert (size < (((size_t)1) << SIZEBITS));
+
+  if (size >= ((size_t)1) << SIZEBITS)
+    return (void)(errno = ENOMEM), NULL;
 
   if (sub == NULL || 3 * sub->sub_used > 2 * sub->sub_n) {
     /* Resize the hash table */
@@ -429,6 +445,7 @@ void *sub_alloc(su_home_t *home,
       b2->sub_preload = sub->sub_preload;
       b2->sub_prsize = sub->sub_prsize;
       b2->sub_prused = sub->sub_prused;
+      b2->sub_hauto = sub->sub_hauto;
       b2->sub_preauto = sub->sub_preauto;
       b2->sub_destructor = sub->sub_destructor;
       /* auto_all is not copied! */
@@ -473,7 +490,7 @@ void *sub_alloc(su_home_t *home,
     if (!preload)
       sub->sub_auto_all = 0;
 
-    if (zero == do_clone) {
+    if (zero >= do_clone) {
       /* Prepare cloned home */ 
       su_home_t *subhome = data;
 
@@ -485,13 +502,13 @@ void *sub_alloc(su_home_t *home,
 
       subhome->suh_size = (unsigned)size;
       subhome->suh_blocks->sub_parent = home;
-      subhome->suh_blocks->sub_ref = 1;
+      subhome->suh_blocks->sub_hauto = 0;
     }
 
     /* OK, add the block to the hash table. */
 
     sua = su_block_add(sub, data); assert(sua);
-    sua->sua_size = size;
+    sua->sua_size = (unsigned)size;
     sua->sua_home = zero > 1;
 
     if (sub->sub_stats)
@@ -525,16 +542,16 @@ void *su_home_new(isize_t size)
   assert(size >= sizeof (*home));
 
   if (size < sizeof (*home))
-    return (errno = EINVAL), NULL;
+    return (void)(errno = EINVAL), NULL;
   else if (size > INT_MAX)
-    return (errno = ENOMEM), NULL;
+    return (void)(errno = ENOMEM), NULL;
 
   home = calloc(1, size);
   if (home) {
     home->suh_size = (int)size;
     home->suh_blocks = su_hash_alloc(SUB_N);
     if (home->suh_blocks)
-      home->suh_blocks->sub_ref = 1;
+      home->suh_blocks->sub_hauto = 0;
     else
       free(home), home = NULL;
   }
@@ -612,12 +629,10 @@ int su_home_desctructor(su_home_t *home, void (*destructor)(void *))
 
 /**Unreference a su_home_t object.
  *
- * The function su_home_unref() decrements the reference count on a home
- * object and destroys and frees it and the memory allocations using it.
- *
- * @param home memory pool object to be unreferences
+ * Decrements the reference count on home object and destroys and frees it
+ * and the memory allocations using it if the reference count reaches 0.
  *
- * The function return values is 
+ * @param home memory pool object to be unreferenced
  *
  * @retval 1 if object was freed
  * @retval 0 if object is still alive
@@ -650,8 +665,10 @@ int su_home_unref(su_home_t *home)
     return 1;
   }
   else {
+    int hauto = sub->sub_hauto;
     _su_home_deinit(home);
-    free(home);
+    if (!hauto)
+      free(home);
     /* UNLOCK(home); */
     return 1;
   }
@@ -725,7 +742,7 @@ int su_home_has_parent(su_home_t const *home)
 
 /** Allocate a memory block.
  *
- * The function su_alloc() allocates a memory block of a given @a size.
+ * Allocates a memory block of a given @a size.
  *
  * If @a home is NULL, this function behaves exactly like malloc().
  *
@@ -752,9 +769,9 @@ void *su_alloc(su_home_t *home, isize_t size)
 
 /**Free a memory block.
  *
- * The function su_free() frees a single memory block. The @a home must be
- * the owner of the memory block (usually the memory home used to allocate
- * the memory block, or NULL if no home was used).
+ * Frees a single memory block. The @a home must be the owner of the memory
+ * block (usually the memory home used to allocate the memory block, or NULL
+ * if no home was used).
  *
  * @param home  pointer to home object
  * @param data  pointer to the memory block to be freed
@@ -792,7 +809,7 @@ void su_free(su_home_t *home, void *data)
       }
 
 #if MEMCHECK != 0
-      memset(data, 0xaa, allocation->sua_size);
+      memset(data, 0xaa, (size_t)allocation->sua_size);
 #endif
 
       memset(allocation, 0, sizeof (*allocation));
@@ -810,9 +827,9 @@ void su_free(su_home_t *home, void *data)
 
 /** Check home consistency.
  *
- * The function su_home_check() ensures that the home structure and all
- * memory blocks allocated through it are consistent.  It can be used to
- * catch memory allocation and usage errors.
+ * Ensures that the home structure and all memory blocks allocated through
+ * it are consistent. It can be used to catch memory allocation and usage
+ * errors.
  *
  * @param home Pointer to a memory home.
  */
@@ -851,11 +868,10 @@ void su_home_check_blocks(su_block_t const *b)
 /**
  * Create an su_home_t object.
  *
- * The function su_home_create() creates a home object.  A home object is
- * used to collect multiple memory allocations, so that they all can be
- * freed by calling su_home_unref().
+ * Creates a home object. A home object is used to collect multiple memory
+ * allocations, so that they all can be freed by calling su_home_unref().
  *
- * @return This function returns a pointer to an @c su_home_t object, or @c
+ * @return This function returns a pointer to an #su_home_t object, or 
  * NULL upon an error. 
  */
 su_home_t *su_home_create(void)
@@ -863,10 +879,10 @@ su_home_t *su_home_create(void)
   return su_home_new(sizeof(su_home_t));
 }
 
-/** Deinitialize a home object
+/** Destroy a home object
  *
- * The function su_home_destroy() frees all memory blocks associated with a
- * home object. Note that the home object is not freed.
+ * Frees all memory blocks associated with a home object. Note that the home
+ * object structure is not freed.
  *
  * @param home pointer to a home object
  *
@@ -876,14 +892,22 @@ su_home_t *su_home_create(void)
  */
 void su_home_destroy(su_home_t *home)
 {
-  su_home_deinit(home);
-  /* XXX - home itself is not destroyed */
+  if (MEMLOCK(home)) {
+    assert(home->suh_blocks);
+    assert(home->suh_blocks->sub_ref == 1);
+    if (!home->suh_blocks->sub_hauto)
+      /* should warn user */;
+    home->suh_blocks->sub_hauto = 1;
+    _su_home_deinit(home);
+    /* UNLOCK(home); */
+  }
 }
 
 /** Initialize an su_home_t struct.
  *
- * The function su_home_init() initializes an su_home_t structure. It can be
- * used when the home structure is allocated from stack.
+ * Initializes an su_home_t structure. It can be used when the home
+ * structure is allocated from stack or when the home structure is part of
+ * an another object.
  *
  * @param home pointer to home object
  *
@@ -894,10 +918,14 @@ void su_home_destroy(su_home_t *home)
  */
 int su_home_init(su_home_t *home)
 {
+  su_block_t *sub;
+    
   if (home == NULL)
     return -1;
 
-  home->suh_blocks = su_hash_alloc(SUB_N);
+  home->suh_blocks = sub = su_hash_alloc(SUB_N);
+  if (!sub)
+    return -1;
 
   return 0;
 }
@@ -949,6 +977,9 @@ void _su_home_deinit(su_home_t *home)
       free(b);
 
     home->suh_blocks = NULL;
+
+    if (home->suh_lock)
+      su_home_destroy_mutexes(home->suh_lock);
   }
 
   home->suh_lock = NULL;
@@ -956,9 +987,9 @@ void _su_home_deinit(su_home_t *home)
 
 /** Free memory blocks allocated through home.
  *
- * The function @c su_home_deinit() frees the memory blocks associated with
- * the home object allocated otherwise. It does not free the home object
- * itself. Use su_home_unref() to free the home object.
+ * Frees the memory blocks associated with the home object allocated. It
+ * does not free the home object itself. Use su_home_unref() to free the
+ * home object.
  *
  * @param home pointer to home object
  *
@@ -967,7 +998,9 @@ void _su_home_deinit(su_home_t *home)
 void su_home_deinit(su_home_t *home)
 {
   if (MEMLOCK(home)) {
-    assert(home->suh_blocks && home->suh_blocks->sub_ref == 0);
+    assert(home->suh_blocks);
+    assert(home->suh_blocks->sub_ref == 1);
+    assert(home->suh_blocks->sub_hauto);
     _su_home_deinit(home);
     /* UNLOCK(home); */
   }
@@ -975,11 +1008,11 @@ void su_home_deinit(su_home_t *home)
 
 /**Move allocations from a su_home_t object to another.
  *
- * The function su_home_move() moves allocations made through the @a src
- * home object under the @a dst home object. It is handy, for example, if an
- * operation allocates some number of blocks that should be freed upon an
- * error. It uses a temporary home and moves the blocks from temporary to a
- * proper home when successful, but frees the temporary home upon an error.
+ * Moves allocations made through the @a src home object under the @a dst
+ * home object. It is handy, for example, if an operation allocates some
+ * number of blocks that should be freed upon an error. It uses a temporary
+ * home and moves the blocks from temporary to a proper home when
+ * successful, but frees the temporary home upon an error.
  *
  * If @a src has destructor, it is called before starting to move.
  *
@@ -1111,8 +1144,8 @@ void su_home_preload(su_home_t *home, isize_t n, isize_t isize)
 
 /** Preload a memory home from stack.
  *
- * The function su_home_auto() initalizes a memory home using an area
- * allocated from stack. Poor mans alloca().
+ * Initializes a memory home using an area allocated from stack. Poor man's
+ * alloca().
  */
 su_home_t *su_home_auto(void *area, isize_t size)
 {
@@ -1142,10 +1175,12 @@ su_home_t *su_home_auto(void *area, isize_t size)
     size = prepsize + 65535;
 
   sub->sub_n = SUB_N_AUTO;
+  sub->sub_ref = 1;
   sub->sub_preload = p + prepsize;
   sub->sub_prsize = (unsigned)(size - prepsize);
-  sub->sub_preauto = 1;
+  sub->sub_hauto = 1;
   sub->sub_auto = 1;
+  sub->sub_preauto = 1;
   sub->sub_auto_all = 1;
 
   return home;
@@ -1154,7 +1189,7 @@ su_home_t *su_home_auto(void *area, isize_t size)
 
 /** Reallocate a memory block.
  *
- *   The function su_realloc() allocates a memory block of @a size bytes.
+ *   Allocates a memory block of @a size bytes.
  *   It copies the old block contents to the new block and frees the old
  *   block.
  *
@@ -1165,7 +1200,7 @@ su_home_t *su_home_auto(void *area, isize_t size)
  *   @param size  size of the memory block to be allocated
  *   
  * @return
- *   This function returns a pointer to the allocated memory block or
+ *   A pointer to the allocated memory block or
  *   NULL if an error occurred.
  */
 void *su_realloc(su_home_t *home, void *data, isize_t size)
@@ -1216,7 +1251,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
 #endif
       memset(sua, 0, sizeof *sua);
       sub->sub_used--;
-      su_block_add(sub, ndata)->sua_size = size;
+      su_block_add(sub, ndata)->sua_size = (unsigned)size;
     }
     UNLOCK(home);
 
@@ -1238,7 +1273,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
       }
 
       sub->sub_prused = (unsigned)p2;
-      sua->sua_size = size;
+      sua->sua_size = (unsigned)size;
 
 #if MEMCHECK_EXTRA
       memcpy((char *)data + size, &term, sizeof (term));
@@ -1247,7 +1282,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
       return data;
     }
   }
-  else if (size < sua->sua_size) {
+  else if (size < (size_t)sua->sua_size) {
     /* Reduce existing preload */
     if (sub->sub_stats) {
       su_home_stats_free(sub, data, data, sua->sua_size);
@@ -1256,7 +1291,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
 #if MEMCHECK_EXTRA
     memcpy((char *)data + size, &term, sizeof (term));
 #endif
-    sua->sua_size = size;
+    sua->sua_size = (unsigned)size;
     UNLOCK(home);
     return data;
   }
@@ -1271,7 +1306,10 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
        su_home_stats_free(sub, data, data, sua->sua_size);
     }
     
-    memcpy(ndata, data, sua->sua_size < size ? sua->sua_size : size);
+    memcpy(ndata, data,
+          (size_t)sua->sua_size < size
+          ? (size_t)sua->sua_size
+          : size);
 #if MEMCHECK_EXTRA
     memcpy((char *)ndata + size, &term, sizeof (term));
 #endif
@@ -1281,7 +1319,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
 
     memset(sua, 0, sizeof *sua); sub->sub_used--;
 
-    su_block_add(sub, ndata)->sua_size = size;
+    su_block_add(sub, ndata)->sua_size = (unsigned)size;
   }
 
   UNLOCK(home);
@@ -1327,7 +1365,7 @@ int su_in_home(su_home_t *home, void const *memory)
 
 /**Allocate and zero a memory block.
  *
- * The function su_zalloc() allocates a memory block with a given size from
+ * Allocates a memory block with a given size from
  * given memory home @a home and zeroes the allocated block.
  *
  *  @param home  pointer to memory pool object
@@ -1359,9 +1397,9 @@ void *su_zalloc(su_home_t *home, isize_t size)
 
 /** Allocate a structure
  *
- * The function su_salloc() allocates a structure with a given size, zeros
+ * Allocates a structure with a given size, zeros
  * it, and initializes the size field to the given size.  The size field
- * is the first in the structure. It has type of int. 
+ * is an int at the beginning of the structure. Note that it has type of int. 
  *
  * @param home  pointer to memory pool object
  * @param size  size of the structure
@@ -1540,7 +1578,8 @@ void su_home_stats_alloc(su_block_t *sub, void *p, void *preload,
 }
 
 static 
-void su_home_stats_free(su_block_t *sub, void *p, void *preload, size_t size)
+void su_home_stats_free(su_block_t *sub, void *p, void *preload,
+                       unsigned size)
 {
   su_home_stat_t *hs = sub->sub_stats;
 
index f9fb0ab5f6f67e50757c8ccd97dcaf9b35f93e22..d9f4a94724543fd6be839955fada47d8b4ec33c4 100644 (file)
@@ -39,6 +39,7 @@
 #if SU_HAVE_PTHREADS
 #include <pthread.h>
 #include <assert.h>
+#include <stdlib.h>
 
 extern void (*su_home_locker)(void *mutex);
 extern void (*su_home_unlocker)(void *mutex);
@@ -46,6 +47,8 @@ extern void (*su_home_unlocker)(void *mutex);
 extern void (*su_home_mutex_locker)(void *mutex);
 extern void (*su_home_mutex_unlocker)(void *mutex);
 
+extern void (*su_home_destroy_mutexes)(void *mutex);
+
 /** Mutex */
 static void mutex_locker(void *_mutex)
 {
@@ -58,6 +61,15 @@ static void mutex_unlocker(void *_mutex)
   pthread_mutex_t *mutex = _mutex;
   pthread_mutex_unlock(mutex + 1);
 }
+
+static void mutex_destroy(void *_mutex)
+{
+  pthread_mutex_t *mutex = _mutex;
+  pthread_mutex_destroy(mutex + 0);
+  pthread_mutex_destroy(mutex + 1);
+  free(_mutex);
+}
+
 #endif
 
 
@@ -65,7 +77,7 @@ static void mutex_unlocker(void *_mutex)
  *
  * Convert a memory home object as thread-safe by allocating mutexes and
  * modifying function pointers in su_alloc.c module.
-
+ *
  * @param home memory home object to be converted thread-safe.
  *
  * @retval 0 when successful,
@@ -94,9 +106,10 @@ int su_home_threadsafe(su_home_t *home)
     su_home_mutex_unlocker = mutex_unlocker;
     su_home_locker = (void (*)(void *))pthread_mutex_lock;
     su_home_unlocker = (void (*)(void *))pthread_mutex_unlock;
+    su_home_destroy_mutexes = mutex_destroy;
   }
 
-  mutex = su_alloc(home, 2 * sizeof (pthread_mutex_t));
+  mutex = calloc(1, 2 * (sizeof *mutex));
   assert(mutex);
   if (mutex) {
     /* Mutex for memory operations */
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_base_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_base_port.c
new file mode 100644 (file)
index 0000000..3e8668d
--- /dev/null
@@ -0,0 +1,577 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_base_port.c
+ *
+ * OS-Independent Socket Syncronization Interface.
+ *
+ * This looks like nth reincarnation of "reactor".  It implements the
+ * poll/select/WaitForMultipleObjects and message passing functionality.
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#define su_base_port_s su_port_s
+#define SU_CLONE_T su_msg_t 
+
+#include "sofia-sip/su.h"
+#include "su_port.h"
+#include "sofia-sip/su_alloc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#if 1
+#define PORT_REFCOUNT_DEBUG(x) ((void)0)
+#else
+#define PORT_REFCOUNT_DEBUG(x)  printf x
+#endif
+
+static int su_base_port_execute_msgs(su_msg_t *queue);
+
+/**@internal
+ *
+ * Initialize a message port.
+ *
+ * @retval 0 when successful
+ * @retval -1 upon an error
+ */
+int su_base_port_init(su_port_t *self, su_port_vtable_t const *vtable)
+{
+  if (self) {
+    self->sup_vtable = vtable;
+    self->sup_tail = &self->sup_head;
+
+    return 0;
+  }
+
+  return -1;
+}
+
+/** @internal Deinit a base implementation of port. */
+void su_base_port_deinit(su_port_t *self)
+{
+}
+
+void su_base_port_lock(su_port_t *self, char const *who)
+{
+}
+
+void su_base_port_unlock(su_port_t *self, char const *who)
+{
+}
+
+int su_base_port_own_thread(su_port_t const *self)
+{
+  return 1;
+}
+
+void su_base_port_incref(su_port_t *self, char const *who)
+{
+  su_home_ref(self->sup_home);
+  PORT_REFCOUNT_DEBUG(("incref(%p) to %u by %s\n", self, 
+                      su_home_refcount(self->sup_home), who));
+}
+
+int su_base_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  int zapped = su_home_unref(self->sup_home);
+
+  PORT_REFCOUNT_DEBUG(("%s(%p) to %u%s by %s\n", 
+                      blocking ? "zapref" : "decref",
+                      self, zapped ? 0 : su_home_refcount(self->sup_home),
+                      blocking && !zapped ? " FAILED" :"",
+                      who));
+
+  /* We should block until all references are destroyed */
+  if (blocking) 
+    /* ...but we just abort() */
+    assert(zapped);
+
+  return zapped;
+}
+
+struct _GSource *su_base_port_gsource(su_port_t *self)
+{
+  return NULL;
+}
+
+/** @internal Send a message to the port.
+ *
+ * @retval 1 if port thread needs to be woken
+ * @retval 0 if there are other messages in queue, too
+ * @retval -1 upon an error
+ */
+int su_base_port_send(su_port_t *self, su_msg_r rmsg)
+{
+  if (self) {
+    int wakeup;
+
+    su_port_lock(self, "su_port_send");
+    
+    wakeup = self->sup_head == NULL;
+
+    *self->sup_tail = rmsg[0]; rmsg[0] = NULL;
+    self->sup_tail = &(*self->sup_tail)->sum_next;
+
+    su_port_unlock(self, "su_port_send");
+
+    return wakeup;
+  }
+  else {
+    su_msg_destroy(rmsg);
+    return -1;
+  }
+}
+
+/** @internal
+ * Execute the messages in the incoming queue.
+ *
+ * @param self - pointer to a port object
+ *
+ * @retval Number of messages executed
+ */
+int su_base_port_getmsgs(su_port_t *self)
+{
+  if (self->sup_head) {
+    su_msg_t *queue;
+
+    su_port_lock(self, "su_base_port_getmsgs");
+
+    queue = self->sup_head;
+    self->sup_tail = &self->sup_head;
+    self->sup_head = NULL;
+
+    su_port_unlock(self, "su_base_port_getmsgs");
+
+    return su_base_port_execute_msgs(queue);
+  }
+
+  return 0;
+}
+
+
+int su_base_port_getmsgs_from(su_port_t *self, su_port_t *from)
+{
+  su_msg_t *msg, *selected;
+  su_msg_t **next = &self->sup_head, **tail= &selected;
+
+  if (!*next)
+    return 0;
+
+  su_port_lock(self, "su_base_port_getmsgs_from_port");
+
+  while (*next) {
+    msg = *next;
+
+    if (msg->sum_from->sut_port == from) {
+      *tail = msg, *next = msg->sum_next, tail = &msg->sum_next;
+    }
+    else
+      next = &msg->sum_next;      
+  }
+
+  *tail = NULL, self->sup_tail = next;
+
+  su_port_unlock(self, "su_base_port_getmsgs_from_port");
+
+  return su_base_port_execute_msgs(selected);
+}
+
+static
+int su_base_port_getmsgs_of_root(su_port_t *self, su_root_t *root)
+{
+  su_msg_t *msg, *selected;
+  su_msg_t **next = &self->sup_head, **tail= &selected;
+
+  if (!*next)
+    return 0;
+
+  su_port_lock(self, "su_base_port_getmsgs_of_root");
+
+  while (*next) {
+    msg = *next;
+
+    if (msg->sum_from->sut_root == root ||
+       msg->sum_to->sut_root == root) {
+      *tail = msg, *next = msg->sum_next, tail = &msg->sum_next;
+    }
+    else
+      next = &msg->sum_next;      
+  }
+
+  *tail = NULL, self->sup_tail = next;
+  
+  su_port_unlock(self, "su_base_port_getmsgs_of_root");
+
+  return su_base_port_execute_msgs(selected);
+}
+
+static int su_base_port_execute_msgs(su_msg_t *queue)
+{
+  su_msg_t *msg;
+  int n = 0;
+
+  for (msg = queue; msg; msg = queue) {
+    su_msg_f f = msg->sum_func;
+
+    queue = msg->sum_next, msg->sum_next = NULL;
+
+    if (f) 
+      f(SU_ROOT_MAGIC(msg->sum_to->sut_root), &msg, msg->sum_data);
+    su_msg_delivery_report(&msg);
+    n++;
+  }
+
+  return n;
+}
+
+/** @internal Enable multishot mode.
+ *
+ * The function su_port_multishot() enables, disables or queries the
+ * multishot mode for the port. The multishot mode determines how the events
+ * are scheduled by port. If multishot mode is enabled, port serves all the
+ * sockets that have received network events. If it is disabled, the
+ * socket events are server one at a time.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+int su_base_port_multishot(su_port_t *self, int multishot)
+{
+  return 0;
+}
+
+/** @internal Enable threadsafe operation. */
+int su_base_port_threadsafe(su_port_t *self)
+{
+  return su_home_threadsafe(self->sup_home);
+}
+
+/** @internal Main loop.
+ * 
+ * The function @c su_port_run() waits for wait objects and the timers
+ * associated with the port object.  When any wait object is signaled or
+ * timer is expired, it invokes the callbacks, and returns waiting.
+ * 
+ * The function @c su_port_run() runs until @c su_port_break() is called
+ * from a callback.
+ * 
+ * @param self     pointer to port object
+ * 
+ */
+void su_base_port_run(su_port_t *self)
+{
+  su_duration_t tout = 0;
+
+  assert(su_port_own_thread(self));
+
+  for (self->sup_running = 1; self->sup_running;) {
+    tout = 2000;
+
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+
+    if (self->sup_head)
+      self->sup_vtable->su_port_getmsgs(self);
+
+    if (self->sup_timers)
+      su_timer_expire(&self->sup_timers, &tout, su_now());
+
+    if (!self->sup_running)
+      break;
+
+    if (self->sup_head)      /* if there are messages do a quick wait */
+      tout = 0;
+
+    self->sup_vtable->su_port_wait_events(self, tout);
+  }
+}
+
+#if tuning
+/* This version can help tuning... */
+void su_base_port_run_tune(su_port_t *self)
+{
+  int i;
+  int timers = 0, messages = 0, events = 0;
+  su_duration_t tout = 0, tout0;
+  su_time_t started = su_now(), woken = started, bedtime = woken;
+
+  assert(su_port_own_thread(self));
+
+  for (self->sup_running = 1; self->sup_running;) {
+    tout = 2000;
+
+    timers = 0, messages = 0;
+
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+
+    if (self->sup_head)
+      messages = self->sup_vtable->su_port_getmsgs(self);
+
+    if (self->sup_timers)
+      timers = su_timer_expire(&self->sup_timers, &tout, su_now());
+
+    if (!self->sup_running)
+      break;
+
+    if (self->sup_head)      /* if there are messages do a quick wait */
+      tout = 0;
+
+    bedtime = su_now();
+
+    events = self->sup_vtable->su_port_wait_events(self, tout);
+
+    woken = su_now();
+
+    if (messages || timers || events)
+      SU_DEBUG_1(("su_port_run(%p): %.6f: %u messages %u timers %u "
+                 "events slept %.6f/%.3f\n",
+                 self, su_time_diff(woken, started), messages, timers, events,
+                 su_time_diff(woken, bedtime), tout * 1e-3));
+
+    if (!self->sup_running)
+      break;
+  }
+}
+#endif
+
+/** @internal
+ * The function @c su_port_break() is used to terminate execution of @c
+ * su_port_run(). It can be called from a callback function.
+ * 
+ * @param self     pointer to port
+ * 
+ */
+void su_base_port_break(su_port_t *self)
+{
+  self->sup_running = 0; 
+}
+
+/** @internal Block until wait object is signaled or timeout.
+ *
+ * This function waits for wait objects and the timers associated with 
+ * the root object.  When any wait object is signaled or timer is
+ * expired, it invokes the callbacks. 
+ * 
+ *   This function returns when a callback has been invoked or @c tout
+ *   milliseconds is elapsed. 
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ * 
+ * @return
+ *   Milliseconds to the next invocation of timer, or @c SU_WAIT_FOREVER if
+ *   there are no active timers.
+ */
+su_duration_t su_base_port_step(su_port_t *self, su_duration_t tout)
+{
+  su_time_t now = su_now();
+
+  assert(su_port_own_thread(self));
+
+  if (self->sup_prepoll)
+    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+
+  if (self->sup_head)
+    self->sup_vtable->su_port_getmsgs(self);
+
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, now);
+
+  /* if there are messages do a quick wait */
+  if (self->sup_head)
+    tout = 0;
+
+  if (self->sup_vtable->su_port_wait_events(self, tout))
+    tout = 0;
+  else
+    tout = SU_WAIT_FOREVER;
+
+  if (self->sup_head)
+    if (self->sup_vtable->su_port_getmsgs(self)) {
+      /* Check for wait events that may have been generated by messages */
+      if (self->sup_vtable->su_port_wait_events(self, 0))
+       tout = 0;
+    }
+
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, su_now());
+
+  if (self->sup_head)
+    tout = 0;
+
+  return tout;
+}
+
+/* =========================================================================
+ * Pre-poll() callback
+ */
+
+int su_base_port_add_prepoll(su_port_t *self,
+                            su_root_t *root, 
+                            su_prepoll_f *callback, 
+                            su_prepoll_magic_t *magic)
+{
+  if (self->sup_prepoll)
+    return -1;
+
+  self->sup_prepoll = callback;
+  self->sup_pp_magic = magic;
+  self->sup_pp_root = root;
+
+  return 0;
+}
+
+int su_base_port_remove_prepoll(su_port_t *self,
+                               su_root_t *root)
+{
+  if (self->sup_pp_root != root)
+    return -1;
+
+  self->sup_prepoll = NULL;
+  self->sup_pp_magic = NULL;
+  self->sup_pp_root = NULL;
+
+  return 0;
+}
+
+/* =========================================================================
+ * Timers
+ */
+
+su_timer_t **su_base_port_timers(su_port_t *self)
+{
+  return &self->sup_timers;
+}
+
+/* ====================================================================== */
+
+/** @internal 
+ * Used to check wait events in callbacks that take lots of time
+ *
+ * This function does a timeout 0 poll() and runs wait objects.
+ *
+ * @param port     pointer to port
+ *
+ * @return number of events handled
+ */
+int su_base_port_yield(su_port_t *self)
+{
+  return self->sup_vtable->su_port_wait_events(self, 0);
+}
+
+/* ====================================================================== 
+ * Clones 
+ */
+
+#define SU_TASK_COPY(d, s, by) (void)((d)[0]=(s)[0], \
+  (s)->sut_port?(void)su_port_incref(s->sut_port, #by):(void)0)
+
+static void su_base_port_clone_break(su_root_magic_t *m,
+                                    su_msg_r msg,
+                                    su_msg_arg_t *arg);
+
+int su_base_port_start_shared(su_root_t *parent,
+                             su_clone_r return_clone,
+                             su_root_magic_t *magic,
+                             su_root_init_f init,
+                             su_root_deinit_f deinit)
+{
+  su_port_t *self = parent->sur_task->sut_port;
+  su_root_t *child;
+
+  child = su_salloc(su_port_home(self), sizeof *child);
+  if (!child)
+    return -1;
+
+  child->sur_magic = magic;
+  child->sur_deinit = deinit;
+  child->sur_threading = parent->sur_threading;
+
+  SU_TASK_COPY(child->sur_parent, su_root_task(parent), 
+              su_base_port_clone_start);
+  SU_TASK_COPY(child->sur_task, child->sur_parent,
+              su_base_port_clone_start);
+
+  child->sur_task->sut_root = child;
+
+  if (su_msg_create(return_clone,
+                   child->sur_task, su_root_task(parent),
+                   su_base_port_clone_break,
+                   0) == 0 &&
+      init(child, magic) == 0)
+    return 0;
+
+  deinit(child, magic);
+  su_msg_destroy(return_clone);
+  su_root_destroy(child);
+  return -1;
+}
+
+static void su_base_port_clone_break(su_root_magic_t *m,
+                                    su_msg_r msg,
+                                    su_msg_arg_t *arg)
+{
+  _su_task_t const *task = su_msg_to(msg);
+
+  while (su_base_port_getmsgs_of_root(task->sut_port, task->sut_root))
+    ;
+
+  su_root_destroy(task->sut_root);
+}
+
+void su_base_port_wait(su_clone_r rclone)
+{
+  su_port_t *self;
+  su_root_t *root_to_wait;
+
+  self = su_msg_from(rclone)->sut_port;
+  assert(self == su_msg_to(rclone)->sut_port);
+  root_to_wait = su_msg_to(rclone)->sut_root;
+
+  assert(rclone[0]->sum_func == su_base_port_clone_break);
+
+  while (su_base_port_getmsgs_of_root(self, root_to_wait))
+    ;
+  su_root_destroy(root_to_wait);
+  su_msg_destroy(rclone);
+}
+
index 5be78a7199ea40a1f870e2627d817a438a1ba560..77dd61f90659211fb36eb6299e112e44d28a1bc6 100644 (file)
@@ -108,7 +108,7 @@ bm_memmem_study(char const *needle, size_t nlen)
 /** Search for a substring using Boyer-Moore algorithm.
  * @ingroup su_bm
  */
-char const*
+char *
 bm_memmem(char const *haystack, size_t hlen,
          char const *needle, size_t nlen,
          bm_fwd_table_t *fwd)
@@ -117,14 +117,14 @@ bm_memmem(char const *haystack, size_t hlen,
   bm_fwd_table_t fwd0[1];
 
   if (nlen == 0)
-    return haystack;
+    return (char *)haystack;
   if (needle == NULL || haystack == NULL || nlen > hlen)
     return NULL;
 
   if (nlen == 1) {
     for (i = 0; i < hlen; i++)
       if (haystack[i] == needle[0])
-       return haystack + i;
+       return (char *)haystack + i;
     return NULL;
   }
 
@@ -139,7 +139,7 @@ bm_memmem(char const *haystack, size_t hlen,
                  (int)(i - j), "", (int)j, needle, needle + j + 1, 
                  j == 0 ? "match!" : "back by 1"));
       if (j == 0)
-       return haystack + i;
+       return (char *)haystack + i;
       i--, j--;
     }
     else {
@@ -207,7 +207,7 @@ bm_memcasemem_study(char const *needle, size_t nlen)
 /** Search for substring using Boyer-Moore algorithm.
  * @ingroup su_bm
  */
-char const*
+char *
 bm_memcasemem(char const *haystack, size_t hlen,
              char const *needle, size_t nlen,
              bm_fwd_table_t *fwd)
@@ -216,14 +216,14 @@ bm_memcasemem(char const *haystack, size_t hlen,
   bm_fwd_table_t fwd0[1];
 
   if (nlen == 0)
-    return haystack;
+    return (char *)haystack;
   if (needle == 0 || haystack == 0 || nlen > hlen)
     return NULL;
 
   if (nlen == 1) {
     for (i = 0; i < hlen; i++)
       if (haystack[i] == needle[0])
-       return haystack + i;
+       return (char *)haystack + i;
     return NULL;
   }
 
@@ -245,7 +245,7 @@ bm_memcasemem(char const *haystack, size_t hlen,
                  (int)(i - j), "", (int)j, needle, needle + j + 1, 
                  j == 0 ? "match!" : "back by 1"));
       if (j == 0)
-       return haystack + i;
+       return (char *)haystack + i;
       i--, j--;
     }
     else {
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_devpoll_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_devpoll_port.c
new file mode 100644 (file)
index 0000000..712bfbd
--- /dev/null
@@ -0,0 +1,633 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2005, 2006, 2007 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_devpoll_port.c
+ *
+ * Port implementation using devpoll(7)
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Fri Jan 26 20:44:14 2007 ppessi
+ * @date Original: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#define su_port_s su_devpoll_port_s
+
+#include "su_port.h"
+
+#if HAVE_SYS_DEVPOLL_H
+
+#include "sofia-sip/su.h"
+#include "sofia-sip/su_alloc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#include <sys/devpoll.h>
+
+#define POLL2EPOLL_NEEDED \
+  (POLLIN != EPOLLIN || POLLOUT != EPOLLOUT || POLLPRI != EPOLLPRI || \
+   POLLERR != EPOLLERR || POLLHUP != EPOLLHUP)
+#define POLL2EPOLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
+#define EPOLL2POLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
+
+/** Port based on /dev/poll. */
+
+struct su_devpoll_port_s {
+  su_socket_port_t sup_base[1];
+
+  /** devpoll fd */
+  int              sup_devpoll;
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+                                     su_port_register() or 
+                                     su_port_unregister()
+                                  */
+  int              sup_n_registrations;
+  int              sup_max_index; /**< Indexes are equal or smaller than this */
+  int              sup_size_indices; /**< Size of allocated index table */
+
+  /** Structure containing registration data */
+  struct su_devpoll {
+    struct su_devpoll *ser_next; /* Next in free list */
+    su_wakeup_f     ser_cb; 
+    su_wakeup_arg_t*ser_arg; 
+    su_root_t      *ser_root; 
+    int             ser_id; /** registration identifier */
+    su_wait_t       ser_wait[1];
+  } **sup_indices;
+
+  /** Mapping from socket to struct su_devpoll */
+  struct su_devpoll **sup_devpoll_by_socket;
+  int sup_max_socket;
+  size_t sup_n_devpoll_by_socket;
+};
+
+static void su_devpoll_port_decref(su_port_t *self,
+                                  int blocking,
+                                  char const *who);
+static int su_devpoll_port_register(su_port_t *self,
+                                 su_root_t *root, 
+                                 su_wait_t *wait, 
+                                 su_wakeup_f callback,
+                                 su_wakeup_arg_t *arg,
+                                 int priority);
+static int su_devpoll_port_unregister(su_port_t *port,
+                                   su_root_t *root, 
+                                   su_wait_t *wait,    
+                                   su_wakeup_f callback, 
+                                   su_wakeup_arg_t *arg);
+static int su_devpoll_port_deregister(su_port_t *self, int i);
+static int su_devpoll_port_unregister_all(su_port_t *self, su_root_t *root);
+static int su_devpoll_port_eventmask(su_port_t *self, 
+                                  int index,
+                                  int socket,
+                                  int events);
+static int su_devpoll_port_multishot(su_port_t *self, int multishot);
+static int su_devpoll_port_wait_events(su_port_t *self, su_duration_t tout);
+static char const *su_devpoll_port_name(su_port_t const *self);
+
+su_port_vtable_t const su_devpoll_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_devpoll_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_devpoll_port_decref,
+      su_base_port_gsource,
+      su_socket_port_send,
+      su_devpoll_port_register,
+      su_devpoll_port_unregister,
+      su_devpoll_port_deregister,
+      su_devpoll_port_unregister_all,
+      su_devpoll_port_eventmask,
+      su_base_port_run,
+      su_base_port_break,
+      su_base_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_devpoll_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_devpoll_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_devpoll_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
+    }};
+
+static char const *su_devpoll_port_name(su_port_t const *self)
+{
+  return "devpoll";
+}
+
+static void su_devpoll_port_decref(su_port_t *self,
+                                  int blocking,
+                                  char const *who)
+{
+  (void)su_base_port_decref(self, blocking, who);
+}
+
+
+static void su_devpoll_port_deinit(void *arg)
+{
+  su_port_t *self = arg;
+
+  SU_DEBUG_9(("%s(%p) called\n", "su_devpoll_port_deinit", (void* )self));
+
+  su_socket_port_deinit(self->sup_base);
+
+  close(self->sup_devpoll), self->sup_devpoll = -1;
+}
+
+/** @internal
+ *
+ *  Register a #su_wait_t object. The wait object, a callback function and
+ *  an argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
+ *
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
+ * 
+ * @param self      pointer to port
+ * @param root      pointer to root object
+ * @param waits             pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg       argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
+ * 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_devpoll_port_register(su_port_t *self,
+                            su_root_t *root, 
+                            su_wait_t *wait, 
+                            su_wakeup_f callback,
+                            su_wakeup_arg_t *arg,
+                            int priority)
+{
+  int i, j, n;
+  struct su_devpoll *ser;
+  struct su_devpoll **indices = self->sup_indices;
+  struct su_devpoll **devpoll_by_socket = self->sup_devpoll_by_socket;
+  su_home_t *h = su_port_home(self);
+  struct pollfd pollfd[1];
+
+  assert(su_port_own_thread(self));
+
+  if (wait->fd < 0)
+    return su_seterrno(EINVAL);
+
+  n = self->sup_size_indices;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  ser = indices[0];
+
+  if (!ser) {
+    i = self->sup_max_index, j = i == 0 ? 15 : i + 16;
+    
+    if (j >= self->sup_size_indices) {
+      /* Reallocate index table */
+      n = n < 1024 ? 2 * n : n + 1024;
+      indices = su_realloc(h, indices, n * sizeof(indices[0]));
+      if (!indices)
+       return -1;
+      self->sup_indices = indices;
+      self->sup_size_indices = n;
+    }
+
+    /* Allocate registrations */
+    ser = su_zalloc(h, (j - i) * (sizeof *ser));
+    if (!ser)
+      return -1;
+
+    indices[0] = ser;
+
+    for (i++; i <= j; i++) {
+      ser->ser_id = i;
+      ser->ser_next = i < j ? ser + 1 : NULL;
+      indices[i] = ser++;
+    }
+
+    self->sup_max_index = j;
+
+    ser = indices[0];
+  }
+
+  if ((size_t)wait->fd >= self->sup_n_devpoll_by_socket) {
+    size_t n_devpoll_by_socket = ((size_t)wait->fd + 32) / 32 * 32;
+
+    devpoll_by_socket = su_realloc(h, devpoll_by_socket, 
+                                  n_devpoll_by_socket * 
+                                  (sizeof devpoll_by_socket[0]));
+    if (devpoll_by_socket == NULL)
+      return -1;
+    
+    memset(&devpoll_by_socket[self->sup_n_devpoll_by_socket],
+          0,
+          (char *)&devpoll_by_socket[n_devpoll_by_socket] - 
+          (char *)&devpoll_by_socket[self->sup_n_devpoll_by_socket]);
+    
+    self->sup_devpoll_by_socket = devpoll_by_socket;
+    self->sup_n_devpoll_by_socket = n_devpoll_by_socket;
+  }
+
+
+  if (devpoll_by_socket[wait->fd])
+    /* XXX - we should lift this limitation with epoll, too */
+    return errno = EEXIST, -1;  
+
+  i = ser->ser_id;
+
+  pollfd->fd = wait->fd;
+  pollfd->events = wait->events & ~POLLREMOVE;
+  pollfd->revents = 0;
+
+  if (write(self->sup_devpoll, pollfd, (sizeof pollfd)) != (sizeof pollfd)) {
+    return errno = EIO, -1;  
+  }
+
+  indices[0] = ser->ser_next;
+  devpoll_by_socket[wait->fd] = ser;
+
+  ser->ser_next = NULL;
+  *ser->ser_wait = *wait;
+  ser->ser_cb = callback;
+  ser->ser_arg = arg;
+  ser->ser_root = root;
+
+  self->sup_registers++;
+  self->sup_n_registrations++;
+
+  return i;                    /* return index */
+}
+
+/** Deregister a su_wait_t object. */
+static int su_devpoll_port_deregister0(su_port_t *self, int i, int destroy_wait)
+{
+  struct su_devpoll **indices = self->sup_indices;
+  struct su_devpoll *ser;
+  struct pollfd pollfd[1];
+
+  ser = self->sup_indices[i];
+  if (ser == NULL || ser->ser_cb == NULL) {
+    su_seterrno(ENOENT);
+    return -1;
+  }
+
+  assert(ser->ser_id == i);
+  assert(self->sup_devpoll_by_socket[ser->ser_wait->fd] == ser);
+
+  pollfd->fd = ser->ser_wait->fd;
+  pollfd->events = POLLREMOVE;
+  pollfd->revents = 0;
+
+  if (write(self->sup_devpoll, pollfd, sizeof pollfd) == -1) {
+    SU_DEBUG_1(("su_devpoll_port(%p): POLLREMOVE %d: %s\n", (void *)self,
+               ser->ser_wait->fd, su_strerror(su_errno())));
+  }
+
+  if (destroy_wait)
+    su_wait_destroy(ser->ser_wait);
+  
+  memset(ser, 0, sizeof *ser);
+  ser->ser_id = i;
+  ser->ser_next = indices[0], indices[0] = ser;
+  self->sup_devpoll_by_socket[pollfd->fd] = NULL;
+
+  self->sup_n_registrations--;
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ *  The function su_devpoll_port_unregister() unregisters a su_wait_t object. The
+ *  wait object, a callback function and a argument are removed from the
+ *  port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
+ *
+ * @deprecated Use su_devpoll_port_deregister() instead. 
+ *
+ * @return Nonzero index of the wait object, or -1 upon an error.
+ */
+int su_devpoll_port_unregister(su_port_t *self,
+                            su_root_t *root, 
+                            su_wait_t *wait,   
+                            su_wakeup_f callback, /* XXX - ignored */
+                            su_wakeup_arg_t *arg)
+{
+  int i, I;
+
+  struct su_devpoll *ser;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1; i <= I; i++) {
+    ser = self->sup_indices[i];
+
+    if (ser->ser_cb &&
+       arg == ser->ser_arg &&
+       SU_WAIT_CMP(wait[0], ser->ser_wait[0]) == 0)
+      return su_devpoll_port_deregister0(self, ser->ser_id, 0);
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
+}
+
+/** Deregister a su_wait_t object.
+ *  
+ *  Deregisters a registration by index. The wait object, a callback
+ *  function and a argument are removed from the port object. The wait
+ *  object is destroyed.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_devpoll_port_deregister(su_port_t *self, int i)
+{
+  struct su_devpoll *ser;
+
+  if (i <= 0 || i > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[i];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  return su_devpoll_port_deregister0(self, i, 1);
+}
+
+
+/** @internal
+ * Unregister all su_wait_t objects of given su_root_t instance.
+ *
+ * The function su_devpoll_port_unregister_all() unregisters all su_wait_t
+ * objects associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_devpoll_port_unregister_all(su_port_t *self, su_root_t *root)
+{
+  int i, I, n;
+
+  struct su_devpoll *ser;
+
+  assert(self); assert(root);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1, n = 0; i <= I; i++) {
+    ser = self->sup_indices[i];
+    if (ser->ser_root != root)
+      continue;
+    su_devpoll_port_deregister0(self, ser->ser_id, 0);
+    n++;
+  }
+
+  return n;
+}
+
+/**Set mask for a registered event. @internal
+ *
+ * The function su_devpoll_port_eventmask() sets the mask describing events
+ * that can signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.  */
+int su_devpoll_port_eventmask(su_port_t *self, int index, int socket, int events)
+{
+  struct su_devpoll *ser;
+  struct pollfd w[2];
+
+  if (index <= 0 || index > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[index];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  ser->ser_wait->events = events;
+
+  w[0].fd = socket;
+  w[0].events = POLLREMOVE;
+  w[0].revents = 0;
+  w[1].fd = socket;
+  w[1].events = events & ~POLLREMOVE;
+  w[1].revents = 0;
+
+  if (write(self->sup_devpoll, w, (sizeof w)) == -1) {
+    SU_DEBUG_1(("su_devpoll_port_eventmask(%p): %d: %s\n", (void *)self, 
+               socket, su_strerror(su_errno())));
+    return -1;
+  }
+
+  return 0;
+}
+
+/** @internal Enable multishot mode.
+ *
+ * Enables, disables or queries the multishot mode for the port. The
+ * multishot mode determines how the events are scheduled by port. If
+ * multishot mode is enabled, port serves all the sockets that have received
+ * network events. If it is disabled, only first socket event is served.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+static
+int su_devpoll_port_multishot(su_port_t *self, int multishot)
+{
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
+}
+
+
+/** @internal
+ * Wait (poll()) for wait objects in port.
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ *
+ * @return number of events handled
+ */
+static
+int su_devpoll_port_wait_events(su_port_t *self, su_duration_t tout)
+{
+  int j, n, events = 0;
+  unsigned version = self->sup_registers;
+
+  int const M = 4;
+  struct pollfd ev[M];
+  struct dvpoll dp[1];
+
+  dp->dp_fds = memset(ev, 0, sizeof ev);
+  dp->dp_nfds = self->sup_multishot ? M : 1;
+  dp->dp_timeout = tout >= INT_MAX ? INT_MAX : tout;
+
+  n = ioctl(self->sup_devpoll, DP_POLL, dp);
+
+  for (j = 0; j < n; j++) {
+    int socket;
+    struct su_devpoll *ser;
+    su_root_magic_t *magic;
+
+    socket = ev[j].fd;
+    if (socket < 0 || self->sup_n_devpoll_by_socket <= socket)
+      continue;
+    ser = self->sup_devpoll_by_socket[socket]; assert(ser);
+      
+    magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
+    ser->ser_wait->revents = ev[j].revents;
+    ser->ser_cb(magic, ser->ser_wait, ser->ser_arg);
+    events++;
+    if (version != self->sup_registers)
+      /* Callback function used su_register()/su_deregister() */
+      break;
+  }    
+
+  return events;
+}
+
+/** Create a port using /dev/poll or poll().
+ */
+su_port_t *su_devpoll_port_create(void)
+{
+  su_port_t *self;
+  int devpoll = open("/dev/poll", O_RDWR);
+
+  if (devpoll == -1) {
+    /* Fallback to poll() */
+    SU_DEBUG_3(("%s(): open(\"%s\") => %u: %s\n", 
+               "su_devpoll_port_create", "/dev/poll",
+               errno, strerror(errno)));
+    return su_poll_port_create();
+  }
+
+  self = su_home_new(sizeof *self);
+  if (!self) {
+    close(devpoll);
+    return self;
+  }
+
+  if (su_home_destructor(su_port_home(self), su_devpoll_port_deinit) < 0 ||
+      !(self->sup_indices = 
+       su_zalloc(su_port_home(self),
+                 (sizeof self->sup_indices[0]) * 
+                 (self->sup_size_indices = 64)))) {
+    su_home_unref(su_port_home(self));
+    close(devpoll);
+    return NULL;
+  }
+
+  self->sup_devpoll = devpoll;
+  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
+
+  if (su_socket_port_init(self->sup_base, su_devpoll_port_vtable) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  SU_DEBUG_9(("%s(%p): devpoll_create() => %u: %s\n",
+             "su_port_create", (void *)self, self->sup_devpoll, "OK"));
+
+  return self;
+}
+
+int su_devpoll_clone_start(su_root_t *parent,
+                        su_clone_r return_clone,
+                        su_root_magic_t *magic,
+                        su_root_init_f init,
+                        su_root_deinit_f deinit)
+{
+  return su_pthreaded_port_start(su_devpoll_port_create, 
+                                parent, return_clone, magic, init, deinit);
+}
+
+#else
+
+su_port_t *su_devpoll_port_create(void)
+{
+  return su_default_port_create();
+}
+
+int su_devpoll_clone_start(su_root_t *parent,
+                        su_clone_r return_clone,
+                        su_root_magic_t *magic,
+                        su_root_init_f init,
+                        su_root_deinit_f deinit)
+{
+  return su_default_clone_start(parent, return_clone, magic, init, deinit);
+}
+
+#endif  /* HAVE_EPOLL */
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_epoll_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_epoll_port.c
new file mode 100644 (file)
index 0000000..35d8477
--- /dev/null
@@ -0,0 +1,586 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2005, 2006, 2007 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_epoll_port.c
+ *
+ * Port implementation using epoll(7)
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Fri Jan 26 20:44:14 2007 ppessi
+ * @date Original: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#define su_port_s su_epoll_port_s
+
+#include "su_port.h"
+
+#if HAVE_EPOLL
+
+#include "sofia-sip/su.h"
+#include "sofia-sip/su_alloc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#include <sys/epoll.h>
+
+#define POLL2EPOLL_NEEDED \
+  (POLLIN != EPOLLIN || POLLOUT != EPOLLOUT || POLLPRI != EPOLLPRI || \
+   POLLERR != EPOLLERR || POLLHUP != EPOLLHUP)
+#define POLL2EPOLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
+#define EPOLL2POLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
+
+/** Port based on epoll(). */
+
+struct su_epoll_port_s {
+  su_socket_port_t sup_base[1];
+
+  /** epoll fd */
+  int              sup_epoll;
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+                                     su_port_register() or 
+                                     su_port_unregister()
+                                  */
+  int              sup_n_registrations;
+  int              sup_max_index; /**< Indexes are equal or smaller than this */
+  int              sup_size_indices; /**< Size of allocated index table */
+
+  /** Structure containing registration data */
+  struct su_epoll_register {
+    struct su_epoll_register *ser_next; /* Next in free list */
+    su_wakeup_f     ser_cb; 
+    su_wakeup_arg_t*ser_arg; 
+    su_root_t      *ser_root; 
+    int             ser_id; /** registration identifier */
+    su_wait_t       ser_wait[1];
+  } **sup_indices;
+};
+
+static void su_epoll_port_decref(su_port_t *self,
+                                int blocking,
+                                char const *who);
+static int su_epoll_port_register(su_port_t *self,
+                                 su_root_t *root, 
+                                 su_wait_t *wait, 
+                                 su_wakeup_f callback,
+                                 su_wakeup_arg_t *arg,
+                                 int priority);
+static int su_epoll_port_unregister(su_port_t *port,
+                                   su_root_t *root, 
+                                   su_wait_t *wait,    
+                                   su_wakeup_f callback, 
+                                   su_wakeup_arg_t *arg);
+static int su_epoll_port_deregister(su_port_t *self, int i);
+static int su_epoll_port_unregister_all(su_port_t *self, su_root_t *root);
+static int su_epoll_port_eventmask(su_port_t *self, 
+                                  int index,
+                                  int socket,
+                                  int events);
+static int su_epoll_port_multishot(su_port_t *self, int multishot);
+static int su_epoll_port_wait_events(su_port_t *self, su_duration_t tout);
+static char const *su_epoll_port_name(su_port_t const *self);
+
+su_port_vtable_t const su_epoll_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_epoll_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_epoll_port_decref,
+      su_base_port_gsource,
+      su_socket_port_send,
+      su_epoll_port_register,
+      su_epoll_port_unregister,
+      su_epoll_port_deregister,
+      su_epoll_port_unregister_all,
+      su_epoll_port_eventmask,
+      su_base_port_run,
+      su_base_port_break,
+      su_base_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_epoll_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_epoll_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_epoll_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
+    }};
+
+static char const *su_epoll_port_name(su_port_t const *self)
+{
+  return "epoll";
+}
+
+static void su_epoll_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  (void)su_base_port_decref(self, blocking, who);
+}
+
+static void su_epoll_port_deinit(void *arg)
+{
+  su_port_t *self = arg;
+
+  SU_DEBUG_9(("%s(%p) called\n", "su_epoll_port_deinit", (void* )self));
+
+  su_socket_port_deinit(self->sup_base);
+
+  close(self->sup_epoll), self->sup_epoll = -1;
+}
+
+/** @internal
+ *
+ *  Register a #su_wait_t object. The wait object, a callback function and
+ *  an argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
+ *
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
+ * 
+ * @param self      pointer to port
+ * @param root      pointer to root object
+ * @param waits             pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg       argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
+ * 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_epoll_port_register(su_port_t *self,
+                          su_root_t *root, 
+                          su_wait_t *wait, 
+                          su_wakeup_f callback,
+                          su_wakeup_arg_t *arg,
+                          int priority)
+{
+  int i, j, n;
+  struct epoll_event ev;
+  struct su_epoll_register *ser;
+  struct su_epoll_register **indices = self->sup_indices;
+
+  assert(su_port_own_thread(self));
+
+  n = self->sup_size_indices;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  ser = indices[0];
+
+  if (!ser) {
+    su_home_t *h = su_port_home(self);
+
+    i = self->sup_max_index, j = i == 0 ? 15 : i + 16;
+    
+    if (j >= self->sup_size_indices) {
+      /* Reallocate index table */
+      n = n < 1024 ? 2 * n : n + 1024;
+      indices = su_realloc(h, indices, n * sizeof(indices[0]));
+      if (!indices)
+       return -1;
+      self->sup_indices = indices;
+      self->sup_size_indices = n;
+    }
+
+    /* Allocate registrations */
+    ser = su_zalloc(h, (j - i) * (sizeof *ser));
+    if (!ser)
+      return -1;
+
+    indices[0] = ser;
+
+    for (i++; i <= j; i++) {
+      ser->ser_id = i;
+      ser->ser_next = i < j ? ser + 1 : NULL;
+      indices[i] = ser++;
+    }
+
+    self->sup_max_index = j;
+
+    ser = indices[0];
+  }
+
+  i = ser->ser_id;
+
+  ev.events = POLL2EPOLL(wait->events);
+  ev.data.u64 = 0;
+  ev.data.u32 = (uint32_t)i;
+  
+  if (epoll_ctl(self->sup_epoll, EPOLL_CTL_ADD, wait->fd, &ev) == -1) {
+    SU_DEBUG_0(("EPOLL_CTL_ADD(%u, %u) failed: %s\n",
+               wait->fd, ev.events, strerror(errno)));
+    return -1;
+  }
+
+  indices[0] = ser->ser_next;
+
+  ser->ser_next = NULL;
+  *ser->ser_wait = *wait;
+  ser->ser_cb = callback;
+  ser->ser_arg = arg;
+  ser->ser_root = root;
+
+  self->sup_registers++;
+  self->sup_n_registrations++;
+
+  return i;                    /* return index */
+}
+
+/** Deregister a su_wait_t object. */
+static int su_epoll_port_deregister0(su_port_t *self, int i, int destroy_wait)
+{
+  struct su_epoll_register **indices = self->sup_indices;
+  struct su_epoll_register *ser;
+
+  ser = self->sup_indices[i];
+  if (ser == NULL || ser->ser_cb == NULL) {
+    su_seterrno(ENOENT);
+    return -1;
+  }
+
+  assert(ser->ser_id == i);
+
+  if (epoll_ctl(self->sup_epoll, EPOLL_CTL_DEL, ser->ser_wait->fd, NULL) == -1) {
+    SU_DEBUG_1(("su_port(%p): EPOLL_CTL_DEL(%u): %s\n", (void *)self, 
+               ser->ser_wait->fd, su_strerror(su_errno())));
+  }
+
+  if (destroy_wait)
+    su_wait_destroy(ser->ser_wait);
+  
+  memset(ser, 0, sizeof *ser);
+  ser->ser_id = i;
+  ser->ser_next = indices[0], indices[0] = ser;
+
+  self->sup_n_registrations--;
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ *  The function su_epoll_port_unregister() unregisters a su_wait_t object. The
+ *  wait object, a callback function and a argument are removed from the
+ *  port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
+ *
+ * @deprecated Use su_epoll_port_deregister() instead. 
+ *
+ * @return Nonzero index of the wait object, or -1 upon an error.
+ */
+int su_epoll_port_unregister(su_port_t *self,
+                            su_root_t *root, 
+                            su_wait_t *wait,   
+                            su_wakeup_f callback, /* XXX - ignored */
+                            su_wakeup_arg_t *arg)
+{
+  int i, I;
+
+  struct su_epoll_register *ser;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1; i <= I; i++) {
+    ser = self->sup_indices[i];
+
+    if (ser->ser_cb &&
+       arg == ser->ser_arg &&
+       SU_WAIT_CMP(wait[0], ser->ser_wait[0]) == 0)
+      return su_epoll_port_deregister0(self, ser->ser_id, 0);
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
+}
+
+/** Deregister a su_wait_t object.
+ *  
+ *  Deregisters a registration by index. The wait object, a callback
+ *  function and a argument are removed from the port object. The wait
+ *  object is destroyed.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_epoll_port_deregister(su_port_t *self, int i)
+{
+  struct su_epoll_register *ser;
+
+  if (i <= 0 || i > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[i];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  return su_epoll_port_deregister0(self, i, 1);
+}
+
+
+/** @internal
+ * Unregister all su_wait_t objects of given su_root_t instance.
+ *
+ * The function su_epoll_port_unregister_all() unregisters all su_wait_t
+ * objects associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_epoll_port_unregister_all(su_port_t *self, su_root_t *root)
+{
+  int i, I, n;
+
+  struct su_epoll_register *ser;
+
+  assert(self); assert(root);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1, n = 0; i <= I; i++) {
+    ser = self->sup_indices[i];
+    if (ser->ser_root != root)
+      continue;
+    su_epoll_port_deregister0(self, ser->ser_id, 0);
+    n++;
+  }
+
+  return n;
+}
+
+/**Set mask for a registered event. @internal
+ *
+ * The function su_epoll_port_eventmask() sets the mask describing events that can
+ * signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.
+ */
+int su_epoll_port_eventmask(su_port_t *self, int index, int socket, int events)
+{
+  struct su_epoll_register *ser;
+  struct epoll_event ev;
+
+  if (index <= 0 || index > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[index];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  ser->ser_wait->events = events;
+
+  ev.events = POLL2EPOLL(events);
+  ev.data.u64 = (uint64_t)0;
+  ev.data.u32 = (uint32_t)index;
+
+  if (epoll_ctl(self->sup_epoll, EPOLL_CTL_MOD, socket, &ev) == -1) {
+    SU_DEBUG_1(("su_port(%p): EPOLL_CTL_MOD(%u): %s\n", (void *)self, 
+               socket, su_strerror(su_errno())));
+    return -1;
+  }
+
+  return 0;
+}
+
+/** @internal Enable multishot mode.
+ *
+ * Enables, disables or queries the multishot mode for the port. The
+ * multishot mode determines how the events are scheduled by port. If
+ * multishot mode is enabled, port serves all the sockets that have received
+ * network events. If it is disabled, only first socket event is served.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+static
+int su_epoll_port_multishot(su_port_t *self, int multishot)
+{
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
+}
+
+
+/** @internal
+ * Wait (poll()) for wait objects in port.
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ *
+ * @return number of events handled
+ */
+static
+int su_epoll_port_wait_events(su_port_t *self, su_duration_t tout)
+{
+  int j, n, events = 0, index;
+  unsigned version = self->sup_registers;
+
+  int const M = 4;
+  struct epoll_event ev[M];
+    
+  n = epoll_wait(self->sup_epoll, ev, self->sup_multishot ? M : 1, tout);
+
+  assert(n <= M);
+
+  for (j = 0; j < n; j++) {
+    struct su_epoll_register *ser;
+    su_root_magic_t *magic;
+
+    index = (int)ev[j].data.u32;
+    if (!ev[j].events || index <= 0 || self->sup_max_index < index)
+      continue;
+    ser = self->sup_indices[index];
+
+    magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
+    ser->ser_wait->revents = ev[j].events;
+    ser->ser_cb(magic, ser->ser_wait, ser->ser_arg);
+    events++;
+    if (version != self->sup_registers)
+      /* Callback function used su_register()/su_deregister() */
+      return events;
+  }    
+
+  return n;
+}
+
+/** Create a port using epoll() or poll().
+ */
+su_port_t *su_epoll_port_create(void)
+{
+  su_port_t *self;
+  int epoll = epoll_create(su_root_size_hint);
+
+  if (epoll == -1) {
+    /* Fallback to poll() */
+    SU_DEBUG_3(("%s(): epoll_create() => %u: %s\n", 
+               "su_port_create", epoll, strerror(errno)));
+    return su_poll_port_create();
+  }
+
+  self = su_home_new(sizeof *self);
+  if (!self) {
+    close(epoll);
+    return self;
+  }
+
+  SU_DEBUG_9(("%s(%p): epoll_create() => %u: %s\n",
+             "su_port_create", (void *)self, self->sup_epoll, "OK"));
+
+  if (su_home_destructor(su_port_home(self), su_epoll_port_deinit) < 0 ||
+      !(self->sup_indices = 
+       su_zalloc(su_port_home(self),
+                 (sizeof self->sup_indices[0]) * 
+                 (self->sup_size_indices = 64)))) {
+    su_home_unref(su_port_home(self));
+    close(epoll);
+    return NULL;
+  }
+
+  self->sup_epoll = epoll;
+  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
+
+  if (su_socket_port_init(self->sup_base, su_epoll_port_vtable) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  return self;
+}
+
+int su_epoll_clone_start(su_root_t *parent,
+                        su_clone_r return_clone,
+                        su_root_magic_t *magic,
+                        su_root_init_f init,
+                        su_root_deinit_f deinit)
+{
+  return su_pthreaded_port_start(su_epoll_port_create, 
+                                parent, return_clone, magic, init, deinit);
+}
+
+#else
+
+su_port_t *su_epoll_port_create(void)
+{
+  return su_default_port_create();
+}
+
+int su_epoll_clone_start(su_root_t *parent,
+                        su_clone_r return_clone,
+                        su_root_magic_t *magic,
+                        su_root_init_f init,
+                        su_root_deinit_f deinit)
+{
+  return su_default_clone_start(parent, return_clone, magic, init, deinit);
+}
+
+#endif  /* HAVE_EPOLL */
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c
new file mode 100644 (file)
index 0000000..3d72c2b
--- /dev/null
@@ -0,0 +1,639 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_kqueue_port.c
+ *
+ * Port implementation using kqueue()
+ *
+ * @author Martti Mela <Martti.Mela@nokia.com>
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ *
+ * @date Created: Sun Feb 18 19:55:37 EET 2007 mela
+ */
+
+#include "config.h"
+#include "sofia-sip/su.h"
+
+#define su_port_s su_kqueue_port_s
+
+#include "su_port.h"
+
+#if HAVE_KQUEUE
+
+#include "sofia-sip/su_alloc.h"
+
+#include <sys/event.h>
+
+#define SU_ENABLE_MULTISHOT_KQUEUE 1
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+/** Port based on kqueue(). */
+
+struct su_kqueue_port_s {
+  su_socket_port_t sup_base[1];
+
+#define sup_home sup_base->sup_base->sup_base->sup_home
+
+  /** kqueue fd */
+  int              sup_kqueue;
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+                                     su_port_register() or 
+                                     su_port_unregister()
+                                  */
+  int              sup_n_registrations;
+  int              sup_max_index; /**< Indexes are equal or smaller than this */
+  int              sup_size_indices; /**< Size of allocated index table */
+
+#define INDEX_MAX (0x7fffffff)
+
+  /** Structure containing registration data */
+  struct su_register {
+    struct su_register *ser_next; /* Next in free list */
+    su_wakeup_f     ser_cb; 
+    su_wakeup_arg_t*ser_arg; 
+    su_root_t      *ser_root; 
+    int             ser_id; /** registration identifier */
+    su_wait_t       ser_wait[1];
+  } **sup_indices;
+};
+
+static void su_kqueue_port_decref(su_port_t *, int blocking, char const *who);
+
+static int su_kqueue_port_register(su_port_t *self,
+                                su_root_t *root, 
+                                su_wait_t *wait, 
+                                su_wakeup_f callback,
+                                su_wakeup_arg_t *arg,
+                                int priority);
+static int su_kqueue_port_unregister(su_port_t *port,
+                                  su_root_t *root, 
+                                  su_wait_t *wait,     
+                                  su_wakeup_f callback, 
+                                  su_wakeup_arg_t *arg);
+static int su_kqueue_port_deregister(su_port_t *self, int i);
+static int su_kqueue_port_unregister_all(su_port_t *self, su_root_t *root);
+static int su_kqueue_port_eventmask(su_port_t *self, 
+                                 int index,
+                                 int socket,
+                                 int events);
+static int su_kqueue_port_multishot(su_port_t *self, int multishot);
+static int su_kqueue_port_wait_events(su_port_t *self, su_duration_t tout);
+static char const *su_kqueue_port_name(su_port_t const *self);
+
+su_port_vtable_t const su_kqueue_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_kqueue_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_kqueue_port_decref,
+      su_base_port_gsource,
+      su_socket_port_send,
+      su_kqueue_port_register,
+      su_kqueue_port_unregister,
+      su_kqueue_port_deregister,
+      su_kqueue_port_unregister_all,
+      su_kqueue_port_eventmask,
+      su_base_port_run,
+      su_base_port_break,
+      su_base_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_kqueue_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_kqueue_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_kqueue_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
+    }};
+
+static char const *su_kqueue_port_name(su_port_t const *self)
+{
+  return "kqueue";
+}
+
+static void su_kqueue_port_deinit(void *arg)
+{
+  su_port_t *self = arg;
+
+  SU_DEBUG_9(("%s(%p) called\n", "su_kqueue_port_deinit", (void *)self));
+
+  su_socket_port_deinit(self->sup_base);
+
+  close(self->sup_kqueue);
+}
+
+static void su_kqueue_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  su_base_port_decref(self, blocking, who);
+}
+
+/** @internal
+ *
+ *  Register a @c su_wait_t object. The wait object, a callback function and
+ *  an argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
+ *
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
+ * 
+ * @param self      pointer to port
+ * @param root      pointer to root object
+ * @param waits             pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg       argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
+ * 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_kqueue_port_register(su_port_t *self,
+                           su_root_t *root, 
+                           su_wait_t *wait, 
+                           su_wakeup_f callback,
+                           su_wakeup_arg_t *arg,
+                           int priority)
+{
+  int i, j, n;
+  struct su_register *ser;
+  struct su_register **indices = self->sup_indices;
+  struct kevent ev[1];
+  int flags;
+
+  assert(su_port_own_thread(self));
+
+  n = self->sup_size_indices;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  ser = indices[0];
+
+  if (!ser) {
+    su_home_t *h = su_port_home(self);
+
+    i = self->sup_max_index, j = i == 0 ? 15 : i + 16;
+    
+    if (j >= self->sup_size_indices) {
+      /* Reallocate index table */
+      n = n < 1024 ? 2 * n : n + 1024;
+      indices = su_realloc(h, indices, n * sizeof(indices[0]));
+      if (!indices)
+       return -1;
+      self->sup_indices = indices;
+      self->sup_size_indices = n;
+    }
+
+    /* Allocate registrations */
+    ser = su_zalloc(h, (j - i) * (sizeof *ser));
+    if (!ser)
+      return -1;
+
+    indices[0] = ser;
+
+    for (i++; i <= j; i++) {
+      ser->ser_id = i;
+      ser->ser_next = i < j ? ser + 1 : NULL;
+      indices[i] = ser++;
+    }
+
+    self->sup_max_index = j;
+
+    ser = indices[0];
+  }
+
+  i = ser->ser_id;
+
+  flags = (wait->events & SU_WAIT_IN) ? EV_ADD : EV_ADD | EV_DISABLE;
+  EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)i);
+  if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+    SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n",
+               wait->fd, "EVFILT_READ", flags, (void *)i, strerror(errno)));
+    return -1;
+  }
+
+  flags = (wait->events & SU_WAIT_OUT) ? EV_ADD : EV_ADD | EV_DISABLE;
+  EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)i);
+  if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+    int error = errno;
+    SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n",
+               wait->fd, "EVFILT_WRITE", flags, (void *)i, strerror(error)));
+
+    EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)i);
+    kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL);
+
+    errno = error;
+    return -1;
+  }
+  indices[0] = ser->ser_next;
+
+  ser->ser_next = NULL;
+  *ser->ser_wait = *wait;
+  ser->ser_cb = callback;
+  ser->ser_arg = arg;
+  ser->ser_root = root;
+
+  self->sup_registers++;
+  self->sup_n_registrations++;
+
+  return i;                    /* return index */
+}
+
+/** Deregister a su_wait_t object. */
+static int su_kqueue_port_deregister0(su_port_t *self, int i, int destroy_wait)
+{
+  struct su_register **indices = self->sup_indices;
+  struct su_register *ser;
+  struct kevent ev[1];
+  su_wait_t *wait;
+
+  ser = self->sup_indices[i];
+  if (ser == NULL || ser->ser_cb == NULL) {
+    su_seterrno(ENOENT);
+    return -1;
+  }
+
+  assert(ser->ser_id == i);
+
+  wait = ser->ser_wait;
+
+  EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)i);
+  if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+    SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n",
+               wait->fd, "EVFILT_READ", "EV_DELETE", (void *)i,
+               strerror(errno)));
+  }
+
+  EV_SET(ev, wait->fd, EVFILT_WRITE, EV_DELETE, 0, 0, (void *)i);
+  if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+    SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n",
+               wait->fd, "EVFILT_WRITE", "EV_DELETE", (void *)i,
+               strerror(errno)));
+  }
+
+  if (destroy_wait)
+    su_wait_destroy(wait);
+  
+  memset(ser, 0, sizeof *ser);
+  ser->ser_id = i;
+  ser->ser_next = indices[0], indices[0] = ser;
+
+  self->sup_n_registrations--;
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ *  The function su_kqueue_port_unregister() unregisters a su_wait_t object. The
+ *  wait object, a callback function and a argument are removed from the
+ *  port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
+ *
+ * @deprecated Use su_kqueue_port_deregister() instead. 
+ *
+ * @return Nonzero index of the wait object, or -1 upon an error.
+ */
+int su_kqueue_port_unregister(su_port_t *self,
+                             su_root_t *root, 
+                             su_wait_t *wait,  
+                             su_wakeup_f callback, /* XXX - ignored */
+                             su_wakeup_arg_t *arg)
+{
+  int i, I;
+
+  struct su_register *ser;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1; i <= I; i++) {
+    ser = self->sup_indices[i];
+
+    if (ser->ser_cb &&
+       arg == ser->ser_arg &&
+       SU_WAIT_CMP(wait[0], ser->ser_wait[0]) == 0)
+      return su_kqueue_port_deregister0(self, ser->ser_id, 0);
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
+}
+
+/** Deregister a su_wait_t object.
+ *  
+ *  Deregisters a registration by index. The wait object, a callback
+ *  function and a argument are removed from the port object. The wait
+ *  object is destroyed.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_kqueue_port_deregister(su_port_t *self, int i)
+{
+  struct su_register *ser;
+
+  if (i <= 0 || i > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[i];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  return su_kqueue_port_deregister0(self, i, 1);
+}
+
+/** @internal
+ * Unregister all su_wait_t objects belonging to a root.
+ *
+ * The function su_kqueue_port_unregister_all() unregisters all su_wait_t objects
+ * and destroys all queued timers associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_kqueue_port_unregister_all(su_port_t *self, 
+                               su_root_t *root)
+{
+  int i, I, n;
+
+  struct su_register *ser;
+
+  assert(self); assert(root);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1, n = 0; i <= I; i++) {
+    ser = self->sup_indices[i];
+    if (ser->ser_root != root)
+      continue;
+    su_kqueue_port_deregister0(self, ser->ser_id, 0);
+    n++;
+  }
+
+  return n;
+}
+
+/**Set mask for a registered event. @internal
+ *
+ * The function su_kqueue_port_eventmask() sets the mask describing events
+ * that can signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.
+ */
+int su_kqueue_port_eventmask(su_port_t *self, int index, int socket, int events)
+{
+  struct su_register *ser;
+  struct kevent ev[1];
+  su_wait_t *wait;
+  int flags;
+
+  if (index <= 0 || index > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[index];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  wait = ser->ser_wait;
+
+  assert(socket == wait->fd);
+
+  wait->events = events;
+
+  flags = (wait->events & SU_WAIT_IN) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE;
+  EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)index);
+  if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+    SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n",
+               wait->fd, "EVFILT_READ",
+               (events & SU_WAIT_IN) ? "EV_ENABLE" : "EV_DISABLE",
+               (void *)index, strerror(errno)));
+  }
+
+  flags = (wait->events & SU_WAIT_OUT) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE;
+  EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)index);
+  if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+    SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n",
+               wait->fd, "EVFILT_WRITE",
+               (events & SU_WAIT_OUT) ? "EV_ENABLE" : "EV_DISABLE",
+               (void *)index, strerror(errno)));
+  }
+
+  return 0;
+}
+
+/** @internal Enable multishot mode.
+ *
+ * Enables, disables or queries the multishot mode for the port. The
+ * multishot mode determines how the events are scheduled by port. If
+ * multishot mode is enabled, port serves all the sockets that have received
+ * network events. If it is disabled, only first socket event is served.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+static
+int su_kqueue_port_multishot(su_port_t *self, int multishot)
+{
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
+}
+
+
+/** @internal
+ * Wait (kqueue()) for wait objects in port.
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ *
+ * @return number of events handled
+ */
+static
+int su_kqueue_port_wait_events(su_port_t *self, su_duration_t tout)
+{
+  int j, n, events = 0, index;
+  unsigned version = self->sup_registers;
+
+  int const M = 4;
+  struct kevent ev[M];
+  
+  struct timespec ts;
+
+  ts.tv_sec = tout / 1000;
+  ts.tv_nsec = tout % 1000 * 1000000;
+
+  n = kevent(self->sup_kqueue, NULL, 0,
+            ev, self->sup_multishot ? M : 1,
+            tout < SU_DURATION_MAX ? &ts : NULL);
+
+  assert(n <= M);
+  
+  for (j = 0; j < n; j++) {
+    struct su_register *ser;
+    su_root_magic_t *magic;
+
+    index = (int)ev[j].udata;
+    if (index <= 0 || self->sup_max_index < index)
+      continue;
+    ser = self->sup_indices[index];
+
+    magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
+    ser->ser_wait->revents =
+      (ser->ser_wait->events | SU_WAIT_HUP) &
+      (
+       ((ev[j].filter == EVFILT_READ) ? SU_WAIT_IN : 0) |
+       ((ev[j].filter == EVFILT_WRITE) ? SU_WAIT_OUT : 0) |
+       ((ev[j].flags & EV_EOF) ? SU_WAIT_HUP : 0)
+       );
+    if (ser->ser_wait->revents) {
+      ser->ser_cb(magic, ser->ser_wait, ser->ser_arg);
+      events++;
+      if (version != self->sup_registers)
+       /* Callback function used su_register()/su_deregister() */
+       return events;
+    }
+  }    
+
+  return n;
+}
+
+
+/** Create a port using kqueue() (or poll()/select(), if kqueue() fails).
+ */
+su_port_t *su_kqueue_port_create(void)
+{
+  su_port_t *self = NULL;
+  int kq = kqueue();
+
+  if (kq < 0) {
+#if HAVE_POLL
+    return su_poll_port_create();
+#else
+    return su_select_port_create();
+#endif
+  }
+
+  self = su_home_new(sizeof *self);
+  if (!self)
+    goto failed;
+
+  if (su_home_destructor(su_port_home(self), su_kqueue_port_deinit) < 0)
+    goto failed;
+
+  self->sup_kqueue = kq, kq = -1;
+  self->sup_indices = su_zalloc(su_port_home(self),
+                               (sizeof self->sup_indices[0]) * 
+                               (self->sup_size_indices = 64));
+  if (!self->sup_indices)
+    goto failed;
+
+  if (su_socket_port_init(self->sup_base, su_kqueue_port_vtable) < 0)
+    goto failed;
+
+  self->sup_multishot = SU_ENABLE_MULTISHOT_KQUEUE;
+
+  return self;
+
+ failed:
+  if (kq != -1)
+    close(kq);
+  su_home_unref(su_port_home(self));
+  return NULL;
+}
+
+int su_kqueue_clone_start(su_root_t *parent,
+                       su_clone_r return_clone,
+                       su_root_magic_t *magic,
+                       su_root_init_f init,
+                       su_root_deinit_f deinit)
+{
+  return su_pthreaded_port_start(su_kqueue_port_create, 
+                                parent, return_clone, magic, init, deinit);
+}
+
+#else
+
+su_port_t *su_kqueue_port_create(void)
+{
+  return su_default_port_create();
+}
+
+int su_kqueue_clone_start(su_root_t *parent,
+                       su_clone_r return_clone,
+                       su_root_magic_t *magic,
+                       su_root_init_f init,
+                       su_root_deinit_f deinit)
+{
+  return su_default_clone_start(parent, return_clone, magic, init, deinit);
+}
+
+#endif  /* HAVE_KQUEUE */
index 7434598db468f3c521bd88abbb3456374e8ddcfb..b00b0c912e88cef652b3426c53ff4ddc3a1bd296 100644 (file)
@@ -1045,7 +1045,9 @@ int bsd_localinfo(su_localinfo_t const hints[1],
 {
   struct ifaddrs *ifa, *results;
   int error = 0;
+#if SU_HAVE_IN6
   int v4_mapped = (hints->li_flags & LI_V4MAPPED) != 0;
+#endif
   char *canonname = NULL;
 
   if (getifaddrs(&results) < 0) {
@@ -1057,7 +1059,10 @@ int bsd_localinfo(su_localinfo_t const hints[1],
 
   for (ifa = results; ifa; ifa = ifa->ifa_next) {
     su_localinfo_t *li;
-    su_sockaddr_t *su, su2[1];
+    su_sockaddr_t *su;
+#if SU_HAVE_IN6
+    su_sockaddr_t su2[1];
+#endif
     socklen_t sulen;
     int scope, flags = 0, gni_flags = 0, if_index = 0;
     char const *ifname = 0;
@@ -1075,15 +1080,19 @@ int bsd_localinfo(su_localinfo_t const hints[1],
     if (su->su_family == AF_INET) {
       sulen = sizeof(su->su_sin);
       scope = li_scope4(su->su_sin.sin_addr.s_addr);
+#if SU_HAVE_IN6
       if (v4_mapped)
        sulen = sizeof(su->su_sin6);
+#endif
     }
+#if SU_HAVE_IN6
     else if (su->su_family == AF_INET6) {
       if (IN6_IS_ADDR_MULTICAST(&su->su_sin6.sin6_addr))
        continue;
       sulen = sizeof(su->su_sin6);
       scope = li_scope6(&su->su_sin6.sin6_addr);
     }
+#endif
     else 
       continue;
 
@@ -1102,6 +1111,7 @@ int bsd_localinfo(su_localinfo_t const hints[1],
     if (scope == LI_SCOPE_HOST || scope == LI_SCOPE_LINK)
       gni_flags = NI_NUMERICHOST;
 
+#if SU_HAVE_IN6
     if (v4_mapped && su->su_family == AF_INET) {
       /* Map IPv4 address to IPv6 address */
       memset(su2, 0, sizeof(*su2));
@@ -1110,6 +1120,7 @@ int bsd_localinfo(su_localinfo_t const hints[1],
       ((int32_t*)&su2->su_sin6.sin6_addr)[3] = su->su_sin.sin_addr.s_addr;
       su = su2;
     }
+#endif
 
     if ((error = li_name(hints, gni_flags, su, &canonname)) < 0)
       break;
@@ -1188,7 +1199,7 @@ static
 int win_localinfo(su_localinfo_t const hints[1], su_localinfo_t **rresult)
 {
   /* This is Windows XP code, for both IPv6 and IPv4. */
-  size_t iaa_size = 2048;
+  ULONG iaa_size = 2048;
   IP_ADAPTER_ADDRESSES *iaa0, *iaa;
   int error, loopback_seen = 0;
   int v4_mapped = (hints->li_flags & LI_V4MAPPED) != 0;
@@ -1197,7 +1208,7 @@ int win_localinfo(su_localinfo_t const hints[1], su_localinfo_t **rresult)
   int flags = GAA_FLAG_SKIP_MULTICAST;
   *rresult = NULL; next = rresult;
 
-  iaa0 = malloc(iaa_size);
+  iaa0 = malloc((size_t)iaa_size);
   if (!iaa0) {
     SU_DEBUG_1(("su_localinfo: memory exhausted\n"));
     error = ELI_MEMORY;
@@ -1209,7 +1220,25 @@ int win_localinfo(su_localinfo_t const hints[1], su_localinfo_t **rresult)
       error = GetAdaptersAddresses(hints->li_family, flags, NULL, iaa0, &iaa_size);
   }
   if (error) {
-    SU_DEBUG_1(("su_localinfo: GetAdaptersAddresses failed: %d\n", error));
+    char const *empty = "";
+    LPTSTR msg = empty;
+
+    if (error == ERROR_NO_DATA) {
+      error = ELI_NOADDRESS;
+      goto err;
+    }
+
+    if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+                      FORMAT_MESSAGE_FROM_SYSTEM | 
+                      FORMAT_MESSAGE_IGNORE_INSERTS,
+                      NULL,
+                      error,
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      msg, 0, NULL))
+      msg = empty;
+    SU_DEBUG_1(("su_localinfo: GetAdaptersAddresses: %s (%d)\n", msg, error));
+    if (msg != empty) LocalFree((LPVOID)msg);
     error = ELI_SYSTEM;
     goto err;
   }
@@ -1218,7 +1247,7 @@ int win_localinfo(su_localinfo_t const hints[1], su_localinfo_t **rresult)
     IP_ADAPTER_UNICAST_ADDRESS *ua;
     IP_ADAPTER_UNICAST_ADDRESS lua[1];
     int if_index = iaa->IfIndex;
-    int ifnamelen = 0;
+    size_t ifnamelen = 0;
     char ifname[16];
 
     for (ua = iaa->FirstUnicastAddress; ;ua = ua->Next) {
index e48b7c5c8ec8750c66c254c24f93698f5986629a..8bb973f799e7cea0ad6e968c39ade3fd63344d9e 100644 (file)
 #include "sofia-sip/su_os_nw.h"
 #include "sofia-sip/su_debug.h"
 
-/* Works only with pthreads */
-#if SU_HAVE_PTHREADS
+#if defined(__APPLE_CC__)
+# define SU_NW_CHANGE_PTHREAD 1
+#endif
 
-#include <pthread.h>
+#if defined (SU_NW_CHANGE_PTHREAD)
+# define SU_HAVE_NW_CHANGE 1
+# include <pthread.h>
+#endif
 
 #if defined(__APPLE_CC__)
 #include <AvailabilityMacros.h>
@@ -68,8 +72,9 @@ struct su_network_changed_s {
   SCDynamicStoreRef           su_storeRef[1];
   CFRunLoopSourceRef          su_sourceRef[1];
 #endif
-
+#if defined (SU_NW_CHANGE_PTHREAD)
   pthread_t                   su_os_thread;
+#endif
 
   su_network_changed_f       *su_network_changed_cb;
   su_network_changed_magic_t *su_network_changed_magic;
@@ -109,7 +114,7 @@ void nw_changed_cb(SCDynamicStoreRef store,
                    sizeof *snc) == SU_FAILURE) {
 
     return;
-  }    
+  }
 
   snc2 = su_msg_data(rmsg); assert(snc2);
   snc2->su_root = snc->su_root;
@@ -119,7 +124,7 @@ void nw_changed_cb(SCDynamicStoreRef store,
   snc2->su_os_thread = snc->su_os_thread;
   snc2->su_network_changed_cb = snc->su_network_changed_cb;
   snc2->su_network_changed_magic = snc->su_network_changed_magic;
-  
+
   if (su_msg_send(rmsg) == SU_FAILURE) {
     su_msg_destroy(rmsg);
     return;
@@ -219,10 +224,7 @@ CreateIPAddressListChangeCallbackSCF(SCDynamicStoreCallBack callback,
 
     return err;
 }
-#endif /* __APPLE_CC__ */
-
 
-#if defined(__APPLE_CC__)
 static void *su_start_nw_os_thread(void *ptr)
 {
   su_network_changed_t *snc = (su_network_changed_t *) ptr;
@@ -249,19 +251,13 @@ su_network_changed_t
                             su_network_changed_f *network_changed_cb,
                             su_network_changed_magic_t *magic)
 {
-#if defined (__APPLE_CC__)
   su_network_changed_t *snc = NULL;
-#endif
 
   assert(home && root && network_changed_cb && magic);
 
-  /* Not implemented for others than OSX */
-#if !defined (__APPLE_CC__)
-  return NULL;
-#else
-
+#if defined (SU_HAVE_NW_CHANGE)
   snc = su_zalloc(home, sizeof *snc);
-  
+
   if (!snc)
     return NULL;
 
@@ -269,15 +265,16 @@ su_network_changed_t
   snc->su_root = root;
   snc->su_network_changed_cb = network_changed_cb;
   snc->su_network_changed_magic = magic;
-  
+
+# if defined (SU_NW_CHANGE_PTHREAD)
   if ((pthread_create(&(snc->su_os_thread), NULL,
                      su_start_nw_os_thread,
                      (void *) snc)) != 0) {
     return NULL;
   }
-
-  return snc;
+# endif
 #endif
+  return snc;
 }
 
 /** Remove a callback registered for the network change event.
@@ -288,20 +285,3 @@ int su_root_remove_network_changed(su_network_changed_t *snc)
 {
   return -1;
 }
-
-#else
-
-su_network_changed_t
-*su_root_add_network_changed(su_home_t *home, su_root_t *root,
-                            su_network_changed_f *network_changed_cb,
-                            su_network_changed_magic_t *magic)
-{
-  return NULL;
-}
-
-int su_root_remove_network_changed(su_network_changed_t *snc)
-{
-  return -1;
-}
-
-#endif /* SU_HAVE_PTHREADS */
index 9735c67b717d6b55c6a16fee50b0deb7599c0884..94c04c2d8d21d37df86d5c0a8026b9075565c88f 100644 (file)
  * poll/select/WaitForMultipleObjects and message passing functionality.
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
- * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ * @author Martti Mela <martti.mela@nokia.com>
  *
  * @date Created: Tue Sep 14 15:51:04 1999 ppessi
  */
 
 #include "config.h"
 
-/* React to multiple events per one poll() to make sure 
- * that high-priority events can never completely mask other events.
- * Enabled by default on all platforms except WIN32 */
-#ifndef WIN32
-#define SU_ENABLE_MULTISHOT_POLL 1
-#else
-#define SU_ENABLE_MULTISHOT_POLL 0
-#endif
-
 #include <stdlib.h>
 #include <assert.h>
 #include <stdarg.h>
@@ -55,9 +46,8 @@
 #include <limits.h>
 #include <errno.h>
 
-#define SU_PORT_IMPLEMENTATION 1
+#define su_port_s su_osx_port_s 
 
-#include "sofia-sip/su.h"
 #include "su_port.h"
 #include "sofia-sip/su_osx_runloop.h"
 #include "sofia-sip/su_alloc.h"
 #define enter (void)0
 #endif
 
-
-#if SU_HAVE_PTHREADS
-/* Pthread implementation */
-#include <pthread.h>
-#define SU_HAVE_MBOX 1
-#else
-#define SU_HAVE_MBOX 0
-#endif
-
-#if HAVE_SOCKETPAIR
-#define MBOX_SEND  1
-#else
-#define MBOX_SEND  0
-#endif
-
 static su_port_t *su_osx_runloop_create(void) __attribute__((__malloc__));
 
 /* Callback for CFObserver and CFSocket */
-static
-void cf_observer_cb(CFRunLoopObserverRef observer
-                   CFRunLoopActivity activity, 
-                   void *info);
-static void su_port_osx_socket_cb(CFSocketRef s, 
+static void cf_observer_cb(CFRunLoopObserverRef observer, 
+                          CFRunLoopActivity activity
+                          void *info);
+
+static void su_osx_port_socket_cb(CFSocketRef s, 
                                  CFSocketCallBackType callbackType, 
                                  CFDataRef address, 
                                  const void *data, 
                                  void *info);
-static CFSocketCallBackType map_poll_event_to_cf_event(int events);
 
-static void su_port_osx_lock(su_port_t *self, char const *who);
-static void su_port_osx_unlock(su_port_t *self, char const *who);
-static void su_port_osx_incref(su_port_t *self, char const *who);
-static void su_port_osx_decref(su_port_t *self, int blocking, char const *who);
+static void su_osx_port_deinit(void *arg);
 
-static int su_port_osx_send(su_port_t *self, su_msg_r rmsg);
+static void su_osx_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  (void)su_base_port_decref(self, blocking, who);
+}
+
+
+static CFSocketCallBackType map_poll_event_to_cf_event(int events);
 
-static int su_port_osx_register(su_port_t *self,
+static int su_osx_port_send(su_port_t *self, su_msg_r rmsg);
+
+static int su_osx_port_register(su_port_t *self,
                            su_root_t *root, 
                            su_wait_t *wait, 
                            su_wakeup_f callback,
                            su_wakeup_arg_t *arg,
                            int priority);
-static int su_port_osx_unregister(su_port_t *port,
+static int su_osx_port_unregister(su_port_t *port,
                              su_root_t *root, 
                              su_wait_t *wait,  
                              su_wakeup_f callback, 
                              su_wakeup_arg_t *arg);
 
-static int su_port_osx_deregister(su_port_t *self, int i);
-
-static int su_port_osx_unregister_all(su_port_t *self,
-                          su_root_t *root);
-
-static int su_port_osx_getmsgs(su_port_t *self);
-static
-int su_port_osx_eventmask(su_port_t *self, int index, int socket, int events);
-static
-void su_port_osx_run(su_port_t *self);
-static
-void su_port_osx_break(su_port_t *self);
-static
-su_duration_t su_port_osx_step(su_port_t *self, su_duration_t tout);
-
-#if 0
-unsigned su_port_query(su_port_t *, su_wait_t *, unsigned n_waits);
-void su_port_event(su_port_t *, su_wait_t *waitobj);
-#endif
-
-static
-int su_port_osx_own_thread(su_port_t const *port);
-
-static
-int su_port_osx_add_prepoll(su_port_t *port,
-                       su_root_t *root, 
-                       su_prepoll_f *, 
-                       su_prepoll_magic_t *);
+static int su_osx_port_deregister(su_port_t *self, int i);
 
-static
-int su_port_osx_remove_prepoll(su_port_t *port,
+static int su_osx_port_unregister_all(su_port_t *self,
                           su_root_t *root);
 
-static
-su_timer_t **su_port_osx_timers(su_port_t *port);
+static int su_osx_port_eventmask(su_port_t *, int , int, int );
+static void su_osx_port_run(su_port_t *self);
+static void su_osx_port_break(su_port_t *self);
+static su_duration_t su_osx_port_step(su_port_t *self, su_duration_t tout);
 
-static
-int su_port_osx_multishot(su_port_t *port, int multishot);
+static int su_osx_port_multishot(su_port_t *port, int multishot);
 
-static
-int su_port_osx_threadsafe(su_port_t *port);
+static int su_osx_port_wait_events(su_port_t *self, su_duration_t tout);
 
-static
-int su_port_osx_yield(su_port_t *port);
+static char const *su_osx_port_name(su_port_t const *self)
+{
+  return "CFRunLoop";
+}
 
-su_port_vtable_t const su_port_osx_vtable[1] =
+su_port_vtable_t const su_osx_port_vtable[1] =
   {{
-      /* su_vtable_size: */ sizeof su_port_osx_vtable,
-      su_port_osx_lock,
-      su_port_osx_unlock,
-      su_port_osx_incref,
-      su_port_osx_decref,
-      NULL /* su_port_osx_runloop */, /* XXX - was: gsource, */
-      su_port_osx_send,
-      su_port_osx_register,
-      su_port_osx_unregister,
-      su_port_osx_deregister,
-      su_port_osx_unregister_all,
-      su_port_osx_eventmask,
-      su_port_osx_run,
-      su_port_osx_break,
-      su_port_osx_step,
-      su_port_osx_own_thread,
-      su_port_osx_add_prepoll,
-      su_port_osx_remove_prepoll,
-      su_port_osx_timers,
-      su_port_osx_multishot,
-      su_port_osx_threadsafe,
-      su_port_osx_yield
+      /* su_vtable_size: */ sizeof su_osx_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_osx_port_decref,
+      su_base_port_gsource,
+      su_osx_port_send,
+      su_osx_port_register,
+      su_osx_port_unregister,
+      su_osx_port_deregister,
+      su_osx_port_unregister_all,
+      su_osx_port_eventmask,
+      su_osx_port_run,
+      su_osx_port_break,
+      su_osx_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_osx_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_osx_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_osx_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
     }};
 
-static int su_port_osx_wait_events(su_port_t *self, su_duration_t tout);
-
-
-/* *
+/*
  * Port is a per-thread reactor.  
  *
  * Multiple root objects executed by single thread share a su_port_t object. 
  */
-struct su_port_s {
-  su_home_t        sup_home[1];
+struct su_osx_port_s {
+  su_socket_port_t sup_socket[1];
 
-  su_port_vtable_t const *sup_vtable;
-  
-  unsigned         sup_running;
-  unsigned         sup_source_fired;
+#define sup_pthread sup_socket->sup_base
+#define sup_base sup_socket->sup_base->sup_base
+#define sup_home sup_socket->sup_base->sup_base->sup_home
 
-
-#if SU_HAVE_PTHREADS
-  pthread_t        sup_tid;
-  pthread_mutex_t  sup_mutex[1];
-#if __CYGWIN__
-  pthread_mutex_t  sup_reflock[1];
-  int              sup_ref;
-#else
-  pthread_rwlock_t sup_ref[1];
-#endif
-#else
-  int              sup_ref;
-#endif
-
-#if SU_HAVE_MBOX
-  su_socket_t      sup_mbox[MBOX_SEND + 1];
-  su_wait_t        sup_mbox_wait;
-#endif
+  unsigned         sup_source_fired;
 
   CFRunLoopRef        sup_main_loop;
   CFRunLoopSourceRef *sup_sources;
   CFSocketRef        *sup_sockets;
+
+  CFRunLoopObserverRef sup_observer;
+  CFRunLoopObserverContext sup_observer_cntx[1];
+  /* Struct for CFSocket callbacks; contains current CFSource index */
+  struct osx_magic {
+    su_port_t *o_port;
+    int        o_current;
+    int        o_count;
+  } osx_magic[1];
   
   unsigned         sup_multishot; /**< Multishot operation? */
 
@@ -257,147 +205,10 @@ struct su_port_s {
   su_root_t      **sup_wait_roots; 
 
   su_wait_t       *sup_waits; 
-
-  /* Pre-poll callback */
-  su_prepoll_f    *sup_prepoll; 
-  su_prepoll_magic_t *sup_pp_magic;
-  su_root_t       *sup_pp_root;
-
-  /* Timer list */
-  su_timer_t      *sup_timers;
-
-  /* Message list - this is protected by lock  */
-  su_msg_t        *sup_head;
-  su_msg_t       **sup_tail;
-
-#if 0
-  int              sup_free_index;   /**< Number of first free index */
-  int             *sup_indices; /** Indices to registrations */
-
-  int             *sup_reverses; /** Reverse index */
-  su_wakeup_f     *sup_wait_cbs; 
-  su_wakeup_arg_t**sup_wait_args; 
-  su_root_t      **sup_wait_roots; 
-
-  su_wait_t       *sup_waits; 
-
-  /* Pre-poll callback */
-  su_prepoll_f    *sup_prepoll; 
-  su_prepoll_magic_t *sup_pp_magic;
-  su_root_t       *sup_pp_root;
-
-  /* Timer list */
-  su_timer_t      *sup_timers;
-
-  /* Message list - this is protected by lock  */
-  su_msg_t        *sup_head;
-  su_msg_t       **sup_tail;
-#endif
 };
 
 
-/* Struct for CFSocket callbacks; contains current CFSource index */
-typedef struct {
-  su_port_t *o_port;
-  int        o_current;
-  int        o_count;
-} osx_magic_t;
-
-
-#if SU_HAVE_PTHREADS
-#define SU_PORT_OSX_OWN_THREAD(p)   (pthread_equal((p)->sup_tid, pthread_self()))
-
-#if __CYGWIN__
-
-/* Debugging versions */
-#define SU_PORT_OSX_INITREF(p)      (pthread_mutex_init((p)->sup_reflock, NULL), printf("initref(%p)\n", (p)))
-#define SU_PORT_OSX_INCREF(p, f)    (pthread_mutex_lock(p->sup_reflock), p->sup_ref++, pthread_mutex_unlock(p->sup_reflock), printf("incref(%p) by %s\n", (p), f))
-#define SU_PORT_OSX_DECREF(p, f)    do {                                       \
-    pthread_mutex_lock(p->sup_reflock);        p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
-    if ((p->sup_ref) == 0) {                   \
-      printf("decref(%p) to 0 by %s\n", (p), f); su_port_osx_destroy(p); }     \
-    else { printf("decref(%p) to %u by %s\n", (p), p->sup_ref, f); }  } while(0)
-
-#define SU_PORT_OSX_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
-    pthread_mutex_lock(p->sup_reflock);        p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
-  if ((p->sup_ref) != 0) { \
-    assert(!"SU_PORT_OSX_ZAPREF"); } \
-  su_port_osx_destroy(p); } while(0)
-
-#define SU_PORT_OSX_INITLOCK(p) \
-   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
-
-#define SU_PORT_OSX_LOCK(p, f)    \
-   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
-
-#define SU_PORT_OSX_UNLOCK(p, f)  \
-  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
-
-#elif 1
-#define SU_PORT_OSX_INITREF(p)      (pthread_rwlock_init(p->sup_ref, NULL))
-#define SU_PORT_OSX_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref))
-#define SU_PORT_OSX_DECREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
-  if (pthread_rwlock_trywrlock(p->sup_ref) == 0) su_port_osx_destroy(p); } while(0)
-
-#define SU_PORT_OSX_ZAPREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
-  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
-    assert(!"SU_PORT_OSX_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
-  su_port_osx_destroy(p); } while(0)
-
-#define SU_PORT_OSX_INITLOCK(p)     (pthread_mutex_init((p)->sup_mutex, NULL))
-#define SU_PORT_OSX_LOCK(p, f)      (pthread_mutex_lock((p)->sup_mutex))
-#define SU_PORT_OSX_UNLOCK(p, f)    (pthread_mutex_unlock((p)->sup_mutex))
-
-#else
-
-/* Debugging versions */
-#define SU_PORT_OSX_INITREF(p)      (pthread_rwlock_init((p)->sup_ref, NULL), printf("initref(%p)\n", (p)))
-#define SU_PORT_OSX_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref), printf("incref(%p) by %s\n", (p), f))
-#define SU_PORT_OSX_DECREF(p, f)    do {                                       \
-    pthread_rwlock_unlock(p->sup_ref);                                 \
-    if (pthread_rwlock_trywrlock(p->sup_ref) == 0) {                   \
-      printf("decref(%p) to 0 by %s\n", (p), f); su_port_osx_destroy(p); }     \
-    else { printf("decref(%p) by %s\n", (p), f); }  } while(0)
-
-#define SU_PORT_OSX_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
-  pthread_rwlock_unlock(p->sup_ref); \
-  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
-    assert(!"SU_PORT_OSX_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
-  su_port_osx_destroy(p); } while(0)
-
-#define SU_PORT_OSX_INITLOCK(p) \
-   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
-
-#define SU_PORT_OSX_LOCK(p, f)    \
-   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
-
-#define SU_PORT_OSX_UNLOCK(p, f)  \
-  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
-
-#endif
-
-#else /* !SU_HAVE_PTHREADS */
-
-#define SU_PORT_OSX_OWN_THREAD(p)  1
-#define SU_PORT_OSX_INITLOCK(p)    (void)(p)
-#define SU_PORT_OSX_LOCK(p, f)      (void)(p)
-#define SU_PORT_OSX_UNLOCK(p, f)    (void)(p)
-#define SU_PORT_OSX_ZAPREF(p, f)    ((p)->sup_ref--)
-
-#define SU_PORT_OSX_INITREF(p)      ((p)->sup_ref = 1)
-#define SU_PORT_OSX_INCREF(p, f)    ((p)->sup_ref++)
-#define SU_PORT_OSX_DECREF(p, f) \
-do { if (--((p)->sup_ref) == 0) su_port_osx_destroy(p); } while (0);
-
-#endif
-
-#if SU_HAVE_MBOX
-static int su_port_osx_wakeup(su_root_magic_t *magic, 
-                         su_wait_t *w,
-                         su_wakeup_arg_t *arg);
-#endif
-
-static void su_port_osx_destroy(su_port_t *self);
+/* XXX - mela static void su_osx_port_destroy(su_port_t *self); */
 
 /** Create a reactor object.
  *
@@ -414,7 +225,6 @@ su_root_t *su_root_osx_runloop_create(su_root_magic_t *magic)
   return su_root_create_with_port(magic, su_osx_runloop_create());
 }
 
-
 void osx_enabler_cb(CFSocketRef s, 
                    CFSocketCallBackType type, 
                    CFDataRef address, 
@@ -422,35 +232,32 @@ void osx_enabler_cb(CFSocketRef s,
                    void *info)
 {
   CFRunLoopRef  rl;
-  osx_magic_t  *magic = (osx_magic_t *) info;
+  struct osx_magic  *magic = (struct osx_magic *) info;
   su_port_t    *self = magic->o_port;
   su_duration_t tout = 0;
   su_time_t     now = su_now();
   
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_running) {
+  if (self->sup_base->sup_running) {
     
-    if (self->sup_prepoll)
-      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+    if (self->sup_base->sup_prepoll)
+      self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
     
-    if (self->sup_head)
-      su_port_osx_getmsgs(self);
+    if (self->sup_base->sup_head)
+      su_base_port_getmsgs(self);
     
-    if (self->sup_timers)
-      su_timer_expire(&self->sup_timers, &tout, now);
+    if (self->sup_base->sup_timers)
+      su_timer_expire(&self->sup_base->sup_timers, &tout, now);
   }
   
   CFRunLoopWakeUp(rl);
-  
 }
 
 
 /**@internal
  *
- * Allocates and initializes a message port. It creates a mailbox used to.
- * wake up the tasks waiting on the port if needed.  Currently, the
- * mailbox is simply an UDP socket connected to itself.
+ * Allocates and initializes a message port.
  *
  * @return
  *   If successful a pointer to the new message port is returned, otherwise
@@ -458,142 +265,60 @@ void osx_enabler_cb(CFSocketRef s,
  */
 su_port_t *su_osx_runloop_create(void)
 {
-  su_port_t *self;
-
-  SU_DEBUG_9(("su_osx_runloop_create() called\n"));
+  su_port_t *self = su_home_new(sizeof *self);
 
-  self = su_home_clone(NULL, sizeof(*self));
-
-  if (self) {
-#if SU_HAVE_MBOX
-    int af;
-    su_socket_t mb = INVALID_SOCKET;
-    char const *why;
-#endif
-    CFRunLoopObserverRef cf_observer; 
-    osx_magic_t *osx_magic = NULL;
-    CFRunLoopObserverContext cf_observer_cntx[1] = {{0, NULL, NULL,
-                                                    NULL, NULL}};
-
-    self->sup_vtable = su_port_osx_vtable;
-    
-    SU_PORT_OSX_INITREF(self);
-    SU_PORT_OSX_INITLOCK(self);
-    self->sup_tail = &self->sup_head;
-
-    self->sup_multishot = 0; /* XXX (SU_ENABLE_MULTISHOT_POLL) != 0; */
-
-#if SU_HAVE_PTHREADS
-    self->sup_tid = pthread_self();
-#endif
-  
-#if SU_HAVE_MBOX
-#if HAVE_SOCKETPAIR
-#if defined(AF_LOCAL)
-    af = AF_LOCAL;
-#else
-    af = AF_UNIX;
-#endif
-    if (socketpair(af, SOCK_STREAM, 0, self->sup_mbox) == -1) {
-      why = "su_port_osx_init: socketpair"; goto error;
-    }
-
-    mb = self->sup_mbox[0];
-    su_setblocking(self->sup_mbox[0], 0);
-    su_setblocking(self->sup_mbox[1], 0);
-#else
-    {
-      struct sockaddr_in sin = { sizeof(struct sockaddr_in), 0 };
-      socklen_t sinsize = sizeof sin;
-      struct sockaddr *sa = (struct sockaddr *)&sin;
-
-      af = PF_INET;
-
-      self->sup_mbox[0] = mb = su_socket(af, SOCK_DGRAM, IPPROTO_UDP);
-      if (mb == INVALID_SOCKET) {
-       why = "su_port_osx_init: socket"; goto error;
-      }
-  
-      sin.sin_family = AF_INET;
-      sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* 127.1 */
-      
-      /* Get a port for us */
-      if (bind(mb, sa, sizeof sin) == -1) {
-       why = "su_port_osx_init: bind"; goto error;
-      }
+  if (!self)
+    return self;
 
-      if (getsockname(mb, sa, &sinsize) == -1) {
-       why = "su_port_osx_init: getsockname"; goto error;
-      }
-    
-      if (connect(mb, sa, sinsize) == -1) {
-       why = "su_port_osx_init: connect"; goto error;
-      }
-    }
-#endif    
+  enter;
 
-    if (su_wait_create(&self->sup_mbox_wait, mb, SU_WAIT_IN) == -1) {
-      why = "su_port_osx_init: su_wait_create"; goto error;
-    }
+  if (su_home_destructor(su_port_home(self), su_osx_port_deinit) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
 
-    if (su_port_osx_register(self, NULL, &self->sup_mbox_wait,
-                            su_port_osx_wakeup, 
-                            (su_wakeup_arg_t *)self->sup_mbox, 0)
-       == -1) {
-      why = "su_port_osx_create: su_port_osx_register"; goto error;
-    }
+  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
 
-    osx_magic = calloc(1, sizeof(*osx_magic));
-    osx_magic->o_port = self;
-    cf_observer_cntx->info = osx_magic;
-    
-    cf_observer =
-      CFRunLoopObserverCreate(NULL, kCFRunLoopAfterWaiting | kCFRunLoopBeforeWaiting,
-                             TRUE, 0, cf_observer_cb, cf_observer_cntx);
-    
+  if (su_socket_port_init(self->sup_base, su_osx_port_vtable) == 0) {
+    self->osx_magic->o_port = self;
+    self->sup_observer_cntx->info = self->osx_magic;
+    self->sup_observer =
+      CFRunLoopObserverCreate(NULL, 
+                             kCFRunLoopAfterWaiting | kCFRunLoopBeforeWaiting,
+                             TRUE, 0, cf_observer_cb, self->sup_observer_cntx);
+#if 0
     CFRunLoopAddObserver(CFRunLoopGetCurrent(),
-                        cf_observer,
+                        self->sup_observer,
                         kCFRunLoopDefaultMode);
-    
-    SU_DEBUG_9(("su_port_osx_create() returns %p\n", self));
-    
-    return self;
-    
-  error:
-    su_perror(why);
-    su_port_osx_destroy(self), self = NULL;
 #endif
   }
-  
-  SU_DEBUG_9(("su_port_osx_create() returns %p\n", self));
-  
+  else
+    return su_home_unref(su_port_home(self)), NULL;
+
   return self;
 }
 
-
 static
 void cf_observer_cb(CFRunLoopObserverRef observer, 
                    CFRunLoopActivity activity, 
                    void *info)
 {
   CFRunLoopRef  rl;
-  osx_magic_t  *magic = (osx_magic_t *) info;
+  struct osx_magic  *magic = (struct osx_magic *) info;
   su_port_t    *self = magic->o_port;
   su_duration_t tout = 0;
   su_time_t     now = su_now();
 
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_running) {
+  if (self->sup_base->sup_running) {
 
-    if (self->sup_prepoll)
-      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+    if (self->sup_base->sup_prepoll)
+      self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
     
-    if (self->sup_head)
-      su_port_osx_getmsgs(self);
+    if (self->sup_base->sup_head)
+      su_port_getmsgs(self);
     
-    if (self->sup_timers)
-      su_timer_expire(&self->sup_timers, &tout, now);
+    if (self->sup_base->sup_timers)
+      su_timer_expire(&self->sup_base->sup_timers, &tout, now);
   } else
     SU_DEBUG_9(("cf_observer_cb(): PORT IS NOT RUNNING!\n"));
 
@@ -603,70 +328,13 @@ void cf_observer_cb(CFRunLoopObserverRef observer,
 }
 
 /** @internal Destroy a port. */
-void su_port_osx_destroy(su_port_t *self)
-{
-  assert(self);
-
-  SU_DEBUG_9(("su_port_osx_destroy() called\n"));
-
-#if SU_HAVE_MBOX
-  if (self->sup_mbox[0] != INVALID_SOCKET) {
-    su_port_osx_unregister(self, NULL, &self->sup_mbox_wait, NULL, 
-                      (su_wakeup_arg_t *)self->sup_mbox);
-    su_wait_destroy(&self->sup_mbox_wait);
-    su_close(self->sup_mbox[0]); self->sup_mbox[0] = INVALID_SOCKET;
-#if HAVE_SOCKETPAIR
-    su_close(self->sup_mbox[1]); self->sup_mbox[1] = INVALID_SOCKET;
-#endif
-    SU_DEBUG_9(("su_port_osx_destroy() close mailbox\n"));
-  }
-#endif
-  if (self->sup_sources) 
-    free(self->sup_sources), self->sup_sources = NULL;
-  if (self->sup_sockets) 
-    free(self->sup_sockets), self->sup_sockets = NULL;
-  if (self->sup_waits) 
-    free(self->sup_waits), self->sup_waits = NULL;
-  if (self->sup_wait_cbs)
-    free(self->sup_wait_cbs), self->sup_wait_cbs = NULL;
-  if (self->sup_wait_args)
-    free(self->sup_wait_args), self->sup_wait_args = NULL;
-  if (self->sup_wait_roots)
-    free(self->sup_wait_roots), self->sup_wait_roots = NULL;
-  if (self->sup_reverses)
-    free(self->sup_reverses), self->sup_reverses = NULL;
-  if (self->sup_indices)
-    free(self->sup_indices), self->sup_indices = NULL;
-
-  SU_DEBUG_9(("su_port_osx_destroy() freed registrations\n"));
-
-  su_home_zap(self->sup_home);
-
-  SU_DEBUG_9(("su_port_osx_destroy() returns\n"));
-
-}
-
-static void su_port_osx_lock(su_port_t *self, char const *who)
-{
-  SU_PORT_OSX_LOCK(self, who);
-}
-
-static void su_port_osx_unlock(su_port_t *self, char const *who)
+static void su_osx_port_deinit(void *arg)
 {
-  SU_PORT_OSX_UNLOCK(self, who);
-}
+  su_port_t *self = arg;
 
-static void su_port_osx_incref(su_port_t *self, char const *who)
-{
-  SU_PORT_OSX_INCREF(self, who);
-}
+  SU_DEBUG_9(("%s(%p) called\n", "su_osx_port_deinit", (void *)self));
 
-static void su_port_osx_decref(su_port_t *self, int blocking, char const *who)
-{
-  if (blocking)
-    SU_PORT_OSX_ZAPREF(self, who);
-  else
-    SU_PORT_OSX_DECREF(self, who);
+  su_socket_port_deinit(self->sup_base);
 }
 
 static
@@ -692,6 +360,7 @@ CFSocketCallBackType map_poll_event_to_cf_event(int events)
 }
 
 
+#if 0
 static
 int map_cf_event_to_poll_event(CFSocketCallBackType type)
 {
@@ -711,18 +380,18 @@ int map_cf_event_to_poll_event(CFSocketCallBackType type)
 
   return event;
 }
-
+#endif
 
 static
-void su_port_osx_socket_cb(CFSocketRef s, 
+void su_osx_port_socket_cb(CFSocketRef s, 
                           CFSocketCallBackType type, 
                           CFDataRef address, 
                           const void *data, 
                           void *info)
 {
-  osx_magic_t       *magic = (osx_magic_t *) info;
-  su_port_t         *self = magic->o_port;
-  int                curr = magic->o_current;
+  struct osx_magic *magic = (struct osx_magic *) info;
+  su_port_t        *self = magic->o_port;
+  int               curr = magic->o_current;
   su_duration_t tout = 0;
   
 #if SU_HAVE_POLL
@@ -742,13 +411,13 @@ void su_port_osx_socket_cb(CFSocketRef s,
                          &waits[n], 
                          self->sup_wait_args[n]);
     
-    if (self->sup_running) {
-      su_port_osx_getmsgs(self);
+    if (self->sup_base->sup_running) {
+      su_port_getmsgs(self);
       
-      if (self->sup_timers)
-       su_timer_expire(&self->sup_timers, &tout, su_now());
+      if (self->sup_base->sup_timers)
+       su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
 
-      if (self->sup_head)
+      if (self->sup_base->sup_head)
        tout = 0;
 
       /* CFRunLoopWakeUp(CFRunLoopGetCurrent()); */
@@ -761,37 +430,20 @@ void su_port_osx_socket_cb(CFSocketRef s,
   
 }
 
-#if SU_HAVE_MBOX
-/** @internal Message box wakeup function. */
-static int su_port_osx_wakeup(su_root_magic_t *magic, /* NULL */
-                             su_wait_t *w,
-                             su_wakeup_arg_t *arg)
-{
-  char buf[32];
-  su_socket_t s = *(su_socket_t *)arg;
-  su_wait_events(w, s);
-  recv(s, buf, sizeof(buf), 0);
-
-  /* CFRunLoopWakeUp(CFRunLoopGetCurrent()); */
-
-  return 0;
-}
-#endif
-
 /** @internal Send a message to the port. */
-int su_port_osx_send(su_port_t *self, su_msg_r rmsg)
+int su_osx_port_send(su_port_t *self, su_msg_r rmsg)
 {
   CFRunLoopRef rl;
 
   if (self) {
     int wakeup;
 
-    SU_PORT_OSX_LOCK(self, "su_port_osx_send");
+    //XXX - mela SU_OSX_PORT_LOCK(self, "su_osx_port_send");
     
-    wakeup = self->sup_head == NULL;
+    wakeup = self->sup_base->sup_head == NULL;
 
-    *self->sup_tail = rmsg[0]; rmsg[0] = NULL;
-    self->sup_tail = &(*self->sup_tail)->sum_next;
+    *self->sup_base->sup_tail = rmsg[0]; rmsg[0] = NULL;
+    self->sup_base->sup_tail = &(*self->sup_base->sup_tail)->sum_next;
 
 #if SU_HAVE_MBOX
     /* if (!pthread_equal(pthread_self(), self->sup_tid)) */
@@ -808,7 +460,7 @@ int su_port_osx_send(su_port_t *self, su_msg_r rmsg)
     }
 #endif
 
-    SU_PORT_OSX_UNLOCK(self, "su_port_osx_send");
+    //XXX - mela SU_OSX_PORT_UNLOCK(self, "su_osx_port_send");
 
     rl = CFRunLoopGetCurrent();
     CFRunLoopWakeUp(rl);
@@ -820,48 +472,6 @@ int su_port_osx_send(su_port_t *self, su_msg_r rmsg)
     return -1;
   }
 }
-
-/** @internal
- * Execute the messages in the incoming queue until the queue is empty..
- *
- * @param self - pointer to a port object
- *
- * @retval Number of messages sent
- */
-int su_port_osx_getmsgs(su_port_t *self)
-{
-  int n = 0;
-
-  if (self->sup_head) {
-    su_msg_f f;
-    su_msg_t *msg, *queue;
-
-    SU_PORT_OSX_LOCK(self, "su_port_getmsgs");
-
-    queue = self->sup_head;
-    self->sup_tail = &self->sup_head;
-    self->sup_head = NULL;
-
-    SU_PORT_OSX_UNLOCK(self, "su_port_osx_getmsgs");
-
-    for (msg = queue; msg; msg = queue) {
-      queue = msg->sum_next;
-      msg->sum_next = NULL;
-
-      f = msg->sum_func;
-      if (f) 
-       f(SU_ROOT_MAGIC(msg->sum_to->sut_root), &msg, msg->sum_data);
-      su_msg_delivery_report(&msg);
-      n++;
-    }
-
-    /* Check for wait events that may have been generated by messages */
-    su_port_osx_wait_events(self, 0);
-  }
-
-  return n;
-}
-
 static int o_count;
 
 /** @internal
@@ -882,9 +492,9 @@ static int o_count;
  *              (0 is normal, 1 important, 2 realtime)
  * 
  * @return
- *   The function @su_port_osx_register returns nonzero index of the wait object, 
+ *   The function @su_osx_port_register returns nonzero index of the wait object, 
  *   or -1 upon an error.  */
-int su_port_osx_register(su_port_t *self,
+int su_osx_port_register(su_port_t *self,
                         su_root_t *root, 
                         su_wait_t *wait, 
                         su_wakeup_f callback,
@@ -896,11 +506,11 @@ int su_port_osx_register(su_port_t *self,
   CFRunLoopSourceRef *sources, source;
   CFSocketRef cf_socket, *sockets;
   int events = 0;
-  osx_magic_t *osx_magic = NULL;
+  struct osx_magic *osx_magic = NULL;
   CFSocketContext cf_socket_cntx[1] = {{0, NULL, NULL, NULL, NULL}};
   CFOptionFlags flags = 0;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   n = self->sup_n_waits;
 
@@ -1024,7 +634,7 @@ int su_port_osx_register(su_port_t *self,
 
   cf_socket = CFSocketCreateWithNative(NULL,
                                       (CFSocketNativeHandle) su_wait_socket(wait),
-                                      events, su_port_osx_socket_cb, cf_socket_cntx);
+                                      events, su_osx_port_socket_cb, cf_socket_cntx);
 
   flags = CFSocketGetSocketFlags(cf_socket);
   flags &= ~kCFSocketCloseOnInvalidate;
@@ -1053,7 +663,7 @@ int su_port_osx_register(su_port_t *self,
 
 /** Deregister a su_wait_t object. */
 static
-int su_port_osx_deregister0(su_port_t *self, int i)
+int su_osx_port_deregister0(su_port_t *self, int i)
 {
   CFRunLoopRef rl;
   int n, N, *indices, *reverses;
@@ -1127,7 +737,7 @@ int su_port_osx_deregister0(su_port_t *self, int i)
 
 /** Unregister a su_wait_t object.
  *  
- *  The function su_port_osx_unregister() unregisters a su_wait_t object. The
+ *  The function su_osx_port_unregister() unregisters a su_wait_t object. The
  *  wait object, a callback function and a argument are removed from the
  *  port object.
  * 
@@ -1140,7 +750,7 @@ int su_port_osx_deregister0(su_port_t *self, int i)
  * 
  * @return Nonzero index of the wait object, or -1 upon an error.
  */
-int su_port_osx_unregister(su_port_t *self,
+int su_osx_port_unregister(su_port_t *self,
                       su_root_t *root, 
                       su_wait_t *wait, 
                       su_wakeup_f callback, /* XXX - ignored */
@@ -1149,13 +759,13 @@ int su_port_osx_unregister(su_port_t *self,
   int n, N;
 
   assert(self);
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   N = self->sup_n_waits;
 
   for (n = 0; n < N; n++) {
     if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
-      return su_port_osx_deregister0(self, self->sup_reverses[n]);
+      return su_osx_port_deregister0(self, self->sup_reverses[n]);
     }
   }
 
@@ -1166,7 +776,7 @@ int su_port_osx_unregister(su_port_t *self,
 
 /** Deregister a su_wait_t object.
  *  
- *  The function su_port_osx_deregister() deregisters a su_wait_t registrattion. 
+ *  The function su_osx_port_deregister() deregisters a su_wait_t registrattion. 
  *  The wait object, a callback function and a argument are removed from the
  *  port object.
  * 
@@ -1175,13 +785,13 @@ int su_port_osx_unregister(su_port_t *self,
  * 
  * @return Index of the wait object, or -1 upon an error.
  */
-int su_port_osx_deregister(su_port_t *self, int i)
+int su_osx_port_deregister(su_port_t *self, int i)
 {
   su_wait_t wait[1] = { SU_WAIT_INIT };
   int retval;
 
   assert(self);
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   if (i <= 0 || i > self->sup_size_waits)
     return su_seterrno(EBADF);
@@ -1189,7 +799,7 @@ int su_port_osx_deregister(su_port_t *self, int i)
   if (self->sup_indices[i] < 0)
     return su_seterrno(EBADF);
     
-  retval = su_port_osx_deregister0(self, i);
+  retval = su_osx_port_deregister0(self, i);
 
   su_wait_destroy(wait);
 
@@ -1200,7 +810,7 @@ int su_port_osx_deregister(su_port_t *self, int i)
 /** @internal
  * Unregister all su_wait_t objects.
  *
- * The function su_port_osx_unregister_all() unregisters all su_wait_t objects
+ * The function su_osx_port_unregister_all() unregisters all su_wait_t objects
  * and destroys all queued timers associated with given root object.
  * 
  * @param  self     - pointer to port object
@@ -1208,7 +818,7 @@ int su_port_osx_deregister(su_port_t *self, int i)
  * 
  * @return Number of wait objects removed.
  */
-int su_port_osx_unregister_all(su_port_t *self, 
+int su_osx_port_unregister_all(su_port_t *self, 
                           su_root_t *root)
 {
   int i, j, index, N;
@@ -1221,7 +831,7 @@ int su_port_osx_unregister_all(su_port_t *self,
   CFRunLoopSourceRef *sources;
   CFSocketRef        *sockets;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - assert(SU_OSX_PORT_OWN_THREAD(self));
 
   N          = self->sup_n_waits;
   indices    = self->sup_indices;
@@ -1295,7 +905,7 @@ int su_port_osx_unregister_all(su_port_t *self,
 
 /**Set mask for a registered event. @internal
  *
- * The function su_port_osx_eventmask() sets the mask describing events that can
+ * The function su_osx_port_eventmask() sets the mask describing events that can
  * signal the registered callback.
  *
  * @param port   pointer to port object
@@ -1306,12 +916,12 @@ int su_port_osx_unregister_all(su_port_t *self,
  * @retval 0 when successful,
  * @retval -1 upon an error.
  */
-int su_port_osx_eventmask(su_port_t *self, int index, int socket, int events)
+int su_osx_port_eventmask(su_port_t *self, int index, int socket, int events)
 {
   int n, ret;
 
   assert(self);
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   if (index <= 0 || index > self->sup_size_waits)
     return su_seterrno(EBADF);
@@ -1330,7 +940,7 @@ int su_port_osx_eventmask(su_port_t *self, int index, int socket, int events)
 /** @internal
  *
  *  Copies the su_wait_t objects from the port. The number of wait objects
- *  can be found out by calling su_port_osx_query() with @a n_waits as zero.
+ *  can be found out by calling su_osx_port_query() with @a n_waits as zero.
  * 
  * @note This function is called only by friends.
  *
@@ -1340,11 +950,11 @@ int su_port_osx_eventmask(su_port_t *self, int index, int socket, int events)
  *
  * @return Number of wait objects, or 0 upon an error.
  */
-unsigned su_port_osx_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
+unsigned su_osx_port_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
 {
   unsigned n;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   n = self->sup_n_waits;
 
@@ -1360,7 +970,7 @@ unsigned su_port_osx_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
 
 /** @internal Enable multishot mode.
  *
- * The function su_port_osx_multishot() enables, disables or queries the
+ * The function su_osx_port_multishot() enables, disables or queries the
  * multishot mode for the port. The multishot mode determines how the events
  * are scheduled by port. If multishot mode is enabled, port serves all the
  * sockets that have received network events. If it is disables, only first
@@ -1373,7 +983,7 @@ unsigned su_port_osx_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
  * @retval 1 multishot mode is enabled
  * @retval -1 an error occurred
  */
-int su_port_osx_multishot(su_port_t *self, int multishot)
+int su_osx_port_multishot(su_port_t *self, int multishot)
 {
   if (multishot < 0)
     return self->sup_multishot;
@@ -1383,12 +993,14 @@ int su_port_osx_multishot(su_port_t *self, int multishot)
     return (errno = EINVAL), -1;
 }
 
+#if 0
 /** @internal Enable threadsafe operation. */
 static
-int su_port_osx_threadsafe(su_port_t *port)
+int su_osx_port_threadsafe(su_port_t *port)
 {
   return su_home_threadsafe(port->sup_home);
 }
+#endif
 
 /** Prepare root to be run on OSX Run Loop.
  *
@@ -1408,23 +1020,23 @@ void su_root_osx_prepare_run(su_root_t *root)
   CFRunLoopRef rl;
   su_duration_t tout = 0;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   enter;
 
-  self->sup_running = 1;
+  self->sup_base->sup_running = 1;
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_prepoll)
-    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+  if (self->sup_base->sup_prepoll)
+    self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
 
-  if (self->sup_head)
-    su_port_osx_getmsgs(self);
+  if (self->sup_base->sup_head)
+    su_port_getmsgs(self);
   
-  if (self->sup_timers)
-    su_timer_expire(&self->sup_timers, &tout, su_now());
+  if (self->sup_base->sup_timers)
+    su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
 
-  if (!self->sup_running)
+  if (!self->sup_base->sup_running)
     return;
 
   CFRetain(rl);
@@ -1435,45 +1047,45 @@ void su_root_osx_prepare_run(su_root_t *root)
 
 /** @internal Main loop.
  * 
- * The function @c su_port_osx_run() waits for wait objects and the timers
+ * The function @c su_osx_port_run() waits for wait objects and the timers
  * associated with the port object.  When any wait object is signaled or
  * timer is expired, it invokes the callbacks, and returns waiting.
  * 
- * The function @c su_port_osx_run() runs until @c su_port_osx_break() is called
+ * The function @c su_osx_port_run() runs until @c su_osx_port_break() is called
  * from a callback.
  * 
  * @param self     pointer to port object
  * 
  */
-void su_port_osx_run(su_port_t *self)
+void su_osx_port_run(su_port_t *self)
 {
   CFRunLoopRef rl;
   su_duration_t tout = 0;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
   enter;
 
-  self->sup_running = 1;
+  self->sup_base->sup_running = 1;
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_prepoll)
-    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+  if (self->sup_base->sup_prepoll)
+    self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
 
-  if (self->sup_head)
-    su_port_osx_getmsgs(self);
+  if (self->sup_base->sup_head)
+    su_port_getmsgs(self);
   
-  if (self->sup_timers)
-    su_timer_expire(&self->sup_timers, &tout, su_now());
+  if (self->sup_base->sup_timers)
+    su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
 
-  if (!self->sup_running)
+  if (!self->sup_base->sup_running)
     return;
 
   CFRetain(rl);
   self->sup_main_loop = rl;
 
   /* if there are messages do a quick wait */
-  if (self->sup_head)
+  if (self->sup_base->sup_head)
     tout = 0;
 
   CFRunLoopRun();
@@ -1484,70 +1096,70 @@ void su_port_osx_run(su_port_t *self)
 
 #if tuning
 /* This version can help tuning... */
-void su_port_osx_run_tune(su_port_t *self)
+void su_osx_port_run_tune(su_port_t *self)
 {
   int i;
   int timers = 0, messages = 0, events = 0;
   su_duration_t tout = 0, tout0;
   su_time_t started = su_now(), woken = started, bedtime = woken;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
+  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
 
-  for (self->sup_running = 1; self->sup_running;) {
+  for (self->sup_base->sup_running = 1; self->sup_base->sup_running;) {
     tout0 = tout, tout = 2000;
 
     timers = 0, messages = 0;
 
-    if (self->sup_prepoll)
-      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+    if (self->sup_base->sup_prepoll)
+      self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
 
-    if (self->sup_head)
-      messages = su_port_osx_getmsgs(self);
+    if (self->sup_base->sup_head)
+      messages = su_port_getmsgs(self);
 
-    if (self->sup_timers)
-      timers = su_timer_expire(&self->sup_timers, &tout, su_now());
+    if (self->sup_base->sup_timers)
+      timers = su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
 
-    if (!self->sup_running)
+    if (!self->sup_base->sup_running)
       break;
 
-    if (self->sup_head)      /* if there are messages do a quick wait */
+    if (self->sup_base->sup_head)      /* if there are messages do a quick wait */
       tout = 0;
 
     bedtime = su_now();
 
-    events = su_port_osx_wait_events(self, tout);
+    events = su_osx_port_wait_events(self, tout);
 
     woken = su_now();
 
     if (messages || timers || events)
-      SU_DEBUG_1(("su_port_osx_run(%p): %.6f: %u messages %u timers %u "
+      SU_DEBUG_1(("su_osx_port_run(%p): %.6f: %u messages %u timers %u "
                  "events slept %.6f/%.3f\n",
                  self, su_time_diff(woken, started), messages, timers, events,
                  su_time_diff(woken, bedtime), tout0 * 1e-3));
 
-    if (!self->sup_running)
+    if (!self->sup_base->sup_running)
       break;
   }
 }
 #endif
 
 /** @internal
- * The function @c su_port_osx_break() is used to terminate execution of @c
- * su_port_osx_run(). It can be called from a callback function.
+ * The function @c su_osx_port_break() is used to terminate execution of @c
+ * su_osx_port_run(). It can be called from a callback function.
  * 
  * @param self     pointer to port
  * 
  */
-void su_port_osx_break(su_port_t *self)
+void su_osx_port_break(su_port_t *self)
 {
   if (self->sup_main_loop)
     CFRunLoopStop(self->sup_main_loop);
 
-  self->sup_running = 0; 
+  self->sup_base->sup_running = 0; 
 }
 
 /** @internal
- * The function @c su_port_osx_wait_events() is used to poll() for wait objects
+ * The function @c su_osx_port_wait_events() is used to poll() for wait objects
  *
  * @param self     pointer to port
  * @param tout     timeout in milliseconds
@@ -1555,7 +1167,7 @@ void su_port_osx_break(su_port_t *self)
  * @return number of events handled
  */
 static
-int su_port_osx_wait_events(su_port_t *self, su_duration_t tout)
+int su_osx_port_wait_events(su_port_t *self, su_duration_t tout)
 {
   int i, events = 0;
   su_wait_t *waits = self->sup_waits;
@@ -1600,21 +1212,6 @@ int su_port_osx_wait_events(su_port_t *self, su_duration_t tout)
   return events;
 }
 
-/** @internal 
- * Used to check wait events in callbacks that take lots of time
- *
- * This function does a timeout 0 poll() and runs wait objects.
- *
- * @param port     pointer to port
- *
- * @return number of events handled
- */
-static
-int su_port_osx_yield(su_port_t *port)
-{
-  return su_port_osx_wait_events(port, 0);
-}
-
 /** @internal Block until wait object is signaled or timeout.
  *
  * This function waits for wait objects and the timers associated with 
@@ -1631,15 +1228,13 @@ int su_port_osx_yield(su_port_t *port)
  *   Milliseconds to the next invocation of timer, or @c SU_WAIT_FOREVER if
  *   there are no active timers.
  */
-su_duration_t su_port_osx_step(su_port_t *self, su_duration_t tout)
+su_duration_t su_osx_port_step(su_port_t *self, su_duration_t tout)
 {
   CFRunLoopRef rl;
   su_time_t now = su_now();
   CFAbsoluteTime start;
   int ret, timeout = tout > INT32_MAX ? INT32_MAX : tout;
 
-  assert(SU_PORT_OSX_OWN_THREAD(self));
-
   rl = CFRunLoopGetCurrent();
 
   if (!rl)
@@ -1650,138 +1245,33 @@ su_duration_t su_port_osx_step(su_port_t *self, su_duration_t tout)
   if (tout < timeout)
     timeout = tout;
 
-  if (self->sup_prepoll)
-    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+  if (self->sup_base->sup_prepoll)
+    self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
 
-  if (self->sup_head)
-    su_port_osx_getmsgs(self);
+  if (self->sup_base->sup_head)
+    su_base_port_getmsgs(self);
 
-  if (self->sup_timers)
-    su_timer_expire(&self->sup_timers, &tout, now);
+  if (self->sup_base->sup_timers)
+    su_timer_expire(&self->sup_base->sup_timers, &tout, now);
 
   /* if there are messages do a quick wait */
-  if (self->sup_head)
+  if (self->sup_base->sup_head)
     tout = 0;
 
-  start = CFAbsoluteTimeGetCurrent();
-  for (;;) {
-    /* Run loop with only one pass, indicate if a source was processed */
-    ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
-                            0,
-                            TRUE);
+  ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
+                          tout/1000000.0,
+                          true);
 
-    /* Ok, one of our sources was fired */
-    if (self->sup_source_fired == 1) {
-      self->sup_source_fired = 0;
-      break;
-    }
+  CFRunLoopWakeUp(rl);
 
-    /* Check how long to run this loop */
-    if (CFAbsoluteTimeGetCurrent() >= start + timeout / 1000)
-      break;
-  }
-  
-  if (self->sup_head)
-    su_port_osx_getmsgs(self);
+  if (self->sup_base->sup_head)
+    su_base_port_getmsgs(self);
 
-  if (self->sup_timers)
-    su_timer_expire(&self->sup_timers, &tout, su_now());
+  if (self->sup_base->sup_timers)
+    su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
 
-  if (self->sup_head)
+  if (self->sup_base->sup_head)
     tout = 0;
 
   return tout;
 }
-
-
-/** @internal
- * Checks if the calling thread owns the port object.
- *
- * @param self pointer to a port object
- *
- * @retval true (nonzero) if the calling thread owns the port,
- * @retval false (zero) otherwise.
- */
-int su_port_osx_own_thread(su_port_t const *self)
-{
-  return self == NULL || SU_PORT_OSX_OWN_THREAD(self);
-}
-
-#if 0
-/** @internal
- *  Prints out the contents of the port.
- *
- * @param self pointer to a port
- * @param f    pointer to a file (if @c NULL, uses @c stdout).
- */
-void su_port_osx_dump(su_port_t const *self, FILE *f)
-{
-  int i;
-#define IS_WAIT_IN(x) (((x)->events & SU_WAIT_IN) ? "IN" : "")
-#define IS_WAIT_OUT(x) (((x)->events & SU_WAIT_OUT) ? "OUT" : "")
-#define IS_WAIT_ACCEPT(x) (((x)->events & SU_WAIT_ACCEPT) ? "ACCEPT" : "")
-
-  if (f == NULL)
-    f = stdout;
-
-  fprintf(f, "su_port_osx_t at %p:\n", self);
-  fprintf(f, "\tport is%s running\n", self->sup_running ? "" : "not ");
-#if SU_HAVE_PTHREADS
-  fprintf(f, "\tport tid %p\n", (void *)self->sup_tid);
-#endif
-#if SU_HAVE_MBOX
-  fprintf(f, "\tport mbox %d (%s%s%s)\n", self->sup_mbox[0],
-         IS_WAIT_IN(&self->sup_mbox_wait),
-         IS_WAIT_OUT(&self->sup_mbox_wait),
-         IS_WAIT_ACCEPT(&self->sup_mbox_wait));
-#endif
-  fprintf(f, "\t%d wait objects\n", self->sup_n_waits);
-  for (i = 0; i < self->sup_n_waits; i++) {
-    
-  }
-}
-
-#endif
-
-/* =========================================================================
- * Pre-poll() callback
- */
-
-int su_port_osx_add_prepoll(su_port_t *port,
-                       su_root_t *root, 
-                       su_prepoll_f *callback, 
-                       su_prepoll_magic_t *magic)
-{
-  if (port->sup_prepoll)
-    return -1;
-
-  port->sup_prepoll = callback;
-  port->sup_pp_magic = magic;
-  port->sup_pp_root = root;
-
-  return 0;
-}
-
-int su_port_osx_remove_prepoll(su_port_t *port,
-                          su_root_t *root)
-{
-  if (port->sup_pp_root != root)
-    return -1;
-
-  port->sup_prepoll = NULL;
-  port->sup_pp_magic = NULL;
-  port->sup_pp_root = NULL;
-
-  return 0;
-}
-
-/* =========================================================================
- * Timers
- */
-
-static
-su_timer_t **su_port_osx_timers(su_port_t *self)
-{
-  return &self->sup_timers;
-}
-
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_poll_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_poll_port.c
new file mode 100644 (file)
index 0000000..1f18fe2
--- /dev/null
@@ -0,0 +1,695 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_poll_port.c
+ *
+ * Port implementation using poll()
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Create: Fri Jan 26 20:44:14 2007 ppessi
+ * @date Original: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#define su_port_s su_poll_port_s
+
+#include "su_port.h"
+#include "sofia-sip/su_alloc.h"
+#include "sofia-sip/su.h"
+
+#if HAVE_POLL_PORT
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+/** Port based on poll(). */
+
+struct su_poll_port_s {
+  su_socket_port_t sup_base[1];
+
+#define sup_home sup_base->sup_base->sup_base->sup_home
+
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+                                     su_port_register() or 
+                                     su_port_unregister()
+                                  */
+
+  int              sup_n_waits; /**< Active su_wait_t in su_waits */
+  int              sup_size_waits; /**< Size of allocated su_waits */
+  int              sup_pri_offset; /**< Offset to prioritized waits */
+
+#define INDEX_MAX (0x7fffffff)
+
+  /** Indices from index returned by su_root_register() to tables below. 
+   *
+   * Free elements are negative. Free elements form a list, value of free
+   * element is (0 - index of next free element).
+   *
+   * First element sup_indices[0] points to first free element. 
+   */
+  int             *sup_indices;
+
+  int             *sup_reverses; /** Reverse index */
+  su_wakeup_f     *sup_wait_cbs; 
+  su_wakeup_arg_t**sup_wait_args; 
+  su_root_t      **sup_wait_roots; 
+  su_wait_t       *sup_waits; 
+
+};
+
+static void su_poll_port_decref(su_port_t *, int blocking, char const *who);
+
+static int su_poll_port_register(su_port_t *self,
+                                su_root_t *root, 
+                                su_wait_t *wait, 
+                                su_wakeup_f callback,
+                                su_wakeup_arg_t *arg,
+                                int priority);
+static int su_poll_port_unregister(su_port_t *port,
+                                  su_root_t *root, 
+                                  su_wait_t *wait,     
+                                  su_wakeup_f callback, 
+                                  su_wakeup_arg_t *arg);
+static int su_poll_port_deregister(su_port_t *self, int i);
+static int su_poll_port_unregister_all(su_port_t *self, su_root_t *root);
+static int su_poll_port_eventmask(su_port_t *self, 
+                                 int index,
+                                 int socket,
+                                 int events);
+static int su_poll_port_multishot(su_port_t *self, int multishot);
+static int su_poll_port_wait_events(su_port_t *self, su_duration_t tout);
+static char const *su_poll_port_name(su_port_t const *self);
+
+su_port_vtable_t const su_poll_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_poll_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_poll_port_decref,
+      su_base_port_gsource,
+      su_socket_port_send,
+      su_poll_port_register,
+      su_poll_port_unregister,
+      su_poll_port_deregister,
+      su_poll_port_unregister_all,
+      su_poll_port_eventmask,
+      su_base_port_run,
+      su_base_port_break,
+      su_base_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_poll_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_poll_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_poll_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
+    }};
+
+static char const *su_poll_port_name(su_port_t const *self)
+{
+  return "poll";
+}
+
+static void su_poll_port_deinit(void *arg)
+{
+  su_port_t *self = arg;
+
+  SU_DEBUG_9(("%s(%p) called\n", "su_poll_port_deinit", (void *)self));
+
+  su_socket_port_deinit(self->sup_base);
+}
+
+static void su_poll_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  su_base_port_decref(self, blocking, who);
+}
+
+/** @internal
+ *
+ *  Register a @c su_wait_t object. The wait object, a callback function and
+ *  an argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
+ *
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
+ * 
+ * @param self      pointer to port
+ * @param root      pointer to root object
+ * @param waits             pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg       argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
+ * 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_poll_port_register(su_port_t *self,
+                         su_root_t *root, 
+                         su_wait_t *wait, 
+                         su_wakeup_f callback,
+                         su_wakeup_arg_t *arg,
+                         int priority)
+{
+  int i, j, n;
+
+  assert(su_port_own_thread(self));
+
+  n = self->sup_n_waits;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  if (n >= self->sup_size_waits) {
+    su_home_t *h = self->sup_home;
+    /* Reallocate size arrays */
+    int size;
+    int *indices;
+    int *reverses;
+    su_wait_t *waits;
+    su_wakeup_f *wait_cbs;
+    su_wakeup_arg_t **wait_args;
+    su_root_t **wait_tasks;
+
+    if (self->sup_size_waits == 0)
+      size = su_root_size_hint;
+    else 
+      size = 2 * self->sup_size_waits;
+
+    if (size < SU_WAIT_MIN)
+      size = SU_WAIT_MIN;
+
+    /* Too large */
+    if (-3 - size > 0)
+      return (errno = ENOMEM), -1;
+
+    indices = su_realloc(h, self->sup_indices, (size + 1) * sizeof(*indices));
+    if (indices) {
+      self->sup_indices = indices;
+
+      if (self->sup_size_waits == 0)
+       indices[0] = -1;
+
+      for (i = self->sup_size_waits + 1; i <= size; i++)
+       indices[i] = -1 - i;
+    }
+
+    reverses = su_realloc(h, self->sup_reverses, size * sizeof(*waits));
+    if (reverses) {
+      for (i = self->sup_size_waits; i < size; i++)
+       reverses[i] = -1;
+      self->sup_reverses = reverses;
+    }
+      
+    waits = su_realloc(h, self->sup_waits, size * sizeof(*waits));
+    if (waits)
+      self->sup_waits = waits;
+
+    wait_cbs = su_realloc(h, self->sup_wait_cbs, size * sizeof(*wait_cbs));
+    if (wait_cbs)
+      self->sup_wait_cbs = wait_cbs;
+
+    wait_args = su_realloc(h, self->sup_wait_args, size * sizeof(*wait_args));
+    if (wait_args)
+      self->sup_wait_args = wait_args;
+
+    /* Add sup_wait_roots array, if needed */
+    wait_tasks = su_realloc(h, self->sup_wait_roots, size * sizeof(*wait_tasks));
+    if (wait_tasks) 
+      self->sup_wait_roots = wait_tasks;
+
+    if (!(indices && 
+         reverses && waits && wait_cbs && wait_args && wait_tasks)) {
+      return -1;
+    }
+
+    self->sup_size_waits = size;
+  }
+
+  i = -self->sup_indices[0]; assert(i <= self->sup_size_waits);
+
+  if (priority > 0) {
+    /* Insert */
+    for (n = self->sup_n_waits; n > 0; n--) {
+      j = self->sup_reverses[n-1]; assert(self->sup_indices[j] == n - 1);
+      self->sup_indices[j] = n;
+      self->sup_reverses[n] = j;
+      self->sup_waits[n] = self->sup_waits[n-1];
+      self->sup_wait_cbs[n] = self->sup_wait_cbs[n-1];
+      self->sup_wait_args[n] = self->sup_wait_args[n-1];
+      self->sup_wait_roots[n] = self->sup_wait_roots[n-1];     
+    }
+
+    self->sup_pri_offset++;
+  }
+  else {
+    /* Append - no need to move anything */
+    n = self->sup_n_waits;
+  }
+
+  self->sup_n_waits++;
+
+  self->sup_indices[0] = self->sup_indices[i];  /* Free index */
+  self->sup_indices[i] = n;
+
+  self->sup_reverses[n] = i;
+  self->sup_waits[n] = *wait;
+  self->sup_wait_cbs[n] = callback;
+  self->sup_wait_args[n] = arg;
+  self->sup_wait_roots[n] = root;
+
+  self->sup_registers++;
+
+  /* Just like epoll, we return -1 or positive integer */
+
+  return i;
+}
+
+/** Deregister a su_wait_t object. */
+static int su_poll_port_deregister0(su_port_t *self, int i, int destroy_wait)
+{
+  int n, N, *indices, *reverses;
+
+  indices = self->sup_indices;
+  reverses = self->sup_reverses;
+
+  n = indices[i]; assert(n >= 0);
+
+  if (destroy_wait)
+    su_wait_destroy(&self->sup_waits[n]);
+  
+  N = --self->sup_n_waits;
+  
+  if (n < self->sup_pri_offset) {
+    int j = --self->sup_pri_offset;
+    if (n != j) {
+      assert(reverses[j] > 0);
+      assert(indices[reverses[j]] == j);
+      indices[reverses[j]] = n;
+      reverses[n] = reverses[j];
+
+      self->sup_waits[n] = self->sup_waits[j];
+      self->sup_wait_cbs[n] = self->sup_wait_cbs[j];
+      self->sup_wait_args[n] = self->sup_wait_args[j];
+      self->sup_wait_roots[n] = self->sup_wait_roots[j];
+      n = j;
+    }
+  }
+
+  if (n < N) {
+    assert(reverses[N] > 0);
+    assert(indices[reverses[N]] == N);
+
+    indices[reverses[N]] = n;
+    reverses[n] = reverses[N];
+
+    self->sup_waits[n] = self->sup_waits[N];
+    self->sup_wait_cbs[n] = self->sup_wait_cbs[N];
+    self->sup_wait_args[n] = self->sup_wait_args[N];
+    self->sup_wait_roots[n] = self->sup_wait_roots[N];
+    n = N;
+  }
+
+  reverses[n] = -1;
+  memset(&self->sup_waits[n], 0, sizeof self->sup_waits[n]);
+  self->sup_wait_cbs[n] = NULL;
+  self->sup_wait_args[n] = NULL;
+  self->sup_wait_roots[n] = NULL;
+  
+  indices[i] = indices[0];
+  indices[0] = -i;
+
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ *  The function su_poll_port_unregister() unregisters a su_wait_t object. The
+ *  wait object, a callback function and a argument are removed from the
+ *  port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
+ *
+ * @deprecated Use su_poll_port_deregister() instead. 
+ *
+ * @return Nonzero index of the wait object, or -1 upon an error.
+ */
+int su_poll_port_unregister(su_port_t *self,
+                           su_root_t *root, 
+                           su_wait_t *wait,    
+                           su_wakeup_f callback, /* XXX - ignored */
+                           su_wakeup_arg_t *arg)
+{
+  int n, N;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  N = self->sup_n_waits;
+
+  for (n = 0; n < N; n++) {
+    if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
+      return su_poll_port_deregister0(self, self->sup_reverses[n], 0);
+    }
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
+}
+
+/** Deregister a su_wait_t object.
+ *  
+ *  Deregisters a registration by index. The wait object, a callback
+ *  function and a argument are removed from the port object. The wait
+ *  object is destroyed.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_poll_port_deregister(su_port_t *self, int i)
+{
+  su_wait_t wait[1] = { SU_WAIT_INIT };
+  int retval;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  if (i <= 0 || i > self->sup_size_waits)
+    return su_seterrno(EBADF);
+
+  if (self->sup_indices[i] < 0)
+    return su_seterrno(EBADF);
+    
+  retval = su_poll_port_deregister0(self, i, 1);
+
+  su_wait_destroy(wait);
+
+  return retval;
+}
+
+
+/** @internal
+ * Unregister all su_wait_t objects.
+ *
+ * The function su_poll_port_unregister_all() unregisters all su_wait_t objects
+ * and destroys all queued timers associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_poll_port_unregister_all(su_port_t *self, 
+                               su_root_t *root)
+{
+  int i, j, index, N;
+  int             *indices, *reverses;
+  su_wait_t       *waits;
+  su_wakeup_f     *wait_cbs;
+  su_wakeup_arg_t**wait_args;
+  su_root_t      **wait_roots;
+
+  assert(su_port_own_thread(self));
+
+  N          = self->sup_n_waits;
+  indices    = self->sup_indices;
+  reverses   = self->sup_reverses;
+  waits      = self->sup_waits; 
+  wait_cbs   = self->sup_wait_cbs; 
+  wait_args  = self->sup_wait_args;
+  wait_roots = self->sup_wait_roots; 
+  
+  for (i = j = 0; i < N; i++) {
+    index = reverses[i]; assert(index > 0 && indices[index] == i);
+
+    if (wait_roots[i] == root) {
+      /* XXX - we should free all resources associated with this, too */
+      if (i < self->sup_pri_offset)
+       self->sup_pri_offset--;
+
+      indices[index] = indices[0];
+      indices[0] = -index;
+      continue;
+    }
+
+    if (i != j) {
+      indices[index] = j;
+      reverses[j]   = reverses[i];
+      waits[j]      = waits[i];
+      wait_cbs[j]   = wait_cbs[i];
+      wait_args[j]  = wait_args[i];
+      wait_roots[j] = wait_roots[i];
+    }
+    
+    j++;
+  }
+  
+  for (i = j; i < N; i++) {
+    reverses[i] = -1;
+    wait_cbs[i] = NULL;
+    wait_args[i] = NULL;
+    wait_roots[i] = NULL;
+  }
+  memset(&waits[j], 0, (char *)&waits[N] - (char *)&waits[j]);
+
+  self->sup_n_waits = j;
+  self->sup_registers++;
+
+  return N - j;
+}
+
+/**Set mask for a registered event. @internal
+ *
+ * The function su_poll_port_eventmask() sets the mask describing events
+ * that can signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.
+ */
+int su_poll_port_eventmask(su_port_t *self, int index, int socket, int events)
+{
+  int n;
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  if (index <= 0 || index > self->sup_size_waits)
+    return su_seterrno(EBADF);
+  n = self->sup_indices[index];
+  if (n < 0)
+    return su_seterrno(EBADF);
+
+  return su_wait_mask(&self->sup_waits[n], socket, events);
+}
+
+/** @internal Enable multishot mode.
+ *
+ * Enables, disables or queries the multishot mode for the port. The
+ * multishot mode determines how the events are scheduled by port. If
+ * multishot mode is enabled, port serves all the sockets that have received
+ * network events. If it is disabled, only first socket event is served.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+static
+int su_poll_port_multishot(su_port_t *self, int multishot)
+{
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
+}
+
+
+/** @internal
+ * Wait (poll()) for wait objects in port.
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ *
+ * @return number of events handled
+ */
+static
+int su_poll_port_wait_events(su_port_t *self, su_duration_t tout)
+{
+  int i, events = 0;
+  su_wait_t *waits = self->sup_waits;
+  int n = self->sup_n_waits;
+  su_root_t *root;
+  unsigned version = self->sup_registers;
+
+  i = su_wait(waits, (unsigned)n, tout);
+
+  if (i >= 0 && i < n) {
+    /* poll() can return events for multiple wait objects */
+    if (self->sup_multishot) {
+      for (; i < n; i++) {
+        if (waits[i].revents) {
+          root = self->sup_wait_roots[i];
+          self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
+                                &waits[i],
+                                self->sup_wait_args[i]);
+          events++;
+          /* Callback function used su_register()/su_deregister() */
+          if (version != self->sup_registers)
+            break;
+        }
+      }
+    }
+    else {
+      root = self->sup_wait_roots[i];
+      self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
+                            &self->sup_waits[i],
+                            self->sup_wait_args[i]);
+      events++;
+    }
+  }
+
+  return events;
+}
+
+#if 0
+/** @internal
+ *  Prints out the contents of the port.
+ *
+ * @param self pointer to a port
+ * @param f    pointer to a file (if @c NULL, uses @c stdout).
+ */
+void su_port_dump(su_port_t const *self, FILE *f)
+{
+  int i;
+#define IS_WAIT_IN(x) (((x)->events & SU_WAIT_IN) ? "IN" : "")
+#define IS_WAIT_OUT(x) (((x)->events & SU_WAIT_OUT) ? "OUT" : "")
+#define IS_WAIT_ACCEPT(x) (((x)->events & SU_WAIT_ACCEPT) ? "ACCEPT" : "")
+
+  if (f == NULL)
+    f = stdout;
+
+  fprintf(f, "su_port_t at %p:\n", self);
+  fprintf(f, "\tport is%s running\n", self->sup_running ? "" : "not ");
+#if SU_HAVE_PTHREADS
+  fprintf(f, "\tport tid %p\n", (void *)self->sup_tid);
+  fprintf(f, "\tport mbox %d (%s%s%s)\n", self->sup_mbox[0],
+         IS_WAIT_IN(&self->sup_mbox_wait),
+         IS_WAIT_OUT(&self->sup_mbox_wait),
+         IS_WAIT_ACCEPT(&self->sup_mbox_wait));
+#endif
+  fprintf(f, "\t%d wait objects\n", self->sup_n_waits);
+  for (i = 0; i < self->sup_n_waits; i++) {
+    
+  }
+}
+
+#endif
+
+/** Create a port using epoll() or poll().
+ */
+su_port_t *su_poll_port_create(void)
+{
+  su_port_t *self = su_home_new(sizeof *self);
+
+  if (!self)
+    return self;
+
+  if (su_home_destructor(su_port_home(self), su_poll_port_deinit) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
+
+  if (su_socket_port_init(self->sup_base, su_poll_port_vtable) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  return self;
+}
+
+int su_poll_clone_start(su_root_t *parent,
+                       su_clone_r return_clone,
+                       su_root_magic_t *magic,
+                       su_root_init_f init,
+                       su_root_deinit_f deinit)
+{
+  return su_pthreaded_port_start(su_default_port_create, 
+                                parent, return_clone, magic, init, deinit);
+}
+
+#else
+
+su_port_t *su_poll_port_create(void)
+{
+  return su_default_port_create();
+}
+
+int su_poll_clone_start(su_root_t *parent,
+                       su_clone_r return_clone,
+                       su_root_magic_t *magic,
+                       su_root_init_f init,
+                       su_root_deinit_f deinit)
+{
+  return su_default_clone_start(parent, return_clone, magic, init, deinit);
+}
+
+#endif  /* HAVE_POLL_PORT */
+
index bc0a8e31f63f2a6b16464feb6023716f9d712ba9..8cc9dc5b0b680d58edcc605f9e75150e85541ec4 100644 (file)
@@ -27,8 +27,9 @@
  *
  * OS-Independent Socket Syncronization Interface.
  *
- * This looks like nth reincarnation of "reactor".  It implements the
- * poll/select/WaitForMultipleObjects and message passing functionality.
+ * This looks like nth reincarnation of "reactor". It implements the
+ * poll/select/WaitForMultipleObjects and message passing functionality. 
+ * This is virtual implementation:
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  * @author Kai Vehmanen <kai.vehmanen@nokia.com>
 
 #include "config.h"
 
-/* React to multiple events per one poll() to make sure 
- * that high-priority events can never completely mask other events.
- * Enabled by default on all platforms except WIN32 */
-#ifndef WIN32
-#define SU_ENABLE_MULTISHOT_POLL 1
-#else
-#define SU_ENABLE_MULTISHOT_POLL 0
-#endif
-
-#include <stdlib.h>
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
+#define SU_CLONE_T      su_msg_t
 
-#define SU_PORT_IMPLEMENTATION 1
+#define su_port_s su_virtual_port_s
 
-#include "sofia-sip/su.h"
 #include "su_port.h"
-#include "sofia-sip/su_alloc.h"
-
-#if SU_HAVE_PTHREADS
-/* Pthread implementation */
-#include <pthread.h>
-#define SU_HAVE_MBOX 1
-#else
-#define SU_HAVE_MBOX 0
-#endif
 
-#if HAVE_SOCKETPAIR
-#define MBOX_SEND  1
-#else
-#define MBOX_SEND  0
-#endif
+#include <string.h>
+#include <stdlib.h>
 
+/** Create the default su_port_t implementation. */
+su_port_t *su_default_port_create(void)
+{
 #if HAVE_EPOLL
-#include <sys/epoll.h>
-
-#define POLL2EPOLL_NEEDED \
-  (POLLIN != EPOLLIN || POLLOUT != EPOLLOUT || POLLPRI != EPOLLPRI || \
-   POLLERR != EPOLLERR || POLLHUP != EPOLLHUP)
-#define POLL2EPOLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
-#define EPOLL2POLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
-
-#endif
-
-static void su_port_lock(su_port_t *self, char const *who);
-static void su_port_unlock(su_port_t *self, char const *who);
-static void su_port_incref(su_port_t *self, char const *who);
-static void su_port_decref(su_port_t *self, int blocking, char const *who);
-
-static struct _GSource *su_port_gsource(su_port_t *port);
-
-static int su_port_send(su_port_t *self, su_msg_r rmsg);
-
-static int su_port_register(su_port_t *self,
-                           su_root_t *root, 
-                           su_wait_t *wait, 
-                           su_wakeup_f callback,
-                           su_wakeup_arg_t *arg,
-                           int priority);
-static int su_port_unregister(su_port_t *port,
-                             su_root_t *root, 
-                             su_wait_t *wait,  
-                             su_wakeup_f callback, 
-                             su_wakeup_arg_t *arg);
-
-static int su_port_deregister(su_port_t *self, int i);
-
-static int su_port_unregister_all(su_port_t *self,
-                          su_root_t *root);
-static
-int su_port_eventmask(su_port_t *self, int index, int socket, int events);
-static
-void su_port_run(su_port_t *self);
-static
-void su_port_break(su_port_t *self);
-static
-su_duration_t su_port_step(su_port_t *self, su_duration_t tout);
-
-static
-int su_port_own_thread(su_port_t const *port);
-
-static
-int su_port_add_prepoll(su_port_t *port,
-                       su_root_t *root, 
-                       su_prepoll_f *, 
-                       su_prepoll_magic_t *);
-
-static
-int su_port_remove_prepoll(su_port_t *port,
-                          su_root_t *root);
-
-static
-su_timer_t **su_port_timers(su_port_t *port);
-
-static
-int su_port_multishot(su_port_t *port, int multishot);
-
-static
-int su_port_threadsafe(su_port_t *port);
-
-static
-int su_port_yield(su_port_t *port);
-
-su_port_vtable_t const su_port_vtable[1] =
-  {{
-      /* su_vtable_size: */ sizeof su_port_vtable,
-      su_port_lock,
-      su_port_unlock,
-      su_port_incref,
-      su_port_decref,
-      su_port_gsource,
-      su_port_send,
-      su_port_register,
-      su_port_unregister,
-      su_port_deregister,
-      su_port_unregister_all,
-      su_port_eventmask,
-      su_port_run,
-      su_port_break,
-      su_port_step,
-      su_port_own_thread,
-      su_port_add_prepoll,
-      su_port_remove_prepoll,
-      su_port_timers,
-      su_port_multishot,
-      su_port_threadsafe,
-      su_port_yield
-    }};
-
-static int su_port_wait_events(su_port_t *self, su_duration_t tout);
-
-
-/** 
- * Port is a per-thread reactor.  
- *
- * Multiple root objects executed by single thread share a su_port_t object. 
- */
-struct su_port_s {
-  su_home_t        sup_home[1];
-
-  su_port_vtable_t const *sup_vtable;
-  
-  unsigned         sup_running;
-
-#if SU_HAVE_PTHREADS
-  pthread_t        sup_tid;
-  pthread_mutex_t  sup_mutex[1];
-#if __CYGWIN__
-  pthread_mutex_t  sup_reflock[1];
-  int              sup_ref;
-#else
-  pthread_rwlock_t sup_ref[1];
-#endif
+  return su_epoll_port_create();
+#elif HAVE_KQUEUE
+  return su_kqueue_port_create();
+#elif HAVE_SYS_DEVPOLL_H
+  return su_devpoll_port_create();
+#elif HAVE_POLL_PORT
+  return su_poll_port_create();
+#elif HAVE_WIN32
+  return su_wsaevent_port_create();
+#elif HAVE_SELECT
+  return su_select_port_create();
 #else
-  int              sup_ref;
-#endif
-
-#if SU_HAVE_MBOX
-  su_socket_t      sup_mbox[MBOX_SEND + 1];
-  su_wait_t        sup_mbox_wait;
+  return NULL;
 #endif
+}
 
+int su_default_clone_start(su_root_t *parent,
+                          su_clone_r return_clone,
+                          su_root_magic_t *magic,
+                          su_root_init_f init,
+                          su_root_deinit_f deinit)
+{
 #if HAVE_EPOLL
-  /** epoll() fd */
-  int              sup_epoll;
-#endif
-
-  unsigned         sup_multishot; /**< Multishot operation? */
-
-  unsigned         sup_registers; /** Counter incremented by 
-                                     su_port_register() or 
-                                     su_port_unregister()
-                                  */
-  int              sup_n_waits; /**< Active su_wait_t in su_waits */
-  int              sup_size_waits; /**< Size of allocate su_waits */
-
-  int              sup_pri_offset; /**< Offset to prioritized waits */
-
-#if !SU_HAVE_WINSOCK
-#define INDEX_MAX (0x7fffffff)
-#else 
-  /* We use WSAWaitForMultipleEvents() */
-#define INDEX_MAX (64)
-#endif
-
-  /** Indices from index returned by su_root_register() to tables below. 
-   *
-   * Free elements are negative. Free elements form a list, value of free
-   * element is (0 - index of next free element).
-   *
-   * First element sup_indices[0] points to first free element. 
-   */
-  int             *sup_indices;
-
-  int             *sup_reverses; /** Reverse index */
-  su_wakeup_f     *sup_wait_cbs; 
-  su_wakeup_arg_t**sup_wait_args; 
-  su_root_t      **sup_wait_roots; 
-
-  su_wait_t       *sup_waits; 
-
-  /* Pre-poll callback */
-  su_prepoll_f    *sup_prepoll; 
-  su_prepoll_magic_t *sup_pp_magic;
-  su_root_t       *sup_pp_root;
-
-  /* Timer list */
-  su_timer_t      *sup_timers;
-
-  /* Message list - this is protected by lock  */
-  su_msg_t        *sup_head;
-  su_msg_t       **sup_tail;
-};
-
-#if SU_HAVE_PTHREADS
-#define SU_PORT_OWN_THREAD(p)   (pthread_equal((p)->sup_tid, pthread_self()))
-
-#if __CYGWIN__
-
-/* Debugging versions */
-#define SU_PORT_INITREF(p)      (pthread_mutex_init((p)->sup_reflock, NULL), printf("initref(%p)\n", (p)))
-#define SU_PORT_INCREF(p, f)    (pthread_mutex_lock(p->sup_reflock), p->sup_ref++, pthread_mutex_unlock(p->sup_reflock), printf("incref(%p) by %s\n", (p), f))
-#define SU_PORT_DECREF(p, f)    do {                                   \
-    pthread_mutex_lock(p->sup_reflock);        p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
-    if ((p->sup_ref) == 0) {                   \
-      printf("decref(%p) to 0 by %s\n", (p), f); su_port_destroy(p); } \
-    else { printf("decref(%p) to %u by %s\n", (p), p->sup_ref, f); }  } while(0)
-
-#define SU_PORT_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
-    pthread_mutex_lock(p->sup_reflock);        p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
-  if ((p->sup_ref) != 0) { \
-    assert(!"SU_PORT_ZAPREF"); } \
-  su_port_destroy(p); } while(0)
-
-#define SU_PORT_INITLOCK(p) \
-   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
-
-#define SU_PORT_LOCK(p, f)    \
-   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
-
-#define SU_PORT_UNLOCK(p, f)  \
-  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
-
-#elif 1
-#define SU_PORT_INITREF(p)      (pthread_rwlock_init(p->sup_ref, NULL))
-#define SU_PORT_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref))
-#define SU_PORT_DECREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
-  if (pthread_rwlock_trywrlock(p->sup_ref) == 0) su_port_destroy(p); } while(0)
-
-#define SU_PORT_ZAPREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
-  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
-    assert(!"SU_PORT_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
-  su_port_destroy(p); } while(0)
-
-#define SU_PORT_INITLOCK(p)     (pthread_mutex_init((p)->sup_mutex, NULL))
-#define SU_PORT_LOCK(p, f)      (pthread_mutex_lock((p)->sup_mutex))
-#define SU_PORT_UNLOCK(p, f)    (pthread_mutex_unlock((p)->sup_mutex))
-
+  return su_epoll_clone_start(parent, return_clone, magic, init, deinit);
+#elif HAVE_KQUEUE
+  return su_kqueue_clone_start(parent, return_clone, magic, init, deinit);
+#elif HAVE_SYS_DEVPOLL_H
+  return su_devpoll_clone_start(parent, return_clone, magic, init, deinit);
+#elif HAVE_POLL_PORT
+  return su_poll_clone_start(parent, return_clone, magic, init, deinit);
+#elif HAVE_WIN32
+  return su_wsaevent_clone_start(parent, return_clone, magic, init, deinit);
+#elif HAVE_SELECT
+  return su_select_clone_start(parent, return_clone, magic, init, deinit);
 #else
-
-/* Debugging versions */
-#define SU_PORT_INITREF(p)      (pthread_rwlock_init((p)->sup_ref, NULL), printf("initref(%p)\n", (p)))
-#define SU_PORT_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref), printf("incref(%p) by %s\n", (p), f))
-#define SU_PORT_DECREF(p, f)    do {                                   \
-    pthread_rwlock_unlock(p->sup_ref);                                 \
-    if (pthread_rwlock_trywrlock(p->sup_ref) == 0) {                   \
-      printf("decref(%p) to 0 by %s\n", (p), f); su_port_destroy(p); } \
-    else { printf("decref(%p) by %s\n", (p), f); }  } while(0)
-
-#define SU_PORT_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
-  pthread_rwlock_unlock(p->sup_ref); \
-  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
-    assert(!"SU_PORT_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
-  su_port_destroy(p); } while(0)
-
-#define SU_PORT_INITLOCK(p) \
-   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
-
-#define SU_PORT_LOCK(p, f)    \
-   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
-
-#define SU_PORT_UNLOCK(p, f)  \
-  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
-
-#endif
-
-#else /* !SU_HAVE_PTHREADS */
-
-#define SU_PORT_OWN_THREAD(p)  1
-#define SU_PORT_INITLOCK(p)    (void)(p)
-#define SU_PORT_LOCK(p, f)      (void)(p)
-#define SU_PORT_UNLOCK(p, f)    (void)(p)
-#define SU_PORT_ZAPREF(p, f)    ((p)->sup_ref--)
-
-#define SU_PORT_INITREF(p)      ((p)->sup_ref = 1)
-#define SU_PORT_INCREF(p, f)    ((p)->sup_ref++)
-#define SU_PORT_DECREF(p, f) \
-do { if (--((p)->sup_ref) == 0) su_port_destroy(p); } while (0);
-
-#endif
-
-#if SU_HAVE_MBOX
-static int su_port_wakeup(su_root_magic_t *magic, 
-                         su_wait_t *w,
-                         su_wakeup_arg_t *arg);
+  errno = ENOSYS;
+  return -1;
 #endif
+}
 
-static void su_port_destroy(su_port_t *self);
+static su_port_create_f *preferred_su_port_create;
+static su_clone_start_f *preferred_su_clone_start;
 
-/**@internal
- *
- * Allocates and initializes a message port. It creates a mailbox used to.
- * wake up the tasks waiting on the port if needed.  Currently, the
- * mailbox is simply an UDP socket connected to itself.
+/** Explicitly set the preferred su_port_t implementation.
  *
- * @return
- *   If successful a pointer to the new message port is returned, otherwise
- *   NULL is returned.  
+ * @sa su_epoll_port_create(), su_poll_port_create(), su_select_port_create()
  */
-su_port_t *su_port_create(void)
+void su_port_prefer(su_port_create_f *create,
+                   su_clone_start_f *start)
 {
-  su_port_t *self;
-
-  SU_DEBUG_9(("su_port_create() called\n"));
-
-  self = su_home_clone(NULL, sizeof(*self));
-
-  if (self) {
-#if SU_HAVE_MBOX
-    int af;
-    su_socket_t mb = INVALID_SOCKET;
-    char const *why;
-#endif
-
-    self->sup_vtable = su_port_vtable;
-    
-    SU_PORT_INITREF(self);
-    SU_PORT_INITLOCK(self);
-    self->sup_tail = &self->sup_head;
-
-    self->sup_multishot = (SU_ENABLE_MULTISHOT_POLL) != 0;
+  if (create) preferred_su_port_create = create;
+  if (start) preferred_su_clone_start = start;
+}
 
-#if SU_HAVE_PTHREADS
-    self->sup_tid = pthread_self();
-#endif
+void su_port_set_system_preferences(char const *name)
+{
+  su_port_create_f *create = preferred_su_port_create;
+  su_clone_start_f *start = preferred_su_clone_start;
 
+  if (name == NULL)
+      ;
 #if HAVE_EPOLL
-    self->sup_epoll = epoll_create(su_root_size_hint);
-    if (self->sup_epoll == -1)
-      SU_DEBUG_3(("su_port(%p): epoll_create(): %s\n", self, strerror(errno)));
-    else
-      SU_DEBUG_9(("su_port(%p): epoll_create() => %u: OK\n",
-                 self, self->sup_epoll));
+  else if (strcmp(name, "epoll") == 0) {
+    create = su_epoll_port_create;
+    start = su_epoll_clone_start;
+  }
 #endif
-  
-#if SU_HAVE_MBOX
-#if HAVE_SOCKETPAIR
-#if defined(AF_LOCAL)
-    af = AF_LOCAL;
-#else
-    af = AF_UNIX;
+#if HAVE_KQUEUE
+  else if (strcmp(name, "kqueue") == 0) {
+    create = su_kqueue_port_create;
+    start = su_kqueue_clone_start;
+  }
 #endif
-    if (socketpair(af, SOCK_STREAM, 0, self->sup_mbox) == -1) {
-      why = "su_port_init: socketpair"; goto error;
-    }
-
-    mb = self->sup_mbox[0];
-    su_setblocking(self->sup_mbox[0], 0);
-    su_setblocking(self->sup_mbox[1], 0);
-#else
-    {
-      struct sockaddr_in sin = { sizeof(struct sockaddr_in), 0 };
-      socklen_t sinsize = sizeof sin;
-      struct sockaddr *sa = (struct sockaddr *)&sin;
-
-      af = PF_INET;
-
-      self->sup_mbox[0] = mb = su_socket(af, SOCK_DGRAM, IPPROTO_UDP);
-      if (mb == INVALID_SOCKET) {
-       why = "su_port_init: socket"; goto error;
-      }
-  
-      sin.sin_family = AF_INET;
-      sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* 127.1 */
-      
-      /* Get a port for us */
-      if (bind(mb, sa, sizeof sin) == -1) {
-       why = "su_port_init: bind"; goto error;
-      }
-
-      if (getsockname(mb, sa, &sinsize) == -1) {
-       why = "su_port_init: getsockname"; goto error;
-      }
-    
-      if (connect(mb, sa, sinsize) == -1) {
-       why = "su_port_init: connect"; goto error;
-      }
-    }
-#endif    
-
-    if (su_wait_create(&self->sup_mbox_wait, mb, SU_WAIT_IN) == -1) {
-      why = "su_port_init: su_wait_create"; goto error;
-    }
-
-    if (su_port_register(self, NULL, &self->sup_mbox_wait, su_port_wakeup, 
-                        (su_wakeup_arg_t *)self->sup_mbox, 0)
-       == -1) {
-      why = "su_port_create: su_port_register"; goto error;
-    }
-
-    SU_DEBUG_9(("su_port_create() returns %p\n", self));
-
-    return self;
-
-  error:
-    su_perror(why);
-    su_port_destroy(self), self = NULL;
+#if HAVE_SYS_DEVPOLL_H
+  else if (strcmp(name, "devpoll") == 0) {
+    create = su_devpoll_port_create;
+    start = su_devpoll_clone_start;
+  }
 #endif
+#if HAVE_POLL_PORT
+  else if (strcmp(name, "poll") == 0) {
+    create = su_poll_port_create;
+    start = su_poll_clone_start;
   }
-
-  SU_DEBUG_9(("su_port_create() returns %p\n", self));
-
-  return self;
-}
-
-/** @internal Destroy a port. */
-void su_port_destroy(su_port_t *self)
-{
-  assert(self);
-
-  SU_DEBUG_9(("su_port_destroy() called\n"));
-
-#if SU_HAVE_MBOX
-  if (self->sup_mbox[0] != INVALID_SOCKET) {
-    su_port_unregister(self, NULL, &self->sup_mbox_wait, NULL, 
-                      (su_wakeup_arg_t *)self->sup_mbox);
-    su_wait_destroy(&self->sup_mbox_wait);
-    su_close(self->sup_mbox[0]); self->sup_mbox[0] = INVALID_SOCKET;
-#if HAVE_SOCKETPAIR
-    su_close(self->sup_mbox[1]); self->sup_mbox[1] = INVALID_SOCKET;
 #endif
-    SU_DEBUG_9(("su_port_destroy() close mailbox\n"));
+#if HAVE_WIN32
+  else if (strcasecmp(name, "wsaevent") == 0) {
+    create = su_wsaevent_port_create;
+    start = su_wsaevent_clone_start;
+  }
+#elif HAVE_SELECT
+  else if (strcmp(name, "select") == 0) {
+    create = su_select_port_create;
+    start = su_select_clone_start;
   }
 #endif
-  if (self->sup_waits) 
-    free(self->sup_waits), self->sup_waits = NULL;
-  if (self->sup_wait_cbs)
-    free(self->sup_wait_cbs), self->sup_wait_cbs = NULL;
-  if (self->sup_wait_args)
-    free(self->sup_wait_args), self->sup_wait_args = NULL;
-  if (self->sup_wait_roots)
-    free(self->sup_wait_roots), self->sup_wait_roots = NULL;
-  if (self->sup_reverses)
-    free(self->sup_reverses), self->sup_reverses = NULL;
-  if (self->sup_indices)
-    free(self->sup_indices), self->sup_indices = NULL;
 
-  SU_DEBUG_9(("su_port_destroy() freed registrations\n"));
+  if (create == NULL) 
+    create = su_default_port_create;
 
-  su_home_zap(self->sup_home);
+  if (!preferred_su_port_create ||
+      preferred_su_port_create == su_default_port_create) 
+    preferred_su_port_create = create;
 
-  SU_DEBUG_9(("su_port_destroy() returns\n"));
+  if (start == NULL)
+    start = su_default_clone_start;
 
+  if (!preferred_su_clone_start || 
+      preferred_su_clone_start == su_default_clone_start)
+    preferred_su_clone_start = start;
 }
 
-static void su_port_lock(su_port_t *self, char const *who)
-{
-  SU_PORT_LOCK(self, who);
-}
-
-static void su_port_unlock(su_port_t *self, char const *who)
-{
-  SU_PORT_UNLOCK(self, who);
-}
-
-static void su_port_incref(su_port_t *self, char const *who)
-{
-  SU_PORT_INCREF(self, who);
-}
-
-static void su_port_decref(su_port_t *self, int blocking, char const *who)
+/** Create the preferred su_port_t implementation. */
+su_port_t *su_port_create(void)
 {
-  if (blocking)
-    SU_PORT_ZAPREF(self, who);
-  else
-    SU_PORT_DECREF(self, who);
-}
+  if (preferred_su_port_create == NULL)
+    su_port_set_system_preferences(getenv("SU_PORT"));
 
-static struct _GSource *su_port_gsource(su_port_t *self)
-{
-  return NULL;
+  return preferred_su_port_create();
 }
 
-#if SU_HAVE_MBOX
-/** @internal Message box wakeup function. */
-static int su_port_wakeup(su_root_magic_t *magic, /* NULL */
-                         su_wait_t *w,
-                         su_wakeup_arg_t *arg)
+/** Return name of the su_port_t instance. */
+char const *su_port_name(su_port_t const *port)
 {
-  char buf[32];
-  su_socket_t s = *(su_socket_t *)arg;
-  su_wait_events(w, s);
-  recv(s, buf, sizeof(buf), 0);
-  return 0;
-}
-#endif
-
-/** @internal Send a message to the port. */
-int su_port_send(su_port_t *self, su_msg_r rmsg)
-{
-  if (self) {
-    int wakeup;
-
-    SU_PORT_LOCK(self, "su_port_send");
-    
-    wakeup = self->sup_head == NULL;
-
-    *self->sup_tail = rmsg[0]; rmsg[0] = NULL;
-    self->sup_tail = &(*self->sup_tail)->sum_next;
-
-#if SU_HAVE_MBOX
-    /* if (!pthread_equal(pthread_self(), self->sup_tid)) */
-    if (wakeup)
-    {
-      assert(self->sup_mbox[MBOX_SEND] != INVALID_SOCKET);
-
-      if (send(self->sup_mbox[MBOX_SEND], "X", 1, 0) == -1) {
-#if HAVE_SOCKETPAIR
-       if (su_errno() != EWOULDBLOCK)
-#endif
-         su_perror("su_msg_send: send()");
-      }
-    }
-#endif
-
-    SU_PORT_UNLOCK(self, "su_port_send");
-
-    return 0;
-  }
-  else {
-    su_msg_destroy(rmsg);
-    return -1;
-  }
+  return port->sup_vtable->su_port_name(port);
 }
 
-/** @internal
- * Execute the messages in the incoming queue until the queue is empty..
- *
- * @param self - pointer to a port object
- *
- * @retval Number of messages sent
+/* ========================================================================
+ * su_clone_t
  */
-int su_port_getmsgs(su_port_t *self)
-{
-  int n = 0;
-
-  if (self->sup_head) {
-    su_msg_f f;
-    su_msg_t *msg, *queue;
-
-    SU_PORT_LOCK(self, "su_port_getmsgs");
-
-    queue = self->sup_head;
-    self->sup_tail = &self->sup_head;
-    self->sup_head = NULL;
 
-    SU_PORT_UNLOCK(self, "su_port_getmsgs");
-
-    for (msg = queue; msg; msg = queue) {
-      queue = msg->sum_next;
-      msg->sum_next = NULL;
-
-      f = msg->sum_func;
-      if (f) 
-       f(SU_ROOT_MAGIC(msg->sum_to->sut_root), &msg, msg->sum_data);
-      su_msg_delivery_report(&msg);
-      n++;
-    }
-
-    /* Check for wait events that may have been generated by messages */
-    su_port_wait_events(self, 0);
-  }
-
-  return n;
-}
-
-/** @internal
- *
- *  Register a @c su_wait_t object. The wait object, a callback function and
- *  a argument pointer is stored in the port object.  The callback function
- *  will be called when the wait object is signaled.
- *
- *  Please note if identical wait objects are inserted, only first one is
- *  ever signalled.
+/**@ingroup su_wait
  * 
- * @param self      pointer to port
- * @param root      pointer to root object
- * @param waits             pointer to wait object
- * @param callback   callback function pointer
- * @param arg       argument given to callback function when it is invoked
- * @param priority   relative priority of the wait object 
- *              (0 is normal, 1 important, 2 realtime)
+ * @page su_clone_t Clone Objects
+ *
+ * The process may be divided into many tasks via cloning. Several tasks may
+ * run in context of one thread, or each task may be run by its own thread. 
+ * However, only a single thread can execute code within a task. There can
+ * be a 1-to-N mapping from thread to tasks. Thus, software using tasks can
+ * be executed by multiple threads in a multithreaded environment and by a
+ * single thread in a singlethreaded environment.
  * 
- * @return
- *   Positive index of the wait object, 
- *   or -1 upon an error.
- */
-int su_port_register(su_port_t *self,
-                    su_root_t *root, 
-                    su_wait_t *wait, 
-                    su_wakeup_f callback,
-                    su_wakeup_arg_t *arg,
-                    int priority)
-{
-  int i, j, n;
-
-  assert(SU_PORT_OWN_THREAD(self));
-
-  n = self->sup_n_waits;
-
-  if (n >= SU_WAIT_MAX)
-    return su_seterrno(ENOMEM);
-
-  if (n >= self->sup_size_waits) {
-    /* Reallocate size arrays */
-    int size;
-    int *indices;
-    int *reverses;
-    su_wait_t *waits;
-    su_wakeup_f *wait_cbs;
-    su_wakeup_arg_t **wait_args;
-    su_root_t **wait_tasks;
-
-    if (self->sup_size_waits == 0)
-      size = su_root_size_hint;
-    else 
-      size = 2 * self->sup_size_waits;
-
-    if (size < SU_WAIT_MIN)
-      size = SU_WAIT_MIN;
-
-    /* Too large */
-    if (-3 - size > 0)
-      return (errno = ENOMEM), -1;
-
-    indices = realloc(self->sup_indices, (size + 1) * sizeof(*indices));
-    if (indices) {
-      self->sup_indices = indices;
-
-      if (self->sup_size_waits == 0)
-       indices[0] = -1;
-
-      for (i = self->sup_size_waits + 1; i <= size; i++)
-       indices[i] = -1 - i;
-    }
-
-    reverses = realloc(self->sup_reverses, size * sizeof(*waits));
-    if (reverses) {
-      for (i = self->sup_size_waits; i < size; i++)
-       reverses[i] = -1;
-      self->sup_reverses = reverses;
-    }
-      
-    waits = realloc(self->sup_waits, size * sizeof(*waits));
-    if (waits)
-      self->sup_waits = waits;
-
-    wait_cbs = realloc(self->sup_wait_cbs, size * sizeof(*wait_cbs));
-    if (wait_cbs)
-      self->sup_wait_cbs = wait_cbs;
-
-    wait_args = realloc(self->sup_wait_args, size * sizeof(*wait_args));
-    if (wait_args)
-      self->sup_wait_args = wait_args;
-
-    /* Add sup_wait_roots array, if needed */
-    wait_tasks = realloc(self->sup_wait_roots, size * sizeof(*wait_tasks));
-    if (wait_tasks) 
-      self->sup_wait_roots = wait_tasks;
-
-    if (!(indices && 
-         reverses && waits && wait_cbs && wait_args && wait_tasks)) {
-      return -1;
-    }
-
-    self->sup_size_waits = size;
-  }
-
-  i = -self->sup_indices[0]; assert(i <= self->sup_size_waits);
-
-#if HAVE_EPOLL
-  if (self->sup_epoll != -1) {
-    struct epoll_event ev;
-
-    ev.events = POLL2EPOLL(wait->events);
-    ev.data.u64 = 0;
-    ev.data.u32 = (uint32_t)i;
-
-    if (epoll_ctl(self->sup_epoll, EPOLL_CTL_ADD, wait->fd, &ev) == -1) {
-      SU_DEBUG_0(("EPOLL_CTL_ADD(%u, %u) failed: %s\n",
-                 wait->fd, ev.events, strerror(errno)));
-      return -1;
-    }
-  }
-  else
-#endif  
-  if (priority > 0) {
-    /* Insert */
-    for (n = self->sup_n_waits; n > 0; n--) {
-      j = self->sup_reverses[n-1]; assert(self->sup_indices[j] == n - 1);
-      self->sup_indices[j] = n;
-      self->sup_reverses[n] = j;
-      self->sup_waits[n] = self->sup_waits[n-1];
-      self->sup_wait_cbs[n] = self->sup_wait_cbs[n-1];
-      self->sup_wait_args[n] = self->sup_wait_args[n-1];
-      self->sup_wait_roots[n] = self->sup_wait_roots[n-1];     
-    }
-
-    self->sup_pri_offset++;
-  }
-  else {
-    /* Append - no need to move anything */
-    n = self->sup_n_waits;
-  }
-
-  self->sup_n_waits++;
-
-  self->sup_indices[0] = self->sup_indices[i];  /* Free index */
-  self->sup_indices[i] = n;
-
-  self->sup_reverses[n] = i;
-  self->sup_waits[n] = *wait;
-  self->sup_wait_cbs[n] = callback;
-  self->sup_wait_args[n] = arg;
-  self->sup_wait_roots[n] = root;
-
-  self->sup_registers++;
-
-  /* Just like epoll, we return -1 or positive integer */
-
-  return i;
-}
-
-/** Deregister a su_wait_t object. */
-static
-int su_port_deregister0(su_port_t *self, int i)
-{
-  int n, N, *indices, *reverses;
-
-  indices = self->sup_indices;
-  reverses = self->sup_reverses;
-
-  n = indices[i]; assert(n >= 0);
-
-#if HAVE_EPOLL
-  if (self->sup_epoll != -1) {
-    su_wait_t *wait = &self->sup_waits[n];
-    struct epoll_event ev;
-
-    ev.events = POLL2EPOLL(wait->events);
-    ev.data.u64 = (uint64_t)0;
-    ev.data.u32 = (uint32_t)i;
-
-    if (epoll_ctl(self->sup_epoll, EPOLL_CTL_DEL, wait->fd, &ev) == -1) {
-      SU_DEBUG_1(("su_port(%p): EPOLL_CTL_DEL(%u): %s\n", self, 
-                 wait->fd, su_strerror(su_errno())));
-    }
-  }
-#endif
-
-  N = --self->sup_n_waits;
-  
-  if (n < self->sup_pri_offset) {
-    int j = --self->sup_pri_offset;
-    if (n != j) {
-      assert(reverses[j] > 0);
-      assert(indices[reverses[j]] == j);
-      indices[reverses[j]] = n;
-      reverses[n] = reverses[j];
-
-      self->sup_waits[n] = self->sup_waits[j];
-      self->sup_wait_cbs[n] = self->sup_wait_cbs[j];
-      self->sup_wait_args[n] = self->sup_wait_args[j];
-      self->sup_wait_roots[n] = self->sup_wait_roots[j];
-      n = j;
-    }
-  }
-
-  if (n < N) {
-    assert(reverses[N] > 0);
-    assert(indices[reverses[N]] == N);
-
-    indices[reverses[N]] = n;
-    reverses[n] = reverses[N];
-
-    self->sup_waits[n] = self->sup_waits[N];
-    self->sup_wait_cbs[n] = self->sup_wait_cbs[N];
-    self->sup_wait_args[n] = self->sup_wait_args[N];
-    self->sup_wait_roots[n] = self->sup_wait_roots[N];
-    n = N;
-  }
-
-  reverses[n] = -1;
-  memset(&self->sup_waits[n], 0, sizeof self->sup_waits[n]);
-  self->sup_wait_cbs[n] = NULL;
-  self->sup_wait_args[n] = NULL;
-  self->sup_wait_roots[n] = NULL;
-  
-  indices[i] = indices[0];
-  indices[0] = -i;
-
-  self->sup_registers++;
-
-  return i;
-}
-
-
-/** Unregister a su_wait_t object.
- *  
- *  The function su_port_unregister() unregisters a su_wait_t object. The
- *  wait object, a callback function and a argument are removed from the
- *  port object.
+ * The clones are useful for handling tasks that can be executed by a
+ * separate threads, but which do not block excessively. When threads are
+ * not available or they are not needed, clones can also be run in a
+ * single-threaded mode. Running in single-threaded mode is especially
+ * useful while debugging.
  * 
- * @param self     - pointer to port object
- * @param root     - pointer to root object
- * @param wait     - pointer to wait object
- * @param callback - callback function pointer (may be NULL)
- * @param arg      - argument given to callback function when it is invoked 
- *                   (may be NULL)
- *
- * @deprecated Use su_port_deregister() instead. 
- *
- * @return Nonzero index of the wait object, or -1 upon an error.
+ * A clone task is created with function su_clone_start(). Each clone has
+ * its own root object (su_root_t), which holds a context pointer
+ * (su_root_magic_t *). The context object can be different from that of 
+ * parent task.
+ *
+ * When a clone is started, the clone initialization function is called. The
+ * initialization function should do whatever initialization there is to be
+ * performed, register I/O events and timers, and then return. If the
+ * initialization is successful, the clone task reverts to run the event
+ * loop and invoking the event callbacks until its parent stops it by
+ * calling su_clone_wait() which invokes the deinit function. The clone task
+ * is destroyed when the deinit function returns. 
+ *
+ * The public API consists of following functions:
+ *    - su_clone_start()
+ *    - su_clone_task()
+ *    - su_clone_wait()
+ *    - su_clone_forget()
+ *
+ * @note 
+ * There is only one event loop for each thread which can be shared by
+ * multiple clone tasks. Therefore, the clone tasks can not explicitly run
+ * or step the event loop, but they are limited to event callbacks. A clone
+ * task may not call su_root_break(), su_root_run() or su_root_step().
  */
-int su_port_unregister(su_port_t *self,
-                      su_root_t *root, 
-                      su_wait_t *wait, 
-                      su_wakeup_f callback, /* XXX - ignored */
-                      su_wakeup_arg_t *arg)
-{
-  int n, N;
 
-  assert(self);
-  assert(SU_PORT_OWN_THREAD(self));
-
-  N = self->sup_n_waits;
-
-  for (n = 0; n < N; n++) {
-    if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
-      return su_port_deregister0(self, self->sup_reverses[n]);
-    }
-  }
-
-  su_seterrno(ENOENT);
-
-  return -1;
+static int su_root_init_nothing(su_root_t *root, su_root_magic_t *magic)
+{
+  return 0;
 }
 
-/** Deregister a su_wait_t object.
- *  
- *  The function su_port_deregister() deregisters a su_wait_t registrattion. 
- *  The wait object, a callback function and a argument are removed from the
- *  port object.
- * 
- * @param self     - pointer to port object
- * @param i        - registration index
- * 
- * @return Index of the wait object, or -1 upon an error.
- */
-int su_port_deregister(su_port_t *self, int i)
+static void su_root_deinit_nothing(su_root_t *root, su_root_magic_t *magic)
 {
-  su_wait_t wait[1] = { SU_WAIT_INIT };
-  int retval;
-
-  assert(self);
-  assert(SU_PORT_OWN_THREAD(self));
-
-  if (i <= 0 || i > self->sup_size_waits)
-    return su_seterrno(EBADF);
-
-  if (self->sup_indices[i] < 0)
-    return su_seterrno(EBADF);
-    
-  retval = su_port_deregister0(self, i);
-
-  su_wait_destroy(wait);
-
-  return retval;
 }
 
-
-/** @internal
- * Unregister all su_wait_t objects.
- *
- * The function su_port_unregister_all() unregisters all su_wait_t objects
- * and destroys all queued timers associated with given root object.
- * 
- * @param  self     - pointer to port object
- * @param  root     - pointer to root object
- * 
- * @return Number of wait objects removed.
+/** Start a clone task.
+ *
+ * Allocate and initialize a sub-task. Depending on the su_root_threading()
+ * settings, a separate thread may be created to execute the sub-task. The
+ * sub-task is represented by clone handle to the rest of the application. 
+ * The function su_clone_start() returns the clone handle in @a
+ * return_clone. The clone handle is used to communicate with the newly
+ * created clone task using messages.
+ *
+ * A new #su_root_t object is created for the sub-task with the @a magic as
+ * the root context pointer. Because the sub-task may or may not have its
+ * own thread, all its activity must be scheduled via this root object. In
+ * other words, the sub-task can be schedule
+ * -# I/O events with su_root_register()
+ * -# timers with su_timer_set(), su_timer_set_at() or su_timer_run()
+ * -# messages with su_msg_send().
+ *
+ * Messages can also be used to pass information between tasks or threads.
+ *
+ * In multi-threaded implementation, su_clone_start() launches a new thread,
+ * and the initialization routine is executed by this newly created thread. 
+ * The calling thread blocks until the initialization routine completes. If
+ * the initialization routine returns #su_success (0), the sub-task is
+ * considered to be created successfully. After the successful
+ * initialization, the sub-task continues to execeute the function
+ * su_root_run().
+ *
+ * In single-threaded implementations, just a new root object is created. 
+ * The initialization routine is called directly from su_clone_start().
+ *
+ * If the initalization function @a init fails, the sub-task (either the
+ * newly created thread or the current thread executing the su_clone_start()
+ * function) calls the deinitialization function, and su_clone_start()
+ * returns NULL.
+ *
+ * @param parent   root to be cloned
+ * @param return_clone reference to a clone [OUT]
+ * @param magic    pointer to user data
+ * @param init     initialization function
+ * @param deinit   deinitialization function
+ *
+ * @return 0 if successfull, -1 upon an error.
+ *
+ * @note Earlier documentation mentioned that @a parent could be NULL. That
+ * feature has never been implemented, however.
+ *
+ * @sa su_root_threading(), su_clone_task(), su_clone_stop(), su_clone_wait(),
+ * su_clone_forget().
  */
-int su_port_unregister_all(su_port_t *self, 
-                          su_root_t *root)
+int su_clone_start(su_root_t *parent,
+                  su_clone_r return_clone,
+                  su_root_magic_t *magic,
+                  su_root_init_f init,
+                  su_root_deinit_f deinit)
 {
-  int i, j, index, N;
-  int             *indices, *reverses;
-  su_wait_t       *waits;
-  su_wakeup_f     *wait_cbs;
-  su_wakeup_arg_t**wait_args;
-  su_root_t      **wait_roots;
-
-  assert(SU_PORT_OWN_THREAD(self));
-
-  N          = self->sup_n_waits;
-  indices    = self->sup_indices;
-  reverses   = self->sup_reverses;
-  waits      = self->sup_waits; 
-  wait_cbs   = self->sup_wait_cbs; 
-  wait_args  = self->sup_wait_args;
-  wait_roots = self->sup_wait_roots; 
-  
-  for (i = j = 0; i < N; i++) {
-    index = reverses[i]; assert(index > 0 && indices[index] == i);
+  su_port_vtable_t const *svp;
 
-    if (wait_roots[i] == root) {
-      /* XXX - we should free all resources associated with this, too */
-#if HAVE_EPOLL
-      if (self->sup_epoll != -1) {
-       int fd = waits[i].fd;
-       struct epoll_event ev;
-
-       ev.events = POLL2EPOLL(waits[i].events);
-       ev.data.u64 = (uint64_t)0;
-       ev.data.u32 = (uint32_t)index;
-
-       if (epoll_ctl(self->sup_epoll, EPOLL_CTL_DEL, fd, &ev) == -1) {
-         SU_DEBUG_1(("EPOLL_CTL_DEL(%u): %s\n", 
-                     waits[i].fd, su_strerror(su_errno())));
-       }
-      }
-#endif
-      if (i < self->sup_pri_offset)
-       self->sup_pri_offset--;
-
-      indices[index] = indices[0];
-      indices[0] = -index;
-      continue;
-    }
+  if (init == NULL)
+    init = su_root_init_nothing;
+  if (deinit == NULL)
+    deinit = su_root_deinit_nothing;
 
-    if (i != j) {
-      indices[index] = j;
-      reverses[j]   = reverses[i];
-      waits[j]      = waits[i];
-      wait_cbs[j]   = wait_cbs[i];
-      wait_args[j]  = wait_args[i];
-      wait_roots[j] = wait_roots[i];
-    }
     
-    j++;
-  }
-  
-  for (i = j; i < N; i++) {
-    reverses[i] = -1;
-    wait_cbs[i] = NULL;
-    wait_args[i] = NULL;
-    wait_roots[i] = NULL;
+  if (parent == NULL || parent->sur_threading) {
+    if (preferred_su_clone_start == NULL)
+      su_port_set_system_preferences(getenv("SU_PORT"));
+    return preferred_su_clone_start(parent, return_clone, magic, init, deinit);
   }
-  memset(&waits[j], 0, (char *)&waits[N] - (char *)&waits[j]);
 
-  self->sup_n_waits = j;
-  self->sup_registers++;
+  svp = parent->sur_task->sut_port->sup_vtable;
 
-  return N - j;
+  if (svp->su_port_start_shared == NULL)
+    return su_seterrno(EINVAL);
+
+  /* Return a task sharing the same port. */
+  return svp->su_port_start_shared(parent, return_clone, magic, init, deinit);
 }
 
-/**Set mask for a registered event. @internal
- *
- * The function su_port_eventmask() sets the mask describing events that can
- * signal the registered callback.
- *
- * @param port   pointer to port object
- * @param index  registration index
- * @param socket socket
- * @param events new event mask
+/** Get reference to a clone task.
+ * 
+ * @param clone Clone pointer
  *
- * @retval 0 when successful,
- * @retval -1 upon an error.
+ * @return A reference to the task structure of the clone.
  */
-int su_port_eventmask(su_port_t *self, int index, int socket, int events)
+_su_task_r su_clone_task(su_clone_r clone)
 {
-  int n;
-  assert(self);
-  assert(SU_PORT_OWN_THREAD(self));
-
-  if (index <= 0 || index > self->sup_size_waits)
-    return su_seterrno(EBADF);
-  n = self->sup_indices[index];
-  if (n < 0)
-    return su_seterrno(EBADF);
-
-#if HAVE_EPOLL
-  if (self->sup_epoll != -1) {
-    su_wait_t *wait = &self->sup_waits[n];
-    struct epoll_event ev;
-
-    wait->events = events;
-
-    ev.events = POLL2EPOLL(events);
-    ev.data.u64 = (uint64_t)0;
-    ev.data.u32 = (uint32_t)index;
-
-    if (epoll_ctl(self->sup_epoll, EPOLL_CTL_MOD, wait->fd, &ev) == -1) {
-      SU_DEBUG_1(("su_port(%p): EPOLL_CTL_MOD(%u): %s\n", self, 
-                 wait->fd, su_strerror(su_errno())));
-      return -1;
-    }
-  }
-#endif
-
-  return su_wait_mask(&self->sup_waits[n], socket, events);
+  return su_msg_to(clone);
 }
 
-#if 0
-/** @internal
- *
- * Copies the su_wait_t objects from the port. The number of wait objects
- * can be found out by calling su_port_query() with @a n_waits as zero.
+/**Forget the clone.
  * 
- * @note This function is called only by friends.
+ * Normally, the clone task executes until it is stopped.  If the parent
+ * task does not need to stop the task, it can "forget" the clone.  The
+ * clone exits independently of the parent task.
  *
- * @param self     - pointer to port object
- * @param waits    - pointer to array to which wait objects are copied
- * @param n_waits  - number of wait objects fitting in array waits
- *
- * @return Number of wait objects, or 0 upon an error.
+ * @param rclone Reference to the clone.
  */
-unsigned su_port_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
+void su_clone_forget(su_clone_r rclone)
 {
-  unsigned n;
-
-  assert(SU_PORT_OWN_THREAD(self));
-
-  n = self->sup_n_waits;
-
-  if (n_waits != 0) {
-    if (waits && n_waits >= n)
-      memcpy(waits, self->sup_waits, n * sizeof(*waits));
-    else
-      n = 0;
-  }
-
-  return n;
+  su_msg_destroy(rclone);
 }
-#endif
 
-/** @internal Enable multishot mode.
- *
- * The function su_port_multishot() enables, disables or queries the
- * multishot mode for the port. The multishot mode determines how the events
- * are scheduled by port. If multishot mode is enabled, port serves all the
- * sockets that have received network events. If it is disables, only first
- * socket event is served.
+/** Stop the clone.
  *
- * @param self      pointer to port object
- * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * This can used only if clone task has sent no report messages (messages
+ * with delivery report sent back to clone).
  * 
- * @retval 0 multishot mode is disabled
- * @retval 1 multishot mode is enabled
- * @retval -1 an error occurred
+ * @deprecated. Use su_clone_wait().
  */
-int su_port_multishot(su_port_t *self, int multishot)
+void su_clone_stop(su_clone_r rclone)
 {
-  if (multishot < 0)
-    return self->sup_multishot;
-  else if (multishot == 0 || multishot == 1)
-    return self->sup_multishot = multishot;
-  else 
-    return (errno = EINVAL), -1;
+  su_msg_send(rclone);
 }
 
-/** @internal Enable threadsafe operation. */
-static
-int su_port_threadsafe(su_port_t *port)
-{
-  return su_home_threadsafe(port->sup_home);
-}
-
-/** @internal Main loop.
- * 
- * The function @c su_port_run() waits for wait objects and the timers
- * associated with the port object.  When any wait object is signaled or
- * timer is expired, it invokes the callbacks, and returns waiting.
- * 
- * The function @c su_port_run() runs until @c su_port_break() is called
- * from a callback.
- * 
- * @param self     pointer to port object
- * 
+/** Stop a clone and wait until it is has completed.
+ *
+ * The function su_clone_wait() is used to stop the clone task and wait
+ * until it has cleaned up. The clone task is destroyed asynchronously. The
+ * parent sends a message to clone, clone deinitializes itself and then
+ * replies. After the reply message is received by the parent, it will send
+ * a third message back to clone.
+ *
+ * The parent destroy all messages to or from clone task before calling
+ * su_clone_wait(). The parent task may not send any messages to the clone
+ * after calling su_clone_wait(). The su_clone_wait() function blocks until
+ * the cloned task is destroyed. During that time, the parent task must be
+ * prepared to process all the messages sent by clone task. This includes
+ * all the messages sent by clone before destroy the message reached the
+ * clone.
  */
-void su_port_run(su_port_t *self)
+void su_clone_wait(su_root_t *root, su_clone_r rclone)
 {
-  su_duration_t tout = 0;
-
-  assert(SU_PORT_OWN_THREAD(self));
-
-  for (self->sup_running = 1; self->sup_running;) {
-    tout = 2000;
-
-    if (self->sup_prepoll)
-      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
-
-    if (self->sup_head)
-      su_port_getmsgs(self);
-
-    if (self->sup_timers)
-      su_timer_expire(&self->sup_timers, &tout, su_now());
-
-    if (!self->sup_running)
-      break;
-
-    if (self->sup_head)      /* if there are messages do a quick wait */
-      tout = 0;
-
-    su_port_wait_events(self, tout);
+  if (rclone[0]) {
+    assert(root == NULL || root == su_msg_from(rclone)->sut_root);
+    su_port_wait(rclone);
   }
 }
 
-#if tuning
-/* This version can help tuning... */
-void su_port_run_tune(su_port_t *self)
-{
-  int i;
-  int timers = 0, messages = 0, events = 0;
-  su_duration_t tout = 0, tout0;
-  su_time_t started = su_now(), woken = started, bedtime = woken;
-
-  assert(SU_PORT_OWN_THREAD(self));
-
-  for (self->sup_running = 1; self->sup_running;) {
-    tout0 = tout, tout = 2000;
-
-    timers = 0, messages = 0;
-
-    if (self->sup_prepoll)
-      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
-
-    if (self->sup_head)
-      messages = su_port_getmsgs(self);
-
-    if (self->sup_timers)
-      timers = su_timer_expire(&self->sup_timers, &tout, su_now());
-
-    if (!self->sup_running)
-      break;
-
-    if (self->sup_head)      /* if there are messages do a quick wait */
-      tout = 0;
-
-    bedtime = su_now();
-
-    events = su_port_wait_events(self, tout);
-
-    woken = su_now();
-
-    if (messages || timers || events)
-      SU_DEBUG_1(("su_port_run(%p): %.6f: %u messages %u timers %u "
-                 "events slept %.6f/%.3f\n",
-                 self, su_time_diff(woken, started), messages, timers, events,
-                 su_time_diff(woken, bedtime), tout0 * 1e-3));
-
-    if (!self->sup_running)
-      break;
-  }
-}
-#endif
-
-/** @internal
- * The function @c su_port_break() is used to terminate execution of @c
- * su_port_run(). It can be called from a callback function.
- * 
- * @param self     pointer to port
- * 
- */
-void su_port_break(su_port_t *self)
-{
-  self->sup_running = 0; 
-}
-
-/** @internal
- * The function @c su_port_wait_events() is used to poll() for wait objects
+/** Pause a clone.
  *
- * @param self     pointer to port
- * @param tout     timeout in milliseconds
+ * Obtain an exclusive lock on clone's private data.
  *
- * @return number of events handled
+ * @retval 0 if successful (and clone is paused)
+ * @retval -1 upon an error
+ *
+ * @deprecated Never implemented.
  */
-static
-int su_port_wait_events(su_port_t *self, su_duration_t tout)
+int su_clone_pause(su_clone_r rclone)
 {
-  int i, events = 0;
-  su_wait_t *waits = self->sup_waits;
-  int n = self->sup_n_waits;
-  su_root_t *root;
-#if HAVE_POLL
-  unsigned version = self->sup_registers;
-#endif
-#if HAVE_EPOLL
-  
-  if (self->sup_epoll != -1) {
-    int const M = 4;
-    struct epoll_event ev[M];
-    int j, index;
-    int *indices = self->sup_indices;
-    
-    n = epoll_wait(self->sup_epoll, ev, self->sup_multishot ? M : 1, tout);
-
-    assert(n <= M);
+#if 0
+  su_root_t *cloneroot = su_task_root(su_msg_to(rclone));
 
-    for (j = 0; j < n; j++) {
-      su_root_t *root;
-      su_root_magic_t *magic;
+  if (!cloneroot)
+    return (errno = EFAULT), -1;
 
-      if (!ev[j].events || ev[j].data.u32 > INDEX_MAX)
-       continue;
-      index = (int)ev[j].data.u32;
-      assert(index > 0 && index <= self->sup_size_waits);
-      i = indices[index]; assert(i >= 0 && i <= self->sup_n_waits);
-      root = self->sup_wait_roots[i];
-      magic = root ? su_root_magic(root) : NULL;
-      waits[i].revents = ev[j].events;
-      self->sup_wait_cbs[i](magic, &waits[i], self->sup_wait_args[i]);
-      events++;
-      /* Callback function used su_register()/su_deregister() */
-      if (version != self->sup_registers)
-       break;
-    }
-    
-    return n < 0 ? n : events;
-  }
-#endif
-
-  i = su_wait(waits, (unsigned)n, tout);
+  if (SU_ROOT_OWN_THREAD(cloneroot))
+    /* We own it already */
+    return 0;
 
-  if (i >= 0 && i < n) {
-#if HAVE_POLL                  
-    /* poll() can return events for multiple wait objects */
-    if (self->sup_multishot) {
-      for (; i < n; i++) {
-        if (waits[i].revents) {
-          root = self->sup_wait_roots[i];
-          self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
-                                &waits[i],
-                                self->sup_wait_args[i]);
-          events++;
-          /* Callback function used su_register()/su_deregister() */
-          if (version != self->sup_registers)
-            break;
-        }
-      }
-    }
-#else /* !HAVE_POLL */
-    if (0) {
-    }
+  return su_port_pause(cloneroot->sur_port);
+#else
+  return errno = ENOSYS, -1;
 #endif
-    else {
-      root = self->sup_wait_roots[i];
-      self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
-                            &self->sup_waits[i],
-                            self->sup_wait_args[i]);
-      events++;
-    }
-  }
-
-  return events;
 }
 
-/** @internal 
- * Used to check wait events in callbacks that take lots of time
+/** Resume a clone.
  *
- * This function does a timeout 0 poll() and runs wait objects.
+ * Give up an exclusive lock on clone's private data.
  *
- * @param port     pointer to port
+ * @retval 0 if successful (and clone is resumed)
+ * @retval -1 upon an error
  *
- * @return number of events handled
+ * @deprecated Never implemented.
  */
-static
-int su_port_yield(su_port_t *port)
+int su_clone_resume(su_clone_r rclone)
 {
-  return su_port_wait_events(port, 0);
-}
-
-/** @internal Block until wait object is signaled or timeout.
- *
- * This function waits for wait objects and the timers associated with 
- * the root object.  When any wait object is signaled or timer is
- * expired, it invokes the callbacks. 
- * 
- *   This function returns when a callback has been invoked or @c tout
- *   milliseconds is elapsed. 
- *
- * @param self     pointer to port
- * @param tout     timeout in milliseconds
- * 
- * @return
- *   Milliseconds to the next invocation of timer, or @c SU_WAIT_FOREVER if
- *   there are no active timers.
- */
-su_duration_t su_port_step(su_port_t *self, su_duration_t tout)
-{
-  su_time_t now = su_now();
-
-  assert(SU_PORT_OWN_THREAD(self));
-
-  if (self->sup_prepoll)
-    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
-
-  if (self->sup_head)
-    su_port_getmsgs(self);
-
-  if (self->sup_timers)
-    su_timer_expire(&self->sup_timers, &tout, now);
-
-  /* if there are messages do a quick wait */
-  if (self->sup_head)
-    tout = 0;
-
-  if (su_port_wait_events(self, tout))
-    tout = 0;
-  else
-    tout = SU_WAIT_FOREVER;
-
-  if (self->sup_head)
-    su_port_getmsgs(self);
-
-  if (self->sup_timers)
-    su_timer_expire(&self->sup_timers, &tout, su_now());
+#if 0
+  su_root_t *cloneroot = su_task_root(su_msg_to(rclone));
 
-  if (self->sup_head)
-    tout = 0;
-
-  return tout;
-}
+  if (!cloneroot)
+    return (errno = EFAULT), -1;
 
+  if (SU_ROOT_OWN_THREAD(cloneroot))
+    /* We cannot give it away */
+    return 0;
 
-/** @internal
- * Checks if the calling thread owns the port object.
- *
- * @param self pointer to a port object
- *
- * @retval true (nonzero) if the calling thread owns the port,
- * @retval false (zero) otherwise.
- */
-int su_port_own_thread(su_port_t const *self)
-{
-  return self == NULL || SU_PORT_OWN_THREAD(self);
+  return su_port_resume(cloneroot->sur_port);
+#else
+  return errno = ENOSYS, -1;
+#endif
 }
 
-#if 0
-/** @internal
- *  Prints out the contents of the port.
- *
- * @param self pointer to a port
- * @param f    pointer to a file (if @c NULL, uses @c stdout).
- */
-void su_port_dump(su_port_t const *self, FILE *f)
+void su_port_wait(su_clone_r rclone)
 {
-  int i;
-#define IS_WAIT_IN(x) (((x)->events & SU_WAIT_IN) ? "IN" : "")
-#define IS_WAIT_OUT(x) (((x)->events & SU_WAIT_OUT) ? "OUT" : "")
-#define IS_WAIT_ACCEPT(x) (((x)->events & SU_WAIT_ACCEPT) ? "ACCEPT" : "")
+  su_port_t *cloneport;
 
-  if (f == NULL)
-    f = stdout;
-
-  fprintf(f, "su_port_t at %p:\n", self);
-  fprintf(f, "\tport is%s running\n", self->sup_running ? "" : "not ");
-#if SU_HAVE_PTHREADS
-  fprintf(f, "\tport tid %p\n", (void *)self->sup_tid);
-#endif
-#if SU_HAVE_MBOX
-  fprintf(f, "\tport mbox %d (%s%s%s)\n", self->sup_mbox[0],
-         IS_WAIT_IN(&self->sup_mbox_wait),
-         IS_WAIT_OUT(&self->sup_mbox_wait),
-         IS_WAIT_ACCEPT(&self->sup_mbox_wait));
-#endif
-  fprintf(f, "\t%d wait objects\n", self->sup_n_waits);
-  for (i = 0; i < self->sup_n_waits; i++) {
-    
-  }
+  cloneport = su_msg_to(rclone)->sut_port;
+  cloneport->sup_vtable->su_port_wait(rclone);
 }
 
-#endif
-
-/* =========================================================================
- * Pre-poll() callback
- */
-
-int su_port_add_prepoll(su_port_t *port,
-                       su_root_t *root, 
-                       su_prepoll_f *callback, 
-                       su_prepoll_magic_t *magic)
+int su_port_execute(su_task_r const task,
+                   int (*function)(void *), void *arg,
+                   int *return_value)
 {
-  if (port->sup_prepoll)
-    return -1;
+  if (!task->sut_port->sup_vtable->su_port_execute)
+    return errno = ENOSYS, -1;
 
-  port->sup_prepoll = callback;
-  port->sup_pp_magic = magic;
-  port->sup_pp_root = root;
-
-  return 0;
+  return task->sut_port->sup_vtable->
+    su_port_execute(task, function, arg, return_value);
 }
 
-int su_port_remove_prepoll(su_port_t *port,
-                          su_root_t *root)
+#if notyet && nomore
+int su_port_pause(su_port_t *self)
 {
-  if (port->sup_pp_root != root)
-    return -1;
-
-  port->sup_prepoll = NULL;
-  port->sup_pp_magic = NULL;
-  port->sup_pp_root = NULL;
-
-  return 0;
+  assert(self->sup_vtable->su_port_pause);
+  return self->sup_vtable->su_port_pause(self);
 }
 
-/* =========================================================================
- * Timers
- */
-
-static
-su_timer_t **su_port_timers(su_port_t *self)
+int su_port_resume(su_port_t *self)
 {
-  return &self->sup_timers;
+  assert(self->sup_vtable->su_port_resume);
+  return self->sup_vtable->su_port_resume(self);
 }
+#endif
index 1d13ec15e53e934f6944c31b93d319820b3f5437..21a2ae9b31be4b52b355c83f435bb719f1c9301f 100644 (file)
@@ -86,7 +86,7 @@ struct su_root_s {
 #define SU_ROOT_MAGIC(r) ((r) ? (r)->sur_magic : NULL)
 
 /** Virtual function table for port */
-typedef struct {
+typedef struct su_port_vtable {
   unsigned su_vtable_size;
   void (*su_port_lock)(su_port_t *port, char const *who);
   void (*su_port_unlock)(su_port_t *port, char const *who);
@@ -128,80 +128,114 @@ typedef struct {
   int (*su_port_multishot)(su_port_t *port, int multishot);
 
   int (*su_port_threadsafe)(su_port_t *port);
-  
   /* Extension from > 1.12.0 */
   int (*su_port_yield)(su_port_t *port);
+  /* Extension from >= 1.12.4 */
+  int (*su_port_wait_events)(su_port_t *port, su_duration_t timeout);
+  int (*su_port_getmsgs)(su_port_t *port);
+  /* Extension from >= 1.12.5 */
+  int (*su_port_getmsgs_from)(su_port_t *port, su_port_t *cloneport);
+  char const *(*su_port_name)(su_port_t const *port);
+  int (*su_port_start_shared)(su_root_t *root,
+                             su_clone_r return_clone,
+                             su_root_magic_t *magic,
+                             su_root_init_f init,
+                             su_root_deinit_f deinit);
+  void (*su_port_wait)(su_clone_r rclone);
+  int (*su_port_execute)(su_task_r const task,
+                        int (*function)(void *), void *arg,
+                        int *return_value);  
 } su_port_vtable_t;
 
 SOFIAPUBFUN su_port_t *su_port_create(void)
      __attribute__((__malloc__));
 
+/* Extension from >= 1.12.5 */
+
 SOFIAPUBFUN void su_msg_delivery_report(su_msg_r msg);
 SOFIAPUBFUN su_duration_t su_timer_next_expires(su_timer_t const * t,
                                                su_time_t now);
 SOFIAPUBFUN su_root_t *su_root_create_with_port(su_root_magic_t *magic,
-                                               su_port_t *port);
+                                               su_port_t *port)
+  __attribute__((__malloc__));
+
+/* Extension from >= 1.12.6 */
 
-#if SU_PORT_IMPLEMENTATION
+SOFIAPUBFUN char const *su_port_name(su_port_t const *port);
 
+/* ---------------------------------------------------------------------- */
+
+/* React to multiple events per one poll() to make sure 
+ * that high-priority events can never completely mask other events.
+ * Enabled by default on all platforms except WIN32 */
+#if !defined(WIN32)
+#define SU_ENABLE_MULTISHOT_POLL 1
 #else
-struct su_port_s {
-  su_home_t               sup_home[1];
+#define SU_ENABLE_MULTISHOT_POLL 0
+#endif
+
+/* ---------------------------------------------------------------------- */
+/* Virtual functions */
+
+typedef struct su_virtual_port_s {
+  su_home_t        sup_home[1];
   su_port_vtable_t const *sup_vtable;
-};
+} su_virtual_port_t;
+
+static inline
+su_home_t *su_port_home(su_port_t const *self)
+{
+  return (su_home_t *)self;
+}
 
 static inline
 void su_port_lock(su_port_t *self, char const *who)
 {
-  if (self) self->sup_vtable->su_port_lock(self, who);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base) base->sup_vtable->su_port_lock(self, who);
 }
 
-#define SU_PORT_LOCK(p, f)      (su_port_lock(p, #f))
 static inline
 void su_port_unlock(su_port_t *self, char const *who)
 {
-  if (self) self->sup_vtable->su_port_unlock(self, who);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base) base->sup_vtable->su_port_unlock(self, who);
 }
 
-#define SU_PORT_UNLOCK(p, f)    (su_port_unlock(p, #f))
-
 static inline
 void su_port_incref(su_port_t *self, char const *who)
 {
-  if (self) self->sup_vtable->su_port_incref(self, who);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base) base->sup_vtable->su_port_incref(self, who);
 }
 
-#define SU_PORT_INCREF(p, f)    (su_port_incref(p, #f))
 static inline
 void su_port_decref(su_port_t *self, char const *who)
 {
-  if (self) self->sup_vtable->su_port_decref(self, 0, who);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base) base->sup_vtable->su_port_decref(self, 0, who);
 }
 
-#define SU_PORT_DECREF(p, f)    (su_port_decref(p, #f))
-
 static inline
 void su_port_zapref(su_port_t *self, char const *who)
 {
-  if (self) self->sup_vtable->su_port_decref(self, 1, who);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base) base->sup_vtable->su_port_decref(self, 1, who);
 }
 
-#define SU_PORT_ZAPREF(p, f)    (su_port_zapref(p, #f))
-
 static inline
 struct _GSource *su_port_gsource(su_port_t *self)
 {
-  return self ? self->sup_vtable->su_port_gsource(self) : NULL;
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  return base ? base->sup_vtable->su_port_gsource(self) : NULL;
 }
 
-
 static inline
 int su_port_send(su_port_t *self, su_msg_r rmsg)
 {
-  if (self) 
-    return self->sup_vtable->su_port_send(self, rmsg);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base) 
+    return base->sup_vtable->su_port_send(self, rmsg);
   errno = EINVAL;
   return -1;
 }
@@ -215,8 +249,9 @@ int su_port_register(su_port_t *self,
                     su_wakeup_arg_t *arg,
                     int priority)
 {
-  if (self)
-    return self->sup_vtable->su_port_register(self, root, wait,
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_register(self, root, wait,
                                              callback, arg, priority);
   errno = EINVAL;
   return -1;
@@ -229,8 +264,9 @@ int su_port_unregister(su_port_t *self,
                       su_wakeup_f callback, 
                       su_wakeup_arg_t *arg)
 {
-  if (self)
-    return self->sup_vtable->
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->
       su_port_unregister(self, root, wait, callback, arg);
   errno = EINVAL;
   return -1;
@@ -239,9 +275,9 @@ int su_port_unregister(su_port_t *self,
 static inline
 int su_port_deregister(su_port_t *self, int i)
 {
-  if (self)
-    return self->sup_vtable->
-      su_port_deregister(self, i);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_deregister(self, i);
   errno = EINVAL;
   return -1;
 }
@@ -250,8 +286,9 @@ static inline
 int su_port_unregister_all(su_port_t *self,
                           su_root_t *root)
 {
-  if (self)
-    return self->sup_vtable->
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->
       su_port_unregister_all(self, root);
   errno = EINVAL;
   return -1;
@@ -260,10 +297,11 @@ int su_port_unregister_all(su_port_t *self,
 static inline
 int su_port_eventmask(su_port_t *self, int index, int socket, int events)
 {
-  if (self)
-    return self->sup_vtable->
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->
       su_port_eventmask(self, index, socket, events);
-  assert(self);
+  assert(base);
   errno = EINVAL;
   return -1;
 }
@@ -271,22 +309,25 @@ int su_port_eventmask(su_port_t *self, int index, int socket, int events)
 static inline
 void su_port_run(su_port_t *self)
 {
-  if (self)
-    self->sup_vtable->su_port_run(self);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    base->sup_vtable->su_port_run(self);
 }
 
 static inline
 void su_port_break(su_port_t *self)
 {
-  if (self)
-    self->sup_vtable->su_port_break(self);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    base->sup_vtable->su_port_break(self);
 }
 
 static inline
 su_duration_t su_port_step(su_port_t *self, su_duration_t tout)
 {
-  if (self)
-    return self->sup_vtable->su_port_step(self, tout);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_step(self, tout);
   errno = EINVAL;
   return (su_duration_t)-1;
 }
@@ -295,7 +336,8 @@ su_duration_t su_port_step(su_port_t *self, su_duration_t tout)
 static inline
 int su_port_own_thread(su_port_t const *self)
 {
-  return self == NULL || self->sup_vtable->su_port_own_thread(self);
+  su_virtual_port_t const *base = (su_virtual_port_t *)self;
+  return base == NULL || base->sup_vtable->su_port_own_thread(self);
 }
 
 static inline
@@ -304,8 +346,9 @@ int su_port_add_prepoll(su_port_t *self,
                        su_prepoll_f *prepoll, 
                        su_prepoll_magic_t *magic)
 {
-  if (self)
-    return self->sup_vtable->
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->
       su_port_add_prepoll(self, root, prepoll, magic);
   errno = EINVAL;
   return -1;
@@ -315,8 +358,9 @@ static inline
 int su_port_remove_prepoll(su_port_t *self,
                           su_root_t *root)
 {
-  if (self)
-    return self->sup_vtable->su_port_remove_prepoll(self, root);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_remove_prepoll(self, root);
   errno = EINVAL;
   return -1;
 }
@@ -324,8 +368,9 @@ int su_port_remove_prepoll(su_port_t *self,
 static inline
 su_timer_t **su_port_timers(su_port_t *self)
 {
-  if (self)
-    return self->sup_vtable->su_port_timers(self);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_timers(self);
   errno = EINVAL;
   return NULL;
 }
@@ -333,10 +378,11 @@ su_timer_t **su_port_timers(su_port_t *self)
 static inline
 int su_port_multishot(su_port_t *self, int multishot)
 {
-  if (self)
-    return self->sup_vtable->su_port_multishot(self, multishot);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_multishot(self, multishot);
 
-  assert(self);
+  assert(base);
   errno = EINVAL;
   return -1;
 }
@@ -344,16 +390,200 @@ int su_port_multishot(su_port_t *self, int multishot)
 static inline
 int su_port_threadsafe(su_port_t *self)
 {
-  if (self)
-    return self->sup_vtable->su_port_threadsafe(self);
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+  if (base)
+    return base->sup_vtable->su_port_threadsafe(self);
 
-  assert(self);
+  assert(base);
   errno = EINVAL;
   return -1;
 }
 
+static inline
+int su_port_getmsgs(su_port_t *self)
+{
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+
+  return base->sup_vtable->su_port_getmsgs(self);
+}
+
+static inline
+int su_port_getmsgs_from(su_port_t *self, su_port_t *cloneport)
+{
+  su_virtual_port_t *base = (su_virtual_port_t *)self;
+
+  return base->sup_vtable->su_port_getmsgs_from(self, cloneport);
+}
+
+SOFIAPUBFUN void su_port_wait(su_clone_r rclone);
+
+SOFIAPUBFUN int su_port_execute(su_task_r const task,
+                               int (*function)(void *), void *arg,
+                               int *return_value);
+
+/* ---------------------------------------------------------------------- */
+
+/** Base port object.
+ *
+ * Port is a per-thread reactor. Multiple root objects executed by a single
+ * thread share the su_port_t object.
+ */
+typedef struct su_base_port_s {
+  su_home_t        sup_home[1];
+  su_port_vtable_t const *sup_vtable;
+
+  /* Implementation may vary stuff below, too. */
+  
+  /* Pre-poll callback */
+  su_prepoll_f    *sup_prepoll; 
+  su_prepoll_magic_t *sup_pp_magic;
+  su_root_t       *sup_pp_root;
+
+  /* Message list - this is protected by su_port_lock()/su_port_unlock() */
+  su_msg_t        *sup_head, **sup_tail;
+
+  /* Timer list */
+  su_timer_t      *sup_timers;
+
+  unsigned         sup_running;          /**< In su_root_run() loop? */
+} su_base_port_t;
+
+/* Base methods */
 
+SOFIAPUBFUN int su_base_port_init(su_port_t *, su_port_vtable_t const *);
+SOFIAPUBFUN void su_base_port_deinit(su_port_t *self);
+
+SOFIAPUBFUN void su_base_port_lock(su_port_t *self, char const *who);
+SOFIAPUBFUN void su_base_port_unlock(su_port_t *self, char const *who);
+
+SOFIAPUBFUN int su_base_port_own_thread(su_port_t const *self);
+
+SOFIAPUBFUN void su_base_port_incref(su_port_t *self, char const *who);
+SOFIAPUBFUN int su_base_port_decref(su_port_t *self,
+                                   int blocking,
+                                   char const *who);
+
+SOFIAPUBFUN struct _GSource *su_base_port_gsource(su_port_t *self);
+
+SOFIAPUBFUN su_socket_t su_base_port_mbox(su_port_t *self);
+SOFIAPUBFUN int su_base_port_send(su_port_t *self, su_msg_r rmsg);
+SOFIAPUBFUN int su_base_port_getmsgs(su_port_t *self);
+SOFIAPUBFUN int su_base_port_getmsgs_from(su_port_t *self,
+                                          su_port_t *from);
+
+SOFIAPUBFUN void su_base_port_run(su_port_t *self);
+SOFIAPUBFUN void su_base_port_break(su_port_t *self);
+SOFIAPUBFUN su_duration_t su_base_port_step(su_port_t *self,
+                                           su_duration_t tout);
+
+SOFIAPUBFUN int su_base_port_add_prepoll(su_port_t *self,
+                                        su_root_t *root, 
+                                        su_prepoll_f *, 
+                                        su_prepoll_magic_t *);
+
+SOFIAPUBFUN int su_base_port_remove_prepoll(su_port_t *self, su_root_t *root);
+
+SOFIAPUBFUN su_timer_t **su_base_port_timers(su_port_t *self);
+
+SOFIAPUBFUN int su_base_port_multishot(su_port_t *self, int multishot);
+SOFIAPUBFUN int su_base_port_threadsafe(su_port_t *self);
+SOFIAPUBFUN int su_base_port_yield(su_port_t *self);
+
+SOFIAPUBFUN int su_base_port_start_shared(su_root_t *parent,
+                                         su_clone_r return_clone,
+                                         su_root_magic_t *magic,
+                                         su_root_init_f init,
+                                         su_root_deinit_f deinit);
+SOFIAPUBFUN void su_base_port_wait(su_clone_r rclone);
+
+/* ---------------------------------------------------------------------- */
+
+#if SU_HAVE_PTHREADS
+
+#include <pthread.h>
+
+/** Pthread port object */ 
+typedef struct su_pthread_port_s {
+  su_base_port_t   sup_base[1];
+  struct su_pthread_port_waiting_parent 
+                  *sup_waiting_parent;
+  pthread_t        sup_tid;
+#if 0
+  pthread_mutex_t  sup_runlock[1];
+  pthread_cond_t   sup_resume[1];
+  short            sup_paused; /**< True if thread is paused */
 #endif
+  short            sup_thread; /**< True if thread is active */
+} su_pthread_port_t;
+
+/* Pthread methods */
+
+SOFIAPUBFUN int su_pthread_port_init(su_port_t *, su_port_vtable_t const *);
+SOFIAPUBFUN void su_pthread_port_deinit(su_port_t *self);
+
+SOFIAPUBFUN void su_pthread_port_lock(su_port_t *self, char const *who);
+SOFIAPUBFUN void su_pthread_port_unlock(su_port_t *self, char const *who);
+
+SOFIAPUBFUN int su_pthread_port_own_thread(su_port_t const *self);
+
+#if 0                          /* not yet  */
+SOFIAPUBFUN int su_pthread_port_send(su_port_t *self, su_msg_r rmsg);
+
+SOFIAPUBFUN su_port_t *su_pthread_port_create(void);
+SOFIAPUBFUN su_port_t *su_pthread_port_start(su_root_t *parent,
+                                            su_clone_r return_clone,
+                                            su_root_magic_t *magic,
+                                            su_root_init_f init,
+                                            su_root_deinit_f deinit);
+#endif
+
+SOFIAPUBFUN int su_pthreaded_port_start(su_port_create_f *create,
+                                       su_root_t *parent,
+                                       su_clone_r return_clone,
+                                       su_root_magic_t *magic,
+                                       su_root_init_f init,
+                                       su_root_deinit_f deinit);
+
+SOFIAPUBFUN void su_pthread_port_wait(su_clone_r rclone);
+SOFIAPUBFUN int su_pthread_port_execute(su_task_r const task,
+                                       int (*function)(void *), void *arg,
+                                       int *return_value);
+
+
+#if 0
+SOFIAPUBFUN int su_pthread_port_pause(su_port_t *self);
+SOFIAPUBFUN int su_pthread_port_resume(su_port_t *self);
+#endif
+
+#else
+
+typedef su_base_port_t su_pthread_port_t;
+
+#define su_pthread_port_init   su_base_port_init
+#define su_pthread_port_deinit su_base_port_deinit
+#define su_pthread_port_lock   su_base_port_lock
+#define su_pthread_port_unlock su_base_port_unlock
+#define su_pthread_port_own_thread su_base_port_own_thread
+#define su_pthread_port_wait   su_base_port_wait
+#define su_pthread_port_execute  su_base_port_execute
+
+#endif
+
+/* ====================================================================== */
+/* Mailbox port using sockets */
+
+#define SU_MBOX_SIZE 2
+
+typedef struct su_socket_port_s {
+  su_pthread_port_t sup_base[1];
+  int               sup_mbox_index;
+  su_socket_t       sup_mbox[SU_MBOX_SIZE];
+} su_socket_port_t;
+
+SOFIAPUBFUN int su_socket_port_init(su_socket_port_t *, 
+                                   su_port_vtable_t const *);
+SOFIAPUBFUN void su_socket_port_deinit(su_socket_port_t *self);
+SOFIAPUBFUN int su_socket_port_send(su_port_t *self, su_msg_r rmsg);
 
 SOFIA_END_DECLS
 
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_pthread_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_pthread_port.c
new file mode 100644 (file)
index 0000000..5f2b0a9
--- /dev/null
@@ -0,0 +1,563 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_pthread_port.c
+ *
+ * OS-Independent Syncronization Interface with pthreads
+ *
+ * This implements #su_msg_t message passing functionality using pthreads.
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#define su_pthread_port_s su_port_s
+#define SU_CLONE_T su_msg_t
+
+#include "sofia-sip/su.h"
+#include "su_port.h"
+#include "sofia-sip/su_alloc.h"
+
+#if 1
+#define PORT_LOCK_DEBUG(x)  ((void)0)
+#else
+#define PORT_LOCK_DEBUG(x)  printf x
+#endif
+
+#define SU_TASK_COPY(d, s, by) (void)((d)[0]=(s)[0], \
+  (s)->sut_port?(void)su_port_incref(s->sut_port, #by):(void)0)
+
+/**@internal
+ *
+ * Initializes a message port. It creates a mailbox used to wake up the
+ * thread waiting on the port if needed. Currently, the mailbox is a
+ * socketpair or an UDP socket connected to itself.
+ */
+int su_pthread_port_init(su_port_t *self, su_port_vtable_t const *vtable)
+{
+  SU_DEBUG_9(("su_pthread_port_init(%p, %p) called\n",
+             (void *)self, (void *)vtable));
+
+  self->sup_tid = pthread_self();
+
+  if (su_base_port_init(self, vtable) == 0 &&
+      su_base_port_threadsafe(self) == 0) {
+    return 0;
+  }
+  else
+    su_base_port_deinit(self);
+
+  return -1;
+}
+
+
+/** @internal Deinit a base implementation of port. */
+void su_pthread_port_deinit(su_port_t *self)
+{
+  assert(self);
+
+#if 0
+  pthread_mutex_destroy(self->sup_runlock);
+  pthread_cond_destroy(self->sup_resume);
+#endif
+
+  su_base_port_deinit(self);
+}
+
+void su_pthread_port_lock(su_port_t *self, char const *who)
+{
+  PORT_LOCK_DEBUG(("%p at %s locking(%p)...",
+                  (void *)pthread_self(), who, self));
+
+  su_home_mutex_lock(self->sup_base->sup_home);
+
+  PORT_LOCK_DEBUG((" ...%p at %s locked(%p)...", 
+                  (void *)pthread_self(), who, self));
+}
+
+void su_pthread_port_unlock(su_port_t *self, char const *who)
+{
+  su_home_mutex_unlock(self->sup_base->sup_home);
+
+  PORT_LOCK_DEBUG((" ...%p at %s unlocked(%p)\n", 
+                  (void *)pthread_self(), who, self));
+}
+
+/** @internal
+ * Checks if the calling thread owns the port object.
+ *
+ * @param self pointer to a port object
+ *
+ * @retval true (nonzero) if the calling thread owns the port,
+ * @retval false (zero) otherwise.
+ */
+int su_pthread_port_own_thread(su_port_t const *self)
+{
+  return self == NULL || 
+    pthread_equal(self->sup_tid, pthread_self());
+}
+
+/* -- Clones ------------------------------------------------------------ */
+
+struct clone_args
+{
+  su_port_create_f*create;
+  su_root_t       *parent;
+  su_root_magic_t *magic;
+  su_root_init_f   init;
+  su_root_deinit_f deinit;
+  pthread_mutex_t  mutex[1];
+  pthread_cond_t   cv[1];
+  int              retval;
+  su_msg_r         clone;
+};
+
+static void *su_pthread_port_clone_main(void *varg);
+static void su_pthread_port_return_to_parent(struct clone_args *arg,
+                                            int retval);
+static su_msg_function su_pthread_port_clone_break;
+
+/* Structure used to synchronize parent and clone in su_clone_wait() */
+struct su_pthread_port_waiting_parent {
+  pthread_mutex_t deinit[1];
+  pthread_mutex_t mutex[1];
+  pthread_cond_t cv[1];
+  int waiting;
+};
+
+/** Start a clone task running under a pthread.
+ *
+ * @internal
+ *
+ * Allocates and initializes a sub-task with its own pthread. The sub-task is
+ * represented by clone handle to the rest of the application. The function
+ * su_clone_start() returns the clone handle in @a return_clone. The clone
+ * handle is used to communicate with the newly created clone task using
+ * messages.
+ *
+ * A new #su_root_t object is created for the sub-task with the @a magic as
+ * the root context pointer. Because the sub-task may or may not have its
+ * own thread, all its activity must be scheduled via this root object. In
+ * other words, the sub-task can be schedule
+ * -# I/O events with su_root_register()
+ * -# timers with su_timer_set(), su_timer_set_at() or su_timer_run()
+ * -# messages with su_msg_send().
+ *
+ * Messages can also be used to pass information between tasks or threads.
+ *
+ * After the new thread has been launched, the initialization routine is
+ * executed by the newly created thread. The calling thread blocks until
+ * the initialization routine completes. If the initialization routine
+ * returns #su_success (0), the sub-task is considered to be created
+ * successfully. After the successful initialization, the sub-task continues
+ * to execeute the function su_root_run().
+ *
+ * If the initalization function @a init fails, the sub-task (either the
+ * newly created thread or the current thread executing the su_clone_start()
+ * function) calls the deinitialization function, and su_clone_start()
+ * returns NULL.
+ *
+ * @param parent   root to be cloned (may be NULL if multi-threaded)
+ * @param return_clone reference to a clone [OUT]
+ * @param magic    pointer to user data
+ * @param init     initialization function
+ * @param deinit   deinitialization function
+ *
+ * @return 0 if successfull, -1 upon an error.
+ *
+ * @sa su_root_threading(), su_clone_task(), su_clone_stop(), su_clone_wait(),
+ * su_clone_forget().
+ * 
+ */
+int su_pthreaded_port_start(su_port_create_f *create,
+                           su_root_t *parent,
+                           su_clone_r return_clone,
+                           su_root_magic_t *magic,
+                           su_root_init_f init,
+                           su_root_deinit_f deinit)
+{
+  struct clone_args arg = {
+    /* create: */ NULL,
+    /* parent: */ NULL,
+    /* magic: */  NULL,
+    /* init: */   NULL,
+    /* deinit: */ NULL,
+    /* mutex: */  { PTHREAD_MUTEX_INITIALIZER },
+    /* cv: */     { PTHREAD_COND_INITIALIZER },
+    /* retval: */ -1,
+    /* clone: */  SU_MSG_R_INIT,
+  };
+
+  int thread_created = 0;
+  pthread_t tid;
+
+  arg.create = create;
+  arg.parent = parent;
+  arg.magic = magic;
+  arg.init = init;
+  arg.deinit = deinit;
+
+  pthread_mutex_lock(arg.mutex);
+  if (pthread_create(&tid, NULL, su_pthread_port_clone_main, &arg) == 0) {
+    pthread_cond_wait(arg.cv, arg.mutex);
+    thread_created = 1;
+  }
+  pthread_mutex_unlock(arg.mutex);
+
+  pthread_mutex_destroy(arg.mutex);
+  pthread_cond_destroy(arg.cv);
+
+  if (arg.retval != 0) {
+    if (thread_created)
+      pthread_join(tid, NULL);
+    return -1;
+  }
+
+  *return_clone = *arg.clone;
+
+  return 0;
+}
+
+/** Main function for clone thread.
+ *
+ * @internal
+ */
+static void *su_pthread_port_clone_main(void *varg)
+{
+  struct clone_args *arg = (struct clone_args *)varg;
+  su_task_r task;
+  int zap = 1;
+
+#if SU_HAVE_WINSOCK
+  su_init();
+#endif
+
+  task->sut_port = arg->create();
+
+  if (task->sut_port) {
+    task->sut_port->sup_thread = 1;
+
+    task->sut_root = su_salloc(su_port_home(task->sut_port),
+                              sizeof *task->sut_root);
+    if (task->sut_root) {
+
+      task->sut_root->sur_threading = 1;       /* By default */
+
+      SU_TASK_COPY(task->sut_root->sur_parent, su_root_task(arg->parent), 
+                  su_pthread_port_clone_main);
+      SU_TASK_COPY(task->sut_root->sur_task, task,
+                  su_pthread_port_clone_main);
+
+      if (su_msg_create(arg->clone,
+                       task,
+                       su_root_task(arg->parent),
+                       su_pthread_port_clone_break,
+                       0) == 0) {
+       task->sut_root->sur_magic = arg->magic;
+       task->sut_root->sur_deinit = arg->deinit;
+
+       if (arg->init(task->sut_root, arg->magic) == 0) {
+         su_pthread_port_return_to_parent(arg, 0), arg = NULL;
+
+         su_root_run(task->sut_root); /* Do the work */
+
+         /* Cleanup */
+         if (task->sut_port->sup_waiting_parent) {
+           struct su_pthread_port_waiting_parent *mom;
+
+           mom = task->sut_port->sup_waiting_parent;
+           pthread_mutex_lock(mom->mutex);
+           mom->waiting = 0;
+           pthread_cond_signal(mom->cv);
+           pthread_mutex_unlock(mom->mutex);
+    
+           pthread_mutex_lock(mom->deinit);
+           su_port_getmsgs(task->sut_port);
+           pthread_mutex_unlock(mom->deinit);
+         }
+         else
+           zap = 0;
+       }
+       else
+         su_msg_destroy(arg->clone);
+
+       su_root_destroy(task->sut_root);
+      }
+    }
+
+    task->sut_port->sup_thread = 0;
+
+    task->sut_port->sup_base->sup_vtable->
+      su_port_decref(task->sut_port, zap, 
+                    "su_pthread_port_clone_main");
+  }
+
+#if SU_HAVE_WINSOCK
+  su_deinit();
+#endif
+
+  if (arg)
+    su_pthread_port_return_to_parent(arg, -1);
+
+  return NULL;                 /* Exit from thread */
+}
+
+/* Signal that parent can resume execution */
+static void su_pthread_port_return_to_parent(struct clone_args *arg,
+                                            int retval)
+{
+  arg->retval = retval;
+
+  pthread_mutex_lock(arg->mutex);
+  pthread_cond_signal(arg->cv);
+  pthread_mutex_unlock(arg->mutex);
+}
+
+/** "Stop" message function for pthread clone.
+ *
+ * @sa su_clone_wait()
+ * @internal 
+ */
+static void su_pthread_port_clone_break(su_root_magic_t *m,
+                                       su_msg_r msg,
+                                       su_msg_arg_t *a)
+{
+  su_root_t *root = su_msg_to(msg)->sut_root;
+
+  root->sur_deiniting = 1;
+
+  su_root_break(root);
+}
+
+/** Wait for the pthread clone to exit.
+ * @internal
+ */
+void su_pthread_port_wait(su_clone_r rclone)
+{
+  su_port_t *clone, *parent;
+  struct su_pthread_port_waiting_parent mom[1];
+  pthread_t tid;
+
+  clone = su_msg_to(rclone)->sut_port;
+  parent = su_msg_from(rclone)->sut_port;
+
+  if (clone == parent) {
+    su_base_port_wait(rclone);
+    return;
+  }
+  
+  assert(parent); assert(clone); 
+  assert(rclone[0]->sum_func == su_pthread_port_clone_break);
+#if 0
+  assert(!clone->sup_paused);
+#endif
+
+  tid = clone->sup_tid;
+
+  if (!clone->sup_thread) {    /* Already died */
+    su_msg_destroy(rclone);
+    pthread_join(tid, NULL);
+    return;  
+  }
+
+  pthread_mutex_init(mom->deinit, NULL);
+  pthread_mutex_lock(mom->deinit);
+
+  pthread_cond_init(mom->cv, NULL);
+  pthread_mutex_init(mom->mutex, NULL);
+  pthread_mutex_lock(mom->mutex);
+
+  mom->waiting = 1;
+
+  clone->sup_waiting_parent = mom;
+
+  su_msg_send(rclone);
+
+  while (mom->waiting)
+    pthread_cond_wait(mom->cv, mom->mutex);
+
+  /* Run all messages from clone */
+  while (su_port_getmsgs_from(parent, clone))
+    ;
+
+  /* Allow clone thread to exit */
+  pthread_mutex_unlock(mom->deinit);
+  pthread_join(tid, NULL);
+
+  pthread_mutex_destroy(mom->deinit);
+
+  pthread_mutex_unlock(mom->mutex);
+  pthread_mutex_destroy(mom->mutex);
+  pthread_cond_destroy(mom->cv);
+}
+
+struct su_pthread_port_execute
+{
+  pthread_mutex_t mutex[1];
+  pthread_cond_t cond[1];
+  int (*function)(void *);
+  void *arg;
+  int value;
+};
+
+static su_msg_function _su_pthread_port_execute;
+
+/** Execute the @a function by a pthread @a task.
+ *
+ * @retval 0 if successful
+ * @retval -1 upon an error
+ *
+ * @sa su_task_execute()
+ *
+ * @internal
+ */
+int su_pthread_port_execute(su_task_r const task,
+                           int (*function)(void *), void *arg,
+                           int *return_value)
+{
+  int success;
+  su_msg_r m = SU_MSG_R_INIT;
+  struct su_pthread_port_execute frame = {
+    { PTHREAD_MUTEX_INITIALIZER },
+    { PTHREAD_COND_INITIALIZER },
+    function, arg, 0
+  };
+
+  if (su_msg_create(m, task, su_task_null,
+                   _su_pthread_port_execute, (sizeof &frame)) < 0)
+    return -1;
+
+  *(struct su_pthread_port_execute **)su_msg_data(m) = &frame;
+
+  pthread_mutex_lock(frame.mutex);
+
+  success = su_msg_send(m);
+
+  if (success == 0)
+    while (frame.function)
+      pthread_cond_wait(frame.cond, frame.mutex);
+  else
+    su_msg_destroy(m);
+
+  pthread_mutex_unlock(frame.mutex);
+  pthread_mutex_destroy(frame.mutex);
+  pthread_cond_destroy(frame.cond);
+
+  if (return_value)
+    *return_value = frame.value;
+
+  return success;
+}
+
+static void _su_pthread_port_execute(su_root_magic_t *m,
+                                    su_msg_r msg,
+                                    su_msg_arg_t *a)
+{
+  struct su_pthread_port_execute *frame;
+  frame = *(struct su_pthread_port_execute **)a;
+  pthread_mutex_lock(frame->mutex);
+  frame->value = frame->function(frame->arg);
+  frame->function = NULL;      /* Mark as completed */
+  pthread_cond_signal(frame->cond);
+  pthread_mutex_unlock(frame->mutex);
+}
+
+#if 0                          /* pausing and resuming are not used */
+
+/** Pause the pthread port.
+ *
+ * This is a message function invoked by su_pthread_port_pause() and called
+ * from the message dispatcher. It releases the lock sup_runlock and waits
+ * until the condition variable sup_resume is signaled and sup_paused is
+ * cleared by su_pthread_port_resume().
+ */
+static
+void su_pthread_port_paused(su_root_magic_t *magic,
+                           su_msg_r msg,
+                           su_msg_arg_t *arg)
+{
+  su_port_t *self = su_msg_to(msg)->sut_port;
+  self->sup_paused = 1;
+  while (self->sup_paused)
+    pthread_cond_wait(self->sup_resume, self->sup_runlock);
+}
+
+/** Pause a port.
+ *
+ * Obtain an exclusive lock on port's private data.
+ *
+ * @retval 0 if successful (and clone is paused)
+ * @retval -1 upon an error
+ */
+int su_pthread_port_pause(su_port_t *self)
+{
+  su_msg_r m = SU_MSG_R_INIT;
+  _su_task_t task[1] = {{ self, NULL }};
+
+  if (su_msg_create(m, task, su_task_null, su_pthread_port_paused, 0) < 0)
+    return -1;
+
+  if (su_msg_send(m) < 0)
+    return -1;
+
+  if (pthread_mutex_lock(self->sup_runlock) < 0)
+    return -1;
+
+  return 0;
+}
+
+/** Resume a port.
+ *
+ * Give up an exclusive lock on port's private data.
+ *
+ * @retval 0 if successful (and clone is resumed)
+ * @retval -1 upon an error
+ */
+int su_pthread_port_resume(su_port_t *self)
+{
+  assert(self && self->sup_paused);
+
+  self->sup_paused = 0;
+
+  if (pthread_cond_signal(self->sup_resume) < 0 ||
+      pthread_mutex_unlock(self->sup_runlock) < 0)
+    return -1;
+
+  return 0;
+}
+
+#endif
index 553bb71a4688b4f13585a684fa8a32a9dd13927e..7cea484080a7ebec311be6f3d903b23351ea0924 100644 (file)
 
 struct su_root_s;
 
-typedef struct su_cloned_s {
-  struct su_root_s *sc_root;
-  int *sc_wait;
-#if SU_HAVE_PTHREADS
-  pthread_t  sc_tid;
-  pthread_mutex_t sc_pause[1];
-  pthread_cond_t sc_resume[1];
-  int sc_paused;
-#endif  
-} su_cloned_t;
-
 #define SU_ROOT_MAGIC_T struct su_root_magic_s
 #define SU_WAKEUP_ARG_T struct su_wakeup_arg_s
 #define SU_TIMER_ARG_T  struct su_timer_arg_s
-#define SU_CLONE_T      su_msg_t
-#define SU_MSG_ARG_T    struct su_cloned_s
 
 #include "su_port.h"
 #include "sofia-sip/su_alloc.h"
@@ -136,11 +123,11 @@ su_task_r const su_task_null = SU_TASK_R_INIT;
 
 #define SU_TASK_ZAP(t, f) \
   while (t->sut_port) { \
-   SU_PORT_DECREF(t->sut_port, f); t->sut_port = NULL; break; }
+   su_port_decref(t->sut_port, #f); t->sut_port = NULL; break; }
 
 #define SU_TASK_ZAPP(t, f) \
   do { if (t->sut_port) { \
-   SU_PORT_DECREF(t->sut_port, f); t->sut_port = NULL; } \
+   su_port_decref(t->sut_port, #f); t->sut_port = NULL; } \
    t->sut_root = NULL; } while(0)
 
 /**
@@ -186,7 +173,7 @@ _su_task_r su_task_new(su_task_r task, su_root_t *root, su_port_t *port)
 
   task->sut_root = root;
   if ((task->sut_port = port)) {
-    SU_PORT_INCREF(port, su_task_new);
+    su_port_incref(port, "su_task_new");
   }
   return task;
 }
@@ -207,14 +194,14 @@ void su_task_copy(su_task_r dst, su_task_r const src)
 
   port = src->sut_port;
   if (port) {
-    SU_PORT_INCREF(port, su_task_copy);
+    su_port_incref(port, "su_task_copy");
   }
 
   dst[0] = src[0];
 }
 
 #define SU_TASK_COPY(d, s, by) (void)((d)[0]=(s)[0], \
-  (s)->sut_port?(void)SU_PORT_INCREF(s->sut_port, by):(void)0)
+  (s)->sut_port?(void)su_port_incref(s->sut_port, #by):(void)0)
 
 /**
  * Moves a task handle.
@@ -242,8 +229,10 @@ void su_task_move(su_task_r dst, su_task_r src)
  */
 int su_task_cmp(su_task_r const a, su_task_r const b)
 {
-  intptr_t retval = a->sut_port - b->sut_port;
-  retval = retval ? retval : (char *)a->sut_root - (char *)b->sut_root;
+  intptr_t retval = (char *)a->sut_port - (char *)b->sut_port;
+
+  if (retval == 0)
+    retval = (char *)a->sut_root - (char *)b->sut_root;
 
   if (sizeof(retval) != sizeof(int)) {
     if (retval < 0)
@@ -329,32 +318,7 @@ su_timer_t **su_task_timers(su_task_r const task)
   return task ? su_port_timers(task->sut_port) : NULL;
 }
 
-#if SU_HAVE_PTHREADS
-
-struct su_task_execute
-{
-  pthread_mutex_t mutex[1];
-  pthread_cond_t cond[1];
-  int (*function)(void *);
-  void *arg;
-  int value;
-};
-
-static void _su_task_execute(su_root_magic_t *m,
-                            su_msg_r msg,
-                            su_msg_arg_t *a)
-{
-  struct su_task_execute *frame = *(struct su_task_execute **)a;
-  pthread_mutex_lock(frame->mutex);
-  frame->value = frame->function(frame->arg);
-  frame->function = NULL;      /* Mark as completed */
-  pthread_cond_signal(frame->cond);
-  pthread_mutex_unlock(frame->mutex);
-}
-
-#endif
-
-/** Execute by task thread
+/** Execute the @a function by @a task thread.
  *
  * @retval 0 if successful
  * @retval -1 upon an error
@@ -367,42 +331,7 @@ int su_task_execute(su_task_r const task,
     return (errno = EFAULT), -1;
 
   if (!su_port_own_thread(task->sut_port)) {
-#if SU_HAVE_PTHREADS
-    int success;
-    su_msg_r m = SU_MSG_R_INIT;
-    struct su_task_execute frame = {
-      { PTHREAD_MUTEX_INITIALIZER },
-      { PTHREAD_COND_INITIALIZER },
-      function, arg, 0
-    };
-
-    if (su_msg_create(m, task, su_task_null,
-                     _su_task_execute, (sizeof &frame)) < 0)
-      return -1;
-
-    *(struct su_task_execute **)su_msg_data(m) = &frame;
-
-    pthread_mutex_lock(frame.mutex);
-
-    success = su_msg_send(m);
-
-    if (success == 0)
-      while (frame.function)
-       pthread_cond_wait(frame.cond, frame.mutex);
-    else
-      su_msg_destroy(m);
-
-    pthread_mutex_unlock(frame.mutex);
-    pthread_mutex_destroy(frame.mutex);
-    pthread_cond_destroy(frame.cond);
-
-    if (return_value)
-      *return_value = frame.value;
-
-    return success;
-#else
-    return (errno = ENOSYS), -1;
-#endif
+    return su_port_execute(task, function, arg, return_value);
   }
   else {
     int value = function(arg);
@@ -420,51 +349,6 @@ int su_task_detach(su_task_r self);
 
 int su_timer_reset_all(su_timer_t **t0, su_task_r);
 
-/**@ingroup su_wait
- * 
- * @page su_clone_t Clone Objects
- *
- * The process may be divided into many tasks via cloning. Several tasks may
- * run in context of one thread, or each task may be run by its own thread. 
- * However, only a single thread can execute code within a task. There can
- * be a 1-to-N mapping from thread to tasks. Thus, software using tasks can
- * be executed by multiple threads in a multithreaded environment and by a
- * single thread in a singlethreaded environment.
- * 
- * The clones are useful for handling tasks that can be executed by a
- * separate threads, but which do not block excessively. When threads are
- * not available or they are not needed, clones can also be run in a
- * single-threaded mode. Running in single-threaded mode is especially
- * useful while debugging.
- * 
- * A clone task is created with function su_clone_start(). Each clone has
- * its own root object (su_root_t), which holds a context pointer
- * (su_root_magic_t *). The context object can be different from that of 
- * parent task.
- *
- * When a clone is started, the clone initialization function is called. The
- * initialization function should do whatever initialization there is to be
- * performed, register I/O events and timers, and then return. If the
- * initialization is successful, the clone task reverts to run the event
- * loop and invoking the event callbacks until its parent stops it by
- * calling su_clone_wait() which invokes the deinit function. The clone task
- * is destroyed when the deinit function returns. 
- *
- * The public API consists of following functions:
- *    - su_clone_start()
- *    - su_clone_task()
- *    - su_clone_wait()
- *    - su_clone_forget()
- *
- * @note 
- * There is only one event loop for each thread which can be shared by
- * multiple clone tasks. Therefore, the clone tasks can not explicitly run
- * or step the event loop, but they are limited to event callbacks. A clone
- * task may not call su_root_break(), su_root_run() or su_root_step().
- */
-
-static void su_root_deinit(su_root_t *self);
-
 /* Note that is *not* necessary same as su_root_t,
  * as su_root_t can be extended */
 
@@ -486,9 +370,13 @@ su_root_t *su_root_create(su_root_magic_t *magic)
   return su_root_create_with_port(magic, su_port_create());
 }
 
-/** Create a reactor object using given message port.
+/**@internal
  *
- * Allocate and initialize the instance of su_root_t.
+ * Create a reactor object using given message port.
+ *
+ * Allocate and initialize the instance of su_root_t. Note that this
+ * function always uses a reference to su_port_t, even when creating the
+ * root fails.
  *
  * @param magic     pointer to user data
  * @param port      pointer to a message port
@@ -503,7 +391,7 @@ su_root_t *su_root_create_with_port(su_root_magic_t *magic,
   if (!port)
     return NULL;
 
-  self = su_salloc(NULL, sizeof(struct su_root_s));
+  self = su_salloc(su_port_home(port), sizeof(struct su_root_s));
 
   if (self) {
     self->sur_magic = magic;
@@ -512,15 +400,17 @@ su_root_t *su_root_create_with_port(su_root_magic_t *magic,
 #else
     self->sur_threading = 0;
 #endif
+    /* This one creates a new reference to port */
     su_task_new(self->sur_task, self, port);
-  } else {
-    su_port_decref(port, "su_root_create");
-  }
+    /* ... so we zap the old one below */
+  } 
+
+  su_port_decref(port, "su_root_create_with_port");
 
   return self;
 }
 
-/** Destroy a synchronization object.
+/** Destroy a root object.
  * 
  *  Stop and free an instance of su_root_t
  *
@@ -528,21 +418,14 @@ su_root_t *su_root_create_with_port(su_root_magic_t *magic,
  */
 void su_root_destroy(su_root_t *self)
 {
-  if (self) {
-    assert(SU_ROOT_OWN_THREAD(self));
-    su_root_deinit(self);
-    su_free(NULL, self);
-  }
-}
+  su_port_t *port;
+  int unregistered, reset;
+
+  if (!self)
+    return;
+
+  assert(SU_ROOT_OWN_THREAD(self));
 
-/** @internal Deinitialize a synchronization object.
- *
- *  Deinitialize an instance of su_root_t
- *
- * @param self     pointer to a root object.
- */
-static void su_root_deinit(su_root_t *self)
-{
   self->sur_deiniting = 1;
 
   if (self->sur_deinit) {
@@ -552,17 +435,37 @@ static void su_root_deinit(su_root_t *self)
     deinit(self, magic);
   }
 
-  if (self->sur_port) {
-    int n_w = su_port_unregister_all(self->sur_port, self);
-    int n_t = su_timer_reset_all(su_task_timers(self->sur_task), self->sur_task);
+  port = self->sur_port; assert(port);
 
-    if (n_w || n_t)
-      SU_DEBUG_1(("su_root_deinit: "
-                 "%u registered waits, %u timers\n", n_w, n_t));
-  }
+  unregistered = su_port_unregister_all(port, self);
+  reset = su_timer_reset_all(su_task_timers(self->sur_task), self->sur_task);
+
+  if (unregistered || reset)
+    SU_DEBUG_1(("su_root_destroy: "
+               "%u registered waits, %u timers\n",
+               unregistered, reset));
+
+  SU_TASK_ZAP(self->sur_parent, su_root_destroy);
+
+  su_free(su_port_home(port), self);
 
-  SU_TASK_ZAP(self->sur_parent, su_root_deinit);
-  SU_TASK_ZAP(self->sur_task, su_root_deinit);
+  su_port_decref(port, "su_root_destroy");
+}
+
+/** Get instance name.
+ *
+ * @param self      pointer to a root object
+ *
+ * @return Instance name (e.g., "epoll", "devpoll", "select").
+ *
+ * @NEW_1_12_6
+ */
+char const *su_root_name(su_root_t *self)
+{
+  if (self && self->sur_task->sut_port)
+    return su_port_name(self->sur_task->sut_port);
+  else
+    return NULL;
 }
 
 /** Set the context pointer.
@@ -760,7 +663,6 @@ int su_root_multishot(su_root_t *self, int multishot)
   }
 }
 
-
 /** Run event and message loop.
  *
  * The function su_root_run() runs the root main loop. The root loop waits
@@ -852,12 +754,20 @@ su_duration_t su_root_sleep(su_root_t *self, su_duration_t duration)
 int su_root_yield(su_root_t *self)
 {
   if (self && self->sur_task[0].sut_port) {
-    su_port_t *port = self->sur_task[0].sut_port;
+    su_virtual_port_t *port = (su_virtual_port_t *)self->sur_task[0].sut_port;
+    /* Make sure we have su_port_wait_events extension */
+    if (port->sup_vtable->su_vtable_size >= 
+       offsetof(su_port_vtable_t, su_port_wait_events) 
+       && port->sup_vtable->su_port_wait_events)
+      return port->sup_vtable->
+       su_port_wait_events(self->sur_task[0].sut_port, 0);
+
     /* Make sure we have su_port_yield extension */
     if (port->sup_vtable->su_vtable_size >= 
        offsetof(su_port_vtable_t, su_port_yield) 
        && port->sup_vtable->su_port_yield)
-      return port->sup_vtable->su_port_yield(port);
+    return port->sup_vtable->
+      su_port_yield(self->sur_task[0].sut_port);
   }
   errno = EINVAL;
   return -1;
@@ -919,467 +829,6 @@ int su_root_remove_prepoll(su_root_t *root)
   return su_port_remove_prepoll(root->sur_port, root);
 }
 
-/* ========================================================================
- * su_clone_t
- */
-
-/* - su_clone_forget() */
-
-#if SU_HAVE_PTHREADS
-struct clone_args
-{
-  su_root_t      * self;
-  su_root_init_f   init;
-  su_root_deinit_f deinit;
-  pthread_mutex_t  mutex;
-  pthread_cond_t   cv;
-  int              retval;
-  su_msg_r         clone;
-  su_root_t const *parent;
-};
-
-static void su_clone_report2(su_root_magic_t *m,
-                            su_msg_r msg,
-                            su_cloned_t *sc);
-
-static void su_clone_signal_parent(void *varg)
-{
-  struct clone_args *arg = (struct clone_args *)varg;
-
-  pthread_mutex_lock(&arg->mutex);
-  pthread_cond_signal(&arg->cv);
-  pthread_mutex_unlock(&arg->mutex);
-}
-
-/** Message function for clone message.
- *
- * This calls the clone task deinitialization function, which should make
- * sure that no more messages are sent by clone task.
- *
- * @sa su_clone_wait()
- */
-static void su_clone_break(su_root_magic_t *m,
-                          su_msg_r msg,
-                          su_cloned_t *sc)
-{
-  su_root_t *root = sc->sc_root;
-
-  root->sur_deiniting = 1;
-
-  if (root->sur_deinit) {
-    su_root_deinit_f deinit = root->sur_deinit;
-    su_root_magic_t *magic = root->sur_magic;
-    root->sur_deinit = NULL;
-    deinit(root, magic);
-  }
-}
-
-/** Delivery report function for clone message.
- *
- * This is executed by parent task. This is the last message sent by clone task.
- */
-static void su_clone_report(su_root_magic_t *m,
-                           su_msg_r msg,
-                           su_cloned_t *sc)
-{
-  su_msg_report(msg, su_clone_report2);
-}
-
-/** Back delivery report function for clone message.
- *
- * This is executed by clone task. It completes the three way handshake and
- * it is used to signal clone that it can destroy its port.
- */
-static void su_clone_report2(su_root_magic_t *m,
-                           su_msg_r msg,
-                           su_cloned_t *sc)
-{
-  su_root_break(sc->sc_root);
-  if (sc->sc_wait)
-    *sc->sc_wait = 0;
-}
-
-static void *su_clone_main(void *varg)
-{
-  struct clone_args *arg = (struct clone_args *)varg;
-  su_root_t *self = arg->self;
-  su_port_t *port;
-  su_cloned_t *sc;
-
-  pthread_cleanup_push(su_clone_signal_parent, varg);
-
-#if SU_HAVE_WINSOCK
-  su_init();
-#endif
-
-  port = su_port_create();
-  if (!port)
-    pthread_exit(NULL);
-  su_port_threadsafe(port);
-  SU_PORT_INCREF(port, su_clone_main);
-
-  /* Change task ownership */
-  SU_PORT_INCREF(self->sur_task->sut_port = port, su_clone_main);
-  self->sur_task->sut_root = self;
-
-  if (su_msg_create(arg->clone,
-                   self->sur_task, su_root_task(arg->parent),
-                   su_clone_break, sizeof(self)) != 0) {
-    su_port_decref(self->sur_port, "su_clone_main");
-    self->sur_port = NULL;
-    pthread_exit(NULL);
-  }
-
-  su_msg_report(arg->clone, su_clone_report);
-
-  sc = su_msg_data(arg->clone);
-  sc->sc_root = self;
-  sc->sc_tid = pthread_self();
-
-  pthread_mutex_init(sc->sc_pause, NULL);
-  pthread_cond_init(sc->sc_resume, NULL);
-  pthread_mutex_lock(sc->sc_pause);
-
-  if (arg->init && arg->init(self, self->sur_magic) != 0) {
-    if (arg->deinit)
-      arg->deinit(self, self->sur_magic);
-    su_msg_destroy(arg->clone);
-    su_port_decref(self->sur_port, "su_clone_main");
-    self->sur_port = NULL;
-    pthread_exit(NULL);
-  }
-
-  arg->retval = 0;
-
-  pthread_cleanup_pop(1);  /* signal change of ownership */
-
-  su_root_run(self);   /* Do the work */
-
-  su_root_destroy(self);   /* Cleanup root */   
-
-  SU_PORT_ZAPREF(port, su_clone_main);
-
-#if SU_HAVE_WINSOCK
-  su_deinit();
-#endif
-
-  return NULL;
-}
-#endif
-
-static void su_clone_xyzzy(su_root_magic_t *m,
-                          su_msg_r msg,
-                          su_cloned_t *sc)
-{
-  su_root_destroy(sc->sc_root);
-  if (sc->sc_wait)
-    *sc->sc_wait = 0;
-}
-
-/** Start a clone task.
- *
- * The function su_clone_start() allocates and initializes a sub-task. 
- * Depending on the settings, a separate thread may be created to execute
- * the sub-task. The sub-task is represented by clone handle to the rest of
- * the application. The function su_clone_start() returns the clone handle
- * in @a return_clone. The clone handle is used to communicate with the
- * newly created clone task using messages.
- *
- * A new #su_root_t object is created for the sub-task with the @a magic as
- * the root context pointer. Because the sub-task may or may not have its
- * own thread, all its activity must be scheduled via this root object. In
- * other words, the sub-task can be schedule
- * -# I/O events with su_root_register()
- * -# timers with su_timer_set(), su_timer_set_at() or su_timer_run()
- * -# messages with su_msg_send().
- *
- * Messages can also be used to pass information between tasks or threads.
- *
- * In multi-threaded implementation, su_clone_start() launches a new thread,
- * and the initialization routine is executed by this newly created thread. 
- * The calling thread blocks until the initialization routine completes. If
- * the initialization routine returns #su_success (0), the sub-task is
- * considered to be created successfully. After the successful
- * initialization, the sub-task continues to execeute the function
- * su_root_run().
- *
- * In single-threaded implementations, just a new root object is created. 
- * The initialization routine is called directly from su_clone_start().
- *
- * If the initalization function @a init fails, the sub-task (either the
- * newly created thread or the current thread executing the su_clone_start()
- * function) calls the deinitialization function, and su_clone_start()
- * returns NULL.
- *
- * @param parent   root to be cloned (may be NULL if multi-threaded)
- * @param return_clone reference to a clone [OUT]
- * @param magic    pointer to user data
- * @param init     initialization function
- * @param deinit   deinitialization function
- *
- * @return 0 if successfull, -1 upon an error.
- *
- * @sa su_root_threading(), su_clone_task(), su_clone_stop(), su_clone_wait(),
- * su_clone_forget().
- */
-int su_clone_start(su_root_t *parent,
-                  su_clone_r return_clone,
-                  su_root_magic_t *magic,
-                  su_root_init_f init,
-                  su_root_deinit_f deinit)
-{
-  su_root_t *child;
-  int retval = -1;
-
-  if (parent) {
-    assert(SU_ROOT_OWN_THREAD(parent));
-    assert(parent->sur_port);
-  }
-#if !SU_HAVE_PTHREADS
-  else {
-    /* if we don't have threads, we *must* have parent root */
-    return -1;
-  }
-#endif
-
-  child = su_salloc(NULL, sizeof(struct su_root_s));
-
-#if SU_HAVE_PTHREADS
-  if (child && (parent == NULL || parent->sur_threading)) {
-    struct clone_args arg = {
-      NULL, NULL, NULL,
-      PTHREAD_MUTEX_INITIALIZER,
-      PTHREAD_COND_INITIALIZER,
-      -1,
-      SU_MSG_R_INIT,
-      NULL
-    };
-
-    int thread_created = 0;
-    pthread_t tid;
-
-    su_port_threadsafe(parent->sur_port);
-
-    arg.self = child;
-    arg.init = init;
-    arg.deinit = deinit;
-    arg.parent = parent;
-
-    child->sur_magic = magic;
-    child->sur_deinit = deinit;
-    child->sur_threading = parent->sur_threading;
-
-    SU_TASK_COPY(child->sur_parent, su_root_task(parent), su_clone_start);
-
-    pthread_mutex_lock(&arg.mutex);
-    if (pthread_create(&tid, NULL, su_clone_main, &arg) == 0) {
-      pthread_cond_wait(&arg.cv, &arg.mutex);
-      thread_created = 1;
-    }
-    pthread_mutex_unlock(&arg.mutex);
-
-    if (arg.retval != 0) {
-      if (thread_created)
-       pthread_join(tid, NULL);
-      su_root_destroy(child), child = NULL;
-    }
-    else {
-      retval = 0;
-      *return_clone = *arg.clone;
-    }
-  } else
-#endif
-  if (child) {
-    assert(parent);
-
-    child->sur_magic = magic;
-    child->sur_deinit = deinit;
-    child->sur_threading = parent->sur_threading;
-
-    SU_TASK_COPY(child->sur_parent, su_root_task(parent), su_clone_start);
-    SU_TASK_COPY(child->sur_task, child->sur_parent, su_clone_start);
-    su_task_attach(child->sur_task, child);
-
-    if (su_msg_create(return_clone,
-                     child->sur_task, su_root_task(parent),
-                     su_clone_xyzzy, sizeof(child)) == 0) {
-      if (init == NULL || init(child, magic) == 0) {
-       su_cloned_t *sc = su_msg_data(return_clone);
-       sc->sc_root = child;
-#if SU_HAVE_PTHREADS
-       sc->sc_tid = pthread_self();
-       pthread_mutex_init(sc->sc_pause, NULL);
-       pthread_cond_init(sc->sc_resume, NULL);
-       pthread_mutex_lock(sc->sc_pause);
-#endif
-       retval = 0;
-      } else {
-       if (deinit)
-         deinit(child, magic);
-       su_msg_destroy(return_clone);
-       su_root_destroy(child), child = NULL;
-      }
-    }
-    else {
-      su_root_destroy(child), child = NULL;
-    }
-  }
-
-  return retval;
-}
-
-/** Get reference to clone task.
- * 
- * @param clone Clone pointer
- *
- * @return A reference to the task structure of the clone.
- */
-_su_task_r su_clone_task(su_clone_r clone)
-{
-  return su_msg_to(clone);
-}
-
-/**Forget the clone.
- * 
- * Normally, the clone task executes until it is stopped.  If the parent
- * task does not need to stop the task, it can "forget" the clone.  The
- * clone exits independently of the parent task.
- *
- * @param rclone Reference to the clone.
- */
-void su_clone_forget(su_clone_r rclone)
-{
-  su_msg_destroy(rclone);
-}
-
-/** Stop the clone.
- *
- * @deprecated. Use su_clone_wait().
- */
-void su_clone_stop(su_clone_r rclone)
-{
-  su_msg_send(rclone);
-}
-
-/** Stop a clone and wait until it is has completed.
- *
- * The function su_clone_wait() is used to stop the clone task and wait
- * until it has cleaned up. The clone task is destroyed asynchronously. The
- * parent sends a message to clone, clone deinitializes itself and then
- * replies. After the reply message is received by the parent, it will send
- * a third message back to clone.
- *
- * The parent destroy all messages to or from clone task before calling
- * su_clone_wait(). The parent task may not send any messages to the clone
- * after calling su_clone_wait(). The su_clone_wait() function blocks until
- * the cloned task is destroyed. During that time, the parent task must be
- * prepared to process all the messages sent by clone task. This includes
- * all the messages sent by clone before destroy message reached the clone.
- */
-void su_clone_wait(su_root_t *root, su_clone_r rclone)
-{
-  su_cloned_t *sc = su_msg_data(rclone);
-
-  if (sc) {
-#if SU_HAVE_PTHREADS
-    pthread_t clone_tid = sc->sc_tid;
-#endif
-    int one = 1;
-    /* This does 3-way handshake. 
-     * First, su_clone_break() is executed by clone. 
-     * The message is returned to parent (this task), 
-     * which executes su_clone_report().
-     * Then the message is again returned to clone, 
-     * which executes su_clone_report2() and exits.
-     */
-    sc->sc_wait = &one;
-    su_msg_send(rclone);
-
-    su_root_step(root, 0);
-    su_root_step(root, 0);
-
-    while (one)
-      su_root_step(root, 10);
-
-#if SU_HAVE_PTHREADS
-    if (!pthread_equal(clone_tid, pthread_self()))
-      pthread_join(clone_tid, NULL);
-#endif
-  }
-}
-
-#if SU_HAVE_PTHREADS           /* No-op without threads */
-static
-void su_clone_paused(su_root_magic_t *magic, su_msg_r msg, su_msg_arg_t *arg)
-{
-  su_cloned_t *cloned = *(su_cloned_t **)arg;
-  assert(cloned);
-  pthread_cond_wait(cloned->sc_resume, cloned->sc_pause);
-}
-#endif
-
-/** Pause a clone.
- *
- * Obtain a exclusive lock on clone's private data.
- *
- * @retval 0 if successful (and clone is paused)
- * @retval -1 upon an error
- */
-int su_clone_pause(su_clone_r rclone)
-{
-#if SU_HAVE_PTHREADS           /* No-op without threads */
-  su_cloned_t *cloned = su_msg_data(rclone);
-  su_msg_r m = SU_MSG_R_INIT;
-
-  if (!cloned)
-    return (errno = EFAULT), -1;
-
-  if (pthread_equal(pthread_self(), cloned->sc_tid))
-    return 0;
-
-  if (su_msg_create(m, su_clone_task(rclone), su_task_null,
-                   su_clone_paused, sizeof cloned) < 0)
-    return -1;
-
-  *(su_cloned_t **)su_msg_data(m) = cloned;
-
-  if (su_msg_send(m) < 0)
-    return -1;
-
-  if (pthread_mutex_lock(cloned->sc_pause) < 0)
-    return -1;
-  pthread_cond_signal(cloned->sc_resume);
-#endif
-
-  return 0;
-}
-
-/** Resume a clone.
- *
- * Give up a exclusive lock on clone's private data.
- *
- * @retval 0 if successful (and clone is resumed)
- * @retval -1 upon an error
- */
-int su_clone_resume(su_clone_r rclone)
-{
-#if SU_HAVE_PTHREADS           /* No-op without threads */
-  su_cloned_t *cloned = su_msg_data(rclone);
-
-  if (!cloned)
-    return (errno = EFAULT), -1;
-
-  if (pthread_equal(pthread_self(), cloned->sc_tid))
-    return 0;
-
-  if (pthread_mutex_unlock(cloned->sc_pause) < 0)
-    return -1;
-#endif
-
-  return 0;
-}
-
-
 /* =========================================================================
  * Messages
  */
@@ -1405,12 +854,9 @@ int su_msg_create(su_msg_r        rmsg,
                  su_msg_f        wakeup,
                  isize_t         size)
 {
-  su_port_t *port = to->sut_port;
   su_msg_t *msg;
 
-  SU_PORT_LOCK(port, su_msg_create);
-  msg = su_zalloc(NULL /*port->sup_home*/, sizeof(*msg) + size);
-  SU_PORT_UNLOCK(port, su_msg_create);
+  msg = su_zalloc(NULL, sizeof(*msg) + size);
 
   if (msg) {
     msg->sum_size = sizeof(*msg) + size;
@@ -1522,14 +968,14 @@ void su_msg_destroy(su_msg_r rmsg)
   if (rmsg[0]) {
     /* su_port_t *port = rmsg[0]->sum_to->sut_port; */
 
-    /* SU_PORT_INCREF(port, su_msg_destroy); */
+    /* su_port_incref(port, "su_msg_destroy"); */
     SU_TASK_ZAP(rmsg[0]->sum_to, su_msg_destroy);
     SU_TASK_ZAP(rmsg[0]->sum_from, su_msg_destroy);
 
     su_free(NULL /* port->sup_home */, rmsg[0]);
     /* SU_PORT_UNLOCK(port, su_msg_destroy); */
 
-    /* SU_PORT_DECREF(port, su_msg_destroy); */
+    /* su_port_decref(port, "su_msg_destroy"); */
   }
 
   rmsg[0] = NULL;
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_select_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_select_port.c
new file mode 100644 (file)
index 0000000..807b589
--- /dev/null
@@ -0,0 +1,657 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_select_port.c
+ *
+ * Port implementation using select().
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Fri Jan 26 17:56:34 2007 ppessi
+ */
+
+#include "config.h"
+
+#if HAVE_SELECT
+
+#define su_port_s su_select_port_s
+
+#include "sofia-sip/su.h"
+#include "su_port.h"
+#include "sofia-sip/su_alloc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#if HAVE_WIN32
+#error winsock select() not supported yet
+#else
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#elif HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifndef __NFDBITS
+#define __NFDBITS (8 * sizeof (long int))
+#endif
+
+#undef FDSETSIZE
+/* Size of fd set in bytes */
+#define FDSETSIZE(n) (((n) + __NFDBITS - 1) / __NFDBITS * (__NFDBITS / 8))
+#endif
+
+/** Port based on select(). */
+
+struct su_select_port_s {
+  su_socket_port_t sup_base[1];
+
+#define sup_home sup_base->sup_base->sup_base->sup_home
+
+  /** epoll fd */
+  int              sup_epoll;
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+                                     su_port_register() or 
+                                     su_port_unregister()
+                                  */
+  int              sup_n_registrations;
+  int              sup_max_index; /**< Indexes are equal or smaller than this */
+  int              sup_size_indices; /**< Size of allocated index table */
+
+  /** Structure containing registration data */
+  struct su_select_register {
+    struct su_select_register *ser_next; /* Next in free list */
+    su_wakeup_f     ser_cb; 
+    su_wakeup_arg_t*ser_arg; 
+    su_root_t      *ser_root; 
+    int             ser_id; /** registration identifier */
+    su_wait_t       ser_wait[1];
+  } **sup_indices;
+
+  int               sup_maxfd, sup_allocfd;
+  
+  fd_set           *sup_readfds, *sup_readfds2;
+  fd_set           *sup_writefds, *sup_writefds2;
+};
+
+static void su_select_port_decref(su_port_t *self,
+                                int blocking,
+                                char const *who);
+static int su_select_port_register(su_port_t *self,
+                                 su_root_t *root, 
+                                 su_wait_t *wait, 
+                                 su_wakeup_f callback,
+                                 su_wakeup_arg_t *arg,
+                                 int priority);
+static int su_select_port_unregister(su_port_t *port,
+                                   su_root_t *root, 
+                                   su_wait_t *wait,    
+                                   su_wakeup_f callback, 
+                                   su_wakeup_arg_t *arg);
+static int su_select_port_deregister(su_port_t *self, int i);
+static int su_select_port_unregister_all(su_port_t *self, su_root_t *root);
+static int su_select_port_eventmask(su_port_t *self, 
+                                  int index,
+                                  int socket,
+                                  int events);
+static int su_select_port_multishot(su_port_t *self, int multishot);
+static int su_select_port_wait_events(su_port_t *self, su_duration_t tout);
+static char const *su_select_port_name(su_port_t const *self);
+
+su_port_vtable_t const su_select_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_select_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_select_port_decref,
+      su_base_port_gsource,
+      su_socket_port_send,
+      su_select_port_register,
+      su_select_port_unregister,
+      su_select_port_deregister,
+      su_select_port_unregister_all,
+      su_select_port_eventmask,
+      su_base_port_run,
+      su_base_port_break,
+      su_base_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_select_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_select_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_select_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
+    }};
+
+static char const *su_select_port_name(su_port_t const *self)
+{
+  return "select";
+}
+
+static void su_select_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  (void)su_base_port_decref(self, blocking, who);
+}
+
+static void su_select_port_deinit(void *arg)
+{
+  su_port_t *self = arg;
+
+  SU_DEBUG_9(("%s(%p) called\n", "su_select_port_deinit", (void *)self));
+
+  su_socket_port_deinit(self->sup_base);
+}
+
+/** @internal
+ *
+ *  Register a #su_wait_t object. The wait object, a callback function and
+ *  an argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
+ *
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
+ * 
+ * @param self      pointer to port
+ * @param root      pointer to root object
+ * @param waits             pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg       argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
+ * 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_select_port_register(su_port_t *self,
+                          su_root_t *root, 
+                          su_wait_t *wait, 
+                          su_wakeup_f callback,
+                          su_wakeup_arg_t *arg,
+                          int priority)
+{
+  int i, j, n;
+  struct su_select_register *ser;
+  struct su_select_register **indices = self->sup_indices;
+  int allocfd = self->sup_allocfd;
+  fd_set *readfds = self->sup_readfds, *readfds2 = self->sup_readfds2;
+  fd_set *writefds = self->sup_writefds, *writefds2 = self->sup_writefds2;
+
+  assert(su_port_own_thread(self));
+
+  n = self->sup_size_indices;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  self->sup_registers++;
+
+  if (wait->fd >= allocfd) 
+    allocfd += __NFDBITS;              /* long at a time */
+
+  if (allocfd >= self->sup_allocfd) {
+    size_t bytes = FDSETSIZE(allocfd);
+    size_t bytes0 = FDSETSIZE(self->sup_allocfd);
+    /* (Re)allocate fd_sets  */
+
+    readfds = su_realloc(self->sup_home, readfds, bytes);
+    if (readfds) self->sup_readfds = readfds;
+    readfds2 = su_realloc(self->sup_home, readfds2, bytes);
+    if (readfds2) self->sup_readfds2 = readfds2;
+    if (!readfds || !readfds2)
+      return -1;
+
+    writefds = su_realloc(self->sup_home, writefds, bytes);
+    if (writefds) self->sup_writefds = writefds;
+    writefds2 = su_realloc(self->sup_home, writefds2, bytes);
+    if (writefds2) self->sup_writefds2 = writefds2;
+    if (!writefds || !writefds2)
+      return -1;
+
+    memset((char *)readfds + bytes0, 0, bytes - bytes0);
+    memset((char *)writefds + bytes0, 0, bytes - bytes0);
+
+    self->sup_allocfd = allocfd;
+  }
+
+  ser = indices[0];
+
+  if (!ser) {
+    su_home_t *h = su_port_home(self);
+
+    i = self->sup_max_index, j = i == 0 ? 15 : i + 16;
+    
+    if (j >= self->sup_size_indices) {
+      /* Reallocate index table */
+      n = n < 1024 ? 2 * n : n + 1024;
+      indices = su_realloc(h, indices, n * sizeof(indices[0]));
+      if (!indices)
+       return -1;
+      self->sup_indices = indices;
+      self->sup_size_indices = n;
+    }
+
+    /* Allocate registrations */
+    ser = su_zalloc(h, (j - i) * (sizeof *ser));
+    if (!ser)
+      return -1;
+
+    indices[0] = ser;
+
+    for (i++; i <= j; i++) {
+      ser->ser_id = i;
+      ser->ser_next = i < j ? ser + 1 : NULL;
+      indices[i] = ser++;
+    }
+
+    self->sup_max_index = j;
+
+    ser = indices[0];
+  }
+
+  i = ser->ser_id;
+
+  indices[0] = ser->ser_next;
+  
+  ser->ser_next = NULL;
+  *ser->ser_wait = *wait;
+  ser->ser_cb = callback;
+  ser->ser_arg = arg;
+  ser->ser_root = root;
+
+  if (wait->events & SU_WAIT_IN)
+    FD_SET(wait->fd, readfds);
+  if (wait->events & SU_WAIT_OUT)
+    FD_SET(wait->fd, writefds);
+
+  if (wait->fd >= self->sup_maxfd)
+    self->sup_maxfd = wait->fd + 1;
+
+  self->sup_n_registrations++;
+
+  return i;                    /* return index */
+}
+
+static void su_select_port_update_maxfd(su_port_t *self)
+{
+  int i;
+  su_socket_t maxfd = 0;
+
+  for (i = 1; i <= self->sup_max_index; i++) {
+    if (!self->sup_indices[i]->ser_cb)
+      continue;
+    if (maxfd <= self->sup_indices[i]->ser_wait->fd)
+      maxfd = self->sup_indices[i]->ser_wait->fd + 1;
+  }
+
+  self->sup_maxfd = maxfd;
+}
+
+/** Deregister a su_wait_t object. */
+static int su_select_port_deregister0(su_port_t *self, int i, int destroy_wait)
+{
+  struct su_select_register **indices = self->sup_indices;
+  struct su_select_register *ser;
+
+  ser = self->sup_indices[i];
+  if (ser == NULL || ser->ser_cb == NULL) {
+    su_seterrno(ENOENT);
+    return -1;
+  }
+
+  assert(ser->ser_id == i);
+
+  FD_CLR(ser->ser_wait->fd, self->sup_readfds);
+  FD_CLR(ser->ser_wait->fd, self->sup_writefds);
+
+  if (ser->ser_wait->fd + 1 >= self->sup_maxfd)
+    self->sup_maxfd = 0;
+
+  memset(ser, 0, sizeof *ser);
+  ser->ser_id = i;
+  ser->ser_next = indices[0], indices[0] = ser;
+
+  self->sup_n_registrations--;
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ * The function su_select_port_unregister() unregisters a su_wait_t object. 
+ * The registration defined by the wait object, the callback function and
+ * the argument pointer are removed from the port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
+ *
+ * @deprecated Use su_select_port_deregister() instead. 
+ *
+ * @return Nonzero index of the wait object, or -1 upon an error.
+ */
+int su_select_port_unregister(su_port_t *self,
+                            su_root_t *root, 
+                            su_wait_t *wait,   
+                            su_wakeup_f callback, /* XXX - ignored */
+                            su_wakeup_arg_t *arg)
+{
+  int i, I;
+
+  struct su_select_register *ser;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1; i <= I; i++) {
+    ser = self->sup_indices[i];
+
+    if (ser->ser_cb &&
+       arg == ser->ser_arg &&
+       SU_WAIT_CMP(wait[0], ser->ser_wait[0]) == 0)
+      return su_select_port_deregister0(self, ser->ser_id, 0);
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
+}
+
+/** Deregister a su_wait_t object.
+ *  
+ *  Deregisters a registration by index. The wait object, a callback
+ *  function and a argument are removed from the port object. The wait
+ *  object is destroyed.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_select_port_deregister(su_port_t *self, int i)
+{
+  struct su_select_register *ser;
+
+  if (i <= 0 || i > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[i];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  return su_select_port_deregister0(self, i, 1);
+}
+
+
+/** @internal
+ * Unregister all su_wait_t objects of given su_root_t instance.
+ *
+ * The function su_select_port_unregister_all() unregisters all su_wait_t
+ * objects associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_select_port_unregister_all(su_port_t *self, su_root_t *root)
+{
+  int i, I, n;
+
+  struct su_select_register *ser;
+
+  assert(self); assert(root);
+  assert(su_port_own_thread(self));
+
+  I = self->sup_max_index;
+
+  for (i = 1, n = 0; i <= I; i++) {
+    ser = self->sup_indices[i];
+    if (ser->ser_root != root)
+      continue;
+    su_select_port_deregister0(self, ser->ser_id, 0);
+    n++;
+  }
+
+  return n;
+}
+
+/**Set mask for a registered event. @internal
+ *
+ * The function su_select_port_eventmask() sets the mask describing events
+ * that can signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.
+ */
+int su_select_port_eventmask(su_port_t *self,
+                            int index,
+                            int socket, int events)
+{
+  struct su_select_register *ser;
+
+  if (index <= 0 || index > self->sup_max_index)
+    return su_seterrno(EBADF);
+
+  ser = self->sup_indices[index];
+  if (!ser->ser_cb)
+    return su_seterrno(EBADF);
+
+  if (self->sup_maxfd == 0)
+    su_select_port_update_maxfd(self);
+
+  if (socket >= self->sup_maxfd)
+    return su_seterrno(EBADF);
+
+  if (su_wait_mask(ser->ser_wait, socket, events) < 0)
+    return -1;
+
+  assert(socket < self->sup_maxfd);
+  
+  if (events & SU_WAIT_IN)
+    FD_SET(socket, self->sup_readfds);
+  else
+    FD_CLR(socket, self->sup_readfds);
+
+  if (events & SU_WAIT_OUT)
+    FD_SET(socket, self->sup_writefds);
+  else
+    FD_CLR(socket, self->sup_writefds);
+
+  return 0;
+}
+
+/** @internal Enable multishot mode.
+ *
+ * Enables, disables or queries the multishot mode for the port. The
+ * multishot mode determines how the events are scheduled by port. If
+ * multishot mode is enabled, port serves all the sockets that have received
+ * network events. If it is disabled, only first socket event is served.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+static
+int su_select_port_multishot(su_port_t *self, int multishot)
+{
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
+}
+
+
+/** @internal
+ * Wait (poll()) for wait objects in port.
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ *
+ * @return number of events handled
+ */
+static
+int su_select_port_wait_events(su_port_t *self, su_duration_t tout)
+{
+  int j, n, events = 0;
+  unsigned version = self->sup_registers;
+  size_t bytes;
+  struct timeval tv;
+  fd_set *rset = NULL, *wset = NULL;
+
+  if (self->sup_maxfd == 0)
+    su_select_port_update_maxfd(self);
+
+  bytes = self->sup_maxfd ? FDSETSIZE(self->sup_maxfd - 1) : 0;
+
+  if (bytes) {
+    rset = memcpy(self->sup_readfds2, self->sup_readfds, bytes);
+    wset = memcpy(self->sup_writefds2, self->sup_writefds, bytes);
+  }  
+
+  tv.tv_sec = tout / 1000;
+  tv.tv_usec = (tout % 1000) * 1000;
+
+  n = select(self->sup_maxfd, rset, wset, NULL, &tv);
+
+  if (n <= 0) {
+    SU_DEBUG_0(("su_select_port_wait_events(%p): %s (%d)\n",
+               (void *)self, su_strerror(su_errno()), su_errno()));
+    return 0;
+  }
+
+  for (j = 1; j < self->sup_max_index; j++) {
+    struct su_select_register *ser;
+    su_root_magic_t *magic;
+    int fd;
+
+    ser = self->sup_indices[j];
+    if (!ser->ser_cb)
+      continue;
+
+    fd = ser->ser_wait->fd;
+    ser->ser_wait->revents = 0;
+
+    if (ser->ser_wait->events & SU_WAIT_IN)
+      if (FD_ISSET(fd, rset)) ser->ser_wait->revents |= SU_WAIT_IN, n--;
+    if (ser->ser_wait->events & SU_WAIT_OUT)
+      if (FD_ISSET(fd, wset)) ser->ser_wait->revents |= SU_WAIT_OUT, n--;
+
+    if (ser->ser_wait->revents) {
+      magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
+      ser->ser_cb(magic, ser->ser_wait, ser->ser_arg);
+      events++;
+      if (version != self->sup_registers)
+       /* Callback function used su_register()/su_deregister() */
+       return events;
+      if (!self->sup_multishot)
+       /* Callback function used su_register()/su_deregister() */
+       return events;
+    }
+
+    if (n == 0)
+      break;
+  }    
+
+  assert(n == 0);
+
+  return events;
+}
+
+/** Create a port using epoll() or poll().
+ */
+su_port_t *su_select_port_create(void)
+{
+  su_port_t *self;
+
+  self = su_home_new(sizeof *self);
+  if (!self)
+    return NULL;
+
+  if (su_home_destructor(su_port_home(self), su_select_port_deinit) < 0 ||
+      !(self->sup_indices = 
+       su_zalloc(su_port_home(self),
+                 (sizeof self->sup_indices[0]) * 
+                 (self->sup_size_indices = __NFDBITS)))) {
+    su_home_unref(su_port_home(self));
+    return NULL;
+  }
+
+  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
+
+  if (su_socket_port_init(self->sup_base, su_select_port_vtable) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  return self;
+}
+
+int su_select_clone_start(su_root_t *parent,
+                        su_clone_r return_clone,
+                        su_root_magic_t *magic,
+                        su_root_init_f init,
+                        su_root_deinit_f deinit)
+{
+  return su_pthreaded_port_start(su_select_port_create, 
+                                parent, return_clone, magic, init, deinit);
+}
+
+
+#endif
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_socket_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_socket_port.c
new file mode 100644 (file)
index 0000000..6843133
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_socket_port.c
+ *
+ * OS-Independent Syncronization Interface with socket mailbox
+ *
+ * This implements wakeup using sockets by su_port_send().
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#define su_socket_port_s su_port_s
+#define SU_CLONE_T su_msg_t
+
+#include "sofia-sip/su.h"
+#include "su_port.h"
+#include "sofia-sip/su_alloc.h"
+
+#if HAVE_SOCKETPAIR
+#define SU_MBOX_SEND 1
+#else
+#define SU_MBOX_SEND 0
+#endif
+
+/** @internal Message box wakeup function. */
+static int su_mbox_port_wakeup(su_root_magic_t *magic, /* NULL */
+                              su_wait_t *w,
+                              su_wakeup_arg_t *arg)
+{
+  char buf[32];
+  su_socket_t socket = *(su_socket_t*)arg;
+  su_wait_events(w, socket);
+  recv(socket, buf, sizeof(buf), 0);
+  return 0;
+}
+
+/**@internal
+ *
+ * Initializes a message port. It creates a mailbox used to wake up the
+ * thread waiting on the port if needed. Currently, the mailbox is a
+ * socketpair or an UDP socket connected to itself.
+ */
+int su_socket_port_init(su_port_t *self, su_port_vtable_t const *vtable)
+{
+  int retval = -1;
+  int af;
+  su_socket_t mb = INVALID_SOCKET;
+  su_wait_t wait[1] = { SU_WAIT_INIT };
+  char const *why;
+
+  SU_DEBUG_9(("su_socket_port_init(%p, %p) called\n", 
+             (void *)self, (void *)vtable));
+
+  if (su_pthread_port_init(self, vtable) != 0)
+    return -1;
+
+#if HAVE_SOCKETPAIR
+#if defined(AF_LOCAL)
+  af = AF_LOCAL;
+#else
+  af = AF_UNIX;
+#endif
+
+  if (socketpair(af, SOCK_STREAM, 0, self->sup_mbox) == -1) {
+    why = "socketpair"; goto error;
+  }
+
+  mb = self->sup_mbox[0];
+  su_setblocking(self->sup_mbox[1], 0);
+
+#else
+  {
+    struct sockaddr_in sin = { sizeof(struct sockaddr_in), 0 };
+    socklen_t sinsize = sizeof sin;
+    struct sockaddr *sa = (struct sockaddr *)&sin;
+    
+    af = PF_INET;
+      
+    self->sup_mbox[0] = mb = su_socket(af, SOCK_DGRAM, IPPROTO_UDP);
+    if (mb == INVALID_SOCKET) {
+      why = "socket"; goto error;
+    }
+    
+    sin.sin_family = AF_INET;
+    sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* 127.1 */
+      
+    /* Get a port for us */
+    if (bind(mb, sa, sizeof sin) == -1) {
+      why = "bind"; goto error;
+    }
+
+    if (getsockname(mb, sa, &sinsize) == -1) {
+      why = "getsockname"; goto error;
+    }
+    
+    if (connect(mb, sa, sinsize) == -1) {
+      why = "connect"; goto error;
+    }
+  }
+#endif    
+
+  if (su_wait_create(wait, mb, SU_WAIT_IN) == -1) {
+    why = "su_wait_create";
+    goto error;
+  }
+
+  self->sup_mbox_index = su_port_register(self, NULL, wait, 
+                                         su_mbox_port_wakeup, 
+                                         (void *)self->sup_mbox, 0);
+
+  if (self->sup_mbox_index <= 0) {
+    why = "su_port_register";
+    su_wait_destroy(wait);
+    goto error;
+  }
+
+  return 0;
+  
+  error:
+    su_log("%s: %s: %s\n", "su_socket_port_init", 
+          why, su_strerror(su_errno()));
+
+  return retval;
+}
+
+
+/** @internal Deinit a base implementation of port. */
+void su_socket_port_deinit(su_port_t *self)
+{
+  assert(self);
+
+  if (self->sup_mbox_index > 0)
+    su_port_deregister(self, self->sup_mbox_index);
+  self->sup_mbox_index = 0;
+
+  if (self->sup_mbox[0] && self->sup_mbox[0] != INVALID_SOCKET)
+    su_close(self->sup_mbox[0]); self->sup_mbox[0] = INVALID_SOCKET;
+#if HAVE_SOCKETPAIR
+  if (self->sup_mbox[1] && self->sup_mbox[1] != INVALID_SOCKET)
+    su_close(self->sup_mbox[1]); self->sup_mbox[1] = INVALID_SOCKET;
+#endif
+
+  su_pthread_port_deinit(self);
+}
+
+/** @internal Send a message to the port. */
+int su_socket_port_send(su_port_t *self, su_msg_r rmsg)
+{
+  int wakeup = su_base_port_send(self, rmsg);
+
+  if (wakeup < 0)
+    return -1;
+
+  if (wakeup) {
+    assert(self->sup_mbox[SU_MBOX_SEND] != INVALID_SOCKET);
+
+    if (send(self->sup_mbox[SU_MBOX_SEND], "X", 1, 0) == -1) {
+#if HAVE_SOCKETPAIR
+      if (su_errno() != EWOULDBLOCK)
+#endif
+       su_perror("su_msg_send: send()");
+    }
+  }
+
+  return 0;
+}
index ae93983c576c65a39057fc69f156e81805c38bf6..cb9ba9341bf27c4d4d6ae48ad57316c99782517c 100644 (file)
 #include <time.h>
 
 #include "sofia-sip/su_types.h"
-#include "sofia-sip/su_time.h"
 #include "su_module_debug.h"
 
+/* Include bodies of inlined functions */
+#undef su_inline
+#define su_inline
+#undef SU_HAVE_INLINE
+#define SU_HAVE_INLINE 1
+
+#include "sofia-sip/su_time.h"
+
 #if HAVE_SYS_TIME_H
 #include <sys/time.h> /* Get struct timeval */
 #endif
index 67a24b6752e84fe42413497fcce8d4b20ce1f99a..b17625859e29247096ffe572a98b37ce8dadf04c 100644 (file)
@@ -157,8 +157,9 @@ struct su_timer_s {
   unsigned char   sut_set;     /**< Timer is set (inserted in tree) */
 };
 
+/** @internal Timer running status */ 
 enum sut_running {
-  reset = 0,
+  reset = 0,           /**< Timer is not running */
   run_at_intervals = 1, /**< Compensate missed wakeup calls */
   run_for_ever = 2     /**< Do not compensate  */
 };
@@ -193,7 +194,10 @@ RBTREE_BODIES(static inline, timers, su_timer_t,
              IS_RED, SET_RED, IS_BLACK, SET_BLACK, COPY_COLOR,
              CMP, INSERT, REMOVE);
 
-/** Set the timer. */
+/**@internal Set the timer. 
+ *
+ * @retval 0 when successful (always)
+ */
 static inline int
 su_timer_set0(su_timer_t **timers,
              su_timer_t *t,
@@ -212,7 +216,10 @@ su_timer_set0(su_timer_t **timers,
   return timers_append(timers, t);
 }
 
-/** Reset the timer. */
+/**@internal Reset the timer. 
+ *
+ * @retval 0 when successful (always)
+ */
 static inline int
 su_timer_reset0(su_timer_t **timers,
                su_timer_t *t)
@@ -229,6 +236,40 @@ su_timer_reset0(su_timer_t **timers,
   return 0;
 }
 
+/**@internal Validate timer @a t and return pointer to per-port timer tree.
+ * 
+ * @retval pointer to pointer to timer tree when successful
+ * @retval NULL upon an error
+ */
+static
+su_timer_t **su_timer_tree(su_timer_t const *t,
+                          int use_sut_duration,
+                          char const *caller)
+{
+  su_timer_t **timers;
+
+  if (t == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t,
+               "NULL argument"));
+    return NULL;
+  }
+
+  timers = su_task_timers(t->sut_task);
+
+  if (timers == NULL)
+    SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t,
+               "invalid timer"));
+
+  if (use_sut_duration && t->sut_duration == 0) {
+    assert(t->sut_duration > 0);
+    SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t, 
+               "timer without default duration"));
+    return NULL;
+  }
+
+  return timers;
+}
+
 
 /**Create a timer.
  *
@@ -291,23 +332,12 @@ int su_timer_set_interval(su_timer_t *t,
                          su_timer_arg_t *arg,
                          su_duration_t interval)
 {
-  char const *func = "su_timer_set_interval";
-  su_timer_t **timers;
+  su_timer_t **timers = su_timer_tree(t, 0, "su_timer_set_interval");
 
-  if (t == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
-    return -1;
-  }
-
-  timers = su_task_timers(t->sut_task);
-  if (timers == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
+  if (t == NULL)
     return -1;
-  }
 
-  su_timer_set0(timers, t, wakeup, arg, su_now(), interval);
-
-  return 0;
+  return su_timer_set0(timers, t, wakeup, arg, su_now(), interval);
 }
 
 /** Set the timer for the default interval.
@@ -326,18 +356,12 @@ int su_timer_set(su_timer_t *t,
                 su_timer_f wakeup,
                 su_timer_arg_t *arg)
 {
-  char const *func = "su_timer_set";
+  su_timer_t **timers = su_timer_tree(t, 1, "su_timer_set");
 
-  if (t == NULL)
+  if (timers == NULL)
     return -1;
 
-  assert(t->sut_duration > 0);
-  if (t->sut_duration == 0) {
-    SU_DEBUG_0(("%s(%p): %s\n", func, t, "timer without default duration"));
-    return -1;
-  }
-
-  return su_timer_set_interval(t, wakeup, arg, t->sut_duration);
+  return su_timer_set0(timers, t, wakeup, arg, su_now(), t->sut_duration);
 }
 
 /** Set timer at known time.
@@ -356,23 +380,12 @@ int su_timer_set_at(su_timer_t *t,
                    su_wakeup_arg_t *arg,
                    su_time_t when)
 {
-  char const *func = "su_timer_set_at";
-  su_timer_t **timers;
+  su_timer_t **timers = su_timer_tree(t, 0, "su_timer_set_at");
 
-  if (t == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
+  if (timers == NULL)
     return -1;
-  }
 
-  timers = su_task_timers(t->sut_task);
-  if (timers == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
-    return -1;
-  }
-
-  su_timer_set0(timers, t, wakeup, arg, when, 0);
-
-  return 0;
+  return su_timer_set0(timers, t, wakeup, arg, when, 0);
 }
 
 /** Set the timer for regular intervals.
@@ -397,34 +410,17 @@ int su_timer_run(su_timer_t *t,
                 su_timer_f wakeup,
                 su_timer_arg_t *arg)
 {
-  char const *func = "su_timer_run";
-  su_timer_t **timers;
-  su_time_t now = su_now();
-
-  if (t == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
-    return -1;
-  }
+  su_timer_t **timers = su_timer_tree(t, 1, "su_timer_run");
+  su_time_t now;
 
-  assert(t->sut_duration > 0);
-  if (t->sut_duration == 0) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "timer without default duration"));
+  if (timers == NULL)
     return -1;
-  }
-
-  timers = su_task_timers(t->sut_task);
-  if (timers == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
-    return -1;
-  }
 
   t->sut_running = run_at_intervals;
-  t->sut_run = now;
+  t->sut_run = now = su_now();
   t->sut_woken = 0;
 
-  su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
-
-  return 0;
+  return su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
 }
 
 /**Set the timer for regular intervals.
@@ -447,37 +443,19 @@ int su_timer_set_for_ever(su_timer_t *t,
                          su_timer_f wakeup,
                          su_timer_arg_t *arg)
 {
-  char const *func = "su_timer_run";
-  su_timer_t **timers;
-  su_time_t now = su_now();
-
-  if (t == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
-    return -1;
-  }
+  su_timer_t **timers = su_timer_tree(t, 1, "su_timer_set_for_ever");
+  su_time_t now;
 
-  assert(t->sut_duration > 0);
-  if (t->sut_duration == 0) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "timer without default duration"));
+  if (timers == NULL)
     return -1;
-  }
-
-  timers = su_task_timers(t->sut_task);
-  if (timers == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
-    return -1;
-  }
 
   t->sut_running = run_for_ever;
-  t->sut_run = now;
+  t->sut_run = now = su_now();
   t->sut_woken = 0;
 
-  su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
-
-  return 0;
+  return su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
 }
 
-
 /**Reset the timer.
  *
  * Resets (stops) the given timer.
@@ -488,19 +466,12 @@ int su_timer_set_for_ever(su_timer_t *t,
  */
 int su_timer_reset(su_timer_t *t)
 {
-  char const *func = "su_timer_reset";
-  su_timer_t **timers;
+  su_timer_t **timers = su_timer_tree(t, 0, "su_timer_reset");
 
-  if (t == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
+  if (timers == NULL)
     return -1;
-  }
 
-  timers = su_task_timers(t->sut_task);
-
-  su_timer_reset0(timers, t);
-
-  return 0;
+  return su_timer_reset0(timers, t);
 }
 
 /** @internal Check for expired timers in queue.
@@ -574,6 +545,7 @@ int su_timer_expire(su_timer_t ** const timers,
 }
 
 
+/** Calculate duration in milliseconds until next timer expires. */
 su_duration_t su_timer_next_expires(su_timer_t const * t, su_time_t now)
 {
   su_duration_t tout;
@@ -623,14 +595,13 @@ int su_timer_reset_all(su_timer_t **timers, su_task_r task)
 
 /** Get the root object owning the timer.
  *
- *   The function su_timer_root() return pointer to the root object owning the
- *   timer.
+ * Return pointer to the root object owning the timer.
  *
  * @param t pointer to the timer
  *
- * @return Pointer to the root object owning the timer.
+ * @return Pointer to the root object.
  */
 su_root_t *su_timer_root(su_timer_t const *t)
 {
-  return su_task_root(t->sut_task);
+  return t ? su_task_root(t->sut_task) : NULL;
 }
index 7e412b41a002e5dbe71bd4b81d5d91266197e6dd..09c7ed930ad9a13b18f58d1b712d821fa27e643c 100644 (file)
@@ -31,6 +31,7 @@
  * (poll()/select()/WaitForMultipleObjects()) functionality.
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Martti Mela <Martti.Mela@nokia.com>
  * @date Created: Tue Sep 14 15:51:04 1999 ppessi
  *
  */
@@ -149,7 +150,7 @@ int su_wait_create(su_wait_t *newwait, su_socket_t socket, int events)
 
   *newwait = h;
 
-#elif SU_HAVE_POLL
+#elif SU_HAVE_POLL || HAVE_SELECT
   int mode;
 
   if (newwait == NULL || events == 0 || socket == INVALID_SOCKET) {
@@ -187,7 +188,9 @@ int su_wait_destroy(su_wait_t *waitobj)
   su_wait_t w0 = NULL;
   if (*waitobj)
     WSACloseEvent(*waitobj);
-#elif SU_HAVE_POLL
+#elif SU_HAVE_POLL || HAVE_SELECT
+  su_wait_t w0 = { INVALID_SOCKET, 0, 0 };
+#else
   su_wait_t w0 = { INVALID_SOCKET, 0, 0 };
 #endif
   assert(waitobj != NULL);
@@ -231,7 +234,7 @@ int su_wait(su_wait_t waits[], unsigned n, su_duration_t timeout)
   else
     return i;
 
-#elif SU_HAVE_POLL
+#elif SU_HAVE_POLL || HAVE_SELECT
   for (;;) {
     int i = poll(waits, n, timeout);
 
@@ -273,7 +276,7 @@ int su_wait_events(su_wait_t *waitobj, su_socket_t s)
 
   return net_events.lNetworkEvents;
 
-#elif SU_HAVE_POLL
+#elif SU_HAVE_POLL || HAVE_SELECT
   /* poll(e, 1, 0); */
   return waitobj->revents;
 #endif
@@ -302,7 +305,8 @@ int su_wait_mask(su_wait_t *waitobj, su_socket_t s, int events)
     WSASetLastError(error);
     return -1;
   }
-#elif SU_HAVE_POLL
+
+#elif SU_HAVE_POLL || HAVE_SELECT
   waitobj->fd = s;
   waitobj->events = events;
   waitobj->revents = 0;
diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_win32_port.c b/libs/sofia-sip/libsofia-sip-ua/su/su_win32_port.c
new file mode 100644 (file)
index 0000000..02ff3f4
--- /dev/null
@@ -0,0 +1,643 @@
+/*
+ * 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
+ *
+ */
+
+/**@ingroup su_wait
+ * @CFILE su_win32_port.c
+ *
+ * Port implementation using WSAEVENTs
+ *
+ * @author Pekka Pessi <Pekka.Pessi@nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen@nokia.com>
+ *
+ * @date Created: Mon Feb  5 20:29:21 2007 ppessi
+ * @date Original: Tue Sep 14 15:51:04 1999 ppessi
+ */
+
+#include "config.h"
+
+#define su_port_s su_wsaevent_port_s
+
+#include "sofia-sip/su.h"
+#include "su_port.h"
+#include "sofia-sip/su_alloc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+/** Port based on su_wait() aka WSAWaitForMultipleEvents. */
+
+#define INDEX_MAX (64)
+
+struct su_wsaevent_port_s {
+  su_socket_port_t sup_base[1];
+
+#define sup_home sup_base->sup_base->sup_base->sup_home
+
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+                                     su_port_register() or 
+                                     su_port_unregister()
+                                  */
+
+  int              sup_n_waits; /**< Active su_wait_t in su_waits */
+  int              sup_size_waits; /**< Size of allocated su_waits */
+  int              sup_pri_offset; /**< Offset to prioritized waits */
+
+  /** Indices from index returned by su_root_register() to tables below. 
+   *
+   * Free elements are negative. Free elements form a list, value of free
+   * element is (0 - index of next free element).
+   *
+   * First element sup_indices[0] points to first free element. 
+   */
+  int             *sup_indices;
+
+  int             *sup_reverses; /** Reverse index */
+  su_wakeup_f     *sup_wait_cbs; 
+  su_wakeup_arg_t**sup_wait_args; 
+  su_root_t      **sup_wait_roots; 
+  su_wait_t       *sup_waits; 
+
+};
+
+static void su_wsevent_port_decref(su_port_t *, int blocking, char const *who);
+
+static int su_wsevent_port_register(su_port_t *self,
+                                su_root_t *root, 
+                                su_wait_t *wait, 
+                                su_wakeup_f callback,
+                                su_wakeup_arg_t *arg,
+                                int priority);
+static int su_wsevent_port_unregister(su_port_t *port,
+                                  su_root_t *root, 
+                                  su_wait_t *wait,     
+                                  su_wakeup_f callback, 
+                                  su_wakeup_arg_t *arg);
+static int su_wsevent_port_deregister(su_port_t *self, int i);
+static int su_wsevent_port_unregister_all(su_port_t *self, su_root_t *root);
+static int su_wsevent_port_eventmask(su_port_t *self, 
+                                 int index,
+                                 int socket,
+                                 int events);
+static int su_wsevent_port_multishot(su_port_t *self, int multishot);
+static int su_wsevent_port_wait_events(su_port_t *self, su_duration_t tout);
+static char const *su_wsevent_port_name(su_port_t const *self);
+
+su_port_vtable_t const su_wsevent_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_wsevent_port_vtable,
+      su_pthread_port_lock,
+      su_pthread_port_unlock,
+      su_base_port_incref,
+      su_wsevent_port_decref,
+      su_base_port_gsource,
+      su_socket_port_send,
+      su_wsevent_port_register,
+      su_wsevent_port_unregister,
+      su_wsevent_port_deregister,
+      su_wsevent_port_unregister_all,
+      su_wsevent_port_eventmask,
+      su_base_port_run,
+      su_base_port_break,
+      su_base_port_step,
+      su_pthread_port_own_thread,
+      su_base_port_add_prepoll,
+      su_base_port_remove_prepoll,
+      su_base_port_timers,
+      su_wsevent_port_multishot,
+      su_base_port_threadsafe,
+      su_base_port_yield,
+      su_wsevent_port_wait_events,
+      su_base_port_getmsgs,
+      su_base_port_getmsgs_from,
+      su_wsevent_port_name,
+      su_base_port_start_shared,
+      su_pthread_port_wait,
+      su_pthread_port_execute,
+    }};
+
+static char const *su_wsevent_port_name(su_port_t const *self)
+{
+  return "poll";
+}
+
+static void su_wsevent_port_deinit(void *arg)
+{
+  su_port_t *self = arg;
+
+  SU_DEBUG_9(("%s(%p) called\n", "su_wsevent_port_deinit", self));
+
+  su_socket_port_deinit(self->sup_base);
+}
+
+static void su_wsevent_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  su_base_port_decref(self, blocking, who);
+}
+
+/** @internal
+ *
+ *  Register a @c su_wait_t object. The wait object, a callback function and
+ *  an argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
+ *
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
+ * 
+ * @param self      pointer to port
+ * @param root      pointer to root object
+ * @param waits             pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg       argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
+ * 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_wsevent_port_register(su_port_t *self,
+                         su_root_t *root, 
+                         su_wait_t *wait, 
+                         su_wakeup_f callback,
+                         su_wakeup_arg_t *arg,
+                         int priority)
+{
+  int i, j, n;
+
+  assert(su_port_own_thread(self));
+
+  n = self->sup_n_waits;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  if (n >= self->sup_size_waits) {
+    su_home_t *h = self->sup_home;
+    /* Reallocate size arrays */
+    int size;
+    int *indices;
+    int *reverses;
+    su_wait_t *waits;
+    su_wakeup_f *wait_cbs;
+    su_wakeup_arg_t **wait_args;
+    su_root_t **wait_tasks;
+
+    if (self->sup_size_waits == 0)
+      size = su_root_size_hint;
+    else 
+      size = 2 * self->sup_size_waits;
+
+    if (size < SU_WAIT_MIN)
+      size = SU_WAIT_MIN;
+
+    /* Too large */
+    if (-3 - size > 0)
+      return (errno = ENOMEM), -1;
+
+    indices = su_realloc(h, self->sup_indices, (size + 1) * sizeof(*indices));
+    if (indices) {
+      self->sup_indices = indices;
+
+      if (self->sup_size_waits == 0)
+       indices[0] = -1;
+
+      for (i = self->sup_size_waits + 1; i <= size; i++)
+       indices[i] = -1 - i;
+    }
+
+    reverses = su_realloc(h, self->sup_reverses, size * sizeof(*waits));
+    if (reverses) {
+      for (i = self->sup_size_waits; i < size; i++)
+       reverses[i] = -1;
+      self->sup_reverses = reverses;
+    }
+      
+    waits = su_realloc(h, self->sup_waits, size * sizeof(*waits));
+    if (waits)
+      self->sup_waits = waits;
+
+    wait_cbs = su_realloc(h, self->sup_wait_cbs, size * sizeof(*wait_cbs));
+    if (wait_cbs)
+      self->sup_wait_cbs = wait_cbs;
+
+    wait_args = su_realloc(h, self->sup_wait_args, size * sizeof(*wait_args));
+    if (wait_args)
+      self->sup_wait_args = wait_args;
+
+    /* Add sup_wait_roots array, if needed */
+    wait_tasks = su_realloc(h, self->sup_wait_roots, size * sizeof(*wait_tasks));
+    if (wait_tasks) 
+      self->sup_wait_roots = wait_tasks;
+
+    if (!(indices && 
+         reverses && waits && wait_cbs && wait_args && wait_tasks)) {
+      return -1;
+    }
+
+    self->sup_size_waits = size;
+  }
+
+  i = -self->sup_indices[0]; assert(i <= self->sup_size_waits);
+
+  if (priority > 0) {
+    /* Insert */
+    for (n = self->sup_n_waits; n > 0; n--) {
+      j = self->sup_reverses[n-1]; assert(self->sup_indices[j] == n - 1);
+      self->sup_indices[j] = n;
+      self->sup_reverses[n] = j;
+      self->sup_waits[n] = self->sup_waits[n-1];
+      self->sup_wait_cbs[n] = self->sup_wait_cbs[n-1];
+      self->sup_wait_args[n] = self->sup_wait_args[n-1];
+      self->sup_wait_roots[n] = self->sup_wait_roots[n-1];     
+    }
+
+    self->sup_pri_offset++;
+  }
+  else {
+    /* Append - no need to move anything */
+    n = self->sup_n_waits;
+  }
+
+  self->sup_n_waits++;
+
+  self->sup_indices[0] = self->sup_indices[i];  /* Free index */
+  self->sup_indices[i] = n;
+
+  self->sup_reverses[n] = i;
+  self->sup_waits[n] = *wait;
+  self->sup_wait_cbs[n] = callback;
+  self->sup_wait_args[n] = arg;
+  self->sup_wait_roots[n] = root;
+
+  self->sup_registers++;
+
+  /* Just like epoll, we return -1 or positive integer */
+
+  return i;
+}
+
+/** Deregister a su_wait_t object. */
+static int su_wsevent_port_deregister0(su_port_t *self, int i, int destroy_wait)
+{
+  int n, N, *indices, *reverses;
+
+  indices = self->sup_indices;
+  reverses = self->sup_reverses;
+
+  n = indices[i]; assert(n >= 0);
+
+  if (destroy_wait)
+    su_wait_destroy(&self->sup_waits[n]);
+  
+  N = --self->sup_n_waits;
+  
+  if (n < self->sup_pri_offset) {
+    int j = --self->sup_pri_offset;
+    if (n != j) {
+      assert(reverses[j] > 0);
+      assert(indices[reverses[j]] == j);
+      indices[reverses[j]] = n;
+      reverses[n] = reverses[j];
+
+      self->sup_waits[n] = self->sup_waits[j];
+      self->sup_wait_cbs[n] = self->sup_wait_cbs[j];
+      self->sup_wait_args[n] = self->sup_wait_args[j];
+      self->sup_wait_roots[n] = self->sup_wait_roots[j];
+      n = j;
+    }
+  }
+
+  if (n < N) {
+    assert(reverses[N] > 0);
+    assert(indices[reverses[N]] == N);
+
+    indices[reverses[N]] = n;
+    reverses[n] = reverses[N];
+
+    self->sup_waits[n] = self->sup_waits[N];
+    self->sup_wait_cbs[n] = self->sup_wait_cbs[N];
+    self->sup_wait_args[n] = self->sup_wait_args[N];
+    self->sup_wait_roots[n] = self->sup_wait_roots[N];
+    n = N;
+  }
+
+  reverses[n] = -1;
+  memset(&self->sup_waits[n], 0, sizeof self->sup_waits[n]);
+  self->sup_wait_cbs[n] = NULL;
+  self->sup_wait_args[n] = NULL;
+  self->sup_wait_roots[n] = NULL;
+  
+  indices[i] = indices[0];
+  indices[0] = -i;
+
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ * Unregisters a su_wait_t object. The wait object, a callback function and
+ * a argument are removed from the port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
+ *
+ * @deprecated Use su_wsevent_port_deregister() instead. 
+ *
+ * @return Nonzero index of the wait object, or -1 upon an error.
+ */
+int su_wsevent_port_unregister(su_port_t *self,
+                           su_root_t *root, 
+                           su_wait_t *wait,    
+                           su_wakeup_f callback, /* XXX - ignored */
+                           su_wakeup_arg_t *arg)
+{
+  int n, N;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  N = self->sup_n_waits;
+
+  for (n = 0; n < N; n++) {
+    if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
+      return su_wsevent_port_deregister0(self, self->sup_reverses[n], 0);
+    }
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
+}
+
+/** Deregister a su_wait_t object.
+ *  
+ *  Deregisters a registration by index. The wait object, a callback
+ *  function and a argument are removed from the port object. The wait
+ *  object is destroyed.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_wsevent_port_deregister(su_port_t *self, int i)
+{
+  su_wait_t wait[1] = { SU_WAIT_INIT };
+  int retval;
+
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  if (i <= 0 || i > self->sup_size_waits)
+    return su_seterrno(EBADF);
+
+  if (self->sup_indices[i] < 0)
+    return su_seterrno(EBADF);
+    
+  retval = su_wsevent_port_deregister0(self, i, 1);
+
+  su_wait_destroy(wait);
+
+  return retval;
+}
+
+
+/** @internal
+ * Unregister all su_wait_t objects.
+ *
+ * Unregisters all su_wait_t objects and destroys all queued timers
+ * associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_wsevent_port_unregister_all(su_port_t *self, 
+                               su_root_t *root)
+{
+  int i, j, index, N;
+  int             *indices, *reverses;
+  su_wait_t       *waits;
+  su_wakeup_f     *wait_cbs;
+  su_wakeup_arg_t**wait_args;
+  su_root_t      **wait_roots;
+
+  assert(su_port_own_thread(self));
+
+  N          = self->sup_n_waits;
+  indices    = self->sup_indices;
+  reverses   = self->sup_reverses;
+  waits      = self->sup_waits; 
+  wait_cbs   = self->sup_wait_cbs; 
+  wait_args  = self->sup_wait_args;
+  wait_roots = self->sup_wait_roots; 
+  
+  for (i = j = 0; i < N; i++) {
+    index = reverses[i]; assert(index > 0 && indices[index] == i);
+
+    if (wait_roots[i] == root) {
+      /* XXX - we should free all resources associated with this, too */
+      if (i < self->sup_pri_offset)
+       self->sup_pri_offset--;
+
+      indices[index] = indices[0];
+      indices[0] = -index;
+      continue;
+    }
+
+    if (i != j) {
+      indices[index] = j;
+      reverses[j]   = reverses[i];
+      waits[j]      = waits[i];
+      wait_cbs[j]   = wait_cbs[i];
+      wait_args[j]  = wait_args[i];
+      wait_roots[j] = wait_roots[i];
+    }
+    
+    j++;
+  }
+  
+  for (i = j; i < N; i++) {
+    reverses[i] = -1;
+    wait_cbs[i] = NULL;
+    wait_args[i] = NULL;
+    wait_roots[i] = NULL;
+  }
+  memset(&waits[j], 0, (char *)&waits[N] - (char *)&waits[j]);
+
+  self->sup_n_waits = j;
+  self->sup_registers++;
+
+  return N - j;
+}
+
+/**Set mask for a registered event. @internal
+ *
+ * Sets the mask describing events that can signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.
+ */
+int su_wsevent_port_eventmask(su_port_t *self, int index, int socket, int events)
+{
+  int n;
+  assert(self);
+  assert(su_port_own_thread(self));
+
+  if (index <= 0 || index > self->sup_size_waits)
+    return su_seterrno(EBADF);
+  n = self->sup_indices[index];
+  if (n < 0)
+    return su_seterrno(EBADF);
+
+  return su_wait_mask(&self->sup_waits[n], socket, events);
+}
+
+/** @internal Enable multishot mode.
+ *
+ * Enables, disables or queries the multishot mode for the port. The
+ * multishot mode determines how the events are scheduled by port. If
+ * multishot mode is enabled, port serves all the sockets that have received
+ * network events. If it is disabled, only first socket event is served.
+ *
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
+ * 
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
+ */
+static
+int su_wsevent_port_multishot(su_port_t *self, int multishot)
+{
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
+}
+
+
+/** @internal
+ * Wait (poll()) for wait objects in port.
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ *
+ * @return number of events handled
+ */
+static
+int su_wsevent_port_wait_events(su_port_t *self, su_duration_t tout)
+{
+  int i, events = 0;
+  su_wait_t *waits = self->sup_waits;
+  int n = self->sup_n_waits;
+  su_root_t *root;
+
+  i = su_wait(waits, (unsigned)n, tout);
+
+  if (i >= 0 && i < n) {
+#if 0
+    /* poll() can return events for multiple wait objects */
+    if (self->sup_multishot) {
+      unsigned version = self->sup_registers;
+
+      for (; i < n; i++) {
+        if (waits[i].revents) {
+          root = self->sup_wait_roots[i];
+          self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
+                                &waits[i],
+                                self->sup_wait_args[i]);
+          events++;
+          /* Callback function used su_register()/su_deregister() */
+          if (version != self->sup_registers)
+            break;
+        }
+      }
+    }
+#else
+    if (0) ;
+#endif
+    else {
+      root = self->sup_wait_roots[i];
+      self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
+                            &self->sup_waits[i],
+                            self->sup_wait_args[i]);
+      events++;
+    }
+  }
+
+  return events;
+}
+
+/** Create a port using WSAEVENTs and WSAWaitForMultipleEvents. */
+su_port_t *su_wsaevent_port_create(void)
+{
+  su_port_t *self = su_home_new(sizeof *self);
+
+  if (!self)
+    return self;
+
+  if (su_home_destructor(su_port_home(self), su_wsevent_port_deinit) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
+
+  if (su_socket_port_init(self->sup_base, su_wsevent_port_vtable) < 0)
+    return su_home_unref(su_port_home(self)), NULL;
+
+  return self;
+}
+
+int su_wsaevent_clone_start(su_root_t *parent,
+                           su_clone_r return_clone,
+                           su_root_magic_t *magic,
+                           su_root_init_f init,
+                           su_root_deinit_f deinit)
+{
+  return su_pthreaded_port_start(su_wsaevent_port_create, 
+                                parent, return_clone, magic, init, deinit);
+}
+
index 81df24f948bfe8c3721f51e4c002bd53fa3cefcd..4765ce6dc93f75d6bb4da1e0880943e9f5c24c5c 100644 (file)
@@ -46,11 +46,18 @@ HEADER {
     fn = FILENAME;
   }
 
-  DLL = fn;
-  sub(/[.]c(at)?/, "_dll.c", DLL);
+  if (REF == "") {
+    REF = fn;
+    sub(/[.]c(at)?/, "_ref.c", REF);
+  }
 
   if (NODLL) DLL = "/dev/null";
 
+  if (DLL == "") {
+    DLL = fn;
+    sub(/[.]c(at)?/, "_dll.c", DLL);
+  }
+
   base = fn;
   sub(/.*\//, "", base);
 
@@ -73,9 +80,6 @@ HEADER {
       "#include <sofia-sip/su_tag_class.h>\n\n" > DLL;
   }
 
-  REF = fn;
-  sub(/[.]c(at)?/, "_ref.c", REF);
-
   printf("/*\n" \
         " * PLEASE NOTE: \n" \
         " * \n" \
@@ -110,6 +114,11 @@ HEADER {
   print "" > DLL;
 }
 
+/SU_HAVE_EXPERIMENTAL/ { 
+  print $0 > REF; 
+  print $0 > DLL; 
+}
+
 !DEFS && /^tag_typedef_t/ { DEFS = 1; }
 
 DEFS && /tag_typedef_t/ {
index 395a2424cc416d02a2764c44e59aae9a97c43d5a..683daafc0c08f78a73bcf280ed4eac28b2e3e7de 100644 (file)
 
 char const name[] = "htable_test";
 
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v|--verbatim]\n", name);
-  exit(2);
+  fprintf(stderr, "usage: %s [-v|--verbatim] [-a|--abort]\n", name);
+  exit(exitcode);
 }
 
 static int table_test(int flags);
@@ -70,8 +70,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbatim") == 0)
       flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--abort") == 0)
+      flags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= table_test(flags); fflush(stdout);
@@ -179,44 +181,46 @@ int table_test(int flags)
 
   BEGIN();
 
-  TEST0(c = context_create());
-  TEST0(add(c, 0, 1)); TEST0(c->c_hash->ht_table[0]);
-  TEST0(add(c, 1, 2)); TEST0(c->c_hash->ht_table[1]);
-  TEST0(add(c, 2, 3)); TEST0(c->c_hash->ht_table[2]);
-  TEST0(add(c, 0, 4)); TEST0(c->c_hash->ht_table[3]);
-  TEST0(add(c, 2, 5)); TEST0(c->c_hash->ht_table[4]);
-
-  TEST0(e = search(c, 1, 2, 0));
-  zap(c, e);
-  TEST0(c->c_hash->ht_table[0]);
-  TEST0(c->c_hash->ht_table[1]);
-  TEST0(c->c_hash->ht_table[2]);
-  TEST0(c->c_hash->ht_table[3]);
-  TEST0(c->c_hash->ht_table[4] == NULL);
+  TEST_1(c = context_create());
+  TEST_1(add(c, 0, 1)); TEST_1(c->c_hash->ht_table[0]);
+  TEST_1(add(c, 1, 2)); TEST_1(c->c_hash->ht_table[1]);
+  TEST_1(add(c, 2, 3)); TEST_1(c->c_hash->ht_table[2]);
+  TEST_1(add(c, 0, 4)); TEST_1(c->c_hash->ht_table[3]);
+  TEST_1(add(c, 2, 5)); TEST_1(c->c_hash->ht_table[4]);
+
+  TEST_1(e = search(c, 1, 2, 0));
+  TEST(htable_remove(c->c_hash, e), 0);
+  TEST(htable_remove(c->c_hash, e), -1);
+  su_free(c->c_home, e);
+  TEST_1(c->c_hash->ht_table[0]);
+  TEST_1(c->c_hash->ht_table[1]);
+  TEST_1(c->c_hash->ht_table[2]);
+  TEST_1(c->c_hash->ht_table[3]);
+  TEST_1(c->c_hash->ht_table[4] == NULL);
 
   zap(c, c->c_hash->ht_table[0]);
 
-  TEST0(c->c_hash->ht_table[0]);
-  TEST0(c->c_hash->ht_table[1] == NULL);
-  TEST0(c->c_hash->ht_table[2]);
-  TEST0(c->c_hash->ht_table[3]);
-  TEST0(c->c_hash->ht_table[4] == NULL);
+  TEST_1(c->c_hash->ht_table[0]);
+  TEST_1(c->c_hash->ht_table[1] == NULL);
+  TEST_1(c->c_hash->ht_table[2]);
+  TEST_1(c->c_hash->ht_table[3]);
+  TEST_1(c->c_hash->ht_table[4] == NULL);
 
-  TEST0(add(c, 0, 6)); TEST0(c->c_hash->ht_table[1]);
-  TEST0(add(c, 1, 7)); TEST0(c->c_hash->ht_table[4]);
+  TEST_1(add(c, 0, 6)); TEST_1(c->c_hash->ht_table[1]);
+  TEST_1(add(c, 1, 7)); TEST_1(c->c_hash->ht_table[4]);
 
   /* Test that zapping entry 0 does not move 2 and 3 */
   zap(c, c->c_hash->ht_table[0]);
-  TEST0(c->c_hash->ht_table[4] == NULL);
+  TEST_1(c->c_hash->ht_table[4] == NULL);
 
   {
     /* Insert entries at the end of hash, then resize and check
        for correct ordering */
     hash_value_t size = c->c_hash->ht_size, h = size - 1;
 
-    TEST0(add(c, h, 0)); TEST0(add(c, h, 1)); TEST0(add(c, h, 2));
-    TEST0(add(c, h, 3)); TEST0(add(c, h, 4)); TEST0(add(c, h, 5));
-    TEST0(add(c, h, 6)); TEST0(add(c, h, 7)); TEST0(add(c, h, 8));
+    TEST_1(add(c, h, 0)); TEST_1(add(c, h, 1)); TEST_1(add(c, h, 2));
+    TEST_1(add(c, h, 3)); TEST_1(add(c, h, 4)); TEST_1(add(c, h, 5));
+    TEST_1(add(c, h, 6)); TEST_1(add(c, h, 7)); TEST_1(add(c, h, 8));
 
     TEST(count(c, h), 9);
     
index 91ea878cd6d62b8615b87b6aa473b57184b97b5f..c5a6a3bc3c49b4dcf6bf014ae60524661ad4378c 100644 (file)
@@ -58,9 +58,10 @@ static int test_flags = 0;
 
 char const name[] = "test_memmem";
 
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v]\n", name);
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
 }
 
 static int test_notfound(void);
@@ -77,14 +78,25 @@ static int test_notfound(void)
 
   TEST_P(memmem(haystack, 12, needle, 3), haystack + 2);
   TEST_P(memmem(needle, 3, haystack, 12), NULL);
-  TEST_P(memmem(haystack, 12, "", 0), haystack);
-  TEST_P(memmem(haystack, 12, null, 0), haystack);
-  TEST_P(memmem(haystack, 0, "", 0), haystack);
-  TEST_P(memmem(haystack, 0, null, 0), haystack);
+  
+#if HAVE_MEMMEM
+  if (memmem(haystack, 12, "", 0) == NULL) {
+    fprintf(stderr, "test_memmem.c: "
+           "*** WARNING: system memmem() fails with empty needle ***\n");
+  }
+  else 
+#endif
+  {
+    TEST_P(memmem(haystack, 12, "", 0), haystack);
+    TEST_P(memmem(haystack, 12, null, 0), haystack);
+    TEST_P(memmem(haystack, 0, "", 0), haystack);
+    TEST_P(memmem(haystack, 0, null, 0), haystack);
+  }
 
   TEST_P(memmem(haystack + 2, 3, needle, 3), haystack + 2);
   TEST_P(memmem(haystack + 2, 2, needle, 3), NULL);
   TEST_P(memmem(a = "a\0bc", 4, "a\0bc", 4), a);
+  TEST_P(memmem(a, 4, "\0bc", 3), a + 1);
 
   END();
 }
@@ -225,8 +237,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       test_flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      test_flags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_notfound(); fflush(stdout);
index e54867e70a3edf5316a3fec750446e5ff2cd6a6e..b8e7676634339a600caf6a65ebe517f3edb21624 100644 (file)
 
 #include "config.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-
-#include <assert.h>
-
 struct pinger;
 #define SU_ROOT_MAGIC_T struct pinger
 #define SU_INTERNAL_P   su_root_t *
@@ -53,6 +46,12 @@ struct pinger;
 #include "sofia-sip/su_log.h"
 #include "sofia-sip/su_debug.h"
 
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <assert.h>
+
 char const name[] = "su_test";
 
 #if HAVE_FUNC
@@ -410,14 +409,6 @@ init_ping(struct pinger *p, su_msg_r msg, su_sockaddr_t *arg)
   }
 }
 
-static
-RETSIGTYPE term(int n)
-{
-  enter;
-
-  exit(1);
-}
-
 void
 time_test(void)
 {
@@ -440,10 +431,12 @@ time_test(void)
     printf("time_test: passed\n");
 }
 
-#if HAVE_ALARM
+#if HAVE_SIGNAL
 #include <unistd.h>
 #include <signal.h>
 
+#if HAVE_ALARM
+
 static RETSIGTYPE sig_alarm(int s)
 {
   enter;
@@ -456,6 +449,18 @@ static char const no_alarm[] = " [--no-alarm]";
 static char const no_alarm[] = "";
 #endif
 
+static
+RETSIGTYPE term(int n)
+{
+  enter;
+
+  exit(1);
+}
+#else
+static char const no_alarm[] = "";
+#endif
+
+
 void
 usage(int exitcode)
 {
@@ -519,11 +524,10 @@ int main(int argc, char *argv[])
     }
   }
 
-  signal(SIGTERM, term);
-
   su_init(); atexit(su_deinit);
 
-  time_test();
+#if HAVE_SIGNAL
+  signal(SIGTERM, term);
 
 #if HAVE_ALARM
   if (opt_alarm) {
@@ -532,8 +536,15 @@ int main(int argc, char *argv[])
   }
 #endif
 
+#endif
+
+  time_test();
+
   root = su_root_create(NULL);
   if (!root) perror("su_root_create"), exit(1);
+
+  fprintf(stdout, "test_su: testing %s port implementation\n",
+         su_root_name(root));
   
   su_root_threading(root, !opt_singlethread);
 
index 3dae357111e771a9460eaef6a8e1e3bf48b60b5c..3205c91f78aa5bf1230f5ec083abb59f66a6863b 100644 (file)
@@ -681,11 +681,12 @@ int test_speed(void)
 }
 
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr,
-         "usage: %s [-v]\n",
+         "usage: %s [-v] [-a]\n",
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -696,8 +697,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_insert(); fflush(stdout);
index ac2708d680ca9c0b66d235a58600f75e7687fca0..569bdd88a5cefb6187e3e1e3408ce13dbb832fcf 100644 (file)
@@ -47,17 +47,10 @@ int tstflags;
 #define TSTFLAGS tstflags
 #include <sofia-sip/tstdef.h>
 
-char const *name = "su_torture";
-
-static int test_sockaddr(void);
-
-void usage(void)
-{
-  fprintf(stderr, "usage: %s [-v]\n", name);
-}
+char const *name = "torture_su";
 
 /**  */
-int test_sockaddr(void)
+static int test_sockaddr(void)
 {
   su_localinfo_t hints[1] = {{ LI_CANONNAME }};
   su_localinfo_t *li, *res = NULL;
@@ -100,7 +93,7 @@ int test_sockaddr(void)
   TEST(su_setblocking(s, 1), 0);
   TEST(su_close(s), 0);
 
-  su_freelocalinfo(res);
+  su_freelocalinfo(res), res = NULL;
 
 #if SU_HAVE_IN6
   hints->li_family = AF_INET6;
@@ -111,16 +104,17 @@ int test_sockaddr(void)
   for (li = res; li; li = li->li_next)
     TEST(li->li_family, AF_INET6);
 
-  su_freelocalinfo(res);
+  su_freelocalinfo(res), res = NULL;
 #endif
 
   hints->li_flags |= LI_NUMERIC;
   TEST(su_getlocalinfo(hints, &res), 0);
+  su_freelocalinfo(res), res = NULL;
 
-  hints->li_flags |= LI_NAMEREQD;
   res = NULL;
+  hints->li_flags |= LI_NAMEREQD;
   su_getlocalinfo(hints, &res);
-  su_freelocalinfo(res);
+  su_freelocalinfo(res), res = NULL;
 
   memset(a, 0, sizeof *a); 
   memset(b, 0, sizeof *b); 
@@ -161,7 +155,7 @@ int test_sockaddr(void)
 
 int test_sendrecv(void)
 {
-  int s, l, a;
+  su_socket_t s, l, a;
   int n;
   su_sockaddr_t su, csu;
   socklen_t sulen = sizeof su.su_sin, csulen = sizeof csu.su_sin;
@@ -260,6 +254,120 @@ int test_sendrecv(void)
   END();
 }
 
+#if HAVE_SELECT 
+
+#if HAVE_WIN32
+int test_select(void)
+{
+  return 0;
+}
+#else
+
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#elif HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifndef __NFDBITS
+#define __NFDBITS (8 * sizeof (long int))
+#endif
+
+#undef howmany
+/* Size of fd set in bytes. Sorry, octets. */
+#define howmany(n) (((n) + __NFDBITS - 1) / __NFDBITS * (__NFDBITS / 8))
+
+#define FD_ZERO_TO(maxfd, set) \
+  memset((set), 0, howmany(maxfd))
+
+/* Test assumptions in su_select_port implementation */
+int test_select(void)
+{
+  su_socket_t s;
+  su_sockaddr_t su;
+  socklen_t sulen = sizeof su.su_sin;
+  size_t bytes;
+  fd_set *rset, *wset;
+  struct timeval tv;
+
+  BEGIN();
+
+  s = su_socket(AF_INET, SOCK_DGRAM, 0); TEST_1(s != -1);
+
+  memset(&su, 0, sulen);
+  su.su_len = sulen;
+  su.su_family = AF_INET;
+  TEST(inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
+  TEST(bind(s, &su.su_sa, sulen), 0);
+  TEST(getsockname(s, &su.su_sa, &sulen), 0);
+  
+  tv.tv_sec = 0; tv.tv_usec = 1000;
+  TEST(select(0, NULL, NULL, NULL, &tv), 0);
+
+  bytes = howmany(s);
+  TEST_1(rset = malloc(bytes));
+  TEST_1(wset = malloc(bytes));
+
+  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); FD_SET(s, wset);
+  tv.tv_sec = 0, tv.tv_usec = 1000;
+  TEST(select(s + 1, NULL, wset, NULL, &tv), 1);
+  TEST_1(FD_ISSET(s, wset));
+
+  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
+  FD_SET(s, rset); FD_SET(s, wset);
+  tv.tv_sec = 0, tv.tv_usec = 1000;
+  TEST(select(s + 1, rset, wset, NULL, &tv), 1);
+  TEST_1(!FD_ISSET(s, rset));
+  TEST_1(FD_ISSET(s, wset));
+
+  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
+  FD_SET(s, rset); FD_SET(s, wset);
+  tv.tv_sec = 0, tv.tv_usec = 1000;
+  TEST(select(s + 1, rset, NULL, NULL, &tv), 0);
+  TEST_1(!FD_ISSET(s, rset));
+
+  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
+  FD_SET(s, rset); FD_CLR(s, wset);
+  tv.tv_sec = 0, tv.tv_usec = 1000;
+  TEST(select(s + 1, rset, wset, NULL, &tv), 0);
+  TEST_1(!FD_ISSET(s, rset));
+  TEST_1(!FD_ISSET(s, wset));
+
+  TEST(su_sendto(s, "foo", 3, 0, &su, sulen), 3);
+
+  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
+  FD_SET(s, rset); FD_CLR(s, wset);
+  tv.tv_sec = 0, tv.tv_usec = 1000;
+  TEST(select(s + 1, rset, wset, NULL, &tv), 1);
+  TEST_1(FD_ISSET(s, rset));
+  TEST_1(!FD_ISSET(s, wset));
+
+  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
+  FD_SET(s, rset); FD_SET(s, wset);
+  tv.tv_sec = 0, tv.tv_usec = 1000;
+  TEST(select(s + 1, rset, wset, NULL, &tv), 2);
+  TEST_1(FD_ISSET(s, rset));
+  TEST_1(FD_ISSET(s, wset));
+
+  su_close(s);
+
+  free(wset);
+  free(rset);
+
+  END();
+}
+#endif
+
+#else
+int test_select(void)
+{
+  return 0;
+}
+#endif
+
 #include <sofia-sip/su_md5.h>
 
 int test_md5(void)
@@ -379,6 +487,12 @@ int test_md5(void)
   END();
 }
 
+void usage(int exitcode)
+{
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
+}
+
 int main(int argc, char *argv[])
 {
   int retval = 0;
@@ -389,16 +503,18 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
   
   retval |= test_sockaddr();
   retval |= test_sendrecv();
+  retval |= test_select();
   retval |= test_md5(); fflush(stdout);
 
   su_deinit();
 
   return retval;
 }
-
index 3149cdcffc0dd1cf577ebb342b4f35b91c602ad9..4b74fdf3a600b4a0c45857470691a8e04b44a2e8 100644 (file)
@@ -59,6 +59,12 @@ void exdestructor(void *arg)
   (*ex->p)++;
 }
 
+void test_destructor(void *a)
+{
+  su_home_t *h = a;
+  h->suh_size = 13;
+}
+
 /** Test basic memory home operations  */
 static int test_alloc(void)
 {
@@ -78,8 +84,8 @@ static int test_alloc(void)
 
   d0 = d1a = d1 = d2 = d3 = 0;
   h0->p = &d0; h1->p = &d1a;
-  TEST(su_home_desctructor(h0->home, exdestructor), 0);
-  TEST(su_home_desctructor(h1->home, exdestructor), 0);
+  TEST(su_home_destructor(h0->home, exdestructor), 0);
+  TEST(su_home_destructor(h1->home, exdestructor), 0);
 
   TEST_1(h2 = su_home_ref(h0->home));
   su_home_unref(h0->home);
@@ -95,7 +101,7 @@ static int test_alloc(void)
   TEST(d1a, destructed_once);
 
   TEST_1(h1 = su_home_clone(h0->home, sizeof(*h1)));
-  TEST(su_home_desctructor(h1->home, exdestructor), 0);
+  TEST(su_home_destructor(h1->home, exdestructor), 0);
   h1->p = &d1;
 
   for (i = 0; i < 128; i++)
@@ -125,7 +131,7 @@ static int test_alloc(void)
 
   TEST_1(su_in_home(h2->home, m));
   TEST_1(!su_in_home(h2->home, (char *)m + 1));
-  TEST_1(!su_in_home(h2->home, su_in_home));
+  TEST_1(!su_in_home(h2->home, (void *)(intptr_t)su_in_home));
   TEST_1(!su_in_home(h3->home, m));
   TEST_1(!su_in_home(NULL, m));
   TEST_1(!su_in_home(h3->home, NULL));
@@ -161,6 +167,25 @@ static int test_alloc(void)
   su_home_check(h0->home);
   su_home_zap(h0->home);
 
+  {
+    su_home_t h1[1];
+
+    memset(h1, 0, sizeof h1);
+
+    TEST(su_home_init(h1), 0);
+    TEST(su_home_threadsafe(h1), 0);
+
+    TEST_1(su_home_ref(h1));
+    TEST_1(su_home_ref(h1));
+
+    TEST(su_home_destructor(h1, test_destructor), 0);
+
+    TEST_1(!su_home_unref(h1));
+    TEST_1(!su_home_unref(h1));
+    TEST_1(su_home_unref(h1));
+    TEST(h1->suh_size, 13);
+  }
+
   END();
 }
 
@@ -654,9 +679,10 @@ static int test_auto(void)
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
-  fprintf(stderr, "usage: %s [-v]\n", name);
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -667,8 +693,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_alloc();
index d7d722cb79e14ff78258b71cfbb7247b70e30364..9ea0627fd1ca86d040a43ff7ee57857a98142418 100644 (file)
 char const *name = "torture_su_bm";
 int tstflags;
 
-#define TORTURELOG(x)                 \
-  do {                                \
-    if (tstflags & (2 * tst_verbatim)) \
-      printf x;                               \
-  } while(0)
-    
+#define TORTURELOG TEST_LOG
+
 #include "su_bm.c"
 
 int test_bm(void)
@@ -192,6 +188,8 @@ char const Needle[] =
 
     s = bm_memmem(hs, strlen(hs), needle, nlen, fwd);
 
+    free(fwd);
+
     TEST_S(s, hs + 1919);
 
     TEST_1(bm_memmem(hs, strlen(hs), Needle, nlen, NULL) == 0);
@@ -211,11 +209,12 @@ char const Needle[] =
 }
 
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v]\n", 
+         "usage: %s [-v] [-a]\n", 
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -232,10 +231,12 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else if (strcmp(argv[i], "-l") == 0)
-      tstflags |= 2 * tst_verbatim;
+      tstflags |= tst_log;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_bm(); fflush(stdout);
index 0d4d9b4e49ff1186f7074de8fcefe66814cd25da..d2603fa5947bedeecc0751c1d90f32f8718c09a2 100644 (file)
@@ -24,7 +24,7 @@
 
 /**
  * @file torture_su_port.c
- * @brief Test su_port interface
+ * @brief Test su_poll_port interface
  *
  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  * @date Created: Wed Mar 10 17:05:23 2004 ppessi
@@ -39,7 +39,10 @@ struct su_root_magic_s;
 
 #define SU_ROOT_MAGIC_T struct su_root_magic_s
 
-#include "su_port.c"
+#include "su_poll_port.c"
+
+#undef HAVE_EPOLL
+#define HAVE_EPOLL 0
 
 #if HAVE_FUNC
 #elif HAVE_FUNCTION
@@ -56,7 +59,7 @@ int tstflags;
 
 char const *name = "torture_su_port";
 
-int N0 = SU_HAVE_MBOX, N = 128, I = 128 + 1;
+int const N0 = SU_MBOX_SIZE > 0, N = 128, I = 129;
 
 int test_sup_indices(su_port_t const *port)
 {
@@ -121,7 +124,7 @@ static int callback(su_root_magic_t *magic,
 
   magic->wakeups[i]++;
 
-#if HAVE_POLL
+#if HAVE_POLL || HAVE_SELECT
   if (w->fd != magic->sockets[i])
     return ++magic->error;
 #endif
@@ -144,7 +147,8 @@ int test_wakeup(su_port_t *port, su_root_magic_t *magic)
       su_perror("getsockname"), exit(1);
     if (su_sendto(magic->sockets[1], "X", 1, 0, su, sulen) < 0)
       su_perror("su_sendto"), exit(1);
-    n = su_port_wait_events(port, 100);
+    n = su_poll_port_wait_events(port, 100);
+
     if (n != 1)
       return 1;
     if (magic->error)
@@ -188,9 +192,10 @@ int test_register(void)
 
   su_root_size_hint = 16;
 
-  TEST_1(port = su_port_create());
+  TEST_1(port = su_poll_port_create());
   TEST(su_port_threadsafe(port), 0);
-  SU_PORT_INCREF(port, __func__);
+  /* Before 1.12.4 su_port_create() had reference count 0 after creation */
+  /* su_port_incref(port, "test_register"); */
 
   TEST_1(test_sup_indices(port));
 
@@ -292,16 +297,17 @@ int test_register(void)
     TEST(su_port_deregister(port, reg[i]), -1);
   }
 
-  TEST_VOID(su_port_decref(port, 1, __func__));
+  TEST_VOID(su_port_decref(port, __func__));
 
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr,
-         "usage: %s [-v]\n",
+         "usage: %s [-v] [-a]\n",
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -319,8 +325,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   su_init();
index bdbd76472f11829407abfad30f89c0ed61d1819e..86fcd362b118db12ed3bf1f95316fbad8e54e74f 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "config.h"
 
-char const *name = "su_root_test";
+char const *name = "torture_su_root";
 
 #include <stdio.h>
 #include <string.h>
@@ -54,15 +54,19 @@ typedef struct test_ep_s   test_ep_t;
 
 #include <sofia-sip/su_wait.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_log.h>
 
-typedef struct test_ep_s {
+struct test_ep_s {
+  test_ep_t     *next, **prev, **list;
   int           i;
   int           s;
   su_wait_t     wait[1];
   int           registered;
   socklen_t     addrlen;
   su_sockaddr_t addr[1];
-} test_ep_at[1];
+};
+
+typedef struct test_ep_s   test_ep_at[1];
 
 struct root_test_s {
   su_home_t  rt_home[1];
@@ -81,11 +85,22 @@ struct root_test_s {
   unsigned   rt_success_init:1;
   unsigned   rt_success_deinit:1;
 
+  unsigned   rt_sent_reporter:1;
+  unsigned   rt_recv_reporter:1;
+  unsigned   rt_reported_reporter:1;
+
+  unsigned :0;
+
   test_ep_at rt_ep[5];
+
+  int rt_sockets, rt_woken;
 };
 
 /** Test root initialization */
-int init_test(root_test_t *rt)
+int init_test(root_test_t *rt,
+             char const *preference,
+             su_port_create_f *create,
+             su_clone_start_f *start)
 {
   su_sockaddr_t su[1] = {{ 0 }};
   int i;
@@ -94,10 +109,15 @@ int init_test(root_test_t *rt)
 
   su_init();
 
-  su->su_family = rt->rt_family;
+  su_port_prefer(create, start);
 
   TEST_1(rt->rt_root = su_root_create(rt));
 
+  printf("%s: testing %s (%s) implementation\n",
+        name, preference, su_root_name(rt->rt_root));
+
+  su->su_family = rt->rt_family;
+
   for (i = 0; i < 5; i++) {
     test_ep_t *ep = rt->rt_ep[i];
     ep->i = i;
@@ -179,7 +199,6 @@ static int wakeup4(root_test_t *rt, su_wait_t *w, test_ep_t *ep)
 static
 su_wakeup_f wakeups[5] = { wakeup0, wakeup1, wakeup2, wakeup3, wakeup4 };
 
-
 static
 void test_run(root_test_t *rt)
 {
@@ -271,6 +290,133 @@ static int register_test(root_test_t *rt)
   END();
 }
 
+
+int wakeup_remove(root_test_t *rt, su_wait_t *w, test_ep_t *node)
+{
+  char buffer[64];
+  ssize_t x;
+  test_ep_t *n = node->next; 
+
+  su_wait_events(w, node->s);
+
+  x = recv(node->s, buffer, sizeof(buffer), 0);
+
+  if (x < 0)
+    fprintf(stderr, "%s: %s\n", "recv", su_strerror(su_errno()));
+
+  if (node->prev) {            /* first run */
+    *node->prev = n;
+
+    if (n) {
+      *node->prev = node->next;    
+      node->next->prev = node->prev;
+      sendto(n->s, "foo", 3, 0, (void *)n->addr, n->addrlen);
+    }
+
+    node->next = NULL;
+    node->prev = NULL;
+    
+    if (!*node->list) {
+      su_root_break(rt->rt_root);
+    }
+  }
+  else {                       /* second run */
+    if (++rt->rt_woken == rt->rt_sockets)
+      su_root_break(rt->rt_root);
+  }
+
+  return 0;
+}
+
+
+int event_test(root_test_t rt[1])
+{
+  BEGIN();
+  int i = 0, N = 2048;
+  test_ep_t *n, *nodes, *list = NULL;
+  su_sockaddr_t su[1];
+  socklen_t sulen;
+  
+  TEST_1(nodes = calloc(N, sizeof *nodes));
+  
+  memset(su, 0, sulen = sizeof su->su_sin);
+  su->su_len = sizeof su->su_sin;
+  su->su_family = AF_INET;
+  su->su_sin.sin_addr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */
+
+  for (i = 0; i < N; i++) {
+    n = nodes + i;
+    n->s = su_socket(AF_INET, SOCK_DGRAM, 0);
+
+    if (n->s == INVALID_SOCKET)
+      break;
+
+    n->addrlen = sizeof n->addr;
+
+    n->addr->su_len = sizeof n->addr;
+
+    if (bind(n->s, (void *)su, sulen) < 0) {
+      su_perror("bind()");
+      su_close(n->s);
+      break;
+    }
+      
+    if (getsockname(n->s, (void *)n->addr, &n->addrlen)) {
+      su_perror("getsockname()");
+      su_close(n->s);
+      break;
+    }
+
+    if (su_wait_create(n->wait, n->s, SU_WAIT_IN)) {
+      su_perror("su_wait_create()");
+      su_close(n->s);
+      break;
+    }
+
+    n->registered = su_root_register(rt->rt_root, n->wait, wakeup_remove, n, 0);
+    if (n->registered < 0) {
+      su_wait_destroy(n->wait);
+      su_close(n->s);
+      break;
+    }
+    
+    n->list = &list, n->prev = &list;
+    if ((n->next = list))
+      n->next->prev = &n->next;
+    list = n;
+  }
+
+  TEST_1(i >= 1);
+
+  N = i;
+
+  /* Wake up socket at a time */
+  n = list; sendto(n->s, "foo", 3, 0, (void *)n->addr, n->addrlen);
+
+  su_root_run(rt->rt_root);
+
+  for (i = 0; i < N; i++) {
+    n = nodes + i;
+    TEST_1(n->prev == NULL);
+    sendto(n->s, "bar", 3, 0, (void *)n->addr, n->addrlen);
+  }
+
+  rt->rt_sockets = N;
+
+  /* Wake up all sockets */
+  su_root_run(rt->rt_root);
+
+  for (i = 0; i < N; i++) {
+    n = nodes + i;
+    su_root_deregister(rt->rt_root, n->registered);
+    TEST_1(su_close(n->s) == 0);
+  }
+
+  free(nodes);
+
+  END();
+}
+
 int fail_init(su_root_t *root, root_test_t *rt)
 {
   rt->rt_fail_init = 1;
@@ -293,14 +439,49 @@ void success_deinit(su_root_t *root, root_test_t *rt)
   rt->rt_success_deinit = 1;
 }
 
+void receive_a_reporter(root_test_t *rt, 
+                       su_msg_r msg,
+                       su_msg_arg_t *arg)
+{
+  rt->rt_recv_reporter = 1;
+}
+
+void receive_recv_report(root_test_t *rt, 
+                        su_msg_r msg,
+                        su_msg_arg_t *arg)
+{
+  rt->rt_reported_reporter = 1;
+}
+
+void send_a_reporter_msg(root_test_t *rt, 
+                        su_msg_r msg,
+                        su_msg_arg_t *arg)
+{
+  su_msg_r m = SU_MSG_R_INIT;
+
+  if (su_msg_create(m,
+                   su_msg_from(msg),
+                   su_msg_to(msg),
+                   receive_a_reporter,
+                   0) == 0 &&
+      su_msg_report(m, receive_recv_report) == 0 &&
+      su_msg_send(m) == 0)
+    rt->rt_sent_reporter = 1;
+}
+
 static int clone_test(root_test_t rt[1])
 {
   BEGIN();
 
+  su_msg_r m = SU_MSG_R_INIT;
+
   rt->rt_fail_init = 0;
   rt->rt_fail_deinit = 0;
   rt->rt_success_init = 0;
   rt->rt_success_deinit = 0;
+  rt->rt_sent_reporter = 0;
+  rt->rt_recv_reporter = 0;
+  rt->rt_reported_reporter = 0;
 
   TEST(su_clone_start(rt->rt_root,
                      rt->rt_clone,
@@ -318,45 +499,108 @@ static int clone_test(root_test_t rt[1])
   TEST_1(rt->rt_success_init);
   TEST_1(!rt->rt_success_deinit);
 
+  /* Make sure 3-way handshake is done as expected */
+  TEST(su_msg_create(m,
+                    su_clone_task(rt->rt_clone),
+                    su_root_task(rt->rt_root),
+                    send_a_reporter_msg,
+                    0), 0);
+  TEST(su_msg_send(m), 0);
+
   TEST_VOID(su_clone_wait(rt->rt_root, rt->rt_clone));
 
   TEST_1(rt->rt_success_deinit);
-  
+  TEST_1(rt->rt_sent_reporter);
+  TEST_1(rt->rt_recv_reporter);
+  TEST_1(rt->rt_reported_reporter);
+
+  rt->rt_recv_reporter = 0;
+
+  /* Make sure we can handle messages done as expected */
+  TEST(su_msg_create(m,
+                    su_root_task(rt->rt_root),
+                    su_task_null,
+                    receive_a_reporter,
+                    0), 0);
+  TEST(su_msg_send(m), 0);
+  su_root_step(rt->rt_root, 0);
+  TEST_1(rt->rt_recv_reporter);
+
+  rt->rt_success_init = 0;
+  rt->rt_success_deinit = 0;
+
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v]\n", 
+         "usage: %s [-v] [-a]\n", 
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
 {
-  root_test_t rt[1] = {{{ SU_HOME_INIT(rt) }}};
+  root_test_t *rt, rt0[1] = {{{ SU_HOME_INIT(rt0) }}}, rt1[1];
   int retval = 0;
   int i;
 
+  struct {
+    su_port_create_f *create;
+    su_clone_start_f *start;
+    char const *name;
+  } prefer[] =
+      {
+       { NULL, NULL, "default" },
+#if HAVE_EPOLL
+       { su_epoll_port_create, su_epoll_clone_start, "epoll", },
+#endif
+#if HAVE_KQUEUE
+       { su_kqueue_port_create, su_kqueue_clone_start, "kqueue", },
+#endif
+#if HAVE_SYS_DEVPOLL_H
+       { su_devpoll_port_create, su_devpoll_clone_start, "devpoll", },
+#endif
+#if HAVE_POLL_PORT
+       { su_poll_port_create, su_poll_clone_start, "poll" },
+#endif
+#if HAVE_SELECT
+       { su_select_port_create, su_select_clone_start, "select" },
+#endif
+       { NULL, NULL }
+      };
+
+  rt = rt0;
   rt->rt_family = AF_INET;
 
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       rt->rt_flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      rt->rt_flags |= tst_abort;
 #if SU_HAVE_IN6
     else if (strcmp(argv[i], "-6") == 0)
       rt->rt_family = AF_INET6;
 #endif
     else
-      usage();
+      usage(1);
   }
 
-  retval |= init_test(rt);
-  retval |= register_test(rt);
-  retval |= clone_test(rt);
-  su_root_threading(rt->rt_root, 0);
-  retval |= clone_test(rt);
-  retval |= deinit_test(rt);
+  i = 0;
+
+  do {
+    rt = rt1, *rt = *rt0;
+
+    retval |= init_test(rt, prefer[i].name, prefer[i].create, prefer[i].start);
+    retval |= register_test(rt);
+    retval |= event_test(rt);
+    su_root_threading(rt->rt_root, 1);
+    retval |= clone_test(rt);
+    su_root_threading(rt->rt_root, 0);
+    retval |= clone_test(rt);
+    retval |= deinit_test(rt);
+  } while (prefer[++i].create);
 
   return retval;
 }
index 93f55d60096f4e7f25d0597b1b138f33d60fe92d..33d1d4f4c154926f90d8089525ed450ead2e5509 100644 (file)
@@ -327,11 +327,12 @@ static int clone_test(root_test_t rt[1])
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v]\n", 
+         "usage: %s [-v] [-a]\n", 
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -345,12 +346,14 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       rt->rt_flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      rt->rt_flags |= tst_abort;
 #if SU_HAVE_IN6
     else if (strcmp(argv[i], "-6") == 0)
       rt->rt_family = AF_INET6;
 #endif
     else
-      usage();
+      usage(1);
   }
 
   retval |= init_test(rt);
index 410ecd31b9ebe34f5b6ef792a53a9b6be4f5e72d..fac8e280c220f5521e631f4c73b6242afe246f2c 100644 (file)
@@ -620,11 +620,12 @@ static int test_scan(void)
   END();
 }
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v]\n", 
+         "usage: %s [-v] [-a]\n", 
          name);
+  exit(exitcode);
 }
 
 int main(int argc, char *argv[])
@@ -637,8 +638,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_assumptions();
index e466f8f8a079d9badd92f23f1631925f4193d3d7..40edd01bbf9655f9c8a5d65943fb8e4c72633181 100644 (file)
@@ -54,11 +54,12 @@ static int test1(int flags);
 static int test2(int flags);
 static int test3(int flags);
 
-void usage(void)
+void usage(int exitcode)
 {
   fprintf(stderr, 
-         "usage: %s [-v]\n", 
+         "usage: %s [-v] [-a]\n", 
          name);
+  exit(exitcode);
 }
 
 char *lastpart(char *path)
@@ -80,8 +81,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       flags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      flags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test1(flags); fflush(stdout);
index 1b6a53c5ed42a08f345ad08fff8224c6fded8230..4b7f63654a18e5f4f14ddabb7cebe631a16a699a 100644 (file)
@@ -39,7 +39,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <signal.h>
 
 #include <assert.h>
 
@@ -91,6 +90,10 @@ print_X(struct tester *x, su_timer_t *t1, struct timing *ti)
   putchar('X'); fflush(stdout);
 }
 
+#if HAVE_SIGNAL
+
+#include <signal.h>
+
 su_msg_r intr_msg = SU_MSG_R_INIT;
 
 static RETSIGTYPE intr_handler(int signum)
@@ -103,6 +106,8 @@ static void test_break(struct tester *tester, su_msg_r msg, su_msg_arg_t *arg)
   su_root_break(tester->root);
 }
 
+#endif
+
 void
 end_test(struct tester *tester, su_timer_t *t, struct timing *ti)
 {
@@ -182,6 +187,7 @@ int main(int argc, char *argv[])
 
   tester->root = root = su_root_create(tester);
 
+#if HAVE_SIGNAL
   su_msg_create(intr_msg,
                su_root_task(root),
                su_root_task(root),
@@ -189,9 +195,9 @@ int main(int argc, char *argv[])
 
   signal(SIGINT, intr_handler);
 #if HAVE_SIGPIPE
-  signal(SIGPIPE, intr_handler);
   signal(SIGQUIT, intr_handler);
   signal(SIGHUP, intr_handler);
+#endif
 #endif
 
   t = su_timer_create(su_root_task(root), interval);
@@ -217,7 +223,9 @@ int main(int argc, char *argv[])
 
   su_root_run(root);
 
+#if HAVE_SIGNAL
   su_msg_destroy(intr_msg);
+#endif
 
   su_timer_destroy(t);
   su_timer_destroy(t1);
index 12d9cfaec28c7de17626310ce40b1ce757c5e6ae..2deb095344dd9446a64e2fc24a88294932c1cc72 100644 (file)
@@ -35,20 +35,28 @@ nobase_include_sofia_HEADERS = \
                        sofia-sip/tport_plugins.h
 
 TLS_SRC =              tport_type_tls.c tport_tls.c tport_tls.h
-
 if HAVE_TLS
 USE_TLS_SRC =          $(TLS_SRC)
 endif
 
+STUN_SRC =             tport_stub_stun.c tport_type_stun.c
+if HAVE_STUN
+USE_STUN_SRC =                 $(STUN_SRC)
+endif
+
+HTTP_SRC =             tport_type_connect.c
+if HAVE_NTH
+USE_HTTP_SRC =                 $(HTTP_SRC)
+endif
+
 libtport_la_SOURCES =  tport.c tport_logging.c \
-                       tport_stub_stun.c tport_stub_sigcomp.c \
+                       tport_stub_sigcomp.c \
                        tport_type_udp.c tport_type_tcp.c tport_type_sctp.c \
-                       tport_type_connect.c tport_type_stun.c \
                        tport_internal.h \
-                       tport_tag.c tport_tag_ref.c $(USE_TLS_SRC)
+                       tport_tag.c tport_tag_ref.c $(USE_HTTP_SRC) $(USE_TLS_SRC) $(USE_STUN_SRC)
 
 # to make sure all files end up in the dist package
-EXTRA_libtport_la_SOURCES = $(TLS_SRC) 
+EXTRA_libtport_la_SOURCES = $(TLS_SRC) $(STUN_SRC) $(HTTP_SRC)
 
 # Disable for now
 EXTRA_libtport_la_SOURCES += tport_sigcomp.c tport_threadpool.c
@@ -78,4 +86,5 @@ EXTRA_DIST =          Doxyfile tport.docs \
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
+
index 634f943b1cc3c5ca97948981042e736e6b256a4e..099fb2e53474d64bcb3d3e83caf344a49163e558 100644 (file)
@@ -389,6 +389,8 @@ TPORT_DLL extern tag_typedef_t tptag_tos;
  * 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().
+ *
+ * @NEW_1_12_5
  */
 #define TPTAG_TOS(x) tptag_tos, tag_int_v((x))
 
@@ -402,6 +404,8 @@ TPORT_DLL extern tag_typedef_t tptag_log;
  * nth_engine_create(), or initial nth_site_create().
  *
  * @sa #TPORT_DUMP, TPTAG_DUMP()
+ *
+ * @NEW_1_12_5
  */
 #define TPTAG_LOG(x) tptag_log, tag_bool_v((x))
 
@@ -415,6 +419,8 @@ TPORT_DLL extern tag_typedef_t tptag_dump;
  * nth_engine_create(), or initial nth_site_create().
  *
  * @sa #TPORT_DUMP, TPTAG_LOG().
+ *
+ * @NEW_1_12_5
  */
 #define TPTAG_DUMP(x) tptag_dump, tag_str_v((x))
 
index b9e9e31b417a69f2ec4ab36762f29775b121bd1b..e2950047db65c5efcaf42c407bb0d238795c8911 100644 (file)
@@ -112,11 +112,6 @@ char const name[] = "tport_test";
 
 SOFIAPUBVAR su_log_t tport_log[];
 
-void usage(void)
-{
-  fprintf(stderr, "usage: %s [-v]\n", name);
-}
-
 static int name_test(tp_test_t *tt)
 {
   tp_name_t tpn[1];
@@ -381,7 +376,7 @@ static void tp_test_error(tp_test_t *tt,
 {
   tt->tt_status = -1;
   fprintf(stderr, "tp_test_error(%p): error %d (%s) from %s\n", 
-         tp, errcode, su_strerror(errcode), 
+         (void *)tp, errcode, su_strerror(errcode), 
          remote ? remote : "<unknown destination>");
 }
 
@@ -1357,6 +1352,12 @@ static int filter_test(tp_test_t *tt)
   END();
 }
 
+void usage(int exitcode)
+{
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
+}
+
 int main(int argc, char *argv[])
 {
   int flags = 0;       /* XXX */
@@ -1365,10 +1366,12 @@ int main(int argc, char *argv[])
   tp_test_t tt[1] = {{{ SU_HOME_INIT(tt) }}};
 
   for (i = 1; argv[i]; i++) {
-    if (strcmp(argv[i], "-v") == 0)
+    if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbatim") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--abort") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   /* Use log */
index fae8bf459f1160001699a150666d570fbdac6cf0..52ee051872493165c08eb5c8df423ca6aad614b6 100644 (file)
@@ -292,7 +292,7 @@ int tport_is_connected(tport_t const *self)
 }
 
 /** MTU for transport  */
-static inline usize_t tport_mtu(tport_t const *self)
+static inline unsigned tport_mtu(tport_t const *self)
 {
   return self->tp_params->tpp_mtu;
 }
@@ -453,7 +453,7 @@ tport_t *tport_tcreate(tp_stack_t *stack,
   if (!mr)
     return NULL;
 
-  SU_DEBUG_7(("%s(): %p\n", "tport_create", mr));
+  SU_DEBUG_7(("%s(): %p\n", "tport_create", (void *)mr));
 
   mr->mr_stack = stack;
   mr->mr_tpac = tpac;
@@ -492,7 +492,9 @@ tport_t *tport_tcreate(tp_stack_t *stack,
   if (tick < 200)
     tick = 200;
 
+#if HAVE_SOFIA_STUN
   tport_init_stun_server(mr, ta_args(ta));
+#endif
 
   mr->mr_timer = su_timer_create(su_root_task(root), tick);
   su_timer_set(mr->mr_timer, tport_tick, mr);
@@ -516,7 +518,7 @@ void tport_destroy(tport_t *self)
        /* tpac_address */ NULL
       }};
 
-  SU_DEBUG_7(("%s(%p)\n", __func__, self));
+  SU_DEBUG_7(("%s(%p)\n", __func__, (void *)self));
 
   if (self == NULL)
     return;
@@ -531,7 +533,9 @@ void tport_destroy(tport_t *self)
   while (mr->mr_primaries)
     tport_zap_primary(mr->mr_primaries);
 
+#if HAVE_SOFIA_STUN
   tport_deinit_stun_server(mr);
+#endif
 
   if (mr->mr_dump_file)
     fclose(mr->mr_dump_file), mr->mr_dump_file = NULL;
@@ -579,7 +583,8 @@ tport_primary_t *tport_alloc_primary(tport_master_t *mr,
     if (!pri->pri_public)
       tp->tp_addrinfo->ai_addr = &tp->tp_addr->su_sa;
 
-    SU_DEBUG_5(("%s(%p): new primary tport %p\n", __func__, mr, pri));
+    SU_DEBUG_5(("%s(%p): new primary tport %p\n", __func__, (void *)mr,
+               (void *)pri));
   }
 
   *next = pri; 
@@ -706,7 +711,7 @@ tport_primary_t *tport_listen(tport_master_t *mr,
   pri->pri_primary->tp_has_connection = 0;
 
   SU_DEBUG_5(("%s(%p): %s " TPN_FORMAT "\n", 
-             __func__, pri, "listening at",
+                         __func__, (void *)pri, "listening at",
              TPN_ARGS(pri->pri_primary->tp_name)));
 
   return pri;
@@ -778,8 +783,8 @@ int tport_set_events(tport_t *self, int set, int clear)
 
   if (self->tp_pri->pri_vtable->vtp_set_events)
     return self->tp_pri->pri_vtable->vtp_set_events(self);
-
-  SU_DEBUG_7(("tport_set_events(%p): events%s%s%s\n", self,
+  
+  SU_DEBUG_7(("tport_set_events(%p): events%s%s%s\n", (void *)self,
              (events & SU_WAIT_IN) ? " IN" : "",
              (events & SU_WAIT_OUT) ? " OUT" : "",
              SU_WAIT_CONNECT != SU_WAIT_OUT &&
@@ -818,7 +823,7 @@ tport_t *tport_alloc_secondary(tport_primary_t *pri,
   self = su_home_clone(mr->mr_home, pri->pri_vtable->vtp_secondary_size);
 
   if (self) {
-    SU_DEBUG_7(("%s(%p): new secondary tport %p\n", __func__, pri, self));
+         SU_DEBUG_7(("%s(%p): new secondary tport %p\n", __func__, (void *)pri, (void *)self));
 
     self->tp_refs = -1;                        /* Freshly allocated  */
     self->tp_master = mr;
@@ -917,8 +922,8 @@ tport_t *tport_base_connect(tport_primary_t *pri,
            su_wait_destroy(wait),                                   \
            (SU_LOG_LEVEL >= errlevel ?                              \
             su_llog(tport_log, errlevel,                            \
-                    "%s(%p): %s(pf=%d %s/%s): %s\n",                \
-                    __func__, pri, #what, ai->ai_family,            \
+                    "%s(%p): %s(pf=%d %s/%s): %s\n",                   \
+                                __func__, (void *)pri, #what, ai->ai_family,   \
                     tpn->tpn_proto,                                 \
                     tport_hostport(buf, sizeof(buf),                \
                                    (void *)ai->ai_addr, 2),         \
@@ -983,11 +988,11 @@ tport_t *tport_base_connect(tport_primary_t *pri,
 
   if (ai == real_ai) {
     SU_DEBUG_5(("%s(%p): %s to " TPN_FORMAT "\n", 
-               __func__, self, what, TPN_ARGS(self->tp_name)));
+                               __func__, (void *)self, what, TPN_ARGS(self->tp_name)));
   }
   else {
     SU_DEBUG_5(("%s(%p): %s via %s to " TPN_FORMAT "\n",
-               __func__, self, what,
+                               __func__, (void *)self, what,
                tport_hostport(buf, sizeof(buf), (void *)ai->ai_addr, 2),
                TPN_ARGS(self->tp_name)));
   }
@@ -1016,7 +1021,7 @@ void tport_zap_secondary(tport_t *self)
   if (self->tp_msg) {
     msg_destroy(self->tp_msg), self->tp_msg = NULL;
     SU_DEBUG_3(("%s(%p): zapped partially received message\n", 
-               __func__, self));
+                               __func__, (void *)self));
   }
 
   if (self->tp_queue && self->tp_queue[self->tp_qhead]) {
@@ -1026,16 +1031,18 @@ void tport_zap_secondary(tport_t *self)
       n++;
     }
     SU_DEBUG_3(("%s(%p): zapped %lu queued messages\n", 
-               __func__, self, (LU)n));
+                               __func__, (void *)self, (LU)n));
   }
 
   if (self->tp_pused) {
-    SU_DEBUG_3(("%s(%p): zapped with pending requests\n", __func__, self));
+         SU_DEBUG_3(("%s(%p): zapped with pending requests\n", __func__, (void *)self));
   }
 
   mr = self->tp_master;
 
+#if HAVE_SOFIA_STUN
   tport_stun_server_remove_socket(self);
+#endif
 
   if (self->tp_index)
     su_root_deregister(mr->mr_root, self->tp_index);
@@ -1110,7 +1117,7 @@ int tport_get_params(tport_t const *self,
     || !tport_is_primary(self) || !tport_is_dgram(self);
 
   n = tl_tgets(ta_args(ta),
-              TPTAG_MTU(tpp->tpp_mtu),
+              TPTAG_MTU((usize_t)tpp->tpp_mtu),
               TPTAG_REUSE(self->tp_reusable),
               TPTAG_CONNECT(connect),
               TPTAG_QUEUESIZE(tpp->tpp_qsize),
@@ -1146,14 +1153,16 @@ int tport_set_params(tport_t *self,
   ta_list ta;
   int n;
   tport_params_t tpp[1], *tpp0;
-
+  
+  usize_t mtu;
   int connect, sdwn_error, reusable, stun_server;
-
+  
   if (self == NULL)
     return su_seterrno(EINVAL);
 
   memcpy(tpp, tpp0 = self->tp_params, sizeof *tpp);
 
+  mtu = tpp->tpp_mtu;
   connect = tpp->tpp_conn_orient;
   sdwn_error = tpp->tpp_sdwn_error;
   reusable = self->tp_reusable;
@@ -1162,7 +1171,7 @@ int tport_set_params(tport_t *self,
   ta_start(ta, tag, value);
 
   n = tl_gets(ta_args(ta),
-             TPTAG_MTU_REF(tpp->tpp_mtu),
+             TPTAG_MTU_REF(mtu),
              TAG_IF(!self->tp_queue, TPTAG_QUEUESIZE_REF(tpp->tpp_qsize)),
              TPTAG_IDLE_REF(tpp->tpp_idle),
              TPTAG_TIMEOUT_REF(tpp->tpp_timeout),
@@ -1195,6 +1204,9 @@ int tport_set_params(tport_t *self,
   if (tpp->tpp_qsize >= 1000)
     tpp->tpp_qsize = 1000;
 
+  if (mtu > UINT_MAX)
+    mtu = UINT_MAX;
+  tpp->tpp_mtu = (unsigned)mtu;
   /* Currently only primary UDP transport can *not* be connection oriented */ 
   tpp->tpp_conn_orient = connect; 
   tpp->tpp_sdwn_error = sdwn_error;
@@ -1226,7 +1238,9 @@ extern tport_vtable_t const tport_threadpool_vtable;
 
 tport_vtable_t const *tport_vtables[TPORT_NUMBER_OF_TYPES + 1] =
 {
+#if HAVE_SOFIA_NTH
   &tport_http_connect_vtable,
+#endif
 #if HAVE_TLS
   &tport_tls_client_vtable,
   &tport_tls_vtable,
@@ -1294,7 +1308,9 @@ tport_set_f const *tport_set_methods[TPORT_NUMBER_OF_TYPES + 1] =
     tport_server_bind_set,
     tport_client_bind_set,
     tport_threadpool_set,
+#if HAVE_SOFIA_NTH
     tport_http_connect_set,
+#endif
 #if HAVE_TLS
     tport_tls_set,
 #endif
@@ -1406,8 +1422,8 @@ int tport_bind_client(tport_master_t *mr,
 
   if (public == tport_type_local)
     public = tport_type_client;
-
-  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, mr, TPN_ARGS(tpn)));
+  
+  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, (void *)mr, TPN_ARGS(tpn)));
 
   memset(tpn0, 0, sizeof(tpn0));
 
@@ -1466,8 +1482,8 @@ int tport_bind_server(tport_master_t *mr,
   unsigned short step = 0;
 
   bind6only_check(mr);
-
-  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, mr, TPN_ARGS(tpn)));
+  
+  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, (void *)mr, TPN_ARGS(tpn)));
 
   if (tpn->tpn_host == NULL || strcmp(tpn->tpn_host, tpn_any) == 0) {
     /* Use a local IP address */
@@ -1535,7 +1551,7 @@ int tport_bind_server(tport_master_t *mr,
       tpname->tpn_host = host;
 
       SU_DEBUG_9(("%s(%p): calling tport_listen for %s\n", 
-                 __func__, mr, ai->ai_canonname));
+                 __func__, (void *)mr, ai->ai_canonname));
 
       pri = tport_listen(mr, vtable, tpname, ainfo, tags);
       if (!pri) {
@@ -1582,7 +1598,7 @@ int tport_bind_server(tport_master_t *mr,
       break;
 
     SU_DEBUG_3(("%s(%p): cannot bind all transports to port %u, trying %u\n", 
-               __func__, mr, old, port));
+                               __func__, (void *)mr, old, port));
   }
 
   tport_freeaddrinfo(res);
@@ -1687,7 +1703,7 @@ int tport_server_addrinfo(tport_master_t *mr,
     int error = tport_getaddrinfo(host, service, hints, return_addrinfo);
     if (error || !*return_addrinfo) {
       SU_DEBUG_3(("%s(%p): su_getaddrinfo(%s, %s) for %s: %s\n", 
-                 __func__, mr, host ? host : "\"\"", service, protocol,
+                                 __func__, (void *)mr, host ? host : "\"\"", service, protocol,
                  su_gai_strerror(error)));
       return su_seterrno(error != EAI_MEMORY ? ENOENT : ENOMEM);
     }
@@ -1738,13 +1754,13 @@ tport_get_local_addrinfo(tport_master_t *mr,
   if (error) {
 #if SU_HAVE_IN6
     SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n", 
-               __func__, mr, 
+                               __func__, (void *)mr, 
                family == AF_INET6 ? "ip6" 
                : family == AF_INET ? "ip4" : "ip",
                su_gli_strerror(error)));
 #else
     SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n", 
-               __func__, mr, 
+                               __func__, (void *)mr, 
                family == AF_INET ? "ip4" : "ip",
                su_gli_strerror(error)));
 #endif
@@ -1941,7 +1957,7 @@ int tport_addrinfo_copy(su_addrinfo_t *dst, void *addr, socklen_t addrlen,
  */
 void tport_close(tport_t *self)
 {
-  SU_DEBUG_5(("%s(%p): " TPN_FORMAT "\n", "tport_close", self,
+       SU_DEBUG_5(("%s(%p): " TPN_FORMAT "\n", "tport_close", (void *)self,
              TPN_ARGS(self->tp_name)));
 
   self->tp_closed = 1;
@@ -1990,8 +2006,8 @@ int tport_shutdown(tport_t *self, int how)
 {
   if (!tport_is_secondary(self))
     return -1;
-
-  SU_DEBUG_7(("%s(%p, %d)\n", "tport_shutdown", self, how));
+  
+  SU_DEBUG_7(("%s(%p, %d)\n", "tport_shutdown", (void *)self, how));
 
   if (!tport_is_tcp(self) ||
       how < 0 || 
@@ -2057,7 +2073,7 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
        tp_next = tprb_succ(tp);
        if (tp->tp_queue && tp->tp_queue[tp->tp_qhead]) {
          SU_DEBUG_9(("tport_tick(%p) - trying to send to %s/%s:%s\n", 
-                     tp, tp->tp_protoname, tp->tp_host, tp->tp_port));
+                                 (void *)tp, tp->tp_protoname, tp->tp_host, tp->tp_port));
          tport_send_queue(tp);
        }
       }      
@@ -2073,7 +2089,7 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
          (int)tp->tp_params->tpp_timeout < ts - (int)tp->tp_time &&
          !msg_is_streaming(msg)) {
        SU_DEBUG_5(("tport_tick(%p): incomplete message idle for %d ms\n",
-                   tp, ts - (int)tp->tp_time));
+                               (void *)tp, ts - (int)tp->tp_time));
        msg_set_streaming(msg, 0);
        msg_set_flags(msg, MSG_FLG_ERROR | MSG_FLG_TRUNC | MSG_FLG_TIMEOUT);
        tport_deliver(tp, msg, NULL, NULL, now);
@@ -2094,10 +2110,10 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
       }
 
       if (closed) {
-       SU_DEBUG_5(("tport_tick(%p): closed, zapping\n", tp));
+                 SU_DEBUG_5(("tport_tick(%p): closed, zapping\n", (void *)tp));
       } else {
        SU_DEBUG_5(("tport_tick(%p): unused for %d ms, closing and zapping\n",
-                   tp, ts - (int)tp->tp_time));
+                               (void *)tp, ts - (int)tp->tp_time));
        if (!tport_is_closed(tp))
          tport_close(tp);
       }
@@ -2125,7 +2141,7 @@ int tport_flush(tport_t *tp)
       continue;
 
     SU_DEBUG_1(("tport_flush(%p): %szapping\n",
-               tp, tport_is_closed(tp) ? "" : "closing and "));
+                               (void *)tp, tport_is_closed(tp) ? "" : "closing and "));
     if (!tport_is_closed(tp))
       tport_close(tp);
     tport_zap_secondary(tp);
@@ -2364,10 +2380,10 @@ void tport_error_report(tport_t *self, int errcode,
   }
   else {
     if (tport_is_primary(self))
-      SU_DEBUG_3(("%s(%p): %s (with %s)\n", __func__, self, 
+               SU_DEBUG_3(("%s(%p): %s (with %s)\n", __func__, (void *)self, 
                  errmsg, self->tp_protoname));
     else
-      SU_DEBUG_3(("%s(%p): %s (with %s/%s:%s)\n", __func__, self, 
+               SU_DEBUG_3(("%s(%p): %s (with %s/%s:%s)\n", __func__, (void *)self, 
                  errmsg, self->tp_protoname, self->tp_host, self->tp_port));
   }
 
@@ -2433,7 +2449,7 @@ int tport_accept(tport_primary_t *pri, int events)
 
       if (tport_setname(self, pri->pri_protoname, ai, NULL) != -1) {
        SU_DEBUG_5(("%s(%p): new connection from " TPN_FORMAT "\n", 
-                   __func__,  self, TPN_ARGS(self->tp_name)));
+                               __func__,  (void *)self, TPN_ARGS(self->tp_name)));
 
        tprb_append(&pri->pri_secondary, self);
 
@@ -2486,8 +2502,8 @@ static int tport_connected(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
   su_wait_t wait[1] =  { SU_WAIT_INIT };
 
   int error;
-
-  SU_DEBUG_7(("tport_connected(%p): events%s%s\n", self,
+  
+  SU_DEBUG_7(("tport_connected(%p): events%s%s\n", (void *)self,
              events & SU_WAIT_CONNECT ? " CONNECTED" : "",
              events & SU_WAIT_ERR ? " ERR" : ""));
 
@@ -2512,7 +2528,7 @@ static int tport_connected(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
 
   su_root_deregister(mr->mr_root, self->tp_index);
   self->tp_index = -1;
-  self->tp_events = SU_WAIT_IN | SU_WAIT_ERR;
+  self->tp_events = SU_WAIT_IN | SU_WAIT_ERR | SU_WAIT_HUP;
   if (su_wait_create(wait, self->tp_socket, self->tp_events) == -1 ||
       (self->tp_index = su_root_register(mr->mr_root, 
                                         wait, tport_wakeup, self, 0))
@@ -2537,7 +2553,7 @@ static int tport_wakeup_pri(su_root_magic_t *m, su_wait_t *w, tport_t *self)
 #endif
 
   SU_DEBUG_7(("%s(%p): events%s%s%s%s%s%s\n", 
-             "tport_wakeup_pri", self,
+                         "tport_wakeup_pri", (void *)self,
              events & SU_WAIT_IN ? " IN" : "",
              SU_WAIT_ACCEPT != SU_WAIT_IN && 
              (events & SU_WAIT_ACCEPT) ? " ACCEPT" : "",
@@ -2563,7 +2579,7 @@ static int tport_wakeup(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
 #endif
 
   SU_DEBUG_7(("%s(%p): events%s%s%s%s%s\n", 
-             "tport_wakeup", self,
+                         "tport_wakeup", (void *)self,
              events & SU_WAIT_IN ? " IN" : "",
              events & SU_WAIT_OUT ? " OUT" : "",
              events & SU_WAIT_HUP ? " HUP" : "",
@@ -2617,7 +2633,7 @@ int tport_continue(tport_t *self)
  */
 void tport_hup_event(tport_t *self)
 {
-  SU_DEBUG_7(("%s(%p)\n", __func__, self));
+       SU_DEBUG_7(("%s(%p)\n", __func__, (void *)self));
 
   if (self->tp_msg) {
     su_time_t now = su_now();
@@ -2650,8 +2666,8 @@ void tport_recv_event(tport_t *self)
 {
   su_time_t now;
   int again;
-
-  SU_DEBUG_7(("%s(%p)\n", "tport_recv_event", self));
+  
+  SU_DEBUG_7(("%s(%p)\n", "tport_recv_event", (void *)self));
 
   do {
     now = su_now(); 
@@ -2661,8 +2677,10 @@ void tport_recv_event(tport_t *self)
 
     self->tp_time = su_time_ms(now);
 
+#if HAVE_SOFIA_STUN
     if (again == 3) /* STUN keepalive */
       return;
+#endif
 
     if (again < 0) {
       int error = su_errno();
@@ -2718,7 +2736,7 @@ static void tport_parse(tport_t *self, int complete, su_time_t now)
 
     if (msg_get_flags(msg, MSG_FLG_TOOLARGE))
       SU_DEBUG_3(("%s(%p): too large message from " TPN_FORMAT "\n",
-                 __func__, self, TPN_ARGS(self->tp_name)));
+                                 __func__, (void *)self, TPN_ARGS(self->tp_name)));
 
     /* Do not try to read anymore from this connection? */
     if (tport_is_stream(self) && 
@@ -2806,9 +2824,9 @@ void tport_deliver(tport_t *self,
 
   SU_DEBUG_7(("%s(%p): %smsg %p ("MOD_ZU" bytes)"
              " from " TPN_FORMAT " next=%p\n", 
-             __func__, self, error ? "bad " : "",
-             msg, (size_t)msg_size(msg),
-             TPN_ARGS(d->d_from), next));
+             __func__, (void *)self, error ? "bad " : "",
+             (void *)msg, (size_t)msg_size(msg),
+             TPN_ARGS(d->d_from), (void *)next));
 
   ref = tport_incref(self);
 
@@ -2895,7 +2913,7 @@ ssize_t tport_recv_iovec(tport_t const *self,
     if (!(*in_out_msg = msg = tport_msg_alloc(self, N))) {
       SU_DEBUG_7(("%s(%p): cannot allocate msg for "MOD_ZU" bytes "
                  "from (%s/%s:%s)\n", 
-                 __func__, self, N, 
+                                 __func__, (void *)self, N, 
                  self->tp_protoname, self->tp_host, self->tp_port));
       return -1;
     }
@@ -2914,7 +2932,7 @@ ssize_t tport_recv_iovec(tport_t const *self,
     int err = su_errno();
     SU_DEBUG_7(("%s(%p): cannot get msg %p buffer for "MOD_ZU" bytes "
                "from (%s/%s:%s): %s\n", 
-               __func__, self, msg, N, 
+                               __func__, (void *)self, (void *)msg, N, 
                self->tp_protoname, self->tp_host, self->tp_port,
                su_strerror(err)));
     su_seterrno(err);
@@ -2925,8 +2943,8 @@ ssize_t tport_recv_iovec(tport_t const *self,
 
   SU_DEBUG_7(("%s(%p) msg %p from (%s/%s:%s) has "MOD_ZU" bytes, "
              "veclen = "MOD_ZD"\n",
-              __func__, self, 
-             msg, self->tp_protoname, self->tp_host, self->tp_port, 
+              __func__, (void *)self, 
+                         (void *)msg, self->tp_protoname, self->tp_host, self->tp_port, 
              N, veclen));
 
   for (i = 0; veclen > 1 && i < veclen; i++) {
@@ -2977,8 +2995,9 @@ tport_t *tport_tsend(tport_t *self,
   }
 
   *tpn = *_tpn;
-
-  SU_DEBUG_7(("tport_tsend(%p) tpn = " TPN_FORMAT "\n", self, TPN_ARGS(tpn)));
+  
+  SU_DEBUG_7(("tport_tsend(%p) tpn = " TPN_FORMAT "\n",
+             (void *)self, TPN_ARGS(tpn)));
 
   if (tport_is_master(self)) {
     primary = (tport_primary_t *)tport_primary_by_name(self, tpn);
@@ -3030,7 +3049,7 @@ tport_t *tport_tsend(tport_t *self,
   if (tpn->tpn_comp) {
     ai->ai_flags |= TP_AI_COMPRESSED;
     SU_DEBUG_9(("%s: compressed msg(%p) with %s\n", 
-               __func__, msg, tpn->tpn_comp));
+                               __func__, (void *)msg, tpn->tpn_comp));
   } 
 
   if (!tpn->tpn_comp || cc == NONE)
@@ -3140,7 +3159,7 @@ int tport_prepare_and_send(tport_t *self, msg_t *msg,
     return -1;
   }
 
-  if (msg_size(msg) > (mtu ? mtu : tport_mtu(self))) {
+  if (msg_size(msg) > (usize_t)(mtu ? mtu : tport_mtu(self))) {
     msg_set_errno(msg, EMSGSIZE);
     return -1;
   }
@@ -3236,9 +3255,9 @@ int tport_send_msg(tport_t *self, msg_t *msg,
       }
       else {
        char const *comp = tpn->tpn_comp;
-
+       
        SU_DEBUG_1(("tport(%p): send truncated for %s/%s:%s%s%s\n", 
-                   self, tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port,
+                               (void *)self, tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port,
                    comp ? ";comp=" : "", comp ? comp : ""));
 
        su_seterrno(EIO);
@@ -3252,6 +3271,7 @@ int tport_send_msg(tport_t *self, msg_t *msg,
   /* We have sent a complete message */
 
   self->tp_slogged = NULL;
+  self->tp_stats.sent_msgs ++;
 
   ai = msg_addrinfo(msg); assert(ai);
   close_after = (ai->ai_flags & TP_AI_CLOSE) == TP_AI_CLOSE;
@@ -3302,9 +3322,9 @@ ssize_t tport_vsend(tport_t *self,
 
     if (tpn == NULL || tport_is_connection_oriented(self))
       tpn = self->tp_name;
-
+    
     SU_DEBUG_7(("tport_vsend(%p): "MOD_ZU" bytes of "MOD_ZU" to %s/%s:%s%s\n", 
-               self, n, m, tpn->tpn_proto, tpn->tpn_host, 
+                               (void *)self, n, m, tpn->tpn_proto, tpn->tpn_host, 
                tpn->tpn_port, 
                (ai->ai_flags & TP_AI_COMPRESSED) ? ";comp=sigcomp" : ""));
   }
@@ -3326,7 +3346,7 @@ int tport_send_error(tport_t *self, msg_t *msg,
 
   if (su_is_blocking(error)) {
     SU_DEBUG_5(("tport_vsend(%p): %s with (s=%d %s/%s:%s%s)\n", 
-               self, "EAGAIN", (int)self->tp_socket, 
+                               (void *)self, "EAGAIN", (int)self->tp_socket, 
                tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port, comp));
     return 0;
   }
@@ -3335,7 +3355,7 @@ int tport_send_error(tport_t *self, msg_t *msg,
 
   if (self->tp_addrinfo->ai_family == AF_INET) {
     SU_DEBUG_3(("tport_vsend(%p): %s with (s=%d %s/%s:%s%s)\n", 
-               self, su_strerror(error), (int)self->tp_socket, 
+                               (void *)self, su_strerror(error), (int)self->tp_socket, 
                tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port, comp));
   }
 #if SU_HAVE_IN6
@@ -3343,7 +3363,7 @@ int tport_send_error(tport_t *self, msg_t *msg,
     su_sockaddr_t const *su = (su_sockaddr_t const *)ai->ai_addr;
     SU_DEBUG_3(("tport_vsend(%p): %s with "
                "(s=%d, IP6=%s/%s:%s%s (scope=%i) addrlen=%u)\n", 
-               self, su_strerror(error), (int)self->tp_socket, 
+                               (void *)self, su_strerror(error), (int)self->tp_socket, 
                tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port, comp,
                su->su_scope_id, (unsigned)ai->ai_addrlen));
   }
@@ -3351,7 +3371,7 @@ int tport_send_error(tport_t *self, msg_t *msg,
   else {
     SU_DEBUG_3(("\ttport_vsend(%p): %s with "
                "(s=%d, AF=%u addrlen=%u)%s\n", 
-               self, su_strerror(error), 
+                               (void *)self, su_strerror(error), 
                (int)self->tp_socket, ai->ai_family, (unsigned)ai->ai_addrlen, comp));
   }
 
@@ -3359,7 +3379,7 @@ int tport_send_error(tport_t *self, msg_t *msg,
   int i;
   for (i = 0; i < iovused; i++)
     SU_DEBUG_7(("\t\tiov[%d] = { %d bytes @ %p }\n", 
-               i, iov[i].siv_len, iov[i].siv_base));
+               i, iov[i].siv_len, (void *)iov[i].siv_base));
 #endif
 
   if (tport_is_connection_oriented(self)) {
@@ -3480,9 +3500,9 @@ int tport_queue(tport_t *self, msg_t *msg)
 {
   unsigned short qhead = self->tp_qhead;
   unsigned short N = self->tp_params->tpp_qsize;
-
+  
   SU_DEBUG_7(("tport_queue(%p): queueing %p for %s/%s:%s\n", 
-             self, msg, self->tp_protoname, self->tp_host, self->tp_port));
+                         (void *)self, (void *)msg, self->tp_protoname, self->tp_host, self->tp_port));
 
   if (self->tp_queue == NULL) {
     assert(N > 0);
@@ -3618,9 +3638,9 @@ int tport_tqsend(tport_t *self, msg_t *msg, msg_t *next,
 void tport_send_event(tport_t *self)
 {
   assert(tport_is_connection_oriented(self));
-
+  
   SU_DEBUG_7(("tport_send_event(%p) - ready to send to (%s/%s:%s)\n", 
-             self, self->tp_protoname, self->tp_host, self->tp_port));
+                         (void *)self, self->tp_protoname, self->tp_host, self->tp_port));
   tport_send_queue(self);
 }
 
@@ -3671,8 +3691,11 @@ void tport_send_queue(tport_t *self)
     }
     assert(total == n);
 
+    /* We have sent a complete message */
+    
     self->tp_queue[qhead] = NULL;
     msg_destroy(msg);
+    self->tp_stats.sent_msgs++;
     self->tp_slogged = NULL;
 
     qhead = (qhead + 1) % N;
@@ -3773,11 +3796,15 @@ msg_select_addrinfo(msg_t *msg, su_addrinfo_t *res)
       continue;
 #endif
 
+    if (ai->ai_protocol == 0)
+      continue;
     if (ai->ai_addrlen > sizeof(su_sockaddr_t))
       continue;
+
     mai->ai_family = ai->ai_family;
     mai->ai_socktype = ai->ai_socktype;
     mai->ai_protocol = ai->ai_protocol;
+
     if (ai->ai_addrlen < sizeof(su_sockaddr_t))
       memset(su, 0, sizeof(su_sockaddr_t));
     memcpy(su, ai->ai_addr, ai->ai_addrlen);
@@ -3847,9 +3874,9 @@ int tport_pend(tport_t *self,
 
   if (self == NULL || msg == NULL || callback == NULL || client == NULL)
     return -1;
-
+  
   SU_DEBUG_7(("tport_pend(%p): pending %p for %s/%s:%s (already %u)\n", 
-             self, msg, 
+                         (void *)self, (void *)msg, 
              self->tp_protoname, self->tp_host, self->tp_port,
              self->tp_pused));
 
@@ -3904,13 +3931,13 @@ int tport_release(tport_t *self,
 
   if (pending->p_client != client || 
       pending->p_msg != msg) {
-    SU_DEBUG_1(("tport_release(%p): %u %p by %p not pending\n", self, 
-               pendd, msg, client));
+         SU_DEBUG_1(("tport_release(%p): %u %p by %p not pending\n", (void *)self, 
+                                 pendd, (void *)msg, (void *)client));
     return su_seterrno(EINVAL), -1;
   }
-
+  
   SU_DEBUG_7(("tport_release(%p): %p by %p with %p%s\n", 
-             self, msg, client, reply,
+                         (void *)self, (void *)msg, (void *)client, (void *)reply,
              still_pending ? " (preliminary)" : ""));
 
   /* sigcomp can here associate request (msg) with response (reply) */
@@ -4249,7 +4276,7 @@ tport_t *tport_by_name(tport_t const *self, tp_name_t const *tpn)
     }
     else {
       SU_DEBUG_7(("tport(%p): EXPENSIVE unresolved " TPN_FORMAT "\n",
-                 self, TPN_ARGS(tpn)));
+                                 (void *)self, TPN_ARGS(tpn)));
 
       sub = tprb_first(sub);
     }
@@ -4269,11 +4296,11 @@ tport_t *tport_by_name(tport_t const *self, tp_name_t const *tpn)
        if ((socklen_t)sub->tp_addrlen != sulen ||
            memcmp(sub->tp_addr, su, sulen)) {
          SU_DEBUG_7(("tport(%p): not found by name " TPN_FORMAT "\n",
-                     self, TPN_ARGS(tpn)));
+                                 (void *)self, TPN_ARGS(tpn)));
          break;
        }
        SU_DEBUG_7(("tport(%p): found %p by name " TPN_FORMAT "\n",
-                   self, sub, TPN_ARGS(tpn)));
+                               (void *)self, (void *)sub, TPN_ARGS(tpn)));
       }
       else if ((strcasecmp(canon, sub->tp_canon) &&
                strcasecmp(host, sub->tp_host)) ||
@@ -4354,10 +4381,10 @@ tport_t *tport_by_addrinfo(tport_primary_t const *pri,
 
   if (sub)
     SU_DEBUG_7(("%s(%p): found %p by name " TPN_FORMAT "\n",
-               __func__, pri, sub, TPN_ARGS(tpn)));
+                               __func__, (void *)pri, (void *)sub, TPN_ARGS(tpn)));
   else
     SU_DEBUG_7(("%s(%p): not found by name " TPN_FORMAT "\n",
-               __func__, pri, TPN_ARGS(tpn)));
+                               __func__, (void *)pri, TPN_ARGS(tpn)));
 
   return (tport_t *)sub;
 }
index a70ecc31ea156b5f64c8e6a89c72acd35e674c3f..6669cb40f49145bf8b7b1c255ce6570180aa9a48 100644 (file)
@@ -91,7 +91,7 @@ typedef long unsigned LU;     /* for printf() and friends */
 
 /** Transport parameters */
 typedef struct {
-  usize_t  tpp_mtu;            /**< Maximum packet size */
+  unsigned tpp_mtu;            /**< Maximum packet size */
   unsigned tpp_idle;           /**< Allowed connection idle time. */
   unsigned tpp_timeout;                /**< Allowed idle time for message. */
   unsigned tpp_sigcomp_lifetime;  /**< SigComp compartment lifetime  */
index ff3d670965e431564201fe96e735431761657223..9b2d24b49b52c364ba8e1fa730687bbea24db07f 100644 (file)
@@ -221,17 +221,17 @@ void tport_log_msg(tport_t *self, msg_t *msg,
       n = strncspn(s, end - s, "\r\n");
 
       if (linelen + n > MAX_LINELEN) {
-       n = MAX_LINELEN - n - linelen;
+       n = MAX_LINELEN - linelen;
        truncated = logged + n;
       }
 
-      su_log("%s%.*s", linelen > n ? "" : "   ", (int)n, s);
+      su_log("%s%.*s", linelen > 0 ? "" : "   ", (int)n, s);
       s += n, linelen += n, logged += n;
 
       if (truncated)
        break;
       if (s == end)
-       continue;
+       break;
 
       linelen = 0;
       su_log("\n");
index 61f86aee0aaeee99a99e01bd063ff754d70912ff..b5971497a05da71c200ed839659bd59cff183c7b 100644 (file)
@@ -155,7 +155,7 @@ int tport_recv_stun_dgram(tport_t const *self,
     }
     else
       SU_DEBUG_7(("tport(%p): recv_stun_dgram(): "
-                 "ignoring request with "MOD_ZU" bytes\n", self, n));
+                 "ignoring request with "MOD_ZU" bytes\n", (void *)self, n));
   }
   else if (request[0] == 0 && self->tp_master->mr_stun_server) {
     tport_stun_server_vtable_t const *vst = tport_stun_server_vtable;
@@ -178,7 +178,7 @@ int tport_recv_stun_dgram(tport_t const *self,
     elen = (elen + 3) & -4;    /* Round up to 4 */
 
     SU_DEBUG_7(("tport(%p): recv_stun_dgram(): "
-               "responding %u %s\n", self, status, error));
+               "responding %u %s\n", (void *)self, status, error));
   /*
      0                   1                   2                   3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -237,7 +237,7 @@ int tport_recv_stun_dgram(tport_t const *self,
 #undef set16
   }
   else {
-    SU_DEBUG_0(("tport(%p): recv_stun_dgram(): internal error\n", self));
+    SU_DEBUG_0(("tport(%p): recv_stun_dgram(): internal error\n", (void *)self));
     su_seterrno(EBADMSG);
     retval = -1;
   }
index 7abebbd84fdf8edf927ca20980fdf402e085ae7e..0a242cc47e8924ca9c66a3b2909763716fc0e805 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if HAVE_SIGPIPE
 #include <signal.h>
+#endif
 
 #include "tport_tls.h"
 
@@ -162,8 +165,10 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti)
     }
   }
 
+#if HAVE_SIGPIPE
   /* Avoid possible SIGPIPE when sending close_notify */
   signal(SIGPIPE, SIG_IGN);
+#endif
 
   if (tls->bio_err == NULL)
     tls->bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
@@ -295,7 +300,9 @@ tls_t *tls_init_master(tls_issues_t *ti)
   unsigned char sessionId[32] = "sofia/tls"; 
   tls_t *tls;
 
+#if HAVE_SIGPIPE
   signal(SIGPIPE, SIG_IGN);  /* Ignore spurios SIGPIPE from OpenSSL */
+#endif
 
   tls_set_default(ti);
 
@@ -420,6 +427,7 @@ tls_t *tls_clone(tls_t *master, int sock, int accept)
     SSL_set_connect_state(tls->con);
   SSL_set_mode(tls->con, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
 
+  su_setblocking(sock, 0);
   tls_read(tls); /* XXX - works only with non-blocking sockets */
 
   return tls;
@@ -611,7 +619,7 @@ ssize_t tls_read(tls_t *tls)
   }
 
   if (0)
-    fprintf(stderr, "tls_read(%p) called on %s (events %u)\n", tls,
+    fprintf(stderr, "tls_read(%p) called on %s (events %u)\n", (void *)tls,
            tls->type == tls_slave ? "server" : "client",
            tls->read_events);
 
@@ -674,7 +682,7 @@ ssize_t tls_write(tls_t *tls, void *buf, size_t size)
 
   if (0) 
     fprintf(stderr, "tls_write(%p, %p, "MOD_ZU") called on %s\n", 
-           tls, buf, size,
+           (void *)tls, buf, size,
            tls && tls->type == tls_slave ? "server" : "client");
 
   if (tls == NULL || buf == NULL) {
index 14ec9faab190b109cb09e69644e6ed3979f802e7..047d91ca71d420719f587a538ebca0004a7a94ed 100644 (file)
@@ -37,8 +37,6 @@
 
 #include "config.h"
 
-#if HAVE_SCTP
-
 #include "tport_internal.h"
 
 #if HAVE_NETINET_SCTP_H
 #undef MAX_STREAMS
 #define MAX_STREAMS MAX_STREAMS
 
+/* Missing socket symbols */
+#ifndef SOL_SCTP
+#define SOL_SCTP IPPROTO_SCTP
+#endif
+
+
 enum { MAX_STREAMS = 1 };
 typedef struct tport_sctp_t
 {
@@ -76,6 +80,8 @@ typedef struct tport_sctp_t
 
 #define TP_SCTP_MSG_MAX (65536)
 
+#if HAVE_SCTP
+
 static int tport_sctp_init_primary(tport_primary_t *, 
                                   tp_name_t tpn[1], 
                                   su_addrinfo_t *, tagi_t const *,
@@ -174,9 +180,6 @@ static int tport_sctp_init_secondary(tport_t *self, int socket, int accepted,
 {
   self->tp_has_connection = 1;
 
-  if (su_setblocking(socket, 0) < 0)
-    return *return_reason = "su_setblocking", -1;
-
   if (accepted) {
     /* Accepted socket inherit the init information from listen socket */
     return 0;
index 542af84e20b370916a754c6f09ed98b82805eacf..a890b3f61879d3b70559704b701e5cb98cac1139 100644 (file)
@@ -175,8 +175,6 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted,
 
   if (setsockopt(socket, SOL_TCP, TCP_NODELAY, (void *)&one, sizeof one) == -1)
     return *return_reason = "TCP_NODELAY", -1;
-  if (su_setblocking(socket, 0) < 0)
-    return *return_reason = "su_setblocking", -1;
 
   if (!accepted)
     tport_tcp_setsndbuf(socket, 64 * 1024);
@@ -230,7 +228,7 @@ int tport_recv_stream(tport_t *self)
   }
   if (N == -1) {
     err = su_errno();
-    SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, self,
+    SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, (void *)self,
                su_strerror(err), err));
     return -1;
   }
index b3a0ce401f96257f3d7160838558d5ae5ee2ade5..68a651c83e5e0aa4ff806306f0b9aa960325160f 100644 (file)
@@ -187,7 +187,7 @@ static int tport_tls_init_master(tport_primary_t *pri,
     ti.CAfile = su_sprintf(autohome, "%s/%s", path, "cafile.pem");
     ti.version = tls_version;
 
-    SU_DEBUG_9(("%s(%p): tls key = %s\n", __func__, pri, ti.key));
+    SU_DEBUG_9(("%s(%p): tls key = %s\n", __func__, (void *)pri, ti.key));
 
     if (ti.key && ti.CAfile && ti.randFile) {
       tlspri->tlspri_master = tls_init_master(&ti);
@@ -271,7 +271,7 @@ int tport_tls_set_events(tport_t const *self)
   int mask = tls_events(tlstp->tlstp_context, self->tp_events);
 
   SU_DEBUG_7(("%s(%p): logical events%s%s real%s%s\n",
-             "tport_tls_set_events", self, 
+             "tport_tls_set_events", (void *)self, 
              (self->tp_events & SU_WAIT_IN) ? " IN" : "",
              (self->tp_events & SU_WAIT_OUT) ? " OUT" : "",
              (mask & SU_WAIT_IN) ? " IN" : "",
@@ -325,7 +325,7 @@ int tport_tls_events(tport_t *self, int events)
     return 0;
 
   SU_DEBUG_7(("%s(%p): logical events%s%s real%s%s\n",
-             "tport_tls_events", self, 
+             "tport_tls_events", (void *)self, 
              (events & SU_WAIT_IN) ? " IN" : "",
              (events & SU_WAIT_OUT) ? " OUT" : "",
              (mask & SU_WAIT_IN) ? " IN" : "",
@@ -358,7 +358,7 @@ int tport_tls_recv(tport_t *self)
 
   N = tls_read(tlstp->tlstp_context);
 
-  SU_DEBUG_7(("%s(%p): tls_read() returned "MOD_ZD"\n", __func__, self, N));
+  SU_DEBUG_7(("%s(%p): tls_read() returned "MOD_ZD"\n", __func__, (void *)self, N));
 
   if (N == 0) /* End-of-stream */
     return 0;
@@ -462,7 +462,7 @@ ssize_t tport_tls_send(tport_t const *self,
 #endif
 
     SU_DEBUG_9(("tport_tls_writevec: vec %p %p %lu ("MOD_ZD")\n",  
-               tlstp->tlstp_context, iov[i].siv_base, (LU)iov[i].siv_len, 
+               (void *)tlstp->tlstp_context, (void *)iov[i].siv_base, (LU)iov[i].siv_len, 
                nerror));
 
     if (nerror == -1) {
index 21d815b5287a0c171b8e81a8d43d0d4042704316..a5c3b540b992b8aa1bc9cbe8c1c670e02d80697d 100644 (file)
@@ -166,7 +166,9 @@ int tport_udp_init_primary(tport_primary_t *pri,
 
   tport_check_trunc(pri->pri_primary, ai);
 
+#if HAVE_SOFIA_STUN
   tport_stun_server_add_socket(pri->pri_primary);
+#endif
 
   return 0;
 }
@@ -233,7 +235,7 @@ int tport_recv_dgram(tport_t *self)
   if (self->tp_params->tpp_drop && 
       (unsigned)su_randint(0, 1000) < self->tp_params->tpp_drop) {
     su_recv(self->tp_socket, sample, 1, 0);
-    SU_DEBUG_3(("tport(%p): simulated packet loss!\n", self));
+    SU_DEBUG_3(("tport(%p): simulated packet loss!\n", (void *)self));
     return 0;
   }
 
@@ -246,10 +248,15 @@ int tport_recv_dgram(tport_t *self)
   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_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, (void *)self,
                su_strerror(err), err));
     return -1;
   }
+  if (N == 0) {
+    su_recv(self->tp_socket, sample, 1, 0);
+    SU_DEBUG_3(("tport(%p): zero length packet", (void *)self));
+    return 0;
+  }
 #endif
 
   veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, 1);
@@ -280,7 +287,8 @@ int tport_recv_dgram(tport_t *self)
       return -1;
   }
   else if (n <= 1) {
-    SU_DEBUG_1(("%s(%p): runt of "MOD_ZD" bytes\n", "tport_recv_dgram", self, n));
+    SU_DEBUG_1(("%s(%p): runt of "MOD_ZD" bytes\n",
+               "tport_recv_dgram", (void *)self, n));
     msg_destroy(msg), self->tp_msg = NULL;
     return 0;
   }
@@ -299,9 +307,11 @@ int tport_recv_dgram(tport_t *self)
     /* SigComp */
     return tport_recv_comp_dgram(self, self->tp_comp, &self->tp_msg, 
                                 from, fromlen);
+#if HAVE_SOFIA_STUN
   else if (sample[0] == 0 || sample[0] == 1)
     /* STUN request or response */
     return tport_recv_stun_dgram(self, &self->tp_msg, from, fromlen);
+#endif
   else
     return 0;
 }
index 906db1417d960b78c711d9043f6e1b7466834927..b36f50733b67f5b64e9015a9e9bd49ed19d18c21 100644 (file)
@@ -34,6 +34,7 @@ COVERAGE_INPUT =      $(liburl_la_SOURCES) $(include_sofia_HEADERS)
 
 LDADD =                liburl.la \
                        ../bnf/libbnf.la \
+                       ../ipt/libipt.la \
                        ../su/libsu.la
 
 test_urlmap_SOURCES =  urlmap.c urlmap.h
@@ -52,6 +53,6 @@ TESTS =               torture_url test_urlmap
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include ../sofia.am
+include $(top_srcdir)/rules/sofia.am
 
 TAG_DLL_FLAGS =        DLLREF=1
index cb2e30bbe7cee8c9aadcdea5d3b52d62bbdb91be..5a351f9f456b9ab25fadb8dffb6acff1b7a07554 100644 (file)
 #ifndef URL_H_TYPES
 #define URL_H_TYPES
 
-/** Recognized URL schemes (value of url_t.url_type). */
+/** Recognized URL schemes (value of url_t.url_type). 
+ *
+ * @sa &lt;<a href="http://www.iana.org/assignments/uri-schemes.html">http://www.iana.org/assignments/uri-schemes.html</a>&gt;
+ */
 enum url_type_e {
-  url_invalid = -2,            /**< Invalid url. */
-  url_unknown = -1,            /**< Unknown scheme. */
-  url_any = 0,                 /**< @c "*" */
-  url_sip,                     /**< @c "sip:" */
-  url_sips,                    /**< @c "sips:" */
-  url_tel,                     /**< @c "tel:" */
-  url_fax,                     /**< @c "fax:" */
-  url_modem,                   /**< @c "modem:" */
-  url_http,                    /**< @c "http:" */
-  url_https,                   /**< @c "https:" */
-  url_ftp,                     /**< @c "ftp:" */
-  url_file,                    /**< @c "file:" */
-  url_rtsp,                    /**< @c "rtsp:" */
-  url_rtspu,                   /**< @c "rtspu:" */
-  url_mailto,                  /**< @c "mailto:" */
-  url_im,                      /**< @c "im:" (simple instant messaging) */
-  url_pres,                    /**< @c "pres:" (simple presence) */
-  url_cid,                     /**< @c "cid:" (Content-ID) */
-  url_msrp,                    /**< @c "msrp:" (message session relay)  */
-  url_msrps,                   /**< @c "msrps:" (new in @VERSION_1_12_2) */
-  url_wv,                      /**< @c "wv:" (Wireless village) */
+  url_invalid = -2,    /**< Invalid url. */
+  url_unknown = -1,    /**< Unknown scheme. */
+  url_any = 0,         /**< "*" */
+  url_sip,             /**< "sip:". @sa @RFC3261 */
+  url_sips,            /**< "sips:". @sa @RFC3261 */
+  url_tel,             /**< "tel:" @sa RFC3966 */
+  url_fax,             /**< "fax:". @note Obsolete. @sa @RFC2806 */
+  url_modem,           /**< "modem:". @note Obsolete. @sa @RFC2806  */
+  url_http,            /**< "http:". @sa @RFC2616, @RFC3986 */
+  url_https,           /**< "https:". @sa @RFC2618, @RFC3986 */
+  url_ftp,             /**< "ftp:". @sa @RFC1738 */
+  url_file,            /**< "file:" @sa @RFC1738 */
+  url_rtsp,            /**< "rtsp:" @sa @RFC2326 */
+  url_rtspu,           /**< "rtspu:" @sa @RFC2326 */
+  url_mailto,          /**< "mailto:" @sa @RFC2368 */
+  url_im,              /**< "im:" (simple instant messaging). @sa @RFC3860 */
+  url_pres,            /**< "pres:" (simple presence). @sa @RFC3859  */
+  url_cid,             /**< "cid:" (Content-ID). @sa @RFC2392 */
+  url_msrp,            /**< "msrp:" (message session relay)  */
+  url_msrps,           /**< "msrps:" (new in @VERSION_1_12_2) */
+  url_wv,              /**< "wv:" (Wireless village) */
   _url_none
 };
 
index bbd02f47dbeeeb60f21648435f85823036f0da36..e5f65992a894e17eeecb499d19507c0a1839d516 100644 (file)
@@ -49,11 +49,6 @@ static int tstflags = 0;
 
 char const name[] = "torture_url";
 
-void usage(void)
-{
-  fprintf(stderr, "usage: %s [-v]\n", name);
-}
-
 unsigned char hash1[16], hash2[16];
 
 /* test unquoting and canonizing */
@@ -108,7 +103,7 @@ int test_quote(void)
   TEST_S(url_escape(unreserved, UNRESERVED, NULL), UNRESERVED);
   TEST_S(url_unescape(unreserved, UNRESERVED), UNRESERVED);
 
-  d = "%73ip:%55@%68";
+  d = "%53ip:%75@%48";         /* Sip:u@H */
   u = url_hdup(home, (url_t *)d); TEST_1(u);
   url_digest(hash1, sizeof(hash1), u, NULL);
   url_digest(hash2, sizeof(hash2), (url_t const *)d, NULL);
@@ -125,9 +120,11 @@ int test_quote(void)
   d = url_as_string(home, u); TEST_1(d);
   TEST_S(d, c);
 
-  d = "sip:&=+$,;?/:&=+$,@host:56001;param=+$,/:@&;another=@"
+  d = "sip:&=+$,;?/:&=+$,@[::1]:56001;param=+$,/:@&;another=@"
     "?header=" RESERVED "&%3b%2f%3f%3a%40%26%3d%2b%24%2c";
   u = url_hdup(home, (url_t *)d); TEST_1(u);
+  TEST_S(u->url_user, "&=+$,;?/");
+  TEST_S(u->url_host, "[::1]");
   TEST_S(u->url_headers, "header=" RESERVED "&%3B%2F%3F%3A%40%26%3D%2B%24%2C");
   url_digest(hash1, sizeof(hash1), u, NULL);
   url_digest(hash2, sizeof(hash2), (url_t const *)d, NULL);
@@ -137,8 +134,10 @@ int test_quote(void)
   d = url_as_string(home, u); TEST_1(d);
   TEST_S(d, c);
 
-  d = "http://&=+$,;:&=+$,;@host:8080/foo;param=+$,/:@&;another=@?query=" RESERVED;
+  d = "http://&=+$,;:&=+$,;@host:8080/foo;param=+$,/:@&;another=@"
+    "?query=" RESERVED;
   u = url_hdup(home, (url_t *)d); TEST_1(u);
+  TEST_S(u->url_user, "&=+$,;"); TEST_S(u->url_password, "&=+$,;");
   url_digest(hash1, sizeof(hash1), u, NULL);
   url_digest(hash2, sizeof(hash2), (url_t const *)d, NULL);
   TEST(memcmp(hash1, hash2, sizeof(hash1)), 0);
@@ -333,6 +332,13 @@ int test_sip(void)
   TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1:55:"), NULL);
   TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1:sip"), NULL);
 
+  u = url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar@127.0.0.1"); TEST_1(u);
+  TEST(u->url_type, url_sip);
+  TEST_S(u->url_user, "#**00**#;foo=/bar");
+
+  TEST_1(!url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar@#127.0.0.1"));
+  TEST_1(!url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar;127.0.0.1"));
+
   for (i = 32; i <= 256; i++) {
     char pu[512];
     char param[512];
@@ -397,6 +403,10 @@ int test_sip(void)
   TEST_S(u->url_params, "isfocus");
   TEST_1(!url_have_transport(u));
 
+  u = url_hdup(home, (void *)"sip:%22foo%22@172.21.55.55:5060");
+  TEST_1(u);
+  TEST_S(u->url_user, "%22foo%22");
+
   a = url_hdup(home, (void *)"sip:172.21.55.55:5060");
   b = url_hdup(home, (void *)"sip:172.21.55.55");
   TEST_1(a); TEST_1(b);
@@ -628,7 +638,7 @@ int test_modem(void)
 int test_file(void)
 {
   /* Test a url with path like file:/foo/bar  */
-  char fileurl[] = "file:/foo/bar";
+  char fileurl[] = "file:///foo/bar";
   url_t file[1] = { URL_INIT_AS(file) };
   su_home_t home[1] = { SU_HOME_INIT(home) };
   char *tst;
@@ -642,7 +652,9 @@ int test_file(void)
 
   TEST_1(tst = su_strdup(home, fileurl));
   TEST(url_d(url, tst), 0);
+  TEST_S(url->url_host, "");
   file->url_root = '/';
+  file->url_host = "";
   file->url_path = "foo/bar";
   TEST(url_cmp(file, url), 0);
   TEST(url->url_type, url_file);
@@ -827,6 +839,16 @@ int test_http(void)
   TEST_S(url->url_host, "some.host");
   TEST_S(url->url_headers, "query");
   TEST_S(url->url_params, NULL);
+
+  TEST_1(u = url_hdup(home, (void *)"http://[::1]/test;ing?here"));
+  TEST_S(u->url_host, "[::1]");
+  TEST_S(u->url_path, "test;ing");
+  TEST_S(u->url_headers, "here");
+
+  url_digest(hash1, sizeof(hash1), u, NULL);
+  url_digest(hash2, sizeof(hash2), (url_t *)"http://[::1]/test;ing?here", 
+            NULL);
+  TEST(memcmp(hash1, hash2, sizeof(hash1)), 0);
     
   su_home_deinit(home);
 
@@ -1026,7 +1048,11 @@ int test_print(void)
   END();
 }
 
-
+void usage(int exitcode)
+{
+  fprintf(stderr, "usage: %s [-v] [-a]\n", name);
+  exit(exitcode);
+}
 
 int main(int argc, char *argv[])
 {
@@ -1036,8 +1062,10 @@ int main(int argc, char *argv[])
   for (i = 1; argv[i]; i++) {
     if (strcmp(argv[i], "-v") == 0)
       tstflags |= tst_verbatim;
+    else if (strcmp(argv[i], "-a") == 0)
+      tstflags |= tst_abort;
     else
-      usage();
+      usage(1);
   }
 
   retval |= test_quote(); fflush(stdout);
index 9960f9f5b1676190b4c92e37722ceb898c52572d..909f364e8b59ad426e2eacb03371f9d022772036 100644 (file)
@@ -556,8 +556,8 @@ static
 int _url_d(url_t *url, char *s)
 {
   size_t n, p;
-  char *s0, rest_c, *host;
-  int net_path = 1;
+  char *s0, rest_c, *host, *user;
+  int have_authority = 1;
 
   memset(url, 0, sizeof(*url));
   
@@ -582,112 +582,131 @@ int _url_d(url_t *url, char *s)
 
     url->url_type = url_get_type(url->url_scheme, n);
 
-    net_path = !url_type_is_opaque(url->url_type);
+    have_authority = !url_type_is_opaque(url->url_type);
   }
   else {
     url->url_type = url_unknown;
   }
 
-  host = s;
+  user = NULL, host = s;
 
   if (url->url_type == url_sip || url->url_type == url_sips) {
-    /* SIP URL may have /; in user part */
-       n = strcspn(s, "@#");   /* Opaque part */\r
-       if ((p = strcspn(s, "#")) == n) {\r
-         n = strcspn(s, "@");\r
-      if (s[n] != '@')\r
-        n = 0;\r
-       }\r
+    /* SIP URL may have /;? in user part but no path */
+    /* user-unreserved  =  "&" / "=" / "+" / "$" / "," / ";" / "?" / "/" */
+    /* Some #*@#* phones include unescaped # there, too */
+    n = strcspn(s, "@/;?#");
+    p = strcspn(s + n, "@");
+    if (s[n + p] == '@') {
+      n += p;
+      user = s;
+      host = s + n + 1;
+    }
+
     n += strcspn(s + n, "/;?#");
   }
-  else if (url->url_type == url_wv) {
-    /* WV URL may have / in user part */
-    n = strcspn(s, "@#?;");
-    if (s[n] == '@')
-      n += strcspn(s + n, ";?#");
-  }
-  else if (url->url_type == url_invalid) {
-    n = strcspn(s, "#");
-  }
-  else if (net_path && host[0] == '/') {
-    url->url_root = host[0];   /* Absolute path */
+  else if (have_authority) {
+    if (url->url_type == url_wv) {
+      /* WV URL may have / in user part */
+      n = strcspn(s, "@#?;");
+      if (s[n] == '@') {
+       user = s;
+       host = s + n + 1;
+       n += strcspn(s + n, ";?#");
+      }
+    }
+    else if (host[0] == '/' && host[1] != '/') {
+      /* foo:/bar or /bar - no authority, just path */
+      url->url_root = '/';     /* Absolute path */
+      host = NULL, n = 0;
+    }
+    else {
+      if (host[0] == '/' && host[1] == '/') {
+       /* We have authority, / / foo or foo */
+       host += 2; s += 2, url->url_root = '/';
+       n = strcspn(s, "/?#@[]");
+      }
+      else 
+       n = strcspn(s, "@;/?#");
 
-    if (host[1] == '/') {      /* We have host-part */
-      host += 2; s += 2;
+      if (s[n] == '@')
+       user = host, host = user + n + 1;
+
+      n += strcspn(s + n, ";/?#");     /* Find path, query and/or fragment */
     }
-    else 
-      host = NULL;
-    n = strcspn(s, "/;?#");    /* Find path, query and/or fragment */
   }
-  else {
-    n = strcspn(s, "/;?#");    /* Find params, query and/or fragment */
+  else /* !have_authority */ {
+    user = host, host = NULL;
+    if (url->url_type != url_invalid)
+      n = strcspn(s, "/;?#");  /* Find params, query and/or fragment */
+    else
+      n = strcspn(s, "#");
   }
 
   rest_c = s[n]; s[n] = 0; s = rest_c ? s + n + 1 : NULL;
 
-  if (host) {
-    char *atsign, *port;
-
-    if (!net_path) {
-      url->url_user = host;
-      host = NULL;
+  if (user) {
+    if (host) host[-1] = '\0';
+    url->url_user = user;
+    if (url->url_type != url_unknown) {
+      n = strcspn(user, ":");
+      if (user[n]) {
+       user[n] = '\0';
+       url->url_password = user + n + 1;
+      }
     }
-    else if ((atsign = strchr(host, '@'))) {
-      char *user;
-
-      url->url_user = user = host;
+  }
 
-      if (atsign)
-       *atsign++ = '\0';
-      host = atsign;
+  if (host) {
+    url->url_host = host;
+    /* IPv6 (and in some cases, IPv4) addresses are quoted with [] */
+    if (host[0] == '[') {
+      n = strcspn(host, "]");
+      if (host[n] && (host[n + 1] == '\0' || host[n + 1] == ':'))
+       n++;
+      else
+       n = 0;
+    }
+    else {
+      n = strcspn(host, ":");
+    }
 
-      if (url->url_type != url_unknown) {
-       char *colon = strchr(user, ':');
-       if (colon)
-         *colon++ = '\0';
-       url->url_password = colon;
-      }
+    /* We allow empty host by default */
+    if (n == 0) switch (url->url_type) {
+    case url_sip:
+    case url_sips:
+    case url_im:
+    case url_pres:
+      return -1;
+    default:
+      break;
     }
+    
+    if (host[n] == ':') {
+      char *port = host + n + 1;
+      url->url_port = port;
+      switch (url->url_type) {
+      case url_any:
+      case url_sip:
+      case url_sips:
+      case url_http:
+      case url_https:
+      case url_ftp:
+      case url_file:
+      case url_rtsp:
+      case url_rtspu:
+       if (!url_canonize2(port, port, SIZE_MAX, RESERVED_MASK))
+         return -1;
 
-    if ((url->url_host = host)) {
-      /* IPv6 (and in some cases, IPv4) addresses are quoted with [] */
-      if (host[0] == '[') {
-       port = strchr(host, ']');
-       if (!port)
+       /* Check that port is really numeric or wildcard */
+       /* Port can be *digit, empty string or "*" */
+       while (*port >= '0' && *port <= '9')
+         port++;
+       
+       if (port != url->url_port ? port[0] != '\0' 
+           : (port[0] != '*' || port[1] != '\0'))
          return -1;
-       port = strchr(port + 1, ':');
-      }
-      else 
-       port = strchr(host, ':');
-
-      if (port) {
-       *port++ = '\0';
-       url->url_port = port;
-       switch (url->url_type) {
-       case url_any:
-       case url_sip:
-       case url_sips:
-       case url_http:
-       case url_https:
-       case url_ftp:
-       case url_file:
-       case url_rtsp:
-       case url_rtspu:
-         
-         if (!url_canonize2(port, port, SIZE_MAX, RESERVED_MASK))
-           return -1;
-
-         /* Check that port is really numeric or wildcard */
-         /* Port can be *digit, empty string or "*" */
-         while (*port >= '0' && *port <= '9')
-           port++;
-         if (port != url->url_port 
-             ? port[0] != '\0' 
-             : port[0] != '\0'
-             && (port[0] != '*' || port[1] != '\0'))
-           return -1;
-       }
       }
+      host[n] = 0;
     }
   }
 
@@ -742,12 +761,15 @@ int url_d(url_t *url, char *s)
     if (s && !url_canonize(s, s, SIZE_MAX, SIP_USER_UNRESERVED))
       return -1;
 
+    /* Having different charset in user and password does not make sense */
+    /* but that is how it is defined in RFC 3261 */
 #   define SIP_PASS_UNRESERVED "&=+$,"
     s = (char *)url->url_password;
     if (s && !url_canonize(s, s, SIZE_MAX, SIP_PASS_UNRESERVED))
       return -1;
 
-  } else {
+  }
+  else {
 
 #   define USER_UNRESERVED "&=+$,;"
     s = (char *)url->url_user;
@@ -943,7 +965,7 @@ issize_t url_e(char buffer[], isize_t n, url_t const *url)
 }
 
 
-/** Calculate the lengh of URL when encoded. 
+/** Calculate the length of URL when encoded. 
  *
  */
 isize_t url_len(url_t const * url)
@@ -1588,7 +1610,7 @@ int url_cmp(url_t const *a, url_t const *b)
 static
 int url_tel_cmp_numbers(char const *A, char const *B)
 {
-  char a, b;
+  short a, b;
   int rv;
 
   while (*A && *B) {
@@ -1889,8 +1911,8 @@ void canon_update(su_md5_t *md5, char const *s, size_t n, char const *allow)
 static
 void url_string_update(su_md5_t *md5, char const *s)
 {
-  size_t n;
-  int hostpart = 1;
+  size_t n, p;
+  int have_authority = 1;
   enum url_type_e type = url_any;
   char const *at, *colon;
   char schema[48];
@@ -1910,7 +1932,7 @@ void url_string_update(su_md5_t *md5, char const *s)
     type = url_get_type(schema, at - schema);
     su_md5_iupdate(md5, schema, at - schema);
 
-    hostpart = !url_type_is_opaque(type);
+    have_authority = !url_type_is_opaque(type);
     s += n + 1;
   }
   else {
@@ -1918,62 +1940,71 @@ void url_string_update(su_md5_t *md5, char const *s)
   }
   
   if (type == url_sip || type == url_sips) {
-    n = strcspn(s, "@#");      /* Opaque part */
-    if (s[n] != '@')
-      n = 0;
+    /* SIP URL may have /;? in user part but no path */
+    /* user-unreserved  =  "&" / "=" / "+" / "$" / "," / ";" / "?" / "/" */
+    /* Some #*@#* phones include unescaped # there, too */
+    n = strcspn(s, "@/;?#");
+    p = strcspn(s + n, "@");
+    if (s[n + p] == '@') {
+      n += p;
+      /* Ignore password in hash */
+      colon = memchr(s, ':', n);
+      p = colon ? (size_t)(colon - s) : n;
+      canon_update(md5, s, p, SIP_USER_UNRESERVED);
+      s += n + 1; n = 0;
+    }
+    else
+      su_md5_iupdate(md5, "", 1);      /* user */
     n += strcspn(s + n, "/;?#");
   }
-  else if (type == url_wv) {    /* WV URL may have / in user part */
-    n = strcspn(s, "@#?;");
-    if (s[n] == '@')
-      n += strcspn(s + n, ";?#");
-  }
-  else if (!hostpart || s[0] != '/') {
-    n = strcspn(s, "/;?#");    /* Opaque part */
-  }
-  else if (s[1] == '/') {
-    s += 2;
-    n = strcspn(s, "/;?#");    /* Until host, path, query or fragment */
-  }
-  else {
-    /* foo:/bar */
-    su_md5_update(md5, "\0\0", 2); /* user, host */
-    su_md5_striupdate(md5, url_port_default(type));
-    return;
+  else if (have_authority) {
+    if (type == url_wv) {    /* WV URL may have / in user part */
+      n = strcspn(s, "@;?#");
+    }
+    else if (type != url_wv && s[0] == '/' && s[1] != '/') {
+      /* foo:/bar */
+      su_md5_update(md5, "\0\0", 2); /* user, host */
+      su_md5_striupdate(md5, url_port_default(type));
+      return;
+    }
+    else if (s[0] == '/' && s[1] == '/') {
+      /* We have authority, / / foo or foo */
+      s += 2;
+      n = strcspn(s, "/?#@[]");
+    }
+    else 
+      n = strcspn(s, "@;/?#");
+
+    if (s[n] == '@') {
+      /* Ignore password in hash */
+      colon = type != url_unknown ? memchr(s, ':', n) : NULL;
+      p = colon ? (size_t)(colon - s) : n;
+      canon_update(md5, s, p, SIP_USER_UNRESERVED);
+      s += n + 1;
+      n = strcspn(s, "/;?#");  /* Until path, query or fragment */
+    }
+    else {
+      su_md5_iupdate(md5, "", 1);      /* user */
+      n += strcspn(s + n, "/;?#");     /* Until path, query or fragment */
+    }
   }
-  
-  if (!hostpart) {
-    char const *colon = memchr(s, ':', n);
+  else /* if (!have_authority) */ {
+    n = strcspn(s, ":/;?#");   /* Until pass, path, query or fragment */
     
-    if (colon) n = colon - s;
     canon_update(md5, s, n, ""); /* user */
     su_md5_update(md5, "\0", 1); /* host, no port */
     su_md5_striupdate(md5, url_port_default(type));
     return;
   }
 
-  at = memchr(s, '@', n);
-
-  if (at) {
-    char const *allow = 
-      (type == url_sip || type == url_sips) 
-      ? SIP_USER_UNRESERVED
-      : USER_UNRESERVED;
-
-    colon = type == url_unknown ? NULL : memchr(s, ':', at - s);
-
-    /* Updated only user part */
-    if (colon)
-      canon_update(md5, s, colon - s, allow);
-    else
-      canon_update(md5, s, at - s, allow);
-    n = n - (at + 1 - s);
-    s = at + 1;
+  if (n > 0 && s[0] == '[') {  /* IPv6reference */
+    colon = memchr(s, ']', n);
+    if (colon == NULL || ++colon == s + n || *colon != ':')
+      colon = NULL;
   }
-  else
-    su_md5_iupdate(md5, "", 1);        /* user */
+  else 
+    colon = memchr(s, ':', n);
 
-  colon = memchr(s, ':', n);   /* XXX - IPv6! */
   if (colon) {
     canon_update(md5, s, colon - s, ""); /* host */
     canon_update(md5, colon + 1, (s + n) - (colon + 1), "");
index 87eeda613316867442a570a93c023ec5266144d6..1de0bc38cdf0ed30a65c8a0083f42def7802847c 100644 (file)
@@ -113,7 +113,7 @@ AC_CACHE_CHECK([for maximum warnings compiler flag],
   *gcc*) ac_cv_cwflag=-Wall;;
   *)   case "$host" in
     *irix*)    ac_cv_cwflag=-fullwarn ;;
-    *solaris*)  ac_cv_cwflag="-erroff=%none,E_END_OF_LOOP_CODE_NOT_REACHED -xCC"
+    *solaris*)  ac_cv_cwflag="-erroff=%none,E_END_OF_LOOP_CODE_NOT_REACHED,E_BAD_PTR_INT_COMBINATION -errtags"
                ;;
     *)         ac_cv_cwflag=;;
                esac 
@@ -127,7 +127,7 @@ AC_ARG_VAR([SOFIA_CFLAGS], [CFLAGS not used during configure])
 # GCoverage
 #
 AC_ARG_ENABLE(coverage,
-[  --enable-coverage       compile test-coverage (disabled)],
+[  --enable-coverage       compile test-coverage [[disabled]]],
  , enable_coverage=no)
 
 if test X$enable_coverage != Xno ; then
@@ -341,7 +341,7 @@ dnl ======================================================================
 AC_DEFUN([SAC_ENABLE_NDEBUG],[
 AC_REQUIRE([SAC_TOOL_CC])
 AC_ARG_ENABLE(ndebug,
-[  --enable-ndebug             compile with NDEBUG (disabled)],
+[  --enable-ndebug         compile with NDEBUG [[disabled]]],
  , enable_ndebug=no)
 AM_CONDITIONAL(NDEBUG, test x$enable_ndebug = yes)
 ])
@@ -351,7 +351,8 @@ dnl SAC_ENABLE_EXPENSIVE_CHECKS
 dnl ======================================================================
 AC_DEFUN([SAC_ENABLE_EXPENSIVE_CHECKS],[
 AC_ARG_ENABLE(expensive-checks,
-[  --enable-expensive-checks   run also expensive checks (disabled)],
+[  --enable-expensive-checks
+                          run also expensive checks [[disabled]]],
  , enable_expensive_checks=no)
 if test $enable_expensive_checks != no; then
 AC_SUBST([TESTS_ENVIRONMENT], [EXPENSIVE_CHECKS=1])
index 6833d354301c98795c83bfd421d61f9720943204..3abbe7880454f0ca759af624e121646639a7724b 100644 (file)
@@ -4,32 +4,45 @@ dnl ======================================================================
 AC_DEFUN([SAC_OPENSSL], [
 
 AC_ARG_WITH(openssl,
-[  --with-openssl          use OpenSSL (enabled)],, with_openssl=yes)
+[  --with-openssl          use OpenSSL [[enabled]]],, with_openssl=pkg-config)
 
 dnl SOSXXX:SAC_ASSERT_DEF([openssl libraries])
 
-if test "$with_openssl" != no  ;then
-  AC_CHECK_HEADERS(openssl/tls1.h, [
 
-    HAVE_OPENSSL=1 HAVE_TLS=1
-
-    AC_CHECK_LIB(crypto, BIO_new,, 
-       HAVE_OPENSSL=0
-       AC_MSG_WARN(OpenSSL crypto library was not found))
-
-    AC_CHECK_LIB(ssl, TLSv1_method,, 
-       HAVE_TLS=0
-       AC_MSG_WARN(OpenSSL protocol library was not found))
-
-    if test x$HAVE_OPENSSL = x1; then
-      AC_DEFINE([HAVE_OPENSSL], 1, [Define to 1 if you have OpenSSL])
-    fi
-
-    if test x$HAVE_TLS = x1; then
-      AC_DEFINE([HAVE_TLS], 1, [Define to 1 if you have TLS])
-    fi
-  ],
-  AC_MSG_WARN(OpenSSL include files were not found))
+if test "$with_openssl" = no  ;then
+  : # No openssl
+else
+
+  if test "$with_openssl" = "pkg-config" ; then 
+    PKG_CHECK_MODULES(openssl, openssl,
+       [HAVE_TLS=1 HAVE_OPENSSL=1 LIBS="$openssl_LIBS $LIBS"],
+       [HAVE_OPENSSL=0])
+  fi
+
+  if test $HAVE_OPENSSL = 1 ; then
+     AC_DEFINE([HAVE_LIBCRYPTO], 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
+     AC_DEFINE([HAVE_LIBSSL], 1, [Define to 1 if you have the `ssl' library (-lssl).])
+  else
+    AC_CHECK_HEADERS([openssl/tls1.h], [
+      HAVE_OPENSSL=1 HAVE_TLS=1
+
+      AC_CHECK_LIB(crypto, BIO_new,, 
+       HAVE_OPENSSL=0
+       AC_MSG_WARN(OpenSSL crypto library was not found))
+
+      AC_CHECK_LIB(ssl, TLSv1_method,, 
+       HAVE_TLS=0
+       AC_MSG_WARN(OpenSSL protocol library was not found))
+     ],[AC_MSG_WARN(OpenSSL include files were not found)])
+  fi
+  
+  if test x$HAVE_OPENSSL = x1; then
+     AC_DEFINE([HAVE_OPENSSL], 1, [Define to 1 if you have OpenSSL])
+  fi
+
+  if test x$HAVE_TLS = x1; then
+    AC_DEFINE([HAVE_TLS], 1, [Define to 1 if you have TLS])
+  fi
 fi
 
 AM_CONDITIONAL(HAVE_TLS, test x$HAVE_TLS = x1)
index 7e78fa6704bffa20d98a43637b4bcc7256079214..823a6aed6edf946b882939f3ab49527f2cb94488 100644 (file)
@@ -13,7 +13,7 @@ dnl SAC_WITH_RT - check for POSIX realtime library
 dnl ======================================================================
 AC_DEFUN([SAC_WITH_RT],[
 AC_ARG_WITH(rt,  
-[  --with-rt               use POSIX realtime library (used by default)])
+[  --with-rt               use POSIX realtime library [[used by default]]])
 ])
 
 dnl ======================================================================
index 5cde2c149ae3835eb5c9ba7f4fc560ca24f2f23e..f6eb7a6352b8ebda4ba2b71fb81bfaa3311af0fa 100644 (file)
@@ -46,6 +46,14 @@ else
   SAC_SU_DEFINE([SU_HAVE_PTHREADS], 1, [Sofia SU uses pthreads])
 fi
 
+AC_ARG_ENABLE(experimental,
+[  --enable-experimental   enable experimental features [[disabled]]],
+ , enable_experimental=no)
+
+if test $enable_experimental = yes ; then
+  SAC_SU_DEFINE([SU_HAVE_EXPERIMENTAL], 1, [Enable experimental features])
+fi
+
 dnl ===========================================================================
 dnl Checks for typedefs, headers, structures, and compiler characteristics.
 dnl ===========================================================================
@@ -69,9 +77,10 @@ case "$ac_cv_c_inline" in
                Define to 1 if you have inline functions.
        ])dnl
   ;;
-  no)  SAC_SU_DEFINE(su_inline, static)dnl
-       SAC_SU_DEFINE(SU_INLINE)dnl
-       SAC_SU_DEFINE(SU_HAVE_INLINE)dnl
+  no | "" )
+       SAC_SU_DEFINE(su_inline, static)dnl
+       SAC_SU_DEFINE(SU_INLINE, /*inline*/)dnl
+       SAC_SU_DEFINE(SU_HAVE_INLINE, 0)dnl
   ;;
   *)   SAC_SU_DEFINE_UNQUOTED(su_inline, static $ac_cv_c_inline)dnl
        SAC_SU_DEFINE_UNQUOTED(SU_INLINE, $ac_cv_c_inline)dnl
@@ -80,7 +89,7 @@ case "$ac_cv_c_inline" in
 esac
 
 AC_ARG_ENABLE(size-compat,
-[  --disable-size-compat            use compatibility size_t types (enabled)],
+[  --disable-size-compat   use compatibility size_t types [[enabled]]],
  , enable_size_compat=yes)
 
 if test X$enable_size_compat != Xyes; then
@@ -104,7 +113,8 @@ dnl ======================================================================
 dnl SAC_ENABLE_COREFOUNDATION
 dnl ======================================================================
 AC_ARG_ENABLE(corefoundation,
-[  --enable-corefoundation     compile with OSX COREFOUNDATION (disabled)],
+[  --enable-corefoundation 
+                          compile with OSX COREFOUNDATION [[disabled]]],
  , enable_corefoundation=no)
 AM_CONDITIONAL(COREFOUNDATION, test $enable_corefoundation = yes)
 
@@ -119,21 +129,17 @@ fi
 ### Test if we have stack suitable for handling tags directly
 ###
 
-test -z "$ac_cv_tagstack" && 
-case "$target" in 
-i?86-*-* ) ac_cv_tagstack=yes ;;
-esac
-
 AC_CACHE_CHECK([for stack suitable for tags],[ac_cv_tagstack],[
 ac_cv_tagstack=no
 
-AC_RUN_IFELSE([
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #if HAVE_INTTYPES_H
 #include <inttypes.h>
 #endif
 #if HAVE_STDINT_H
 #include <stdint.h>
 #endif
+
 #include <stdarg.h>
 
 typedef void *tp;
@@ -169,7 +175,12 @@ int main(int avc, char **av)
               (tv)1, (tv)2, (tv)3, (tv)4, (tv)5,
               (tv)6, (tv)7, (tv)8, (tv)9, (tv)10);
 }
-],[ac_cv_tagstack=yes],[ac_cv_tagstack=no],[ac_cv_tagstack=no])])
+]])],[ac_cv_tagstack=yes],[ac_cv_tagstack=no],[
+case "$target" in 
+i?86-*-* ) ac_cv_tagstack=yes ;;
+* ) ac_cv_tagstack=no ;;
+esac
+])])
 
 if test $ac_cv_tagstack = yes ; then
 SAC_SU_DEFINE([SU_HAVE_TAGSTACK], 1, [
@@ -227,9 +238,10 @@ AC_CHECK_HEADERS([winsock2.h], [
      GetSystemTimeAsFileTime().])
 ],[
 dnl no winsock2
+
 SAC_SU_DEFINE([SU_HAVE_BSDSOCK], 1, [Define to 1 if you have BSD socket interface])
 AC_CHECK_HEADERS([sys/socket.h sys/ioctl.h sys/filio.h sys/sockio.h \
-                 sys/select.h])
+                 sys/select.h sys/epoll.h sys/devpoll.h])
 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h \
                   net/if.h net/if_types.h ifaddr.h netpacket/packet.h],,,
                [
@@ -429,9 +441,12 @@ AC_SEARCH_LIBS(getipnodebyname, xnet socket nsl)
 AC_SEARCH_LIBS(gethostbyname, xnet nsl)
 AC_SEARCH_LIBS(getaddrinfo, xnet socket nsl)
 
-AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock alarm \
+AC_FUNC_ALLOCA
+
+AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock \
                 socketpair gethostname gethostbyname getipnodebyname \
-                poll epoll_create select if_nameindex \
+                poll epoll_create kqueue select if_nameindex \
+               signal alarm \
                getaddrinfo getnameinfo freeaddrinfo gai_strerror getifaddrs \
                 getline getdelim getpass])
 # getline getdelim getpass are _GNU_SOURCE stuff
@@ -440,7 +455,8 @@ if test $ac_cv_func_poll = yes ; then
   SAC_SU_DEFINE([SU_HAVE_POLL], 1, [Define to 1 if you have poll().])
 fi
 
-if test $ac_cv_func_epoll_create = yes ; then
+if test $ac_cv_func_epoll_create = yes && test $ac_cv_header_sys_epoll_h = yes
+then
   AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have epoll interface.])
 fi
 
@@ -455,8 +471,32 @@ if test "${with_rt}" != no; then
 fi
 
 SAC_REPLACE_FUNCS([memmem memccpy memspn memcspn strcasestr strtoull \
-                  inet_ntop inet_pton])
+                  inet_ntop inet_pton poll])
+
+if test $ac_cv_func_signal = yes ; then
+AC_CHECK_DECL([SIGPIPE], [
+AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
+#include <signal.h>
+])
+dnl add SIGHUP SIGQUIT if needed
+fi
 
+# ===========================================================================
+# Check how to implement su_port
+# ===========================================================================
+
+AC_ARG_ENABLE(poll-port,
+[  --disable-poll-port     disable su_poll_port [[enabled]]
+                          Use this option in systems emulating poll with select],
+ , enable_poll_port=maybe)
+
+if test $enable_poll_port = maybe ; then
+  if test $ac_cv_func_poll = yes ; then
+    AC_DEFINE([HAVE_POLL_PORT], 1, [Define to 1 if you use poll in su_port.])
+  fi
+elif test $enable_poll_port = yes ; then
+    AC_DEFINE([HAVE_POLL_PORT], 1, [Define to 1 if you use poll in su_port.])
+fi
 
 # ===========================================================================
 # Check pthread_rwlock_unlock()
index ac5b0cd60bd0013d8c5e9ba1689d7df689db2904..0153a43cc825207bdaa0c0f3003da1ab4c5f6575 100644 (file)
@@ -4,7 +4,7 @@ dnl ======================================================================
 AC_DEFUN([SAC_TPORT], [
 
 AC_ARG_WITH(sigcomp,
-[  --with-sigcomp=dir      use Sofia SigComp package (not used by default)],,
+[  --with-sigcomp=dir      use Sofia SigComp package [[not used]]],,
        with_sigcomp=no)
 
 if test -n "${with_sigcomp}" && test "${with_sigcomp}" != no ; then
@@ -27,10 +27,12 @@ fi
 AC_SYS_IP_RECVERR
 AC_SYS_IPV6_RECVERR
 
-AC_CHECK_HEADERS(netinet/tcp.h netinet/sctp.h)
+AC_CHECK_HEADERS([netinet/tcp.h netinet/sctp.h],[],[],[
+#include <sys/socket.h>
+])
 
-AC_ARG_WITH(sctp,
-[  --enable-sctp          use LK-SCTP (not used by default)],,
+AC_ARG_ENABLE(sctp,
+[  --enable-sctp           use SCTP [[disabled]]],,
  enable_sigcomp=no)
 
 if test x$enable_sctp = xyes; then
index 9ba9ff19a87429b9f5eb90ea2d1a757e2582b77b..01c14c023576d1e53be75b87f8ffa011de4b3e3d 100644 (file)
@@ -12,15 +12,15 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 BuildRequires: pkgconfig
 
-%{!?bcond_with:%define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}}
-%{!?bcond_without:%define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}}
+%define opt_with() %{expand:%%global with_%{1} %%{?_with_%{1}:1}%%{?!_with_%{1}:0}}
+%define opt_without() %{expand:%%global with_%{1} %%{!?_without_%{1}:1}%%{?_without_%{1}:0}}
 
 # Options: 
-%bcond_with doxygen    - Generate documents using doxygen and dot
-%bcond_with check      - Run tests
-%bcond_with openssl    - Always use OpenSSL (TLS)
-%bcond_with glib       - Always use glib-2.0 (>= 2.2)
-%bcond_with sctp       - Include SCTP transport
+%opt_with doxygen      - Generate documents using doxygen and dot
+%opt_with check                - Run tests
+%opt_with openssl      - Always use OpenSSL (TLS)
+%opt_with glib         - Always use glib-2.0 (>= 2.2)
+%opt_with sctp         - Include SCTP transport
 
 %define have_doxygen %{?_with_doxygen:1}%{!?_with_doxygen:0}
 %define have_openssl %(%{?!_with_openssl:pkg-config 'openssl >= 0.9.7'&&}echo 1||echo 0)
@@ -49,7 +49,7 @@ options="$options --with-pic --enable-shared --disable-static"
 %if !%{have_glib}
 options="$options --without-glib"
 %endif
-%if %{with sctp}
+%if %{with_sctp}
 options="$options --enable-sctp"
 %endif
 
@@ -62,7 +62,7 @@ make doxygen
 
 # XXX comment next line to build with non-check aware rpmbuild.
 %check
-%if %{with check}
+%if %{with_check}
 make check
 %endif
 
@@ -126,7 +126,7 @@ Requires:   pkgconfig
 Development package for Sofia SIP UA library. This package includes 
 static libraries and include files.
 
-%if %{without doxygen}
+%if !%{with_doxygen}
 The reference documentation for Sofia SIP UA library is available at 
 <http://sofia-sip.sourceforge.net/development.html>
 %endif
diff --git a/libs/sofia-sip/rules/recursive.am b/libs/sofia-sip/rules/recursive.am
new file mode 100644 (file)
index 0000000..2a68877
--- /dev/null
@@ -0,0 +1,52 @@
+# Recursive Makefile targets
+# --------------------------
+
+if ENABLE_COVERAGE
+COVERAGE_RECURSIVE = coverage-recursive
+coverage: $(COVERAGE_RECURSIVE)
+endif
+
+all-recursive: built-sources-recursive
+built-sources: built-sources-recursive 
+clean-built-sources: clean-built-sources-recursive
+valcheck: valcheck-recursive
+
+SOFIA_RECURSIVE = \
+       valcheck-recursive \
+       $(COVERAGE_RECURSIVE)
+
+SOFIA_DIST_RECURSIVE = \
+       built-sources-recursive \
+       clean-built-sources-recursive
+
+$(SOFIA_RECURSIVE):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
+         || eval $$failcom; \
+       done; \
+       test -z "$$fail"
+
+$(SOFIA_DIST_RECURSIVE):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
+         || eval $$failcom; \
+       done; \
+       test -z "$$fail"
diff --git a/libs/sofia-sip/rules/sofia.am b/libs/sofia-sip/rules/sofia.am
new file mode 100644 (file)
index 0000000..059dfa4
--- /dev/null
@@ -0,0 +1,62 @@
+# common Makefile targets for libsofia-sip-ua(-glib) modules
+# ----------------------------------------------------------
+
+AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) $(openssl_CFLAGS)
+
+# Use with --enable-ndebug
+if NDEBUG
+AM_CFLAGS += -DNDEBUG
+endif
+
+built-sources: $(BUILT_SOURCES)
+
+DISTCLEANFILES = $(BUILT_SOURCES)
+
+clean-built-sources:
+       -rm -rf $(BUILT_SOURCES) $(BUILT_SOURCES:%=$(srcdir)/%)
+
+# rules for building tag files
+
+TAG_AWK=$(top_srcdir)/libsofia-sip-ua/su/tag_dll.awk
+
+*_tag_ref.c: $(TAG_AWK)
+
+SUFFIXES = _tag_ref.c _tag.c
+
+_tag.c_tag_ref.c:
+       $(AWK) -f $(TAG_AWK) NODLL=1 $(TAG_DLL_FLAGS) REF=$@ $<
+
+if ENABLE_COVERAGE
+coverage:
+       @$(top_srcdir)/scripts/coverage $(COVERAGE_FLAGS) $(COVERAGE_INPUT)
+endif
+
+../bnf/libbnf.la ../http/libhttp.la ../ipt/libipt.la ../iptsec/libiptsec.la \
+ ../msg/libmsg.la ../nea/libnea.la ../nta/libnta.la ../nth/libnth.la \
+ ../nua/libnua.la ../sdp/libsdp.la ../sip/libsip.la ../soa/libsoa.la \
+ ../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
+ ../tport/libtport.la ../url/liburl.la:
+       $(MAKE) -C $(@D) $(@F)
+
+INTERNAL_INCLUDES = \
+       -I$(srcdir)/../features -I../features \
+       -I$(srcdir)/../ipt -I../ipt \
+       -I$(srcdir)/../iptsec -I../iptsec \
+       -I$(srcdir)/../bnf -I../bnf \
+       -I$(srcdir)/../http -I../http \
+       -I$(srcdir)/../msg -I../msg \
+       -I$(srcdir)/../nth -I../nth \
+       -I$(srcdir)/../nta -I../nta \
+       -I$(srcdir)/../nea -I../nea \
+       -I$(srcdir)/../nua -I../nua \
+       -I$(srcdir)/../soa -I../soa \
+       -I$(srcdir)/../sdp -I../sdp \
+       -I$(srcdir)/../sip -I../sip \
+       -I$(srcdir)/../soa -I../soa \
+       -I$(srcdir)/../sresolv -I../sresolv \
+       -I$(srcdir)/../tport -I../tport \
+       -I$(srcdir)/../stun -I../stun \
+       -I$(srcdir)/../url -I../url \
+       -I$(srcdir)/../su -I../su
+
+include $(top_srcdir)/rules/valcheck.am
\ No newline at end of file
diff --git a/libs/sofia-sip/rules/valcheck.am b/libs/sofia-sip/rules/valcheck.am
new file mode 100644 (file)
index 0000000..f9c6900
--- /dev/null
@@ -0,0 +1,114 @@
+# 
+# run tests with valgrind
+#
+
+# Copyright (C) 2007 Nokia Corporation.
+
+# 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 file contains free software from Makefile.in by the Free Software
+# Foundation:
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+VALGRIND = valgrind 
+
+VALGRINDFLAGS = --tool=memcheck
+
+valcheck: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) valcheck-am
+
+valcheck-am: all-am
+       $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+       $(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
+
+# Run tests with valgrind in 
+valcheck-TESTS:        $(TESTS)
+       @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+       srcdir=$(srcdir); export srcdir; \
+       list='$(TESTS)'; \
+       if test -n "$$list"; then \
+         for tst in $$list; do \
+           if test -f ./$$tst; then dir=./; \
+           elif test -f $$tst; then dir=; \
+           else dir="$(srcdir)/"; fi; \
+           if case $$tst in \
+            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
+                 $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
+           *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
+              $${dir}$$tst ;; \
+           esac ; then \
+             all=`expr $$all + 1`; \
+             case " $(XFAIL_TESTS) " in \
+             *" $$tst "*) \
+               xpass=`expr $$xpass + 1`; \
+               failed=`expr $$failed + 1`; \
+               echo "XPASS: $$tst"; \
+             ;; \
+             *) \
+               echo "PASS: $$tst"; \
+             ;; \
+             esac; \
+           elif test $$? -ne 77; then \
+             all=`expr $$all + 1`; \
+             case " $(XFAIL_TESTS) " in \
+             *" $$tst "*) \
+               xfail=`expr $$xfail + 1`; \
+               echo "XFAIL: $$tst"; \
+             ;; \
+             *) \
+               failed=`expr $$failed + 1`; \
+               echo "FAIL: $$tst"; \
+             ;; \
+             esac; \
+           else \
+             skip=`expr $$skip + 1`; \
+             echo "SKIP: $$tst"; \
+           fi; \
+         done; \
+         if test "$$failed" -eq 0; then \
+           if test "$$xfail" -eq 0; then \
+             banner="All $$all tests passed"; \
+           else \
+             banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+           fi; \
+         else \
+           if test "$$xpass" -eq 0; then \
+             banner="$$failed of $$all tests failed"; \
+           else \
+             banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+           fi; \
+         fi; \
+         dashes="$$banner"; \
+         skipped=""; \
+         if test "$$skip" -ne 0; then \
+           skipped="($$skip tests were not run)"; \
+           test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+             dashes="$$skipped"; \
+         fi; \
+         report=""; \
+         if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+           report="Please report to $(PACKAGE_BUGREPORT)"; \
+           test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+             dashes="$$report"; \
+         fi; \
+         dashes=`echo "$$dashes" | sed s/./=/g`; \
+         echo "$$dashes"; \
+         echo "$$banner"; \
+         test -z "$$skipped" || echo "$$skipped"; \
+         test -z "$$report" || echo "$$report"; \
+         echo "$$dashes"; \
+         test "$$failed" -eq 0; \
+       else :; fi
index 911bbfb9f192f3981625640a88a57e95fda1b1c0..219ea4e83e135bd45445986e64dd3ce2fda67e91 100644 (file)
@@ -331,7 +331,7 @@ int main(int argc, char *argv[])
   return context->c_retval;
 }
 
-/** Handle responses to registration request */
+/** Handle responses to OPTIONS request */
 static
 int response_to_options(context_t *context,
                        nta_outgoing_t *oreq,
@@ -355,12 +355,16 @@ int response_to_options(context_t *context,
            sip_is_content_length(h))
          continue;
       }
-      if (h->sh_class->hc_name) {
-       snprintf(hname, sizeof hname, "%s: %%s\n", h->sh_class->hc_name);
-       sl_header_print(stdout, hname, h); 
+
+      if (h->sh_class->hc_name == NULL) {
+       sl_header_print(stdout, NULL, h);
+      } 
+      else if (h->sh_class->hc_name[0] == '\0') {
+       sl_header_print(stdout, "%s\n", h); 
       }
       else {
-       sl_header_print(stdout, NULL, h); 
+       snprintf(hname, sizeof hname, "%s: %%s\n", h->sh_class->hc_name);
+       sl_header_print(stdout, hname, h); 
       }
     }
   }
index fa6d7a5a90f623d80fa8203df23ccfb9ced6a23a..89947af6a6f76c9ab3a67fb119f9fb8c647423e0 100644 (file)
@@ -44,6 +44,31 @@ EXTRA_DIST = SofiaSIP.dsw \
        autogen.cmd build_sources.cmd version_files.cmd version.awk \
        install.cmd check.cmd
 
+# VC2005 Project files
+EXTRA_DIST += SofiaSIP.sln \
+    libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj \
+    libsofia-sip-ua/libsofia_sip_ua.vcproj \
+    tests/test_htable/test_htable.vcproj \
+    tests/test_memmem/test_memmem.vcproj \
+    tests/test_nta/test_nta.vcproj \
+    tests/test_nua/test_nua.vcproj \
+    tests/test_su/test_su.vcproj \
+    tests/test_tport/test_tport.vcproj \
+    tests/torture_rbtree/torture_rbtree.vcproj \
+    tests/torture_su/torture_su.vcproj \
+    tests/torture_su_alloc/torture_su_alloc.vcproj \
+    tests/torture_su_bm/torture_su_bm.vcproj \
+    tests/torture_su_port/torture_su_port.vcproj \
+    tests/torture_su_root/torture_su_root.vcproj \
+    tests/torture_su_tag/torture_su_tag.vcproj \
+    tests/torture_su_time/torture_su_time.vcproj \
+    tests/torture_su_timer/torture_su_timer.vcproj \
+    utils/localinfo/localinfo.vcproj \
+    utils/sip_dig/sip_dig.vcproj \
+    utils/sip_options/sip_options.vcproj \
+    utils/sip_options_static/sip_options_static.vcproj \
+    utils/stunc/stunc.vcproj
+
 PTHREAD_DIST = \
        pthread/ChangeLog \
        pthread/md5.sum.txt \
index cab4c75b28d05c2994df208a11e077d435b090f3..180e2d299adcc56a970b2c42b33a864ea9c302a8 100644 (file)
@@ -252,21 +252,6 @@ Package=<4>
 \r
 ###############################################################################\r
 \r
-Project: "torture_su_port"=".\tests\torture_su_port\torture_su_port.dsp" - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-    Begin Project Dependency\r
-    Project_Dep_Name libsofia_sip_ua_static\r
-    End Project Dependency\r
-}}}\r
-\r
-###############################################################################\r
-\r
 Project: "torture_su_root"=".\tests\torture_su_root\torture_su_root.dsp" - Package Owner=<4>\r
 \r
 Package=<5>\r
diff --git a/libs/sofia-sip/win32/SofiaSIP.sln b/libs/sofia-sip/win32/SofiaSIP.sln
new file mode 100644 (file)
index 0000000..bab60a6
--- /dev/null
@@ -0,0 +1,197 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual C++ Express 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsofia_sip_ua", "libsofia-sip-ua\libsofia_sip_ua.vcproj", "{0D85D39A-C7FB-4C52-A541-73665FB478E6}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsofia_sip_ua_static", "libsofia-sip-ua-static\libsofia_sip_ua_static.vcproj", "{5A6E80AB-5335-4F14-9030-D4DA3A13109B}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "localinfo", "utils\localinfo\localinfo.vcproj", "{CD3CE1A9-BABD-43F1-9CEB-6F047AEE2FC5}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sip_dig", "utils\sip_dig\sip_dig.vcproj", "{627985F5-C1A1-406F-8184-464B34E36F1B}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sip_options", "utils\sip_options\sip_options.vcproj", "{FDBA680D-D560-49CC-B72F-EC9B3CA52B9C}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sip_options_static", "utils\sip_options_static\sip_options_static.vcproj", "{4E9B7192-4242-47A9-B449-E3E18F8B4216}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B} = {5A6E80AB-5335-4F14-9030-D4DA3A13109B}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stunc", "utils\stunc\stunc.vcproj", "{0AE740B8-54A3-486F-AA84-F19B592B29D3}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_htable", "tests\test_htable\test_htable.vcproj", "{41C72ECB-BF92-4C98-9B57-89BFCE1FA772}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_memmem", "tests\test_memmem\test_memmem.vcproj", "{B87FBA69-5616-48E5-8A3A-46CB9B95F3F8}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B} = {5A6E80AB-5335-4F14-9030-D4DA3A13109B}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_nta", "tests\test_nta\test_nta.vcproj", "{C9AEEF0E-D3F6-4346-A9CF-5B775CEE4EC8}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_nua", "tests\test_nua\test_nua.vcproj", "{2919D919-41FC-4138-8243-676F0EDFCCCB}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_su", "tests\test_su\test_su.vcproj", "{9E207F42-049E-46E3-ACE5-1A5AFF8E7A05}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_tport", "tests\test_tport\test_tport.vcproj", "{D02963A2-AED0-4825-82D3-0F9DC1475AF3}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_rbtree", "tests\torture_rbtree\torture_rbtree.vcproj", "{74AF1B59-64D3-4D22-8F30-98B2868123C8}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su", "tests\torture_su\torture_su.vcproj", "{A4C22592-4EBA-407C-A739-9AFF43141140}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su_alloc", "tests\torture_su_alloc\torture_su_alloc.vcproj", "{2B20EC13-8E2E-45F0-A865-E52FC35638D6}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su_bm", "tests\torture_su_bm\torture_su_bm.vcproj", "{44EB96E2-6863-4D5D-853A-1288E95261E6}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B} = {5A6E80AB-5335-4F14-9030-D4DA3A13109B}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su_root", "tests\torture_su_root\torture_su_root.vcproj", "{62F73F70-88D5-4FC9-B166-4CFF4BB9E61B}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su_tag", "tests\torture_su_tag\torture_su_tag.vcproj", "{2560F904-8A51-42D5-A1F9-411B452F899D}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su_time", "tests\torture_su_time\torture_su_time.vcproj", "{6D10B051-BD5B-486D-AE4E-02F70DDE59AA}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B} = {5A6E80AB-5335-4F14-9030-D4DA3A13109B}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "torture_su_timer", "tests\torture_su_timer\torture_su_timer.vcproj", "{01B062BA-DF7B-4F0C-967A-6F485D2F7C44}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6} = {0D85D39A-C7FB-4C52-A541-73665FB478E6}\r
+       EndProjectSection\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6}.Debug|Win32.Build.0 = Debug|Win32\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6}.Release|Win32.ActiveCfg = Release|Win32\r
+               {0D85D39A-C7FB-4C52-A541-73665FB478E6}.Release|Win32.Build.0 = Release|Win32\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B}.Debug|Win32.Build.0 = Debug|Win32\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B}.Release|Win32.ActiveCfg = Release|Win32\r
+               {5A6E80AB-5335-4F14-9030-D4DA3A13109B}.Release|Win32.Build.0 = Release|Win32\r
+               {CD3CE1A9-BABD-43F1-9CEB-6F047AEE2FC5}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {CD3CE1A9-BABD-43F1-9CEB-6F047AEE2FC5}.Debug|Win32.Build.0 = Debug|Win32\r
+               {CD3CE1A9-BABD-43F1-9CEB-6F047AEE2FC5}.Release|Win32.ActiveCfg = Release|Win32\r
+               {CD3CE1A9-BABD-43F1-9CEB-6F047AEE2FC5}.Release|Win32.Build.0 = Release|Win32\r
+               {627985F5-C1A1-406F-8184-464B34E36F1B}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {627985F5-C1A1-406F-8184-464B34E36F1B}.Debug|Win32.Build.0 = Debug|Win32\r
+               {627985F5-C1A1-406F-8184-464B34E36F1B}.Release|Win32.ActiveCfg = Release|Win32\r
+               {627985F5-C1A1-406F-8184-464B34E36F1B}.Release|Win32.Build.0 = Release|Win32\r
+               {FDBA680D-D560-49CC-B72F-EC9B3CA52B9C}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {FDBA680D-D560-49CC-B72F-EC9B3CA52B9C}.Debug|Win32.Build.0 = Debug|Win32\r
+               {FDBA680D-D560-49CC-B72F-EC9B3CA52B9C}.Release|Win32.ActiveCfg = Release|Win32\r
+               {FDBA680D-D560-49CC-B72F-EC9B3CA52B9C}.Release|Win32.Build.0 = Release|Win32\r
+               {4E9B7192-4242-47A9-B449-E3E18F8B4216}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {4E9B7192-4242-47A9-B449-E3E18F8B4216}.Debug|Win32.Build.0 = Debug|Win32\r
+               {4E9B7192-4242-47A9-B449-E3E18F8B4216}.Release|Win32.ActiveCfg = Release|Win32\r
+               {4E9B7192-4242-47A9-B449-E3E18F8B4216}.Release|Win32.Build.0 = Release|Win32\r
+               {0AE740B8-54A3-486F-AA84-F19B592B29D3}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {0AE740B8-54A3-486F-AA84-F19B592B29D3}.Debug|Win32.Build.0 = Debug|Win32\r
+               {0AE740B8-54A3-486F-AA84-F19B592B29D3}.Release|Win32.ActiveCfg = Release|Win32\r
+               {0AE740B8-54A3-486F-AA84-F19B592B29D3}.Release|Win32.Build.0 = Release|Win32\r
+               {41C72ECB-BF92-4C98-9B57-89BFCE1FA772}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {41C72ECB-BF92-4C98-9B57-89BFCE1FA772}.Debug|Win32.Build.0 = Debug|Win32\r
+               {41C72ECB-BF92-4C98-9B57-89BFCE1FA772}.Release|Win32.ActiveCfg = Release|Win32\r
+               {41C72ECB-BF92-4C98-9B57-89BFCE1FA772}.Release|Win32.Build.0 = Release|Win32\r
+               {B87FBA69-5616-48E5-8A3A-46CB9B95F3F8}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {B87FBA69-5616-48E5-8A3A-46CB9B95F3F8}.Debug|Win32.Build.0 = Debug|Win32\r
+               {B87FBA69-5616-48E5-8A3A-46CB9B95F3F8}.Release|Win32.ActiveCfg = Release|Win32\r
+               {B87FBA69-5616-48E5-8A3A-46CB9B95F3F8}.Release|Win32.Build.0 = Release|Win32\r
+               {C9AEEF0E-D3F6-4346-A9CF-5B775CEE4EC8}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {C9AEEF0E-D3F6-4346-A9CF-5B775CEE4EC8}.Debug|Win32.Build.0 = Debug|Win32\r
+               {C9AEEF0E-D3F6-4346-A9CF-5B775CEE4EC8}.Release|Win32.ActiveCfg = Release|Win32\r
+               {C9AEEF0E-D3F6-4346-A9CF-5B775CEE4EC8}.Release|Win32.Build.0 = Release|Win32\r
+               {2919D919-41FC-4138-8243-676F0EDFCCCB}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {2919D919-41FC-4138-8243-676F0EDFCCCB}.Debug|Win32.Build.0 = Debug|Win32\r
+               {2919D919-41FC-4138-8243-676F0EDFCCCB}.Release|Win32.ActiveCfg = Release|Win32\r
+               {2919D919-41FC-4138-8243-676F0EDFCCCB}.Release|Win32.Build.0 = Release|Win32\r
+               {9E207F42-049E-46E3-ACE5-1A5AFF8E7A05}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {9E207F42-049E-46E3-ACE5-1A5AFF8E7A05}.Debug|Win32.Build.0 = Debug|Win32\r
+               {9E207F42-049E-46E3-ACE5-1A5AFF8E7A05}.Release|Win32.ActiveCfg = Release|Win32\r
+               {9E207F42-049E-46E3-ACE5-1A5AFF8E7A05}.Release|Win32.Build.0 = Release|Win32\r
+               {D02963A2-AED0-4825-82D3-0F9DC1475AF3}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {D02963A2-AED0-4825-82D3-0F9DC1475AF3}.Debug|Win32.Build.0 = Debug|Win32\r
+               {D02963A2-AED0-4825-82D3-0F9DC1475AF3}.Release|Win32.ActiveCfg = Release|Win32\r
+               {D02963A2-AED0-4825-82D3-0F9DC1475AF3}.Release|Win32.Build.0 = Release|Win32\r
+               {74AF1B59-64D3-4D22-8F30-98B2868123C8}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {74AF1B59-64D3-4D22-8F30-98B2868123C8}.Debug|Win32.Build.0 = Debug|Win32\r
+               {74AF1B59-64D3-4D22-8F30-98B2868123C8}.Release|Win32.ActiveCfg = Release|Win32\r
+               {74AF1B59-64D3-4D22-8F30-98B2868123C8}.Release|Win32.Build.0 = Release|Win32\r
+               {A4C22592-4EBA-407C-A739-9AFF43141140}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {A4C22592-4EBA-407C-A739-9AFF43141140}.Debug|Win32.Build.0 = Debug|Win32\r
+               {A4C22592-4EBA-407C-A739-9AFF43141140}.Release|Win32.ActiveCfg = Release|Win32\r
+               {A4C22592-4EBA-407C-A739-9AFF43141140}.Release|Win32.Build.0 = Release|Win32\r
+               {2B20EC13-8E2E-45F0-A865-E52FC35638D6}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {2B20EC13-8E2E-45F0-A865-E52FC35638D6}.Debug|Win32.Build.0 = Debug|Win32\r
+               {2B20EC13-8E2E-45F0-A865-E52FC35638D6}.Release|Win32.ActiveCfg = Release|Win32\r
+               {2B20EC13-8E2E-45F0-A865-E52FC35638D6}.Release|Win32.Build.0 = Release|Win32\r
+               {44EB96E2-6863-4D5D-853A-1288E95261E6}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {44EB96E2-6863-4D5D-853A-1288E95261E6}.Debug|Win32.Build.0 = Debug|Win32\r
+               {44EB96E2-6863-4D5D-853A-1288E95261E6}.Release|Win32.ActiveCfg = Release|Win32\r
+               {44EB96E2-6863-4D5D-853A-1288E95261E6}.Release|Win32.Build.0 = Release|Win32\r
+               {62F73F70-88D5-4FC9-B166-4CFF4BB9E61B}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {62F73F70-88D5-4FC9-B166-4CFF4BB9E61B}.Debug|Win32.Build.0 = Debug|Win32\r
+               {62F73F70-88D5-4FC9-B166-4CFF4BB9E61B}.Release|Win32.ActiveCfg = Release|Win32\r
+               {62F73F70-88D5-4FC9-B166-4CFF4BB9E61B}.Release|Win32.Build.0 = Release|Win32\r
+               {2560F904-8A51-42D5-A1F9-411B452F899D}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {2560F904-8A51-42D5-A1F9-411B452F899D}.Debug|Win32.Build.0 = Debug|Win32\r
+               {2560F904-8A51-42D5-A1F9-411B452F899D}.Release|Win32.ActiveCfg = Release|Win32\r
+               {2560F904-8A51-42D5-A1F9-411B452F899D}.Release|Win32.Build.0 = Release|Win32\r
+               {6D10B051-BD5B-486D-AE4E-02F70DDE59AA}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {6D10B051-BD5B-486D-AE4E-02F70DDE59AA}.Debug|Win32.Build.0 = Debug|Win32\r
+               {6D10B051-BD5B-486D-AE4E-02F70DDE59AA}.Release|Win32.ActiveCfg = Release|Win32\r
+               {6D10B051-BD5B-486D-AE4E-02F70DDE59AA}.Release|Win32.Build.0 = Release|Win32\r
+               {01B062BA-DF7B-4F0C-967A-6F485D2F7C44}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {01B062BA-DF7B-4F0C-967A-6F485D2F7C44}.Debug|Win32.Build.0 = Debug|Win32\r
+               {01B062BA-DF7B-4F0C-967A-6F485D2F7C44}.Release|Win32.ActiveCfg = Release|Win32\r
+               {01B062BA-DF7B-4F0C-967A-6F485D2F7C44}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
index afc75faa155d7bbc55df5695d30272e125e0d712..2e62dbedf3c463b38f41e3f2ba8a22875f456017 100644 (file)
@@ -3,21 +3,22 @@
 ::
 
 @setlocal
-@if x%AWK%==x set AWK=gawk
+@if x%AWK%==x set AWK=mawk
 @set CHECK=@IF errorlevel 1 GOTO failed
 
 :: Check that we really have awk
 @%AWK% "{ exit(0); }" < NUL >NUL
 @if not errorlevel 9009 goto have_awk
-@echo *** install %AWK% (GNU awk) into your PATH ***
+@echo *** install %AWK% (mawk or GNU awk) into your PATH ***
+@echo *** see http://gnuwin32.sourceforge.net/packages/mawk.htm ***
 @goto failed
 :have_awk
 
-@set MSG_AWK=gawk -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk
+@set MSG_AWK=%AWK% -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk
 :: in Win32 exit 0; from gawk 3.1.3 gets converted to errorlevel 1
 :: If you have gawk 3.1.3 uncomment the following line
-:: @set MSG_AWK=gawk -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk success=-1
-@set TAG_AWK=gawk -f ../libsofia-sip-ua/su/tag_dll.awk BINMODE=rw
+:: @set MSG_AWK=%AWK% -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk success=-1
+@set TAG_AWK=%AWK% -f ../libsofia-sip-ua/su/tag_dll.awk BINMODE=rw
 
 @set IN=../libsofia-sip-ua/msg/test_class.h
 @set PR=../libsofia-sip-ua/msg/test_protos.h
index e4cdb40bce5947f070ed8ce596d16c1a4979b7b3..197efef69a17012260e480095cfe76986eb5b09f 100644 (file)
@@ -63,5 +63,5 @@ tests\torture_rbtree\Debug\torture_rbtree.exe
 tests\torture_su_bm\Debug\torture_su_bm.exe
 @if errorlevel 1 ( echo torture_su_bm: FAIL ) else echo torture_su_bm: PASS
 
-tests\torture_su_port\Debug\torture_su_port.exe
-@if errorlevel 1 ( echo torture_su_port: FAIL ) else echo torture_su_port: PASS
+:: tests\torture_su_port\Debug\torture_su_port.exe
+:: @if errorlevel 1 ( echo torture_su_port: FAIL ) else echo torture_su_port: PASS
index 13bde115c402c515db0cb9acf880dde6b2283e11..8d10097d798196df588f56da38094b7e7503960d 100644 (file)
  * @date Created: Tue Sep 12 19:22:54 2000 ppessi
  */
 
-/* Define this as the random number source name. */
+/* Define to as the random number source name. */
 #undef DEV_URANDOM
 
-/* Define this as 1 if you have addrinfo structure. */
+/* Define to 1 if you have addrinfo structure. */
 #define HAVE_ADDRINFO 1
 
 /* Define to 1 if you have the `alarm' function. */
 /* Define to 1 if you have the `clock_gettime' function. */
 #undef HAVE_CLOCK_GETTIME
 
-/* Define this as 1 if you have /dev/urandom. */
+/* Define to 1 if you have /dev/urandom. */
 #undef HAVE_DEV_URANDOM
 
+/* Define to 1 if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* Define to 1 if you have the `epoll' function. */
+/* Define to 1 if you have epoll interface. */
 #undef HAVE_EPOLL
 
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
 /* Define this as 1 if you have WIN32 FILETIME type and
    GetSystemTimeAsFileTime(). */
 #define HAVE_FILETIME 1
 /* Define to 1 if you have the `freeaddrinfo' function. */
 #define HAVE_FREEADDRINFO 1
 
-/* Define as 1 if the C compiler supports __func__ */
+/* Define to 1 if the C compiler supports __func__ */
 #undef HAVE_FUNC
 
-/* Define as 1 if the C compiler supports __FUNCTION__ */
+/* Define to 1 if the C compiler supports __FUNCTION__ */
 #undef HAVE_FUNCTION
 
 /* Define to 1 if you have the `gai_strerror' function. */
 /* Define to 1 if you have the <ifaddr.h> header file. */
 #undef HAVE_IFADDR_H
 
-/* Define this as 1 if you have SIOCGIFCONF */
+/* Define to 1 if you have SIOCGIFCONF */
 #undef HAVE_IFCONF
 
-/* Define this as 1 if you have SIOCGIFNUM ioctl */
+/* Define to 1 if you have SIOCGIFNUM ioctl */
 #undef HAVE_IFNUM
 
-/* Define this as 1 if you have ifr_ifindex in <net/if.h> */
+/* Define to 1 if you have ifr_ifindex in <net/if.h> */
 #undef HAVE_IFR_IFINDEX
 
-/* Define this as 1 if you have ifr_index in <net/if.h> */
+/* Define to 1 if you have ifr_index in <net/if.h> */
 #undef HAVE_IFR_INDEX
 
 /* Define to 1 if you have the `if_nameindex' function. */
 /* Define to 1 if you have the `initstate' function. */
 #undef HAVE_INITSTATE
 
-/* Define this as 1 if you have inlining compiler */
+/* Define to 1 if you have inlining compiler */
 #define HAVE_INLINE 1
 
-/* Define this as 1 if you have WIN32 INTERFACE_INFO_EX type. */
+/* Define to 1 if you have WIN32 INTERFACE_INFO_EX type. */
 #undef HAVE_INTERFACE_INFO_EX
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define as 1 you have WIN32 <iphlpapi.h> */
-// XXX: vehmanek-win32-fix:
+/* Define to 1 if you have the <iphlpapi.h> header file. */
+#if _MSC_VER > 1200 
+#define HAVE_IPHLPAPI_H 1
+#else
+// XXX: vehmanek-win32-fix for VC6
 #undef HAVE_IPHLPAPI_H
+#endif
 
-/* Define this as 1 if you have IPV6_RECVERR in <netinet/in6.h> */
+/* Define to 1 if you have IPV6_RECVERR in <netinet/in6.h> */
 #undef HAVE_IPV6_RECVERR
 
-/* Define this as 1 if you have IP_RECVERR in <netinet/in.h> */
+/* Define to 1 if you have IP_RECVERR in <netinet/in.h> */
 #undef HAVE_IP_RECVERR
 
 /* Define to 1 if you have the `crypto' library (-lcrypto). */
 /* Define to 1 if you have the `memspn' function. */
 #undef HAVE_MEMSPN
 
-/* Define this as 1 if you are compiling in MinGW environment */
+/* Define to 1 if you are compiling in MinGW environment */
 #undef HAVE_MINGW
 
+/* Define to 1 if you have MSG_TRUNC flag */
+#undef HAVE_MSG_TRUNC
+
 /* Define to 1 if you have the <netdb.h> header file. */
 #undef HAVE_NETDB_H
 
 /* Define to 1 if you have the <net/if_types.h> header file. */
 #undef HAVE_NET_IF_TYPES_H
 
-/* Define this as 1 if you have OpenSSL */
+/* Define to 1 if you have OpenSSL */
 #undef HAVE_OPENSSL
 
 /* Define to 1 if you have the <openssl/tls1.h> header file. */
 /* Define to 1 if you have the `poll' function. */
 #undef HAVE_POLL
 
-/* Define this as 1 if you have /proc/net/if_inet6 control file */
+/* Define to 1 if you use poll in su_port. */
+#undef HAVE_POLL_PORT
+
+/* Define to 1 if you have /proc/net/if_inet6 control file */
 #undef HAVE_PROC_NET_IF_INET6
 
+/* Define to 1 if you have working pthread_rwlock_t implementation. A thread
+   may hold multiple concurrent read locks on rwlock - that is, successfully
+   call the pthread_rwlock_rdlock() function n times. If so, the application
+   shall ensure that the thread performs matching unlocks - that is, it calls
+   the pthread_rwlock_unlock() function n times. */
+#undef HAVE_PTHREAD_RWLOCK
+
 /* Define to 1 if you have the <pthread.h> header file. */
 #define HAVE_PTHREAD_H 1
 
 /* See later */
 #define HAVE_RANDOM 1
 
-/* Define this as 1 if you have sa_len in struct sockaddr */
+/* Define to 1 if you have sa_len in struct sockaddr */
 #undef HAVE_SA_LEN
 
-/* Define this a 1 if you have SCTP */
+/* Define to 1 if you have SCTP */
 #undef HAVE_SCTP
 
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
 
-/* Define this as 1 if you have Sofia sigcomp >= 2.5 */
+/* Define to 1 if you have Sofia sigcomp >= 2.5 */
 #undef HAVE_SIGCOMP
 
 /* Define to 1 if you have the <sigcomp.h> header file. */
 #undef HAVE_SIGCOMP_H
 
-/* Define as 1 if you have SIGPIPE */
+/* Define to 1 if you have the `signal' function. */
+#define HAVE_SIGNAL 1
+
+/* Define to 1 if you have SIGPIPE */
 #undef HAVE_SIGPIPE
 
-/* Define this as 1 if you have IPv6 structures and constants */
+/* Define to 1 if you have IPv6 structures and constants */
 #define HAVE_SIN6 1
 
-/* Define this as 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY. */
+/* Define to 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY. */
 #define HAVE_SIO_ADDRESS_LIST_QUERY 1
 
 /* Define to 1 if you have the `socketpair' function. */
 #undef HAVE_SOCKETPAIR
 
-/* Define this as 1 if you have Sofia sigcomp >= 2.5 */
+/* Define to 1 if we use NTH library */
+#define HAVE_SOFIA_NTH 1
+
+/* Define to 1 if we use NTLM library */
+#undef HAVE_SOFIA_NTLM
+
+/* Define to 1 if you have Sofia sigcomp >= 2.5 */
 #undef HAVE_SOFIA_SIGCOMP
 
-/* Define as 1 always */
+/* Define to 1 always */
 #define HAVE_SOFIA_SIP 1
 
-/* Define as 1 if we use S/MIME library */
+/* Define to 1 if we use S/MIME library */
 #undef HAVE_SOFIA_SMIME
 
-/* Define as 1 if we use DNS library */
+/* Define to 1 if we use DNS library */
 #define HAVE_SOFIA_SRESOLV 1
 
-/* Define as 1 if we use STUN library */
+/* Define to 1 if we use STUN library */
 #undef HAVE_SOFIA_STUN
 
-/* Define as 1 always */
+/* Define to 1 always */
 #define HAVE_SOFIA_SU 1
 
-/* Define as 1 if we use SRTP */
+/* Define to 1 if we use SRTP */
 #undef HAVE_SRTP
 
 /* Define to 1 if you have the <stdint.h> header file. */
 /* Define to 1 if you have the `strtoull' function. */
 #undef HAVE_STRTOULL
 
-/* Define this as 1 if your CC supports C99 struct initialization */
+/* Define to 1 if your CC supports C99 struct initialization */
 #undef HAVE_STRUCT_KEYWORDS
 
 /* Define to 1 if you have the <sofia-sip/su_wait.h> header file. */
 #define HAVE_SU_WAIT_H 1
 
+/* Define to 1 if you have the <sys/epoll.h> header file. */
+#undef HAVE_SYS_EPOLL_H
+
 /* Define to 1 if you have the <sys/filio.h> header file. */
 #undef HAVE_SYS_FILIO_H
 
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
 /* Define to 1 if you have the `tcsetattr' function. */
 #undef HAVE_TCSETATTR
 
-/* Define this as 1 if you have TLS */
+/* Define to 1 if you have TLS */
 #undef HAVE_TLS
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define as 1 if we use UPnP */
+/* Define to 1 if we use UPnP */
 #undef HAVE_UPNP
 
-/* Define as 1 you have WIN32 */
+/* Define to 1 you have WIN32 */
 #define HAVE_WIN32 1
 
 /* Define to 1 if you have the <windef.h> header file. */
 /* Define to 1 if you have the <ws2tcpip.h> header file. */
 #define HAVE_WS2TCPIP_H 1
 
-/* Define as format (%lli) for long long */
+/* Define to format (%lli) for long long */
 #define LLI "%I64i"
 
-/* Define as format (%llu) for unsigned long long */
+/* Define to format (%llu) for unsigned long long */
 #define LLU "%I64u"
 
-/* Define as format (%llx) for long long hex */
+/* Define to format (%llx) for long long hex */
 #define LLX "%I64x"
 
 /* Name of package */
 /* This is GCC magic  */
 #define __attribute__(x)
 
-/* Define this as 1 if you have TimeGetTime() */
+/* Define to 1 if you have TimeGetTime() */
 #define HAVE_TIMEGETTIME     1
 
 #define PATH_MAX _MAX_PATH
 
 #define HAVE_WINMM 1
 
-/* Define this as 1 if you have FILETIME */
+/* Define to 1 if you have FILETIME */
 #define HAVE_FILETIME 1
 
-/* Define this as 1 if you have WinSock2 ioctl SIO_ADDRESS_LIST_QUERY */
+/* Define to 1 if you have WinSock2 ioctl SIO_ADDRESS_LIST_QUERY */
 #define HAVE_SIO_ADDRESS_LIST_QUERY 1
 
-/* Define this as 1 if you have INTERFACE_INFO ioctl */
+/* Define to 1 if you have INTERFACE_INFO ioctl */
 #define HAVE_INTERFACE_INFO       (1) 
 
 /* Ignore certain warnings */
index a6bf63a6e9354b832e10deb472c24274f6ccd33c..e8a581ad706b056cd0f33a6293c6d431ff000b86 100644 (file)
@@ -113,6 +113,10 @@ SOURCE="..\..\libsofia-sip-ua\su\su_alloc_lock.c"
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\libsofia-sip-ua\su\su_base_port.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\libsofia-sip-ua\su\su_bm.c"\r
 # End Source File\r
 # Begin Source File\r
@@ -149,10 +153,18 @@ SOURCE="..\..\libsofia-sip-ua\su\su_port.c"
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\libsofia-sip-ua\su\su_pthread_port.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\libsofia-sip-ua\su\su_root.c"\r
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\libsofia-sip-ua\su\su_socket_port.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\libsofia-sip-ua\su\su_sprintf.c"\r
 # End Source File\r
 # Begin Source File\r
@@ -199,6 +211,10 @@ SOURCE="..\..\libsofia-sip-ua\su\su_vector.c"
 \r
 SOURCE="..\..\libsofia-sip-ua\su\su_wait.c"\r
 # End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\libsofia-sip-ua\su\su_win32_port.c"\r
+# End Source File\r
 # End Group\r
 # Begin Group "ipt"\r
 \r
diff --git a/libs/sofia-sip/win32/libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj b/libs/sofia-sip/win32/libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj
new file mode 100644 (file)
index 0000000..0f3cfe6
--- /dev/null
@@ -0,0 +1,4359 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="libsofia_sip_ua_static"\r
+       ProjectGUID="{5A6E80AB-5335-4F14-9030-D4DA3A13109B}"\r
+       RootNamespace="libsofia_sip_ua_static"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="4"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..\libsofia-sip-ua\su,..\..\libsofia-sip-ua\ipt,..\..\libsofia-sip-ua\sresolv,..\..\libsofia-sip-ua\bnf,..\..\libsofia-sip-ua\url,..\..\libsofia-sip-ua\msg,..\..\libsofia-sip-ua\sip,..\..\libsofia-sip-ua\nta,..\..\libsofia-sip-ua\nua,..\..\libsofia-sip-ua\iptsec,..\..\libsofia-sip-ua\http,..\..\libsofia-sip-ua\nth,..\..\libsofia-sip-ua\nea,..\..\libsofia-sip-ua\sdp,..\..\libsofia-sip-ua\soa,..\..\libsofia-sip-ua\stun,..\..\libsofia-sip-ua\tport,..\..\libsofia-sip-ua\features,..\pthread,."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/libsofia_sip_ua_static.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                               CompileAs="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               OutputFile=".\Debug\libsofia_sip_ua_static.lib"\r
+                               SuppressStartupBanner="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/libsofia_sip_ua_static.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="4"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..\libsofia-sip-ua\su,..\..\libsofia-sip-ua\ipt,..\..\libsofia-sip-ua\sresolv,..\..\libsofia-sip-ua\bnf,..\..\libsofia-sip-ua\url,..\..\libsofia-sip-ua\msg,..\..\libsofia-sip-ua\sip,..\..\libsofia-sip-ua\nta,..\..\libsofia-sip-ua\nua,..\..\libsofia-sip-ua\iptsec,..\..\libsofia-sip-ua\http,..\..\libsofia-sip-ua\nth,..\..\libsofia-sip-ua\nea,..\..\libsofia-sip-ua\sdp,..\..\libsofia-sip-ua\soa,..\..\libsofia-sip-ua\stun,..\..\libsofia-sip-ua\tport,..\..\libsofia-sip-ua\features,..\pthread,."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;IN_LIBSOFIA_SIP_UA_STATIC;LIBSOFIA_SIP_UA_STATIC;LIBSRES_STATIC"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/libsofia_sip_ua_static.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               CompileAs="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               OutputFile=".\Release\libsofia_sip_ua_static.lib"\r
+                               SuppressStartupBanner="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/libsofia_sip_ua_static.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <Filter\r
+                               Name="su"\r
+                               Filter="su*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\inet_ntop.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\inet_pton.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_addrinfo.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_alloc.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_alloc_lock.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_base_port.c"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_bm.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_default_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_errno.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_global_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_localinfo.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_md5.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_os_nw.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_port.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_pthread_port.c"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_root.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_socket_port.c"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_sprintf.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_strdup.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_strlst.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_tag_io.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_taglist.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_time.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_time0.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_timer.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_uniqueid.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_vector.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_wait.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_win32_port.c"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="ipt"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\base64.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\rc4.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\string0.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\token64.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="url"\r
+                               Filter="url*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\url.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\url_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\url_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="features"\r
+                               Filter="features*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\features\features.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="bnf"\r
+                               Filter="bnf*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\bnf\bnf.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="msg"\r
+                               Filter="msg*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_auth.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_basic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_date.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_generic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_header_copy.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_header_make.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_mclass.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_mime.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_mime_table.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_parser.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_parser_util.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="clib replacement"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\memcspn.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\memmem.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\memspn.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\strcasestr.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\strtoull.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sip"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_basic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_caller_prefs.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_event.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_extra.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_feature.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_header.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_mime.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_parser.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_parser_table.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_prack.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_pref_util.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_reason.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_refer.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_security.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_session.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_status.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_tag_class.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_time.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_util.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="http"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_basic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_extra.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_header.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_parser.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_parser_table.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_status.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_tag_class.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nth"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_client.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_server.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sresolv"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sres.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sres_blocking.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sres_cache.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sresolv.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nea"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_debug.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_event.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_server.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="iptsec"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_client.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_common.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_digest.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_module.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_module_http.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_module_sip.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_plugin.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_plugin_delayed.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\iptsec_debug.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="stun"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_common.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_dns.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_mini.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nua"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_common.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_dialog.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_dialog.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_event_server.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_extension.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_message.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_notifier.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_options.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_params.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_params.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_publish.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_register.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_registrar.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_session.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_stack.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_stack.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_subnotref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\outbound.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\outbound.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nta"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_check.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sl_read_payload.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sl_utils_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sl_utils_print.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="tport"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_logging.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_stub_sigcomp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_stub_stun.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_type_connect.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_type_tcp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_type_udp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sdp"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_parse.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_print.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="soa"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa_session.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa_static.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <Filter\r
+                               Name="su headers"\r
+                               Filter="su*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\htable.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\htable2.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\rbtree.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_addrinfo.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_alloc.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_alloc_stat.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_bm.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_config.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_debug.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_errno.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_localinfo.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_log.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_md5.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_module_debug.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_os_nw.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_port.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_source.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_strlst.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag_inline.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag_io.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tagarg.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_time.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_types.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_uniqueid.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_vector.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_wait.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\tstdef.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="win32 headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\config.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\sofia-sip\su_configure.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\unistd.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="ipt headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\base64.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\rc4.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\string0.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\token64.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="url headers"\r
+                               Filter="url*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\sofia-sip\url.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\sofia-sip\url_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\sofia-sip\url_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="features headers"\r
+                               Filter="features*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\features\sofia-sip\sofia_features.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="bnf headers"\r
+                               Filter="bnf*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\bnf\sofia-sip\bnf.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\bnf\sofia-sip\hostdomain.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="msg headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_addr.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_bnf.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_buffer.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_date.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_header.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mclass.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mclass_hash.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mime.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mime_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_parser.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_types.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sip headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_extensions.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_hclasses.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_header.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_parser.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_status.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_util.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="http headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_hclasses.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_header.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_parser.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_status.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nth headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\sofia-sip\nth.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\sofia-sip\nth_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sresolv headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_async.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_cache.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_config.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_record.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-sip\sresolv.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nea headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\sofia-sip\nea.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_debug.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\sofia-sip\nea_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="iptsec headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_client.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_client_plugin.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_common.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_digest.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_module.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_ntlm.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_plugin.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\iptsec_debug.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="stun headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\sofia-sip\stun.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\sofia-sip\stun_common.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\sofia-sip\stun_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nua headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\sofia-sip\nua.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\sofia-sip\nua_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nta headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta_stateless.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta_tport.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\sl_utils.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="tport headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\sofia-sip\tport.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\sofia-sip\tport_plugins.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\sofia-sip\tport_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_tls.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sdp headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sofia-sip\sdp.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sofia-sip\sdp_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="soa headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa_add.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
index ea068669edd96727806de63ddad0303512a0baf6..55bb0ff7fd96acbcd42ced6d40444088dcf673d2 100644 (file)
@@ -125,6 +125,10 @@ SOURCE="..\..\libsofia-sip-ua\su\su_alloc_lock.c"
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\libsofia-sip-ua\su\su_base_port.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\libsofia-sip-ua\su\su_bm.c"\r
 # End Source File\r
 # Begin Source File\r
@@ -161,10 +165,18 @@ SOURCE="..\..\libsofia-sip-ua\su\su_port.c"
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\libsofia-sip-ua\su\su_pthread_port.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\libsofia-sip-ua\su\su_root.c"\r
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\libsofia-sip-ua\su\su_socket_port.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\libsofia-sip-ua\su\su_sprintf.c"\r
 # End Source File\r
 # Begin Source File\r
@@ -211,6 +223,10 @@ SOURCE="..\..\libsofia-sip-ua\su\su_vector.c"
 \r
 SOURCE="..\..\libsofia-sip-ua\su\su_wait.c"\r
 # End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\libsofia-sip-ua\su\su_win32_port.c"\r
+# End Source File\r
 # End Group\r
 # Begin Group "ipt"\r
 \r
diff --git a/libs/sofia-sip/win32/libsofia-sip-ua/libsofia_sip_ua.vcproj b/libs/sofia-sip/win32/libsofia-sip-ua/libsofia_sip_ua.vcproj
new file mode 100644 (file)
index 0000000..7b0cbf3
--- /dev/null
@@ -0,0 +1,4406 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="libsofia_sip_ua"\r
+       ProjectGUID="{0D85D39A-C7FB-4C52-A541-73665FB478E6}"\r
+       RootNamespace="libsofia_sip_ua"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/libsofia_sip_ua.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..\libsofia-sip-ua\su,..\..\libsofia-sip-ua\ipt,..\..\libsofia-sip-ua\sresolv,..\..\libsofia-sip-ua\bnf,..\..\libsofia-sip-ua\url,..\..\libsofia-sip-ua\msg,..\..\libsofia-sip-ua\sip,..\..\libsofia-sip-ua\nta,..\..\libsofia-sip-ua\nua,..\..\libsofia-sip-ua\iptsec,..\..\libsofia-sip-ua\http,..\..\libsofia-sip-ua\nth,..\..\libsofia-sip-ua\nea,..\..\libsofia-sip-ua\sdp,..\..\libsofia-sip-ua\soa,..\..\libsofia-sip-ua\stun,..\..\libsofia-sip-ua\tport,..\..\libsofia-sip-ua\features,..\pthread,."\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;LIBSOFIA_SIP_UA_EXPORTS;IN_LIBSOFIA_SIP_UA=1;IN_LIBSOFIA_SRES=1"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/libsofia_sip_ua.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                               CompileAs="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib advapi32.lib iphlpapi.lib"\r
+                               OutputFile=".\Debug/libsofia_sip_ua.dll"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/libsofia_sip_ua.pdb"\r
+                               ImportLibrary=".\Debug/libsofia_sip_ua.lib"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/libsofia_sip_ua.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               Description="Copy dll to win32 directory"\r
+                               CommandLine="copy Debug\libsofia_sip_ua.dll .."\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/libsofia_sip_ua.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..\libsofia-sip-ua\su,..\..\libsofia-sip-ua\ipt,..\..\libsofia-sip-ua\sresolv,..\..\libsofia-sip-ua\bnf,..\..\libsofia-sip-ua\url,..\..\libsofia-sip-ua\msg,..\..\libsofia-sip-ua\sip,..\..\libsofia-sip-ua\nta,..\..\libsofia-sip-ua\nua,..\..\libsofia-sip-ua\iptsec,..\..\libsofia-sip-ua\http,..\..\libsofia-sip-ua\nth,..\..\libsofia-sip-ua\nea,..\..\libsofia-sip-ua\sdp,..\..\libsofia-sip-ua\soa,..\..\libsofia-sip-ua\stun,..\..\libsofia-sip-ua\tport,..\..\libsofia-sip-ua\features,..\pthread,."\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;LIBSOFIA_SIP_UA_EXPORTS;IN_LIBSOFIA_SIP_UA=1;IN_LIBSOFIA_SRES=1"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/libsofia_sip_ua.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               CompileAs="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib advapi32.lib iphlpapi.lib"\r
+                               OutputFile=".\Release/libsofia_sip_ua.dll"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/libsofia_sip_ua.pdb"\r
+                               ImportLibrary=".\Release/libsofia_sip_ua.lib"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/libsofia_sip_ua.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <Filter\r
+                               Name="su"\r
+                               Filter="su*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\inet_ntop.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\inet_pton.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_addrinfo.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_alloc.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_alloc_lock.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_base_port.c"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_bm.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_default_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_errno.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_global_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_localinfo.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_md5.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_os_nw.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_port.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_pthread_port.c"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_root.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_socket_port.c"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_sprintf.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_strdup.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_strlst.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_tag_io.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_taglist.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_time.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_time0.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_timer.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_uniqueid.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_vector.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_wait.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_win32_port.c"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="ipt"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\base64.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\rc4.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\string0.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\token64.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="url"\r
+                               Filter="url*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\url.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\url_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\url_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="features"\r
+                               Filter="features*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\features\features.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="bnf"\r
+                               Filter="bnf*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\bnf\bnf.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="msg"\r
+                               Filter="msg*.c"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_auth.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_basic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_date.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_generic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_header_copy.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_header_make.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_mclass.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_mime.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_mime_table.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_parser.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_parser_util.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="clib replacement"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\memcspn.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\memmem.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\memspn.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\strcasestr.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\strtoull.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sip"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_basic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_caller_prefs.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_event.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_extra.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_feature.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_header.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_mime.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_parser.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_parser_table.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_prack.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_pref_util.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_reason.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_refer.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_security.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_session.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_status.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_tag_class.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_time.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_util.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="http"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_basic.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_extra.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_header.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_parser.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_parser_table.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_status.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_tag_class.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\http_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nth"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_client.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_server.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\nth_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sresolv"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sres.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sres_blocking.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sres_cache.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sresolv.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nea"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_debug.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_event.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_server.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="iptsec"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_client.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_common.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_digest.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_module.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_module_http.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_module_sip.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_plugin.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_plugin_delayed.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\auth_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\iptsec_debug.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="stun"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_common.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_dns.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_mini.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\stun_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nua"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_common.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_dialog.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_dialog.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_event_server.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_extension.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_message.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_notifier.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_options.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_params.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_params.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_publish.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_register.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_registrar.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_session.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_stack.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_stack.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_subnotref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\nua_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\outbound.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\outbound.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nta"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_check.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sl_read_payload.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sl_utils_log.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sl_utils_print.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="tport"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_logging.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_stub_sigcomp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_stub_stun.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_type_connect.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_type_tcp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_type_udp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sdp"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_parse.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_print.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sdp_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="soa"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa_session.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa_static.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa_tag.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\soa_tag_ref.c"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                                       AdditionalIncludeDirectories=""\r
+                                                       PreprocessorDefinitions=""\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                       </Filter>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <Filter\r
+                               Name="su headers"\r
+                               Filter="su*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\htable.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\htable2.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\rbtree.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_addrinfo.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_alloc.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_alloc_stat.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_bm.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_config.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_debug.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_errno.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_localinfo.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_log.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_md5.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_module_debug.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_os_nw.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\su_port.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_source.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_strlst.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag_inline.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tag_io.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_tagarg.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_time.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_types.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_uniqueid.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_vector.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\su_wait.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\su\sofia-sip\tstdef.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="win32 headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\config.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\sofia-sip\su_configure.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\unistd.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="ipt headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\base64.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\rc4.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\string0.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\ipt\sofia-sip\token64.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="url headers"\r
+                               Filter="url*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\sofia-sip\url.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\sofia-sip\url_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\url\sofia-sip\url_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="features headers"\r
+                               Filter="features*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\features\sofia-sip\sofia_features.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="bnf headers"\r
+                               Filter="bnf*.h"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\bnf\sofia-sip\bnf.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\bnf\sofia-sip\hostdomain.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="msg headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_addr.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_bnf.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_buffer.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_date.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_header.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\msg_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mclass.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mclass_hash.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mime.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_mime_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_parser.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\msg\sofia-sip\msg_types.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sip headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_extensions.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_hclasses.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_header.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sip_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_parser.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_status.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sip\sofia-sip\sip_util.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="http headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_hclasses.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_header.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_parser.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_protos.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_status.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\http\sofia-sip\http_tag_class.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nth headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\sofia-sip\nth.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nth\sofia-sip\nth_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sresolv headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_async.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_cache.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_config.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-resolv\sres_record.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sresolv\sofia-sip\sresolv.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nea headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\sofia-sip\nea.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\nea_debug.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nea\sofia-sip\nea_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="iptsec headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_client.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_client_plugin.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_common.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_digest.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_module.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_ntlm.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\sofia-sip\auth_plugin.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\iptsec\iptsec_debug.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="stun headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\sofia-sip\stun.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\sofia-sip\stun_common.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\stun\sofia-sip\stun_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nua headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\sofia-sip\nua.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nua\sofia-sip\nua_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="nta headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\nta_internal.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta_stateless.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\nta_tport.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\nta\sofia-sip\sl_utils.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="tport headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\sofia-sip\tport.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\sofia-sip\tport_plugins.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\sofia-sip\tport_tag.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\tport\tport_tls.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="sdp headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sofia-sip\sdp.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\sdp\sofia-sip\sdp_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+                       <Filter\r
+                               Name="soa headers"\r
+                               >\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa_add.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\libsofia-sip-ua\soa\sofia-sip\soa_tag.h"\r
+                                       >\r
+                               </File>\r
+                       </Filter>\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/test_htable/test_htable.vcproj b/libs/sofia-sip/win32/tests/test_htable/test_htable.vcproj
new file mode 100644 (file)
index 0000000..f902eed
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="test_htable"\r
+       ProjectGUID="{41C72ECB-BF92-4C98-9B57-89BFCE1FA772}"\r
+       RootNamespace="test_htable"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/test_htable.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/test_htable.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/test_htable.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/test_htable.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/test_htable.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/test_htable.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/test_htable.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/test_htable.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/test_htable.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/test_htable.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\test_htable.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/test_memmem/test_memmem.vcproj b/libs/sofia-sip/win32/tests/test_memmem/test_memmem.vcproj
new file mode 100644 (file)
index 0000000..3e396b2
--- /dev/null
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="test_memmem"\r
+       ProjectGUID="{B87FBA69-5616-48E5-8A3A-46CB9B95F3F8}"\r
+       RootNamespace="test_memmem"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/test_memmem.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\pthread,."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/test_memmem.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile=".\Debug/test_memmem.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/test_memmem.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/test_memmem.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/test_memmem.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\libsofia-sip-ua\ipt,..\..\libsofia-sip-ua\sresolv,..\..\libsofia-sip-ua\bnf,..\..\libsofia-sip-ua\url,..\..\libsofia-sip-ua\msg,..\..\libsofia-sip-ua\sip,..\..\libsofia-sip-ua\nta,..\..\libsofia-sip-ua\nua,..\..\libsofia-sip-ua\iptsec,..\..\libsofia-sip-ua\http,..\..\libsofia-sip-ua\nth,..\..\libsofia-sip-ua\nea,..\..\libsofia-sip-ua\sdp,..\..\libsofia-sip-ua\soa,..\..\libsofia-sip-ua\stun,..\..\libsofia-sip-ua\tport,..\pthread,."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/test_memmem.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile=".\Release/test_memmem.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/test_memmem.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/test_memmem.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\test_memmem.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/test_nta/test_nta.vcproj b/libs/sofia-sip/win32/tests/test_nta/test_nta.vcproj
new file mode 100644 (file)
index 0000000..cd82d5b
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="test_nta"\r
+       ProjectGUID="{C9AEEF0E-D3F6-4346-A9CF-5B775CEE4EC8}"\r
+       RootNamespace="test_nta"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/test_nta.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\nua,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\http,..\..\..\libsofia-sip-ua\nth,..\..\..\libsofia-sip-ua\nea,..\..\..\libsofia-sip-ua\sdp,..\..\..\libsofia-sip-ua\soa,..\..\..\libsofia-sip-ua\stun,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\features,include,."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/test_nta.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/test_nta.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/test_nta.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/test_nta.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/test_nta.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\nua,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\http,..\..\..\libsofia-sip-ua\nth,..\..\..\libsofia-sip-ua\nea,..\..\..\libsofia-sip-ua\sdp,..\..\..\libsofia-sip-ua\soa,..\..\..\libsofia-sip-ua\stun,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\features,include,."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/test_nta.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/test_nta.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/test_nta.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/test_nta.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nta\test_nta.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
index 315308660718d756c14cca8295a5874f14d86295..2d120e529b503f332162b40be30074dd548d4572 100644 (file)
@@ -145,6 +145,10 @@ SOURCE="..\..\..\libsofia-sip-ua\nua\test_nua_params.c"
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE="..\..\..\libsofia-sip-ua\nua\test_offer_answer.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE="..\..\..\libsofia-sip-ua\nua\test_ops.c"\r
 # End Source File\r
 # Begin Source File\r
diff --git a/libs/sofia-sip/win32/tests/test_nua/test_nua.vcproj b/libs/sofia-sip/win32/tests/test_nua/test_nua.vcproj
new file mode 100644 (file)
index 0000000..e90b3b6
--- /dev/null
@@ -0,0 +1,673 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="test_nua"\r
+       ProjectGUID="{2919D919-41FC-4138-8243-676F0EDFCCCB}"\r
+       RootNamespace="test_nua"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/test_nua.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\nua,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\http,..\..\..\libsofia-sip-ua\nth,..\..\..\libsofia-sip-ua\nea,..\..\..\libsofia-sip-ua\sdp,..\..\..\libsofia-sip-ua\soa,..\..\..\libsofia-sip-ua\stun,..\..\..\libsofia-sip-ua\tport,include,."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/test_nua.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/test_nua.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/test_nua.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/test_nua.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/test_nua.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\nua,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\http,..\..\..\libsofia-sip-ua\nth,..\..\..\libsofia-sip-ua\nea,..\..\..\libsofia-sip-ua\sdp,..\..\..\libsofia-sip-ua\soa,..\..\..\libsofia-sip-ua\stun,..\..\..\libsofia-sip-ua\tport,include,."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/test_nua.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/test_nua.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/test_nua.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/test_nua.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\memmem.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_100rel.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_basic_call.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_call_hold.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_call_reject.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_cancel_bye.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_extension.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_init.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_nat.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_nat.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="test_nat_tags.cpp"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_nua.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_nua.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_nua_api.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_nua_params.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_offer_answer.c"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_ops.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_proxy.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_proxy.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_refer.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_register.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_session_timer.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_simple.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\nua\test_sip_events.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/test_su/test_su.vcproj b/libs/sofia-sip/win32/tests/test_su/test_su.vcproj
new file mode 100644 (file)
index 0000000..7f4a2ee
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="test_su"\r
+       ProjectGUID="{9E207F42-049E-46E3-ACE5-1A5AFF8E7A05}"\r
+       RootNamespace="test_su"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/test_su.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/test_su.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/test_su.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/test_su.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/test_su.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/test_su.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/test_su.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/test_su.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/test_su.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/test_su.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\test_su.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/test_tport/test_tport.vcproj b/libs/sofia-sip/win32/tests/test_tport/test_tport.vcproj
new file mode 100644 (file)
index 0000000..7eac861
--- /dev/null
@@ -0,0 +1,289 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="test_tport"\r
+       ProjectGUID="{D02963A2-AED0-4825-82D3-0F9DC1475AF3}"\r
+       RootNamespace="test_tport"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/test_tport.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\nua,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\http,..\..\..\libsofia-sip-ua\nth,..\..\..\libsofia-sip-ua\nea,..\..\..\libsofia-sip-ua\sdp,..\..\..\libsofia-sip-ua\soa,..\..\..\libsofia-sip-ua\stun,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\features,include,."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/test_tport.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/test_tport.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/test_tport.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/test_tport.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/test_tport.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\nua,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\http,..\..\..\libsofia-sip-ua\nth,..\..\..\libsofia-sip-ua\nea,..\..\..\libsofia-sip-ua\sdp,..\..\..\libsofia-sip-ua\soa,..\..\..\libsofia-sip-ua\stun,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\features,include,."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/test_tport.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/test_tport.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/test_tport.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/test_tport.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="test_class.cpp"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\msg\test_class.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\msg\test_protos.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="test_table.cpp"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\tport\test_tport.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_rbtree/torture_rbtree.vcproj b/libs/sofia-sip/win32/tests/torture_rbtree/torture_rbtree.vcproj
new file mode 100644 (file)
index 0000000..59e2d7f
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_rbtree"\r
+       ProjectGUID="{74AF1B59-64D3-4D22-8F30-98B2868123C8}"\r
+       RootNamespace="torture_rbtree"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_rbtree.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_rbtree.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_rbtree.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_rbtree.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_rbtree.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_rbtree.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_rbtree.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_rbtree.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_rbtree.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_rbtree.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_rbtree.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su/torture_su.vcproj b/libs/sofia-sip/win32/tests/torture_su/torture_su.vcproj
new file mode 100644 (file)
index 0000000..2cbd7af
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su"\r
+       ProjectGUID="{A4C22592-4EBA-407C-A739-9AFF43141140}"\r
+       RootNamespace="torture_su"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_alloc/torture_su_alloc.vcproj b/libs/sofia-sip/win32/tests/torture_su_alloc/torture_su_alloc.vcproj
new file mode 100644 (file)
index 0000000..aadb551
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su_alloc"\r
+       ProjectGUID="{2B20EC13-8E2E-45F0-A865-E52FC35638D6}"\r
+       RootNamespace="torture_su_alloc"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_alloc.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_alloc.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_alloc.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_alloc.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_alloc.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_alloc.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_alloc.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_alloc.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_alloc.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_alloc.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_alloc.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_bm/torture_su_bm.vcproj b/libs/sofia-sip/win32/tests/torture_su_bm/torture_su_bm.vcproj
new file mode 100644 (file)
index 0000000..29a00a3
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su_bm"\r
+       ProjectGUID="{44EB96E2-6863-4D5D-853A-1288E95261E6}"\r
+       RootNamespace="torture_su_bm"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_bm.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;LIBSOFIA_SIP_UA_STATIC"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_bm.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_bm.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_bm.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_bm.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_bm.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;LIBSOFIA_SIP_UA_STATIC"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_bm.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_bm.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_bm.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_bm.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_bm.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_port/torture_su_port.vcproj b/libs/sofia-sip/win32/tests/torture_su_port/torture_su_port.vcproj
new file mode 100644 (file)
index 0000000..1da158b
--- /dev/null
@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8,00"\r
+       Name="torture_su_port"\r
+       ProjectGUID="{E5110D04-93C2-417F-B962-0F1C9F30C5A2}"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_port.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\pthread"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;LIBSOFIA_SIP_UA_STATIC"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_port.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_port.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_port.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_port.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_port.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su,..\..\pthread"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;LIBSOFIA_SIP_UA_STATIC"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_port.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_port.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_port.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_port.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_port.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_root/torture_su_root.vcproj b/libs/sofia-sip/win32/tests/torture_su_root/torture_su_root.vcproj
new file mode 100644 (file)
index 0000000..0d1b17c
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su_root"\r
+       ProjectGUID="{62F73F70-88D5-4FC9-B166-4CFF4BB9E61B}"\r
+       RootNamespace="torture_su_root"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_root.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_root.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_root.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_root.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_root.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_root.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_root.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_root.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_root.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_root.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_root.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_tag/torture_su_tag.vcproj b/libs/sofia-sip/win32/tests/torture_su_tag/torture_su_tag.vcproj
new file mode 100644 (file)
index 0000000..ff2a2e2
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su_tag"\r
+       ProjectGUID="{2560F904-8A51-42D5-A1F9-411B452F899D}"\r
+       RootNamespace="torture_su_tag"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_tag.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_tag.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_tag.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_tag.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_tag.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_tag.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_tag.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_tag.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_tag.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_tag.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_tag.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_time/torture_su_time.vcproj b/libs/sofia-sip/win32/tests/torture_su_time/torture_su_time.vcproj
new file mode 100644 (file)
index 0000000..5e627eb
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su_time"\r
+       ProjectGUID="{6D10B051-BD5B-486D-AE4E-02F70DDE59AA}"\r
+       RootNamespace="torture_su_time"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_time.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;LIBSOFIA_SIP_UA_STATIC"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_time.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_time.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_time.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_time.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_time.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;LIBSOFIA_SIP_UA_STATIC"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_time.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_time.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_time.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_time.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_time.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/tests/torture_su_timer/torture_su_timer.vcproj b/libs/sofia-sip/win32/tests/torture_su_timer/torture_su_timer.vcproj
new file mode 100644 (file)
index 0000000..80dff8d
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="torture_su_timer"\r
+       ProjectGUID="{01B062BA-DF7B-4F0C-967A-6F485D2F7C44}"\r
+       RootNamespace="torture_su_timer"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Debug/torture_su_timer.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/torture_su_timer.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/torture_su_timer.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/torture_su_timer.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/torture_su_timer.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TypeLibraryName=".\Release/torture_su_timer.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..,..\..\..\libsofia-sip-ua\su"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/torture_su_timer.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1035"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/torture_su_timer.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/torture_su_timer.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/torture_su_timer.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\..\libsofia-sip-ua\su\torture_su_timer.c"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCLCompilerTool"\r
+                                       AdditionalIncludeDirectories=""\r
+                                       PreprocessorDefinitions=""\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/utils/localinfo/localinfo.vcproj b/libs/sofia-sip/win32/utils/localinfo/localinfo.vcproj
new file mode 100644 (file)
index 0000000..d686df4
--- /dev/null
@@ -0,0 +1,284 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="localinfo"\r
+       ProjectGUID="{CD3CE1A9-BABD-43F1-9CEB-6F047AEE2FC5}"\r
+       RootNamespace="localinfo"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/localinfo.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/localinfo.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                               CompileAs="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/localinfo.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/localinfo.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/localinfo.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/localinfo.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/localinfo.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               CompileAs="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/localinfo.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/localinfo.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/localinfo.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\libsofia-sip-ua\su\getopt.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\libsofia-sip-ua\su\localinfo.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/utils/sip_dig/sip_dig.vcproj b/libs/sofia-sip/win32/utils/sip_dig/sip_dig.vcproj
new file mode 100644 (file)
index 0000000..106dba2
--- /dev/null
@@ -0,0 +1,260 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="sip_dig"\r
+       ProjectGUID="{627985F5-C1A1-406F-8184-464B34E36F1B}"\r
+       RootNamespace="sip_dig"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/sip_dig.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/sip_dig.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/sip_dig.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/sip_dig.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/sip_dig.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/sip_dig.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\sresolv,..\..\..\libsofia-sip-ua\bnf,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/sip_dig.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/sip_dig.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/sip_dig.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/sip_dig.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\utils\sip-dig.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/utils/sip_options/sip_options.vcproj b/libs/sofia-sip/win32/utils/sip_options/sip_options.vcproj
new file mode 100644 (file)
index 0000000..8769020
--- /dev/null
@@ -0,0 +1,260 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="sip_options"\r
+       ProjectGUID="{FDBA680D-D560-49CC-B72F-EC9B3CA52B9C}"\r
+       RootNamespace="sip_options"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/sip_options.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/sip_options.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/sip_options.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/sip_options.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/sip_options.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/sip_options.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/sip_options.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/sip_options.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/sip_options.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/sip_options.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\utils\sip-options.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/utils/sip_options_static/sip_options_static.vcproj b/libs/sofia-sip/win32/utils/sip_options_static/sip_options_static.vcproj
new file mode 100644 (file)
index 0000000..51a4624
--- /dev/null
@@ -0,0 +1,260 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="sip_options_static"\r
+       ProjectGUID="{4E9B7192-4242-47A9-B449-E3E18F8B4216}"\r
+       RootNamespace="sip_options_static"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/sip_options_static.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;LIBSOFIA_SIP_UA_STATIC"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/sip_options_static.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib advapi32.lib iphlpapi.lib"\r
+                               OutputFile=".\Release/sip_options_static.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/sip_options_static.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/sip_options_static.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/sip_options_static.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;LIBSOFIA_SIP_UA_STATIC"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/sip_options_static.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib advapi32.lib iphlpapi.lib"\r
+                               OutputFile=".\Debug/sip_options_static.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/sip_options_static.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/sip_options_static.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\utils\sip-options.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/libs/sofia-sip/win32/utils/stunc/stunc.vcproj b/libs/sofia-sip/win32/utils/stunc/stunc.vcproj
new file mode 100644 (file)
index 0000000..662fc85
--- /dev/null
@@ -0,0 +1,260 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="stunc"\r
+       ProjectGUID="{0AE740B8-54A3-486F-AA84-F19B592B29D3}"\r
+       RootNamespace="stunc"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/stunc.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\features,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               PrecompiledHeaderFile=".\Debug/stunc.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Debug/stunc.exe"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/stunc.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Debug/stunc.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="1"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/stunc.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..,..\..,..\..\..\libsofia-sip-ua\su,..\..\..\libsofia-sip-ua\features,..\..\..\libsofia-sip-ua\tport,..\..\..\libsofia-sip-ua\iptsec,..\..\..\libsofia-sip-ua\ipt,..\..\..\libsofia-sip-ua\url,..\..\..\libsofia-sip-ua\nta,..\..\..\libsofia-sip-ua\msg,..\..\..\libsofia-sip-ua\sip"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/stunc.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="4"\r
+                               WarnAsError="true"\r
+                               SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               OutputFile=".\Release/stunc.exe"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               ProgramDatabaseFile=".\Release/stunc.pdb"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\Release/stunc.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\libsofia-sip-ua\stun\stunc.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               AdditionalIncludeDirectories=""\r
+                                               PreprocessorDefinitions=""\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\pthread\pthreadVC2.lib"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
index d18adf962db41cb01c9d9c6f0a356adc81bb4632..840a206b4a0aa06a769206e0466f2946b133fbe7 100644 (file)
 ::
 
 @setlocal
-@if x%AWK%==x set AWK=gawk
+@if x%AWK%==x set AWK=mawk
 @set VERSION=%AWK% -v BINMODE="rw" -f version.awk
 @set AC=..\configure.ac
 
 :: Check that we really have awk
 @%AWK% "{ exit(0); }" < NUL >NUL
 @if not errorlevel 9009 goto have_awk
-@echo *** install %AWK% (GNU awk) into your PATH ***
+@echo *** install %AWK% (mawk or GNU awk) into your PATH ***
+@echo *** see http://gnuwin32.sourceforge.net/packages/mawk.htm ***
 @goto end
 :have_awk
 
index 5763a54f5bfd995e8f3ac969de42456a8bc51a36..a0f2b86106325c9be4fd990f3a3b3a2cd39393c2 100644 (file)
@@ -54,6 +54,7 @@
                                ProgramDataBaseFileName=".\Debug/"\r
                                BrowseInformation="1"\r
                                WarningLevel="4"\r
+                               WarnAsError="true"\r
                                SuppressStartupBanner="true"\r
                                Detect64BitPortabilityProblems="true"\r
                                DebugInformationFormat="3"\r
                                ProgramDataBaseFileName=".\Release/"\r
                                BrowseInformation="1"\r
                                WarningLevel="4"\r
+                               WarnAsError="true"\r
                                SuppressStartupBanner="true"\r
                                Detect64BitPortabilityProblems="true"\r
                        />\r
                                        RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_alloc_lock.c"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_base_port.c"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_bm.c"\r
                                        >\r
                                        RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_port.c"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_pthread_port.c"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_root.c"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_socket_port.c"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_sprintf.c"\r
                                        >\r
                                        RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_wait.c"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_win32_port.c"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="ipt"\r