Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: net/tools/quic/quic_packet_reader.cc

Issue 1979763002: Landing Recent QUIC changes until Sun May 8 00:39:29 2016 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 IPEndPoint client_address = IPEndPoint(packets_[i].raw_address); 114 IPEndPoint client_address = IPEndPoint(packets_[i].raw_address);
115 IPAddress server_ip; 115 IPAddress server_ip;
116 QuicTime packet_timestamp = QuicTime::Zero(); 116 QuicTime packet_timestamp = QuicTime::Zero();
117 QuicSocketUtils::GetAddressAndTimestampFromMsghdr( 117 QuicSocketUtils::GetAddressAndTimestampFromMsghdr(
118 &mmsg_hdr_[i].msg_hdr, &server_ip, &packet_timestamp); 118 &mmsg_hdr_[i].msg_hdr, &server_ip, &packet_timestamp);
119 if (!IsInitializedAddress(server_ip)) { 119 if (!IsInitializedAddress(server_ip)) {
120 QUIC_BUG << "Unable to get server address."; 120 QUIC_BUG << "Unable to get server address.";
121 continue; 121 continue;
122 } 122 }
123 123
124 if (FLAGS_quic_use_socket_timestamp) { 124 if (packet_timestamp == QuicTime::Zero()) {
125 if (packet_timestamp == QuicTime::Zero()) { 125 // This isn't particularly desirable, but not all platforms support socket
126 // This isn't particularly desirable, but not all platforms support 126 // timestamping.
127 // socket timestamping. 127 if (fallback_timestamp == QuicTime::Zero()) {
128 if (fallback_timestamp == QuicTime::Zero()) { 128 fallback_timestamp = clock.Now();
129 fallback_timestamp = clock.Now();
130 }
131 packet_timestamp = fallback_timestamp;
132 } 129 }
130 packet_timestamp = fallback_timestamp;
133 } 131 }
134 132
135 QuicReceivedPacket packet(reinterpret_cast<char*>(packets_[i].iov.iov_base), 133 QuicReceivedPacket packet(reinterpret_cast<char*>(packets_[i].iov.iov_base),
136 mmsg_hdr_[i].msg_len, packet_timestamp, false); 134 mmsg_hdr_[i].msg_len, packet_timestamp, false);
137 IPEndPoint server_address(server_ip, port); 135 IPEndPoint server_address(server_ip, port);
138 processor->ProcessPacket(server_address, client_address, packet); 136 processor->ProcessPacket(server_address, client_address, packet);
139 } 137 }
140 138
141 if (packets_dropped != nullptr) { 139 if (packets_dropped != nullptr) {
142 QuicSocketUtils::GetOverflowFromMsghdr(&mmsg_hdr_[0].msg_hdr, 140 QuicSocketUtils::GetOverflowFromMsghdr(&mmsg_hdr_[0].msg_hdr,
(...skipping 25 matching lines...) Expand all
168 &server_ip, &timestamp, &client_address); 166 &server_ip, &timestamp, &client_address);
169 167
170 if (bytes_read < 0) { 168 if (bytes_read < 0) {
171 return false; // ReadPacket failed. 169 return false; // ReadPacket failed.
172 } 170 }
173 171
174 if (server_ip.empty()) { 172 if (server_ip.empty()) {
175 QUIC_BUG << "Unable to get server address."; 173 QUIC_BUG << "Unable to get server address.";
176 return false; 174 return false;
177 } 175 }
178 if (FLAGS_quic_use_socket_timestamp && timestamp == QuicTime::Zero()) { 176 if (timestamp == QuicTime::Zero()) {
179 // This isn't particularly desirable, but not all platforms support socket 177 // This isn't particularly desirable, but not all platforms support socket
180 // timestamping. 178 // timestamping.
181 timestamp = clock.Now(); 179 timestamp = clock.Now();
182 } 180 }
183 181
184 QuicReceivedPacket packet(buf, bytes_read, timestamp, false); 182 QuicReceivedPacket packet(buf, bytes_read, timestamp, false);
185 IPEndPoint server_address(server_ip, port); 183 IPEndPoint server_address(server_ip, port);
186 processor->ProcessPacket(server_address, client_address, packet); 184 processor->ProcessPacket(server_address, client_address, packet);
187 185
188 // The socket read was successful, so return true even if packet dispatch 186 // The socket read was successful, so return true even if packet dispatch
189 // failed. 187 // failed.
190 return true; 188 return true;
191 } 189 }
192 190
193 191
194 } // namespace net 192 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_packet_printer_bin.cc ('k') | net/tools/quic/quic_server_session_base_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698