| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 char* buffer, | 53 char* buffer, |
| 54 size_t buf_len, | 54 size_t buf_len, |
| 55 uint32* dropped_packets, | 55 uint32* dropped_packets, |
| 56 IPAddressNumber* self_address, | 56 IPAddressNumber* self_address, |
| 57 IPEndPoint* peer_address); | 57 IPEndPoint* peer_address); |
| 58 | 58 |
| 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, |
| 64 const char* buffer, |
| 65 size_t buf_len, |
| 64 const IPAddressNumber& self_address, | 66 const IPAddressNumber& self_address, |
| 65 const IPEndPoint& peer_address); | 67 const IPEndPoint& peer_address); |
| 66 | 68 |
| 67 // A helper for WritePacket which fills in the cmsg with the supplied self | 69 // A helper for WritePacket which fills in the cmsg with the supplied self |
| 68 // address. | 70 // address. |
| 69 // Returns the length of the packet info structure used. | 71 // Returns the length of the packet info structure used. |
| 70 static size_t SetIpInfoInCmsg(const IPAddressNumber& self_address, | 72 static size_t SetIpInfoInCmsg(const IPAddressNumber& self_address, |
| 71 cmsghdr* cmsg); | 73 cmsghdr* cmsg); |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(QuicSocketUtils); | 76 DISALLOW_COPY_AND_ASSIGN(QuicSocketUtils); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 } // namespace tools | 79 } // namespace tools |
| 78 } // namespace net | 80 } // namespace net |
| 79 | 81 |
| 80 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ | 82 #endif // NET_TOOLS_QUIC_QUIC_SOCKET_UTILS_H_ |
| OLD | NEW |