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 #include <features.h> | 8 #include <features.h> |
9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #define SO_RXQ_OVFL 40 | 29 #define SO_RXQ_OVFL 40 |
30 #endif | 30 #endif |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 namespace tools { | 33 namespace tools { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; | 37 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; |
38 const char kSourceAddressTokenSecret[] = "secret"; | 38 const char kSourceAddressTokenSecret[] = "secret"; |
39 const uint32 kServerInitialFlowControlWindow = 100 * net::kMaxPacketSize; | |
40 | 39 |
41 } // namespace | 40 } // namespace |
42 | 41 |
43 QuicServer::QuicServer() | 42 QuicServer::QuicServer() |
44 : port_(0), | 43 : port_(0), |
45 fd_(-1), | 44 fd_(-1), |
46 packets_dropped_(0), | 45 packets_dropped_(0), |
47 overflow_supported_(false), | 46 overflow_supported_(false), |
48 use_recvmmsg_(false), | 47 use_recvmmsg_(false), |
49 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()), | 48 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()), |
(...skipping 21 matching lines...) Expand all Loading... |
71 epoll_server_.set_timeout_in_us(50 * 1000); | 70 epoll_server_.set_timeout_in_us(50 * 1000); |
72 // Initialize the in memory cache now. | 71 // Initialize the in memory cache now. |
73 QuicInMemoryCache::GetInstance(); | 72 QuicInMemoryCache::GetInstance(); |
74 | 73 |
75 QuicEpollClock clock(&epoll_server_); | 74 QuicEpollClock clock(&epoll_server_); |
76 | 75 |
77 scoped_ptr<CryptoHandshakeMessage> scfg( | 76 scoped_ptr<CryptoHandshakeMessage> scfg( |
78 crypto_config_.AddDefaultConfig( | 77 crypto_config_.AddDefaultConfig( |
79 QuicRandom::GetInstance(), &clock, | 78 QuicRandom::GetInstance(), &clock, |
80 QuicCryptoServerConfig::ConfigOptions())); | 79 QuicCryptoServerConfig::ConfigOptions())); |
81 | |
82 // Set flow control options in the config. | |
83 config_.SetInitialCongestionWindowToSend(kServerInitialFlowControlWindow); | |
84 } | 80 } |
85 | 81 |
86 QuicServer::~QuicServer() { | 82 QuicServer::~QuicServer() { |
87 } | 83 } |
88 | 84 |
89 bool QuicServer::Listen(const IPEndPoint& address) { | 85 bool QuicServer::Listen(const IPEndPoint& address) { |
90 port_ = address.port(); | 86 port_ = address.port(); |
91 int address_family = address.GetSockAddrFamily(); | 87 int address_family = address.GetSockAddrFamily(); |
92 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); | 88 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); |
93 if (fd_ < 0) { | 89 if (fd_ < 0) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 QuicEncryptedPacket packet(buf, bytes_read, false); | 223 QuicEncryptedPacket packet(buf, bytes_read, false); |
228 | 224 |
229 IPEndPoint server_address(server_ip, port); | 225 IPEndPoint server_address(server_ip, port); |
230 processor->ProcessPacket(server_address, client_address, packet); | 226 processor->ProcessPacket(server_address, client_address, packet); |
231 | 227 |
232 return true; | 228 return true; |
233 } | 229 } |
234 | 230 |
235 } // namespace tools | 231 } // namespace tools |
236 } // namespace net | 232 } // namespace net |
OLD | NEW |