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> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Writes buf_len to the socket. If writing is successful, sets the result's | 59 // Writes buf_len to the socket. If writing is successful, sets the result's |
60 // status to WRITE_STATUS_OK and sets bytes_written. Otherwise sets the | 60 // status to WRITE_STATUS_OK and sets bytes_written. Otherwise sets the |
61 // result's status to WRITE_STATUS_BLOCKED or WRITE_STATUS_ERROR and sets | 61 // result's status to WRITE_STATUS_BLOCKED or WRITE_STATUS_ERROR and sets |
62 // error_code to errno. | 62 // error_code to errno. |
63 static WriteResult WritePacket(int fd, const char* buffer, size_t buf_len, | 63 static WriteResult WritePacket(int fd, const char* buffer, size_t buf_len, |
64 const IPAddressNumber& self_address, | 64 const IPAddressNumber& self_address, |
65 const IPEndPoint& peer_address); | 65 const IPEndPoint& peer_address); |
66 | 66 |
67 // A helper for WritePacket which fills in the cmsg with the supplied self | 67 // A helper for WritePacket which fills in the cmsg with the supplied self |
68 // address. | 68 // address. |
69 static void SetIpInfoInCmsg(const IPAddressNumber& self_address, | 69 // Returns the length of the packet info structure used. |
70 cmsghdr* cmsg); | 70 static size_t SetIpInfoInCmsg(const IPAddressNumber& self_address, |
| 71 cmsghdr* cmsg); |
71 | 72 |
72 private: | 73 private: |
73 DISALLOW_COPY_AND_ASSIGN(QuicSocketUtils); | 74 DISALLOW_COPY_AND_ASSIGN(QuicSocketUtils); |
74 }; | 75 }; |
75 | 76 |
76 } // namespace tools | 77 } // namespace tools |
77 } // namespace net | 78 } // namespace net |
78 | 79 |
79 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ | 80 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ |
OLD | NEW |