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 // A toy client, which connects to a specified port and sends QUIC | 5 // A toy client, which connects to a specified port and sends QUIC |
6 // request to that endpoint. | 6 // request to that endpoint. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 public: | 40 public: |
41 class ResponseListener { | 41 class ResponseListener { |
42 public: | 42 public: |
43 ResponseListener() {} | 43 ResponseListener() {} |
44 virtual ~ResponseListener() {} | 44 virtual ~ResponseListener() {} |
45 virtual void OnCompleteResponse(QuicStreamId id, | 45 virtual void OnCompleteResponse(QuicStreamId id, |
46 const BalsaHeaders& response_headers, | 46 const BalsaHeaders& response_headers, |
47 const string& response_body) = 0; | 47 const string& response_body) = 0; |
48 }; | 48 }; |
49 | 49 |
50 QuicClient(IPEndPoint server_address, | 50 // Create a quic client, which will have events managed by an externally owned |
51 const QuicServerId& server_id, | 51 // EpollServer. |
52 const QuicVersionVector& supported_versions, | |
53 bool print_response); | |
54 QuicClient(IPEndPoint server_address, | 52 QuicClient(IPEndPoint server_address, |
55 const QuicServerId& server_id, | 53 const QuicServerId& server_id, |
56 const QuicVersionVector& supported_versions, | 54 const QuicVersionVector& supported_versions, |
57 bool print_response, | 55 bool print_response, |
58 const QuicConfig& config); | 56 EpollServer* epoll_server); |
| 57 QuicClient(IPEndPoint server_address, |
| 58 const QuicServerId& server_id, |
| 59 const QuicVersionVector& supported_versions, |
| 60 bool print_response, |
| 61 const QuicConfig& config, |
| 62 EpollServer* epoll_server); |
59 | 63 |
60 virtual ~QuicClient(); | 64 virtual ~QuicClient(); |
61 | 65 |
62 // Initializes the client to create a connection. Should be called exactly | 66 // Initializes the client to create a connection. Should be called exactly |
63 // once before calling StartConnect or Connect. Returns true if the | 67 // once before calling StartConnect or Connect. Returns true if the |
64 // initialization succeeds, false otherwise. | 68 // initialization succeeds, false otherwise. |
65 bool Initialize(); | 69 bool Initialize(); |
66 | 70 |
67 // "Connect" to the QUIC server, including performing synchronous crypto | 71 // "Connect" to the QUIC server, including performing synchronous crypto |
68 // handshake. | 72 // handshake. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 128 } |
125 | 129 |
126 IPAddressNumber bind_to_address() const { return bind_to_address_; } | 130 IPAddressNumber bind_to_address() const { return bind_to_address_; } |
127 | 131 |
128 void set_local_port(int local_port) { local_port_ = local_port; } | 132 void set_local_port(int local_port) { local_port_ = local_port; } |
129 | 133 |
130 const IPEndPoint& server_address() const { return server_address_; } | 134 const IPEndPoint& server_address() const { return server_address_; } |
131 | 135 |
132 const IPEndPoint& client_address() const { return client_address_; } | 136 const IPEndPoint& client_address() const { return client_address_; } |
133 | 137 |
134 EpollServer* epoll_server() { return &epoll_server_; } | 138 EpollServer* epoll_server() { return epoll_server_; } |
135 | 139 |
136 int fd() { return fd_; } | 140 int fd() { return fd_; } |
137 | 141 |
138 const QuicServerId& server_id() const { return server_id_; } | 142 const QuicServerId& server_id() const { return server_id_; } |
139 | 143 |
140 // This should only be set before the initial Connect() | 144 // This should only be set before the initial Connect() |
141 void set_server_id(const QuicServerId& server_id) { | 145 void set_server_id(const QuicServerId& server_id) { |
142 server_id_ = server_id; | 146 server_id_ = server_id; |
143 } | 147 } |
144 | 148 |
| 149 void SetUserAgentID(const string& user_agent_id) { |
| 150 crypto_config_.set_user_agent_id(user_agent_id); |
| 151 } |
| 152 |
145 // SetProofVerifier sets the ProofVerifier that will be used to verify the | 153 // SetProofVerifier sets the ProofVerifier that will be used to verify the |
146 // server's certificate and takes ownership of |verifier|. | 154 // server's certificate and takes ownership of |verifier|. |
147 void SetProofVerifier(ProofVerifier* verifier) { | 155 void SetProofVerifier(ProofVerifier* verifier) { |
148 // TODO(rtenneti): We should set ProofVerifier in QuicClientSession. | 156 // TODO(rtenneti): We should set ProofVerifier in QuicClientSession. |
149 crypto_config_.SetProofVerifier(verifier); | 157 crypto_config_.SetProofVerifier(verifier); |
150 } | 158 } |
151 | 159 |
152 // SetChannelIDSource sets a ChannelIDSource that will be called, when the | 160 // SetChannelIDSource sets a ChannelIDSource that will be called, when the |
153 // server supports channel IDs, to obtain a channel ID for signing a message | 161 // server supports channel IDs, to obtain a channel ID for signing a message |
154 // proving possession of the channel ID. This object takes ownership of | 162 // proving possession of the channel ID. This object takes ownership of |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 IPEndPoint client_address_; | 209 IPEndPoint client_address_; |
202 | 210 |
203 // If initialized, the address to bind to. | 211 // If initialized, the address to bind to. |
204 IPAddressNumber bind_to_address_; | 212 IPAddressNumber bind_to_address_; |
205 // Local port to bind to. Initialize to 0. | 213 // Local port to bind to. Initialize to 0. |
206 int local_port_; | 214 int local_port_; |
207 | 215 |
208 // Session which manages streams. | 216 // Session which manages streams. |
209 scoped_ptr<QuicClientSession> session_; | 217 scoped_ptr<QuicClientSession> session_; |
210 // Listens for events on the client socket. | 218 // Listens for events on the client socket. |
211 EpollServer epoll_server_; | 219 EpollServer* epoll_server_; |
212 // UDP socket. | 220 // UDP socket. |
213 int fd_; | 221 int fd_; |
214 | 222 |
215 // Helper to be used by created connections. | 223 // Helper to be used by created connections. |
216 scoped_ptr<QuicEpollConnectionHelper> helper_; | 224 scoped_ptr<QuicEpollConnectionHelper> helper_; |
217 | 225 |
218 // Listens for full responses. | 226 // Listens for full responses. |
219 scoped_ptr<ResponseListener> response_listener_; | 227 scoped_ptr<ResponseListener> response_listener_; |
220 | 228 |
221 // Writer used to actually send packets to the wire. | 229 // Writer used to actually send packets to the wire. |
(...skipping 22 matching lines...) Expand all Loading... |
244 // when the stream is closed (in OnClose). | 252 // when the stream is closed (in OnClose). |
245 bool print_response_; | 253 bool print_response_; |
246 | 254 |
247 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 255 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
248 }; | 256 }; |
249 | 257 |
250 } // namespace tools | 258 } // namespace tools |
251 } // namespace net | 259 } // namespace net |
252 | 260 |
253 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 261 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
OLD | NEW |