Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
udit043 committed Jun 21, 2016
2 parents fc33f23 + a2afb54 commit 0562209
Show file tree
Hide file tree
Showing 32 changed files with 1,827 additions and 365 deletions.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

2 changes: 1 addition & 1 deletion reTurn/AsyncSocketBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public:

/// Note: The following API's are thread safe and queue the request to be handled by the ioService thread
virtual asio::error_code bind(const asio::ip::address& address, unsigned short port) = 0;
virtual void connect(const std::string& address, unsigned short port) = 0;
virtual void connect(const std::string& address, unsigned short port, bool allowV6) = 0;
/// Note: destination is ignored for TCP and TLS connections
virtual void send(const StunTuple& destination, boost::shared_ptr<DataBuffer>& data); // Send unframed data
virtual void send(const StunTuple& destination, unsigned short channel, boost::shared_ptr<DataBuffer>& data); // send with turn framing
Expand Down
2 changes: 1 addition & 1 deletion reTurn/AsyncTcpSocketBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AsyncTcpSocketBase::bind(const asio::ip::address& address, unsigned short port)
}

void
AsyncTcpSocketBase::connect(const std::string& address, unsigned short port)
AsyncTcpSocketBase::connect(const std::string& address, unsigned short port, bool allowV6)
{
// Start an asynchronous resolve to translate the address
// into a list of endpoints.
Expand Down
2 changes: 1 addition & 1 deletion reTurn/AsyncTcpSocketBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public:
virtual unsigned int getSocketDescriptor();

virtual asio::error_code bind(const asio::ip::address& address, unsigned short port);
virtual void connect(const std::string& address, unsigned short port);
virtual void connect(const std::string& address, unsigned short port, bool allowV6);

virtual void transportReceive();
virtual void transportFramedReceive();
Expand Down
2 changes: 1 addition & 1 deletion reTurn/AsyncTlsSocketBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ AsyncTlsSocketBase::bind(const asio::ip::address& address, unsigned short port)
}

void
AsyncTlsSocketBase::connect(const std::string& address, unsigned short port)
AsyncTlsSocketBase::connect(const std::string& address, unsigned short port, bool allowV6)
{
mHostname = address;

Expand Down
2 changes: 1 addition & 1 deletion reTurn/AsyncTlsSocketBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public:
virtual unsigned int getSocketDescriptor();

virtual asio::error_code bind(const asio::ip::address& address, unsigned short port);
virtual void connect(const std::string& address, unsigned short port);
virtual void connect(const std::string& address, unsigned short port, bool allowV6);

void doHandshake();

Expand Down
4 changes: 2 additions & 2 deletions reTurn/AsyncUdpSocketBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ AsyncUdpSocketBase::bind(const asio::ip::address& address, unsigned short port)
}

