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