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> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 hdr->msg_iovlen = 1; | 49 hdr->msg_iovlen = 1; |
50 | 50 |
51 hdr->msg_control = cbuf_ + kSpaceForOverflowAndIp * i; | 51 hdr->msg_control = cbuf_ + kSpaceForOverflowAndIp * i; |
52 hdr->msg_controllen = kSpaceForOverflowAndIp; | 52 hdr->msg_controllen = kSpaceForOverflowAndIp; |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 QuicPacketReader::~QuicPacketReader() { | 56 QuicPacketReader::~QuicPacketReader() { |
57 } | 57 } |
58 | 58 |
| 59 // TODO(danzh): write a public method to wrap ReadAndDispatchPackets() and |
| 60 // ReadAndDispatchSinglePacket() based on MMSG_MORE. |
59 bool QuicPacketReader::ReadAndDispatchPackets( | 61 bool QuicPacketReader::ReadAndDispatchPackets( |
60 int fd, | 62 int fd, |
61 int port, | 63 int port, |
62 ProcessPacketInterface* processor, | 64 ProcessPacketInterface* processor, |
63 QuicPacketCount* packets_dropped) { | 65 QuicPacketCount* packets_dropped) { |
64 #if MMSG_MORE | 66 #if MMSG_MORE |
65 // Re-set the length fields in case recvmmsg has changed them. | 67 // Re-set the length fields in case recvmmsg has changed them. |
66 for (int i = 0; i < kNumPacketsPerReadMmsgCall; ++i) { | 68 for (int i = 0; i < kNumPacketsPerReadMmsgCall; ++i) { |
67 iov_[i].iov_len = 2 * kMaxPacketSize; | 69 iov_[i].iov_len = 2 * kMaxPacketSize; |
68 mmsg_hdr_[i].msg_len = 0; | 70 mmsg_hdr_[i].msg_len = 0; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 processor->ProcessPacket(server_address, client_address, packet); | 136 processor->ProcessPacket(server_address, client_address, packet); |
135 | 137 |
136 // The socket read was successful, so return true even if packet dispatch | 138 // The socket read was successful, so return true even if packet dispatch |
137 // failed. | 139 // failed. |
138 return true; | 140 return true; |
139 } | 141 } |
140 | 142 |
141 } // namespace tools | 143 } // namespace tools |
142 | 144 |
143 } // namespace net | 145 } // namespace net |
OLD | NEW |