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 // A class to read incoming QUIC packets from the UDP socket. | 5 // A class to read incoming QUIC packets from the UDP socket. |
6 | 6 |
7 #ifndef NET_TOOLS_QUIC_QUIC_PACKET_READER_H_ | 7 #ifndef NET_TOOLS_QUIC_QUIC_PACKET_READER_H_ |
8 #define NET_TOOLS_QUIC_QUIC_PACKET_READER_H_ | 8 #define NET_TOOLS_QUIC_QUIC_PACKET_READER_H_ |
9 | 9 |
10 #include <netinet/in.h> | 10 #include <netinet/in.h> |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 virtual ~QuicPacketReader(); | 38 virtual ~QuicPacketReader(); |
39 | 39 |
40 // Reads a number of packets from the given fd, and then passes them off to | 40 // Reads a number of packets from the given fd, and then passes them off to |
41 // the PacketProcessInterface. Returns true if there may be additional | 41 // the PacketProcessInterface. Returns true if there may be additional |
42 // packets available on the socket. | 42 // packets available on the socket. |
43 // Populates |packets_dropped| if it is non-null and the socket is configured | 43 // Populates |packets_dropped| if it is non-null and the socket is configured |
44 // to track dropped packets and some packets are read. | 44 // to track dropped packets and some packets are read. |
45 // If the socket has timestamping enabled, the per packet timestamps will be | 45 // If the socket has timestamping enabled, the per packet timestamps will be |
46 // passed to the processor. Otherwise, |clock| will be used. | 46 // passed to the processor. Otherwise, |clock| will be used. |
47 // If |potentially_small_mtu| is set, the incoming packets have been | |
48 // identified as potentially having an unusually small MTU. | |
49 virtual bool ReadAndDispatchPackets(int fd, | 47 virtual bool ReadAndDispatchPackets(int fd, |
50 int port, | 48 int port, |
51 bool potentially_small_mtu, | |
52 const QuicClock& clock, | 49 const QuicClock& clock, |
53 ProcessPacketInterface* processor, | 50 ProcessPacketInterface* processor, |
54 QuicPacketCount* packets_dropped); | 51 QuicPacketCount* packets_dropped); |
55 | 52 |
56 private: | 53 private: |
57 // Initialize the internal state of the reader. | 54 // Initialize the internal state of the reader. |
58 void Initialize(); | 55 void Initialize(); |
59 | 56 |
60 // Reads and dispatches many packets using recvmmsg. | 57 // Reads and dispatches many packets using recvmmsg. |
61 bool ReadAndDispatchManyPackets(int fd, | 58 bool ReadAndDispatchManyPackets(int fd, |
62 int port, | 59 int port, |
63 bool potentially_small_mtu, | |
64 const QuicClock& clock, | 60 const QuicClock& clock, |
65 ProcessPacketInterface* processor, | 61 ProcessPacketInterface* processor, |
66 QuicPacketCount* packets_dropped); | 62 QuicPacketCount* packets_dropped); |
67 | 63 |
68 // Reads and dispatches a single packet using recvmsg. | 64 // Reads and dispatches a single packet using recvmsg. |
69 static bool ReadAndDispatchSinglePacket(int fd, | 65 static bool ReadAndDispatchSinglePacket(int fd, |
70 int port, | 66 int port, |
71 bool potentially_small_mtu, | |
72 const QuicClock& clock, | 67 const QuicClock& clock, |
73 ProcessPacketInterface* processor, | 68 ProcessPacketInterface* processor, |
74 QuicPacketCount* packets_dropped); | 69 QuicPacketCount* packets_dropped); |
75 | 70 |
76 // Storage only used when recvmmsg is available. | 71 // Storage only used when recvmmsg is available. |
77 | 72 |
78 #if MMSG_MORE | 73 #if MMSG_MORE |
79 // TODO(danzh): change it to be a pointer to avoid the allocation on the stack | 74 // TODO(danzh): change it to be a pointer to avoid the allocation on the stack |
80 // from exceeding maximum allowed frame size. | 75 // from exceeding maximum allowed frame size. |
81 // packets_ and mmsg_hdr_ are used to supply cbuf and buf to the recvmmsg | 76 // packets_ and mmsg_hdr_ are used to supply cbuf and buf to the recvmmsg |
(...skipping 12 matching lines...) Expand all Loading... |
94 PacketData packets_[kNumPacketsPerReadMmsgCall]; | 89 PacketData packets_[kNumPacketsPerReadMmsgCall]; |
95 mmsghdr mmsg_hdr_[kNumPacketsPerReadMmsgCall]; | 90 mmsghdr mmsg_hdr_[kNumPacketsPerReadMmsgCall]; |
96 #endif | 91 #endif |
97 | 92 |
98 DISALLOW_COPY_AND_ASSIGN(QuicPacketReader); | 93 DISALLOW_COPY_AND_ASSIGN(QuicPacketReader); |
99 }; | 94 }; |
100 | 95 |
101 } // namespace net | 96 } // namespace net |
102 | 97 |
103 #endif // NET_TOOLS_QUIC_QUIC_PACKET_READER_H_ | 98 #endif // NET_TOOLS_QUIC_QUIC_PACKET_READER_H_ |
OLD | NEW |