Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
| 6 | 6 |
| 7 #include "content/common/p2p_messages.h" | 7 #include "content/common/p2p_messages.h" |
| 8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 DidCompleteRead(result); | 131 DidCompleteRead(result); |
| 132 if (state_ == STATE_OPEN) { | 132 if (state_ == STATE_OPEN) { |
| 133 DoRead(); | 133 DoRead(); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 void P2PSocketHostTcp::OnPacket(std::vector<char>& data) { | 137 void P2PSocketHostTcp::OnPacket(std::vector<char>& data) { |
| 138 if (!authorized_) { | 138 if (!authorized_) { |
| 139 P2PSocketHost::StunMessageType type; | 139 P2PSocketHost::StunMessageType type; |
| 140 bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); | 140 bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); |
| 141 if (stun && (type == STUN_BINDING_REQUEST || | 141 if (stun && IsRequestOrResponse(type)) { |
|
Wez
2011/08/09 18:09:23
How does receipt of a binding/allocate request/res
Sergey Ulanov
2011/08/09 18:15:41
By sending/receiving the stun request or response
Wez
2011/08/09 18:30:57
The only effect that |authorized_| seems to have i
Sergey Ulanov
2011/08/09 19:18:26
We do block incoming data packets before stun requ
Wez
2011/08/09 19:54:50
Sorry; forgot about the |!authorized_| surrounding
Sergey Ulanov
2011/08/09 21:06:56
Ok, connected sounds good. I will rename it in a s
| |
| 142 type == STUN_BINDING_RESPONSE)) { | |
| 143 authorized_ = true; | 142 authorized_ = true; |
| 144 } else if (!stun || type == STUN_DATA_INDICATION) { | 143 } else if (!stun || type == STUN_DATA_INDICATION) { |
| 145 LOG(ERROR) << "Received unexpected data packet from " | 144 LOG(ERROR) << "Received unexpected data packet from " |
| 146 << remote_address_.ToString() | 145 << remote_address_.ToString() |
| 147 << " before STUN binding is finished. " | 146 << " before STUN binding is finished. " |
| 148 << "Terminating connection."; | 147 << "Terminating connection."; |
| 149 OnError(); | 148 OnError(); |
| 150 return; | 149 return; |
| 151 } | 150 } |
| 152 } | 151 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 DoWrite(); | 264 DoWrite(); |
| 266 } | 265 } |
| 267 } | 266 } |
| 268 | 267 |
| 269 P2PSocketHost* P2PSocketHostTcp::AcceptIncomingTcpConnection( | 268 P2PSocketHost* P2PSocketHostTcp::AcceptIncomingTcpConnection( |
| 270 const net::IPEndPoint& remote_address, int id) { | 269 const net::IPEndPoint& remote_address, int id) { |
| 271 NOTREACHED(); | 270 NOTREACHED(); |
| 272 OnError(); | 271 OnError(); |
| 273 return NULL; | 272 return NULL; |
| 274 } | 273 } |
| OLD | NEW |