| 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/tools/quic/quic_client.h" | 5 #include "net/tools/quic/quic_client.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/epoll.h> | 10 #include <sys/epoll.h> |
| 11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "net/quic/crypto/quic_random.h" | 15 #include "net/quic/crypto/quic_random.h" |
| 16 #include "net/quic/quic_connection.h" | 16 #include "net/quic/quic_connection.h" |
| 17 #include "net/quic/quic_data_reader.h" | 17 #include "net/quic/quic_data_reader.h" |
| 18 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
| 19 #include "net/quic/quic_session_key.h" | 19 #include "net/quic/quic_server_id.h" |
| 20 #include "net/tools/balsa/balsa_headers.h" | 20 #include "net/tools/balsa/balsa_headers.h" |
| 21 #include "net/tools/quic/quic_epoll_connection_helper.h" | 21 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 22 #include "net/tools/quic/quic_socket_utils.h" | 22 #include "net/tools/quic/quic_socket_utils.h" |
| 23 #include "net/tools/quic/quic_spdy_client_stream.h" | 23 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 24 | 24 |
| 25 #ifndef SO_RXQ_OVFL | 25 #ifndef SO_RXQ_OVFL |
| 26 #define SO_RXQ_OVFL 40 | 26 #define SO_RXQ_OVFL 40 |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace net { | 29 namespace net { |
| 30 namespace tools { | 30 namespace tools { |
| 31 | 31 |
| 32 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; | 32 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; |
| 33 | 33 |
| 34 QuicClient::QuicClient(IPEndPoint server_address, | 34 QuicClient::QuicClient(IPEndPoint server_address, |
| 35 const QuicSessionKey& server_key, | 35 const QuicServerId& server_id, |
| 36 const QuicVersionVector& supported_versions, | 36 const QuicVersionVector& supported_versions, |
| 37 bool print_response, | 37 bool print_response, |
| 38 uint32 initial_flow_control_window) | 38 uint32 initial_flow_control_window) |
| 39 : server_address_(server_address), | 39 : server_address_(server_address), |
| 40 server_key_(server_key), | 40 server_id_(server_id), |
| 41 local_port_(0), | 41 local_port_(0), |
| 42 fd_(-1), | 42 fd_(-1), |
| 43 helper_(CreateQuicConnectionHelper()), | 43 helper_(CreateQuicConnectionHelper()), |
| 44 initialized_(false), | 44 initialized_(false), |
| 45 packets_dropped_(0), | 45 packets_dropped_(0), |
| 46 overflow_supported_(false), | 46 overflow_supported_(false), |
| 47 supported_versions_(supported_versions), | 47 supported_versions_(supported_versions), |
| 48 print_response_(print_response), | 48 print_response_(print_response), |
| 49 initial_flow_control_window_(initial_flow_control_window) { | 49 initial_flow_control_window_(initial_flow_control_window) { |
| 50 config_.SetDefaults(); | 50 config_.SetDefaults(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 QuicClient::QuicClient(IPEndPoint server_address, | 53 QuicClient::QuicClient(IPEndPoint server_address, |
| 54 const QuicSessionKey& server_key, | 54 const QuicServerId& server_id, |
| 55 const QuicConfig& config, | 55 const QuicConfig& config, |
| 56 const QuicVersionVector& supported_versions, | 56 const QuicVersionVector& supported_versions, |
| 57 uint32 initial_flow_control_window) | 57 uint32 initial_flow_control_window) |
| 58 : server_address_(server_address), | 58 : server_address_(server_address), |
| 59 server_key_(server_key), | 59 server_id_(server_id), |
| 60 config_(config), | 60 config_(config), |
| 61 local_port_(0), | 61 local_port_(0), |
| 62 fd_(-1), | 62 fd_(-1), |
| 63 helper_(CreateQuicConnectionHelper()), | 63 helper_(CreateQuicConnectionHelper()), |
| 64 initialized_(false), | 64 initialized_(false), |
| 65 packets_dropped_(0), | 65 packets_dropped_(0), |
| 66 overflow_supported_(false), | 66 overflow_supported_(false), |
| 67 supported_versions_(supported_versions), | 67 supported_versions_(supported_versions), |
| 68 print_response_(false), | 68 print_response_(false), |
| 69 initial_flow_control_window_(initial_flow_control_window) { | 69 initial_flow_control_window_(initial_flow_control_window) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 bool QuicClient::StartConnect() { | 160 bool QuicClient::StartConnect() { |
| 161 DCHECK(initialized_); | 161 DCHECK(initialized_); |
| 162 DCHECK(!connected()); | 162 DCHECK(!connected()); |
| 163 | 163 |
| 164 QuicPacketWriter* writer = CreateQuicPacketWriter(); | 164 QuicPacketWriter* writer = CreateQuicPacketWriter(); |
| 165 if (writer_.get() != writer) { | 165 if (writer_.get() != writer) { |
| 166 writer_.reset(writer); | 166 writer_.reset(writer); |
| 167 } | 167 } |
| 168 | 168 |
| 169 session_.reset(new QuicClientSession( | 169 session_.reset(new QuicClientSession( |
| 170 server_key_, | 170 server_id_, |
| 171 config_, | 171 config_, |
| 172 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(), | 172 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(), |
| 173 writer_.get(), false, supported_versions_, | 173 writer_.get(), false, supported_versions_, |
| 174 initial_flow_control_window_), | 174 initial_flow_control_window_), |
| 175 &crypto_config_)); | 175 &crypto_config_)); |
| 176 return session_->CryptoConnect(); | 176 return session_->CryptoConnect(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool QuicClient::EncryptionBeingEstablished() { | 179 bool QuicClient::EncryptionBeingEstablished() { |
| 180 return !session_->IsEncryptionEstablished() && | 180 return !session_->IsEncryptionEstablished() && |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 QuicEncryptedPacket packet(buf, bytes_read, false); | 319 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 320 | 320 |
| 321 IPEndPoint client_address(client_ip, client_address_.port()); | 321 IPEndPoint client_address(client_ip, client_address_.port()); |
| 322 session_->connection()->ProcessUdpPacket( | 322 session_->connection()->ProcessUdpPacket( |
| 323 client_address, server_address, packet); | 323 client_address, server_address, packet); |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace tools | 327 } // namespace tools |
| 328 } // namespace net | 328 } // namespace net |
| OLD | NEW |