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

Side by Side Diff: net/tools/quic/quic_socket_utils.h

Issue 2229703003: Introduce TTL in QuicReceivedPacket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129359661
Patch Set: git pull from upper stream 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 unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_packet_reader.cc ('k') | net/tools/quic/quic_socket_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Some socket related helper methods for quic. 5 // Some socket related helper methods for quic.
6 6
7 #ifndef NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ 7 #ifndef NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_
8 #define NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ 8 #define NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_
9 9
10 #include <netinet/in.h> 10 #include <netinet/in.h>
(...skipping 20 matching lines...) Expand all
31 // Deprecated; serves only as padding. 31 // Deprecated; serves only as padding.
32 struct timespec hwtimetrans; 32 struct timespec hwtimetrans;
33 // The raw hardware timestamp. 33 // The raw hardware timestamp.
34 struct timespec hwtimeraw; 34 struct timespec hwtimeraw;
35 }; 35 };
36 36
37 class QuicSocketUtils { 37 class QuicSocketUtils {
38 public: 38 public:
39 // The first integer is for overflow. The in6_pktinfo is the larger of the 39 // The first integer is for overflow. The in6_pktinfo is the larger of the
40 // address structures present. LinuxTimestamping is present for socket 40 // address structures present. LinuxTimestamping is present for socket
41 // timestamping. 41 // timestamping. The subsequent int is for ttl.
42 // The final int is a sentinel so the msg_controllen feedback 42 // The final int is a sentinel so the msg_controllen feedback
43 // can be used to detect larger control messages than there is space for. 43 // can be used to detect larger control messages than there is space for.
44 static const int kSpaceForCmsg = 44 static const int kSpaceForCmsg =
45 CMSG_SPACE(CMSG_LEN(sizeof(int)) + CMSG_LEN(sizeof(in6_pktinfo)) + 45 CMSG_SPACE(CMSG_LEN(sizeof(int)) + CMSG_LEN(sizeof(in6_pktinfo)) +
46 CMSG_LEN(sizeof(LinuxTimestamping)) + 46 CMSG_LEN(sizeof(LinuxTimestamping)) +
47 CMSG_LEN(sizeof(int)) +
47 CMSG_LEN(sizeof(int))); 48 CMSG_LEN(sizeof(int)));
48 49
49 // Fills in |address| if |hdr| contains IP_PKTINFO or IPV6_PKTINFO. Fills in 50 // Fills in |address| if |hdr| contains IP_PKTINFO or IPV6_PKTINFO. Fills in
50 // |timestamp| if |hdr| contains |SO_TIMESTAMPING|. |address| and |timestamp| 51 // |timestamp| if |hdr| contains |SO_TIMESTAMPING|. |address| and |timestamp|
51 // must not be null. 52 // must not be null.
52 static void GetAddressAndTimestampFromMsghdr(struct msghdr* hdr, 53 static void GetAddressAndTimestampFromMsghdr(struct msghdr* hdr,
53 IPAddress* address, 54 IPAddress* address,
54 QuicWallTime* walltimestamp); 55 QuicWallTime* walltimestamp);
55 56
56 // If the msghdr contains an SO_RXQ_OVFL entry, this will set dropped_packets 57 // If the msghdr contains an SO_RXQ_OVFL entry, this will set dropped_packets
57 // to the correct value and return true. Otherwise it will return false. 58 // to the correct value and return true. Otherwise it will return false.
58 static bool GetOverflowFromMsghdr(struct msghdr* hdr, 59 static bool GetOverflowFromMsghdr(struct msghdr* hdr,
59 QuicPacketCount* dropped_packets); 60 QuicPacketCount* dropped_packets);
60 61
62 // If the msghdr contains an IP_TTL entry, this will set ttl to the correct
63 // value and return true. Otherwise it will return false.
64 static bool GetTtlFromMsghdr(struct msghdr* hdr, int* ttl);
65
61 // Sets either IP_PKTINFO or IPV6_PKTINFO on the socket, based on 66 // Sets either IP_PKTINFO or IPV6_PKTINFO on the socket, based on
62 // address_family. Returns the return code from setsockopt. 67 // address_family. Returns the return code from setsockopt.
63 static int SetGetAddressInfo(int fd, int address_family); 68 static int SetGetAddressInfo(int fd, int address_family);
64 69
65 // Sets SO_TIMESTAMPING on the socket for software receive timestamping. 70 // Sets SO_TIMESTAMPING on the socket for software receive timestamping.
66 // Returns the return code from setsockopt. 71 // Returns the return code from setsockopt.
67 static int SetGetSoftwareReceiveTimestamp(int fd); 72 static int SetGetSoftwareReceiveTimestamp(int fd);
68 73
69 // Sets the send buffer size to |size| and returns false if it fails. 74 // Sets the send buffer size to |size| and returns false if it fails.
70 static bool SetSendBufferSize(int fd, size_t size); 75 static bool SetSendBufferSize(int fd, size_t size);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 static int CreateUDPSocket(const IPEndPoint& address, 120 static int CreateUDPSocket(const IPEndPoint& address,
116 bool* overflow_supported); 121 bool* overflow_supported);
117 122
118 private: 123 private:
119 DISALLOW_COPY_AND_ASSIGN(QuicSocketUtils); 124 DISALLOW_COPY_AND_ASSIGN(QuicSocketUtils);
120 }; 125 };
121 126
122 } // namespace net 127 } // namespace net
123 128
124 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ 129 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_
OLDNEW
« no previous file with comments | « net/tools/quic/quic_packet_reader.cc ('k') | net/tools/quic/quic_socket_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698