| 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_server.h" | 5 #include "net/tools/quic/quic_server.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #ifndef __APPLE__ | 8 #ifndef __APPLE__ |
| 9 // This is a GNU header that is not present in /usr/include on MacOS | 9 // This is a GNU header that is not present in /usr/include on MacOS |
| 10 #include <features.h> | 10 #include <features.h> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // QuicServer. | 33 // QuicServer. |
| 34 // TODO(rtenneti): Enable this flag after MMSG_MORE is set to 1. | 34 // TODO(rtenneti): Enable this flag after MMSG_MORE is set to 1. |
| 35 #define FLAGS_quic_use_optimized_packet_reader false | 35 #define FLAGS_quic_use_optimized_packet_reader false |
| 36 | 36 |
| 37 #ifndef SO_RXQ_OVFL | 37 #ifndef SO_RXQ_OVFL |
| 38 #define SO_RXQ_OVFL 40 | 38 #define SO_RXQ_OVFL 40 |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace net { | 41 namespace net { |
| 42 namespace tools { | 42 namespace tools { |
| 43 namespace { |
| 43 | 44 |
| 44 namespace { | 45 // Specifies the directory used during QuicInMemoryCache |
| 46 // construction to seed the cache. Cache directory can be |
| 47 // generated using `wget -p --save-headers <url>` |
| 48 std::string FLAGS_quic_in_memory_cache_dir = ""; |
| 45 | 49 |
| 46 const PollBits kEpollFlags = PollBits(NET_POLLIN | NET_POLLOUT | NET_POLLET); | 50 const PollBits kEpollFlags = PollBits(NET_POLLIN | NET_POLLOUT | NET_POLLET); |
| 47 const char kSourceAddressTokenSecret[] = "secret"; | 51 const char kSourceAddressTokenSecret[] = "secret"; |
| 48 | 52 |
| 49 } // namespace | 53 } // namespace |
| 50 | 54 |
| 51 QuicServer::QuicServer() | 55 QuicServer::QuicServer() |
| 52 : port_(0), | 56 : port_(0), |
| 53 fd_(-1), | 57 fd_(-1), |
| 54 packets_dropped_(0), | 58 packets_dropped_(0), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 config_.SetInitialStreamFlowControlWindowToSend( | 92 config_.SetInitialStreamFlowControlWindowToSend( |
| 89 kInitialStreamFlowControlWindow); | 93 kInitialStreamFlowControlWindow); |
| 90 } | 94 } |
| 91 if (config_.GetInitialSessionFlowControlWindowToSend() == | 95 if (config_.GetInitialSessionFlowControlWindowToSend() == |
| 92 kMinimumFlowControlSendWindow) { | 96 kMinimumFlowControlSendWindow) { |
| 93 config_.SetInitialSessionFlowControlWindowToSend( | 97 config_.SetInitialSessionFlowControlWindowToSend( |
| 94 kInitialSessionFlowControlWindow); | 98 kInitialSessionFlowControlWindow); |
| 95 } | 99 } |
| 96 | 100 |
| 97 epoll_server_.set_timeout_in_us(50 * 1000); | 101 epoll_server_.set_timeout_in_us(50 * 1000); |
| 98 // Initialize the in memory cache now. | 102 |
| 99 QuicInMemoryCache::GetInstance(); | 103 if (!FLAGS_quic_in_memory_cache_dir.empty()) { |
| 104 QuicInMemoryCache::GetInstance()->InitializeFromDirectory( |
| 105 FLAGS_quic_in_memory_cache_dir); |
| 106 } |
| 100 | 107 |
| 101 QuicEpollClock clock(&epoll_server_); | 108 QuicEpollClock clock(&epoll_server_); |
| 102 | 109 |
| 103 scoped_ptr<CryptoHandshakeMessage> scfg( | 110 scoped_ptr<CryptoHandshakeMessage> scfg( |
| 104 crypto_config_.AddDefaultConfig( | 111 crypto_config_.AddDefaultConfig( |
| 105 QuicRandom::GetInstance(), &clock, | 112 QuicRandom::GetInstance(), &clock, |
| 106 QuicCryptoServerConfig::ConfigOptions())); | 113 QuicCryptoServerConfig::ConfigOptions())); |
| 107 } | 114 } |
| 108 | 115 |
| 109 QuicServer::~QuicServer() { | 116 QuicServer::~QuicServer() { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 QuicEncryptedPacket packet(buf, bytes_read, false); | 281 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 275 | 282 |
| 276 IPEndPoint server_address(server_ip, port); | 283 IPEndPoint server_address(server_ip, port); |
| 277 processor->ProcessPacket(server_address, client_address, packet); | 284 processor->ProcessPacket(server_address, client_address, packet); |
| 278 | 285 |
| 279 return true; | 286 return true; |
| 280 } | 287 } |
| 281 | 288 |
| 282 } // namespace tools | 289 } // namespace tools |
| 283 } // namespace net | 290 } // namespace net |
| OLD | NEW |