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/congestion_control/tcp_receiver.h" | |
16 #include "net/quic/crypto/crypto_handshake.h" | 15 #include "net/quic/crypto/crypto_handshake.h" |
17 #include "net/quic/crypto/quic_random.h" | 16 #include "net/quic/crypto/quic_random.h" |
18 #include "net/quic/quic_clock.h" | 17 #include "net/quic/quic_clock.h" |
19 #include "net/quic/quic_crypto_stream.h" | 18 #include "net/quic/quic_crypto_stream.h" |
20 #include "net/quic/quic_data_reader.h" | 19 #include "net/quic/quic_data_reader.h" |
21 #include "net/quic/quic_protocol.h" | 20 #include "net/quic/quic_protocol.h" |
22 #include "net/tools/quic/quic_dispatcher.h" | 21 #include "net/tools/quic/quic_dispatcher.h" |
23 #include "net/tools/quic/quic_in_memory_cache.h" | 22 #include "net/tools/quic/quic_in_memory_cache.h" |
24 #include "net/tools/quic/quic_socket_utils.h" | 23 #include "net/tools/quic/quic_socket_utils.h" |
25 | 24 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (rc < 0) { | 122 if (rc < 0) { |
124 DLOG(WARNING) << "Socket overflow detection not supported"; | 123 DLOG(WARNING) << "Socket overflow detection not supported"; |
125 } else { | 124 } else { |
126 overflow_supported_ = true; | 125 overflow_supported_ = true; |
127 } | 126 } |
128 | 127 |
129 // These send and receive buffer sizes are sized for a single connection, | 128 // These send and receive buffer sizes are sized for a single connection, |
130 // because the default usage of QuicServer is as a test server with one or | 129 // because the default usage of QuicServer is as a test server with one or |
131 // two clients. Adjust higher for use with many clients. | 130 // two clients. Adjust higher for use with many clients. |
132 if (!QuicSocketUtils::SetReceiveBufferSize(fd_, | 131 if (!QuicSocketUtils::SetReceiveBufferSize(fd_, |
133 TcpReceiver::kReceiveWindowTCP)) { | 132 kDefaultSocketReceiveBuffer)) { |
134 return false; | 133 return false; |
135 } | 134 } |
136 | 135 |
137 if (!QuicSocketUtils::SetSendBufferSize(fd_, | 136 if (!QuicSocketUtils::SetSendBufferSize(fd_, kDefaultSocketReceiveBuffer)) { |
138 TcpReceiver::kReceiveWindowTCP)) { | |
139 return false; | 137 return false; |
140 } | 138 } |
141 | 139 |
142 sockaddr_storage raw_addr; | 140 sockaddr_storage raw_addr; |
143 socklen_t raw_addr_len = sizeof(raw_addr); | 141 socklen_t raw_addr_len = sizeof(raw_addr); |
144 CHECK(address.ToSockAddr(reinterpret_cast<sockaddr*>(&raw_addr), | 142 CHECK(address.ToSockAddr(reinterpret_cast<sockaddr*>(&raw_addr), |
145 &raw_addr_len)); | 143 &raw_addr_len)); |
146 rc = bind(fd_, | 144 rc = bind(fd_, |
147 reinterpret_cast<const sockaddr*>(&raw_addr), | 145 reinterpret_cast<const sockaddr*>(&raw_addr), |
148 sizeof(raw_addr)); | 146 sizeof(raw_addr)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 QuicEncryptedPacket packet(buf, bytes_read, false); | 237 QuicEncryptedPacket packet(buf, bytes_read, false); |
240 | 238 |
241 IPEndPoint server_address(server_ip, port); | 239 IPEndPoint server_address(server_ip, port); |
242 processor->ProcessPacket(server_address, client_address, packet); | 240 processor->ProcessPacket(server_address, client_address, packet); |
243 | 241 |
244 return true; | 242 return true; |
245 } | 243 } |
246 | 244 |
247 } // namespace tools | 245 } // namespace tools |
248 } // namespace net | 246 } // namespace net |
OLD | NEW |