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> |
11 #include <sys/epoll.h> | 11 #include <sys/epoll.h> |
12 #include <sys/socket.h> | 12 #include <sys/socket.h> |
13 | 13 |
14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
15 #include "net/quic/quic_data_reader.h" | 15 #include "net/quic/quic_data_reader.h" |
16 #include "net/quic/quic_protocol.h" | 16 #include "net/quic/quic_protocol.h" |
17 #include "net/tools/quic/quic_in_memory_cache.h" | 17 #include "net/tools/quic/quic_in_memory_cache.h" |
18 #include "net/tools/quic/quic_socket_utils.h" | 18 #include "net/tools/quic/quic_socket_utils.h" |
19 | 19 |
20 #define MMSG_MORE 0 | 20 #define MMSG_MORE 0 |
21 | 21 |
22 #ifndef SO_RXQ_OVFL | 22 #ifndef SO_RXQ_OVFL |
23 #define SO_RXQ_OVFL 40 | 23 #define SO_RXQ_OVFL 40 |
24 #endif | 24 #endif |
25 | 25 |
26 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; | 26 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; |
27 const int kNumPacketsPerReadCall = 5; // Arbitrary | 27 const int kNumPacketsPerReadCall = 5; // Arbitrary |
28 | 28 |
29 namespace net { | 29 namespace net { |
| 30 namespace tools { |
30 | 31 |
31 QuicServer::QuicServer() | 32 QuicServer::QuicServer() |
32 : port_(0), | 33 : port_(0), |
33 packets_dropped_(0), | 34 packets_dropped_(0), |
34 overflow_supported_(false), | 35 overflow_supported_(false), |
35 use_recvmmsg_(false) { | 36 use_recvmmsg_(false) { |
36 epoll_server_.set_timeout_in_us(50 * 1000); | 37 epoll_server_.set_timeout_in_us(50 * 1000); |
37 // Initialize the in memory cache now. | 38 // Initialize the in memory cache now. |
38 QuicInMemoryCache::GetInstance(); | 39 QuicInMemoryCache::GetInstance(); |
39 } | 40 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (!reader.ReadUInt64(&guid)) { | 174 if (!reader.ReadUInt64(&guid)) { |
174 return true; // We read, we just didn't like the results. | 175 return true; // We read, we just didn't like the results. |
175 } | 176 } |
176 | 177 |
177 IPEndPoint server_address(server_ip, port); | 178 IPEndPoint server_address(server_ip, port); |
178 dispatcher->ProcessPacket(server_address, client_address, guid, packet); | 179 dispatcher->ProcessPacket(server_address, client_address, guid, packet); |
179 | 180 |
180 return true; | 181 return true; |
181 } | 182 } |
182 | 183 |
| 184 } // namespace tools |
183 } // namespace net | 185 } // namespace net |
OLD | NEW |