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

Unified Diff: net/tools/quic/quic_socket_utils.cc

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_socket_utils.h ('k') | net/tools/quic/quic_time_wait_list_manager_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_socket_utils.cc
diff --git a/net/tools/quic/quic_socket_utils.cc b/net/tools/quic/quic_socket_utils.cc
index 28a6f2588b5bb4302e5cdc0e9a9a4127d4a45623..a6bc4c0c49642dee758371de8087ab35a7dee866 100644
--- a/net/tools/quic/quic_socket_utils.cc
+++ b/net/tools/quic/quic_socket_utils.cc
@@ -27,9 +27,7 @@ namespace net {
void QuicSocketUtils::GetAddressAndTimestampFromMsghdr(
struct msghdr* hdr,
IPAddress* address,
- QuicTime* timestamp,
- QuicWallTime* walltimestamp,
- bool latched_walltimestamps) {
+ QuicWallTime* walltimestamp) {
if (hdr->msg_controllen > 0) {
for (cmsghdr* cmsg = CMSG_FIRSTHDR(hdr); cmsg != nullptr;
cmsg = CMSG_NXTHDR(hdr, cmsg)) {
@@ -52,12 +50,7 @@ void QuicSocketUtils::GetAddressAndTimestampFromMsghdr(
timespec* ts = &lts->systime;
int64_t usec = (static_cast<int64_t>(ts->tv_sec) * 1000 * 1000) +
(static_cast<int64_t>(ts->tv_nsec) / 1000);
- if (latched_walltimestamps) {
- *walltimestamp = QuicWallTime::FromUNIXMicroseconds(usec);
- } else {
- *timestamp =
- QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(usec);
- }
+ *walltimestamp = QuicWallTime::FromUNIXMicroseconds(usec);
}
}
}
@@ -80,6 +73,23 @@ bool QuicSocketUtils::GetOverflowFromMsghdr(struct msghdr* hdr,
}
// static
+bool QuicSocketUtils::GetTtlFromMsghdr(struct msghdr* hdr, int* ttl) {
+ if (hdr->msg_controllen > 0) {
+ struct cmsghdr* cmsg;
+ for (cmsg = CMSG_FIRSTHDR(hdr); cmsg != nullptr;
+ cmsg = CMSG_NXTHDR(hdr, cmsg)) {
+ if ((cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) ||
+ (cmsg->cmsg_level == IPPROTO_IPV6 &&
+ cmsg->cmsg_type == IPV6_HOPLIMIT)) {
+ *ttl = *(reinterpret_cast<int*>(CMSG_DATA(cmsg)));
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// static
int QuicSocketUtils::SetGetAddressInfo(int fd, int address_family) {
int get_local_ip = 1;
int rc = setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip,
@@ -122,9 +132,7 @@ int QuicSocketUtils::ReadPacket(int fd,
size_t buf_len,
QuicPacketCount* dropped_packets,
IPAddress* self_address,
- QuicTime* timestamp,
QuicWallTime* walltimestamp,
- bool latched_walltimestamps,
IPEndPoint* peer_address) {
DCHECK(peer_address != nullptr);
char cbuf[kSpaceForCmsg];
@@ -176,13 +184,7 @@ int QuicSocketUtils::ReadPacket(int fd,
walltimestamp = &stack_walltimestamp;
}
- QuicTime stack_timestamp = QuicTime::Zero();
- if (timestamp == nullptr) {
- timestamp = &stack_timestamp;
- }
-
- GetAddressAndTimestampFromMsghdr(&hdr, self_address, timestamp, walltimestamp,
- latched_walltimestamps);
+ GetAddressAndTimestampFromMsghdr(&hdr, self_address, walltimestamp);
if (raw_address.ss_family == AF_INET) {
CHECK(peer_address->FromSockAddr(
« no previous file with comments | « net/tools/quic/quic_socket_utils.h ('k') | net/tools/quic/quic_time_wait_list_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698