| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 int SendTo(const void* data, | 136 int SendTo(const void* data, |
| 137 size_t size, | 137 size_t size, |
| 138 const SocketAddress& addr) override { | 138 const SocketAddress& addr) override { |
| 139 ASSERT(!connected_ || addr == remote_addr_); | 139 ASSERT(!connected_ || addr == remote_addr_); |
| 140 if (server_addr_.IsNil() || type_ == SOCK_STREAM) { | 140 if (server_addr_.IsNil() || type_ == SOCK_STREAM) { |
| 141 return socket_->SendTo(data, size, addr); | 141 return socket_->SendTo(data, size, addr); |
| 142 } | 142 } |
| 143 // This array will be too large for IPv4 packets, but only by 12 bytes. | 143 // This array will be too large for IPv4 packets, but only by 12 bytes. |
| 144 scoped_ptr<char[]> buf(new char[size + kNATEncodedIPv6AddressSize]); | 144 std::unique_ptr<char[]> buf(new char[size + kNATEncodedIPv6AddressSize]); |
| 145 size_t addrlength = PackAddressForNAT(buf.get(), | 145 size_t addrlength = PackAddressForNAT(buf.get(), |
| 146 size + kNATEncodedIPv6AddressSize, | 146 size + kNATEncodedIPv6AddressSize, |
| 147 addr); | 147 addr); |
| 148 size_t encoded_size = size + addrlength; | 148 size_t encoded_size = size + addrlength; |
| 149 memcpy(buf.get() + addrlength, data, size); | 149 memcpy(buf.get() + addrlength, data, size); |
| 150 int result = socket_->SendTo(buf.get(), encoded_size, server_addr_); | 150 int result = socket_->SendTo(buf.get(), encoded_size, server_addr_); |
| 151 if (result >= 0) { | 151 if (result >= 0) { |
| 152 ASSERT(result == static_cast<int>(encoded_size)); | 152 ASSERT(result == static_cast<int>(encoded_size)); |
| 153 result = result - static_cast<int>(addrlength); | 153 result = result - static_cast<int>(addrlength); |
| 154 } | 154 } |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 NATSocketServer::Translator* NATSocketServer::TranslatorMap::FindClient( | 494 NATSocketServer::Translator* NATSocketServer::TranslatorMap::FindClient( |
| 495 const SocketAddress& int_ip) { | 495 const SocketAddress& int_ip) { |
| 496 Translator* nat = NULL; | 496 Translator* nat = NULL; |
| 497 for (TranslatorMap::iterator it = begin(); it != end() && !nat; ++it) { | 497 for (TranslatorMap::iterator it = begin(); it != end() && !nat; ++it) { |
| 498 nat = it->second->FindClient(int_ip); | 498 nat = it->second->FindClient(int_ip); |
| 499 } | 499 } |
| 500 return nat; | 500 return nat; |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace rtc | 503 } // namespace rtc |
| OLD | NEW |