Commit 59eb2560 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#13726: Makes sdes an optional feature at build time for sflphone daemon

parent 5d1cd79b
......@@ -190,7 +190,17 @@ AM_CONDITIONAL(BUILD_INSTANT_MESSAGING, test "x$with_instant_messaging" = "xyes"
AX_PTHREAD
# AX_PATH_LIB_PCRE
AC_ARG_WITH([sdes],
[ AS_HELP_STRING([--without-sdes], [disable support for sdes key exchange]) ],
[],
[with_sdes=yes])
AS_IF([test "x$with_sdes" = "xyes"], [
AX_PATH_LIB_PCRE
]);
AC_DEFINE_UNQUOTED([HAVE_SDES], `if test "x$with_sdes" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have sdes support])
AM_CONDITIONAL(BUILD_SDES, test "x$with_sdes" = "xyes" )
dnl Check for libcppunit-dev
CPPUNIT_MIN_VERSION=1.12
......
......@@ -3,15 +3,11 @@ include $(top_srcdir)/globals.mak
noinst_LTLIBRARIES = libsiplink.la
libsiplink_la_SOURCES = \
pattern.cpp \
sdes_negotiator.cpp \
sdp.cpp \
sipaccount.cpp \
sipcall.cpp \
sipvoiplink.cpp \
siptransport.cpp \
pattern.h \
sdes_negotiator.h \
sdp.h \
sipaccount.h \
sipcall.h \
......@@ -20,5 +16,13 @@ libsiplink_la_SOURCES = \
sip_utils.cpp \
sip_utils.h
#libsiplink_la_CXXFLAGS = \
# @PCRE_LIBS@
if BUILD_SDES
libsiplink_la_SOURCES+= sdes_negotiator.cpp \
sdes_negotiator.h \
pattern.cpp \
pattern.h
libsiplink_la_CXXFLAGS = \
@PCRE_LIBS@
endif
......@@ -42,7 +42,6 @@ Pattern::Pattern(const std::string& pattern, const std::string& options) :
options_(0),
optionsDescription_(options)
{
/*
// Set offsets
offset_[0] = offset_[1] = 0;
......@@ -68,20 +67,16 @@ Pattern::Pattern(const std::string& pattern, const std::string& options) :
// Compile the pattern.
compile();
*/
}
Pattern::~Pattern()
{
/*
if (re_ != NULL)
pcre_free(re_);
*/
}
void Pattern::compile()
{
/*
// Compile the pattern
int offset;
const char * error;
......@@ -106,7 +101,6 @@ void Pattern::compile()
ovector_.clear();
ovector_.resize((captureCount + 1) * 3);
*/
}
unsigned int Pattern::getCaptureGroupCount()
......@@ -122,12 +116,10 @@ std::vector<std::string> Pattern::groups()
// pcre_get_substring_list(subject_.c_str(), &ovector_[0], count_, &stringList);
std::vector<std::string> matchedSubstrings;
/*
for (int i = 1; stringList[i] != NULL; i++)
matchedSubstrings.push_back(stringList[i]);
pcre_free_substring_list(stringList);
*/
return matchedSubstrings;
}
......@@ -135,7 +127,6 @@ std::vector<std::string> Pattern::groups()
std::string Pattern::group(int groupNumber)
{
const char * stringPtr;
/*
int rc = pcre_get_substring(subject_.substr(offset_[0]).c_str(), &ovector_[0],
count_, groupNumber, &stringPtr);
......@@ -151,17 +142,15 @@ std::string Pattern::group(int groupNumber)
throw MatchError("Failed to get named substring.");
}
}
*/
std::string matchedStr(stringPtr);
// pcre_free_substring(stringPtr);
pcre_free_substring(stringPtr);
return matchedStr;
}
std::string Pattern::group(const std::string& groupName)
{
/*
const char * stringPtr = NULL;
int rc = pcre_get_named_substring(re_, subject_.substr(offset_[0]).c_str(),
&ovector_[0], count_, groupName.c_str(),
......@@ -179,33 +168,26 @@ std::string Pattern::group(const std::string& groupName)
throw MatchError("Failed to get named substring.");
}
}
*/
std::string matchedStr;
/*
if (stringPtr) {
matchedStr = stringPtr;
pcre_free_substring(stringPtr);
}
*/
return matchedStr;
}
void Pattern::start(const std::string& groupName) const
{
/*
int index = pcre_get_stringnumber(re_, groupName.c_str());
start(index);
*/
}
size_t Pattern::start(unsigned int groupNumber) const
{
/*
if (groupNumber <= (unsigned int) count_)
return ovector_[(groupNumber + 1) * 2];
else
throw std::out_of_range("Invalid group reference.");
*/
return 0;
}
......@@ -216,20 +198,16 @@ size_t Pattern::start() const
void Pattern::end(const std::string& groupName) const
{
/*
int index = pcre_get_stringnumber(re_, groupName.c_str());
end(index);
*/
}
size_t Pattern::end(unsigned int groupNumber) const
{
/*
if (groupNumber <= (unsigned int) count_)
return ovector_[((groupNumber + 1) * 2) + 1 ] - 1;
else
throw std::out_of_range("Invalid group reference.");
*/
return 0;
}
......@@ -240,15 +218,12 @@ size_t Pattern::end() const
bool Pattern::matches()
{
/*
return matches(subject_);
*/
return true;
}
bool Pattern::matches(const std::string& subject)
{
/*
// Try to find a match for this pattern
int rc = pcre_exec(re_, NULL, subject.substr(offset_[1]).c_str(),
subject.length() - offset_[1], 0, options_, &ovector_[0],
......@@ -275,18 +250,14 @@ bool Pattern::matches(const std::string& subject)
// Matching succeeded. Keep the number of substrings for
// subsequent calls to group().
count_ = rc;
*/
return true;
}
std::vector<std::string> Pattern::split()
{
/*
size_t tokenEnd = -1;
size_t tokenStart = 0;
*/
std::vector<std::string> substringSplitted;
/*
while (matches()) {
tokenStart = start();
substringSplitted.push_back(subject_.substr(tokenEnd + 1,
......@@ -296,7 +267,6 @@ std::vector<std::string> Pattern::split()
substringSplitted.push_back(subject_.substr(tokenEnd + 1,
tokenStart - tokenEnd - 1));
*/
return substringSplitted;
}
}
......@@ -32,7 +32,7 @@
#include <stdexcept>
#include <string>
#include <vector>
// #include <pcre.h>
#include <pcre.h>
#include "noncopyable.h"
namespace sfl {
......@@ -308,7 +308,7 @@ class Pattern {
* contains the compiled regular
* expression
*/
// pcre * re_;
pcre * re_;
// The internal output vector used by PCRE.
std::vector<int> ovector_;
......
......@@ -55,6 +55,8 @@
#include "sipaccount.h"
#include "pjsip/sip_types.h"
#include "pjsip/sip_transport_tls.h"
#include "dbus/dbusmanager.h"
#include "dbus/configurationmanager.h"
......
......@@ -46,7 +46,9 @@
#include "sipcall.h"
#include "sipaccount.h"
#include "eventthread.h"
#if HAVE_SDES
#include "sdes_negotiator.h"
#endif
#include "array_size.h"
#include "dbus/dbusmanager.h"
......@@ -63,7 +65,6 @@
#endif
#include "pjsip/sip_endpoint.h"
#include "pjsip/sip_transport_tls.h"
#include "pjsip/sip_uri.h"
#include "pjnath.h"
......@@ -318,12 +319,14 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
std::copy(sfl::CryptoSuites, sfl::CryptoSuites + size,
localCapabilities.begin());
#if HAVE_SDES
sfl::SdesNegotiator sdesnego(localCapabilities, crypto_offer);
if (sdesnego.negotiate()) {
call->getAudioRtp().setRemoteCryptoInfo(sdesnego);
call->getAudioRtp().initLocalCryptoInfo();
}
#endif
}
}
......@@ -1535,6 +1538,7 @@ void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
CryptoOffer crypto_offer;
call->getLocalSDP()->getRemoteSdpCryptoFromOffer(remote_sdp, crypto_offer);
#if HAVE_SDES
bool nego_success = false;
if (!crypto_offer.empty()) {
......@@ -1573,6 +1577,7 @@ void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
if (dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID))->getSrtpFallback())
call->getAudioRtp().initSession();
}
#endif // HAVE_SDES
sfl::AudioCodec *sessionMedia = sdpSession->getSessionAudioMedia();
......
......@@ -24,8 +24,6 @@ test_SOURCES = constants.h \
historytest.cpp \
numbercleanertest.h \
numbercleanertest.cpp \
sdesnegotiatortest.h \
sdesnegotiatortest.cpp \
siptest.h \
siptest.cpp \
sdptest.h \
......@@ -39,6 +37,11 @@ test_SOURCES = constants.h \
resamplertest.h \
resamplertest.cpp
if BUILD_SDES
test_SOURCES+=sdesnegotiatortest.h \
sdesnegotiatortest.cpp
endif
if BUILD_INSTANT_MESSAGING
test_SOURCES+=instantmessagingtest.h \
instantmessagingtest.cpp
......
Supports Markdown
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