| 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 #ifndef NET_QUIC_CORE_QUIC_UTILS_H_ | 5 #ifndef NET_QUIC_CORE_QUIC_UTILS_H_ |
| 6 #define NET_QUIC_CORE_QUIC_UTILS_H_ | 6 #define NET_QUIC_CORE_QUIC_UTILS_H_ |
| 7 | 7 |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <cstdint> | 9 #include <cstdint> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // 7 bytes of |packet_number|. | 58 // 7 bytes of |packet_number|. |
| 59 static uint64_t PackPathIdAndPacketNumber(QuicPathId path_id, | 59 static uint64_t PackPathIdAndPacketNumber(QuicPathId path_id, |
| 60 QuicPacketNumber packet_number); | 60 QuicPacketNumber packet_number); |
| 61 | 61 |
| 62 // Determines and returns change type of address change from |old_address| to | 62 // Determines and returns change type of address change from |old_address| to |
| 63 // |new_address|. | 63 // |new_address|. |
| 64 static PeerAddressChangeType DetermineAddressChangeType( | 64 static PeerAddressChangeType DetermineAddressChangeType( |
| 65 const QuicSocketAddress& old_address, | 65 const QuicSocketAddress& old_address, |
| 66 const QuicSocketAddress& new_address); | 66 const QuicSocketAddress& new_address); |
| 67 | 67 |
| 68 // This converts |length| bytes of binary to a 2*|length|-character | |
| 69 // hexadecimal representation. | |
| 70 // Return value: 2*|length| characters of ASCII std::string. | |
| 71 static std::string HexEncode(const char* data, size_t length); | |
| 72 static std::string HexEncode(base::StringPiece data); | |
| 73 | |
| 74 // Converts |data| from a hexadecimal ASCII std::string to binary. | |
| 75 static std::string HexDecode(base::StringPiece data); | |
| 76 | |
| 77 // Returns a std::string containing hex and ASCII representations of |binary|, | |
| 78 // side-by-side in the style of hexdump. Non-printable characters will be | |
| 79 // printed as '.' in the ASCII output. | |
| 80 // For example: | |
| 81 // "0x0000: 4865 6c6c 6f2c 2051 5549 4321 0102 0304 Hello,.QUIC!...." | |
| 82 static std::string HexDump(base::StringPiece binary_data); | |
| 83 | |
| 84 private: | 68 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(QuicUtils); | 69 DISALLOW_COPY_AND_ASSIGN(QuicUtils); |
| 86 }; | 70 }; |
| 87 | 71 |
| 88 } // namespace net | 72 } // namespace net |
| 89 | 73 |
| 90 #endif // NET_QUIC_CORE_QUIC_UTILS_H_ | 74 #endif // NET_QUIC_CORE_QUIC_UTILS_H_ |
| OLD | NEW |