OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 encryption_level_(ENCRYPTION_NONE), | 237 encryption_level_(ENCRYPTION_NONE), |
238 has_forward_secure_encrypter_(false), | 238 has_forward_secure_encrypter_(false), |
239 first_required_forward_secure_packet_(0), | 239 first_required_forward_secure_packet_(0), |
240 clock_(helper->GetClock()), | 240 clock_(helper->GetClock()), |
241 random_generator_(helper->GetRandomGenerator()), | 241 random_generator_(helper->GetRandomGenerator()), |
242 connection_id_(connection_id), | 242 connection_id_(connection_id), |
243 peer_address_(address), | 243 peer_address_(address), |
244 migrating_peer_port_(0), | 244 migrating_peer_port_(0), |
245 last_packet_decrypted_(false), | 245 last_packet_decrypted_(false), |
246 last_size_(0), | 246 last_size_(0), |
| 247 current_packet_data_(nullptr), |
247 last_decrypted_packet_level_(ENCRYPTION_NONE), | 248 last_decrypted_packet_level_(ENCRYPTION_NONE), |
248 should_last_packet_instigate_acks_(false), | 249 should_last_packet_instigate_acks_(false), |
249 largest_seen_packet_with_ack_(0), | 250 largest_seen_packet_with_ack_(0), |
250 largest_seen_packet_with_stop_waiting_(0), | 251 largest_seen_packet_with_stop_waiting_(0), |
251 max_undecryptable_packets_(0), | 252 max_undecryptable_packets_(0), |
252 pending_version_negotiation_packet_(false), | 253 pending_version_negotiation_packet_(false), |
253 save_crypto_packets_as_termination_packets_(false), | 254 save_crypto_packets_as_termination_packets_(false), |
254 silent_close_enabled_(false), | 255 silent_close_enabled_(false), |
255 received_packet_manager_(&stats_), | 256 received_packet_manager_(&stats_), |
256 ack_queued_(false), | 257 ack_queued_(false), |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, | 1207 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, |
1207 const IPEndPoint& peer_address, | 1208 const IPEndPoint& peer_address, |
1208 const QuicEncryptedPacket& packet) { | 1209 const QuicEncryptedPacket& packet) { |
1209 if (!connected_) { | 1210 if (!connected_) { |
1210 return; | 1211 return; |
1211 } | 1212 } |
1212 if (debug_visitor_ != nullptr) { | 1213 if (debug_visitor_ != nullptr) { |
1213 debug_visitor_->OnPacketReceived(self_address, peer_address, packet); | 1214 debug_visitor_->OnPacketReceived(self_address, peer_address, packet); |
1214 } | 1215 } |
1215 last_size_ = packet.length(); | 1216 last_size_ = packet.length(); |
| 1217 current_packet_data_ = packet.data(); |
1216 | 1218 |
1217 if (FLAGS_check_peer_address_change_after_decryption) { | 1219 if (FLAGS_check_peer_address_change_after_decryption) { |
1218 last_packet_destination_address_ = self_address; | 1220 last_packet_destination_address_ = self_address; |
1219 last_packet_source_address_ = peer_address; | 1221 last_packet_source_address_ = peer_address; |
1220 if (!IsInitializedIPEndPoint(self_address_)) { | 1222 if (!IsInitializedIPEndPoint(self_address_)) { |
1221 self_address_ = last_packet_destination_address_; | 1223 self_address_ = last_packet_destination_address_; |
1222 } | 1224 } |
1223 if (!IsInitializedIPEndPoint(peer_address_)) { | 1225 if (!IsInitializedIPEndPoint(peer_address_)) { |
1224 peer_address_ = last_packet_source_address_; | 1226 peer_address_ = last_packet_source_address_; |
1225 } | 1227 } |
(...skipping 11 matching lines...) Expand all Loading... |
1237 if (framer_.error() == QUIC_DECRYPTION_FAILURE) { | 1239 if (framer_.error() == QUIC_DECRYPTION_FAILURE) { |
1238 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && | 1240 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && |
1239 undecryptable_packets_.size() < max_undecryptable_packets_) { | 1241 undecryptable_packets_.size() < max_undecryptable_packets_) { |
1240 QueueUndecryptablePacket(packet); | 1242 QueueUndecryptablePacket(packet); |
1241 } else if (debug_visitor_ != nullptr) { | 1243 } else if (debug_visitor_ != nullptr) { |
1242 debug_visitor_->OnUndecryptablePacket(); | 1244 debug_visitor_->OnUndecryptablePacket(); |
1243 } | 1245 } |
1244 } | 1246 } |
1245 DVLOG(1) << ENDPOINT << "Unable to process packet. Last packet processed: " | 1247 DVLOG(1) << ENDPOINT << "Unable to process packet. Last packet processed: " |
1246 << last_header_.packet_number; | 1248 << last_header_.packet_number; |
| 1249 current_packet_data_ = nullptr; |
1247 return; | 1250 return; |
1248 } | 1251 } |
1249 | 1252 |
1250 ++stats_.packets_processed; | 1253 ++stats_.packets_processed; |
1251 MaybeProcessUndecryptablePackets(); | 1254 MaybeProcessUndecryptablePackets(); |
1252 MaybeSendInResponseToPacket(); | 1255 MaybeSendInResponseToPacket(); |
1253 SetPingAlarm(); | 1256 SetPingAlarm(); |
| 1257 current_packet_data_ = nullptr; |
1254 } | 1258 } |
1255 | 1259 |
1256 void QuicConnection::CheckForAddressMigration(const IPEndPoint& self_address, | 1260 void QuicConnection::CheckForAddressMigration(const IPEndPoint& self_address, |
1257 const IPEndPoint& peer_address) { | 1261 const IPEndPoint& peer_address) { |
1258 peer_ip_changed_ = false; | 1262 peer_ip_changed_ = false; |
1259 peer_port_changed_ = false; | 1263 peer_port_changed_ = false; |
1260 self_ip_changed_ = false; | 1264 self_ip_changed_ = false; |
1261 self_port_changed_ = false; | 1265 self_port_changed_ = false; |
1262 | 1266 |
1263 if (peer_address_.address().empty()) { | 1267 if (peer_address_.address().empty()) { |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 | 2337 |
2334 void QuicConnection::OnPathClosed(QuicPathId path_id) { | 2338 void QuicConnection::OnPathClosed(QuicPathId path_id) { |
2335 // Stop receiving packets on this path. | 2339 // Stop receiving packets on this path. |
2336 framer_.OnPathClosed(path_id); | 2340 framer_.OnPathClosed(path_id); |
2337 } | 2341 } |
2338 | 2342 |
2339 bool QuicConnection::ack_frame_updated() const { | 2343 bool QuicConnection::ack_frame_updated() const { |
2340 return received_packet_manager_.ack_frame_updated(); | 2344 return received_packet_manager_.ack_frame_updated(); |
2341 } | 2345 } |
2342 | 2346 |
| 2347 StringPiece QuicConnection::GetCurrentPacket() { |
| 2348 if (current_packet_data_ == nullptr) { |
| 2349 return StringPiece(); |
| 2350 } |
| 2351 return StringPiece(current_packet_data_, last_size_); |
| 2352 } |
| 2353 |
2343 } // namespace net | 2354 } // namespace net |
OLD | NEW |