| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 if (event->in_events & EPOLLERR) { | 199 if (event->in_events & EPOLLERR) { |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 /* static */ | 203 /* static */ |
| 204 bool QuicServer::ReadAndDispatchSinglePacket(int fd, | 204 bool QuicServer::ReadAndDispatchSinglePacket(int fd, |
| 205 int port, | 205 int port, |
| 206 ProcessPacketInterface* processor, | 206 ProcessPacketInterface* processor, |
| 207 uint32* packets_dropped) { | 207 QuicPacketCount* packets_dropped) { |
| 208 // Allocate some extra space so we can send an error if the client goes over | 208 // Allocate some extra space so we can send an error if the client goes over |
| 209 // the limit. | 209 // the limit. |
| 210 char buf[2 * kMaxPacketSize]; | 210 char buf[2 * kMaxPacketSize]; |
| 211 | 211 |
| 212 IPEndPoint client_address; | 212 IPEndPoint client_address; |
| 213 IPAddressNumber server_ip; | 213 IPAddressNumber server_ip; |
| 214 int bytes_read = | 214 int bytes_read = |
| 215 QuicSocketUtils::ReadPacket(fd, buf, arraysize(buf), | 215 QuicSocketUtils::ReadPacket(fd, buf, arraysize(buf), |
| 216 packets_dropped, | 216 packets_dropped, |
| 217 &server_ip, &client_address); | 217 &server_ip, &client_address); |
| 218 | 218 |
| 219 if (bytes_read < 0) { | 219 if (bytes_read < 0) { |
| 220 return false; // We failed to read. | 220 return false; // We failed to read. |
| 221 } | 221 } |
| 222 | 222 |
| 223 QuicEncryptedPacket packet(buf, bytes_read, false); | 223 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 224 | 224 |
| 225 IPEndPoint server_address(server_ip, port); | 225 IPEndPoint server_address(server_ip, port); |
| 226 processor->ProcessPacket(server_address, client_address, packet); | 226 processor->ProcessPacket(server_address, client_address, packet); |
| 227 | 227 |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace tools | 231 } // namespace tools |
| 232 } // namespace net | 232 } // namespace net |
| OLD | NEW |