mirror of
https://git.savannah.nongnu.org/git/exosip.git
synced 2026-01-12 00:19:10 +08:00
Dev for high load and performance:
* EXOSIP_OPT_SET_MAX_MESSAGE_TO_READ: set the number of message to read at once for each network processing. * EXOSIP_OPT_SET_MAX_READ_TIMEOUT: set the period in nano seconds during we read for sip message. * EXOSIP_OPT_GET_STATISTICS: retreive numerous statistics. * optimize all loops by using osip iterator to improve performance. Improve autotools, ./configure, Makefile.am * modify --enable-pthread options (sync with osip) * modify --enable-semaphore options (sync with osip) * better order of link/flags, avoid duplicate at compile/link time * rename -DHAVE_CARES_H to -DHAVE_ARES_H (real name of head)
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -19,11 +19,25 @@ eXosip2 (5.0.0)
|
||||
eXosip_publish returns a positive transaction id (tid) on success.
|
||||
note: eXosip_message_send_request was already returing the transaction id (tid) on success.
|
||||
* new API options:
|
||||
EXOSIP_OPT_SET_SIP_INSTANCE: define +sip.instance parameter in Contact headers
|
||||
EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: option to use/not use ephemeral port in Contact.
|
||||
EXOSIP_OPT_ENABLE_REUSE_TCP_PORT: option to reuse port.
|
||||
EXOSIP_OPT_AUTO_MASQUERADE_CONTACT: option to enable automatic masquerading for Contact headers.
|
||||
EXOSIP_OPT_UDP_LEARN_PORT: obsolete and will be removed in the future.
|
||||
* new API options: (high load traffic use-case: DO NOT USE FOR COMMON USAGE)
|
||||
EXOSIP_OPT_SET_MAX_MESSAGE_TO_READ: set the number of message to read at once for each network processing.
|
||||
EXOSIP_OPT_SET_MAX_READ_TIMEOUT: set the period in nano seconds during we read for sip message.
|
||||
EXOSIP_OPT_GET_STATISTICS: retreive numerous statistics.
|
||||
|
||||
* if a SUBSCRIBE is rejected, the context will be released automatically
|
||||
* rename usage of -DHAVE_CARES_H into -DHAVE_ARES_H real name of header.
|
||||
* remove warnings mainly related to socket API (getnameinfo/bind/accept/recv/connect/sendto)
|
||||
* rewrite/update autotools and ./configure options
|
||||
--enable-pthread=[autodetect|force]
|
||||
autodetect POSIX threads or force -DHAVE_PTHREAD [default=autodetect]
|
||||
--enable-semaphore=[autodetect|semaphore|sysv]
|
||||
select your prefered semaphore [default=autodetect].
|
||||
* rewrite all loop using iterator to improve performance (useful for high load traffic)
|
||||
* rewrite Via and Contact management: both will now contains the IP of the real network interface
|
||||
instead of the default one.
|
||||
* improve NAPTR failover, more reliable // add failover for 503 answer
|
||||
|
||||
167
configure.ac
167
configure.ac
@@ -1,5 +1,5 @@
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT([libeXosip2], [5.0.0])
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([libeXosip2],[5.0.0])
|
||||
AC_CONFIG_SRCDIR([include/eXosip2/eXosip.h])
|
||||
|
||||
AC_MSG_NOTICE([libeXosip2 The Extended Open SIP library.])
|
||||
@@ -28,80 +28,87 @@ AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
|
||||
dnl enable --enable-shared and --disable-shared options
|
||||
LT_AC_PROG_SED
|
||||
AC_PROG_LIBTOOL
|
||||
dnl Initialize libtool
|
||||
AC_PROG_SED
|
||||
LT_INIT
|
||||
|
||||
|
||||
#AC_ENABLE_SHARED(yes)
|
||||
|
||||
dnl declare --enable-* args and collect ac_help strings
|
||||
|
||||
AC_ARG_ENABLE(tools,
|
||||
[ --disable-tools compile tools programs (yes).],
|
||||
enable_tools=$enableval,enable_tools="yes")
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --disable-debug turn on debugging (yes).],
|
||||
enable_debug=$enableval,enable_debug="yes")
|
||||
|
||||
AC_ARG_ENABLE(trace,
|
||||
[ --disable-trace turn on trace (yes).],
|
||||
enable_trace=$enableval,enable_trace="yes")
|
||||
|
||||
AC_ARG_ENABLE(mpatrol,
|
||||
[ --enable-mpatrol turn on memory leak detection with patrol (no).],
|
||||
enable_mpatrol=$enableval,enable_mpatrol="no")
|
||||
[AS_HELP_STRING([--enable-mpatrol],
|
||||
[turn on memory leak detection with patrol @<:@default=no@:>@])],
|
||||
enable_mpatrol=$enableval,enable_mpatrol="no")
|
||||
|
||||
AC_ARG_ENABLE(gprof,
|
||||
[ --enable-gprof turn on profiling support.],
|
||||
enable_gprof=$enableval,enable_gprof="no")
|
||||
[AS_HELP_STRING([--enable-gprof],
|
||||
[turn on profiling support @<:@default=no@:>@])],
|
||||
enable_gprof=$enableval,enable_gprof="no")
|
||||
|
||||
dnl support for linux-thread or posix thread (pthread.h)
|
||||
AC_ARG_ENABLE(pthread,
|
||||
[ --enable-pthread enable support for POSIX threads. (autodetect)],
|
||||
enable_pthread=$enableval,enable_pthread="no")
|
||||
|
||||
dnl support for semaphore.h (linux/sun...)
|
||||
AC_ARG_ENABLE(semaphore,
|
||||
[ --enable-semaphore enable support for semaphore (semaphore.h)],
|
||||
enable_semaphore=$enableval,enable_semaphore="no")
|
||||
|
||||
dnl support for sysV semaphore in sys/sem.h (BSD/linux...)
|
||||
AC_ARG_ENABLE(sysv,
|
||||
[ --enable-sysv enable support for sysV semaphore (sys/sem.h).],
|
||||
enable_sysv=$enableval,enable_sysv="no")
|
||||
AC_ARG_ENABLE(trace,
|
||||
[AS_HELP_STRING([--enable-trace],
|
||||
[turn on trace @<:@default=yes@:>@])],
|
||||
enable_trace=$enableval,enable_trace="yes")
|
||||
|
||||
dnl minimize size of code.
|
||||
AC_ARG_ENABLE(minisize,
|
||||
[ --enable-minisize only compile minimal voip related code).],
|
||||
enable_minisize=$enableval,enable_minisize="no")
|
||||
[AS_HELP_STRING([--enable-minisize],
|
||||
[only compile minimal voip related code @<:@default=no@:>@])],
|
||||
enable_minisize=$enableval,enable_minisize="no")
|
||||
|
||||
dnl support for linux-thread or posix thread (pthread.h)
|
||||
AC_ARG_ENABLE(pthread,
|
||||
[AS_HELP_STRING([--enable-pthread=@<:@autodetect|force@:>@],
|
||||
[autodetect POSIX threads or force -DHAVE_PTHREAD @<:@default=autodetect@:>@])],
|
||||
enable_pthread=$enableval,enable_pthread="autodetect")
|
||||
|
||||
dnl support for semaphore.h (linux/sun...)
|
||||
dnl support for sysV semaphore in sys/sem.h (BSD/linux...)
|
||||
AC_ARG_ENABLE(semaphore,
|
||||
[AS_HELP_STRING([--enable-semaphore=@<:@autodetect|semaphore|sysv@:>@],
|
||||
[select your prefered semaphore @<:@default=autodetect@:>@.])],
|
||||
enable_semaphore=$enableval,enable_semaphore="autodetect")
|
||||
|
||||
AC_ARG_ENABLE(openssl,
|
||||
[AS_HELP_STRING([--enable-openssl],
|
||||
[enable support for openssl @<:@default=yes@:>@])],
|
||||
enable_openssl=$enableval,enable_openssl="yes")
|
||||
|
||||
dnl build with multithreaded support (need semaphore).
|
||||
AC_ARG_ENABLE(mt,
|
||||
[ --enable-mt compile eXosip2 without multi-thread support.],
|
||||
enable_mt=$enableval,enable_mt="yes")
|
||||
[AS_HELP_STRING([--enable-mt],
|
||||
[compile with multi-thread support @<:@default=yes@:>@])],
|
||||
enable_mt=$enableval,enable_mt="yes")
|
||||
|
||||
AC_ARG_ENABLE(srvrec,
|
||||
[AS_HELP_STRING([--enable-srvrec],
|
||||
[enable support for SRV records DNS queries @<:@default=yes@:>@])],
|
||||
enable_srvrec=$enableval,enable_srvrec="yes")
|
||||
|
||||
AC_ARG_ENABLE(tools,
|
||||
[AS_HELP_STRING([--enable-tools],
|
||||
[compile tools programs @<:@default=yes@:>@])],
|
||||
enable_tools=$enableval,enable_tools="yes")
|
||||
|
||||
dnl compile with mt support
|
||||
if test "x$enable_mt" = "xyes"; then
|
||||
if test "x$enable_pthread" = "xyes"; then
|
||||
EXOSIP_FLAGS="-DHAVE_PTHREAD"
|
||||
SIP_FSM_FLAGS="-DHAVE_PTHREAD"
|
||||
dnl FSM_LIB="-lpthread"
|
||||
if test "x$enable_pthread" = "xforce"; then
|
||||
AC_DEFINE(HAVE_PTHREAD)
|
||||
else
|
||||
ACX_PTHREAD()
|
||||
AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthreads support -use --enable-mt=no to disable or --enable-pthread=force to define HAVE_PTHREAD])])
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
CC="$PTHREAD_CC"
|
||||
fi
|
||||
else
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -DOSIP_MONOTHREAD"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test "x$enable_semaphore" = "xyes"; then
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -DHAVE_SEMAPHORE_H"
|
||||
AC_CHECK_HEADERS(semaphore.h)
|
||||
elif test "x$enable_sysv" = "xyes"; then
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -UHAVE_SEMAPHORE_H -DHAVE_SYS_SEM_H"
|
||||
AC_CHECK_HEADERS(sys/sem.h)
|
||||
if test "x$enable_semaphore" = "xsemaphore"; then
|
||||
AC_DEFINE(HAVE_SEMAPHORE_H)
|
||||
elif test "x$enable_semaphore" = "xsysv"; then
|
||||
AC_DEFINE(HAVE_SYS_SEM_H)
|
||||
else
|
||||
AC_CHECK_HEADERS(semaphore.h)
|
||||
AC_CHECK_HEADERS(sys/sem.h)
|
||||
@@ -110,7 +117,6 @@ fi
|
||||
if test "x$host_cpu" = "x$build_cpu"; then
|
||||
case $OS in
|
||||
linux*)
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -pedantic"
|
||||
;;
|
||||
irix*)
|
||||
;;
|
||||
@@ -124,7 +130,6 @@ if test "x$host_cpu" = "x$build_cpu"; then
|
||||
sunos*)
|
||||
;;
|
||||
darwin*)
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -pedantic"
|
||||
;;
|
||||
*mingw*)
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -D_WIN32_WINNT=0x0501"
|
||||
@@ -139,11 +144,6 @@ else
|
||||
AC_MSG_NOTICE([Cross compiling exosip.])
|
||||
fi
|
||||
|
||||
if test "x$enable_debug" = "xyes"; then
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -DENABLE_DEBUG -g"
|
||||
CFLAGS=`echo $CFLAGS | sed 's/-O.//'`
|
||||
fi
|
||||
|
||||
if test "x$enable_trace" = "xyes"; then
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -DENABLE_TRACE"
|
||||
fi
|
||||
@@ -160,6 +160,7 @@ fi
|
||||
if test "x$enable_minisize" = "xyes"; then
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -DMINISIZE"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(BUILD_MAXSIZE, test x$enable_minisize = xno)
|
||||
AM_CONDITIONAL(COMPILE_TOOLS, test "x$enable_tools" = "xyes")
|
||||
|
||||
@@ -179,15 +180,14 @@ case $OS in
|
||||
esac
|
||||
|
||||
AC_CHECK_LIB([cares], [ares_init],
|
||||
[AC_CHECK_HEADER(ares.h,
|
||||
[EXOSIP_LIB="$EXOSIP_LIB -lcares"
|
||||
EXOSIP_FLAGS="$EXOSIP_FLAGS -DHAVE_CARES_H"],
|
||||
[AC_CHECK_HEADERS(ares.h,
|
||||
[EXOSIP_LIB="$EXOSIP_LIB -lcares"],
|
||||
[AC_MSG_WARN([c-ares header files are not installed])])
|
||||
],
|
||||
[AC_MSG_WARN([c-ares library is not installed])]
|
||||
)
|
||||
|
||||
PKG_CHECK_MODULES(OSIP, libosip2 >= 4.1, [], [
|
||||
PKG_CHECK_MODULES(OSIP, libosip2 >= 5.0, [], [
|
||||
AC_MSG_WARN([assuming osip can be found in -I$includedir and -L$libdir])
|
||||
OSIP_CFLAGS='-I$(includedir) -I$(prefix)/include'
|
||||
OSIP_LIBS='-L$(libdir) -L$(prefix)/lib -losip2 -losipparser2'
|
||||
@@ -198,7 +198,7 @@ EXOSIP_FLAGS="$EXOSIP_FLAGS"
|
||||
AC_CACHE_CHECK([whether -Wall works], Wall_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wall"
|
||||
AC_TRY_COMPILE(, , Wall_cv_flag=yes, Wall_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wall_cv_flag=yes],[Wall_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -209,7 +209,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wcast-align works], Wcast_align_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wcast-align"
|
||||
AC_TRY_COMPILE(, , Wcast_align_cv_flag=yes, Wcast_align_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wcast_align_cv_flag=yes],[Wcast_align_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -220,7 +220,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wchar-subscripts works], Wchar_subscripts_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wchar-subscripts"
|
||||
AC_TRY_COMPILE(, , Wchar_subscripts_cv_flag=yes, Wchar_subscripts_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wchar_subscripts_cv_flag=yes],[Wchar_subscripts_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -231,7 +231,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wformat works], Wformat_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wformat"
|
||||
AC_TRY_COMPILE(, , Wformat_cv_flag=yes, Wformat_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wformat_cv_flag=yes],[Wformat_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -242,7 +242,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Winline works], Winline_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Winline"
|
||||
AC_TRY_COMPILE(, , Winline_cv_flag=yes, Winline_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Winline_cv_flag=yes],[Winline_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -253,7 +253,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wmissing-declarations works], Wmissing_declarations_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wmissing-declarations"
|
||||
AC_TRY_COMPILE(, , Wmissing_declarations_cv_flag=yes, Wmissing_declarations_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wmissing_declarations_cv_flag=yes],[Wmissing_declarations_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -264,7 +264,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wmissing-prototypes works], Wmissing_prototypes_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wmissing-prototypes"
|
||||
AC_TRY_COMPILE(, , Wmissing_prototypes_cv_flag=yes, Wmissing_prototypes_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wmissing_prototypes_cv_flag=yes],[Wmissing_prototypes_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -275,7 +275,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wnested-externs works], Wnested_externs_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wnested-externs"
|
||||
AC_TRY_COMPILE(, , Wnested_externs_cv_flag=yes, Wnested_externs_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wnested_externs_cv_flag=yes],[Wnested_externs_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -286,7 +286,7 @@ fi
|
||||
AC_CACHE_CHECK([whether -Wpointer-arith works], Wpointer_arith_cv_flag, [
|
||||
saved_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="-Wpointer-arith"
|
||||
AC_TRY_COMPILE(, , Wpointer_arith_cv_flag=yes, Wpointer_arith_cv_flag=no)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[Wpointer_arith_cv_flag=yes],[Wpointer_arith_cv_flag=no])
|
||||
CPPFLAGS=$saved_CPPFLAGS
|
||||
])
|
||||
|
||||
@@ -294,14 +294,9 @@ if test "x$Wpointer_arith_cv_flag" = xyes; then
|
||||
CPPFLAGS="$CPPFLAGS -Wpointer-arith"
|
||||
fi
|
||||
|
||||
TOOLS_LIBS=$TOOLS_LIBS
|
||||
AC_SUBST(TOOLS_LIBS)
|
||||
|
||||
AC_SUBST(EXOSIP_FLAGS)
|
||||
AC_SUBST(EXOSIP_LIB)
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(ctype.h)
|
||||
@@ -344,10 +339,6 @@ AC_CHECK_HEADERS([resolv.h], [], [],
|
||||
dnl check if we have the getifaddrs() sytem call
|
||||
AC_CHECK_FUNCS(getifaddrs)
|
||||
|
||||
AC_ARG_ENABLE(openssl,
|
||||
[ --enable-openssl enable support for openssl],
|
||||
enable_openssl=$enableval,enable_openssl="auto")
|
||||
|
||||
AS_IF([test "$enable_openssl" = "yes" -o "$enable_openssl" = "auto"],
|
||||
[PKG_CHECK_MODULES([SSL], [openssl],
|
||||
[EXOSIP_LIB="$EXOSIP_LIB $SSL_LIBS"]
|
||||
@@ -361,16 +352,11 @@ AS_IF([test "$enable_openssl" = "yes" -o "$enable_openssl" = "auto"],
|
||||
])
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(srvrec,
|
||||
[ --enable-srvrec enable support for SRV records DNS queries (yes) ],
|
||||
enable_srvrec=$enableval,enable_srvrec="yes")
|
||||
|
||||
if test "x$enable_srvrec" = "xyes" ; then
|
||||
CPPFLAGS="$CPPFLAGS -DSRV_RECORD"
|
||||
AC_DEFINE([SRV_RECORD], [1], [Defined to 1 if compiled with NAPTR and SRV support.])
|
||||
fi
|
||||
|
||||
AC_OUTPUT(
|
||||
Makefile
|
||||
AC_CONFIG_FILES([Makefile
|
||||
scripts/Makefile
|
||||
platform/Makefile
|
||||
platform/vsnet/Makefile
|
||||
@@ -381,5 +367,6 @@ AC_OUTPUT(
|
||||
help/Makefile
|
||||
help/doxygen/Makefile
|
||||
help/doxygen/doxygen.dox
|
||||
)
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
@@ -133,7 +133,9 @@ extern "C" {
|
||||
#define EXOSIP_OPT_SET_OC_PORT_RANGE (EXOSIP_OPT_BASE_OPTION+26) /**< int[2] *: set the port range (min, max) to bind for outbound connection */
|
||||
#define EXOSIP_OPT_REMOVE_PREROUTESET (EXOSIP_OPT_BASE_OPTION+27) /**< int *: 0: keep pre-route set in initial INVITE/SUBSCRIBE/REFER, 1 (default): remove pre-route set*/
|
||||
#define EXOSIP_OPT_SET_SIP_INSTANCE (EXOSIP_OPT_BASE_OPTION+28) /**< char *: define +sip.instance parameter in Contact headers (example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6) */
|
||||
|
||||
#define EXOSIP_OPT_SET_MAX_MESSAGE_TO_READ (EXOSIP_OPT_BASE_OPTION+29) /**< int: set the number of message to read at once for each network processing (high load traffic use-case: DO NOT USE FOR COMMON USAGE) */
|
||||
#define EXOSIP_OPT_SET_MAX_READ_TIMEOUT (EXOSIP_OPT_BASE_OPTION+30) /**< long int: set the period in nano seconds during we read for sip message. (high load traffic use-case: DO NOT USE FOR COMMON USAGE)*/
|
||||
|
||||
#define EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE (EXOSIP_OPT_BASE_OPTION+500) /**< int *: enable verification of certificate for TLS connection */
|
||||
#define EXOSIP_OPT_SET_TLS_CERTIFICATES_INFO (EXOSIP_OPT_BASE_OPTION+501) /**< eXosip_tls_ctx_t *: client and/or server certificate/ca-root/key info */
|
||||
#define EXOSIP_OPT_SET_TLS_CLIENT_CERTIFICATE_NAME (EXOSIP_OPT_BASE_OPTION+502) /**< char*: user can choose a specific certifcate present in Windows Certificate Store */
|
||||
@@ -143,6 +145,8 @@ extern "C" {
|
||||
#define EXOSIP_OPT_KEEP_ALIVE_OPTIONS_METHOD (EXOSIP_OPT_BASE_OPTION+1000)
|
||||
#define EXOSIP_OPT_SET_TSC_SERVER (EXOSIP_OPT_BASE_OPTION+1001) /**< void*: set the tsc tunnel handle */
|
||||
|
||||
#define EXOSIP_OPT_GET_STATISTICS (EXOSIP_OPT_BASE_OPTION+2000) /**< struct eXosip_stats*: retreive numerous statistics about transactions, registrations, calls, publications and subscriptions... */
|
||||
|
||||
/**
|
||||
* structure used to for inserting a DNS cache entry and avoid DNS resolution.
|
||||
* @struct eXosip_dns_cache
|
||||
@@ -166,6 +170,34 @@ extern "C" {
|
||||
int answer_code;
|
||||
};
|
||||
|
||||
#ifndef MINISIZE
|
||||
/**
|
||||
* Structure used to retrieve eXosip internal statistics.
|
||||
* Total numbers are provided since last start or restart of eXosip.
|
||||
* Average values are calculated over the last EXOSIP_STATS_PERIOD
|
||||
* which default to 3600 seconds.
|
||||
*
|
||||
* @struct eXosip_stats
|
||||
*/
|
||||
struct eXosip_stats
|
||||
{
|
||||
int allocated_transactions; /**< current number of allocated transactions. */
|
||||
float average_transactions; /**< average number of new transactions/hour. (default period: 1 hour) */
|
||||
int allocated_registrations; /**< current number of allocated registrations. (should remains 1 in standard usage) */
|
||||
float average_registrations; /**< average number of new registrations/hour. (default period: 1 hour) */
|
||||
int allocated_calls; /**< current number of allocated calls. */
|
||||
float average_calls; /**< average number of new calls/hour. (default period: 1 hour) */
|
||||
int allocated_publications; /**< current number of allocated publications. */
|
||||
float average_publications; /**< average number of new publication/hour. (default period: 1 hour) */
|
||||
int allocated_subscriptions; /**< current number of allocated outgoing subscriptions. */
|
||||
float average_subscriptions; /**< average number of new outgoing subscriptions/hour. (default period: 1 hour) */
|
||||
int allocated_insubscriptions; /**< current number of allocated incoming subscriptions. */
|
||||
float average_insubscriptions; /**< average number of new incoming subscriptions/hour. (default period: 1 hour) */
|
||||
|
||||
int reserved1[20]; /**< reserved for future usage without breaking ABI */
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set eXosip options.
|
||||
* See eXosip_option for available options.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
EXTRA_DIST = config.guess config.sub install-sh missing mkinstalldirs \
|
||||
ltmain.sh acx_pthread.m4 aclocal-include.m4
|
||||
ltmain.sh ax_pthread.m4 clocal-include.m4
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
dnl This macro figures out how to build C programs using POSIX
|
||||
dnl threads. It sets the PTHREAD_LIBS output variable to the threads
|
||||
dnl library and linker flags, and the PTHREAD_CFLAGS output variable
|
||||
dnl to any special C compiler flags that are needed. (The user can also
|
||||
dnl force certain compiler flags/libs to be tested by setting these
|
||||
dnl environment variables.)
|
||||
dnl
|
||||
dnl Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||
dnl multi-threaded programs (defaults to the value of CC otherwise).
|
||||
dnl (This is necessary on AIX to use the special cc_r compiler alias.)
|
||||
dnl
|
||||
dnl If you are only building threads programs, you may wish to
|
||||
dnl use these variables in your default LIBS, CFLAGS, and CC:
|
||||
dnl
|
||||
dnl LIBS="$PTHREAD_LIBS $LIBS"
|
||||
dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
dnl CC="$PTHREAD_CC"
|
||||
dnl
|
||||
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
|
||||
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE
|
||||
dnl to that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
dnl
|
||||
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
|
||||
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands
|
||||
dnl to run it if it is not found. If ACTION-IF-FOUND is not specified,
|
||||
dnl the default action will define HAVE_PTHREAD.
|
||||
dnl
|
||||
dnl Please let the authors know if this macro fails on any platform,
|
||||
dnl or if you have any other suggestions or comments. This macro was
|
||||
dnl based on work by SGJ on autoconf scripts for FFTW (www.fftw.org)
|
||||
dnl (with help from M. Frigo), as well as ac_pthread and hb_pthread
|
||||
dnl macros posted by AFC to the autoconf macro repository. We are also
|
||||
dnl grateful for the helpful feedback of numerous users.
|
||||
dnl
|
||||
dnl @version $Id: acx_pthread.m4,v 1.1.1.1 2003-03-11 21:23:07 aymeric Exp $
|
||||
dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Alejandro Forero Cuervo <bachue@bachue.com>
|
||||
|
||||
AC_DEFUN([ACX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
acx_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all.
|
||||
|
||||
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthread or
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
for flag in $acx_pthread_flags; do
|
||||
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||
PTHREAD_CFLAGS="$flag"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[acx_pthread_ok=yes])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: threads are created detached by default
|
||||
# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[int attr=PTHREAD_CREATE_JOINABLE;],
|
||||
ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
|
||||
if test x"$ok" = xunknown; then
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[int attr=PTHREAD_CREATE_UNDETACHED;],
|
||||
ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
|
||||
fi
|
||||
if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
|
||||
[Define to the necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
AC_MSG_RESULT(${ok})
|
||||
if test x"$ok" = xunknown; then
|
||||
AC_MSG_WARN([we do not know how to create joinable pthreads])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*-aix* | *-freebsd*) flag="-D_THREAD_SAFE";;
|
||||
*solaris* | alpha*-osf*) flag="-D_REENTRANT";;
|
||||
esac
|
||||
AC_MSG_RESULT(${flag})
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
# More AIX lossage: must compile with cc_r
|
||||
AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
|
||||
else
|
||||
PTHREAD_CC="$CC"
|
||||
fi
|
||||
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
AC_SUBST(PTHREAD_CC)
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$acx_pthread_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||
:
|
||||
else
|
||||
acx_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
|
||||
])dnl ACX_PTHREAD
|
||||
332
scripts/ax_pthread.m4
Normal file
332
scripts/ax_pthread.m4
Normal file
@@ -0,0 +1,332 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro figures out how to build C programs using POSIX threads. It
|
||||
# sets the PTHREAD_LIBS output variable to the threads library and linker
|
||||
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
|
||||
# flags that are needed. (The user can also force certain compiler
|
||||
# flags/libs to be tested by setting these environment variables.)
|
||||
#
|
||||
# Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||
# multi-threaded programs (defaults to the value of CC otherwise). (This
|
||||
# is necessary on AIX to use the special cc_r compiler alias.)
|
||||
#
|
||||
# NOTE: You are assumed to not only compile your program with these flags,
|
||||
# but also link it with them as well. e.g. you should link with
|
||||
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
||||
#
|
||||
# If you are only building threads programs, you may wish to use these
|
||||
# variables in your default LIBS, CFLAGS, and CC:
|
||||
#
|
||||
# LIBS="$PTHREAD_LIBS $LIBS"
|
||||
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
# CC="$PTHREAD_CC"
|
||||
#
|
||||
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
|
||||
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
|
||||
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
#
|
||||
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
|
||||
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
|
||||
# PTHREAD_CFLAGS.
|
||||
#
|
||||
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
|
||||
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
|
||||
# is not found. If ACTION-IF-FOUND is not specified, the default action
|
||||
# will define HAVE_PTHREAD.
|
||||
#
|
||||
# Please let the authors know if this macro fails on any platform, or if
|
||||
# you have any other suggestions or comments. This macro was based on work
|
||||
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
|
||||
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
|
||||
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
|
||||
# grateful for the helpful feedback of numerous users.
|
||||
#
|
||||
# Updated for Autoconf 2.68 by Daniel Richard G.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program 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 General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 21
|
||||
|
||||
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
|
||||
AC_DEFUN([AX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_LANG_PUSH([C])
|
||||
ax_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
if test x"$ax_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all, and "pthread-config"
|
||||
# which is a program returning the flags for the Pth emulation library.
|
||||
|
||||
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# ... -mt is also the pthreads flag for HP/aCC
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case ${host_os} in
|
||||
solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
|
||||
;;
|
||||
|
||||
darwin*)
|
||||
ax_pthread_flags="-pthread $ax_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Clang doesn't consider unrecognized options an error unless we specify
|
||||
# -Werror. We throw in some extra Clang-specific options to ensure that
|
||||
# this doesn't happen for GCC, which also accepts -Werror.
|
||||
|
||||
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
|
||||
save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_extra_flags="-Werror"
|
||||
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[ax_pthread_extra_flags=
|
||||
AC_MSG_RESULT([no])])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
if test x"$ax_pthread_ok" = xno; then
|
||||
for flag in $ax_pthread_flags; do
|
||||
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||
PTHREAD_CFLAGS="$flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
|
||||
if test x"$ax_pthread_config" = xno; then continue; fi
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
|
||||
static void routine(void *a) { a = 0; }
|
||||
static void *start_routine(void *a) { return a; }],
|
||||
[pthread_t th; pthread_attr_t attr;
|
||||
pthread_create(&th, 0, start_routine, 0);
|
||||
pthread_join(th, 0);
|
||||
pthread_attr_init(&attr);
|
||||
pthread_cleanup_push(routine, 0);
|
||||
pthread_cleanup_pop(0) /* ; */])],
|
||||
[ax_pthread_ok=yes],
|
||||
[])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
if test "x$ax_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$ax_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
attr_name=unknown
|
||||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[int attr = $attr; return attr /* ; */])],
|
||||
[attr_name=$attr; break],
|
||||
[])
|
||||
done
|
||||
AC_MSG_RESULT([$attr_name])
|
||||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case ${host_os} in
|
||||
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
|
||||
osf* | hpux*) flag="-D_REENTRANT";;
|
||||
solaris*)
|
||||
if test "$GCC" = "yes"; then
|
||||
flag="-D_REENTRANT"
|
||||
else
|
||||
# TODO: What about Clang on Solaris?
|
||||
flag="-mt -D_REENTRANT"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$flag])
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT], [
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
|
||||
[[int i = PTHREAD_PRIO_INHERIT;]])],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=no])
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
|
||||
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
# More AIX lossage: compile with *_r variant
|
||||
if test "x$GCC" != xyes; then
|
||||
case $host_os in
|
||||
aix*)
|
||||
AS_CASE(["x/$CC"],
|
||||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
|
||||
[#handle absolute path differently from PATH based program lookup
|
||||
AS_CASE(["x$CC"],
|
||||
[x/*],
|
||||
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
|
||||
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
|
||||
|
||||
AC_SUBST([PTHREAD_LIBS])
|
||||
AC_SUBST([PTHREAD_CFLAGS])
|
||||
AC_SUBST([PTHREAD_CC])
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$ax_pthread_ok" = xyes; then
|
||||
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
|
||||
:
|
||||
else
|
||||
ax_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_POP
|
||||
])dnl AX_PTHREAD
|
||||
@@ -9,7 +9,7 @@ lib_LTLIBRARIES = libeXosip2.la
|
||||
# -Wstrict-prototypes
|
||||
# -Werror
|
||||
#
|
||||
AM_CFLAGS = @EXOSIP_FLAGS@ @CFLAGS@ @PTHREAD_CFLAGS@
|
||||
AM_CFLAGS = $(EXOSIP_FLAGS)
|
||||
|
||||
libeXosip2_la_SOURCES = \
|
||||
eXosip.c eXconf.c \
|
||||
@@ -46,6 +46,6 @@ jpublish.c sdp_offans.c
|
||||
endif
|
||||
|
||||
libeXosip2_la_LDFLAGS = -version-info $(LIBEXOSIP_SO_VERSION) -no-undefined
|
||||
libeXosip2_la_LIBADD = @EXOSIP_LIB@ @PTHREAD_LIBS@ $(OSIP_LIBS)
|
||||
libeXosip2_la_LIBADD = $(EXOSIP_LIB) $(OSIP_LIBS)
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include $(OSIP_CFLAGS)
|
||||
|
||||
142
src/eXcall_api.c
142
src/eXcall_api.c
@@ -133,26 +133,25 @@ _eXosip_call_transaction_find (struct eXosip_t *excontext, int tid, eXosip_call_
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
for (*jd = (*jc)->c_dialogs; *jd != NULL; *jd = (*jd)->next) {
|
||||
osip_transaction_t *transaction;
|
||||
int pos = 0;
|
||||
osip_list_iterator_t it;
|
||||
osip_transaction_t* transaction;
|
||||
|
||||
while (!osip_list_eol ((*jd)->d_inc_trs, pos)) {
|
||||
transaction = (osip_transaction_t *) osip_list_get ((*jd)->d_inc_trs, pos);
|
||||
transaction = (osip_transaction_t*)osip_list_get_first((*jd)->d_inc_trs, &it);
|
||||
while (transaction != OSIP_SUCCESS) {
|
||||
if (transaction != NULL && transaction->transactionid == tid) {
|
||||
*tr = transaction;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
transaction = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol ((*jd)->d_out_trs, pos)) {
|
||||
transaction = (osip_transaction_t *) osip_list_get ((*jd)->d_out_trs, pos);
|
||||
transaction = (osip_transaction_t*)osip_list_get_first((*jd)->d_out_trs, &it);
|
||||
while (transaction != OSIP_SUCCESS) {
|
||||
if (transaction != NULL && transaction->transactionid == tid) {
|
||||
*tr = transaction;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
transaction = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,7 +248,7 @@ eXosip_call_send_initial_invite (struct eXosip_t *excontext, osip_message_t * in
|
||||
return OSIP_BADPARAMETER;
|
||||
}
|
||||
|
||||
i = _eXosip_call_init (&jc);
|
||||
i = _eXosip_call_init (excontext, &jc);
|
||||
if (i != 0) {
|
||||
osip_message_free (invite);
|
||||
return i;
|
||||
@@ -718,6 +717,37 @@ eXosip_call_build_answer (struct eXosip_t *excontext, int tid, int status, osip_
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
static osip_header_t *
|
||||
_eXosip_header_strcasestr(osip_message_t *message, const char *hname, const char *hname_short, const char *value) {
|
||||
osip_header_t *header;
|
||||
int i;
|
||||
i = osip_message_header_get_byname (message, hname, 0, &header);
|
||||
while (i >= 0) {
|
||||
if (header == NULL)
|
||||
break;
|
||||
if (header->hvalue != NULL && osip_strcasestr (header->hvalue, value) != NULL) {
|
||||
/*found */
|
||||
break;
|
||||
}
|
||||
header = NULL;
|
||||
i = osip_message_header_get_byname (message, hname, i + 1, &header);
|
||||
}
|
||||
if (header == NULL) {
|
||||
i = osip_message_header_get_byname (message, hname_short, 0, &header);
|
||||
while (i >= 0) {
|
||||
if (header == NULL)
|
||||
break;
|
||||
if (header->hvalue != NULL && osip_strcasestr (header->hvalue, value) != NULL) {
|
||||
/*found */
|
||||
break;
|
||||
}
|
||||
header = NULL;
|
||||
i = osip_message_header_get_byname (message, hname_short, i + 1, &header);
|
||||
}
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
int
|
||||
eXosip_call_send_answer (struct eXosip_t *excontext, int tid, int status, osip_message_t * answer)
|
||||
{
|
||||
@@ -779,34 +809,10 @@ eXosip_call_send_answer (struct eXosip_t *excontext, int tid, int status, osip_m
|
||||
|| 0 == osip_strcasecmp (tr->orig_request->sip_method, "UPDATE")) {
|
||||
if (MSG_IS_STATUS_2XX (answer) && jd != NULL) {
|
||||
osip_header_t *supported = NULL;
|
||||
int i = 0;
|
||||
|
||||
/* look for timer in supported header: must be added by user-application */
|
||||
supported = _eXosip_header_strcasestr(answer, "supported", "k", "timer");
|
||||
|
||||
i = osip_message_header_get_byname (answer, "supported", 0, &supported);
|
||||
while (i >= 0) {
|
||||
if (supported == NULL)
|
||||
break;
|
||||
if (supported->hvalue != NULL && strstr (supported->hvalue, "timer") != NULL) {
|
||||
/*found */
|
||||
break;
|
||||
}
|
||||
supported = NULL;
|
||||
i = osip_message_header_get_byname (answer, "supported", i + 1, &supported);
|
||||
}
|
||||
if (supported == NULL) {
|
||||
i = osip_message_header_get_byname (answer, "k", 0, &supported);
|
||||
while (i >= 0) {
|
||||
if (supported == NULL)
|
||||
break;
|
||||
if (supported->hvalue != NULL && strstr (supported->hvalue, "timer") != NULL) {
|
||||
/*found */
|
||||
break;
|
||||
}
|
||||
supported = NULL;
|
||||
i = osip_message_header_get_byname (answer, "k", i + 1, &supported);
|
||||
}
|
||||
}
|
||||
if (supported != NULL) { /* timer is supported */
|
||||
/* copy session-expires */
|
||||
/* add refresher=uas, if it's not already there */
|
||||
@@ -818,7 +824,7 @@ eXosip_call_send_answer (struct eXosip_t *excontext, int tid, int status, osip_m
|
||||
if (se_exp != NULL) {
|
||||
osip_header_t *cp = NULL;
|
||||
|
||||
i = osip_header_clone (se_exp, &cp);
|
||||
osip_header_clone (se_exp, &cp);
|
||||
if (cp != NULL) {
|
||||
osip_content_disposition_t *exp_h = NULL;
|
||||
|
||||
@@ -864,30 +870,7 @@ eXosip_call_send_answer (struct eXosip_t *excontext, int tid, int status, osip_m
|
||||
|
||||
|
||||
/* add Require only if remote UA support "timer" */
|
||||
i = osip_message_header_get_byname (tr->orig_request, "supported", 0, &supported);
|
||||
while (i >= 0) {
|
||||
if (supported == NULL)
|
||||
break;
|
||||
if (supported->hvalue != NULL && strstr (supported->hvalue, "timer") != NULL) {
|
||||
/*found */
|
||||
break;
|
||||
}
|
||||
supported = NULL;
|
||||
i = osip_message_header_get_byname (tr->orig_request, "supported", i + 1, &supported);
|
||||
}
|
||||
if (supported == NULL) {
|
||||
i = osip_message_header_get_byname (tr->orig_request, "k", 0, &supported);
|
||||
while (i >= 0) {
|
||||
if (supported == NULL)
|
||||
break;
|
||||
if (supported->hvalue != NULL && strstr (supported->hvalue, "timer") != NULL) {
|
||||
/*found */
|
||||
break;
|
||||
}
|
||||
supported = NULL;
|
||||
i = osip_message_header_get_byname (tr->orig_request, "k", i + 1, &supported);
|
||||
}
|
||||
}
|
||||
supported = _eXosip_header_strcasestr(tr->orig_request, "supported", "k", "timer");
|
||||
if (supported != NULL) { /* timer is supported */
|
||||
osip_message_set_header (answer, "Require", "timer");
|
||||
}
|
||||
@@ -1034,6 +1017,7 @@ eXosip_call_terminate_with_reason (struct eXosip_t *excontext, int cid, int did,
|
||||
int
|
||||
eXosip_call_build_prack (struct eXosip_t *excontext, int tid, osip_message_t *response1xx, osip_message_t ** prack)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
eXosip_dialog_t *jd = NULL;
|
||||
eXosip_call_t *jc = NULL;
|
||||
osip_transaction_t *tr = NULL;
|
||||
@@ -1042,7 +1026,6 @@ eXosip_call_build_prack (struct eXosip_t *excontext, int tid, osip_message_t *re
|
||||
|
||||
osip_header_t *rseq;
|
||||
int i;
|
||||
int pos;
|
||||
|
||||
*prack = NULL;
|
||||
|
||||
@@ -1075,10 +1058,8 @@ eXosip_call_build_prack (struct eXosip_t *excontext, int tid, osip_message_t *re
|
||||
memset (tmp, '\0', sizeof (tmp));
|
||||
snprintf (tmp, 127, "%s %s %s", rseq->hvalue, tr->orig_request->cseq->number, tr->orig_request->cseq->method);
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
old_prack_tr = (osip_transaction_t *) osip_list_get (jd->d_out_trs, pos);
|
||||
|
||||
old_prack_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (old_prack_tr != NULL) {
|
||||
if (old_prack_tr != NULL && old_prack_tr->orig_request != NULL && 0 == osip_strcasecmp (old_prack_tr->orig_request->sip_method, "PRACK")) {
|
||||
osip_header_t *rack_header = NULL;
|
||||
|
||||
@@ -1088,7 +1069,7 @@ eXosip_call_build_prack (struct eXosip_t *excontext, int tid, osip_message_t *re
|
||||
return OSIP_WRONG_STATE;
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
old_prack_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1182,7 +1163,6 @@ _eXosip_call_retry_request (struct eXosip_t *excontext, eXosip_call_t * jc, eXos
|
||||
int cseq;
|
||||
osip_via_t *via;
|
||||
osip_contact_t *co;
|
||||
int pos;
|
||||
int i;
|
||||
|
||||
if (jc == NULL)
|
||||
@@ -1208,11 +1188,10 @@ _eXosip_call_retry_request (struct eXosip_t *excontext, eXosip_call_t * jc, eXos
|
||||
}
|
||||
|
||||
if (MSG_IS_STATUS_3XX (out_tr->last_response)) {
|
||||
co = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (&out_tr->last_response->contacts, pos)) {
|
||||
co = (osip_contact_t *) osip_list_get (&out_tr->last_response->contacts, pos);
|
||||
if (co != NULL && co->url != NULL) {
|
||||
osip_list_iterator_t it;
|
||||
co = (osip_contact_t*)osip_list_get_first(&out_tr->last_response->contacts, &it);
|
||||
while (co != NULL) {
|
||||
if (co->url != NULL && (osip_strcasestr(co->url->scheme, "sip")!=NULL || osip_strcasestr(co->url->scheme, "tel")!=NULL)) {
|
||||
/* check tranport? */
|
||||
osip_uri_param_t *u_param;
|
||||
|
||||
@@ -1226,13 +1205,12 @@ _eXosip_call_retry_request (struct eXosip_t *excontext, eXosip_call_t * jc, eXos
|
||||
break; /* transport param in uri & match our protocol */
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
co = NULL;
|
||||
co = (osip_contact_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (co == NULL || co->url == NULL) {
|
||||
osip_message_free (msg);
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: contact header\n"));
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: no contact header usable for SIP redirection\n"));
|
||||
return OSIP_SYNTAXERROR;
|
||||
}
|
||||
|
||||
@@ -1272,21 +1250,17 @@ _eXosip_call_retry_request (struct eXosip_t *excontext, eXosip_call_t * jc, eXos
|
||||
|
||||
/* support for diversions headers/draft! */
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol (&out_tr->last_response->headers, pos)) {
|
||||
osip_header_t *head = (osip_header_t*)osip_list_get_first(&out_tr->last_response->headers, &it);
|
||||
while (head != NULL) {
|
||||
osip_header_t *copy = NULL;
|
||||
osip_header_t *head = osip_list_get (&out_tr->last_response->headers, pos);
|
||||
|
||||
if (head != NULL && 0 == osip_strcasecmp (head->hname, "diversion")) {
|
||||
if (0 == osip_strcasecmp (head->hname, "diversion")) {
|
||||
i = osip_header_clone (head, ©);
|
||||
if (i == 0) {
|
||||
osip_list_add (&msg->headers, copy, count);
|
||||
count++;
|
||||
osip_list_add (&msg->headers, copy, -1);
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
head = (osip_header_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
242
src/eXconf.c
242
src/eXconf.c
@@ -129,8 +129,8 @@ eXosip_set_user_agent (struct eXosip_t *excontext, const char *user_agent)
|
||||
excontext->user_agent = osip_strdup (user_agent);
|
||||
}
|
||||
|
||||
void
|
||||
_eXosip_kill_transaction (osip_list_t * transactions)
|
||||
static void
|
||||
_eXosip_kill_transaction (struct eXosip_t *excontext, osip_list_t * transactions)
|
||||
{
|
||||
osip_transaction_t *transaction;
|
||||
|
||||
@@ -141,12 +141,8 @@ _eXosip_kill_transaction (osip_list_t * transactions)
|
||||
}
|
||||
|
||||
while (!osip_list_eol (transactions, 0)) {
|
||||
transaction = osip_list_get (transactions, 0);
|
||||
|
||||
_eXosip_delete_reserved (transaction);
|
||||
_eXosip_dnsutils_release (transaction->naptr_record);
|
||||
transaction->naptr_record = NULL;
|
||||
osip_transaction_free (transaction);
|
||||
transaction = (osip_transaction_t *)osip_list_get (transactions, 0);
|
||||
_eXosip_transaction_free (excontext, transaction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,25 +230,15 @@ eXosip_quit (struct eXosip_t *excontext)
|
||||
|
||||
if (tr->state == IST_TERMINATED || tr->state == ICT_TERMINATED || tr->state == NICT_TERMINATED || tr->state == NIST_TERMINATED) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "Release a terminated transaction\n"));
|
||||
osip_list_remove (&excontext->j_transactions, 0);
|
||||
_eXosip_delete_reserved (tr);
|
||||
_eXosip_dnsutils_release (tr->naptr_record);
|
||||
tr->naptr_record = NULL;
|
||||
osip_transaction_free (tr);
|
||||
}
|
||||
else {
|
||||
osip_list_remove (&excontext->j_transactions, 0);
|
||||
_eXosip_delete_reserved (tr);
|
||||
_eXosip_dnsutils_release (tr->naptr_record);
|
||||
tr->naptr_record = NULL;
|
||||
osip_transaction_free (tr);
|
||||
}
|
||||
osip_list_remove (&excontext->j_transactions, 0);
|
||||
_eXosip_transaction_free (excontext, tr);
|
||||
}
|
||||
|
||||
_eXosip_kill_transaction (&excontext->j_osip->osip_ict_transactions);
|
||||
_eXosip_kill_transaction (&excontext->j_osip->osip_nict_transactions);
|
||||
_eXosip_kill_transaction (&excontext->j_osip->osip_ist_transactions);
|
||||
_eXosip_kill_transaction (&excontext->j_osip->osip_nist_transactions);
|
||||
_eXosip_kill_transaction (excontext, &excontext->j_osip->osip_ict_transactions);
|
||||
_eXosip_kill_transaction (excontext, &excontext->j_osip->osip_nict_transactions);
|
||||
_eXosip_kill_transaction (excontext, &excontext->j_osip->osip_ist_transactions);
|
||||
_eXosip_kill_transaction (excontext, &excontext->j_osip->osip_nist_transactions);
|
||||
osip_release (excontext->j_osip);
|
||||
|
||||
{
|
||||
@@ -286,6 +272,13 @@ eXosip_quit (struct eXosip_t *excontext)
|
||||
if (excontext->eXtl_transport.tl_free != NULL)
|
||||
excontext->eXtl_transport.tl_free (excontext);
|
||||
|
||||
_eXosip_counters_free(&excontext->average_transactions);
|
||||
_eXosip_counters_free(&excontext->average_registrations);
|
||||
_eXosip_counters_free(&excontext->average_calls);
|
||||
_eXosip_counters_free(&excontext->average_publications);
|
||||
_eXosip_counters_free(&excontext->average_subscriptions);
|
||||
_eXosip_counters_free(&excontext->average_insubscriptions);
|
||||
|
||||
memset (excontext, 0, sizeof (eXosip_t));
|
||||
excontext->j_stop_ua = -1;
|
||||
|
||||
@@ -397,7 +390,7 @@ eXosip_find_free_port (struct eXosip_t *excontext, int free_port, int transport)
|
||||
#endif /* IPV6_V6ONLY */
|
||||
}
|
||||
|
||||
res1 = bind (sock, curinfo_rtp->ai_addr, curinfo_rtp->ai_addrlen);
|
||||
res1 = bind (sock, curinfo_rtp->ai_addr, (socklen_t)curinfo_rtp->ai_addrlen);
|
||||
if (res1 < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family));
|
||||
close (sock);
|
||||
@@ -440,7 +433,7 @@ eXosip_find_free_port (struct eXosip_t *excontext, int free_port, int transport)
|
||||
}
|
||||
|
||||
|
||||
res1 = bind (sock, curinfo_rtcp->ai_addr, curinfo_rtcp->ai_addrlen);
|
||||
res1 = bind (sock, curinfo_rtcp->ai_addr, (socklen_t)curinfo_rtcp->ai_addrlen);
|
||||
if (res1 < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family));
|
||||
close (sock);
|
||||
@@ -499,7 +492,7 @@ eXosip_find_free_port (struct eXosip_t *excontext, int free_port, int transport)
|
||||
#endif /* IPV6_V6ONLY */
|
||||
}
|
||||
|
||||
res1 = bind (sock, curinfo_rtp->ai_addr, curinfo_rtp->ai_addrlen);
|
||||
res1 = bind (sock, curinfo_rtp->ai_addr, (socklen_t)curinfo_rtp->ai_addrlen);
|
||||
if (res1 < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family));
|
||||
close (sock);
|
||||
@@ -647,6 +640,14 @@ eXosip_init (struct eXosip_t *excontext)
|
||||
|
||||
memset (excontext, 0, sizeof (eXosip_t));
|
||||
|
||||
_eXosip_counters_init(&excontext->average_transactions, 0, 0);
|
||||
_eXosip_counters_init(&excontext->average_registrations, 0, 0);
|
||||
_eXosip_counters_init(&excontext->average_calls, 0, 0);
|
||||
_eXosip_counters_init(&excontext->average_publications, 0, 0);
|
||||
_eXosip_counters_init(&excontext->average_subscriptions, 0, 0);
|
||||
_eXosip_counters_init(&excontext->average_insubscriptions, 0, 0);
|
||||
|
||||
excontext->max_message_to_read=1;
|
||||
excontext->dscp = 0x1A;
|
||||
|
||||
snprintf (excontext->ipv4_for_gateway, 256, "%s", "217.12.3.11");
|
||||
@@ -662,7 +663,6 @@ eXosip_init (struct eXosip_t *excontext)
|
||||
i = WSAStartup (wVersionRequested, &wsaData);
|
||||
if (i != 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Unable to initialize WINSOCK, reason: %d\n", i));
|
||||
/* return -1; It might be already initilized?? */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -753,45 +753,50 @@ eXosip_execute (struct eXosip_t *excontext)
|
||||
int i;
|
||||
|
||||
#ifndef OSIP_MONOTHREAD
|
||||
osip_timers_gettimeout (excontext->j_osip, &lower_tv);
|
||||
if (lower_tv.tv_sec > 10) {
|
||||
eXosip_reg_t *jr;
|
||||
time_t now;
|
||||
|
||||
osip_compensatetime ();
|
||||
|
||||
now = osip_getsystemtime (NULL);
|
||||
|
||||
lower_tv.tv_sec = 10;
|
||||
|
||||
eXosip_lock (excontext);
|
||||
for (jr = excontext->j_reg; jr != NULL; jr = jr->next) {
|
||||
if (jr->r_id >= 1 && jr->r_last_tr != NULL) {
|
||||
if (jr->r_reg_period == 0) {
|
||||
/* skip refresh! */
|
||||
}
|
||||
else if (now - jr->r_last_tr->birth_time > jr->r_reg_period - (jr->r_reg_period / 10)) {
|
||||
/* automatic refresh at "timeout - 10%" */
|
||||
lower_tv.tv_sec = 1;
|
||||
}
|
||||
if (excontext->max_read_timeout>0) {
|
||||
lower_tv.tv_sec=0;
|
||||
lower_tv.tv_usec=excontext->max_read_timeout;
|
||||
} else {
|
||||
osip_timers_gettimeout (excontext->j_osip, &lower_tv);
|
||||
if (lower_tv.tv_sec > 10) {
|
||||
eXosip_reg_t *jr;
|
||||
time_t now;
|
||||
|
||||
osip_compensatetime ();
|
||||
|
||||
now = osip_getsystemtime (NULL);
|
||||
|
||||
lower_tv.tv_sec = 10;
|
||||
|
||||
eXosip_lock (excontext);
|
||||
for (jr = excontext->j_reg; jr != NULL; jr = jr->next) {
|
||||
if (jr->r_id >= 1 && jr->r_last_tr != NULL) {
|
||||
if (jr->r_reg_period == 0) {
|
||||
/* skip refresh! */
|
||||
}
|
||||
else if (now - jr->r_last_tr->birth_time > jr->r_reg_period - (jr->r_reg_period / 10)) {
|
||||
/* automatic refresh at "timeout - 10%" */
|
||||
lower_tv.tv_sec = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
eXosip_unlock (excontext);
|
||||
|
||||
if (lower_tv.tv_sec == 1) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: Reseting timer to 1s before waking up!\n"));
|
||||
}
|
||||
else {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: Reseting timer to 10s before waking up!\n"));
|
||||
}
|
||||
}
|
||||
eXosip_unlock (excontext);
|
||||
|
||||
if (lower_tv.tv_sec == 1) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: Reseting timer to 1s before waking up!\n"));
|
||||
}
|
||||
else {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: Reseting timer to 10s before waking up!\n"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* add a small amount of time on windows to avoid waking up too early. (probably a bad time precision) */
|
||||
if (lower_tv.tv_usec < 990000)
|
||||
lower_tv.tv_usec += 10000; /* add 10ms */
|
||||
else {
|
||||
lower_tv.tv_usec = 10000; /* add 10ms */
|
||||
lower_tv.tv_sec++;
|
||||
/* add a small amount of time on windows to avoid waking up too early. (probably a bad time precision) */
|
||||
if (lower_tv.tv_usec < 990000)
|
||||
lower_tv.tv_usec += 10000; /* add 10ms */
|
||||
else {
|
||||
lower_tv.tv_usec = 10000; /* add 10ms */
|
||||
lower_tv.tv_sec++;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: timer sec:%i usec:%i!\n", lower_tv.tv_sec, lower_tv.tv_usec));
|
||||
@@ -801,7 +806,7 @@ eXosip_execute (struct eXosip_t *excontext)
|
||||
lower_tv.tv_sec = 0;
|
||||
lower_tv.tv_usec = 0;
|
||||
#endif
|
||||
i = _eXosip_read_message (excontext, 1, (int) lower_tv.tv_sec, (int) lower_tv.tv_usec);
|
||||
i = _eXosip_read_message (excontext, excontext->max_message_to_read, (int) lower_tv.tv_sec, (int) lower_tv.tv_usec);
|
||||
|
||||
if (i == -2000) {
|
||||
return -2000;
|
||||
@@ -1121,6 +1126,35 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value)
|
||||
excontext->oc_local_port_range[1] = range[1];
|
||||
break;
|
||||
}
|
||||
case EXOSIP_OPT_SET_MAX_MESSAGE_TO_READ:
|
||||
{
|
||||
excontext->max_message_to_read = *((int *) value);
|
||||
break;
|
||||
}
|
||||
case EXOSIP_OPT_SET_MAX_READ_TIMEOUT:
|
||||
{
|
||||
excontext->max_read_timeout= *((long int *) value);
|
||||
break;
|
||||
}
|
||||
case EXOSIP_OPT_GET_STATISTICS:
|
||||
{
|
||||
struct eXosip_stats *stats = (struct eXosip_stats *) value;
|
||||
struct timeval now;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_transactions, 0, &now);
|
||||
_eXosip_counters_update(&excontext->average_registrations, 0, &now);
|
||||
_eXosip_counters_update(&excontext->average_calls, 0, &now);
|
||||
_eXosip_counters_update(&excontext->average_publications, 0, &now);
|
||||
_eXosip_counters_update(&excontext->average_subscriptions, 0, &now);
|
||||
_eXosip_counters_update(&excontext->average_insubscriptions, 0, &now);
|
||||
excontext->statistics.average_transactions=excontext->average_transactions.current_average;
|
||||
excontext->statistics.average_registrations=excontext->average_registrations.current_average;
|
||||
excontext->statistics.average_calls=excontext->average_calls.current_average;
|
||||
excontext->statistics.average_publications=excontext->average_publications.current_average;
|
||||
excontext->statistics.average_subscriptions=excontext->average_subscriptions.current_average;
|
||||
excontext->statistics.average_insubscriptions=excontext->average_insubscriptions.current_average;
|
||||
memcpy(stats, &excontext->statistics, sizeof(struct eXosip_stats));
|
||||
}
|
||||
default:
|
||||
return OSIP_BADPARAMETER;
|
||||
}
|
||||
@@ -1191,3 +1225,81 @@ _eXosip_thread (void *arg)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MINISIZE
|
||||
|
||||
void _eXosip_counters_init(struct eXosip_counters *bw_stats, int period, int interval) {
|
||||
bw_stats->period=period;
|
||||
bw_stats->interval=interval;
|
||||
if (bw_stats->period<=0)
|
||||
bw_stats->period=EXOSIP_STATS_PERIOD;
|
||||
if (bw_stats->interval<=0)
|
||||
bw_stats->interval=EXOSIP_STATS_INTERVAL;
|
||||
|
||||
bw_stats->num_entries = (bw_stats->period/bw_stats->interval);
|
||||
bw_stats->values = (unsigned short*)osip_malloc(sizeof(unsigned short)*bw_stats->num_entries);
|
||||
memset(bw_stats->values, 0, sizeof(unsigned short)*bw_stats->num_entries);
|
||||
bw_stats->times = (struct timeval*)osip_malloc(sizeof(struct timeval)*bw_stats->num_entries);
|
||||
memset(bw_stats->times, 0, sizeof(struct timeval)*bw_stats->num_entries);
|
||||
}
|
||||
|
||||
void _eXosip_counters_free(struct eXosip_counters *bw_stats) {
|
||||
osip_free(bw_stats->values);
|
||||
osip_free(bw_stats->times);
|
||||
bw_stats->values=NULL;
|
||||
bw_stats->times=NULL;
|
||||
bw_stats->total_values=0;
|
||||
bw_stats->index_last=0;
|
||||
}
|
||||
|
||||
static float compute_average(struct timeval *orig, unsigned int values){
|
||||
struct timeval current;
|
||||
float time;
|
||||
if (values==0) return 0;
|
||||
osip_gettimeofday(¤t,NULL);
|
||||
time=(float)(current.tv_sec - orig->tv_sec)/3600; /* calculate num/hour */
|
||||
if (time==0) return 0;
|
||||
return ((float)values)/(time+0.000001f);
|
||||
}
|
||||
|
||||
void _eXosip_counters_update(struct eXosip_counters *bw_stats, int nvalues, struct timeval *now) {
|
||||
unsigned long interval;
|
||||
unsigned long last_interval;
|
||||
if (bw_stats->values==NULL)
|
||||
_eXosip_counters_init(bw_stats, 0, 0);
|
||||
|
||||
interval = (now->tv_sec-bw_stats->times[0].tv_sec);
|
||||
if (bw_stats->index_last>0 && interval<=bw_stats->interval) {
|
||||
bw_stats->values[0]+=nvalues;
|
||||
bw_stats->total_values+=nvalues;
|
||||
bw_stats->current_average = compute_average(&bw_stats->times[bw_stats->index_last-1], bw_stats->total_values);
|
||||
return;
|
||||
}
|
||||
|
||||
last_interval=0;
|
||||
while (bw_stats->index_last>0) {
|
||||
last_interval = (now->tv_sec-bw_stats->times[bw_stats->index_last-1].tv_sec);
|
||||
if (last_interval<bw_stats->period && bw_stats->index_last<bw_stats->num_entries)
|
||||
break;
|
||||
bw_stats->total_values-=bw_stats->values[bw_stats->index_last-1];
|
||||
bw_stats->index_last--;
|
||||
}
|
||||
|
||||
if (nvalues>0) {
|
||||
bw_stats->total_values+=nvalues;
|
||||
memmove(((unsigned char*)bw_stats->values)+sizeof(unsigned short), bw_stats->values, sizeof(unsigned short)*(bw_stats->index_last));
|
||||
memmove(((unsigned char*)bw_stats->times)+sizeof(struct timeval), bw_stats->times, sizeof(struct timeval)*(bw_stats->index_last));
|
||||
bw_stats->values[0]=nvalues;
|
||||
bw_stats->times[0].tv_sec = now->tv_sec;
|
||||
bw_stats->times[0].tv_usec = now->tv_usec;
|
||||
bw_stats->index_last++;
|
||||
}
|
||||
|
||||
if (bw_stats->index_last>0) {
|
||||
bw_stats->current_average = compute_average(&bw_stats->times[bw_stats->index_last-1], bw_stats->total_values);
|
||||
} else {
|
||||
bw_stats->current_average=0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -49,26 +49,25 @@ _eXosip_insubscription_transaction_find (struct eXosip_t *excontext, int tid, eX
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
for (*jd = (*jn)->n_dialogs; *jd != NULL; *jd = (*jd)->next) {
|
||||
osip_transaction_t *transaction;
|
||||
int pos = 0;
|
||||
osip_list_iterator_t it;
|
||||
osip_transaction_t* transaction;
|
||||
|
||||
while (!osip_list_eol ((*jd)->d_inc_trs, pos)) {
|
||||
transaction = (osip_transaction_t *) osip_list_get ((*jd)->d_inc_trs, pos);
|
||||
transaction = (osip_transaction_t*)osip_list_get_first((*jd)->d_inc_trs, &it);
|
||||
while (transaction != OSIP_SUCCESS) {
|
||||
if (transaction != NULL && transaction->transactionid == tid) {
|
||||
*tr = transaction;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
transaction = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol ((*jd)->d_out_trs, pos)) {
|
||||
transaction = (osip_transaction_t *) osip_list_get ((*jd)->d_out_trs, pos);
|
||||
transaction = (osip_transaction_t*)osip_list_get_first((*jd)->d_out_trs, &it);
|
||||
while (transaction != OSIP_SUCCESS) {
|
||||
if (transaction != NULL && transaction->transactionid == tid) {
|
||||
*tr = transaction;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
transaction = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
84
src/eXosip.c
84
src/eXosip.c
@@ -101,6 +101,16 @@ _eXosip_transaction_init (struct eXosip_t *excontext, osip_transaction_t ** tran
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifndef MINISIZE
|
||||
{
|
||||
struct timeval now;
|
||||
excontext->statistics.allocated_transactions++;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_transactions, 1, &now);
|
||||
}
|
||||
#endif
|
||||
|
||||
osip_transaction_set_reserved1 (*transaction, excontext);
|
||||
{
|
||||
osip_naptr_t *naptr_record = NULL;
|
||||
@@ -115,21 +125,29 @@ _eXosip_transaction_init (struct eXosip_t *excontext, osip_transaction_t ** tran
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_eXosip_transaction_free (struct eXosip_t *excontext, osip_transaction_t *transaction)
|
||||
{
|
||||
_eXosip_delete_reserved (transaction);
|
||||
_eXosip_dnsutils_release (transaction->naptr_record);
|
||||
transaction->naptr_record = NULL;
|
||||
osip_transaction_free (transaction);
|
||||
#ifndef MINISIZE
|
||||
excontext->statistics.allocated_transactions--;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_eXosip_transaction_find (struct eXosip_t *excontext, int tid, osip_transaction_t ** transaction)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
*transaction = NULL;
|
||||
while (!osip_list_eol (&excontext->j_transactions, pos)) {
|
||||
osip_transaction_t *tr;
|
||||
|
||||
tr = (osip_transaction_t *) osip_list_get (&excontext->j_transactions, pos);
|
||||
osip_list_iterator_t it;
|
||||
osip_transaction_t* tr = (osip_transaction_t*)osip_list_get_first(&excontext->j_transactions, &it);
|
||||
while (tr != OSIP_SUCCESS) {
|
||||
if (tr->transactionid == tid) {
|
||||
*transaction = tr;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
return OSIP_NOTFOUND;
|
||||
}
|
||||
@@ -330,17 +348,16 @@ _eXosip_publish_refresh (struct eXosip_t *excontext, eXosip_dialog_t * jd, osip_
|
||||
|
||||
if (out_tr != NULL && out_tr->last_response != NULL && out_tr->last_response->status_code == 412) {
|
||||
/* remove SIP-If-Match header */
|
||||
int pos = 0;
|
||||
|
||||
while (!osip_list_eol (&msg->headers, pos)) {
|
||||
osip_header_t *head = osip_list_get (&msg->headers, pos);
|
||||
osip_list_iterator_t it;
|
||||
osip_header_t* head = (osip_header_t*)osip_list_get_first(&msg->headers, &it);
|
||||
while (head != OSIP_SUCCESS) {
|
||||
|
||||
if (head != NULL && 0 == osip_strcasecmp (head->hname, "sip-if-match")) {
|
||||
i = osip_list_remove (&msg->headers, pos);
|
||||
osip_list_iterator_remove (&it);
|
||||
osip_header_free (head);
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
head = (osip_header_t*)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1191,7 +1208,6 @@ _eXosip_add_authentication_information (struct eXosip_t *excontext, osip_message
|
||||
if (last_response == NULL) {
|
||||
/* we can add all credential that belongs to the same call-id */
|
||||
struct eXosip_http_auth *http_auth;
|
||||
int pos;
|
||||
|
||||
/* update entries with same call_id */
|
||||
for (pos = 0; pos < MAX_EXOSIP_HTTP_AUTH; pos++) {
|
||||
@@ -1418,35 +1434,29 @@ _eXosip_mark_registration_expired (struct eXosip_t *excontext, const char *call_
|
||||
int
|
||||
_eXosip_check_allow_header (eXosip_dialog_t * jd, osip_message_t * message)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifndef MINISIZE
|
||||
for (i = 0; !osip_list_eol (&message->allows, i); i++) {
|
||||
osip_allow_t *dest = (osip_allow_t *) osip_list_get (&message->allows, i);
|
||||
|
||||
if (dest == NULL)
|
||||
return -1;
|
||||
if (dest->value == NULL)
|
||||
continue;
|
||||
if (osip_strcasecmp (dest->value, "UPDATE") == 0) {
|
||||
osip_list_iterator_t it;
|
||||
osip_allow_t* dest = (osip_allow_t*)osip_list_get_first(&message->allows, &it);
|
||||
while (dest != NULL) {
|
||||
if (dest->value != NULL && osip_strcasecmp (dest->value, "update") == 0) {
|
||||
jd->d_session_timer_use_update = 1;
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "Allow header contains UPDATE\n"));
|
||||
break;
|
||||
}
|
||||
dest = (osip_allow_t*)osip_list_get_next(&it);
|
||||
}
|
||||
#else
|
||||
for (i = 0; !osip_list_eol (&message->headers, i); i++) {
|
||||
osip_header_t *dest = (osip_header_t *) osip_list_get (&message->headers, i);
|
||||
|
||||
if (dest == NULL)
|
||||
return -1;
|
||||
if (dest->hvalue == NULL)
|
||||
continue;
|
||||
if (osip_strcasecmp (dest->hname, "allow") != 0)
|
||||
continue;
|
||||
if (osip_strcasecmp (dest->hvalue, "UPDATE") == 0) {
|
||||
jd->d_session_timer_use_update = 1;
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "Allow header contains UPDATE\n"));
|
||||
osip_list_iterator_t it;
|
||||
osip_header_t* dest = (osip_header_t*)osip_list_get_first(&message->headers, &it);
|
||||
while (dest != OSIP_SUCCESS) {
|
||||
if (dest->hvalue != NULL && osip_strcasecmp (dest->hname, "allow") == 0) {
|
||||
if (osip_strcasestr (dest->hvalue, "UPDATE") != NULL) {
|
||||
jd->d_session_timer_use_update = 1;
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "Allow header contains UPDATE\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
dest = (osip_header_t*)osip_list_get_next(&it);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
@@ -275,7 +275,7 @@ extern "C" {
|
||||
time_t r_last_deletion; /* prevent loop for automasquerade: no more than one per minute. */
|
||||
|
||||
struct __eXosip_sockaddr addr;
|
||||
int len;
|
||||
socklen_t len;
|
||||
|
||||
eXosip_reg_t *next;
|
||||
eXosip_reg_t *parent;
|
||||
@@ -339,7 +339,7 @@ extern "C" {
|
||||
int _eXosip_pub_update (struct eXosip_t *excontext, eXosip_pub_t ** pub, osip_transaction_t * tr, osip_message_t * answer);
|
||||
int _eXosip_pub_find_by_aor (struct eXosip_t *excontext, eXosip_pub_t ** pub, const char *aor);
|
||||
int _eXosip_pub_find_by_tid (struct eXosip_t *excontext, eXosip_pub_t ** pjp, int tid);
|
||||
int _eXosip_pub_init (eXosip_pub_t ** pub, const char *aor, const char *exp);
|
||||
int _eXosip_pub_init (struct eXosip_t *excontext, eXosip_pub_t ** pub, const char *aor, const char *exp);
|
||||
void _eXosip_pub_free (struct eXosip_t *excontext, eXosip_pub_t * pub);
|
||||
|
||||
#endif
|
||||
@@ -396,9 +396,30 @@ extern "C" {
|
||||
#define MAX_EXOSIP_HTTP_AUTH 100
|
||||
#endif
|
||||
|
||||
struct eXosip_counters {
|
||||
float current_average;
|
||||
unsigned int num_entries;
|
||||
unsigned short period; /* total max duration */
|
||||
unsigned short interval; /* minimum interval */
|
||||
unsigned short *values;
|
||||
struct timeval *times;
|
||||
unsigned int index_last;
|
||||
unsigned int total_values;
|
||||
};
|
||||
|
||||
typedef struct eXosip_t eXosip_t;
|
||||
|
||||
struct eXosip_t {
|
||||
#ifndef MINISIZE
|
||||
struct eXosip_stats statistics;
|
||||
struct eXosip_counters average_transactions;
|
||||
struct eXosip_counters average_registrations;
|
||||
struct eXosip_counters average_calls;
|
||||
struct eXosip_counters average_publications;
|
||||
struct eXosip_counters average_subscriptions;
|
||||
struct eXosip_counters average_insubscriptions;
|
||||
#endif
|
||||
|
||||
struct eXtl_protocol eXtl_transport;
|
||||
void *eXtludp_reserved;
|
||||
void *eXtltcp_reserved;
|
||||
@@ -428,7 +449,9 @@ extern "C" {
|
||||
jpipe_t *j_socketctl;
|
||||
jpipe_t *j_socketctl_event;
|
||||
#endif
|
||||
|
||||
int max_message_to_read;
|
||||
long int max_read_timeout;
|
||||
|
||||
osip_fifo_t *j_events;
|
||||
|
||||
jauthinfo_t *authinfos;
|
||||
@@ -540,7 +563,6 @@ extern "C" {
|
||||
int _eXosip_build_response_default (struct eXosip_t *excontext, osip_message_t ** dest, osip_dialog_t * dialog, int status, osip_message_t * request);
|
||||
int _eXosip_complete_answer_that_establish_a_dialog (struct eXosip_t *excontext, osip_message_t * response, osip_message_t * request);
|
||||
int _eXosip_build_request_within_dialog (struct eXosip_t *excontext, osip_message_t ** dest, const char *method, osip_dialog_t * dialog);
|
||||
void _eXosip_kill_transaction (osip_list_t * transactions);
|
||||
int _eXosip_remove_transaction_from_call (osip_transaction_t * tr, eXosip_call_t * jc);
|
||||
|
||||
osip_transaction_t *_eXosip_find_last_transaction (eXosip_call_t * jc, eXosip_dialog_t * jd, const char *method);
|
||||
@@ -551,8 +573,7 @@ extern "C" {
|
||||
osip_transaction_t *_eXosip_find_last_out_invite (eXosip_call_t * jc, eXosip_dialog_t * jd);
|
||||
osip_transaction_t *_eXosip_find_previous_invite (eXosip_call_t * jc, eXosip_dialog_t * jd, osip_transaction_t * last_invite);
|
||||
|
||||
|
||||
int _eXosip_call_init (eXosip_call_t ** jc);
|
||||
int _eXosip_call_init (struct eXosip_t *excontext, eXosip_call_t ** jc);
|
||||
void _eXosip_call_renew_expire_time (eXosip_call_t * jc);
|
||||
void _eXosip_call_free (struct eXosip_t *excontext, eXosip_call_t * jc);
|
||||
void _eXosip_call_remove_dialog_reference_in_call (eXosip_call_t * jc, eXosip_dialog_t * jd);
|
||||
@@ -575,12 +596,12 @@ extern "C" {
|
||||
osip_transaction_t *_eXosip_find_last_out_subscribe (eXosip_subscribe_t * js, eXosip_dialog_t * jd);
|
||||
void _eXosip_release_terminated_subscriptions (struct eXosip_t *excontext);
|
||||
void _eXosip_release_terminated_in_subscriptions (struct eXosip_t *excontext);
|
||||
int _eXosip_subscription_init (eXosip_subscribe_t ** js);
|
||||
int _eXosip_subscription_init (struct eXosip_t *excontext, eXosip_subscribe_t ** js);
|
||||
void _eXosip_subscription_free (struct eXosip_t *excontext, eXosip_subscribe_t * js);
|
||||
int _eXosip_subscription_set_refresh_interval (eXosip_subscribe_t * js, osip_message_t * inc_subscribe);
|
||||
int _eXosip_subscription_send_request_with_credential (struct eXosip_t *excontext, eXosip_subscribe_t * js, eXosip_dialog_t * jd, osip_transaction_t * out_tr);
|
||||
int _eXosip_subscription_automatic_refresh (struct eXosip_t *excontext, eXosip_subscribe_t * js, eXosip_dialog_t * jd, osip_transaction_t * out_tr);
|
||||
int _eXosip_notify_init (eXosip_notify_t ** jn, osip_message_t * inc_subscribe);
|
||||
int _eXosip_notify_init (struct eXosip_t *excontext, eXosip_notify_t ** jn, osip_message_t * inc_subscribe);
|
||||
void _eXosip_notify_free (struct eXosip_t *excontext, eXosip_notify_t * jn);
|
||||
int _eXosip_notify_set_contact_info (eXosip_notify_t * jn, char *uri);
|
||||
int _eXosip_notify_set_refresh_interval (eXosip_notify_t * jn, osip_message_t * inc_subscribe);
|
||||
@@ -594,6 +615,7 @@ extern "C" {
|
||||
int _eXosip_dialog_add_contact (struct eXosip_t *excontext, osip_message_t * request);
|
||||
|
||||
int _eXosip_transaction_init (struct eXosip_t *excontext, osip_transaction_t ** transaction, osip_fsm_type_t ctx_type, osip_t * osip, osip_message_t * message);
|
||||
void _eXosip_transaction_free (struct eXosip_t *excontext, osip_transaction_t *transaction);
|
||||
|
||||
int _eXosip_srv_lookup (struct eXosip_t *excontext, osip_message_t * sip, osip_naptr_t ** naptr_record);
|
||||
|
||||
@@ -626,6 +648,24 @@ extern "C" {
|
||||
*/
|
||||
eXosip_tls_ctx_error eXosip_tls_verify_certificate (struct eXosip_t *excontext, int _tls_verify_client_certificate);
|
||||
|
||||
|
||||
#ifndef EXOSIP_STATS_PERIOD
|
||||
#define EXOSIP_STATS_PERIOD 3600 /* default period in seconds */
|
||||
#endif
|
||||
#ifndef EXOSIP_STATS_INTERVAL
|
||||
#define EXOSIP_STATS_INTERVAL 60 /* default interval in seconds */
|
||||
#endif
|
||||
|
||||
#ifndef MINISIZE
|
||||
void _eXosip_counters_init(struct eXosip_counters *bw_stats, int period, int interval);
|
||||
void _eXosip_counters_update(struct eXosip_counters *bw_stats, int nvalues, struct timeval *now);
|
||||
void _eXosip_counters_free(struct eXosip_counters *bw_stats);
|
||||
#else
|
||||
#define _eXosip_counters_init(A, B, C)
|
||||
#define _eXosip_counters_update(A, B, C)
|
||||
#define _eXosip_counters_free(A)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -113,7 +113,7 @@ eXosip_publish (struct eXosip_t *excontext, osip_message_t * message, const char
|
||||
}
|
||||
else {
|
||||
/* start a new publication context */
|
||||
i = _eXosip_pub_init (&pub, to, expires->hvalue);
|
||||
i = _eXosip_pub_init (excontext, &pub, to, expires->hvalue);
|
||||
if (i != 0) {
|
||||
osip_message_free (message);
|
||||
return i;
|
||||
|
||||
@@ -305,16 +305,15 @@ _eXosip_register_build_register (struct eXosip_t *excontext, eXosip_reg_t * jr,
|
||||
osip_contact_t *contact;
|
||||
osip_message_get_contact(reg, 0, &contact);
|
||||
if (contact!=NULL) {
|
||||
osip_generic_param_t *exp_param = NULL;
|
||||
int pos=0;
|
||||
while (!osip_list_eol (&contact->gen_params, pos)) {
|
||||
exp_param = (osip_uri_param_t *) osip_list_get (&contact->gen_params, pos);
|
||||
osip_list_iterator_t it;
|
||||
osip_generic_param_t* exp_param = (osip_generic_param_t*)osip_list_get_first(&contact->gen_params, &it);
|
||||
while (exp_param != NULL) {
|
||||
if (exp_param->gname!=NULL && osip_strcasecmp (exp_param->gname, "expires") == 0) {
|
||||
osip_list_remove(&contact->gen_params, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_generic_param_free(exp_param);
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
exp_param = (osip_generic_param_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
if (excontext->eXtl_transport._tl_update_contact!=NULL)
|
||||
|
||||
@@ -49,26 +49,25 @@ _eXosip_subscription_transaction_find (struct eXosip_t *excontext, int tid, eXos
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
for (*jd = (*js)->s_dialogs; *jd != NULL; *jd = (*jd)->next) {
|
||||
osip_transaction_t *transaction;
|
||||
int pos = 0;
|
||||
osip_list_iterator_t it;
|
||||
osip_transaction_t* transaction;
|
||||
|
||||
while (!osip_list_eol ((*jd)->d_inc_trs, pos)) {
|
||||
transaction = (osip_transaction_t *) osip_list_get ((*jd)->d_inc_trs, pos);
|
||||
transaction = (osip_transaction_t*)osip_list_get_first((*jd)->d_inc_trs, &it);
|
||||
while (transaction != OSIP_SUCCESS) {
|
||||
if (transaction != NULL && transaction->transactionid == tid) {
|
||||
*tr = transaction;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
transaction = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol ((*jd)->d_out_trs, pos)) {
|
||||
transaction = (osip_transaction_t *) osip_list_get ((*jd)->d_out_trs, pos);
|
||||
transaction = (osip_transaction_t*)osip_list_get_first((*jd)->d_out_trs, &it);
|
||||
while (transaction != OSIP_SUCCESS) {
|
||||
if (transaction != NULL && transaction->transactionid == tid) {
|
||||
*tr = transaction;
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
transaction = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +182,7 @@ eXosip_subscription_send_initial_request (struct eXosip_t *excontext, osip_messa
|
||||
osip_event_t *sipevent;
|
||||
int i;
|
||||
|
||||
i = _eXosip_subscription_init (&js);
|
||||
i = _eXosip_subscription_init (excontext, &js);
|
||||
if (i != 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot subscribe."));
|
||||
osip_message_free (subscribe);
|
||||
|
||||
@@ -360,7 +360,7 @@ dtls_tl_open (struct eXosip_t *excontext)
|
||||
#endif /* IPV6_V6ONLY */
|
||||
}
|
||||
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot bind socket node:%s family:%d %s\n", excontext->eXtl_transport.proto_ifs, curinfo->ai_family, strerror (errno)));
|
||||
close (sock);
|
||||
@@ -613,8 +613,6 @@ dtls_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
static int
|
||||
_dtls_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
struct eXosip_account_info *ainfo = NULL;
|
||||
char *proxy = NULL;
|
||||
int i;
|
||||
@@ -650,16 +648,10 @@ _dtls_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
|
||||
if (excontext->dtls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) {
|
||||
|
||||
while (!osip_list_eol (&req->contacts, pos)) {
|
||||
osip_contact_t *co;
|
||||
|
||||
co = (osip_contact_t *) osip_list_get (&req->contacts, pos);
|
||||
pos++;
|
||||
if (co != NULL && co->url != NULL && co->url->host != NULL
|
||||
#if 0
|
||||
&& 0 == osip_strcasecmp (co->url->host, dtls_firewall_ip)
|
||||
#endif
|
||||
) {
|
||||
osip_list_iterator_t it;
|
||||
osip_contact_t* co = (osip_contact_t *)osip_list_get_first(&req->contacts, &it);
|
||||
while (co != NULL) {
|
||||
if (co != NULL && co->url != NULL && co->url->host != NULL) {
|
||||
if (ainfo == NULL) {
|
||||
if (excontext->dtls_firewall_port[0]=='\0') {
|
||||
} else if (co->url->port == NULL && 0 != osip_strcasecmp (excontext->dtls_firewall_port, "5061")) {
|
||||
@@ -697,6 +689,7 @@ _dtls_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
co = (osip_contact_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,7 +743,7 @@ static int
|
||||
dtls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_message_t * sip, char *host, int port, int out_socket)
|
||||
{
|
||||
struct eXtldtls *reserved = (struct eXtldtls *) excontext->eXtldtls_reserved;
|
||||
int len = 0;
|
||||
socklen_t len = 0;
|
||||
size_t length = 0;
|
||||
struct addrinfo *addrinfo;
|
||||
struct __eXosip_sockaddr addr;
|
||||
@@ -919,7 +912,7 @@ dtls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_
|
||||
}
|
||||
|
||||
memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen);
|
||||
len = addrinfo->ai_addrlen;
|
||||
len = (socklen_t)addrinfo->ai_addrlen;
|
||||
|
||||
_eXosip_freeaddrinfo (addrinfo);
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ tcp_tl_open (struct eXosip_t *excontext)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MAIN_SOCKET
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Cannot bind socket node:%s family:%d %s\n", excontext->eXtl_transport.proto_ifs, curinfo->ai_family, strerror (ex_errno)));
|
||||
closesocket (sock);
|
||||
@@ -418,7 +418,7 @@ handle_messages (struct eXosip_t *excontext, struct _tcp_stream *sockinfo)
|
||||
}
|
||||
clen = clen_header ? atoi (clen_header) : 0;
|
||||
if (clen<0)
|
||||
return sockinfo->buflen; /* discard data */
|
||||
return (int)sockinfo->buflen; /* discard data */
|
||||
/* undo our overwrite and advance end_headers */
|
||||
*end_headers = END_HEADERS_STR[0];
|
||||
end_headers += const_strlen (END_HEADERS_STR);
|
||||
@@ -468,8 +468,8 @@ _tcp_tl_recv (struct eXosip_t *excontext, struct _tcp_stream *sockinfo)
|
||||
return OSIP_NOMEM;
|
||||
sockinfo->bufsize = SIP_MESSAGE_MAX_LENGTH;
|
||||
}
|
||||
|
||||
r = (int) recv (sockinfo->socket, sockinfo->buf + sockinfo->buflen, sockinfo->bufsize - sockinfo->buflen, 0);
|
||||
|
||||
r = (int) recv (sockinfo->socket, sockinfo->buf + sockinfo->buflen, (int)(sockinfo->bufsize - sockinfo->buflen), 0);
|
||||
if (r == 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "socket %s:%i: eof\n", sockinfo->remote_ip, sockinfo->remote_port));
|
||||
_eXosip_mark_registration_expired (excontext, sockinfo->reg_call_id);
|
||||
@@ -550,7 +550,8 @@ tcp_tl_read_message (struct eXosip_t *excontext, fd_set * osip_fdset, fd_set * o
|
||||
}
|
||||
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "creating TCP socket at index: %i\n", pos));
|
||||
sock = accept (reserved->tcp_socket, (struct sockaddr *) &sa, &slen);
|
||||
|
||||
sock = (int)accept (reserved->tcp_socket, (struct sockaddr *) &sa, (socklen_t*)&slen);
|
||||
if (sock < 0) {
|
||||
#if defined(EBADF)
|
||||
int status = ex_errno;
|
||||
@@ -799,7 +800,7 @@ _tcp_tl_is_connected (int sock)
|
||||
if (curinfo->ai_protocol && curinfo->ai_protocol != IPPROTO_TCP)
|
||||
continue;
|
||||
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
if (res != 0)
|
||||
continue;
|
||||
|
||||
@@ -816,7 +817,7 @@ _tcp_tl_is_connected (int sock)
|
||||
continue;
|
||||
}
|
||||
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
|
||||
if (res == 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "New binding with %s:%i\n", src6host, port));
|
||||
@@ -918,7 +919,7 @@ _tcp_tl_is_connected (int sock)
|
||||
_eXosip_freeaddrinfo (oc_addrinfo);
|
||||
break;
|
||||
}
|
||||
res = bind (sock, (const struct sockaddr *)oc_curinfo->ai_addr, oc_curinfo->ai_addrlen);
|
||||
res = bind (sock, (const struct sockaddr *)oc_curinfo->ai_addr, (socklen_t)oc_curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "Cannot bind socket node:%s family:%d (port=%i) %s\n", excontext->oc_local_address, oc_curinfo->ai_addr->sa_family, excontext->oc_local_port_current, strerror (ex_errno)));
|
||||
_eXosip_freeaddrinfo (oc_addrinfo);
|
||||
@@ -1019,7 +1020,7 @@ _tcp_tl_is_connected (int sock)
|
||||
_eXosip_transport_set_dscp (excontext, excontext->eXtl_transport.proto_family, sock);
|
||||
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "socket node:%s , socket %d, family:%d set to non blocking mode\n", host, sock, curinfo->ai_family));
|
||||
res = connect (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = connect (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
int connect_err = ex_errno;
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "connecting socket node:%s, socket %d [pos=%d], family:%d, %s[%d]\n", host, sock, pos, curinfo->ai_family, strerror (connect_err), connect_err));
|
||||
@@ -1037,7 +1038,7 @@ _tcp_tl_is_connected (int sock)
|
||||
res = _tcp_tl_is_connected (sock);
|
||||
if (res > 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "socket node:%s, socket %d [pos=%d], family:%d, in progress\n", host, sock, pos, curinfo->ai_family));
|
||||
selected_ai_addrlen = curinfo->ai_addrlen;
|
||||
selected_ai_addrlen = (socklen_t)curinfo->ai_addrlen;
|
||||
memcpy (&selected_ai_addr, curinfo->ai_addr, sizeof (struct sockaddr));
|
||||
break;
|
||||
}
|
||||
@@ -1183,18 +1184,13 @@ _tcp_tl_is_connected (int sock)
|
||||
static int
|
||||
_tcp_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req, char *natted_ip, int natted_port)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
if (req->application_data != (void*) 0x1)
|
||||
return OSIP_SUCCESS;
|
||||
|
||||
if ((natted_ip != NULL && natted_ip[0] != '\0') || natted_port > 0) {
|
||||
|
||||
while (!osip_list_eol (&req->contacts, pos)) {
|
||||
osip_contact_t *co;
|
||||
|
||||
co = (osip_contact_t *) osip_list_get (&req->contacts, pos);
|
||||
pos++;
|
||||
osip_list_iterator_t it;
|
||||
osip_contact_t* co = (osip_contact_t *)osip_list_get_first(&req->contacts, &it);
|
||||
while (co != NULL) {
|
||||
if (co != NULL && co->url != NULL && co->url->host != NULL) {
|
||||
if (natted_port > 0) {
|
||||
if (co->url->port)
|
||||
@@ -1209,6 +1205,7 @@ _tcp_tl_is_connected (int sock)
|
||||
osip_message_force_update (req);
|
||||
}
|
||||
}
|
||||
co = (osip_contact_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1520,7 +1520,7 @@ tls_tl_open (struct eXosip_t *excontext)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MAIN_SOCKET
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot bind socket node:%s family:%d %s\n", excontext->eXtl_transport.proto_ifs, curinfo->ai_family, strerror (ex_errno)));
|
||||
close (sock);
|
||||
@@ -2041,7 +2041,7 @@ handle_messages (struct eXosip_t *excontext, struct _tls_stream *sockinfo)
|
||||
}
|
||||
clen = clen_header ? atoi (clen_header) : 0;
|
||||
if (clen<0)
|
||||
return sockinfo->buflen; /* discard data */
|
||||
return (int)sockinfo->buflen; /* discard data */
|
||||
/* undo our overwrite and advance end_headers */
|
||||
*end_headers = END_HEADERS_STR[0];
|
||||
end_headers += const_strlen (END_HEADERS_STR);
|
||||
@@ -2245,7 +2245,8 @@ tls_tl_read_message (struct eXosip_t *excontext, fd_set * osip_fdset, fd_set * o
|
||||
}
|
||||
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "creating TLS socket at index: %i\n", pos));
|
||||
sock = accept (reserved->tls_socket, (struct sockaddr *) &sa, &slen);
|
||||
|
||||
sock = (int)accept (reserved->tls_socket, (struct sockaddr *) &sa, (socklen_t*)&slen);
|
||||
if (sock < 0) {
|
||||
#if defined(EBADF)
|
||||
int status = ex_errno;
|
||||
@@ -2399,7 +2400,7 @@ _tls_tl_connect_socket (struct eXosip_t *excontext, char *host, int port, int re
|
||||
if (curinfo->ai_protocol && curinfo->ai_protocol != IPPROTO_TCP)
|
||||
continue;
|
||||
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
if (res != 0)
|
||||
continue;
|
||||
|
||||
@@ -2419,7 +2420,7 @@ _tls_tl_connect_socket (struct eXosip_t *excontext, char *host, int port, int re
|
||||
continue;
|
||||
}
|
||||
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
res = getnameinfo ((struct sockaddr *) curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen, src6host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
|
||||
if (res == 0) {
|
||||
int i = _tls_tl_find_socket (excontext, src6host, port);
|
||||
@@ -2524,7 +2525,7 @@ _tls_tl_connect_socket (struct eXosip_t *excontext, char *host, int port, int re
|
||||
_eXosip_get_addrinfo(excontext, &addrinfo, excontext->oc_local_address, excontext->oc_local_port_current, IPPROTO_TCP);
|
||||
|
||||
}
|
||||
res = bind (sock, (const struct sockaddr *)&curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, (const struct sockaddr *)&curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "Cannot bind socket node:%s family:%d (port=%i) %s\n", excontext->oc_local_address, curinfo->ai_addr->sa_family, excontext->oc_local_port_current, strerror (ex_errno)));
|
||||
count++;
|
||||
@@ -2616,7 +2617,7 @@ _tls_tl_connect_socket (struct eXosip_t *excontext, char *host, int port, int re
|
||||
_eXosip_transport_set_dscp (excontext, excontext->eXtl_transport.proto_family, sock);
|
||||
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: socket node:%s , socket %d, family:%d set to non blocking mode\n", host, sock, curinfo->ai_family));
|
||||
res = connect (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = connect (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
if (res < 0) {
|
||||
#ifdef WIN32
|
||||
if (ex_errno != WSAEWOULDBLOCK) {
|
||||
@@ -2633,7 +2634,7 @@ _tls_tl_connect_socket (struct eXosip_t *excontext, char *host, int port, int re
|
||||
res = _tls_tl_is_connected (sock);
|
||||
if (res > 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "socket node:%s, socket %d [pos=%d], family:%d, in progress\n", host, sock, pos, curinfo->ai_family));
|
||||
selected_ai_addrlen = curinfo->ai_addrlen;
|
||||
selected_ai_addrlen = (socklen_t)curinfo->ai_addrlen;
|
||||
memcpy (&selected_ai_addr, curinfo->ai_addr, sizeof (struct sockaddr));
|
||||
break;
|
||||
}
|
||||
@@ -2725,18 +2726,13 @@ _tls_tl_connect_socket (struct eXosip_t *excontext, char *host, int port, int re
|
||||
static int
|
||||
_tls_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req, char *natted_ip, int natted_port)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
if (req->application_data != (void*) 0x1)
|
||||
return OSIP_SUCCESS;
|
||||
|
||||
if ((natted_ip != NULL && natted_ip[0] != '\0') || natted_port > 0) {
|
||||
|
||||
while (!osip_list_eol (&req->contacts, pos)) {
|
||||
osip_contact_t *co;
|
||||
|
||||
co = (osip_contact_t *) osip_list_get (&req->contacts, pos);
|
||||
pos++;
|
||||
osip_list_iterator_t it;
|
||||
osip_contact_t* co = (osip_contact_t *)osip_list_get_first(&req->contacts, &it);
|
||||
while (co != NULL) {
|
||||
if (co != NULL && co->url != NULL && co->url->host != NULL) {
|
||||
if (natted_port > 0) {
|
||||
if (co->url->port)
|
||||
@@ -2751,6 +2747,7 @@ _tls_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req, char *
|
||||
osip_message_force_update (req);
|
||||
}
|
||||
}
|
||||
co = (osip_contact_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -396,13 +396,13 @@ _udp_tl_open (struct eXosip_t *excontext)
|
||||
|
||||
addr = (struct sockaddr_in *) (curinfo->ai_addr);
|
||||
addr->sin_addr.s_addr = htonl (config.internal_address.address);
|
||||
res = tsc_bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = tsc_bind (sock, curinfo->ai_addr, (int)curinfo->ai_addrlen);
|
||||
}
|
||||
else {
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
}
|
||||
#else
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
#endif
|
||||
|
||||
if (res < 0) {
|
||||
@@ -555,13 +555,13 @@ _udp_tl_open_oc (struct eXosip_t *excontext)
|
||||
|
||||
addr = (struct sockaddr_in *) (curinfo->ai_addr);
|
||||
addr->sin_addr.s_addr = htonl (config.internal_address.address);
|
||||
res = tsc_bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = tsc_bind (sock, curinfo->ai_addr, (int)curinfo->ai_addrlen);
|
||||
}
|
||||
else {
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
}
|
||||
#else
|
||||
res = bind (sock, curinfo->ai_addr, curinfo->ai_addrlen);
|
||||
res = bind (sock, curinfo->ai_addr, (socklen_t)curinfo->ai_addrlen);
|
||||
#endif
|
||||
|
||||
if (res < 0) {
|
||||
@@ -867,8 +867,6 @@ udp_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
static int
|
||||
_udp_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
struct eXosip_account_info *ainfo = NULL;
|
||||
char *proxy = NULL;
|
||||
int i;
|
||||
@@ -903,17 +901,10 @@ _udp_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
}
|
||||
|
||||
if (excontext->udp_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) {
|
||||
|
||||
while (!osip_list_eol (&req->contacts, pos)) {
|
||||
osip_contact_t *co;
|
||||
|
||||
co = (osip_contact_t *) osip_list_get (&req->contacts, pos);
|
||||
pos++;
|
||||
if (co != NULL && co->url != NULL && co->url->host != NULL
|
||||
#if 0
|
||||
&& 0 == osip_strcasecmp (co->url->host, udp_firewall_ip)
|
||||
#endif
|
||||
) {
|
||||
osip_list_iterator_t it;
|
||||
osip_contact_t* co = (osip_contact_t *)osip_list_get_first(&req->contacts, &it);
|
||||
while (co != NULL) {
|
||||
if (co != NULL && co->url != NULL && co->url->host != NULL) {
|
||||
if (ainfo == NULL) {
|
||||
if (excontext->udp_firewall_port[0]=='\0') {
|
||||
} else if (co->url->port == NULL && 0 != osip_strcasecmp (excontext->udp_firewall_port, "5060")) {
|
||||
@@ -951,6 +942,7 @@ _udp_tl_update_contact (struct eXosip_t *excontext, osip_message_t * req)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
co = (osip_contact_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,7 +996,7 @@ static int
|
||||
udp_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_message_t * sip, char *host, int port, int out_socket)
|
||||
{
|
||||
struct eXtludp *reserved = (struct eXtludp *) excontext->eXtludp_reserved;
|
||||
int len = 0;
|
||||
socklen_t len = 0;
|
||||
size_t length = 0;
|
||||
struct addrinfo *addrinfo;
|
||||
struct __eXosip_sockaddr addr;
|
||||
@@ -1193,7 +1185,7 @@ udp_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m
|
||||
}
|
||||
|
||||
memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen);
|
||||
len = addrinfo->ai_addrlen;
|
||||
len = (socklen_t)addrinfo->ai_addrlen;
|
||||
|
||||
_eXosip_freeaddrinfo (addrinfo);
|
||||
|
||||
@@ -1290,13 +1282,19 @@ udp_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m
|
||||
_udp_tl_transport_set_dscp_qos(excontext, (struct sockaddr *) &addr, len);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define CAST_RECV_LEN(L) ((int)(L))
|
||||
#else
|
||||
#define CAST_RECV_LEN(L) L
|
||||
#endif
|
||||
|
||||
#ifdef TSC_SUPPORT
|
||||
if (excontext->tunnel_handle)
|
||||
i = tsc_sendto (reserved->udp_socket, message, length, 0, (struct sockaddr *) &addr, len);
|
||||
i = tsc_sendto (reserved->udp_socket, message, CAST_RECV_LEN(length), 0, (struct sockaddr *) &addr, len);
|
||||
else
|
||||
i = sendto (sock, (const void *) message, length, 0, (struct sockaddr *) &addr, len);
|
||||
i = sendto (sock, (const void *) message, CAST_RECV_LEN(length), 0, (struct sockaddr *) &addr, len);
|
||||
#else
|
||||
i = sendto (sock, (const void *) message, length, 0, (struct sockaddr *) &addr, len);
|
||||
i = sendto (sock, (const void *) message, CAST_RECV_LEN(length), 0, (struct sockaddr *) &addr, len);
|
||||
#endif
|
||||
if (0 > i) {
|
||||
if (naptr_record != NULL) {
|
||||
|
||||
113
src/eXutils.c
113
src/eXutils.c
@@ -531,7 +531,7 @@ _eXosip_guess_ip_for_destination (struct eXosip_t *excontext, int family, char *
|
||||
return OSIP_NO_NETWORK;
|
||||
}
|
||||
|
||||
if (WSAIoctl (sock, SIO_ROUTING_INTERFACE_QUERY, addrf->ai_addr, addrf->ai_addrlen, &local_addr, sizeof (local_addr), &local_addr_len, NULL, NULL) != 0) {
|
||||
if (WSAIoctl (sock, SIO_ROUTING_INTERFACE_QUERY, addrf->ai_addr, (DWORD)addrf->ai_addrlen, &local_addr, sizeof (local_addr), &local_addr_len, NULL, NULL) != 0) {
|
||||
closesocket (sock);
|
||||
_eXosip_freeaddrinfo (addrf);
|
||||
snprintf (address, size, (family == AF_INET) ? "127.0.0.1" : "::1");
|
||||
@@ -596,7 +596,7 @@ _eXosip_guess_ip_for_destinationsock (struct eXosip_t *excontext, int family, in
|
||||
return OSIP_NO_NETWORK;
|
||||
}
|
||||
|
||||
if (WSAIoctl (sock, SIO_ROUTING_INTERFACE_QUERY, addrf->ai_addr, addrf->ai_addrlen, &local_addr, sizeof (local_addr), &local_addr_len, NULL, NULL) != 0) {
|
||||
if (WSAIoctl (sock, SIO_ROUTING_INTERFACE_QUERY, addrf->ai_addr, (DWORD)addrf->ai_addrlen, &local_addr, sizeof (local_addr), &local_addr_len, NULL, NULL) != 0) {
|
||||
_eXosip_freeaddrinfo (addrf);
|
||||
snprintf (address, size, (family == AF_INET) ? "127.0.0.1" : "::1");
|
||||
return OSIP_NO_NETWORK;
|
||||
@@ -1014,7 +1014,7 @@ _eXosip_get_addrinfo (struct eXosip_t *excontext, struct addrinfo **addrinfo, co
|
||||
char porttmp[10];
|
||||
|
||||
for (elem = *addrinfo; elem != NULL; elem = elem->ai_next) {
|
||||
getnameinfo (elem->ai_addr, elem->ai_addrlen, tmp, sizeof (tmp), porttmp, sizeof (porttmp), NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
getnameinfo (elem->ai_addr, (socklen_t)elem->ai_addrlen, tmp, sizeof (tmp), porttmp, sizeof (porttmp), NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "getaddrinfo returned: %s port %s\n", tmp, porttmp));
|
||||
}
|
||||
}
|
||||
@@ -1178,7 +1178,7 @@ eXosip_dnsutils_rotate_srv (osip_srv_record_t * srv_record)
|
||||
|
||||
static osip_list_t *dnsutils_list = NULL;
|
||||
|
||||
#if defined(HAVE_CARES_H)
|
||||
#if defined(HAVE_CARES_H) || defined(HAVE_ARES_H)
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
@@ -2123,8 +2123,8 @@ eXosip_dnsutils_naptr_lookup (osip_naptr_t * output_record, const char *domain)
|
||||
struct osip_naptr *
|
||||
eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const char *protocol, const char *transport, int keep_in_cache)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
struct osip_naptr *naptr_record;
|
||||
int pos;
|
||||
int i;
|
||||
|
||||
#if defined(HAVE_WINDNS_H)
|
||||
@@ -2149,10 +2149,8 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
if (keep_in_cache < 0) {
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
if (osip_strcasecmp (domain, naptr_record->domain) == 0) {
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_RETRYLATER)
|
||||
break;
|
||||
@@ -2163,9 +2161,9 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -2206,28 +2204,25 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
osip_free (dns_servers);
|
||||
#endif
|
||||
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
|
||||
/* process all */
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_NAPTRDONE || naptr_record->naptr_state == OSIP_NAPTR_STATE_SRVINPROGRESS)
|
||||
eXosip_dnsutils_srv_lookup (naptr_record);
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (domain == NULL)
|
||||
return NULL;
|
||||
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
it.pos=0;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
if (osip_strcasecmp (domain, naptr_record->domain) == 0) {
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_RETRYLATER)
|
||||
break;
|
||||
@@ -2239,12 +2234,12 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (pos == 10 && keep_in_cache > 0) {
|
||||
if (it.pos == 9 && keep_in_cache > 0) {
|
||||
/* no NAPTR found within the last 10 NAPTR : refuse to keep in cache... */
|
||||
/* If we were adding unlimited NAPTR record into the cache, the program
|
||||
would infinitly increase memory usage. If you reach there, then you
|
||||
@@ -2774,8 +2769,8 @@ eXosip_dnsutils_naptr_lookup (osip_naptr_t * output_record, const char *domain)
|
||||
struct osip_naptr *
|
||||
eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const char *protocol, const char *transport, int keep_in_cache)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
struct osip_naptr *naptr_record;
|
||||
int pos;
|
||||
int i;
|
||||
DNS_STATUS err;
|
||||
DWORD buf_length = 0;
|
||||
@@ -2791,10 +2786,8 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
if (keep_in_cache < 0) {
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
if (osip_strcasecmp (domain, naptr_record->domain) == 0) {
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_RETRYLATER)
|
||||
break;
|
||||
@@ -2805,9 +2798,9 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -2846,28 +2839,25 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
|
||||
/* process all */
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_NAPTRDONE || naptr_record->naptr_state == OSIP_NAPTR_STATE_SRVINPROGRESS)
|
||||
eXosip_dnsutils_srv_lookup (naptr_record);
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (domain == NULL)
|
||||
return NULL;
|
||||
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
it.pos=0;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
if (osip_strcasecmp (domain, naptr_record->domain) == 0) {
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_RETRYLATER)
|
||||
break;
|
||||
@@ -2879,12 +2869,12 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (pos == 10 && keep_in_cache > 0) {
|
||||
if (it.pos == 9 && keep_in_cache > 0) {
|
||||
/* no NAPTR found within the last 10 NAPTR : refuse to keep in cache... */
|
||||
/* If we were adding unlimited NAPTR record into the cache, the program
|
||||
would infinitly increase memory usage. If you reach there, then you
|
||||
@@ -3405,8 +3395,8 @@ defined(OLD_NAMESER) || defined(__FreeBSD__)
|
||||
struct osip_naptr *
|
||||
eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const char *protocol, const char *transport, int keep_in_cache)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
struct osip_naptr *naptr_record;
|
||||
int pos;
|
||||
int i;
|
||||
int not_in_list = 0;
|
||||
|
||||
@@ -3419,10 +3409,8 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
if (keep_in_cache < 0) {
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
if (osip_strcasecmp (domain, naptr_record->domain) == 0) {
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_RETRYLATER)
|
||||
break;
|
||||
@@ -3433,35 +3421,32 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
|
||||
/* process all */
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_NAPTRDONE || naptr_record->naptr_state == OSIP_NAPTR_STATE_SRVINPROGRESS)
|
||||
eXosip_dnsutils_srv_lookup (naptr_record);
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (domain == NULL)
|
||||
return NULL;
|
||||
|
||||
naptr_record = NULL;
|
||||
pos = 0;
|
||||
while (!osip_list_eol (dnsutils_list, pos)) {
|
||||
naptr_record = (osip_naptr_t *) osip_list_get (dnsutils_list, pos);
|
||||
it.pos=0;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_first(dnsutils_list, &it);
|
||||
while (naptr_record != NULL) {
|
||||
if (osip_strcasecmp (domain, naptr_record->domain) == 0) {
|
||||
if (naptr_record->naptr_state == OSIP_NAPTR_STATE_RETRYLATER)
|
||||
break;
|
||||
@@ -3473,12 +3458,12 @@ eXosip_dnsutils_naptr (struct eXosip_t *excontext, const char *domain, const cha
|
||||
}
|
||||
|
||||
naptr_record = NULL;
|
||||
pos++;
|
||||
if (pos == 10)
|
||||
if (it.pos == 9)
|
||||
break;
|
||||
naptr_record = (osip_naptr_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (pos == 10 && keep_in_cache > 0) {
|
||||
if (it.pos == 9 && keep_in_cache > 0) {
|
||||
/* no NAPTR found within the last 10 NAPTR : refuse to keep in cache... */
|
||||
/* If we were adding unlimited NAPTR record into the cache, the program
|
||||
would infinitly increase memory usage. If you reach there, then you
|
||||
|
||||
18
src/jcall.c
18
src/jcall.c
@@ -56,7 +56,7 @@ _eXosip_call_renew_expire_time (eXosip_call_t * jc)
|
||||
}
|
||||
|
||||
int
|
||||
_eXosip_call_init (eXosip_call_t ** jc)
|
||||
_eXosip_call_init (struct eXosip_t *excontext, eXosip_call_t ** jc)
|
||||
{
|
||||
*jc = (eXosip_call_t *) osip_malloc (sizeof (eXosip_call_t));
|
||||
if (*jc == NULL)
|
||||
@@ -64,6 +64,16 @@ _eXosip_call_init (eXosip_call_t ** jc)
|
||||
memset (*jc, 0, sizeof (eXosip_call_t));
|
||||
|
||||
(*jc)->c_id = -1; /* make sure the _eXosip_update will assign a valid id to the call */
|
||||
|
||||
|
||||
#ifndef MINISIZE
|
||||
{
|
||||
struct timeval now;
|
||||
excontext->statistics.allocated_calls++;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_calls, 1, &now);
|
||||
}
|
||||
#endif
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -97,8 +107,6 @@ _eXosip_call_remove_dialog_reference_in_call (eXosip_call_t * jc, eXosip_dialog_
|
||||
void
|
||||
_eXosip_call_free (struct eXosip_t *excontext, eXosip_call_t * jc)
|
||||
{
|
||||
/* ... */
|
||||
|
||||
eXosip_dialog_t *jd;
|
||||
|
||||
if (jc->c_inc_tr != NULL && jc->c_inc_tr->orig_request != NULL && jc->c_inc_tr->orig_request->call_id != NULL && jc->c_inc_tr->orig_request->call_id->number != NULL)
|
||||
@@ -119,5 +127,7 @@ _eXosip_call_free (struct eXosip_t *excontext, eXosip_call_t * jc)
|
||||
osip_list_add (&excontext->j_transactions, jc->c_out_tr, 0);
|
||||
|
||||
osip_free (jc);
|
||||
|
||||
#ifndef MINISIZE
|
||||
excontext->statistics.allocated_calls--;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -846,8 +846,8 @@ cb_rcv2xx_4subscribe (osip_transaction_t * tr, osip_message_t * sip)
|
||||
static int
|
||||
_eXosip_update_expires_according_to_contact (eXosip_reg_t * jreg, osip_transaction_t * tr, osip_message_t * sip)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
osip_contact_t *co_register;
|
||||
int pos;
|
||||
int maxval = 0;
|
||||
|
||||
if (jreg == NULL)
|
||||
@@ -862,9 +862,8 @@ _eXosip_update_expires_according_to_contact (eXosip_reg_t * jreg, osip_transacti
|
||||
|
||||
|
||||
/* search for matching contact (line parameter must be equal) */
|
||||
pos = 0;
|
||||
co_register = (osip_contact_t *) osip_list_get (&sip->contacts, pos);
|
||||
while (co_register != NULL) {
|
||||
co_register = (osip_contact_t *)osip_list_get_first(&sip->contacts, &it);
|
||||
while (co_register != OSIP_SUCCESS) {
|
||||
osip_uri_param_t *line_param = NULL;
|
||||
|
||||
if (co_register->url != NULL)
|
||||
@@ -886,8 +885,7 @@ _eXosip_update_expires_according_to_contact (eXosip_reg_t * jreg, osip_transacti
|
||||
}
|
||||
}
|
||||
|
||||
pos++;
|
||||
co_register = (osip_contact_t *) osip_list_get (&sip->contacts, pos);
|
||||
co_register = (osip_contact_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
if (maxval == 0)
|
||||
|
||||
@@ -38,24 +38,20 @@ osip_transaction_t *
|
||||
_eXosip_find_last_inc_subscribe (eXosip_notify_t * jn, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_transaction_t *inc_tr;
|
||||
int pos;
|
||||
|
||||
inc_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (inc_tr != NULL) {
|
||||
if (0 == strcmp (inc_tr->cseq->method, "SUBSCRIBE"))
|
||||
break;
|
||||
else if (0 == strcmp (inc_tr->cseq->method, "REFER"))
|
||||
break;
|
||||
else
|
||||
inc_tr = NULL;
|
||||
pos++;
|
||||
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
else
|
||||
inc_tr = NULL;
|
||||
|
||||
if (inc_tr == NULL)
|
||||
return jn->n_inc_tr; /* can be NULL */
|
||||
@@ -68,16 +64,15 @@ osip_transaction_t *
|
||||
_eXosip_find_last_out_notify (eXosip_notify_t * jn, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_transaction_t *out_tr;
|
||||
int pos;
|
||||
|
||||
out_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (0 == strcmp (out_tr->cseq->method, "NOTIFY"))
|
||||
return out_tr;
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +80,7 @@ _eXosip_find_last_out_notify (eXosip_notify_t * jn, eXosip_dialog_t * jd)
|
||||
}
|
||||
|
||||
int
|
||||
_eXosip_notify_init (eXosip_notify_t ** jn, osip_message_t * inc_subscribe)
|
||||
_eXosip_notify_init (struct eXosip_t *excontext, eXosip_notify_t ** jn, osip_message_t * inc_subscribe)
|
||||
{
|
||||
osip_contact_t *co;
|
||||
|
||||
@@ -99,6 +94,14 @@ _eXosip_notify_init (eXosip_notify_t ** jn, osip_message_t * inc_subscribe)
|
||||
return OSIP_NOMEM;
|
||||
memset (*jn, 0, sizeof (eXosip_notify_t));
|
||||
|
||||
#ifndef MINISIZE
|
||||
{
|
||||
struct timeval now;
|
||||
excontext->statistics.allocated_insubscriptions++;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_insubscriptions, 1, &now);
|
||||
}
|
||||
#endif
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -126,6 +129,10 @@ _eXosip_notify_free (struct eXosip_t *excontext, eXosip_notify_t * jn)
|
||||
if (jn->n_out_tr != NULL)
|
||||
osip_list_add (&excontext->j_transactions, jn->n_out_tr, 0);
|
||||
osip_free (jn);
|
||||
|
||||
#ifndef MINISIZE
|
||||
excontext->statistics.allocated_insubscriptions--;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
12
src/jpipe.c
12
src/jpipe.c
@@ -108,8 +108,14 @@ jpipe_get_read_descr (jpipe_t * apipe)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef WIN32
|
||||
#define SOCKET_TYPE SOCKET
|
||||
#else
|
||||
#define SOCKET_TYPE int
|
||||
#endif
|
||||
|
||||
int
|
||||
setNonBlocking (int fd)
|
||||
setNonBlocking (SOCKET_TYPE fd)
|
||||
{
|
||||
int flags;
|
||||
|
||||
@@ -221,7 +227,7 @@ jpipe ()
|
||||
|
||||
connect (my_pipe->pipes[1], (struct sockaddr *) &raddr, sizeof (raddr));
|
||||
|
||||
my_pipe->pipes[0] = accept (s, NULL, NULL);
|
||||
my_pipe->pipes[0] = (int)accept (s, NULL, NULL);
|
||||
|
||||
if (my_pipe->pipes[0] <= 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "udp plugin; Failed to call accept!\n"));
|
||||
@@ -295,7 +301,7 @@ jpipe_get_read_descr (jpipe_t * apipe)
|
||||
{
|
||||
if (apipe == NULL)
|
||||
return OSIP_BADPARAMETER;
|
||||
return apipe->pipes[0];
|
||||
return (int)apipe->pipes[0]; /* on windows, this is a conversion from SOCKET to int... doesn't seems to be an issue */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
16
src/jpipe.h
16
src/jpipe.h
@@ -76,8 +76,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
/**
|
||||
* Structure for storing a pipe descriptor
|
||||
* @defvar jpipe_t
|
||||
@@ -88,20 +86,6 @@ extern "C" {
|
||||
int pipes[2];
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Structure for storing a pipe descriptor
|
||||
* @defvar ppl_pipe_t
|
||||
*/
|
||||
typedef struct jpipe_t jpipe_t;
|
||||
|
||||
struct jpipe_t {
|
||||
int pipes[2];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get New pipe pair.
|
||||
*/
|
||||
|
||||
@@ -97,7 +97,7 @@ _eXosip_pub_find_by_tid (struct eXosip_t *excontext, eXosip_pub_t ** pjp, int ti
|
||||
}
|
||||
|
||||
int
|
||||
_eXosip_pub_init (eXosip_pub_t ** pub, const char *aor, const char *exp)
|
||||
_eXosip_pub_init (struct eXosip_t *excontext, eXosip_pub_t ** pub, const char *aor, const char *exp)
|
||||
{
|
||||
static int p_id = 0;
|
||||
eXosip_pub_t *jpub;
|
||||
@@ -117,6 +117,15 @@ _eXosip_pub_init (eXosip_pub_t ** pub, const char *aor, const char *exp)
|
||||
jpub->p_id = ++p_id;
|
||||
|
||||
*pub = jpub;
|
||||
|
||||
#ifndef MINISIZE
|
||||
{
|
||||
struct timeval now;
|
||||
excontext->statistics.allocated_publications++;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_publications, 1, &now);
|
||||
}
|
||||
#endif
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -130,6 +139,9 @@ _eXosip_pub_free (struct eXosip_t *excontext, eXosip_pub_t * pub)
|
||||
osip_list_add (&excontext->j_transactions, pub->p_last_tr, 0);
|
||||
}
|
||||
osip_free (pub);
|
||||
#ifndef MINISIZE
|
||||
excontext->statistics.allocated_publications--;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
12
src/jreg.c
12
src/jreg.c
@@ -119,6 +119,14 @@ _eXosip_reg_init (struct eXosip_t *excontext, eXosip_reg_t ** jr, const char *fr
|
||||
osip_strncpy ((*jr)->r_line, key_line, sizeof ((*jr)->r_line) - 1);
|
||||
}
|
||||
|
||||
#ifndef MINISIZE
|
||||
{
|
||||
struct timeval now;
|
||||
excontext->statistics.allocated_registrations++;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_registrations, 1, &now);
|
||||
}
|
||||
#endif
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -149,6 +157,10 @@ _eXosip_reg_free (struct eXosip_t *excontext, eXosip_reg_t * jreg)
|
||||
}
|
||||
|
||||
osip_free (jreg);
|
||||
|
||||
#ifndef MINISIZE
|
||||
excontext->statistics.allocated_registrations--;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
105
src/jrequest.c
105
src/jrequest.c
@@ -427,62 +427,44 @@ _eXosip_generating_request_out_of_dialog (struct eXosip_t *excontext, osip_messa
|
||||
}
|
||||
|
||||
if (request->to != NULL && request->to->url != NULL) {
|
||||
int pos = 0;
|
||||
size_t pname_len;
|
||||
osip_uri_param_t *u_param;
|
||||
osip_list_iterator_t it;
|
||||
osip_uri_param_t* u_param = (osip_uri_param_t*)osip_list_get_first(&request->to->url->url_params, &it);
|
||||
|
||||
pname_len = strlen ("method");
|
||||
while (!osip_list_eol (&request->to->url->url_params, pos)) {
|
||||
size_t len;
|
||||
|
||||
u_param = (osip_uri_param_t *) osip_list_get (&request->to->url->url_params, pos);
|
||||
len = strlen (u_param->gname);
|
||||
if (pname_len == len && osip_strncasecmp (u_param->gname, "method", pname_len) == 0 && u_param->gvalue != NULL) {
|
||||
osip_list_remove (&request->to->url->url_params, pos);
|
||||
while (u_param != NULL) {
|
||||
if (u_param->gvalue != NULL && u_param->gname!=NULL && osip_strcasecmp (u_param->gname, "method") == 0) {
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_uri_param_free (u_param);
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
u_param = (osip_uri_param_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
if (request->from != NULL && request->from->url != NULL) {
|
||||
int pos = 0;
|
||||
size_t pname_len;
|
||||
osip_uri_param_t *u_param;
|
||||
osip_list_iterator_t it;
|
||||
osip_uri_param_t* u_param = (osip_uri_param_t*)osip_list_get_first(&request->from->url->url_params, &it);
|
||||
|
||||
pname_len = strlen ("method");
|
||||
while (!osip_list_eol (&request->from->url->url_params, pos)) {
|
||||
size_t len;
|
||||
|
||||
u_param = (osip_uri_param_t *) osip_list_get (&request->from->url->url_params, pos);
|
||||
len = strlen (u_param->gname);
|
||||
if (pname_len == len && osip_strncasecmp (u_param->gname, "method", pname_len) == 0 && u_param->gvalue != NULL) {
|
||||
osip_list_remove (&request->from->url->url_params, pos);
|
||||
while (u_param != NULL) {
|
||||
if (u_param->gvalue != NULL && u_param->gname!=NULL && osip_strcasecmp (u_param->gname, "method") == 0) {
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_uri_param_free (u_param);
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
u_param = (osip_uri_param_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
if (request->req_uri) {
|
||||
int pos = 0;
|
||||
size_t pname_len;
|
||||
osip_uri_param_t *u_param;
|
||||
osip_list_iterator_t it;
|
||||
osip_uri_param_t* u_param = (osip_uri_param_t*)osip_list_get_first(&request->req_uri->url_params, &it);
|
||||
|
||||
pname_len = strlen ("method");
|
||||
while (!osip_list_eol (&request->req_uri->url_params, pos)) {
|
||||
size_t len;
|
||||
|
||||
u_param = (osip_uri_param_t *) osip_list_get (&request->req_uri->url_params, pos);
|
||||
len = strlen (u_param->gname);
|
||||
if (pname_len == len && osip_strncasecmp (u_param->gname, "method", pname_len) == 0 && u_param->gvalue != NULL) {
|
||||
osip_list_remove (&request->req_uri->url_params, pos);
|
||||
while (u_param != NULL) {
|
||||
if (u_param->gvalue != NULL && u_param->gname!=NULL && osip_strcasecmp (u_param->gname, "method") == 0) {
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_uri_param_free (u_param);
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
u_param = (osip_uri_param_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,15 +560,12 @@ dialog_fill_route_set (osip_dialog_t * dialog, osip_message_t * request)
|
||||
/* if the pre-existing route set contains a "lr" (compliance
|
||||
with bis-08) then the req_uri should contains the remote target
|
||||
URI */
|
||||
osip_list_iterator_t it;
|
||||
int i;
|
||||
int pos = 0;
|
||||
osip_uri_param_t *lr_param;
|
||||
osip_route_t *route;
|
||||
char *last_route;
|
||||
|
||||
/* AMD bug: fixed 17/06/2002 */
|
||||
|
||||
route = (osip_route_t *) osip_list_get (&dialog->route_set, 0);
|
||||
route = (osip_route_t*)osip_list_get_first(&dialog->route_set, &it);
|
||||
|
||||
osip_uri_uparam_get_byname (route->url, "lr", &lr_param);
|
||||
if (lr_param != NULL) { /* the remote target URI is the req_uri! */
|
||||
@@ -595,17 +574,15 @@ dialog_fill_route_set (osip_dialog_t * dialog, osip_message_t * request)
|
||||
return i;
|
||||
/* "[request] MUST includes a Route header field containing
|
||||
the route set values in order." */
|
||||
/* AMD bug: fixed 17/06/2002 */
|
||||
pos = 0; /* first element is at index 0 */
|
||||
while (!osip_list_eol (&dialog->route_set, pos)) {
|
||||
|
||||
while (route != NULL) {
|
||||
osip_route_t *route2;
|
||||
|
||||
route = osip_list_get (&dialog->route_set, pos);
|
||||
i = osip_route_clone (route, &route2);
|
||||
if (i != 0)
|
||||
return i;
|
||||
osip_list_add (&request->routes, route2, -1);
|
||||
pos++;
|
||||
route = (osip_route_t*)osip_list_get_next(&it);
|
||||
}
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
@@ -620,28 +597,33 @@ dialog_fill_route_set (osip_dialog_t * dialog, osip_message_t * request)
|
||||
/* add the route set */
|
||||
/* "The UAC MUST add a route header field containing
|
||||
the remainder of the route set values in order. */
|
||||
pos = 1; /* yes it is */
|
||||
route = (osip_route_t*)osip_list_get_next(&it); /* yes it is, skip first */
|
||||
|
||||
while (!osip_list_eol (&dialog->route_set, pos)) {
|
||||
while (route != NULL) {
|
||||
osip_route_t *route2;
|
||||
|
||||
route = osip_list_get (&dialog->route_set, pos);
|
||||
i = osip_route_clone (route, &route2);
|
||||
if (i != 0)
|
||||
return i;
|
||||
osip_list_add (&request->routes, route2, -1);
|
||||
pos++;
|
||||
route = (osip_route_t*)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
/* The UAC MUST then place the remote target URI into
|
||||
the route header field as the last value */
|
||||
i = osip_uri_to_str (dialog->remote_contact_uri->url, &last_route);
|
||||
if (i != 0)
|
||||
return i;
|
||||
i = osip_message_set_route (request, last_route);
|
||||
osip_free (last_route);
|
||||
if (i != 0) {
|
||||
return i;
|
||||
{
|
||||
osip_uri_t *new_url;
|
||||
/* Feb 05, 2016: old code was converting contact's URI's uri-param into Route route-param */
|
||||
i = osip_uri_clone(dialog->remote_contact_uri->url, &new_url);
|
||||
if (i != 0)
|
||||
return i;
|
||||
i = osip_route_init(&route);
|
||||
if (i != 0) {
|
||||
osip_uri_free(new_url);
|
||||
return i;
|
||||
}
|
||||
osip_uri_free(route->url);
|
||||
route->url = new_url;
|
||||
}
|
||||
|
||||
/* route header and req_uri set */
|
||||
@@ -888,12 +870,11 @@ _eXosip_generating_cancel (struct eXosip_t *excontext, osip_message_t ** dest, o
|
||||
|
||||
/* add the same route-set than in the previous request */
|
||||
{
|
||||
int pos = 0;
|
||||
osip_route_t *route;
|
||||
osip_list_iterator_t it;
|
||||
osip_route_t* route = (osip_route_t*)osip_list_get_first(&request_cancelled->routes, &it);
|
||||
osip_route_t *route2;
|
||||
|
||||
while (!osip_list_eol (&request_cancelled->routes, pos)) {
|
||||
route = (osip_route_t *) osip_list_get (&request_cancelled->routes, pos);
|
||||
while (route != NULL) {
|
||||
i = osip_route_clone (route, &route2);
|
||||
if (i != 0) {
|
||||
osip_message_free (request);
|
||||
@@ -901,7 +882,7 @@ _eXosip_generating_cancel (struct eXosip_t *excontext, osip_message_t ** dest, o
|
||||
return i;
|
||||
}
|
||||
osip_list_add (&request->routes, route2, -1);
|
||||
pos++;
|
||||
route = (osip_route_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ _eXosip_build_response_default (struct eXosip_t *excontext, osip_message_t ** de
|
||||
{
|
||||
osip_generic_param_t *tag;
|
||||
osip_message_t *response;
|
||||
int pos;
|
||||
int i;
|
||||
|
||||
*dest = NULL;
|
||||
@@ -119,19 +118,21 @@ _eXosip_build_response_default (struct eXosip_t *excontext, osip_message_t ** de
|
||||
return i;
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol (&request->vias, pos)) {
|
||||
osip_via_t *via;
|
||||
osip_via_t *via2;
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
osip_via_t *via = (osip_via_t*)osip_list_get_first(&request->vias, &it);
|
||||
|
||||
via = (osip_via_t *) osip_list_get (&request->vias, pos);
|
||||
i = osip_via_clone (via, &via2);
|
||||
if (i != 0) {
|
||||
osip_message_free (response);
|
||||
return i;
|
||||
while (via != NULL) {
|
||||
osip_via_t *via2;
|
||||
|
||||
i = osip_via_clone (via, &via2);
|
||||
if (i != 0) {
|
||||
osip_message_free (response);
|
||||
return i;
|
||||
}
|
||||
osip_list_add (&response->vias, via2, -1);
|
||||
via = (osip_via_t *)osip_list_get_next(&it);
|
||||
}
|
||||
osip_list_add (&response->vias, via2, -1);
|
||||
pos++;
|
||||
}
|
||||
|
||||
i = osip_call_id_clone (request->call_id, &(response->call_id));
|
||||
@@ -175,9 +176,11 @@ int
|
||||
_eXosip_complete_answer_that_establish_a_dialog (struct eXosip_t *excontext, osip_message_t * response, osip_message_t * request)
|
||||
{
|
||||
int i;
|
||||
int pos = 0;
|
||||
int route_found = 0;
|
||||
char contact[1024];
|
||||
char scheme[10];
|
||||
osip_list_iterator_t it;
|
||||
osip_record_route_t *rr;
|
||||
|
||||
snprintf(scheme, sizeof(scheme), "sip");
|
||||
|
||||
@@ -185,31 +188,31 @@ _eXosip_complete_answer_that_establish_a_dialog (struct eXosip_t *excontext, osi
|
||||
copy all record-route in response
|
||||
add a contact with global scope
|
||||
*/
|
||||
while (!osip_list_eol (&request->record_routes, pos)) {
|
||||
osip_record_route_t *rr;
|
||||
rr = (osip_record_route_t *)osip_list_get_first(&request->record_routes, &it);
|
||||
while (rr != NULL) {
|
||||
osip_record_route_t *rr2;
|
||||
|
||||
rr = (osip_record_route_t *) osip_list_get (&request->record_routes, pos);
|
||||
i = osip_record_route_clone (rr, &rr2);
|
||||
if (i != 0)
|
||||
return i;
|
||||
osip_list_add (&response->record_routes, rr2, -1);
|
||||
|
||||
/* rfc3261: 12.1.1 UAS behavior (check sips in top most Record-Route) */
|
||||
if (pos==0 && rr2!=NULL && rr2->url!=NULL && rr2->url->scheme!=NULL && osip_strcasecmp(rr2->url->scheme, "sips")==0)
|
||||
if (it.pos==0 && rr2!=NULL && rr2->url!=NULL && rr2->url->scheme!=NULL && osip_strcasecmp(rr2->url->scheme, "sips")==0)
|
||||
snprintf(scheme, sizeof(scheme), "sips");
|
||||
|
||||
pos++;
|
||||
rr = (osip_record_route_t *)osip_list_get_next(&it);
|
||||
route_found=1;
|
||||
}
|
||||
|
||||
if (MSG_IS_BYE (request)) {
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
if (pos==0) {
|
||||
if (route_found==0) {
|
||||
/* rfc3261: 12.1.1 UAS behavior (check sips in Contact if no Record-Route) */
|
||||
osip_contact_t *co = (osip_contact_t *) osip_list_get(&request->contacts, 0);
|
||||
if (pos==0 && co!=NULL && co->url!=NULL && co->url->scheme!=NULL && osip_strcasecmp(co->url->scheme, "sips")==0)
|
||||
if (co!=NULL && co->url!=NULL && co->url->scheme!=NULL && osip_strcasecmp(co->url->scheme, "sips")==0)
|
||||
snprintf(scheme, sizeof(scheme), "sips");
|
||||
}
|
||||
/* rfc3261: 12.1.1 UAS behavior (check sips in Request-URI) */
|
||||
|
||||
@@ -38,24 +38,19 @@ osip_transaction_t *
|
||||
_eXosip_find_last_out_subscribe (eXosip_subscribe_t * js, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_transaction_t *out_tr;
|
||||
int pos;
|
||||
|
||||
out_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (0 == strcmp (out_tr->cseq->method, "SUBSCRIBE"))
|
||||
break;
|
||||
else if (0 == strcmp (out_tr->cseq->method, "REFER"))
|
||||
break;
|
||||
else
|
||||
out_tr = NULL;
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
else
|
||||
out_tr = NULL;
|
||||
|
||||
if (out_tr == NULL)
|
||||
return js->s_out_tr; /* can be NULL */
|
||||
@@ -67,38 +62,43 @@ osip_transaction_t *
|
||||
_eXosip_find_last_inc_notify (eXosip_subscribe_t * js, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_transaction_t *out_tr;
|
||||
int pos;
|
||||
|
||||
out_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (0 == strcmp (out_tr->cseq->method, "NOTIFY"))
|
||||
return out_tr;
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_eXosip_subscription_init (eXosip_subscribe_t ** js)
|
||||
_eXosip_subscription_init (struct eXosip_t *excontext, eXosip_subscribe_t ** js)
|
||||
{
|
||||
*js = (eXosip_subscribe_t *) osip_malloc (sizeof (eXosip_subscribe_t));
|
||||
if (*js == NULL)
|
||||
return OSIP_NOMEM;
|
||||
memset (*js, 0, sizeof (eXosip_subscribe_t));
|
||||
|
||||
#ifndef MINISIZE
|
||||
{
|
||||
struct timeval now;
|
||||
excontext->statistics.allocated_subscriptions++;
|
||||
osip_gettimeofday(&now, NULL);
|
||||
_eXosip_counters_update(&excontext->average_subscriptions, 1, &now);
|
||||
}
|
||||
#endif
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_eXosip_subscription_free (struct eXosip_t *excontext, eXosip_subscribe_t * js)
|
||||
{
|
||||
/* ... */
|
||||
|
||||
eXosip_dialog_t *jd;
|
||||
|
||||
if (js->s_inc_tr != NULL && js->s_inc_tr->orig_request != NULL && js->s_inc_tr->orig_request->call_id != NULL && js->s_inc_tr->orig_request->call_id->number != NULL)
|
||||
@@ -119,6 +119,9 @@ _eXosip_subscription_free (struct eXosip_t *excontext, eXosip_subscribe_t * js)
|
||||
osip_list_add (&excontext->j_transactions, js->s_out_tr, 0);
|
||||
|
||||
osip_free (js);
|
||||
#ifndef MINISIZE
|
||||
excontext->statistics.allocated_subscriptions--;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
102
src/misc.c
102
src/misc.c
@@ -40,7 +40,6 @@ _eXosip_remove_transaction_from_call (osip_transaction_t * tr, eXosip_call_t * j
|
||||
osip_transaction_t *inc_tr;
|
||||
osip_transaction_t *out_tr;
|
||||
eXosip_dialog_t *jd;
|
||||
int pos = 0;
|
||||
|
||||
if (jc->c_inc_tr == tr) {
|
||||
jc->c_inc_tr = NULL; /* can be NULL */
|
||||
@@ -48,14 +47,14 @@ _eXosip_remove_transaction_from_call (osip_transaction_t * tr, eXosip_call_t * j
|
||||
}
|
||||
|
||||
for (jd = jc->c_dialogs; jd != NULL; jd = jd->next) {
|
||||
pos = 0;
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
inc_tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (inc_tr != OSIP_SUCCESS) {
|
||||
if (inc_tr == tr) {
|
||||
osip_list_remove (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,14 +64,14 @@ _eXosip_remove_transaction_from_call (osip_transaction_t * tr, eXosip_call_t * j
|
||||
}
|
||||
|
||||
for (jd = jc->c_dialogs; jd != NULL; jd = jd->next) {
|
||||
pos = 0;
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (out_tr == tr) {
|
||||
osip_list_remove (jd->d_out_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,24 +101,20 @@ osip_transaction_t *
|
||||
_eXosip_find_last_inc_transaction (eXosip_call_t * jc, eXosip_dialog_t * jd, const char *method)
|
||||
{
|
||||
osip_transaction_t *inc_tr;
|
||||
int pos;
|
||||
|
||||
inc_tr = NULL;
|
||||
pos = 0;
|
||||
if (method == NULL || method[0] == '\0')
|
||||
return NULL;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
inc_tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (inc_tr != OSIP_SUCCESS) {
|
||||
if (0 == osip_strcasecmp (inc_tr->cseq->method, method))
|
||||
break;
|
||||
else
|
||||
inc_tr = NULL;
|
||||
pos++;
|
||||
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
else
|
||||
inc_tr = NULL;
|
||||
|
||||
return inc_tr;
|
||||
}
|
||||
@@ -128,23 +123,20 @@ osip_transaction_t *
|
||||
_eXosip_find_last_out_transaction (eXosip_call_t * jc, eXosip_dialog_t * jd, const char *method)
|
||||
{
|
||||
osip_transaction_t *out_tr;
|
||||
int pos;
|
||||
|
||||
out_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd == NULL && jc == NULL)
|
||||
return NULL;
|
||||
if (method == NULL || method[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (0 == osip_strcasecmp (out_tr->cseq->method, method))
|
||||
break;
|
||||
else
|
||||
out_tr = NULL;
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,22 +165,17 @@ osip_transaction_t *
|
||||
_eXosip_find_last_inc_invite (eXosip_call_t * jc, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_transaction_t *inc_tr;
|
||||
int pos;
|
||||
|
||||
inc_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
inc_tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (inc_tr != OSIP_SUCCESS) {
|
||||
if (0 == strcmp (inc_tr->cseq->method, "INVITE"))
|
||||
break;
|
||||
else
|
||||
inc_tr = NULL;
|
||||
pos++;
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
else
|
||||
inc_tr = NULL;
|
||||
|
||||
if (inc_tr == NULL)
|
||||
return jc->c_inc_tr; /* can be NULL */
|
||||
@@ -200,21 +187,18 @@ osip_transaction_t *
|
||||
_eXosip_find_last_out_invite (eXosip_call_t * jc, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_transaction_t *out_tr;
|
||||
int pos;
|
||||
|
||||
out_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd == NULL && jc == NULL)
|
||||
return NULL;
|
||||
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (0 == strcmp (out_tr->cseq->method, "INVITE"))
|
||||
break;
|
||||
else
|
||||
out_tr = NULL;
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,26 +215,21 @@ _eXosip_find_previous_invite (eXosip_call_t * jc, eXosip_dialog_t * jd, osip_tra
|
||||
{
|
||||
osip_transaction_t *inc_tr;
|
||||
osip_transaction_t *out_tr;
|
||||
int pos;
|
||||
|
||||
inc_tr = NULL;
|
||||
pos = 0;
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
if (inc_tr == last_invite) {
|
||||
osip_list_iterator_t it;
|
||||
inc_tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (inc_tr != OSIP_SUCCESS) {
|
||||
if (inc_tr != last_invite) {
|
||||
/* we don't want the current one */
|
||||
inc_tr = NULL;
|
||||
if (0 == strcmp (inc_tr->cseq->method, "INVITE"))
|
||||
break;
|
||||
}
|
||||
else if (0 == strcmp (inc_tr->cseq->method, "INVITE"))
|
||||
break;
|
||||
else
|
||||
inc_tr = NULL;
|
||||
pos++;
|
||||
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
else
|
||||
inc_tr = NULL;
|
||||
|
||||
if (inc_tr == NULL)
|
||||
inc_tr = jc->c_inc_tr; /* can be NULL */
|
||||
@@ -260,20 +239,19 @@ _eXosip_find_previous_invite (eXosip_call_t * jc, eXosip_dialog_t * jd, osip_tra
|
||||
}
|
||||
|
||||
out_tr = NULL;
|
||||
pos = 0;
|
||||
|
||||
if (jd != NULL) {
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (out_tr == last_invite) {
|
||||
/* we don't want the current one */
|
||||
out_tr = NULL;
|
||||
}
|
||||
else if (0 == strcmp (out_tr->cseq->method, "INVITE"))
|
||||
break;
|
||||
else
|
||||
out_tr = NULL;
|
||||
pos++;
|
||||
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ eXosip_get_sdp_info (osip_message_t * message)
|
||||
osip_content_type_t *ctt;
|
||||
sdp_message_t *sdp;
|
||||
osip_body_t *oldbody;
|
||||
int pos;
|
||||
osip_list_iterator_t it;
|
||||
|
||||
if (message == NULL)
|
||||
return NULL;
|
||||
@@ -204,18 +204,16 @@ eXosip_get_sdp_info (osip_message_t * message)
|
||||
else if (osip_strcasecmp (ctt->type, "application") != 0 || osip_strcasecmp (ctt->subtype, "sdp") != 0)
|
||||
return NULL;
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol (&message->bodies, pos)) {
|
||||
oldbody = (osip_body_t *)osip_list_get_first(&message->bodies, &it);
|
||||
while (oldbody != NULL) {
|
||||
int i;
|
||||
|
||||
oldbody = (osip_body_t *) osip_list_get (&message->bodies, pos);
|
||||
pos++;
|
||||
sdp_message_init (&sdp);
|
||||
i = sdp_message_parse (sdp, oldbody->body);
|
||||
if (i == 0)
|
||||
return sdp;
|
||||
sdp_message_free (sdp);
|
||||
sdp = NULL;
|
||||
oldbody = (osip_body_t *)osip_list_get_next(&it);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
110
src/udp.c
110
src/udp.c
@@ -246,15 +246,13 @@ _eXosip_process_cancel (struct eXosip_t *excontext, osip_transaction_t * transac
|
||||
}
|
||||
tr = NULL;
|
||||
for (jd = jc->c_dialogs; jd != NULL; jd = jd->next) {
|
||||
int pos = 0;
|
||||
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_t it;
|
||||
tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (tr != OSIP_SUCCESS) {
|
||||
i = _cancel_match_invite (tr, evt->sip);
|
||||
if (i == 0)
|
||||
break;
|
||||
tr = NULL;
|
||||
pos++;
|
||||
tr = (osip_transaction_t *)osip_list_get_next(&it);;
|
||||
}
|
||||
if (tr != NULL)
|
||||
break;
|
||||
@@ -409,7 +407,7 @@ _eXosip_process_new_invite (struct eXosip_t *excontext, osip_transaction_t * tra
|
||||
return;
|
||||
}
|
||||
|
||||
_eXosip_call_init (&jc);
|
||||
_eXosip_call_init (excontext, &jc);
|
||||
|
||||
ADD_ELEMENT (excontext->j_calls, jc);
|
||||
|
||||
@@ -492,7 +490,7 @@ _eXosip_process_new_subscription (struct eXosip_t *excontext, osip_transaction_t
|
||||
return;
|
||||
}
|
||||
|
||||
i = _eXosip_notify_init (&jn, evt->sip);
|
||||
i = _eXosip_notify_init (excontext, &jn, evt->sip);
|
||||
if (i != 0) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "ERROR: missing contact or memory\n"));
|
||||
i = _eXosip_build_response_default (excontext, &answer, NULL, 400, evt->sip);
|
||||
@@ -850,9 +848,7 @@ _eXosip_process_newrequest (struct eXosip_t *excontext, osip_event_t * evt, int
|
||||
if (osip_strcasecmp (br->gvalue, br2->gvalue) == 0) {
|
||||
/* use-case: 1/ a duplicate of initial INVITE is received (same TOP Via header) after we replied -> discard */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: drop INVITE retransmission after INVITE reply\n"));
|
||||
_eXosip_dnsutils_release (transaction->naptr_record);
|
||||
transaction->naptr_record = NULL;
|
||||
osip_transaction_free (transaction);
|
||||
_eXosip_transaction_free (excontext, transaction);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -872,9 +868,7 @@ _eXosip_process_newrequest (struct eXosip_t *excontext, osip_event_t * evt, int
|
||||
|
||||
if (jd != NULL) {
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: receive a request with same cseq??\n"));
|
||||
_eXosip_dnsutils_release (transaction->naptr_record);
|
||||
transaction->naptr_record = NULL;
|
||||
osip_transaction_free (transaction);
|
||||
_eXosip_transaction_free (excontext, transaction);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -884,10 +878,7 @@ _eXosip_process_newrequest (struct eXosip_t *excontext, osip_event_t * evt, int
|
||||
if (ctx_type == IST) {
|
||||
i = _eXosip_build_response_default (excontext, &answer, NULL, 100, evt->sip);
|
||||
if (i != 0) {
|
||||
_eXosip_delete_reserved (transaction);
|
||||
_eXosip_dnsutils_release (transaction->naptr_record);
|
||||
transaction->naptr_record = NULL;
|
||||
osip_transaction_free (transaction);
|
||||
_eXosip_transaction_free (excontext, transaction);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1649,6 +1640,7 @@ _eXosip_read_message (struct eXosip_t *excontext, int max_message_nb, int sec_ma
|
||||
#endif
|
||||
|
||||
if (0 == i || excontext->j_stop_ua != 0) {
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
else if (-1 == i) {
|
||||
#if !defined (_WIN32_WCE) /* TODO: fix me for wince */
|
||||
@@ -1673,6 +1665,10 @@ _eXosip_read_message (struct eXosip_t *excontext, int max_message_nb, int sec_ma
|
||||
}
|
||||
}
|
||||
|
||||
/* avoid infinite select if a message was read at the very end of period */
|
||||
if (tv.tv_sec == 0 && tv.tv_usec == 0 && (sec_max != 0 || usec_max != 0)) {
|
||||
return OSIP_SUCCESS;
|
||||
}
|
||||
max_message_nb--;
|
||||
}
|
||||
return OSIP_SUCCESS;
|
||||
@@ -1754,11 +1750,11 @@ _eXosip_pendingosip_transaction_exist (struct eXosip_t *excontext, eXosip_call_t
|
||||
static int
|
||||
_eXosip_release_finished_transactions (struct eXosip_t *excontext, eXosip_call_t * jc, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
time_t now = osip_getsystemtime (NULL);
|
||||
osip_transaction_t *inc_tr;
|
||||
osip_transaction_t *out_tr;
|
||||
osip_transaction_t *last_invite;
|
||||
int pos;
|
||||
int ret;
|
||||
|
||||
ret = -1;
|
||||
@@ -1767,16 +1763,16 @@ _eXosip_release_finished_transactions (struct eXosip_t *excontext, eXosip_call_t
|
||||
|
||||
if (jd != NULL) {
|
||||
/* go through all incoming transactions of this dialog */
|
||||
pos = 1;
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
inc_tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
if (inc_tr!=NULL) inc_tr = (osip_transaction_t *)osip_list_get_next(&it); /* skip first one */
|
||||
while (inc_tr != OSIP_SUCCESS) {
|
||||
if (0 != osip_strcasecmp (inc_tr->cseq->method, "INVITE")) {
|
||||
/* remove, if transaction too old, independent of the state */
|
||||
if ((inc_tr->state == NIST_TERMINATED) && (inc_tr->birth_time + 30 < now)) { /* Wait a max of 30 seconds */
|
||||
/* remove the transaction from oSIP */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release non-INVITE server transaction (did=%i)\n", jd->d_id));
|
||||
osip_remove_transaction (excontext->j_osip, inc_tr);
|
||||
osip_list_remove (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_list_add (&excontext->j_transactions, inc_tr, 0);
|
||||
|
||||
ret = 0;
|
||||
@@ -1789,29 +1785,29 @@ _eXosip_release_finished_transactions (struct eXosip_t *excontext, eXosip_call_t
|
||||
/* remove the transaction from oSIP */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release INVITE server transaction (did=%i)\n", jd->d_id));
|
||||
osip_remove_transaction (excontext->j_osip, inc_tr);
|
||||
osip_list_remove (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_list_add (&excontext->j_transactions, inc_tr, 0);
|
||||
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
last_invite = _eXosip_find_last_out_invite (jc, jd);
|
||||
|
||||
/* go through all outgoing transactions of this dialog */
|
||||
pos = 1;
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
if (out_tr!=NULL) out_tr = (osip_transaction_t *)osip_list_get_next(&it); /* skip first one */
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
if (0 != osip_strcasecmp (out_tr->cseq->method, "INVITE")) {
|
||||
/* remove, if transaction too old, independent of the state */
|
||||
if ((out_tr->state == NICT_TERMINATED) && (out_tr->birth_time + 30 < now)) { /* Wait a max of 30 seconds */
|
||||
/* remove the transaction from oSIP */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release non INVITE client transaction (did=%i)\n", jd->d_id));
|
||||
osip_remove_transaction (excontext->j_osip, out_tr);
|
||||
osip_list_remove (jd->d_out_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_list_add (&excontext->j_transactions, out_tr, 0);
|
||||
|
||||
ret = 0;
|
||||
@@ -1824,14 +1820,14 @@ _eXosip_release_finished_transactions (struct eXosip_t *excontext, eXosip_call_t
|
||||
/* remove the transaction from oSIP */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release INVITE client transaction (did=%i)\n", jd->d_id));
|
||||
osip_remove_transaction (excontext->j_osip, out_tr);
|
||||
osip_list_remove (jd->d_out_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_list_add (&excontext->j_transactions, out_tr, 0);
|
||||
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1941,12 +1937,13 @@ _eXosip_release_aborted_calls (struct eXosip_t *excontext, eXosip_call_t * jc, e
|
||||
void
|
||||
_eXosip_release_terminated_calls (struct eXosip_t *excontext)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
osip_transaction_t *tr;
|
||||
eXosip_dialog_t *jd;
|
||||
eXosip_dialog_t *jdnext;
|
||||
eXosip_call_t *jc;
|
||||
eXosip_call_t *jcnext;
|
||||
time_t now = osip_getsystemtime (NULL);
|
||||
int pos;
|
||||
|
||||
|
||||
for (jc = excontext->j_calls; jc != NULL;) {
|
||||
@@ -2012,30 +2009,25 @@ _eXosip_release_terminated_calls (struct eXosip_t *excontext)
|
||||
jc = jcnext;
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
while (!osip_list_eol (&excontext->j_transactions, pos)) {
|
||||
osip_transaction_t *tr = (osip_transaction_t *) osip_list_get (&excontext->j_transactions, pos);
|
||||
|
||||
tr = (osip_transaction_t*)osip_list_get_first(&excontext->j_transactions, &it);
|
||||
while (tr != NULL) {
|
||||
|
||||
if (tr->state == NICT_TERMINATED && tr->last_response != NULL && tr->completed_time + 5 > now) {
|
||||
/* keep transaction until authentication or ... */
|
||||
pos++;
|
||||
}
|
||||
else if (tr->state == IST_TERMINATED || tr->state == ICT_TERMINATED || tr->state == NICT_TERMINATED || tr->state == NIST_TERMINATED) { /* free (transaction is already removed from the oSIP stack) */
|
||||
osip_list_remove (&excontext->j_transactions, pos);
|
||||
_eXosip_delete_reserved (tr);
|
||||
_eXosip_dnsutils_release (tr->naptr_record);
|
||||
tr->naptr_record = NULL;
|
||||
osip_transaction_free (tr);
|
||||
_eXosip_transaction_free (excontext, tr);
|
||||
tr = (osip_transaction_t *)osip_list_iterator_remove(&it);
|
||||
continue;
|
||||
}
|
||||
else if (tr->birth_time + 180 < now) { /* Wait a max of 2 minutes */
|
||||
osip_list_remove (&excontext->j_transactions, pos);
|
||||
_eXosip_delete_reserved (tr);
|
||||
_eXosip_dnsutils_release (tr->naptr_record);
|
||||
tr->naptr_record = NULL;
|
||||
osip_transaction_free (tr);
|
||||
_eXosip_transaction_free (excontext, tr);
|
||||
tr = (osip_transaction_t *)osip_list_iterator_remove(&it);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
pos++;
|
||||
|
||||
tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2100,26 +2092,25 @@ _eXosip_release_terminated_publications (struct eXosip_t *excontext)
|
||||
static int
|
||||
_eXosip_release_finished_transactions_for_subscription (struct eXosip_t *excontext, eXosip_dialog_t * jd)
|
||||
{
|
||||
osip_list_iterator_t it;
|
||||
time_t now = osip_getsystemtime (NULL);
|
||||
osip_transaction_t *inc_tr;
|
||||
osip_transaction_t *out_tr;
|
||||
int skip_first = 0;
|
||||
int pos;
|
||||
int ret;
|
||||
|
||||
ret = OSIP_UNDEFINED_ERROR;
|
||||
|
||||
if (jd != NULL) {
|
||||
/* go through all incoming transactions of this dialog */
|
||||
pos = 0;
|
||||
while (!osip_list_eol (jd->d_inc_trs, pos)) {
|
||||
inc_tr = osip_list_get (jd->d_inc_trs, pos);
|
||||
inc_tr = (osip_transaction_t*)osip_list_get_first(jd->d_inc_trs, &it);
|
||||
while (inc_tr != OSIP_SUCCESS) {
|
||||
/* remove, if transaction too old, independent of the state */
|
||||
if ((skip_first == 1) && (inc_tr->state == NIST_TERMINATED) && (inc_tr->birth_time + 30 < now)) { /* keep it for 30 seconds */
|
||||
/* remove the transaction from oSIP */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release non-INVITE server transaction (did=%i)\n", jd->d_id));
|
||||
osip_remove_transaction (excontext->j_osip, inc_tr);
|
||||
osip_list_remove (jd->d_inc_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_list_add (&excontext->j_transactions, inc_tr, 0);
|
||||
|
||||
ret = OSIP_SUCCESS; /* return "released" */
|
||||
@@ -2131,21 +2122,21 @@ _eXosip_release_finished_transactions_for_subscription (struct eXosip_t *exconte
|
||||
skip_first = 1;
|
||||
if (0 == osip_strcasecmp (inc_tr->cseq->method, "NOTIFY"))
|
||||
skip_first = 1;
|
||||
pos++;
|
||||
inc_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
|
||||
skip_first = 0;
|
||||
|
||||
/* go through all outgoing transactions of this dialog */
|
||||
pos = 0;
|
||||
while (!osip_list_eol (jd->d_out_trs, pos)) {
|
||||
out_tr = osip_list_get (jd->d_out_trs, pos);
|
||||
|
||||
out_tr = (osip_transaction_t*)osip_list_get_first(jd->d_out_trs, &it);
|
||||
while (out_tr != OSIP_SUCCESS) {
|
||||
/* remove, if transaction too old, independent of the state */
|
||||
if ((skip_first == 1) && (out_tr->state == NICT_TERMINATED) && (out_tr->birth_time + 30 < now)) { /* Wait a max of 30 seconds */
|
||||
/* remove the transaction from oSIP */
|
||||
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release non INVITE client transaction (did=%i)\n", jd->d_id));
|
||||
osip_remove_transaction (excontext->j_osip, out_tr);
|
||||
osip_list_remove (jd->d_out_trs, pos);
|
||||
osip_list_iterator_remove(&it);
|
||||
osip_list_add (&excontext->j_transactions, out_tr, 0);
|
||||
|
||||
ret = OSIP_SUCCESS; /* return "released" */
|
||||
@@ -2157,7 +2148,8 @@ _eXosip_release_finished_transactions_for_subscription (struct eXosip_t *exconte
|
||||
skip_first = 1;
|
||||
if (0 == osip_strcasecmp (out_tr->cseq->method, "NOTIFY"))
|
||||
skip_first = 1;
|
||||
pos++;
|
||||
|
||||
out_tr = (osip_transaction_t *)osip_list_get_next(&it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ if COMPILE_TOOLS
|
||||
bin_PROGRAMS = sip_reg
|
||||
endif
|
||||
|
||||
AM_CFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @EXOSIP_FLAGS@
|
||||
AM_CFLAGS = $(EXOSIP_FLAGS)
|
||||
|
||||
sip_reg_SOURCES = sip_reg.c
|
||||
sip_reg_LDADD = $(top_builddir)/src/libeXosip2.la @TOOLS_LIBS@ $(OSIP_LIBS) $(EXOSIP_LIB) $(PTHREAD_LIBS)
|
||||
sip_reg_LDADD = $(top_builddir)/src/libeXosip2.la $(OSIP_LIBS)
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include $(OSIP_CFLAGS)
|
||||
|
||||
143
tools/sip_reg.c
143
tools/sip_reg.c
@@ -44,6 +44,10 @@
|
||||
#ifndef OSIP_MONOTHREAD
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef __linux
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
@@ -64,6 +68,15 @@
|
||||
#define UA_STRING "SipReg v" PROG_VER
|
||||
#define SYSLOG_FACILITY LOG_DAEMON
|
||||
|
||||
static volatile int keepRunning = 1;
|
||||
|
||||
#ifdef __linux
|
||||
|
||||
static void intHandler(int dummy) {
|
||||
keepRunning = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
static void
|
||||
syslog_wrapper (int a, const char *fmt, ...)
|
||||
@@ -90,10 +103,6 @@ syslog_wrapper (int a, const char *fmt, ...)
|
||||
|
||||
static void usage (void);
|
||||
|
||||
#ifndef OSIP_MONOTHREAD
|
||||
static void *register_proc (void *arg);
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
@@ -116,36 +125,6 @@ typedef struct regparam_t {
|
||||
|
||||
struct eXosip_t *context_eXosip;
|
||||
|
||||
#ifndef OSIP_MONOTHREAD
|
||||
static void *
|
||||
register_proc (void *arg)
|
||||
{
|
||||
struct regparam_t *regparam = arg;
|
||||
int reg;
|
||||
|
||||
for (;;) {
|
||||
#ifdef _WIN32_WCE
|
||||
Sleep ((regparam->expiry / 2) * 1000);
|
||||
#else
|
||||
sleep (regparam->expiry / 2);
|
||||
#endif
|
||||
eXosip_lock (context_eXosip);
|
||||
reg = eXosip_register_send_register (context_eXosip, regparam->regid, NULL);
|
||||
if (0 > reg) {
|
||||
#ifdef _WIN32_WCE
|
||||
fprintf (stdout, "eXosip_register: error while registring");
|
||||
#else
|
||||
perror ("eXosip_register");
|
||||
#endif
|
||||
exit (1);
|
||||
}
|
||||
regparam->auth = 0;
|
||||
eXosip_unlock (context_eXosip);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
int WINAPI
|
||||
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||
@@ -168,12 +147,13 @@ main (int argc, char *argv[])
|
||||
char *username = NULL;
|
||||
char *password = NULL;
|
||||
struct regparam_t regparam = { 0, 3600, 0 };
|
||||
#ifndef OSIP_MONOTHREAD
|
||||
struct osip_thread *register_thread;
|
||||
#endif
|
||||
int debug = 0;
|
||||
int nofork = 0;
|
||||
|
||||
#ifdef __linux
|
||||
signal(SIGINT, intHandler);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
proxy = osip_strdup ("sip:sip.antisip.com");
|
||||
fromuser = osip_strdup ("sip:jack@sip.antisip.com");
|
||||
@@ -329,22 +309,26 @@ main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OSIP_MONOTHREAD
|
||||
register_thread = osip_thread_create (20000, register_proc, ®param);
|
||||
if (register_thread == NULL) {
|
||||
syslog_wrapper (LOG_ERR, "pthread_create failed");
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
for (;keepRunning;) {
|
||||
static int counter=0;
|
||||
eXosip_event_t *event;
|
||||
|
||||
counter++;
|
||||
if (counter%60000==0) {
|
||||
struct eXosip_stats stats;
|
||||
memset(&stats, 0, sizeof(struct eXosip_stats));
|
||||
eXosip_lock (context_eXosip);
|
||||
eXosip_set_option(context_eXosip, EXOSIP_OPT_GET_STATISTICS, &stats);
|
||||
eXosip_unlock (context_eXosip);
|
||||
syslog_wrapper (LOG_INFO, "eXosip stats: inmemory=(tr:%i//reg:%i) average=(tr:%f//reg:%f)",
|
||||
stats.allocated_transactions, stats.allocated_registrations,
|
||||
stats.average_transactions, stats.average_registrations);
|
||||
}
|
||||
if (!(event = eXosip_event_wait (context_eXosip, 0, 1))) {
|
||||
#ifdef OSIP_MONOTHREAD
|
||||
eXosip_execute (context_eXosip);
|
||||
eXosip_automatic_action (context_eXosip);
|
||||
#endif
|
||||
eXosip_automatic_action (context_eXosip);
|
||||
osip_usleep (10000);
|
||||
continue;
|
||||
}
|
||||
@@ -352,18 +336,81 @@ main (int argc, char *argv[])
|
||||
eXosip_execute (context_eXosip);
|
||||
#endif
|
||||
|
||||
eXosip_lock (context_eXosip);
|
||||
eXosip_automatic_action (context_eXosip);
|
||||
|
||||
switch (event->type) {
|
||||
case EXOSIP_REGISTRATION_SUCCESS:
|
||||
syslog_wrapper (LOG_INFO, "registrered successfully");
|
||||
break;
|
||||
case EXOSIP_REGISTRATION_FAILURE:
|
||||
regparam.auth = 1;
|
||||
break;
|
||||
case EXOSIP_CALL_INVITE:
|
||||
{
|
||||
osip_message_t *answer;
|
||||
int i;
|
||||
|
||||
i = eXosip_call_build_answer (context_eXosip, event->tid, 405, &answer);
|
||||
if (i!=0) {
|
||||
syslog_wrapper (LOG_ERR, "failed to reject INVITE");
|
||||
break;
|
||||
}
|
||||
osip_free(answer->reason_phrase);
|
||||
answer->reason_phrase = osip_strdup ("No Support for Incoming Calls");
|
||||
i = eXosip_call_send_answer (context_eXosip, event->tid, 405, answer);
|
||||
if (i!=0) {
|
||||
syslog_wrapper (LOG_ERR, "failed to reject INVITE");
|
||||
break;
|
||||
}
|
||||
syslog_wrapper (LOG_INFO, "INVITE rejected with 405");
|
||||
break;
|
||||
}
|
||||
case EXOSIP_MESSAGE_NEW:
|
||||
{
|
||||
osip_message_t *answer;
|
||||
int i;
|
||||
|
||||
i = eXosip_message_build_answer (context_eXosip, event->tid, 405, &answer);
|
||||
if (i!=0) {
|
||||
syslog_wrapper (LOG_ERR, "failed to reject %s", event->request->sip_method);
|
||||
break;
|
||||
}
|
||||
i = eXosip_message_send_answer (context_eXosip, event->tid, 405, answer);
|
||||
if (i!=0) {
|
||||
syslog_wrapper (LOG_ERR, "failed to reject %s", event->request->sip_method);
|
||||
break;
|
||||
}
|
||||
syslog_wrapper (LOG_INFO, "%s rejected with 405", event->request->sip_method);
|
||||
break;
|
||||
}
|
||||
case EXOSIP_IN_SUBSCRIPTION_NEW:
|
||||
{
|
||||
osip_message_t *answer;
|
||||
int i;
|
||||
|
||||
i = eXosip_insubscription_build_answer (context_eXosip, event->tid, 405, &answer);
|
||||
if (i!=0) {
|
||||
syslog_wrapper (LOG_ERR, "failed to reject %s", event->request->sip_method);
|
||||
break;
|
||||
}
|
||||
i = eXosip_insubscription_send_answer (context_eXosip, event->tid, 405, answer);
|
||||
if (i!=0) {
|
||||
syslog_wrapper (LOG_ERR, "failed to reject %s", event->request->sip_method);
|
||||
break;
|
||||
}
|
||||
syslog_wrapper (LOG_INFO, "%s rejected with 405", event->request->sip_method);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
syslog_wrapper (LOG_DEBUG, "recieved unknown eXosip event (type, did, cid) = (%d, %d, %d)", event->type, event->did, event->cid);
|
||||
|
||||
}
|
||||
eXosip_unlock (context_eXosip);
|
||||
eXosip_event_free (event);
|
||||
}
|
||||
|
||||
|
||||
eXosip_quit(context_eXosip);
|
||||
osip_free(context_eXosip);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user