OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_packet_reader.h" | 5 #include "net/tools/quic/quic_packet_reader.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #ifndef __APPLE__ | 8 #ifndef __APPLE__ |
9 // This is a GNU header that is not present in /usr/include on MacOS | 9 // This is a GNU header that is not present in /usr/include on MacOS |
10 #include <features.h> | 10 #include <features.h> |
11 #endif | 11 #endif |
12 #include <string.h> | 12 #include <string.h> |
13 #include <sys/epoll.h> | 13 #include <sys/epoll.h> |
14 | 14 |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
17 #include "net/quic/quic_bug_tracker.h" | 17 #include "net/quic/quic_bug_tracker.h" |
18 #include "net/quic/quic_flags.h" | 18 #include "net/quic/quic_flags.h" |
19 #include "net/tools/quic/quic_dispatcher.h" | 19 #include "net/tools/quic/quic_dispatcher.h" |
| 20 #include "net/tools/quic/quic_process_packet_interface.h" |
20 #include "net/tools/quic/quic_socket_utils.h" | 21 #include "net/tools/quic/quic_socket_utils.h" |
21 | 22 |
22 #define MMSG_MORE 0 | 23 #define MMSG_MORE 0 |
23 | 24 |
24 #ifndef SO_RXQ_OVFL | 25 #ifndef SO_RXQ_OVFL |
25 #define SO_RXQ_OVFL 40 | 26 #define SO_RXQ_OVFL 40 |
26 #endif | 27 #endif |
27 | 28 |
28 namespace net { | 29 namespace net { |
29 | 30 |
(...skipping 20 matching lines...) Expand all Loading... |
50 hdr->msg_iov = &iov_[i]; | 51 hdr->msg_iov = &iov_[i]; |
51 hdr->msg_iovlen = 1; | 52 hdr->msg_iovlen = 1; |
52 | 53 |
53 hdr->msg_control = cbuf_ + kSpaceForOverflowAndIp * i; | 54 hdr->msg_control = cbuf_ + kSpaceForOverflowAndIp * i; |
54 hdr->msg_controllen = kSpaceForOverflowAndIp; | 55 hdr->msg_controllen = kSpaceForOverflowAndIp; |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 QuicPacketReader::~QuicPacketReader() {} | 59 QuicPacketReader::~QuicPacketReader() {} |
59 | 60 |
| 61 // TODO(danzh): write a public method to wrap ReadAndDispatchPackets() and |
| 62 // ReadAndDispatchSinglePacket() based on MMSG_MORE. |
60 bool QuicPacketReader::ReadAndDispatchPackets( | 63 bool QuicPacketReader::ReadAndDispatchPackets( |
61 int fd, | 64 int fd, |
62 int port, | 65 int port, |
63 ProcessPacketInterface* processor, | 66 ProcessPacketInterface* processor, |
64 QuicPacketCount* packets_dropped) { | 67 QuicPacketCount* packets_dropped) { |
65 #if MMSG_MORE | 68 #if MMSG_MORE |
66 // Re-set the length fields in case recvmmsg has changed them. | 69 // Re-set the length fields in case recvmmsg has changed them. |
67 for (int i = 0; i < kNumPacketsPerReadMmsgCall; ++i) { | 70 for (int i = 0; i < kNumPacketsPerReadMmsgCall; ++i) { |
68 iov_[i].iov_len = kMaxPacketSize; | 71 iov_[i].iov_len = kMaxPacketSize; |
69 mmsg_hdr_[i].msg_len = 0; | 72 mmsg_hdr_[i].msg_len = 0; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 processor->ProcessPacket(server_address, client_address, packet); | 137 processor->ProcessPacket(server_address, client_address, packet); |
135 | 138 |
136 // The socket read was successful, so return true even if packet dispatch | 139 // The socket read was successful, so return true even if packet dispatch |
137 // failed. | 140 // failed. |
138 return true; | 141 return true; |
139 } | 142 } |
140 | 143 |
141 } // namespace tools | 144 } // namespace tools |
142 | 145 |
143 } // namespace net | 146 } // namespace net |
OLD | NEW |