173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton// Copyright (c) 2012 The Chromium Authors. All rights reserved. 273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton// Use of this source code is governed by a BSD-style license that can be 373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton// found in the LICENSE file. 473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#ifndef NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ 673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#define NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ 773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#include "base/basictypes.h" 973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#include "net/base/ip_endpoint.h" 1073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#include "net/quic/quic_connection_stats.h" 1173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#include "net/quic/quic_protocol.h" 1273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 1373844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonnamespace net { 1473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 1573844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonstruct QuicAckFrame; 1673844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonstruct QuicPacketHeader; 1773844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicAlarm; 1873844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicConnection; 1973844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicConnectionHelperInterface; 2073844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicConnectionVisitorInterface; 2173844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicEncryptedPacket; 2273844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicFecGroup; 2373844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicFramer; 2473844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicPacketCreator; 2573844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicPacketGenerator; 2673844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicPacketWriter; 2773844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicReceivedPacketManager; 2873844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicSentPacketManager; 2973844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass ReceiveAlgorithmInterface; 3073844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass SendAlgorithmInterface; 3173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 3273844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonnamespace test { 3373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 3473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton// Peer to make public a number of otherwise private QuicConnection methods. 3573844aa19a7360b662e2be710fc3c969d6c86606Greg Claytonclass QuicConnectionPeer { 3673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton public: 3773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SendAck(QuicConnection* connection); 3873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 3973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetReceiveAlgorithm(QuicConnection* connection, 4073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton ReceiveAlgorithmInterface* receive_algorithm); 4173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 4273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetSendAlgorithm(QuicConnection* connection, 4373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton SendAlgorithmInterface* send_algorithm); 4473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 4573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAckFrame* CreateAckFrame(QuicConnection* connection); 4673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 4773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicStopWaitingFrame* CreateStopWaitingFrame( 4873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection); 4973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 5073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicConnectionVisitorInterface* GetVisitor( 5173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection); 5273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 5373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicPacketCreator* GetPacketCreator(QuicConnection* connection); 5473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 5573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicPacketGenerator* GetPacketGenerator(QuicConnection* connection); 5673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 5773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicSentPacketManager* GetSentPacketManager( 5873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection); 5973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 6073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicReceivedPacketManager* GetReceivedPacketManager( 6173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection); 6273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 6373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicTime::Delta GetNetworkTimeout(QuicConnection* connection); 6473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 6573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static bool IsSavedForRetransmission( 6673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection, 6773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicPacketSequenceNumber sequence_number); 6873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 6973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static bool IsRetransmission(QuicConnection* connection, 7073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicPacketSequenceNumber sequence_number); 7173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 7273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicPacketEntropyHash GetSentEntropyHash( 7373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection, 7473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicPacketSequenceNumber sequence_number); 7573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 7673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicPacketEntropyHash PacketEntropy( 7773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection, 7873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicPacketSequenceNumber sequence_number); 7973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 8073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicPacketEntropyHash ReceivedEntropyHash( 8173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection, 8273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicPacketSequenceNumber sequence_number); 8373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 8473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static bool IsServer(QuicConnection* connection); 8573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 8673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetIsServer(QuicConnection* connection, bool is_server); 8773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 8873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetSelfAddress(QuicConnection* connection, 8973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton const IPEndPoint& self_address); 9073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 9173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetPeerAddress(QuicConnection* connection, 9273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton const IPEndPoint& peer_address); 9373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 9473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SwapCrypters(QuicConnection* connection, QuicFramer* framer); 9573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 9673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicConnectionHelperInterface* GetHelper(QuicConnection* connection); 9773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 9873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicFramer* GetFramer(QuicConnection* connection); 9973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 10073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton // Set last_header_->fec_group = fec_group and return connection->GetFecGroup 10173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicFecGroup* GetFecGroup(QuicConnection* connection, int fec_group); 10273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 10373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAlarm* GetAckAlarm(QuicConnection* connection); 10473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAlarm* GetPingAlarm(QuicConnection* connection); 10573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAlarm* GetResumeWritesAlarm(QuicConnection* connection); 10673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAlarm* GetRetransmissionAlarm(QuicConnection* connection); 10773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAlarm* GetSendAlarm(QuicConnection* connection); 10873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicAlarm* GetTimeoutAlarm(QuicConnection* connection); 10973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 11073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicPacketWriter* GetWriter(QuicConnection* connection); 11173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton // If |owns_writer| is true, takes ownership of |writer|. 11273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetWriter(QuicConnection* connection, 11373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicPacketWriter* writer, 11473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton bool owns_writer); 11573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void CloseConnection(QuicConnection* connection); 11673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static QuicEncryptedPacket* GetConnectionClosePacket( 11773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicConnection* connection); 11873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 11973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton static void SetSupportedVersions(QuicConnection* connection, 12073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton QuicVersionVector versions); 12173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 12273844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton private: 12373844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton DISALLOW_COPY_AND_ASSIGN(QuicConnectionPeer); 12473844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton}; 12573844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 12673844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton} // namespace test 12773844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 12873844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton} // namespace net 12973844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton 13073844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton#endif // NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ 13173844aa19a7360b662e2be710fc3c969d6c86606Greg Clayton