OLD | NEW |
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 <stddef.h> | 10 #include <stddef.h> |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
| 17 namespace tools { |
17 | 18 |
18 class QuicSocketUtils { | 19 class QuicSocketUtils { |
19 public: | 20 public: |
20 // If the msghdr contains IP_PKTINFO or IPV6_PKTINFO, this will return the | 21 // If the msghdr contains IP_PKTINFO or IPV6_PKTINFO, this will return the |
21 // IPAddressNumber in that header. Returns an uninitialized IPAddress on | 22 // IPAddressNumber in that header. Returns an uninitialized IPAddress on |
22 // failure. | 23 // failure. |
23 static IPAddressNumber GetAddressFromMsghdr(struct msghdr *hdr); | 24 static IPAddressNumber GetAddressFromMsghdr(struct msghdr *hdr); |
24 | 25 |
25 // If the msghdr contains an SO_RXQ_OVFL entry, this will set dropped_packets | 26 // If the msghdr contains an SO_RXQ_OVFL entry, this will set dropped_packets |
26 // to the correct value and return true. Otherwise it will return false. | 27 // to the correct value and return true. Otherwise it will return false. |
(...skipping 18 matching lines...) Expand all Loading... |
45 IPEndPoint* peer_address); | 46 IPEndPoint* peer_address); |
46 | 47 |
47 // Writes buf_len to the socket. If writing is successful returns the number | 48 // Writes buf_len to the socket. If writing is successful returns the number |
48 // of bytes written otherwise returns -1 and sets error to errno. | 49 // of bytes written otherwise returns -1 and sets error to errno. |
49 static int WritePacket(int fd, const char* buffer, size_t buf_len, | 50 static int WritePacket(int fd, const char* buffer, size_t buf_len, |
50 const IPAddressNumber& self_address, | 51 const IPAddressNumber& self_address, |
51 const IPEndPoint& peer_address, | 52 const IPEndPoint& peer_address, |
52 int* error); | 53 int* error); |
53 }; | 54 }; |
54 | 55 |
| 56 } // namespace tools |
55 } // namespace net | 57 } // namespace net |
56 | 58 |
57 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ | 59 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ |
OLD | NEW |