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 28 matching lines...) Expand all Loading... |
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) { |
43 epoll_server_.set_timeout_in_us(50 * 1000); | 43 epoll_server_.set_timeout_in_us(50 * 1000); |
44 // Initialize the in memory cache now. | 44 // Initialize the in memory cache now. |
45 QuicInMemoryCache::GetInstance(); | 45 QuicInMemoryCache::GetInstance(); |
46 | 46 |
47 // Use hardcoded crypto parameters for now. | 47 // Use hardcoded crypto parameters for now. |
48 config_.SetDefaults(); | 48 config_.SetDefaults(); |
49 CryptoHandshakeMessage extra_tags; | |
50 config_.ToHandshakeMessage(&extra_tags); | |
51 QuicEpollClock clock(&epoll_server_); | 49 QuicEpollClock clock(&epoll_server_); |
52 | 50 |
53 scoped_ptr<CryptoHandshakeMessage> scfg( | 51 scoped_ptr<CryptoHandshakeMessage> scfg( |
54 crypto_config_.AddDefaultConfig( | 52 crypto_config_.AddDefaultConfig( |
55 QuicRandom::GetInstance(), &clock, extra_tags, | 53 QuicRandom::GetInstance(), &clock, |
56 QuicCryptoServerConfig::kDefaultExpiry)); | 54 QuicCryptoServerConfig::kDefaultExpiry)); |
57 // If we were using the same config in many servers then we would have to | |
58 // parse a QuicConfig from config_tags here. | |
59 if (!config_.SetFromHandshakeMessage(*scfg)) { | |
60 CHECK(false) << "Crypto config could not be parsed by QuicConfig."; | |
61 } | |
62 } | 55 } |
63 | 56 |
64 QuicServer::~QuicServer() { | 57 QuicServer::~QuicServer() { |
65 } | 58 } |
66 | 59 |
67 bool QuicServer::Listen(const IPEndPoint& address) { | 60 bool QuicServer::Listen(const IPEndPoint& address) { |
68 port_ = address.port(); | 61 port_ = address.port(); |
69 int address_family = address.GetSockAddrFamily(); | 62 int address_family = address.GetSockAddrFamily(); |
70 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); | 63 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); |
71 if (fd_ < 0) { | 64 if (fd_ < 0) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 192 } |
200 | 193 |
201 IPEndPoint server_address(server_ip, port); | 194 IPEndPoint server_address(server_ip, port); |
202 dispatcher->ProcessPacket(server_address, client_address, guid, packet); | 195 dispatcher->ProcessPacket(server_address, client_address, guid, packet); |
203 | 196 |
204 return true; | 197 return true; |
205 } | 198 } |
206 | 199 |
207 } // namespace tools | 200 } // namespace tools |
208 } // namespace net | 201 } // namespace net |
OLD | NEW |