diff --git a/daemon/configure.ac b/daemon/configure.ac index 8e774538a856f45a21758340377e8f6390e99664..6788f9d3662d4df753d4fc074ca3a71cd07a83c0 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -163,23 +163,41 @@ PKG_CHECK_MODULES([CCRTP], [libccrtp] >= ${LIBCCRTP_MIN_VERSION},, [ -############################################################################################################################### -# TLS # -# required dependency(ies): libssl # -############################################################################################################################### +# TLS +# required dependency(ies): libssl dnl Check for OpenSSL to link against pjsip and provide SIPS TLS support -PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev])) +AC_ARG_WITH([tls], + [ AS_HELP_STRING([--without-tls], [disable tls support]) ], + [], + [with_tls=yes]) +AS_IF([test "xwith_tls" = "xyes"], [ + PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev])) + ]); + +AC_DEFINE_UNQUOTED([HAVE_TLS], `if test "x$with_tls" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have tls support]) +AM_CONDITIONAL(BUILD_TLS, test "x$with_tls" = "xyes" ) -############################################################################################################################### -# ZRTP # -# required dependency(ies): libzrtp # -############################################################################################################################### +# ZRTP +# required dependency(ies): libzrtp dnl Check for libzrtpcpp, a ccRTP extension providing zrtp key exchange LIBZRTPCPP_MIN_VERSION=1.3.0 -PKG_CHECK_MODULES(ZRTPCPP, libzrtpcpp >= ${LIBZRTPCPP_MIN_VERSION},, AC_MSG_ERROR([Missing zrtp development package: libzrtpcpp-dev])) +AC_ARG_WITH([zrtp], + [ AS_HELP_STRING([--without-zrtp], [disable zrtp support]) ], + [], + [with_zrtp=yes]) +AS_IF([test "xwith_zrtp" = "xyes"], [ + PKG_CHECK_MODULES(ZRTPCPP, libzrtpcpp >= ${LIBZRTPCPP_MIN_VERSION},, AC_MSG_ERROR([Missing zrtp development package: libzrtpcpp-dev])) + ]); +AC_DEFINE_UNQUOTED([HAVE_ZRTP], `if test "x$with_zrtp" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have zrtp support]) +AM_CONDITIONAL(BUILD_ZRTP, test "x$with_zrtp" = "xyes" ) + + + +# DBUS +# required dependency(ies): libdbus-c++ dnl DBus-C++ detection dnl pkg-config doesn't like 0.6.0-pre1 version number, it assumes that it is dnl more recent than (unreleased) 0.6.0 @@ -189,10 +207,8 @@ AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSIO -############################################################################################################################### -# Instant Messaging # -# required dependency(ies): libxpat # -############################################################################################################################### +# Instant Messaging +# required dependency(ies): libxpat AC_ARG_WITH([instant_messaging], [ AS_HELP_STRING([--without-instant_messaging], [disable support for instant-messaging]) ], [], @@ -206,14 +222,16 @@ AS_IF([test "x$with_instant_messaging" = "xyes"], [ AC_DEFINE_UNQUOTED([HAVE_INSTANT_MESSAGING], `if test "x$with_instant_messaging" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have instant messaging support]) AM_CONDITIONAL(BUILD_INSTANT_MESSAGING, test "x$with_instant_messaging" = "xyes" ) + + +# PTHREAD +# required dependency(ies): libxpat AX_PTHREAD -############################################################################################################################### -# SDES Key Exchange # -# required dependency(ies): libpcre # -############################################################################################################################### +# SDES Key Exchange +# required dependency(ies): libpcre AC_ARG_WITH([sdes], [ AS_HELP_STRING([--without-sdes], [disable support for sdes key exchange]) ], [], @@ -232,10 +250,8 @@ PKG_CHECK_MODULES(CPPUNIT, cppunit >= ${CPPUNIT_MIN_VERSION}, AM_CONDITIONAL(BUI -############################################################################################################################### -# GSM CODEC # -# required dependency(ies): libgsm # -############################################################################################################################### +# GSM CODEC +# required dependency(ies): libgsm dnl check for libgsm1 (doesn't use pkg-config) dnl Check for libgsm AC_ARG_WITH([gsm], [AS_HELP_STRING([--without-gsm], @@ -254,10 +270,8 @@ AM_CONDITIONAL(BUILD_GSM, test "x$with_gsm" = "xyes" ) -############################################################################################################################### -# SPEEX CODEC # -# required dependency(ies): libspeex # -############################################################################################################################### +# SPEEX CODEC +# required dependency(ies): libspeex dnl Check for libspeex AC_ARG_WITH([speex], [AS_HELP_STRING([--without-speex], @@ -277,10 +291,8 @@ AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" ) -############################################################################################################################### -# SPEEX DSP # -# required dependency(ies): libspeexdsp # -############################################################################################################################### +# SPEEX DSP +# required dependency(ies): libspeexdsp dnl check in case the libspeexdsp is not installed AC_ARG_WITH([speexdsp], [AS_HELP_STRING([--without-speexdsp], @@ -300,10 +312,8 @@ AM_CONDITIONAL(BUILD_SPEEXDSP, test "x$with_speexdsp" = "xyes" ) -############################################################################################################################### -# IAX # -# required dependency(ies): libiax2 (static) # -############################################################################################################################### +# IAX +# required dependency(ies): libiax2 (static) dnl Check for IAX AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2], [disable support for the iax2 protocol])], [], [with_iax2=yes]) @@ -313,6 +323,8 @@ AM_CONDITIONAL(USE_IAX, test "x$with_iax2" = "xyes" ) +# NETWORK MANAGER +# required dependency(ies): libiax2 (static) dnl Check for network-manager AC_ARG_WITH([networkmanager], [AS_HELP_STRING([--without-networkmanager], [disable support for network-manager events])], [], @@ -322,10 +334,8 @@ AM_CONDITIONAL(USE_NETWORKMANAGER, test "x$with_networkmanager" = "xyes" ) -############################################################################################################################### -# DOXYGEN # -# required dependency(ies): doxygen # -############################################################################################################################### +# DOXYGEN +# required dependency(ies): doxygen # check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/ # ---------------------------------------------------------------------------- AC_DEFUN([BB_ENABLE_DOXYGEN], diff --git a/daemon/libs/Makefile.am b/daemon/libs/Makefile.am index 105bcd0231a42a82de43d0f493962f5c01bef334..cda25d43b6bce9e150d827dbf913df8138f4a665 100644 --- a/daemon/libs/Makefile.am +++ b/daemon/libs/Makefile.am @@ -1,3 +1,5 @@ +if USE_IAX SUBDIRS = iax2 +endif EXTRA_DIST=pjproject diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index 524ed6029490ae5d9f74d69fe12b20da1c7cb58f..a41ef7488264d1570730e639641bdffb1921efad 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -5,31 +5,29 @@ libexec_PROGRAMS = sflphoned if SFL_VIDEO SFL_VIDEO_SUBDIR = video +SFL_VIDEO_LIB=./video/libvideo.la endif if BUILD_INSTANT_MESSAGING INSTANT_MESSAGING_SUBDIR = im +IM_LIB=./im/libim.la endif -SUBDIRS = dbus audio config hooks history sip iax $(INSTANT_MESSAGING_SUBDIR) $(SFL_VIDEO_SUBDIR) - -sflphoned_SOURCES = main.cpp - # Redefine the USE_IAX variable here, so that it could be used in managerimpl if USE_IAX +IAX_SUBDIR=iax IAX_CXXFLAG=-DUSE_IAX -IAX_LIB=./iax/libiaxlink.la -else -IAX_CXXFLAG= -IAX_LIB= +IAX_LIB=./iax/libiaxlink.la $(top_builddir)/libs/iax2/libiax2.la endif if USE_NETWORKMANAGER NETWORKMANAGER=-DUSE_NETWORKMANAGER -else -NETWORKMANAGER= endif +SUBDIRS = dbus audio config hooks history sip $(IAX_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(SFL_VIDEO_SUBDIR) + +sflphoned_SOURCES = main.cpp + sflphoned_CXXFLAGS = \ -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(IAX_CXXFLAG) $(NETWORKMANAGER) \ -DVERSION=\"$(VERSION)\" @@ -62,16 +60,7 @@ noinst_HEADERS = \ account_schema.h \ registration_states.h -if SFL_VIDEO -SFL_VIDEO_LIB=./video/libvideo.la -endif - -if BUILD_INSTANT_MESSAGING -IM_LIB=./im/libim.la -endif - libsflphone_la_LIBADD = \ - $(top_builddir)/libs/iax2/libiax2.la \ $(IAX_LIB) \ ./sip/libsiplink.la \ ./audio/libaudio.la \ diff --git a/daemon/src/audio/audiortp/Makefile.am b/daemon/src/audio/audiortp/Makefile.am index bb0bf253e22845b6011d9619cb36043cec8d3369..c27eedda76849c5c0653b5937e9780034fda13bd 100644 --- a/daemon/src/audio/audiortp/Makefile.am +++ b/daemon/src/audio/audiortp/Makefile.am @@ -2,19 +2,19 @@ include $(top_srcdir)/globals.mak noinst_LTLIBRARIES = libaudiortp.la +if BUILD_ZRTP +SFL_ZRTP_SRC=audio_zrtp_session.h audio_zrtp_session.cpp zrtp_session_callback.cpp zrtp_session_callback.h +endif + libaudiortp_la_SOURCES = \ + $(SFL_ZRTP_SRC) \ audio_rtp_session.cpp \ audio_symmetric_rtp_session.cpp \ audio_rtp_record_handler.cpp \ audio_rtp_factory.cpp \ - audio_zrtp_session.cpp \ - zrtp_session_callback.cpp \ audio_srtp_session.cpp \ audio_rtp_session.h \ audio_rtp_record_handler.h \ audio_rtp_factory.h \ audio_symmetric_rtp_session.h \ - audio_zrtp_session.h \ - zrtp_session_callback.h \ audio_srtp_session.h - diff --git a/daemon/src/audio/audiortp/audio_rtp_factory.cpp b/daemon/src/audio/audiortp/audio_rtp_factory.cpp index 94bf139d0499b65679a4afa372e6023441636a85..abcce370a429afb2db3107526da0ae6eb4dbe68a 100644 --- a/daemon/src/audio/audiortp/audio_rtp_factory.cpp +++ b/daemon/src/audio/audiortp/audio_rtp_factory.cpp @@ -29,7 +29,9 @@ */ #include "audio_rtp_factory.h" +#if HAVE_ZRTP #include "audio_zrtp_session.h" +#endif #include "audio_symmetric_rtp_session.h" #include "manager.h" #include "sip/sdp.h" @@ -37,6 +39,7 @@ #include "sip/sipaccount.h" #include "sip/sdes_negotiator.h" #include "logger.h" +#include "config.h" namespace sfl { @@ -69,10 +72,14 @@ void AudioRtpFactory::initConfig() srtpEnabled_ = account->getSrtpEnabled(); std::string key(account->getSrtpKeyExchange()); if (srtpEnabled_) { +#if HAVE_ZRTP if (key == "sdes") keyExchangeProtocol_ = SDES; else if (key == "zrtp") keyExchangeProtocol_ = ZRTP; +#else + keyExchangeProtocol_ = SDES; +#endif } else { keyExchangeProtocol_ = NONE; } @@ -93,7 +100,7 @@ void AudioRtpFactory::initSession() const std::string zidFilename(Manager::instance().voipPreferences.getZidFile()); switch (keyExchangeProtocol_) { - +#if HAVE_ZRTP case ZRTP: rtpSession_ = new AudioZrtpSession(*ca_, zidFilename); // TODO: be careful with that. The hello hash is computed asynchronously. Maybe it's @@ -101,7 +108,7 @@ void AudioRtpFactory::initSession() if (helloHashEnabled_) ca_->getLocalSDP()->setZrtpHash(static_cast<AudioZrtpSession *>(rtpSession_)->getHelloHash()); break; - +#endif case SDES: rtpSession_ = new AudioSrtpSession(*ca_); break; @@ -152,6 +159,7 @@ void AudioRtpFactory::updateDestinationIpAddress() rtpSession_->updateDestinationIpAddress(); } +#if HAVE_ZRTP sfl::AudioZrtpSession * AudioRtpFactory::getAudioZrtpSession() { if (keyExchangeProtocol_ == ZRTP) @@ -159,6 +167,7 @@ sfl::AudioZrtpSession * AudioRtpFactory::getAudioZrtpSession() else throw AudioRtpFactoryException("rtpSession_ is NULL in getAudioZrtpSession"); } +#endif void sfl::AudioRtpFactory::initLocalCryptoInfo() { diff --git a/daemon/src/audio/audiortp/audio_rtp_factory.h b/daemon/src/audio/audiortp/audio_rtp_factory.h index 172cd1eaddf6bb656674c43a2ce2f281d982ba72..dfa4d17ede63f27884e0df971d73c7175be3f11b 100644 --- a/daemon/src/audio/audiortp/audio_rtp_factory.h +++ b/daemon/src/audio/audiortp/audio_rtp_factory.h @@ -46,7 +46,9 @@ class SIPCall; namespace sfl { +#if HAVE_ZRTP class AudioZrtpSession; +#endif class AudioCodec; class UnsupportedRtpSessionType : public std::logic_error { @@ -115,12 +117,14 @@ class AudioRtpFactory { srtpEnabled_ = enable; } +#if HAVE_ZRTP /** * Get the current AudioZrtpSession. Throws an AudioRtpFactoryException * if the current rtp thread is null, or if it's not of the correct type. * @return The current AudioZrtpSession thread. */ - sfl::AudioZrtpSession * getAudioZrtpSession(); + sfl::AudioZrtpSession* getAudioZrtpSession(); +#endif void initLocalCryptoInfo(); void initLocalCryptoInfoOnOffHold(); diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp index c601a5d9c4f6d9aa929db37804517e0b0f9e15ee..347255d7f078080b7c25d7c049065059260bf502 100644 --- a/daemon/src/dbus/callmanager.cpp +++ b/daemon/src/dbus/callmanager.cpp @@ -37,7 +37,9 @@ #include "sip/sipvoiplink.h" #include "audio/audiolayer.h" #include "audio/audiortp/audio_rtp_factory.h" +#if HAVE_ZRTP #include "audio/audiortp/audio_zrtp_session.h" +#endif #include "logger.h" #include "manager.h" @@ -307,6 +309,7 @@ CallManager::startTone(const int32_t& start , const int32_t& type) // for conferencing in order to get // the right pointer for the given // callID. +#if HAVE_ZRTP sfl::AudioZrtpSession * CallManager::getAudioZrtpSession(const std::string& callID) { @@ -330,60 +333,81 @@ CallManager::getAudioZrtpSession(const std::string& callID) return zSession; } +#endif void CallManager::setSASVerified(const std::string& callID) { +#if HAVE_ZRTP try { sfl::AudioZrtpSession * zSession; zSession = getAudioZrtpSession(callID); zSession->SASVerified(); } catch (...) { } +#else + ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str()); +#endif } void CallManager::resetSASVerified(const std::string& callID) { +#if HAVE_ZRTP try { sfl::AudioZrtpSession * zSession; zSession = getAudioZrtpSession(callID); zSession->resetSASVerified(); } catch (...) { } +#else + ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str()); +#endif } void CallManager::setConfirmGoClear(const std::string& callID) { +#if HAVE_ZRTP try { sfl::AudioZrtpSession * zSession; zSession = getAudioZrtpSession(callID); zSession->goClearOk(); } catch (...) { } +#else + ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str()); +#endif } void CallManager::requestGoClear(const std::string& callID) { +#if HAVE_ZRTP try { sfl::AudioZrtpSession * zSession; zSession = getAudioZrtpSession(callID); zSession->requestGoClear(); } catch (...) { } +#else + ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str()); +#endif } void CallManager::acceptEnrollment(const std::string& callID, const bool& accepted) { +#if HAVE_ZRTP try { sfl::AudioZrtpSession * zSession; zSession = getAudioZrtpSession(callID); zSession->acceptEnrollment(accepted); } catch (...) { } +#else + ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str()); +#endif } void diff --git a/daemon/src/dbus/callmanager.h b/daemon/src/dbus/callmanager.h index 433106e5ca6ce6929487007483a549da13448b8b..d96c546a8f3f451d91b0ca659f9f0115ab5e74eb 100644 --- a/daemon/src/dbus/callmanager.h +++ b/daemon/src/dbus/callmanager.h @@ -127,7 +127,9 @@ class CallManager private: +#if HAVE_ZRTP sfl::AudioZrtpSession * getAudioZrtpSession(const std::string& callID); +#endif }; #endif//CALLMANAGER_H diff --git a/daemon/src/im/instant_messaging.cpp b/daemon/src/im/instant_messaging.cpp index 9b86d996538871454e78bcd3e02a4395d9cdc650..39e02daae33a485d9466f7d27122eb5dfa4b6e81 100644 --- a/daemon/src/im/instant_messaging.cpp +++ b/daemon/src/im/instant_messaging.cpp @@ -105,7 +105,7 @@ void InstantMessaging::send_sip_message(pjsip_inv_session *session, const std::s sip_send(session, id, *iter); } - +#if HAVE_IAX void InstantMessaging::send_iax_message(iax_session *session, const std::string &/* id */, const std::string &message) { std::vector<std::string> msgs(split_message(message)); @@ -114,6 +114,7 @@ void InstantMessaging::send_iax_message(iax_session *session, const std::string for (iter = msgs.begin(); iter != msgs.end(); ++iter) iax_send_text(session, (*iter).c_str()); } +#endif std::vector<std::string> InstantMessaging::split_message(std::string text) diff --git a/daemon/src/im/instant_messaging.h b/daemon/src/im/instant_messaging.h index 7e9b0ee20f510369766692db90f2d843dad2ab2c..17b3162546c070bf0068f50dbe5a9670079f5a4a 100644 --- a/daemon/src/im/instant_messaging.h +++ b/daemon/src/im/instant_messaging.h @@ -47,6 +47,8 @@ #include <iax-client.h> +#include "config.h" + #define EMPTY_MESSAGE pj_str((char*)"") #define MAXIMUM_MESSAGE_LENGTH 1560 /* PJSIP's sip message limit */ @@ -87,7 +89,9 @@ namespace InstantMessaging { void sip_send(pjsip_inv_session*, const std::string& id, const std::string&); void send_sip_message(pjsip_inv_session*, const std::string& id, const std::string&); +#if HAVE_IAX void send_iax_message(iax_session *session, const std::string& id, const std::string&); +#endif std::vector<std::string> split_message(std::string); diff --git a/daemon/src/sip/siptransport.cpp b/daemon/src/sip/siptransport.cpp index fddf885729e05addc4b30b6ffb95ef14749ac0ec..91b41f84abdd04a2a0f841413dd5483a37ff12cb 100644 --- a/daemon/src/sip/siptransport.cpp +++ b/daemon/src/sip/siptransport.cpp @@ -55,7 +55,9 @@ #include "sipaccount.h" #include "pjsip/sip_types.h" +#if HAVE_TLS #include "pjsip/sip_transport_tls.h" +#endif #include "dbus/dbusmanager.h" #include "dbus/configurationmanager.h" @@ -248,7 +250,7 @@ pj_status_t SipTransport::destroyStunResolver(const std::string &serverName) return PJ_SUCCESS; } - +#if HAVE_TLS pjsip_tpfactory* SipTransport::createTlsListener(SIPAccount &account) { pj_sockaddr_in local_addr; @@ -278,7 +280,6 @@ pjsip_tpfactory* SipTransport::createTlsListener(SIPAccount &account) return listener; } - pjsip_transport * SipTransport::createTlsTransport(SIPAccount &account) { @@ -317,6 +318,7 @@ SipTransport::createTlsTransport(SIPAccount &account) RETURN_IF_FAIL(transport != NULL, NULL, "Could not create new TLS transport"); return transport; } +#endif namespace { std::string transportMapKey(const std::string &interface, int port) @@ -331,9 +333,13 @@ void SipTransport::createSipTransport(SIPAccount &account) { shutdownSipTransport(account); +#if HAVE_TLS if (account.isTlsEnabled()) { account.transport_ = createTlsTransport(account); } else if (account.isStunEnabled()) { +#else + if (account.isStunEnabled()) { +#endif account.transport_ = createStunTransport(account); if (account.transport_ == NULL) { WARN("falling back to UDP transport"); @@ -352,9 +358,11 @@ void SipTransport::createSipTransport(SIPAccount &account) } if (!account.transport_) { +#if HAVE_TLS if (account.isTlsEnabled()) throw std::runtime_error("Could not create TLS connection"); else +#endif throw std::runtime_error("Could not create new UDP transport"); } } diff --git a/daemon/src/sip/siptransport.h b/daemon/src/sip/siptransport.h index 7ca9ff1df293cd3f52bae58c1cf8ec1075be7c52..37568c78b92bf5899c829e0692f9495d90037181 100644 --- a/daemon/src/sip/siptransport.h +++ b/daemon/src/sip/siptransport.h @@ -43,6 +43,8 @@ #include <pjnath/stun_config.h> #include "noncopyable.h" +#include "config.h" + class SIPAccount; class SipTransport { @@ -136,6 +138,8 @@ class SipTransport { pjsip_transport * createStunTransport(SIPAccount &account); + +#if HAVE_TLS /** * Create a connection oriented TLS transport and register to the specified remote address. * First, initialize the TLS listener sole instance. This means that, for the momment, only one TLS transport @@ -154,6 +158,7 @@ class SipTransport { */ pjsip_tpfactory * createTlsListener(SIPAccount &account); +#endif /** * Create a new stun resolver. Store it inside the array. Resolve public address for this