OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // A toy server, which listens on a specified address for QUIC traffic and | 5 // A toy server, which listens on a specified address for QUIC traffic and |
6 // handles incoming responses. | 6 // handles incoming responses. |
7 | 7 |
8 #ifndef NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ | 8 #ifndef NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ |
9 #define NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ | 9 #define NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 | 27 |
28 class QuicDispatcher; | 28 class QuicDispatcher; |
29 | 29 |
30 namespace test { | 30 namespace test { |
31 class QuicSimpleServerPeer; | 31 class QuicSimpleServerPeer; |
32 } // namespace test | 32 } // namespace test |
33 | 33 |
34 class QuicSimpleServer { | 34 class QuicSimpleServer { |
35 public: | 35 public: |
36 QuicSimpleServer(std::unique_ptr<ProofSource> proof_source, | 36 QuicSimpleServer( |
37 const QuicConfig& config, | 37 std::unique_ptr<ProofSource> proof_source, |
38 const QuicVersionVector& supported_versions); | 38 const QuicConfig& config, |
| 39 const QuicCryptoServerConfig::ConfigOptions& crypto_config_options, |
| 40 const QuicVersionVector& supported_versions); |
39 | 41 |
40 virtual ~QuicSimpleServer(); | 42 virtual ~QuicSimpleServer(); |
41 | 43 |
42 // Start listening on the specified address. Returns an error code. | 44 // Start listening on the specified address. Returns an error code. |
43 int Listen(const IPEndPoint& address); | 45 int Listen(const IPEndPoint& address); |
44 | 46 |
45 // Server deletion is imminent. Start cleaning up. | 47 // Server deletion is imminent. Start cleaning up. |
46 void Shutdown(); | 48 void Shutdown(); |
47 | 49 |
48 // Start reading on the socket. On asynchronous reads, this registers | 50 // Start reading on the socket. On asynchronous reads, this registers |
49 // OnReadComplete as the callback, which will then call StartReading again. | 51 // OnReadComplete as the callback, which will then call StartReading again. |
50 void StartReading(); | 52 void StartReading(); |
51 | 53 |
52 // Called on reads that complete asynchronously. Dispatches the packet and | 54 // Called on reads that complete asynchronously. Dispatches the packet and |
53 // continues the read loop. | 55 // continues the read loop. |
54 void OnReadComplete(int result); | 56 void OnReadComplete(int result); |
55 | 57 |
56 void SetStrikeRegisterNoStartupPeriod() { | 58 void SetStrikeRegisterNoStartupPeriod() { |
57 crypto_config_.set_strike_register_no_startup_period(); | 59 crypto_config_.set_strike_register_no_startup_period(); |
58 } | 60 } |
59 | 61 |
60 QuicDispatcher* dispatcher() { return dispatcher_.get(); } | 62 QuicDispatcher* dispatcher() { return dispatcher_.get(); } |
61 | 63 |
| 64 IPEndPoint server_address() const { return server_address_; } |
| 65 |
62 private: | 66 private: |
63 friend class test::QuicSimpleServerPeer; | 67 friend class test::QuicSimpleServerPeer; |
64 | 68 |
65 // Initialize the internal state of the server. | 69 // Initialize the internal state of the server. |
66 void Initialize(); | 70 void Initialize(); |
67 | 71 |
68 QuicVersionManager version_manager_; | 72 QuicVersionManager version_manager_; |
69 | 73 |
70 // Accepts data from the framer and demuxes clients to sessions. | 74 // Accepts data from the framer and demuxes clients to sessions. |
71 std::unique_ptr<QuicDispatcher> dispatcher_; | 75 std::unique_ptr<QuicDispatcher> dispatcher_; |
72 | 76 |
73 // Used by the helper_ to time alarms. | 77 // Used by the helper_ to time alarms. |
74 QuicClock clock_; | 78 QuicClock clock_; |
75 | 79 |
76 // Used to manage the message loop. Owned by dispatcher_. | 80 // Used to manage the message loop. Owned by dispatcher_. |
77 QuicChromiumConnectionHelper* helper_; | 81 QuicChromiumConnectionHelper* helper_; |
78 | 82 |
79 // Used to manage the message loop. Owned by dispatcher_. | 83 // Used to manage the message loop. Owned by dispatcher_. |
80 QuicChromiumAlarmFactory* alarm_factory_; | 84 QuicChromiumAlarmFactory* alarm_factory_; |
81 | 85 |
82 // Listening socket. Also used for outbound client communication. | 86 // Listening socket. Also used for outbound client communication. |
83 std::unique_ptr<UDPServerSocket> socket_; | 87 std::unique_ptr<UDPServerSocket> socket_; |
84 | 88 |
85 // config_ contains non-crypto parameters that are negotiated in the crypto | 89 // config_ contains non-crypto parameters that are negotiated in the crypto |
86 // handshake. | 90 // handshake. |
87 QuicConfig config_; | 91 QuicConfig config_; |
| 92 // crypto_config_ contains crypto parameters that are negotiated in the crypto |
| 93 // handshake. |
| 94 QuicCryptoServerConfig::ConfigOptions crypto_config_options_; |
88 // crypto_config_ contains crypto parameters for the handshake. | 95 // crypto_config_ contains crypto parameters for the handshake. |
89 QuicCryptoServerConfig crypto_config_; | 96 QuicCryptoServerConfig crypto_config_; |
90 | 97 |
91 // The address that the server listens on. | 98 // The address that the server listens on. |
92 IPEndPoint server_address_; | 99 IPEndPoint server_address_; |
93 | 100 |
94 // Keeps track of whether a read is currently in flight, after which | 101 // Keeps track of whether a read is currently in flight, after which |
95 // OnReadComplete will be called. | 102 // OnReadComplete will be called. |
96 bool read_pending_; | 103 bool read_pending_; |
97 | 104 |
(...skipping 11 matching lines...) Expand all Loading... |
109 NetLog net_log_; | 116 NetLog net_log_; |
110 | 117 |
111 base::WeakPtrFactory<QuicSimpleServer> weak_factory_; | 118 base::WeakPtrFactory<QuicSimpleServer> weak_factory_; |
112 | 119 |
113 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServer); | 120 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServer); |
114 }; | 121 }; |
115 | 122 |
116 } // namespace net | 123 } // namespace net |
117 | 124 |
118 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ | 125 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ |
OLD | NEW |