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 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 // Might be old packets that were sent by the client before the version | 358 // Might be old packets that were sent by the client before the version |
359 // was negotiated. Drop these. | 359 // was negotiated. Drop these. |
360 return false; | 360 return false; |
361 | 361 |
362 default: | 362 default: |
363 DCHECK(false); | 363 DCHECK(false); |
364 } | 364 } |
365 | 365 |
366 version_negotiation_state_ = NEGOTIATED_VERSION; | 366 version_negotiation_state_ = NEGOTIATED_VERSION; |
367 visitor_->OnSuccessfulVersionNegotiation(received_version); | 367 visitor_->OnSuccessfulVersionNegotiation(received_version); |
| 368 if (debug_visitor_.get() != NULL) { |
| 369 debug_visitor_->OnSuccessfulVersionNegotiation(received_version); |
| 370 } |
368 DVLOG(1) << ENDPOINT << "version negotiated " << received_version; | 371 DVLOG(1) << ENDPOINT << "version negotiated " << received_version; |
369 | 372 |
370 // Store the new version. | 373 // Store the new version. |
371 framer_.set_version(received_version); | 374 framer_.set_version(received_version); |
372 | 375 |
373 // TODO(satyamshekhar): Store the sequence number of this packet and close the | 376 // TODO(satyamshekhar): Store the sequence number of this packet and close the |
374 // connection if we ever received a packet with incorrect version and whose | 377 // connection if we ever received a packet with incorrect version and whose |
375 // sequence number is greater. | 378 // sequence number is greater. |
376 return true; | 379 return true; |
377 } | 380 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 << " without version flag before version negotiated."; | 487 << " without version flag before version negotiated."; |
485 // Packets should have the version flag till version negotiation is | 488 // Packets should have the version flag till version negotiation is |
486 // done. | 489 // done. |
487 CloseConnection(QUIC_INVALID_VERSION, false); | 490 CloseConnection(QUIC_INVALID_VERSION, false); |
488 return false; | 491 return false; |
489 } else { | 492 } else { |
490 DCHECK_EQ(1u, header.public_header.versions.size()); | 493 DCHECK_EQ(1u, header.public_header.versions.size()); |
491 DCHECK_EQ(header.public_header.versions[0], version()); | 494 DCHECK_EQ(header.public_header.versions[0], version()); |
492 version_negotiation_state_ = NEGOTIATED_VERSION; | 495 version_negotiation_state_ = NEGOTIATED_VERSION; |
493 visitor_->OnSuccessfulVersionNegotiation(version()); | 496 visitor_->OnSuccessfulVersionNegotiation(version()); |
| 497 if (debug_visitor_.get() != NULL) { |
| 498 debug_visitor_->OnSuccessfulVersionNegotiation(version()); |
| 499 } |
494 } | 500 } |
495 } else { | 501 } else { |
496 DCHECK(!header.public_header.version_flag); | 502 DCHECK(!header.public_header.version_flag); |
497 // If the client gets a packet without the version flag from the server | 503 // If the client gets a packet without the version flag from the server |
498 // it should stop sending version since the version negotiation is done. | 504 // it should stop sending version since the version negotiation is done. |
499 packet_generator_.StopSendingVersion(); | 505 packet_generator_.StopSendingVersion(); |
500 version_negotiation_state_ = NEGOTIATED_VERSION; | 506 version_negotiation_state_ = NEGOTIATED_VERSION; |
501 visitor_->OnSuccessfulVersionNegotiation(version()); | 507 visitor_->OnSuccessfulVersionNegotiation(version()); |
| 508 if (debug_visitor_.get() != NULL) { |
| 509 debug_visitor_->OnSuccessfulVersionNegotiation(version()); |
| 510 } |
502 } | 511 } |
503 } | 512 } |
504 | 513 |
505 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); | 514 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); |
506 | 515 |
507 --stats_.packets_dropped; | 516 --stats_.packets_dropped; |
508 DVLOG(1) << ENDPOINT << "Received packet header: " << header; | 517 DVLOG(1) << ENDPOINT << "Received packet header: " << header; |
509 last_header_ = header; | 518 last_header_ = header; |
510 DCHECK(connected_); | 519 DCHECK(connected_); |
511 return true; | 520 return true; |
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 // If we changed the generator's batch state, restore original batch state. | 2000 // If we changed the generator's batch state, restore original batch state. |
1992 if (!already_in_batch_mode_) { | 2001 if (!already_in_batch_mode_) { |
1993 DVLOG(1) << "Leaving Batch Mode."; | 2002 DVLOG(1) << "Leaving Batch Mode."; |
1994 connection_->packet_generator_.FinishBatchOperations(); | 2003 connection_->packet_generator_.FinishBatchOperations(); |
1995 } | 2004 } |
1996 DCHECK_EQ(already_in_batch_mode_, | 2005 DCHECK_EQ(already_in_batch_mode_, |
1997 connection_->packet_generator_.InBatchMode()); | 2006 connection_->packet_generator_.InBatchMode()); |
1998 } | 2007 } |
1999 | 2008 |
2000 } // namespace net | 2009 } // namespace net |
OLD | NEW |