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 327d95606fdf1f21b3808915e588cb1038e3a2f8..a6bc4c0c49642dee758371de8087ab35a7dee866 100644 |
--- a/net/tools/quic/quic_socket_utils.cc |
+++ b/net/tools/quic/quic_socket_utils.cc |
@@ -73,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, |