void
AsyncUdpSocketBase::connect(const std::string& address, unsigned short port)
AsyncUdpSocketBase::connect(const std::string& address, unsigned short port, bool allowV6)
{
// Start an asynchronous resolve to translate the address
// into a list of endpoints.
resip::Data service(port);
#ifdef USE_IPV6
asio::ip::udp::resolver::query query(address, service.c_str());
asio::ip::udp::resolver::query query((allowV6 ? asio::ip::udp::v6() : asio::ip::udp::v4()), address, service.c_str());
#else
asio::ip::udp::resolver::query query(asio::ip::udp::v4(), address, service.c_str());
#endif
Expand Down
2 changes: 1 addition & 1 deletion reTurn/AsyncUdpSocketBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public:
virtual unsigned int getSocketDescriptor();

virtual asio::error_code bind(const asio::ip::address& address, unsigned short port);
virtual void connect(const std::string& address, unsigned short port);
virtual void connect(const std::string& address, unsigned short port, bool allowV6);

virtual void transportReceive();
virtual void transportFramedReceive();
Expand Down
183 changes: 183 additions & 0 deletions reTurn/client/IceCandidate.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#if !defined(IceCandidate_hxx)
#define IceCandidate_hxx

#include "rutil/ParseBuffer.hxx"

namespace reTurn
{
class IceCandidate
{
public:
enum CandidateType
{
CandidateType_Host,
CandidateType_Srflx,
CandidateType_Prflx,
CandidateType_Relay,
CandidateType_Unknown
};

IceCandidate() {}
IceCandidate(
const StunTuple& transportAddr,
CandidateType candidateType,
unsigned int priority,
const resip::Data& foundation,
unsigned int componentId,
const StunTuple& relatedAddr)
: mTransportAddr(transportAddr),
mCandidateType(candidateType),
mPriority(priority),
mFoundation(foundation),
mComponentId(componentId),
mRelatedAddr(relatedAddr)
{
}
IceCandidate(const IceCandidate& rhs)
: mTransportAddr(rhs.mTransportAddr),
mCandidateType(rhs.mCandidateType),
mPriority(rhs.mPriority),
mFoundation(rhs.mFoundation),
mComponentId(rhs.mComponentId),
mRelatedAddr(rhs.mRelatedAddr)
{
}

/*
.jjg. untested, and currently unneeded
IceCandidate(const resip::Data& sdpAttribute)
{
resip::ParseBuffer pb(sdpAttribute);
pb.skipWhitespace();
const char* start = pb.position();
pb.skipNonWhitespace();
pb.data(mFoundation, start);
pb.skipWhitespace();
resip::Data componentId;
start = pb.position();
pb.skipNonWhitespace();
pb.data(componentId, start);
mComponentId = (unsigned int)componentId.convertInt();
pb.skipWhitespace();
resip::Data transport;
start = pb.position();
pb.skipNonWhitespace();
pb.data(transport, start);
if (resip::isEqualNoCase(transport, "udp")) { mTransportAddr.setTransportType(StunTuple::UDP); }
else if (resip::isEqualNoCase(transport, "tcp")) { mTransportAddr.setTransportType(StunTuple::TCP); }
else { assert(0); }
pb.skipWhitespace();
resip::Data priority;
start = pb.position();
pb.skipNonWhitespace();
pb.data(priority, start);
mPriority = (unsigned int)priority.convertInt();
pb.skipWhitespace();
resip::Data connectionAddr;
start = pb.position();
pb.skipNonWhitespace();
pb.data(connectionAddr, start);
mTransportAddr.setAddress(asio::ip::address::from_string(connectionAddr.c_str()));
pb.skipWhitespace();
resip::Data port;
start = pb.position();
pb.skipNonWhitespace();
pb.data(port, start);
mTransportAddr.setPort(port.convertInt());
pb.skipWhitespace();
resip::Data candidateType;
pb.skipChars("typ ");
start = pb.position();
pb.skipNonWhitespace();
pb.data(candidateType, start);
if (resip::isEqualNoCase(candidateType, "host")) { mCandidateType = CandidateType_Host; }
else if (resip::isEqualNoCase(candidateType, "srflx")) { mCandidateType = CandidateType_Srflx; }
else if (resip::isEqualNoCase(candidateType, "prflx")) { mCandidateType = CandidateType_Prflx; }
else if (resip::isEqualNoCase(candidateType, "relay")) { mCandidateType = CandidateType_Relay; }
else { mCandidateType = CandidateType_Unknown; }
pb.skipWhitespace();
if (!pb.eof())
{
resip::Data relatedAddr;
start = pb.position();
pb.skipNonWhitespace();
pb.data(relatedAddr, start);
mRelatedAddr.setTransportType(mTransportAddr.getTransportType());
mRelatedAddr.setAddress(asio::ip::address::from_string(relatedAddr.c_str()));
}
pb.skipWhitespace();
if (!pb.eof())
{
resip::Data relatedPort;
start = pb.position();
pb.skipNonWhitespace();
pb.data(relatedPort, start);
mRelatedAddr.setPort(relatedPort.convertInt());
}
}
*/

virtual ~IceCandidate() {}

const StunTuple& getTransportAddr() const { return mTransportAddr; }
const resip::Data& getFoundation() const { return mFoundation; }
unsigned int getComponentId() const { return mComponentId; }
CandidateType getCandidateType() const { return mCandidateType; }

private:
StunTuple mTransportAddr;
CandidateType mCandidateType;
unsigned int mPriority;
resip::Data mFoundation;
unsigned int mComponentId;
StunTuple mRelatedAddr;

};
}

#endif // IceCandidate_hxx


/* ====================================================================
Copyright (c) 2009, CounterPath, 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. Neither the name of CounterPath nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 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.
==================================================================== */
7 changes: 4 additions & 3 deletions reTurn/client/TurnAsyncSocket.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using namespace resip;

//#define TURN_CHANNEL_BINDING_REFRESH_SECONDS 20 // TESTING only
#define TURN_CHANNEL_BINDING_REFRESH_SECONDS 240 // 4 minuntes - this is one minute before the permission will expire, Note: ChannelBinding refreshes also refresh permissions

#define SOFTWARE_STRING "reTURN Async Client 0.3 - RFC5389/turn-12 " // Note padding size to a multiple of 4, to help compatibility with older clients

namespace reTurn {
Expand Down Expand Up @@ -835,7 +836,7 @@ TurnAsyncSocket::handleBindRequest(StunMessage& stunMessage)
DebugLog(<< "Sending response to BIND to " << stunMessage.mRemoteTuple);
sendStunMessage(response, false, UDP_MAX_RETRANSMITS, DEFAULT_RETRANS_INTERVAL_MS, &(stunMessage.mRemoteTuple));

if(mTurnAsyncSocketHandler) mTurnAsyncSocketHandler->onIncomingBindRequestProcessed(getSocketDescriptor(), stunMessage.mRemoteTuple);
if(mTurnAsyncSocketHandler) mTurnAsyncSocketHandler->onIncomingBindRequestProcessed(getSocketDescriptor(), stunMessage.mRemoteTuple, stunMessage);

return asio::error_code();
}
Expand Down Expand Up @@ -1106,9 +1107,9 @@ TurnAsyncSocket::sendToRemotePeer(RemotePeer& remotePeer, boost::shared_ptr<Data
}

void
TurnAsyncSocket::connect(const std::string& address, unsigned short port)
TurnAsyncSocket::connect(const std::string& address, unsigned short port, bool allowV6)
{
mAsyncSocketBase.connect(address, port);
mAsyncSocketBase.connect(address, port, allowV6);
}

void
Expand Down
2 changes: 1 addition & 1 deletion reTurn/client/TurnAsyncSocket.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public:
// Sets the local HmacKey, used to check the integrity of incoming STUN messages
void setLocalPassword(const char* password);

void connect(const std::string& address, unsigned short port);
void connect(const std::string& address, unsigned short port, bool allowV6);

// Stun Binding Method - use getReflexiveTuple() to get binding info
void bindRequest();
Expand Down
4 changes: 3 additions & 1 deletion reTurn/client/TurnAsyncSocketHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace reTurn {

class StunMessage;

class TurnAsyncSocketHandler
{
public:
Expand Down Expand Up @@ -49,7 +51,7 @@ public:
virtual void onSendSuccess(unsigned int socketDesc) = 0;
virtual void onSendFailure(unsigned int socketDesc, const asio::error_code& e) = 0;

virtual void onIncomingBindRequestProcessed(unsigned int socketDesc, const StunTuple& sourceTuple) = 0;
virtual void onIncomingBindRequestProcessed(unsigned int socketDesc, const StunTuple& sourceTuple, const reTurn::StunMessage& bindRequest) = 0;

private:
};
Expand Down
4 changes: 4 additions & 0 deletions reTurn/client/TurnSocket.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ TurnSocket::createAllocation(unsigned int lifetime,
return asio::error_code(reTurn::InvalidRequestedTransport, asio::error::misc_category);
}

// TURN RequestedAddressFamily
//request.mHasTurnRequestedAddressFamily = true;
//request.mTurnRequestedAddressFamily = 0x01; // IPv4

if(mRequestedProps != StunMessage::PropsNone)
{
request.mHasTurnEvenPort = true;
Expand Down
2 changes: 1 addition & 1 deletion reTurn/client/test/TestAsyncClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ int main(int argc, char* argv[])
handler.setTurnAsyncSocket(turnSocket.get());

// Connect to Stun/Turn Server
turnSocket->connect(argv[1], port);
turnSocket->connect(argv[1], port, false);

// Set the username and password
turnSocket->setUsernameAndPassword(username, password);
Expand Down
2 changes: 1 addition & 1 deletion reTurn/client/test/TestRtpLoad.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int main(int argc, char* argv[])
handler.setTurnAsyncSocket(turnSocket.get());

// Connect to Stun/Turn Server
turnSocket->connect(turnAddress.c_str(), port);
turnSocket->connect(turnAddress.c_str(), port, false);

// Set the username and password
turnSocket->setUsernameAndPassword(username, password);
Expand Down
5 changes: 5 additions & 0 deletions reflow/FakeSelectSocketDescriptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ FakeSelectSocketDescriptor::send()
resip_assert(count == 1);
#else
size_t res = ::write(mPipe[1], fakeData, 1);
<<<<<<< HEAD
resip_assert(res == 1);
=======
assert(res == 1);
((void)res); // elimiante warning GCC
>>>>>>> udit-webrtc
#endif
}

Expand Down

0 comments on commit 0562209

Please sign in to comment.