Commit cf926c31 authored by johan's avatar johan

Merge remote-tracking branch 'origin/dev_dtls'

parents 06c11ea3 1f380402
......@@ -59,6 +59,7 @@ option(ENABLE_STATIC "Build static library (default is shared library)." NO)
option(ENABLE_DEBUG_LOGS "Enable the display of traces showing the execution of the library." NO)
option(ENABLE_FIXED_POINT "Turn on fixed point computations." ${ENABLE_FIXED_POINT_DEFAULT_VALUE})
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
cmake_dependent_option(ENABLE_DTLS "Build with DTLS support." YES "ENABLE_SRTP" NO)
option(ENABLE_SRTP "Build with the SRTP transport support." YES)
option(ENABLE_ZRTP "Build with ZRTP support." YES)
......@@ -90,14 +91,6 @@ cmake_dependent_option(ENABLE_VPX "Build mediastreamer2 with VPX codec." YES "EN
list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(ENABLE_SRTP)
find_package(SRTP)
if(NOT SRTP_FOUND)
message(WARNING "Could not find SRTP library, Mediastreamer2 will be compiled without SRTP support.")
set(ENABLE_SRTP OFF CACHE BOOL "Build with the SRTP transport support." FORCE)
endif()
endif()
include(CheckIncludeFile)
include(CheckLibraryExists)
......@@ -141,6 +134,13 @@ include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
find_package(ORTP REQUIRED)
if(ENABLE_SRTP)
find_package(SRTP)
if(NOT SRTP_FOUND)
message(WARNING "Could not find SRTP library, Mediastreamer2 will be compiled without SRTP support.")
set(ENABLE_SRTP OFF CACHE BOOL "Build with the SRTP transport support." FORCE)
endif()
endif()
if(ENABLE_ZRTP)
find_package(BZRTP)
if(NOT BZRTP_FOUND)
......@@ -148,6 +148,13 @@ if(ENABLE_ZRTP)
set(ENABLE_ZRTP OFF CACHE BOOL "Build mediastreamer2 with ZRTP support." FORCE)
endif()
endif()
if(ENABLE_DTLS AND ENABLE_SRTP) # DTLS requires SRTP
find_package(PolarSSL)
if(NOT POLARSSL_FOUND)
message(WARNING "Could not find polarssl library, mediastreamer2 will be compiled without DTLS support.")
set(ENABLE_DTLS OFF CACHE BOOL "Build mediastreamer2 with DTLS support." FORCE)
endif()
endif()
if(ENABLE_GSM)
find_package(GSM)
if(NOT GSM_FOUND)
......@@ -256,10 +263,12 @@ endif()
if(SRTP_FOUND)
include_directories(${SRTP_INCLUDE_DIRS})
endif()
if(BZRTP_FOUND)
include_directories(${BZRTP_INCLUDE_DIRS})
endif()
if(POLARSSL_FOUND)
include_directories(${POLARSSL_INCLUDE_DIRS})
endif()
if(GSM_FOUND)
include_directories(${GSM_INCLUDE_DIRS})
endif()
......@@ -319,6 +328,9 @@ endif()
if(BZRTP_FOUND)
set(HAVE_ZRTP 1)
endif()
if(ENABLE_DTLS)
set(HAVE_DTLS 1)
endif()
if(ENABLE_ALSA)
set(__ALSA_ENABLED__ 1)
endif()
......
......@@ -83,6 +83,9 @@ endif()
if(@ENABLE_ZRTP@)
find_package(BZRTP)
endif()
if(@ENABLE_DTLS@ AND SRTP_FOUND)
find_package(PolarSSL)
endif()
set(_MS2_ROOT_PATHS
......@@ -173,6 +176,10 @@ if(BZRTP_FOUND)
list(APPEND MS2_INCLUDE_DIRS ${BZRTP_INCLUDE_DIRS})
list(APPEND MS2_LIBRARIES ${BZRTP_LIBRARIES})
endif()
if(POLARSSL_FOUND)
list(APPEND MS2_INCLUDE_DIRS ${POLARSSL_INCLUDE_DIRS})
list(APPEND MS2_LIBRARIES ${POLARSSL_LIBRARIES})
endif()
if(WIN32)
list(APPEND MS2_LIBRARIES ole32 oleaut32 uuid gdi32 user32 vfw32)
endif(WIN32)
......
......@@ -1088,6 +1088,66 @@ else
fi
AM_CONDITIONAL(LIBBZRTP,test x$zrtp != xfalse)
dnl Polarssl lib is requested for DTLS
AC_ARG_WITH( polarssl,
[ --with-polarssl Set prefix where polarssl can be found (ex:/usr, /usr/local)[default=PREFIX] ],
[ polarssl_prefix=${withval}],[ polarssl_prefix=${prefix} ])
if test "$polarssl_prefix" != "NONE" ; then
POLARSSL_CFLAGS="-I${polarssl_prefix}/include"
POLARSSL_LIBS="-L${polarssl_prefix}/lib"
fi
POLARSSL_LIBS="$POLARSSL_LIBS -lpolarssl"
found_polarssl=no
dnl check for DTLS-SRTP support, need polarssl version >= 1.4
AC_ARG_ENABLE(dtls,
[AS_HELP_STRING([--enable-dtls], [Turn on or off compilation of dtls (default=no)])],
[case "${enableval}" in
yes) dtls=true ;;
no) dtls=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-dtls) ;;
esac],
[dtls=false]
)
if test "$dtls" = "true" ; then
if test "$have_srtp" = "no" ; then
AC_MSG_ERROR("DTLS-SRTP requires SRTP")
fi
dnl check for polarssl presence and support for DTLS
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
LIBS="$LIBS $POLARSSL_LIBS"
AC_CHECK_HEADERS(polarssl/ssl.h,
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <polarssl/ssl.h>
]],
[[ssl_set_dtls_srtp_protection_profiles(0,0,0)]])]
,[found_polarssl=yes
AC_MSG_NOTICE([polarssl usable for DTLS-SRTP])]
,[AC_MSG_ERROR([polarssl not usable for DTLS-SRTP])])
])
CPPFLAGS=$CPPFLAGS_save
LIBS=$LIBS_save
if test "x$found_polarssl" = "xyes" ; then
AC_DEFINE(HAVE_DTLS, 1, [Defined when dtls support is compiled])
AC_MSG_NOTICE([polarssl usable for DTLS-SRTP])
AC_SUBST(POLARSSL_CFLAGS)
AC_SUBST(POLARSSL_LIBS)
fi
else
echo "DTLS-SRTP compilation is disabled."
fi
dnl ##################################################
dnl # Check for doxygen
......
......@@ -44,6 +44,8 @@ mediastreamer2_include_HEADERS= ice.h \
msfactory.h \
msmediaplayer.h \
zrtp.h \
stun.h \
stun_udp.h \
ms_srtp.h
EXTRA_DIST=$(mediastreamer2_include_HEADERS)
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2014 Belledonne Communications
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ms_dtls_srtp_h
#define ms_dtls_srtp_h
#include <ortp/rtpsession.h>
#include "mediastreamer2/mscommon.h"
#ifdef __cplusplus
extern "C"{
#endif
/* defined in mediastream.h */
struct _MSMediaStreamSessions;
typedef enum {
MSDtlsSrtpRoleInvalid,
MSDtlsSrtpRoleIsServer,
MSDtlsSrtpRoleIsClient,
MSDtlsSrtpRoleUnset
} MSDtlsSrtpRole;
typedef struct MSDtlsSrtpParams {
const char *pem_certificate; /**< Self certificate in pem format */
const char *pem_pkey; /**< Private key associated to self certificate */
MSDtlsSrtpRole role; /**< Unset(at caller init, role is then choosen by responder but we must still be able to receive packets) */
} MSDtlsSrtpParams;
/* an opaque structure containing all context data needed by DTLS-SRTP */
typedef struct _MSDtlsSrtpContext MSDtlsSrtpContext;
/**
* check if DTLS-SRTP is available
* @return TRUE if it is available, FALSE if not
*/
MS2_PUBLIC bool_t ms_dtls_srtp_available(void);
/**
* Create an initialise a DTLS-SRTP context
* @param[in] sessions A link to the stream sessions structures, used to get rtp session to add transport modifier and needed to set SRTP sessions when keys are ready
* @param[in] params Self certificate and private key to be used for this session. Role (client/server) may be given but can be set later
* @return a pointer to the opaque context structure needed by DTLS-SRTP
*/
MS2_PUBLIC MSDtlsSrtpContext* ms_dtls_srtp_context_new(struct _MSMediaStreamSessions *sessions, MSDtlsSrtpParams *params);
/**
* Start the DTLS-SRTP channel: send DTLS ClientHello if we are client
* @param[in/out] context the DTLS-SRTP context
*/
MS2_PUBLIC void ms_dtls_srtp_start(MSDtlsSrtpContext* context);
/**
* Free ressources used by DTLS-SRTP context
* @param[in/out] context the DTLS-SRTP context
*/
MS2_PUBLIC void ms_dtls_srtp_context_destroy(MSDtlsSrtpContext *ctx);
/**
* Set DTLS role: server or client, called when SDP exchange reach the point where we can determine self role
* @param[in/out] context the DTLS-SRTP context
* @param[in] role Client/Server/Invalid/Unset according to SDP INVITE processing
*/
MS2_PUBLIC void ms_dtls_srtp_set_role(MSDtlsSrtpContext *context, MSDtlsSrtpRole role);
/**
* Give to the DTLS-SRTP context the peer certificate fingerprint extracted from trusted SDP INVITE,
* it will be compared(case insensitive) with locally computed one after DTLS handshake is completed successfully and peer certicate retrieved
* @param[in/out] context the DTLS-SRTP context
* @param[in] peer_fingerprint a null terminated string containing the peer certificate as found in the SDP INVITE(including the heading hash algorithm name)
*/
MS2_PUBLIC void ms_dtls_srtp_set_peer_fingerprint(MSDtlsSrtpContext *context, const char *peer_fingerprint);
#ifdef __cplusplus
}
#endif
#endif /* ms_dtls_srtp_h */
......@@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ice_h
#include "mscommon.h"
#include "ortp/stun_udp.h"
#include "ortp/stun.h"
#include "ortp/ortp.h"
......@@ -120,6 +118,7 @@ typedef struct _IceSession {
socklen_t ss_len; /**< Length of the STUN server address to use for the candidates gathering process */
MSTimeSpec gathering_start_ts;
MSTimeSpec gathering_end_ts;
bool_t check_message_integrity; /*set to false for backward compatibility only*/
} IceSession;
typedef struct _IceStunServerCheckTransaction {
......@@ -129,7 +128,7 @@ typedef struct _IceStunServerCheckTransaction {
} IceStunServerCheckTransaction;
typedef struct _IceStunServerCheck {
ortp_socket_t sock;
RtpTransport *rtptp;
int srcport;
MSList *transactions; /**< List of IceStunServerCheckTransaction structures. */
MSTimeSpec next_transmission_time;
......@@ -174,6 +173,8 @@ typedef struct _IceCandidatePair {
bool_t use_candidate; /**< Boolean value telling if the USE-CANDIDATE attribute must be set for the connectivity checks send for the candidate pair */
bool_t is_nominated; /**< Boolean value telling whether this candidate pair is nominated or not */
bool_t wait_transaction_timeout; /**< Boolean value telling to create a new binding request on retransmission timeout */
bool_t retry_with_dummy_message_integrity; /** use to tell to retry with dummy message integrity. Useful to keep backward compatibility with older version*/
bool_t use_dummy_hmac; /*don't compute real hmac. used for backward compatibility*/
} IceCandidatePair;
/**
......@@ -381,7 +382,7 @@ MS2_PUBLIC void ice_session_set_remote_credentials(IceSession *session, const ch
*
* This function is to be called once the remote credentials have been received via SDP.
*/
MS2_PUBLIC const char* ice_check_list_set_remote_ufrag(const IceCheckList *cl);
MS2_PUBLIC const char* ice_check_list_get_remote_ufrag(const IceCheckList *cl);
/**
* get the remote pwd of an ICE check list.
......@@ -390,7 +391,7 @@ MS2_PUBLIC const char* ice_check_list_set_remote_ufrag(const IceCheckList *cl);
*
* This function is to be called once the remote credentials have been received via SDP.
*/
MS2_PUBLIC const char* ice_check_list_set_remote_pwd(const IceCheckList *cl);
MS2_PUBLIC const char* ice_check_list_get_remote_pwd(const IceCheckList *cl);
/**
* Define the maximum number of connectivity checks that will be performed by the agent.
......@@ -776,6 +777,16 @@ MS2_PUBLIC void ice_session_start_connectivity_checks(IceSession *session);
*/
MS2_PUBLIC void ice_session_check_mismatch(IceSession *session);
/**
* Disable/enable strong message integrity check. Used for backward compatibility only
* default value is enabled
* @param session A pointer to a session
* @param enable value
*
*/
MS2_PUBLIC void ice_session_enable_message_integrity_check(IceSession *session,bool_t enable);
/**
* Core ICE check list processing.
*
......@@ -852,6 +863,7 @@ MS2_PUBLIC void ice_dump_check_list(const IceCheckList *cl);
*/
MS2_PUBLIC void ice_dump_triggered_checks_queue(const IceCheckList *cl);
#ifdef __cplusplus
}
#endif
......
......@@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <ortp/ortp.h>
#include <ortp/event.h>
/* defined in srtp.h*/
typedef struct srtp_ctx_t *MSSrtpCtx;
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msticker.h>
......@@ -35,6 +33,7 @@ typedef struct srtp_ctx_t *MSSrtpCtx;
#include <mediastreamer2/qualityindicator.h>
#include <mediastreamer2/ice.h>
#include <mediastreamer2/zrtp.h>
#include <mediastreamer2/dtls_srtp.h>
#include <mediastreamer2/ms_srtp.h>
......@@ -82,7 +81,9 @@ typedef void (*media_stream_process_rtcp_callback_t)(MediaStream *stream, mblk_t
struct _MSMediaStreamSessions{
RtpSession *rtp_session;
MSSrtpCtx srtp_session;
MSSrtpCtx srtp_rtcp_session;
MSZrtpContext *zrtp_context;
MSDtlsSrtpContext *dtls_context;
MSTicker *ticker;
bool_t is_secured;
};
......@@ -138,6 +139,9 @@ struct _MediaStream {
* @addtogroup audio_stream_api
* @{
**/
MS2_PUBLIC bool_t media_stream_dtls_supported(void);
MS2_PUBLIC void media_stream_set_rtcp_information(MediaStream *stream, const char *cname, const char *tool);
MS2_PUBLIC void media_stream_get_local_rtp_stats(MediaStream *stream, rtp_stats_t *stats);
......@@ -553,6 +557,9 @@ MS2_PUBLIC void audio_stream_enable_zrtp(AudioStream *stream, MSZrtpParams *para
* */
bool_t audio_stream_zrtp_enabled(const AudioStream *stream);
/* enable DTLS on the audio stream */
MS2_PUBLIC void audio_stream_enable_dtls(AudioStream *stream, MSDtlsSrtpParams *params);
/* enable SRTP on the audio stream */
static MS2_INLINE bool_t audio_stream_enable_srtp(AudioStream* stream, MSCryptoSuite suite, const char* snd_key, const char* rcv_key) {
return media_stream_enable_srtp(&stream->ms, suite, snd_key, rcv_key);
......@@ -747,6 +754,9 @@ MS2_PUBLIC void video_stream_send_only_stop(VideoStream *vs);
/* enable ZRTP on the video stream using information from the audio stream */
MS2_PUBLIC void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astream, MSZrtpParams *param);
/* enable DTLS on the video stream */
MS2_PUBLIC void video_stream_enable_dtls(VideoStream *stream, MSDtlsSrtpParams *params);
/* enable SRTP on the video stream */
static MS2_INLINE bool_t video_stream_enable_strp(VideoStream* stream, MSCryptoSuite suite, const char* snd_key, const char* rcv_key) {
return media_stream_enable_srtp(&stream->ms, suite, snd_key, rcv_key);
......
......@@ -20,38 +20,14 @@
#ifndef ms_srtp_h
#define ms_srtp_h
#include <ortp/rtpsession.h>
#include "mediastreamer2/mscommon.h"
#if defined(HAVE_SRTP)
/*srtp defines all this stuff*/
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#if defined(ANDROID) || !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// Android and Windows phone don't use make install
# include <srtp.h>
#else
# include <srtp/srtp.h>
#endif /* ANDROID */
#else /* HAVE_SRTP */
typedef void* srtp_t;
typedef int err_status_t;
typedef struct srtp_policy srtp_policy_t;
#endif /* HAVE_SRTP */
#ifdef __cplusplus
extern "C"{
#endif
/* defined in mediastream.h */
struct _MediaStream;
struct _MSMediaStreamSessions;
/*
* Crypto suite used configure encrypted stream*/
......@@ -74,6 +50,14 @@ MS2_PUBLIC MSCryptoSuite ms_crypto_suite_build_from_name_params(const MSCryptoSu
MS2_PUBLIC int ms_crypto_suite_to_name_params(MSCryptoSuite cs, MSCryptoSuiteNameParams *nameparams);
/* defined in srtp.h*/
typedef struct srtp_ctx_t *MSSrtpCtx;
typedef enum {
MSSRTP_RTP_STREAM,
MSSRTP_RTCP_STREAM,
MSSRTP_ALL_STREAMS
} MSSrtpStreamType;
/**
* Check if SRTP is supported
* @return true if SRTP is supported
......@@ -84,47 +68,49 @@ MS2_PUBLIC bool_t ms_srtp_supported(void);
* Set srtp receiver key for the given media stream.
* If no srtp session exists on the stream it is created, if it already exists srtp policy is created/modified for the receiver side of the stream.
*
* @param[in/out] stream The mediastream to operate on
* @param[in] suite The srtp crypto suite to use
* @param[in] key Srtp master key and master salt in a base 64 NULL terminated string
* @param[in/out] sessions The sessions associated to the current media stream
* @param[in] suite The srtp crypto suite to use
* @param[in] key Srtp master key and master salt in a base 64 NULL terminated string
* @return 0 on success, error code otherwise
*/
MS2_PUBLIC int media_stream_set_srtp_recv_key_b64(struct _MediaStream *stream, enum _MSCryptoSuite suite, const char* key);
MS2_PUBLIC int media_stream_set_srtp_recv_key_b64(struct _MSMediaStreamSessions *sessions, MSCryptoSuite suite, const char* key);
/**
* Set srtp receiver key for the given media stream.
* If no srtp session exists on the stream it is created, if it already exists srtp policy is created/modified for the receiver side of the stream.
*
* @param[in/out] stream The mediastream to operate on
* @param[in/out] sessions The sessions associated to the current media stream
* @param[in] suite The srtp crypto suite to use
* @param[in] key Srtp master key and master salt
* @param[in] key_length key buffer length
* @param[in] stream_type Srtp suite is applied to RTP stream, RTCP stream or both
* @return 0 on success, error code otherwise
*/
MS2_PUBLIC int media_stream_set_srtp_recv_key(struct _MediaStream *stream, enum _MSCryptoSuite suite, const char* key, size_t key_length);
MS2_PUBLIC int media_stream_set_srtp_recv_key(struct _MSMediaStreamSessions *sessions, MSCryptoSuite suite, const char* key, size_t key_length, MSSrtpStreamType stream_type);
/**
* Set srtp sender key for the given media stream.
* If no srtp session exists on the stream it is created, if it already exists srtp policy is created/modified for the sender side of the stream.
*
* @param[in/out] stream The mediastream to operate on
* @param[in/out] sessions The sessions associated to the current media stream
* @param[in] suite The srtp crypto suite to use
* @param[in] key Srtp master key and master salt in a base 64 NULL terminated string
* @return 0 on success, error code otherwise
*/
MS2_PUBLIC int media_stream_set_srtp_send_key_b64(struct _MediaStream *stream, enum _MSCryptoSuite suite, const char* key);
MS2_PUBLIC int media_stream_set_srtp_send_key_b64(struct _MSMediaStreamSessions *sessions, MSCryptoSuite suite, const char* key);
/**
* Set srtp sender key for the given media stream.
* If no srtp session exists on the stream it is created, if it already exists srtp policy is created/modified for the sender side of the stream.
*
* @param[in/out] stream The mediastream to operate on
* @param[in/out] stream The mediastream to operate on
* @param[in] suite The srtp crypto suite to use
* @param[in] key Srtp master key and master salt
* @param[in] key_length key buffer length
* @param[in] stream_type Srtp suite is applied to RTP stream, RTCP stream or both
* @return 0 on success, error code otherwise
*/
MS2_PUBLIC int media_stream_set_srtp_send_key(struct _MediaStream *stream, enum _MSCryptoSuite suite, const char* key, size_t key_length);
MS2_PUBLIC int media_stream_set_srtp_send_key(struct _MSMediaStreamSessions *sessions, MSCryptoSuite suite, const char* key, size_t key_length, MSSrtpStreamType stream_type);
/**
* Deallocate ressources for a srtp session
......@@ -132,7 +118,7 @@ MS2_PUBLIC int media_stream_set_srtp_send_key(struct _MediaStream *stream, enum
* @param[in/out] session SRTP session to be terminated
* @return 0 on success
*/
MS2_PUBLIC err_status_t ms_srtp_dealloc(srtp_t session);
MS2_PUBLIC int ms_srtp_dealloc(MSSrtpCtx session);
#ifdef __cplusplus
}
#endif
......
......@@ -119,6 +119,8 @@ typedef void (*MSIterate2Func)(void *a, void *b);
#ifdef __cplusplus
extern "C"{
#endif
/*for stun*/
typedef struct { unsigned char octet[12]; } UInt96;
MS2_PUBLIC void ms_thread_exit(void* ret_val);
MS2_PUBLIC MSList * ms_list_append(MSList *elem, void * data);
......
This diff is collapsed.
/*
The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ====================================================================
* The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>.
*
*/
#ifndef __STUN_UDP_H__
#define __STUN_UDP_H__
#ifndef __cplusplus
//#define bool int
//#define false 0
//#define true 1
#endif
#ifdef __MACH__
#include <sys/socket.h>
#ifndef _SOCKLEN_T
typedef int socklen_t;
#endif
#endif
#include <ortp/port.h>
#if defined(WIN32) || defined(_WIN32_WCE)
#if !defined(_WIN32_WCE)
#include <errno.h>
#endif
#include <winsock2.h>
/* #include <io.h> */
typedef int socklen_t;
typedef SOCKET Socket;
#ifndef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#ifndef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#endif
#ifndef EALREADY
#define EALREADY WSAEALREADY
#endif
#ifndef ENOTSOCK
#define ENOTSOCK WSAENOTSOCK
#endif
#ifndef EDESTADDRREQ
#define EDESTADDRREQ WSAEDESTADDRREQ
#endif
#ifndef EMSGSIZE
#define EMSGSIZE WSAEMSGSIZE
#endif
#ifndef EPROTOTYPE
#define EPROTOTYPE WSAEPROTOTYPE
#endif
#ifndef ENOPROTOOPT
#define ENOPROTOOPT WSAENOPROTOOPT
#endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#endif
#ifndef ESOCKTNOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#endif
#ifndef EOPNOTSUPP
#define EOPNOTSUPP WSAEOPNOTSUPP
#endif
#ifndef EPFNOSUPPORT
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#endif
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
#ifndef EADDRINUSE
#define EADDRINUSE WSAEADDRINUSE
#endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#endif
#ifndef ENETDOWN
#define ENETDOWN WSAENETDOWN
#endif
#ifndef ENETUNREACH
#define ENETUNREACH WSAENETUNREACH
#endif
#ifndef ENETRESET
#define ENETRESET WSAENETRESET
#endif
#ifndef ECONNABORTED
#define ECONNABORTED WSAECONNABORTED
#endif
#ifndef ECONNRESET
#define ECONNRESET WSAECONNRESET
#endif
#ifndef ENOBUFS
#define ENOBUFS WSAENOBUFS
#endif
#ifndef EISCONN
#define EISCONN WSAEISCONN
#endif
#ifndef ENOTCONN
#define ENOTCONN WSAENOTCONN
#endif
#ifndef ESHUTDOWN
#define ESHUTDOWN WSAESHUTDOWN
#endif
#ifndef ETOOMANYREFS
#define ETOOMANYREFS WSAETOOMANYREFS
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT WSAETIMEDOUT
#endif
#ifndef ECONNREFUSED
#define ECONNREFUSED WSAECONNREFUSED
#endif
#ifndef ELOOP
#define ELOOP WSAELOOP
#endif
#ifndef EHOSTDOWN
#define EHOSTDOWN WSAEHOSTDOWN
#endif
#ifndef EHOSTUNREACH
#define EHOSTUNREACH WSAEHOSTUNREACH
#endif
#ifndef EPROCLIM
#define EPROCLIM WSAEPROCLIM
#endif
#ifndef EUSERS
#define EUSERS WSAEUSERS
#endif
#ifndef EDQUOT
#define EDQUOT WSAEDQUOT
#endif
#ifndef ESTALE
#define ESTALE WSAESTALE
#endif
#ifndef EREMOTE
#define EREMOTE WSAEREMOTE
#endif
typedef LONGLONG Int64;
#else
typedef int Socket;
#ifndef INVALID_SOCKET
#define INVALID_SOCKET -1
#endif
#ifndef SOCKET_ERROR
#define SOCKET_ERROR -1
#endif
#define closesocket(fd) close(fd)
#define WSANOTINITIALISED EPROTONOSUPPORT
#endif
#ifdef __cplusplus
extern "C"{
#endif
ORTP_PUBLIC int getErrno(void);
/* Open a UDP socket to receive on the given port - if port is 0, pick a a
port, if interfaceIp!=0 then use ONLY the interface specified instead of
all of them */
ORTP_PUBLIC Socket
openPort( unsigned short port, unsigned int interfaceIp);
/* recive a UDP message */
ORTP_PUBLIC bool_t
getMessage( Socket fd, char* buf, int* len,
unsigned int* srcIp, unsigned short* srcPort);
/* send a UDP message */
ORTP_PUBLIC bool_t
sendMessage( Socket fd, char* msg, int len,
unsigned int dstIp, unsigned short dstPort);
/* set up network - does nothing in unix but needed for windows */
ORTP_PUBLIC void
initNetwork(void);
#ifdef __cplusplus
}
#endif
#endif
......@@ -28,7 +28,7 @@ extern "C"{
#endif
/* defined in mediastream.h */
struct _MediaStream;