| Index: webrtc/voice_engine/test/channel_transport/udp_transport_impl.cc
|
| diff --git a/webrtc/voice_engine/test/channel_transport/udp_transport_impl.cc b/webrtc/voice_engine/test/channel_transport/udp_transport_impl.cc
|
| index c44cf9e17258caeb61844f984886a04b2a89b376..995e91989970c95041eb5447cd9b0e9d63d6f770 100644
|
| --- a/webrtc/voice_engine/test/channel_transport/udp_transport_impl.cc
|
| +++ b/webrtc/voice_engine/test/channel_transport/udp_transport_impl.cc
|
| @@ -124,10 +124,10 @@ UdpTransportImpl::UdpTransportImpl(const int32_t id,
|
| _destIP(),
|
| _localIP(),
|
| _localMulticastIP(),
|
| - _ptrRtpSocket(NULL),
|
| - _ptrRtcpSocket(NULL),
|
| - _ptrSendRtpSocket(NULL),
|
| - _ptrSendRtcpSocket(NULL),
|
| + _ptrRtpSocket(nullptr),
|
| + _ptrRtcpSocket(nullptr),
|
| + _ptrSendRtpSocket(nullptr),
|
| + _ptrSendRtcpSocket(nullptr),
|
| _remoteRTPAddr(),
|
| _remoteRTCPAddr(),
|
| _localRTPAddr(),
|
| @@ -149,21 +149,20 @@ UdpTransportImpl::UdpTransportImpl(const int32_t id,
|
| _filterIPAddress(),
|
| _rtpFilterPort(0),
|
| _rtcpFilterPort(0),
|
| - _packetCallback(0)
|
| -{
|
| - memset(&_remoteRTPAddr, 0, sizeof(_remoteRTPAddr));
|
| - memset(&_remoteRTCPAddr, 0, sizeof(_remoteRTCPAddr));
|
| - memset(&_localRTPAddr, 0, sizeof(_localRTPAddr));
|
| - memset(&_localRTCPAddr, 0, sizeof(_localRTCPAddr));
|
| + _packetCallback(0) {
|
| + memset(&_remoteRTPAddr, 0, sizeof(_remoteRTPAddr));
|
| + memset(&_remoteRTCPAddr, 0, sizeof(_remoteRTCPAddr));
|
| + memset(&_localRTPAddr, 0, sizeof(_localRTPAddr));
|
| + memset(&_localRTCPAddr, 0, sizeof(_localRTCPAddr));
|
|
|
| - memset(_fromIP, 0, sizeof(_fromIP));
|
| - memset(_destIP, 0, sizeof(_destIP));
|
| - memset(_localIP, 0, sizeof(_localIP));
|
| - memset(_localMulticastIP, 0, sizeof(_localMulticastIP));
|
| + memset(_fromIP, 0, sizeof(_fromIP));
|
| + memset(_destIP, 0, sizeof(_destIP));
|
| + memset(_localIP, 0, sizeof(_localIP));
|
| + memset(_localMulticastIP, 0, sizeof(_localMulticastIP));
|
|
|
| - memset(&_filterIPAddress, 0, sizeof(_filterIPAddress));
|
| + memset(&_filterIPAddress, 0, sizeof(_filterIPAddress));
|
|
|
| - WEBRTC_TRACE(kTraceMemory, kTraceTransport, id, "%s created", __FUNCTION__);
|
| + WEBRTC_TRACE(kTraceMemory, kTraceTransport, id, "%s created", __FUNCTION__);
|
| }
|
|
|
| UdpTransportImpl::~UdpTransportImpl()
|
| @@ -242,11 +241,10 @@ int32_t UdpTransportImpl::InitializeReceiveSockets(
|
| CriticalSectionScoped cs(_critPacketCallback);
|
| _packetCallback = packetCallback;
|
|
|
| - if(packetCallback == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, _id,
|
| - "Closing down receive sockets");
|
| - return 0;
|
| + if (packetCallback == nullptr) {
|
| + WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, _id,
|
| + "Closing down receive sockets");
|
| + return 0;
|
| }
|
| }
|
|
|
| @@ -319,11 +317,10 @@ int32_t UdpTransportImpl::InitializeReceiveSockets(
|
| return -1;
|
| }
|
| }
|
| - if(_mgr == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| - "InitializeReceiveSockets no socket manager");
|
| - return -1;
|
| + if (_mgr == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| + "InitializeReceiveSockets no socket manager");
|
| + return -1;
|
| }
|
|
|
| _useSetSockOpt=false;
|
| @@ -752,8 +749,8 @@ int32_t UdpTransportImpl::SetToS(int32_t DSCP, bool useSetSockOpt)
|
| }
|
| }
|
| CriticalSectionScoped cs(_crit);
|
| - UdpSocketWrapper* rtpSock = NULL;
|
| - UdpSocketWrapper* rtcpSock = NULL;
|
| + UdpSocketWrapper* rtpSock = nullptr;
|
| + UdpSocketWrapper* rtcpSock = nullptr;
|
| if(_ptrSendRtpSocket)
|
| {
|
| rtpSock = _ptrSendRtpSocket;
|
| @@ -761,10 +758,9 @@ int32_t UdpTransportImpl::SetToS(int32_t DSCP, bool useSetSockOpt)
|
| {
|
| rtpSock = _ptrRtpSocket;
|
| }
|
| - if (rtpSock == NULL)
|
| - {
|
| - _lastError = kSocketInvalid;
|
| - return -1;
|
| + if (rtpSock == nullptr) {
|
| + _lastError = kSocketInvalid;
|
| + return -1;
|
| }
|
| if(!rtpSock->ValidHandle())
|
| {
|
| @@ -778,10 +774,9 @@ int32_t UdpTransportImpl::SetToS(int32_t DSCP, bool useSetSockOpt)
|
| {
|
| rtcpSock = _ptrRtcpSocket;
|
| }
|
| - if (rtcpSock == NULL)
|
| - {
|
| - _lastError = kSocketInvalid;
|
| - return -1;
|
| + if (rtcpSock == nullptr) {
|
| + _lastError = kSocketInvalid;
|
| + return -1;
|
| }
|
| if(!rtcpSock->ValidHandle())
|
| {
|
| @@ -809,14 +804,10 @@ int32_t UdpTransportImpl::SetToS(int32_t DSCP, bool useSetSockOpt)
|
| if(_ptrSendRtpSocket)
|
| {
|
| CloseSendSockets();
|
| - _ptrSendRtpSocket =
|
| - _socket_creator->CreateSocket(_id, _mgr, NULL,
|
| - NULL, IpV6Enabled(),
|
| - true);
|
| - _ptrSendRtcpSocket =
|
| - _socket_creator->CreateSocket(_id, _mgr, NULL,
|
| - NULL, IpV6Enabled(),
|
| - true);
|
| + _ptrSendRtpSocket = _socket_creator->CreateSocket(
|
| + _id, _mgr, nullptr, nullptr, IpV6Enabled(), true);
|
| + _ptrSendRtcpSocket = _socket_creator->CreateSocket(
|
| + _id, _mgr, nullptr, nullptr, IpV6Enabled(), true);
|
| rtpSock=_ptrSendRtpSocket;
|
| rtcpSock=_ptrSendRtcpSocket;
|
| ErrorCode retVal = BindRTPSendSocket();
|
| @@ -946,8 +937,8 @@ int32_t UdpTransportImpl::SetPCP(int32_t PCP)
|
| }
|
|
|
| CriticalSectionScoped cs(_crit);
|
| - UdpSocketWrapper* rtpSock = NULL;
|
| - UdpSocketWrapper* rtcpSock = NULL;
|
| + UdpSocketWrapper* rtpSock = nullptr;
|
| + UdpSocketWrapper* rtcpSock = nullptr;
|
| if(_ptrSendRtpSocket)
|
| {
|
| rtpSock = _ptrSendRtpSocket;
|
| @@ -955,10 +946,9 @@ int32_t UdpTransportImpl::SetPCP(int32_t PCP)
|
| {
|
| rtpSock = _ptrRtpSocket;
|
| }
|
| - if (rtpSock == NULL)
|
| - {
|
| - _lastError = kSocketInvalid;
|
| - return -1;
|
| + if (rtpSock == nullptr) {
|
| + _lastError = kSocketInvalid;
|
| + return -1;
|
| }
|
| if(!rtpSock->ValidHandle())
|
| {
|
| @@ -972,10 +962,9 @@ int32_t UdpTransportImpl::SetPCP(int32_t PCP)
|
| {
|
| rtcpSock = _ptrRtcpSocket;
|
| }
|
| - if (rtcpSock == NULL)
|
| - {
|
| - _lastError = kSocketInvalid;
|
| - return -1;
|
| + if (rtcpSock == nullptr) {
|
| + _lastError = kSocketInvalid;
|
| + return -1;
|
| }
|
| if(!rtcpSock->ValidHandle())
|
| {
|
| @@ -1056,12 +1045,10 @@ int32_t UdpTransportImpl::EnableIpV6() {
|
| int32_t UdpTransportImpl::FilterIP(
|
| char filterIPAddress[kIpAddressVersion6Length]) const
|
| {
|
| -
|
| - if(filterIPAddress == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| - "FilterIP: Invalid argument");
|
| - return -1;
|
| + if (filterIPAddress == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| + "FilterIP: Invalid argument");
|
| + return -1;
|
| }
|
| if(_filterIPAddress._sockaddr_storage.sin_family == 0)
|
| {
|
| @@ -1077,11 +1064,10 @@ int32_t UdpTransportImpl::FilterIP(
|
| int32_t UdpTransportImpl::SetFilterIP(
|
| const char filterIPAddress[kIpAddressVersion6Length])
|
| {
|
| - if(filterIPAddress == NULL)
|
| - {
|
| - memset(&_filterIPAddress, 0, sizeof(_filterIPAddress));
|
| - WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, "Filter IP reset");
|
| - return 0;
|
| + if (filterIPAddress == nullptr) {
|
| + memset(&_filterIPAddress, 0, sizeof(_filterIPAddress));
|
| + WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, "Filter IP reset");
|
| + return 0;
|
| }
|
| CriticalSectionScoped cs(_critFilter);
|
| if (_ipV6Enabled)
|
| @@ -1492,9 +1478,8 @@ int32_t UdpTransportImpl::InitializeSourcePorts(uint16_t rtpPort,
|
|
|
| CloseSendSockets();
|
|
|
| - if(_mgr == NULL)
|
| - {
|
| - return -1;
|
| + if (_mgr == nullptr) {
|
| + return -1;
|
| }
|
|
|
| _srcPort = rtpPort;
|
| @@ -1509,10 +1494,10 @@ int32_t UdpTransportImpl::InitializeSourcePorts(uint16_t rtpPort,
|
| _tos=0;
|
| _pcp=0;
|
|
|
| - _ptrSendRtpSocket = _socket_creator->CreateSocket(_id, _mgr, NULL, NULL,
|
| - IpV6Enabled(), false);
|
| - _ptrSendRtcpSocket = _socket_creator->CreateSocket(_id, _mgr, NULL, NULL,
|
| - IpV6Enabled(), false);
|
| + _ptrSendRtpSocket = _socket_creator->CreateSocket(
|
| + _id, _mgr, nullptr, nullptr, IpV6Enabled(), false);
|
| + _ptrSendRtcpSocket = _socket_creator->CreateSocket(
|
| + _id, _mgr, nullptr, nullptr, IpV6Enabled(), false);
|
|
|
| ErrorCode retVal = BindRTPSendSocket();
|
| if(retVal != kNoSocketError)
|
| @@ -1575,13 +1560,11 @@ int32_t UdpTransportImpl::StartReceiving(uint32_t /*numberOfSocketBuffers*/)
|
| return -1;
|
| }
|
| }
|
| - if( _ptrRtpSocket == NULL &&
|
| - _ptrRtcpSocket == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| - "Failed to StartReceiving, no socket initialized");
|
| - _lastError = kStartReceiveError;
|
| - return -1;
|
| + if (_ptrRtpSocket == nullptr && _ptrRtcpSocket == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| + "Failed to StartReceiving, no socket initialized");
|
| + _lastError = kStartReceiveError;
|
| + return -1;
|
| }
|
| _receiving = true;
|
| return 0;
|
| @@ -1638,15 +1621,13 @@ int32_t UdpTransportImpl::InitializeSendSockets(
|
| _destPortRTCP = rtcpPort;
|
| }
|
|
|
| - if(ipaddr == NULL)
|
| - {
|
| - if (!IsIpAddressValid(_destIP, IpV6Enabled()))
|
| - {
|
| - _destPort = 0;
|
| - _destPortRTCP = 0;
|
| - _lastError = kIpAddressInvalid;
|
| - return -1;
|
| - }
|
| + if (ipaddr == nullptr) {
|
| + if (!IsIpAddressValid(_destIP, IpV6Enabled())) {
|
| + _destPort = 0;
|
| + _destPortRTCP = 0;
|
| + _lastError = kIpAddressInvalid;
|
| + return -1;
|
| + }
|
| } else
|
| {
|
| if (IsIpAddressValid(ipaddr, IpV6Enabled()))
|
| @@ -1713,7 +1694,7 @@ int32_t UdpTransportImpl::InitializeSendSockets(
|
| WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| "setsockopt for multicast error on RTP socket");
|
| _ptrRtpSocket->CloseBlocking();
|
| - _ptrRtpSocket = NULL;
|
| + _ptrRtpSocket = nullptr;
|
| _lastError = kMulticastAddressInvalid;
|
| return -1;
|
| }
|
| @@ -1724,7 +1705,7 @@ int32_t UdpTransportImpl::InitializeSendSockets(
|
| WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| "setsockopt for multicast error on RTCP socket");
|
| _ptrRtpSocket->CloseBlocking();
|
| - _ptrRtpSocket = NULL;
|
| + _ptrRtpSocket = nullptr;
|
| _lastError = kMulticastAddressInvalid;
|
| return -1;
|
| }
|
| @@ -1773,10 +1754,9 @@ int32_t UdpTransportImpl::SendRaw(const int8_t *data,
|
| CriticalSectionScoped cs(_crit);
|
| if(isRTCP)
|
| {
|
| - UdpSocketWrapper* rtcpSock = NULL;
|
| - if(_ptrSendRtcpSocket)
|
| - {
|
| - rtcpSock = _ptrSendRtcpSocket;
|
| + UdpSocketWrapper* rtcpSock = nullptr;
|
| + if (_ptrSendRtcpSocket) {
|
| + rtcpSock = _ptrSendRtcpSocket;
|
| } else if(_ptrRtcpSocket)
|
| {
|
| rtcpSock = _ptrRtcpSocket;
|
| @@ -1784,20 +1764,17 @@ int32_t UdpTransportImpl::SendRaw(const int8_t *data,
|
| {
|
| return -1;
|
| }
|
| - if(portnr == 0 && ip == NULL)
|
| - {
|
| - return rtcpSock->SendTo(data,length,_remoteRTCPAddr);
|
| -
|
| - } else if(portnr != 0 && ip != NULL)
|
| - {
|
| - SocketAddress remoteAddr;
|
| - BuildSockaddrIn(portnr, ip, remoteAddr);
|
| - return rtcpSock->SendTo(data,length,remoteAddr);
|
| - } else if(ip != NULL)
|
| - {
|
| - SocketAddress remoteAddr;
|
| - BuildSockaddrIn(_destPortRTCP, ip, remoteAddr);
|
| - return rtcpSock->SendTo(data,length,remoteAddr);
|
| + if (portnr == 0 && ip == nullptr) {
|
| + return rtcpSock->SendTo(data, length, _remoteRTCPAddr);
|
| +
|
| + } else if (portnr != 0 && ip != nullptr) {
|
| + SocketAddress remoteAddr;
|
| + BuildSockaddrIn(portnr, ip, remoteAddr);
|
| + return rtcpSock->SendTo(data, length, remoteAddr);
|
| + } else if (ip != nullptr) {
|
| + SocketAddress remoteAddr;
|
| + BuildSockaddrIn(_destPortRTCP, ip, remoteAddr);
|
| + return rtcpSock->SendTo(data, length, remoteAddr);
|
| } else
|
| {
|
| SocketAddress remoteAddr;
|
| @@ -1805,10 +1782,9 @@ int32_t UdpTransportImpl::SendRaw(const int8_t *data,
|
| return rtcpSock->SendTo(data,length,remoteAddr);
|
| }
|
| } else {
|
| - UdpSocketWrapper* rtpSock = NULL;
|
| - if(_ptrSendRtpSocket)
|
| - {
|
| - rtpSock = _ptrSendRtpSocket;
|
| + UdpSocketWrapper* rtpSock = nullptr;
|
| + if (_ptrSendRtpSocket) {
|
| + rtpSock = _ptrSendRtpSocket;
|
|
|
| } else if(_ptrRtpSocket)
|
| {
|
| @@ -1817,20 +1793,17 @@ int32_t UdpTransportImpl::SendRaw(const int8_t *data,
|
| {
|
| return -1;
|
| }
|
| - if(portnr == 0 && ip == NULL)
|
| - {
|
| - return rtpSock->SendTo(data,length,_remoteRTPAddr);
|
| -
|
| - } else if(portnr != 0 && ip != NULL)
|
| - {
|
| - SocketAddress remoteAddr;
|
| - BuildSockaddrIn(portnr, ip, remoteAddr);
|
| - return rtpSock->SendTo(data,length,remoteAddr);
|
| - } else if(ip != NULL)
|
| - {
|
| - SocketAddress remoteAddr;
|
| - BuildSockaddrIn(_destPort, ip, remoteAddr);
|
| - return rtpSock->SendTo(data,length,remoteAddr);
|
| + if (portnr == 0 && ip == nullptr) {
|
| + return rtpSock->SendTo(data, length, _remoteRTPAddr);
|
| +
|
| + } else if (portnr != 0 && ip != nullptr) {
|
| + SocketAddress remoteAddr;
|
| + BuildSockaddrIn(portnr, ip, remoteAddr);
|
| + return rtpSock->SendTo(data, length, remoteAddr);
|
| + } else if (ip != nullptr) {
|
| + SocketAddress remoteAddr;
|
| + BuildSockaddrIn(_destPort, ip, remoteAddr);
|
| + return rtpSock->SendTo(data, length, remoteAddr);
|
| } else
|
| {
|
| SocketAddress remoteAddr;
|
| @@ -1950,40 +1923,31 @@ bool UdpTransportImpl::SendRtp(const uint8_t* data,
|
| // Create socket if it hasn't been set up already.
|
| // TODO (hellner): why not fail here instead. Sockets not being initialized
|
| // indicates that there is a problem somewhere.
|
| - if( _ptrSendRtpSocket == NULL &&
|
| - _ptrRtpSocket == NULL)
|
| - {
|
| - WEBRTC_TRACE(
|
| - kTraceStateInfo,
|
| - kTraceTransport,
|
| - _id,
|
| - "Creating RTP socket since no receive or source socket is\
|
| + if (_ptrSendRtpSocket == nullptr && _ptrRtpSocket == nullptr) {
|
| + WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, _id,
|
| + "Creating RTP socket since no receive or source socket is\
|
| configured");
|
|
|
| - _ptrRtpSocket = _socket_creator->CreateSocket(_id, _mgr, this,
|
| - IncomingRTPCallback,
|
| - IpV6Enabled(), false);
|
| + _ptrRtpSocket = _socket_creator->CreateSocket(
|
| + _id, _mgr, this, IncomingRTPCallback, IpV6Enabled(), false);
|
|
|
| - // Don't bind to a specific IP address.
|
| - if(! IpV6Enabled())
|
| - {
|
| - strncpy(_localIP, "0.0.0.0",16);
|
| - } else
|
| - {
|
| - strncpy(_localIP, "0000:0000:0000:0000:0000:0000:0000:0000",
|
| - kIpAddressVersion6Length);
|
| - }
|
| - _localPort = _destPort;
|
| + // Don't bind to a specific IP address.
|
| + if (!IpV6Enabled()) {
|
| + strncpy(_localIP, "0.0.0.0", 16);
|
| + } else {
|
| + strncpy(_localIP, "0000:0000:0000:0000:0000:0000:0000:0000",
|
| + kIpAddressVersion6Length);
|
| + }
|
| + _localPort = _destPort;
|
|
|
| - ErrorCode retVal = BindLocalRTPSocket();
|
| - if(retVal != kNoSocketError)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| - "SendPacket() failed to bind RTP socket");
|
| - _lastError = retVal;
|
| - CloseReceiveSockets();
|
| - return false;
|
| - }
|
| + ErrorCode retVal = BindLocalRTPSocket();
|
| + if (retVal != kNoSocketError) {
|
| + WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| + "SendPacket() failed to bind RTP socket");
|
| + _lastError = retVal;
|
| + CloseReceiveSockets();
|
| + return false;
|
| + }
|
| }
|
|
|
| if(_ptrSendRtpSocket)
|
| @@ -2013,40 +1977,31 @@ bool UdpTransportImpl::SendRtcp(const uint8_t* data, size_t length) {
|
| // Create socket if it hasn't been set up already.
|
| // TODO (hellner): why not fail here instead. Sockets not being initialized
|
| // indicates that there is a problem somewhere.
|
| - if( _ptrSendRtcpSocket == NULL &&
|
| - _ptrRtcpSocket == NULL)
|
| - {
|
| - WEBRTC_TRACE(
|
| - kTraceStateInfo,
|
| - kTraceTransport,
|
| - _id,
|
| - "Creating RTCP socket since no receive or source socket is\
|
| + if (_ptrSendRtcpSocket == nullptr && _ptrRtcpSocket == nullptr) {
|
| + WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, _id,
|
| + "Creating RTCP socket since no receive or source socket is\
|
| configured");
|
|
|
| - _ptrRtcpSocket = _socket_creator->CreateSocket(_id, _mgr, this,
|
| - IncomingRTCPCallback,
|
| - IpV6Enabled(), false);
|
| + _ptrRtcpSocket = _socket_creator->CreateSocket(
|
| + _id, _mgr, this, IncomingRTCPCallback, IpV6Enabled(), false);
|
|
|
| - // Don't bind to a specific IP address.
|
| - if(! IpV6Enabled())
|
| - {
|
| - strncpy(_localIP, "0.0.0.0",16);
|
| - } else
|
| - {
|
| - strncpy(_localIP, "0000:0000:0000:0000:0000:0000:0000:0000",
|
| - kIpAddressVersion6Length);
|
| - }
|
| - _localPortRTCP = _destPortRTCP;
|
| + // Don't bind to a specific IP address.
|
| + if (!IpV6Enabled()) {
|
| + strncpy(_localIP, "0.0.0.0", 16);
|
| + } else {
|
| + strncpy(_localIP, "0000:0000:0000:0000:0000:0000:0000:0000",
|
| + kIpAddressVersion6Length);
|
| + }
|
| + _localPortRTCP = _destPortRTCP;
|
|
|
| - ErrorCode retVal = BindLocalRTCPSocket();
|
| - if(retVal != kNoSocketError)
|
| - {
|
| - _lastError = retVal;
|
| - WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| - "SendRtcp() failed to bind RTCP socket");
|
| - CloseReceiveSockets();
|
| - return false;
|
| - }
|
| + ErrorCode retVal = BindLocalRTCPSocket();
|
| + if (retVal != kNoSocketError) {
|
| + _lastError = retVal;
|
| + WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
| + "SendRtcp() failed to bind RTCP socket");
|
| + CloseReceiveSockets();
|
| + return false;
|
| + }
|
| }
|
|
|
| if(_ptrSendRtcpSocket)
|
| @@ -2285,12 +2240,12 @@ void UdpTransportImpl::CloseReceiveSockets()
|
| if(_ptrRtpSocket)
|
| {
|
| _ptrRtpSocket->CloseBlocking();
|
| - _ptrRtpSocket = NULL;
|
| + _ptrRtpSocket = nullptr;
|
| }
|
| if(_ptrRtcpSocket)
|
| {
|
| _ptrRtcpSocket->CloseBlocking();
|
| - _ptrRtcpSocket = NULL;
|
| + _ptrRtcpSocket = nullptr;
|
| }
|
| _receiving = false;
|
| }
|
| @@ -2381,69 +2336,59 @@ int32_t UdpTransport::LocalHostAddressIPV6(char n_localIP[16])
|
| {
|
|
|
| #if defined(_WIN32)
|
| - struct addrinfo *result = NULL;
|
| - struct addrinfo *ptr = NULL;
|
| - struct addrinfo hints;
|
| + struct addrinfo* result = nullptr;
|
| + struct addrinfo* ptr = nullptr;
|
| + struct addrinfo hints;
|
|
|
| - ZeroMemory(&hints, sizeof(hints));
|
| - hints.ai_family = AF_INET6;
|
| + ZeroMemory(&hints, sizeof(hints));
|
| + hints.ai_family = AF_INET6;
|
|
|
| - char szHostName[256] = "";
|
| - if(::gethostname(szHostName, sizeof(szHostName) - 1))
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceTransport, -1, "gethostname failed");
|
| - return -1;
|
| + char szHostName[256] = "";
|
| + if (::gethostname(szHostName, sizeof(szHostName) - 1)) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceTransport, -1, "gethostname failed");
|
| + return -1;
|
| }
|
|
|
| - DWORD dwRetval = getaddrinfo(szHostName, NULL, &hints, &result);
|
| + DWORD dwRetval = getaddrinfo(szHostName, nullptr, &hints, &result);
|
| if ( dwRetval != 0 )
|
| {
|
| WEBRTC_TRACE(kTraceWarning, kTraceTransport, -1,
|
| "getaddrinfo failed, error:%d", dwRetval);
|
| return -1;
|
| }
|
| - for(ptr=result; ptr != NULL ;ptr=ptr->ai_next)
|
| - {
|
| - switch (ptr->ai_family)
|
| - {
|
| - case AF_INET6:
|
| - {
|
| - for(int i = 0; i< 16; i++)
|
| - {
|
| - n_localIP[i] = (*(SocketAddress*)ptr->ai_addr).
|
| - _sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u8[i];
|
| - }
|
| - bool islocalIP = true;
|
| -
|
| - for(int n = 0; n< 15; n++)
|
| - {
|
| - if(n_localIP[n] != 0)
|
| - {
|
| - islocalIP = false;
|
| - break;
|
| - }
|
| - }
|
| + for (ptr = result; ptr != nullptr; ptr = ptr->ai_next) {
|
| + switch (ptr->ai_family) {
|
| + case AF_INET6: {
|
| + for (int i = 0; i < 16; i++) {
|
| + n_localIP[i] =
|
| + (*(SocketAddress*)ptr->ai_addr)
|
| + ._sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u8[i];
|
| + }
|
| + bool islocalIP = true;
|
| +
|
| + for (int n = 0; n < 15; n++) {
|
| + if (n_localIP[n] != 0) {
|
| + islocalIP = false;
|
| + break;
|
| + }
|
| + }
|
|
|
| - if(islocalIP && n_localIP[15] != 1)
|
| - {
|
| - islocalIP = false;
|
| - }
|
| + if (islocalIP && n_localIP[15] != 1) {
|
| + islocalIP = false;
|
| + }
|
|
|
| - if(islocalIP && ptr->ai_next)
|
| - {
|
| - continue;
|
| - }
|
| - if(n_localIP[0] == 0xfe &&
|
| - n_localIP[1] == 0x80 && ptr->ai_next)
|
| - {
|
| - continue;
|
| - }
|
| - freeaddrinfo(result);
|
| - }
|
| - return 0;
|
| - default:
|
| - break;
|
| - };
|
| + if (islocalIP && ptr->ai_next) {
|
| + continue;
|
| + }
|
| + if (n_localIP[0] == 0xfe && n_localIP[1] == 0x80 && ptr->ai_next) {
|
| + continue;
|
| + }
|
| + freeaddrinfo(result);
|
| + }
|
| + return 0;
|
| + default:
|
| + break;
|
| + };
|
| }
|
| freeaddrinfo(result);
|
| WEBRTC_TRACE(kTraceWarning, kTraceTransport, -1,
|
| @@ -2451,29 +2396,26 @@ int32_t UdpTransport::LocalHostAddressIPV6(char n_localIP[16])
|
| return -1;
|
|
|
| #elif defined(WEBRTC_MAC)
|
| - struct ifaddrs* ptrIfAddrs = NULL;
|
| - struct ifaddrs* ptrIfAddrsStart = NULL;
|
| -
|
| - getifaddrs(&ptrIfAddrsStart);
|
| - ptrIfAddrs = ptrIfAddrsStart;
|
| - while(ptrIfAddrs)
|
| - {
|
| - if(ptrIfAddrs->ifa_addr->sa_family == AF_INET6)
|
| - {
|
| - const struct sockaddr_in6* sock_in6 =
|
| - reinterpret_cast<struct sockaddr_in6*>(ptrIfAddrs->ifa_addr);
|
| - const struct in6_addr* sin6_addr = &sock_in6->sin6_addr;
|
| -
|
| - if (IN6_IS_ADDR_LOOPBACK(sin6_addr) ||
|
| - IN6_IS_ADDR_LINKLOCAL(sin6_addr)) {
|
| - ptrIfAddrs = ptrIfAddrs->ifa_next;
|
| - continue;
|
| - }
|
| - memcpy(n_localIP, sin6_addr->s6_addr, sizeof(sin6_addr->s6_addr));
|
| - freeifaddrs(ptrIfAddrsStart);
|
| - return 0;
|
| - }
|
| + struct ifaddrs* ptrIfAddrs = nullptr;
|
| + struct ifaddrs* ptrIfAddrsStart = nullptr;
|
| +
|
| + getifaddrs(&ptrIfAddrsStart);
|
| + ptrIfAddrs = ptrIfAddrsStart;
|
| + while (ptrIfAddrs) {
|
| + if (ptrIfAddrs->ifa_addr->sa_family == AF_INET6) {
|
| + const struct sockaddr_in6* sock_in6 =
|
| + reinterpret_cast<struct sockaddr_in6*>(ptrIfAddrs->ifa_addr);
|
| + const struct in6_addr* sin6_addr = &sock_in6->sin6_addr;
|
| +
|
| + if (IN6_IS_ADDR_LOOPBACK(sin6_addr) || IN6_IS_ADDR_LINKLOCAL(sin6_addr)) {
|
| ptrIfAddrs = ptrIfAddrs->ifa_next;
|
| + continue;
|
| + }
|
| + memcpy(n_localIP, sin6_addr->s6_addr, sizeof(sin6_addr->s6_addr));
|
| + freeifaddrs(ptrIfAddrsStart);
|
| + return 0;
|
| + }
|
| + ptrIfAddrs = ptrIfAddrs->ifa_next;
|
| }
|
| freeifaddrs(ptrIfAddrsStart);
|
| return -1;
|
| @@ -2486,7 +2428,7 @@ int32_t UdpTransport::LocalHostAddressIPV6(char n_localIP[16])
|
| struct ifaddrmsg r;
|
| } req;
|
|
|
| - struct rtattr* rta = NULL;
|
| + struct rtattr* rta = nullptr;
|
| int status;
|
| char buf[16384]; // = 16 * 1024 (16 kB)
|
| struct nlmsghdr* nlmp;
|
| @@ -2675,13 +2617,13 @@ int32_t UdpTransport::LocalHostAddress(uint32_t& localIP)
|
| return -1;
|
| }
|
| ifc.ifc_len = IFRSIZE;
|
| - ifc.ifc_req = NULL;
|
| + ifc.ifc_req = nullptr;
|
| do
|
| {
|
| ++size;
|
| // Buffer size needed is unknown. Try increasing it until no overflow
|
| // occurs.
|
| - if (NULL == (ifc.ifc_req = (ifreq*)realloc(ifc.ifc_req, IFRSIZE))) {
|
| + if (nullptr == (ifc.ifc_req = (ifreq*)realloc(ifc.ifc_req, IFRSIZE))) {
|
| fprintf(stderr, "Out of memory.\n");
|
| exit(EXIT_FAILURE);
|
| }
|
| @@ -2732,11 +2674,8 @@ int32_t UdpTransport::IPAddress(const SocketAddress& address,
|
| {
|
| #if defined(_WIN32)
|
| DWORD dwIPSize = ipSize;
|
| - int32_t returnvalue = WSAAddressToStringA((LPSOCKADDR)(&address),
|
| - sizeof(SocketAddress),
|
| - NULL,
|
| - ip,
|
| - &dwIPSize);
|
| + int32_t returnvalue = WSAAddressToStringA(
|
| + (LPSOCKADDR)(&address), sizeof(SocketAddress), nullptr, ip, &dwIPSize);
|
| if(returnvalue == -1)
|
| {
|
| return -1;
|
| @@ -2747,9 +2686,8 @@ int32_t UdpTransport::IPAddress(const SocketAddress& address,
|
| {
|
| // Parse IP assuming format "a.b.c.d:port".
|
| char* ipEnd = strchr(ip,':');
|
| - if(ipEnd != NULL)
|
| - {
|
| - *ipEnd = '\0';
|
| + if (ipEnd != nullptr) {
|
| + *ipEnd = '\0';
|
| }
|
| ipSize = (int32_t)strlen(ip);
|
| if(ipSize == 0)
|
| @@ -2762,8 +2700,7 @@ int32_t UdpTransport::IPAddress(const SocketAddress& address,
|
| {
|
| // Parse IP assuming format "[address]:port".
|
| char* ipEnd = strchr(ip,']');
|
| - if(ipEnd != NULL)
|
| - {
|
| + if (ipEnd != nullptr) {
|
| // Calculate length
|
| int32_t adrSize = int32_t(ipEnd - ip) - 1;
|
| memmove(ip, &ip[1], adrSize); // Remove '['
|
| @@ -2783,7 +2720,7 @@ int32_t UdpTransport::IPAddress(const SocketAddress& address,
|
|
|
| #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
| int32_t ipFamily = address._sockaddr_storage.sin_family;
|
| - const void* ptrNumericIP = NULL;
|
| + const void* ptrNumericIP = nullptr;
|
|
|
| if(ipFamily == AF_INET)
|
| {
|
| @@ -2797,9 +2734,8 @@ int32_t UdpTransport::IPAddress(const SocketAddress& address,
|
| {
|
| return -1;
|
| }
|
| - if(inet_ntop(ipFamily, ptrNumericIP, ip, ipSize) == NULL)
|
| - {
|
| - return -1;
|
| + if (inet_ntop(ipFamily, ptrNumericIP, ip, ipSize) == nullptr) {
|
| + return -1;
|
| }
|
| uint16_t source_port;
|
| if(ipFamily == AF_INET)
|
|
|