Index: webrtc/base/natsocketfactory.cc |
diff --git a/webrtc/base/natsocketfactory.cc b/webrtc/base/natsocketfactory.cc |
index a92498429c24e5e221069454dc728d95ac263dfb..37586fe3c987085db9c5b7d880f18f8dd5cec99b 100644 |
--- a/webrtc/base/natsocketfactory.cc |
+++ b/webrtc/base/natsocketfactory.cc |
@@ -11,6 +11,7 @@ |
#include "webrtc/base/natsocketfactory.h" |
#include "webrtc/base/arraysize.h" |
+#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/base/natserver.h" |
#include "webrtc/base/virtualsocketserver.h" |
@@ -29,12 +30,12 @@ size_t PackAddressForNAT(char* buf, size_t buf_size, |
// Writes the port. |
*(reinterpret_cast<uint16_t*>(&buf[2])) = HostToNetwork16(remote_addr.port()); |
if (family == AF_INET) { |
- ASSERT(buf_size >= kNATEncodedIPv4AddressSize); |
+ RTC_DCHECK(buf_size >= kNATEncodedIPv4AddressSize); |
in_addr v4addr = ip.ipv4_address(); |
memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4); |
return kNATEncodedIPv4AddressSize; |
} else if (family == AF_INET6) { |
- ASSERT(buf_size >= kNATEncodedIPv6AddressSize); |
+ RTC_DCHECK(buf_size >= kNATEncodedIPv6AddressSize); |
in6_addr v6addr = ip.ipv6_address(); |
memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4); |
return kNATEncodedIPv6AddressSize; |
@@ -47,8 +48,8 @@ size_t PackAddressForNAT(char* buf, size_t buf_size, |
// data where the original packet starts). |
size_t UnpackAddressFromNAT(const char* buf, size_t buf_size, |
SocketAddress* remote_addr) { |
- ASSERT(buf_size >= 8); |
- ASSERT(buf[0] == 0); |
+ RTC_DCHECK(buf_size >= 8); |
+ RTC_DCHECK(buf[0] == 0); |
int family = buf[1]; |
uint16_t port = |
NetworkToHost16(*(reinterpret_cast<const uint16_t*>(&buf[2]))); |
@@ -57,7 +58,7 @@ size_t UnpackAddressFromNAT(const char* buf, size_t buf_size, |
*remote_addr = SocketAddress(IPAddress(*v4addr), port); |
return kNATEncodedIPv4AddressSize; |
} else if (family == AF_INET6) { |
- ASSERT(buf_size >= 20); |
+ RTC_DCHECK(buf_size >= 20); |
const in6_addr* v6addr = reinterpret_cast<const in6_addr*>(&buf[4]); |
*remote_addr = SocketAddress(IPAddress(*v6addr), port); |
return kNATEncodedIPv6AddressSize; |
@@ -129,14 +130,14 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { |
} |
int Send(const void* data, size_t size) override { |
- ASSERT(connected_); |
+ RTC_DCHECK(connected_); |
return SendTo(data, size, remote_addr_); |
} |
int SendTo(const void* data, |
size_t size, |
const SocketAddress& addr) override { |
- ASSERT(!connected_ || addr == remote_addr_); |
+ RTC_DCHECK(!connected_ || addr == remote_addr_); |
if (server_addr_.IsNil() || type_ == SOCK_STREAM) { |
return socket_->SendTo(data, size, addr); |
} |
@@ -149,7 +150,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { |
memcpy(buf.get() + addrlength, data, size); |
int result = socket_->SendTo(buf.get(), encoded_size, server_addr_); |
if (result >= 0) { |
- ASSERT(result == static_cast<int>(encoded_size)); |
+ RTC_DCHECK(result == static_cast<int>(encoded_size)); |
result = result - static_cast<int>(addrlength); |
} |
return result; |
@@ -175,12 +176,12 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { |
// Read the packet from the socket. |
int result = socket_->RecvFrom(buf_, size_, &remote_addr, timestamp); |
if (result >= 0) { |
- ASSERT(remote_addr == server_addr_); |
+ RTC_DCHECK(remote_addr == server_addr_); |
// TODO: we need better framing so we know how many bytes we can |
// return before we need to read the next address. For UDP, this will be |
// fine as long as the reader always reads everything in the packet. |
- ASSERT((size_t)result < size_); |
+ RTC_DCHECK((size_t)result < size_); |
// Decode the wire packet into the actual results. |
SocketAddress real_remote_addr; |
@@ -235,7 +236,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { |
void OnConnectEvent(AsyncSocket* socket) { |
// If we're NATed, we need to send a message with the real addr to use. |
- ASSERT(socket == socket_); |
+ RTC_DCHECK(socket == socket_); |
if (server_addr_.IsNil()) { |
connected_ = true; |
SignalConnectEvent(this); |
@@ -245,7 +246,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { |
} |
void OnReadEvent(AsyncSocket* socket) { |
// If we're NATed, we need to process the connect reply. |
- ASSERT(socket == socket_); |
+ RTC_DCHECK(socket == socket_); |
if (type_ == SOCK_STREAM && !server_addr_.IsNil() && !connected_) { |
HandleConnectReply(); |
} else { |
@@ -253,11 +254,11 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { |
} |
} |
void OnWriteEvent(AsyncSocket* socket) { |
- ASSERT(socket == socket_); |
+ RTC_DCHECK(socket == socket_); |
SignalWriteEvent(this); |
} |
void OnCloseEvent(AsyncSocket* socket, int error) { |
- ASSERT(socket == socket_); |
+ RTC_DCHECK(socket == socket_); |
SignalCloseEvent(this, error); |
} |