| 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 #ifndef NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_ | 5 #ifndef NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_ |
| 6 #define NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_ | 6 #define NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "net/quic/crypto/crypto_handshake.h" | 10 #include "net/quic/crypto/crypto_handshake.h" |
| 11 #include "net/quic/crypto/quic_crypto_server_config.h" | 11 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 12 #include "net/quic/quic_config.h" | 12 #include "net/quic/quic_config.h" |
| 13 #include "net/quic/quic_crypto_stream.h" | 13 #include "net/quic/quic_crypto_stream.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class CryptoHandshakeMessage; | 17 class CryptoHandshakeMessage; |
| 18 class QuicCryptoServerConfig; | 18 class QuicCryptoServerConfig; |
| 19 class QuicCryptoServerStream; |
| 19 class QuicSession; | 20 class QuicSession; |
| 20 | 21 |
| 21 namespace test { | 22 namespace test { |
| 22 class CryptoTestUtils; | 23 class CryptoTestUtils; |
| 23 } // namespace test | 24 } // namespace test |
| 24 | 25 |
| 26 // Receives a notification when the server hello (SHLO) has been ACKed by the |
| 27 // peer. At this point we disable HANDSHAKE_MODE in the sent packet manager. |
| 28 class NET_EXPORT_PRIVATE ServerHelloNotifier : public |
| 29 QuicAckNotifier::DelegateInterface { |
| 30 public: |
| 31 explicit ServerHelloNotifier(QuicCryptoServerStream* stream) |
| 32 : server_stream_(stream) {} |
| 33 |
| 34 // QuicAckNotifier::DelegateInterface implementation |
| 35 virtual void OnAckNotification( |
| 36 int num_original_packets, |
| 37 int num_original_bytes, |
| 38 int num_retransmitted_packets, |
| 39 int num_retransmitted_bytes, |
| 40 QuicTime::Delta delta_largest_observed) OVERRIDE; |
| 41 |
| 42 private: |
| 43 virtual ~ServerHelloNotifier() {} |
| 44 |
| 45 QuicCryptoServerStream* server_stream_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(ServerHelloNotifier); |
| 48 }; |
| 49 |
| 25 class NET_EXPORT_PRIVATE QuicCryptoServerStream : public QuicCryptoStream { | 50 class NET_EXPORT_PRIVATE QuicCryptoServerStream : public QuicCryptoStream { |
| 26 public: | 51 public: |
| 27 QuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config, | 52 QuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config, |
| 28 QuicSession* session); | 53 QuicSession* session); |
| 29 explicit QuicCryptoServerStream(QuicSession* session); | 54 explicit QuicCryptoServerStream(QuicSession* session); |
| 30 virtual ~QuicCryptoServerStream(); | 55 virtual ~QuicCryptoServerStream(); |
| 31 | 56 |
| 32 // Cancel any outstanding callbacks, such as asynchronous validation of client | 57 // Cancel any outstanding callbacks, such as asynchronous validation of client |
| 33 // hello. | 58 // hello. |
| 34 void CancelOutstandingCallbacks(); | 59 void CancelOutstandingCallbacks(); |
| 35 | 60 |
| 36 // CryptoFramerVisitorInterface implementation | 61 // CryptoFramerVisitorInterface implementation |
| 37 virtual void OnHandshakeMessage( | 62 virtual void OnHandshakeMessage( |
| 38 const CryptoHandshakeMessage& message) OVERRIDE; | 63 const CryptoHandshakeMessage& message) OVERRIDE; |
| 39 | 64 |
| 40 // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded, | 65 // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded, |
| 41 // SHA-256 hash of the client's ChannelID key and returns true, if the client | 66 // SHA-256 hash of the client's ChannelID key and returns true, if the client |
| 42 // presented a ChannelID. Otherwise it returns false. | 67 // presented a ChannelID. Otherwise it returns false. |
| 43 bool GetBase64SHA256ClientChannelID(std::string* output) const; | 68 bool GetBase64SHA256ClientChannelID(std::string* output) const; |
| 44 | 69 |
| 45 uint8 num_handshake_messages() const { return num_handshake_messages_; } | 70 uint8 num_handshake_messages() const { return num_handshake_messages_; } |
| 46 | 71 |
| 72 int num_server_config_update_messages_sent() const { |
| 73 return num_server_config_update_messages_sent_; |
| 74 } |
| 75 |
| 76 // Sends the latest server config and source-address token to the client. |
| 77 void SendServerConfigUpdate(); |
| 78 |
| 79 // Called by the ServerHello AckNotifier once the SHLO has been ACKed by the |
| 80 // client. |
| 81 void OnServerHelloAcked(); |
| 82 |
| 47 protected: | 83 protected: |
| 48 virtual QuicErrorCode ProcessClientHello( | 84 virtual QuicErrorCode ProcessClientHello( |
| 49 const CryptoHandshakeMessage& message, | 85 const CryptoHandshakeMessage& message, |
| 50 const ValidateClientHelloResultCallback::Result& result, | 86 const ValidateClientHelloResultCallback::Result& result, |
| 51 CryptoHandshakeMessage* reply, | 87 CryptoHandshakeMessage* reply, |
| 52 std::string* error_details); | 88 std::string* error_details); |
| 53 | 89 |
| 54 // Hook that allows the server to set QuicConfig defaults just | 90 // Hook that allows the server to set QuicConfig defaults just |
| 55 // before going through the parameter negotiation step. | 91 // before going through the parameter negotiation step. |
| 56 virtual void OverrideQuicConfigDefaults(QuicConfig* config); | 92 virtual void OverrideQuicConfigDefaults(QuicConfig* config); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 83 | 119 |
| 84 // crypto_config_ contains crypto parameters for the handshake. | 120 // crypto_config_ contains crypto parameters for the handshake. |
| 85 const QuicCryptoServerConfig& crypto_config_; | 121 const QuicCryptoServerConfig& crypto_config_; |
| 86 | 122 |
| 87 // Pointer to the active callback that will receive the result of | 123 // Pointer to the active callback that will receive the result of |
| 88 // the client hello validation request and forward it to | 124 // the client hello validation request and forward it to |
| 89 // FinishProcessingHandshakeMessage for processing. NULL if no | 125 // FinishProcessingHandshakeMessage for processing. NULL if no |
| 90 // handshake message is being validated. | 126 // handshake message is being validated. |
| 91 ValidateCallback* validate_client_hello_cb_; | 127 ValidateCallback* validate_client_hello_cb_; |
| 92 | 128 |
| 129 // Number of handshake messages received by this stream. |
| 93 uint8 num_handshake_messages_; | 130 uint8 num_handshake_messages_; |
| 94 | 131 |
| 132 // Number of server config update (SCUP) messages sent by this stream. |
| 133 int num_server_config_update_messages_sent_; |
| 134 |
| 95 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerStream); | 135 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerStream); |
| 96 }; | 136 }; |
| 97 | 137 |
| 98 } // namespace net | 138 } // namespace net |
| 99 | 139 |
| 100 #endif // NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_ | 140 #endif // NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_ |
| OLD | NEW |