Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: net/tools/quic/quic_server.cc

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
32 static const char kSourceAddressTokenSecret[] = "secret"; 32 static const char kSourceAddressTokenSecret[] = "secret";
33 33
34 namespace net { 34 namespace net {
35 namespace tools { 35 namespace tools {
36 36
37 QuicServer::QuicServer() 37 QuicServer::QuicServer()
38 : port_(0), 38 : port_(0),
39 packets_dropped_(0), 39 packets_dropped_(0),
40 overflow_supported_(false), 40 overflow_supported_(false),
41 use_recvmmsg_(false), 41 use_recvmmsg_(false),
42 crypto_config_(kSourceAddressTokenSecret) { 42 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()) {
43 // Use hardcoded crypto parameters for now. 43 // Use hardcoded crypto parameters for now.
44 config_.SetDefaults(); 44 config_.SetDefaults();
45 Initialize(); 45 Initialize();
46 } 46 }
47 47
48 QuicServer::QuicServer(const QuicConfig& config) 48 QuicServer::QuicServer(const QuicConfig& config)
49 : port_(0), 49 : port_(0),
50 packets_dropped_(0), 50 packets_dropped_(0),
51 overflow_supported_(false), 51 overflow_supported_(false),
52 use_recvmmsg_(false), 52 use_recvmmsg_(false),
53 config_(config), 53 config_(config),
54 crypto_config_(kSourceAddressTokenSecret) { 54 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()) {
55 Initialize(); 55 Initialize();
56 } 56 }
57 57
58 void QuicServer::Initialize() { 58 void QuicServer::Initialize() {
59 #if MMSG_MORE 59 #if MMSG_MORE
60 use_recvmmsg_ = true; 60 use_recvmmsg_ = true;
61 #endif 61 #endif
62 epoll_server_.set_timeout_in_us(50 * 1000); 62 epoll_server_.set_timeout_in_us(50 * 1000);
63 // Initialize the in memory cache now. 63 // Initialize the in memory cache now.
64 QuicInMemoryCache::GetInstance(); 64 QuicInMemoryCache::GetInstance();
65 65
66 QuicEpollClock clock(&epoll_server_); 66 QuicEpollClock clock(&epoll_server_);
67 67
68 scoped_ptr<CryptoHandshakeMessage> scfg( 68 scoped_ptr<CryptoHandshakeMessage> scfg(
69 crypto_config_.AddDefaultConfig( 69 crypto_config_.AddDefaultConfig(
70 QuicRandom::GetInstance(), &clock, 70 QuicRandom::GetInstance(), &clock,
71 QuicCryptoServerConfig::kDefaultExpiry)); 71 QuicCryptoServerConfig::ConfigOptions()));
72 } 72 }
73 73
74 QuicServer::~QuicServer() { 74 QuicServer::~QuicServer() {
75 } 75 }
76 76
77 bool QuicServer::Listen(const IPEndPoint& address) { 77 bool QuicServer::Listen(const IPEndPoint& address) {
78 port_ = address.port(); 78 port_ = address.port();
79 int address_family = address.GetSockAddrFamily(); 79 int address_family = address.GetSockAddrFamily();
80 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); 80 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
81 if (fd_ < 0) { 81 if (fd_ < 0) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (can_write_more) { 175 if (can_write_more) {
176 event->out_ready_mask |= EPOLLOUT; 176 event->out_ready_mask |= EPOLLOUT;
177 } 177 }
178 } 178 }
179 if (event->in_events & EPOLLERR) { 179 if (event->in_events & EPOLLERR) {
180 LOG(INFO) << "Epollerr"; 180 LOG(INFO) << "Epollerr";
181 } 181 }
182 } 182 }
183 183
184 bool QuicServer::ReadAndDispatchSinglePacket(int fd, 184 bool QuicServer::ReadAndDispatchSinglePacket(int fd,
185 int port, 185 int port,
186 QuicDispatcher* dispatcher, 186 QuicDispatcher* dispatcher,
187 int* packets_dropped) { 187 int* packets_dropped) {
188 // Allocate some extra space so we can send an error if the client goes over 188 // Allocate some extra space so we can send an error if the client goes over
189 // the limit. 189 // the limit.
190 char buf[2 * kMaxPacketSize]; 190 char buf[2 * kMaxPacketSize];
191 191
192 IPEndPoint client_address; 192 IPEndPoint client_address;
193 IPAddressNumber server_ip; 193 IPAddressNumber server_ip;
194 int bytes_read = 194 int bytes_read =
195 QuicSocketUtils::ReadPacket(fd, buf, arraysize(buf), 195 QuicSocketUtils::ReadPacket(fd, buf, arraysize(buf),
196 packets_dropped, 196 packets_dropped,
197 &server_ip, &client_address); 197 &server_ip, &client_address);
(...skipping 15 matching lines...) Expand all
213 } 213 }
214 214
215 IPEndPoint server_address(server_ip, port); 215 IPEndPoint server_address(server_ip, port);
216 dispatcher->ProcessPacket(server_address, client_address, guid, packet); 216 dispatcher->ProcessPacket(server_address, client_address, guid, packet);
217 217
218 return true; 218 return true;
219 } 219 }
220 220
221 } // namespace tools 221 } // namespace tools
222 } // namespace net 222 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698