| 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 |
| 11 #include <memory> |
| 12 |
| 11 #include "webrtc/base/natsocketfactory.h" | 13 #include "webrtc/base/natsocketfactory.h" |
| 12 #include "webrtc/base/natserver.h" | 14 #include "webrtc/base/natserver.h" |
| 13 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/base/socketadapters.h" | 16 #include "webrtc/base/socketadapters.h" |
| 15 | 17 |
| 16 namespace rtc { | 18 namespace rtc { |
| 17 | 19 |
| 18 RouteCmp::RouteCmp(NAT* nat) : symmetric(nat->IsSymmetric()) { | 20 RouteCmp::RouteCmp(NAT* nat) : symmetric(nat->IsSymmetric()) { |
| 19 } | 21 } |
| 20 | 22 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 190 |
| 189 // Allow the NAT to reject this packet. | 191 // Allow the NAT to reject this packet. |
| 190 if (ShouldFilterOut(iter->second, remote_addr)) { | 192 if (ShouldFilterOut(iter->second, remote_addr)) { |
| 191 LOG(LS_INFO) << "Packet from " << remote_addr.ToSensitiveString() | 193 LOG(LS_INFO) << "Packet from " << remote_addr.ToSensitiveString() |
| 192 << " was filtered out by the NAT."; | 194 << " was filtered out by the NAT."; |
| 193 return; | 195 return; |
| 194 } | 196 } |
| 195 | 197 |
| 196 // Forward this packet to the internal address. | 198 // Forward this packet to the internal address. |
| 197 // First prepend the address in a quasi-STUN format. | 199 // First prepend the address in a quasi-STUN format. |
| 198 scoped_ptr<char[]> real_buf(new char[size + kNATEncodedIPv6AddressSize]); | 200 std::unique_ptr<char[]> real_buf(new char[size + kNATEncodedIPv6AddressSize]); |
| 199 size_t addrlength = PackAddressForNAT(real_buf.get(), | 201 size_t addrlength = PackAddressForNAT(real_buf.get(), |
| 200 size + kNATEncodedIPv6AddressSize, | 202 size + kNATEncodedIPv6AddressSize, |
| 201 remote_addr); | 203 remote_addr); |
| 202 // Copy the data part after the address. | 204 // Copy the data part after the address. |
| 203 rtc::PacketOptions options; | 205 rtc::PacketOptions options; |
| 204 memcpy(real_buf.get() + addrlength, buf, size); | 206 memcpy(real_buf.get() + addrlength, buf, size); |
| 205 udp_server_socket_->SendTo(real_buf.get(), size + addrlength, | 207 udp_server_socket_->SendTo(real_buf.get(), size + addrlength, |
| 206 iter->second->route.source(), options); | 208 iter->second->route.source(), options); |
| 207 } | 209 } |
| 208 | 210 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 CritScope cs(&crit_); | 242 CritScope cs(&crit_); |
| 241 whitelist->insert(addr); | 243 whitelist->insert(addr); |
| 242 } | 244 } |
| 243 | 245 |
| 244 bool NATServer::TransEntry::WhitelistContains(const SocketAddress& ext_addr) { | 246 bool NATServer::TransEntry::WhitelistContains(const SocketAddress& ext_addr) { |
| 245 CritScope cs(&crit_); | 247 CritScope cs(&crit_); |
| 246 return whitelist->find(ext_addr) == whitelist->end(); | 248 return whitelist->find(ext_addr) == whitelist->end(); |
| 247 } | 249 } |
| 248 | 250 |
| 249 } // namespace rtc | 251 } // namespace rtc |
| OLD | NEW |