Commit 2098b6ff authored by Martti Mela's avatar Martti Mela

mingw mods

darcs-hash:20060302124401-1b897-03593dc64500c96033ca17457b08052616267d53.gz
parent 439b5371
......@@ -73,7 +73,8 @@ if test x$enable_stun = xno ; then
AC_MSG_WARN([** STUN support disabled **])
elif test x${HAVE_OPENSSL} != x1 ; then
dnl compile STUN only if OPENSSL is available
AC_MSG_WARN([** STUN support disabled as OpenSSL headers and/or libraries were not found **])
AC_MSG_WARN([** TLS support for STUN disabled as OpenSSL headers and/or libraries were not found **])
AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define as 1 if we use STUN library])
else
AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define as 1 if we use STUN library])
fi
......
......@@ -15,7 +15,7 @@ INCLUDES = -I$(srcdir)/../su -I../su
# ----------------------------------------------------------------------
# Build targets
if HAVE_TLS
# if HAVE_TLS
stun_lib_sources = stun.c stun_common.c
stun_prog_targets = stunc torture_stun
else
......
......@@ -52,7 +52,9 @@
#include <sofia-sip/su.h>
#include <sofia-sip/su_localinfo.h>
#if defined(HAVE_OPENSSL)
#include <openssl/opensslv.h>
#endif
/* Missing socket symbols */
#ifndef SOL_TCP
......@@ -182,8 +184,14 @@ struct stun_handle_s
su_localinfo_t sh_localinfo; /**< local addrinfo */
su_sockaddr_t sh_local_addr[1]; /**< local address */
#if defined(HAVE_OPENSSL)
SSL_CTX *sh_ctx; /**< SSL context for TLS */
SSL *sh_ssl; /**< SSL handle for TLS */
#else
void *sh_ctx; /**< SSL context for TLS */
void *sh_ssl; /**< SSL handle for TLS */
#endif
stun_msg_t sh_tls_request;
stun_msg_t sh_tls_response;
int sh_nattype; /**< NAT-type, see stun_common.h */
......@@ -258,8 +266,13 @@ int stun_lifetime(stun_discovery_t *sd)
}
#if defined(HAVE_OPENSSL)
char const stun_version[] =
"sofia-sip-stun using " OPENSSL_VERSION_TEXT;
#else
char const stun_version[] =
"sofia-sip-stun";
#endif
int do_action(stun_handle_t *sh, stun_msg_t *binding_response);
int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg);
......@@ -417,7 +430,7 @@ stun_handle_t *stun_handle_create(stun_magic_t *context,
return stun;
}
#if defined(HAVE_OPENSSL)
/** Shared secret request/response processing */
int stun_handle_request_shared_secret(stun_handle_t *sh)
{
......@@ -509,6 +522,12 @@ int stun_handle_request_shared_secret(stun_handle_t *sh)
return 0;
}
#else
int stun_handle_request_shared_secret(stun_handle_t *sh)
{
return 0;
}
#endif /* HAVE_OPENSSL */
stun_request_t *stun_request_create(stun_discovery_t *sd)
......@@ -762,7 +781,6 @@ static int get_localinfo(su_localinfo_t *clientinfo)
return 0;
}
#endif
/** Bind a socket using STUN client.
......@@ -995,6 +1013,7 @@ int stun_handle_get_nattype(stun_handle_t *sh,
* Internal functions
*******************************************************************/
#if defined(HAVE_OPENSSL)
int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
{
stun_discovery_t *sd = arg;
......@@ -1242,8 +1261,15 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
return 0;
}
#else
int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
{
return 0;
}
#endif /* HAVE_OPENSSL */
#if defined(HAVE_OPENSSL)
void stun_tls_connect_timer_cb(su_root_magic_t *magic,
su_timer_t *t,
su_timer_arg_t *arg)
......@@ -1269,7 +1295,12 @@ void stun_tls_connect_timer_cb(su_root_magic_t *magic,
return;
}
#else
void stun_tls_connect_timer_cb(su_root_magic_t *magic,
su_timer_t *t,
su_timer_arg_t *arg)
{
#endif /* HAVE_OPENSSL */
/** Compose a STUN message of the format defined by stun_msg_t
* result encoded in enc_buf ready for sending as well.
......
......@@ -404,6 +404,7 @@ int stun_encode_buffer(stun_attr_t *attr) {
return attr->enc_buf.size;
}
#if defined(HAVE_OPENSSL)
int stun_encode_message_integrity(stun_attr_t *attr,
unsigned char *buf,
int len,
......@@ -427,6 +428,15 @@ int stun_encode_message_integrity(stun_attr_t *attr,
free(padded_text);
return attr->enc_buf.size;
}
#else
int stun_encode_message_integrity(stun_attr_t *attr,
unsigned char *buf,
int len,
stun_buffer_t *pwd) {
return 0;
}
#endif /* HAVE_OPENSSL */
/** this function allocates the enc_buf, fills in type, length */
int stun_encode_type_len(stun_attr_t *attr, uint16_t len) {
......
......@@ -119,7 +119,7 @@ static struct gai_afd {
#if !SU_HAVE_IN6
extern
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
__declspec(dllimport)
#endif
int h_errno;
......@@ -617,10 +617,6 @@ get_addr(hostname, af, res, pai, port0)
return error;
}
#endif /* !HAVE_GETADDRINFO */
#if !HAVE_GETNAMEINFO
/*
* Issues to be discussed:
* - Thread safe-ness must be checked
......@@ -883,7 +879,7 @@ int su_getaddrinfo(char const *node, char const *service,
su_addrinfo_t const *hints,
su_addrinfo_t **res)
{
#if HAVE_SCTP
#if HAVE_SCTP && SU_HAVE_GETADDRINFO
if (res && hints && hints->ai_protocol == IPPROTO_SCTP) {
su_addrinfo_t *ai, system_hints[1];
int retval, socktype;
......
......@@ -345,10 +345,12 @@ gboolean su_source_check(GSource *gs)
I = self->sup_n_waits;
#if SU_HAVE_POLL
for (i = 0; i < I; i++) {
if (self->sup_waits[i].revents)
return TRUE;
}
#endif
return su_source_prepare(gs, &tout);
}
......@@ -382,6 +384,7 @@ gboolean su_source_dispatch(GSource *gs,
timers = su_timer_expire(&self->sup_timers, &tout, now);
}
#if SU_HAVE_POLL
{
su_root_t *root;
su_wait_t *waits = self->sup_waits;
......@@ -400,6 +403,7 @@ gboolean su_source_dispatch(GSource *gs,
}
}
}
#endif
if (!callback)
return TRUE;
......@@ -996,7 +1000,7 @@ su_duration_t su_source_step(su_port_t *self, su_duration_t tout)
if (tout < timeout)
timeout = tout;
i = poll((struct pollfd *)fds, n, timeout);
i = su_wait((su_wait_t *)fds, n, timeout);
if (g_main_context_check(gmc, priority, fds, n))
g_main_context_dispatch(gmc);
......
......@@ -48,7 +48,13 @@
#include <sys/time.h> /* Get struct timeval */
#endif
#if defined(__MINGW32__)
#define HAVE_FILETIME 1
#include <windows.h>
#endif
#if HAVE_FILETIME
#define HAVE_FILETIME 1
#include <windows.h>
#endif
......
......@@ -78,8 +78,13 @@ typedef struct tport_nat_s tport_nat_t;
#include <sofia-sip/su_wait.h>
#include <sofia-sip/msg.h>
#include <sofia-sip/msg_addr.h>
#include <msg.h>
#include <msg_addr.h>
#if !HAVE_RANDOM
#define random() rand()
#define srandom(x) srand(x)
#endif
#if HAVE_IP_RECVERR || HAVE_IPV6_RECVERR
#include <linux/types.h>
......@@ -258,7 +263,6 @@ struct tport_s {
stun_socket_t *tp_stun_socket;
#endif
su_socket_t tp_stun_socket;
int tp_has_keepalive;
#endif
/* ==== Receive queue ================================================== */
......@@ -7022,7 +7026,7 @@ tport_nat_initialize_nat_traversal(tport_master_t *mr,
for (i = 0; stun_transports[i]; i++) {
if ((strcmp(tpn->tpn_proto, "*") == 0 ||
strcasecmp(tpn->tpn_proto, stun_transports[i]) == 0)) {
SU_DEBUG_5(("%s(%p) creating STUN handle\n", __func__, mr));
SU_DEBUG_5(("%s(%p) starting STUN engine\n", __func__, mr));
nat->stun = stun_handle_create(mr,
mr->mr_root,
......
......@@ -432,6 +432,36 @@ fi
AM_CONDITIONAL(EXPENSIVE_CHECKS, test x$enable_expensive_checks != no)
])
dnl ======================================================================
dnl Check if we are using Windows with MinGW compiler
dnl ======================================================================
AC_DEFUN([AC_CHECK_COMPILATION_ENVIRONMENT], [
AC_REQUIRE([AC_PROG_CC])
AC_CACHE_CHECK([for compilation environment],
ac_cc_environment, [
machine=`$CC -dumpmachine`
if test $machine == "mingw32" ; then
ac_cc_environment=$machine
fi
])
if test X$ac_cc_environment == "Xmingw32" ; then
CFLAGS="$CFLAGS -I\$(top_srcdir)/win32/pthread -DWINVER=0x0501 \
-D_WIN32_WINNT=0x0501 -DIN_LIBSOFIA_SIP_UA -mms-bitfields \
-pipe -mno-cygwin -mwindows -mconsole -Wall -g -O0"
LDFLAGS="$LDFLAGS -Wl,--enable-auto-image-base"
LIBS="-L\$(top_srcdir)/win32/pthread -lpthread -lws2_32 \
-lwsock32"
AC_SUBST(MINGW_ENVIRONMENT)
AC_DEFINE([HAVE_MINGW], [1], [Define this as 1 if you are compiling in MinGW environment])
AC_DEFINE([HAVE_WIN32], [1], [Define this as 1 if you have WIN32])
fi
AM_CONDITIONAL([HAVE_MINGW32], [test "x$ac_cc_environment" != x])
])dnl
dnl ======================================================================
dnl Find long long (at least 64 bits)
dnl ======================================================================
......
......@@ -17,7 +17,7 @@ AC_REQUIRE([SAC_WITH_RT])
# Check for features used by su
dnl Define compilation options for su_configure.h
SAC_SU_DEFINE([SU_HAVE_BSDSOCK], 1, [Define as 1 if you have BSD socket interface])
dnl SAC_SU_DEFINE([SU_HAVE_BSDSOCK], 1, [Define as 1 if you have BSD socket interface])
case "$target" in
*-*-solaris?.* )
......@@ -59,9 +59,15 @@ if $ax_inttypes; then : ; else
AC_MSG_ERROR("No <stdint.h> or <inttypes.h> found.")
fi
if test "x$MINGW_ENVIRONMENT" != x1 ; then
AC_CHECK_HEADER(pthread.h,
HAVE_PTHREADS=1;
SAC_SU_DEFINE([SU_HAVE_PTHREADS], 1, [Sofia SU uses pthreads]))
else
AC_DEFINE([HAVE_PTHREAD_H], 1, [Define to 1 if you have the <pthread.h> header file.])
AC_DEFINE([HAVE_PTHREADS], 1, [Define as 1 you have PTHREADS])
SAC_SU_DEFINE([SU_HAVE_PTHREADS], 1, [Sofia SU uses pthreads])
fi
dnl ===========================================================================
dnl Checks for typedefs, headers, structures, and compiler characteristics.
......@@ -111,25 +117,29 @@ yes) SAC_SU_DEFINE(SU_HAVE_IN6, 1, [
esac
AC_CHECK_HEADERS([unistd.h sys/time.h])
AC_CHECK_HEADERS([sys/socket.h sys/ioctl.h sys/filio.h sys/sockio.h])
AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h \
net/if.h net/if_types.h ifaddr.h],,,
[sys/types.h sys/socket.h])
AC_CACHE_CHECK([for struct addrinfo],
[ac_cv_struct_addrinfo],[
ac_cv_struct_addrinfo=no
if test "$ac_cv_header_sys_socket_h" = yes; then
AC_EGREP_HEADER([struct.+addrinfo], [netdb.h], [
ac_cv_struct_addrinfo=yes])
else
ac_cv_struct_addrinfo='sys/socket.h missing'
fi])
if test "$ac_cv_struct_addrinfo" = yes; then
SAC_SU_DEFINE(SU_HAVE_ADDRINFO, 1,
[Define as 1 if you have struct addrinfo.])
fi
AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [
SAC_SU_DEFINE([SU_HAVE_WINSOCK], 1, [Define as 1 you have WinSock])
SAC_SU_DEFINE([SU_HAVE_WINSOCK2], 1, [Define as 1 you have WinSock2])
SAC_SU_DEFINE(SU_HAVE_SOCKADDR_STORAGE, 1,
[Define this as 1 if you have struct sockaddr_storage])
SAC_SU_DEFINE([SU_HAVE_GETADDRINFO], 1,
[Define this as 1 if you have getaddrinfo() function.])
AC_CHECK_HEADERS([windef.h])
AC_CHECK_HEADERS([iphlpapi.h], [
AC_DEFINE([HAVE_INTERFACE_INFO_EX], 1, [
Define this as 1 if you have WIN32 INTERFACE_INFO_EX type.])
AC_DEFINE([HAVE_SIO_ADDRESS_LIST_QUERY], 1, [
Define this as 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY.])
], [], [#if HAVE_WINDEF_H
#include <windef.h>
#include <winbase.h>
#endif
])
], [
AC_CHECK_HEADERS([sys/socket.h sys/ioctl.h sys/filio.h sys/sockio.h])
AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h net/if.h net/if_types.h], [], [
SAC_SU_DEFINE([SU_HAVE_BSDSOCK], 1, [Define as 1 if you have BSD socket interface])
AC_CACHE_CHECK([for struct sockaddr_storage],
[ac_cv_struct_sockaddr_storage],[
......@@ -145,6 +155,14 @@ if test "$ac_cv_struct_sockaddr_storage" = yes; then
[Define this as 1 if you have struct sockaddr_storage])
fi
# Test for getaddrinfo(), getnameinfo(), freeaddrinfo() and gai_strerror()
AC_CHECK_FUNC([getaddrinfo],[
SAC_SU_DEFINE([SU_HAVE_GETADDRINFO], 1, [
Define this as 1 if you have getaddrinfo() function.
])])
])
])
AC_CACHE_CHECK([for field ifr_index in struct ifreq],
[ac_cv_struct_ifreq_ifr_index],[
ac_cv_struct_ifreq_ifr_index=no
......@@ -219,23 +237,44 @@ else
HAVE_IFNUM=0
fi
if false; then
# Define Win32 macros
AC_DEFINE([HAVE_IPHLPAPI_H], 1, [Define as 1 you have WIN32 <iphlpapi.h>])
AC_DEFINE([HAVE_INTERFACE_INFO_EX], 1, [
Define this as 1 if you have WIN32 INTERFACE_INFO_EX type.])
AC_DEFINE([HAVE_SIO_ADDRESS_LIST_QUERY], 1, [
Define this as 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY.])
fi
# ===========================================================================
# Checks for libraries
# ===========================================================================
SAC_CHECK_SU_LIBS
AC_ARG_WITH(glib-dir,
[ --with-glib-dir=PREFIX explicitly define GLib path],
glib_dir="$withval", glib_dir="no")
#check if GLib path is explicitly defined
if test X$glib_dir != Xno ; then
gprefix=$glib_dir
exec_gprefix=${gprefix}
glibdir=${exec_gprefix}/lib
gincludedir=${gprefix}/include
# glib_genmarshal=glib-genmarshal
# gobject_query=gobject-query
# glib_mkenums=glib-mkenums
# GLIB_LIBS="-L${glibdir} -lglib-2.0 -lintl -liconv"
GLIB_LIBS="-L${glibdir} ${glibdir}/libglib-2.0.dll.a ${glibdir}/libintl.a ${glibdir}/libiconv.a"
GLIB_CFLAGS="-I${gincludedir}/glib-2.0 -I${glibdir}/glib-2.0/include"
# how the hell should I know?
GLIB_VERSION="2.0"
SAC_SU_DEFINE([SU_HAVE_GLIB], 1, [Define as 1 if you have >= glib-2.0])
HAVE_GLIB=yes
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CFLAGS)
else
# No GLib path explicitly defined, use pkg-config
AC_ARG_WITH(glib,
[ --with-glib=version use GLib (default=2.0)], [
case "$with_glib" in
......@@ -250,6 +289,7 @@ SAC_SU_DEFINE([SU_HAVE_GLIB], 1, [Define as 1 if you have >= glib-2.0])
HAVE_GLIB=yes
])
fi
fi
AM_CONDITIONAL([HAVE_GLIB], [test "x$HAVE_GLIB" != x])
......@@ -257,6 +297,7 @@ AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_VERSION)
# ===========================================================================
# Checks for library functions.
# ===========================================================================
......@@ -274,7 +315,7 @@ if test "${with_rt}" != no; then
AC_CHECK_FUNCS([clock_gettime clock_getcpuclockid])
fi
SAC_REPLACE_FUNCS(memmem memccpy memspn memcspn strcasestr strtoull)
SAC_REPLACE_FUNCS(memmem memccpy memspn memcspn strcasestr strtoull inet_ntop inet_pton)
AC_CHECK_FUNC([poll],
SAC_SU_DEFINE([SU_HAVE_POLL], 1, [
......
#
# Template for Sofia SIP UA library RPM spec file
# Template for Sofia SIP UA RPM spec file
#
# Options:
# --with doxygen - Generate documents using doxygen and dot
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment