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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 session_->AddAllocatedPort(port, this, true); | 1065 session_->AddAllocatedPort(port, this, true); |
1066 } | 1066 } |
1067 } | 1067 } |
1068 | 1068 |
1069 void AllocationSequence::OnReadPacket( | 1069 void AllocationSequence::OnReadPacket( |
1070 rtc::AsyncPacketSocket* socket, const char* data, size_t size, | 1070 rtc::AsyncPacketSocket* socket, const char* data, size_t size, |
1071 const rtc::SocketAddress& remote_addr, | 1071 const rtc::SocketAddress& remote_addr, |
1072 const rtc::PacketTime& packet_time) { | 1072 const rtc::PacketTime& packet_time) { |
1073 ASSERT(socket == udp_socket_.get()); | 1073 ASSERT(socket == udp_socket_.get()); |
1074 | 1074 |
1075 bool turn_port_found = false; | |
1076 | 1075 |
1077 // Try to find the TurnPort that matches the remote address. Note that the | 1076 // Try to find the TurnPort that matches the remote address. Note that the |
1078 // message could be a STUN binding response if the TURN server is also used as | 1077 // message could be a STUN binding response if the TURN server is also used as |
1079 // a STUN server. We don't want to parse every message here to check if it is | 1078 // a STUN server. We don't want to parse every message here to check if it is |
1080 // a STUN binding response, so we pass the message to TurnPort regardless of | 1079 // a STUN binding response, so we pass the message to TurnPort regardless of |
1081 // the message type. The TurnPort will just ignore the message since it will | 1080 // the message type. The TurnPort will just ignore the message since it will |
1082 // not find any request by transaction ID. | 1081 // not find any request by transaction ID. |
1083 for (std::vector<TurnPort*>::const_iterator it = turn_ports_.begin(); | 1082 for (TurnPort* port : turn_ports_) { |
1084 it != turn_ports_.end(); ++it) { | |
1085 TurnPort* port = *it; | |
1086 if (port->server_address().address == remote_addr) { | 1083 if (port->server_address().address == remote_addr) { |
1087 port->HandleIncomingPacket(socket, data, size, remote_addr, packet_time); | 1084 if (port->HandleIncomingPacket(socket, data, size, remote_addr, |
1088 turn_port_found = true; | 1085 packet_time)) { |
1089 break; | 1086 return; |
1087 } | |
1090 } | 1088 } |
1091 } | 1089 } |
1092 | 1090 |
1093 if (udp_port_) { | 1091 if (udp_port_) { |
1094 const ServerAddresses& stun_servers = udp_port_->server_addresses(); | 1092 const ServerAddresses& stun_servers = udp_port_->server_addresses(); |
1095 | 1093 |
1096 // Pass the packet to the UdpPort if there is no matching TurnPort, or if | 1094 // Pass the packet to the UdpPort if there is no matching TurnPort, or if |
1097 // the TURN server is also a STUN server. | 1095 // the TURN server is also a STUN server. |
1098 if (!turn_port_found || | 1096 if (stun_servers.find(remote_addr) != stun_servers.end()) { |
honghaiz3
2016/04/22 01:49:03
I think this is incorrect.
In the current code, a
honghaiz3
2016/04/22 03:52:33
One possible approach is to use the existing logic
Sergey Ulanov
2016/04/22 18:05:52
Implemented this suggestion in Patch Set 4.
I'm no
honghaiz3
2016/04/22 19:17:27
I think patch set 4 is slightly safer.
Although p
| |
1099 stun_servers.find(remote_addr) != stun_servers.end()) { | 1097 RTC_DCHECK(udp_port_->SharedSocket()); |
1100 udp_port_->HandleIncomingPacket( | 1098 udp_port_->HandleIncomingPacket(socket, data, size, remote_addr, |
1101 socket, data, size, remote_addr, packet_time); | 1099 packet_time); |
1102 } | 1100 } |
1103 } | 1101 } |
1104 } | 1102 } |
1105 | 1103 |
1106 void AllocationSequence::OnPortDestroyed(PortInterface* port) { | 1104 void AllocationSequence::OnPortDestroyed(PortInterface* port) { |
1107 if (udp_port_ == port) { | 1105 if (udp_port_ == port) { |
1108 udp_port_ = NULL; | 1106 udp_port_ = NULL; |
1109 return; | 1107 return; |
1110 } | 1108 } |
1111 | 1109 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 ServerAddresses servers; | 1182 ServerAddresses servers; |
1185 for (size_t i = 0; i < relays.size(); ++i) { | 1183 for (size_t i = 0; i < relays.size(); ++i) { |
1186 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1184 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1187 servers.insert(relays[i].ports.front().address); | 1185 servers.insert(relays[i].ports.front().address); |
1188 } | 1186 } |
1189 } | 1187 } |
1190 return servers; | 1188 return servers; |
1191 } | 1189 } |
1192 | 1190 |
1193 } // namespace cricket | 1191 } // namespace cricket |
OLD | NEW |