| 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 helpers for quic. | 5 // Some helpers for quic. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_QUIC_UTILS_H_ | 7 #ifndef NET_QUIC_QUIC_UTILS_H_ |
| 8 #define NET_QUIC_QUIC_UTILS_H_ | 8 #define NET_QUIC_QUIC_UTILS_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // | 49 // |
| 50 // If |out_index| is non-nullptr and a match is found then the index of that | 50 // If |out_index| is non-nullptr and a match is found then the index of that |
| 51 // match in |their_tags| is written to |out_index|. | 51 // match in |their_tags| is written to |out_index|. |
| 52 static bool FindMutualTag(const QuicTagVector& our_tags, | 52 static bool FindMutualTag(const QuicTagVector& our_tags, |
| 53 const QuicTag* their_tags, | 53 const QuicTag* their_tags, |
| 54 size_t num_their_tags, | 54 size_t num_their_tags, |
| 55 Priority priority, | 55 Priority priority, |
| 56 QuicTag* out_result, | 56 QuicTag* out_result, |
| 57 size_t* out_index); | 57 size_t* out_index); |
| 58 | 58 |
| 59 // SerializeUint128 writes |v| in little-endian form to |out|. | |
| 60 static void SerializeUint128(uint128 v, uint8* out); | |
| 61 | |
| 62 // SerializeUint128 writes the first 96 bits of |v| in little-endian form | 59 // SerializeUint128 writes the first 96 bits of |v| in little-endian form |
| 63 // to |out|. | 60 // to |out|. |
| 64 static void SerializeUint128Short(uint128 v, uint8* out); | 61 static void SerializeUint128Short(uint128 v, uint8* out); |
| 65 | 62 |
| 66 // Returns the name of the QuicRstStreamErrorCode as a char* | 63 // Returns the name of the QuicRstStreamErrorCode as a char* |
| 67 static const char* StreamErrorToString(QuicRstStreamErrorCode error); | 64 static const char* StreamErrorToString(QuicRstStreamErrorCode error); |
| 68 | 65 |
| 69 // Returns the name of the QuicErrorCode as a char* | 66 // Returns the name of the QuicErrorCode as a char* |
| 70 static const char* ErrorToString(QuicErrorCode error); | 67 static const char* ErrorToString(QuicErrorCode error); |
| 71 | 68 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 90 // tcpdump's -X and -XX options: | 87 // tcpdump's -X and -XX options: |
| 91 // "0x0000: 0090 69bd 5400 000d 610f 0189 0800 4500 ..i.T...a.....E.\n" | 88 // "0x0000: 0090 69bd 5400 000d 610f 0189 0800 4500 ..i.T...a.....E.\n" |
| 92 // "0x0010: 001c fb98 4000 4001 7e18 d8ef 2301 455d ....@.@.~...#.E]\n" | 89 // "0x0010: 001c fb98 4000 4001 7e18 d8ef 2301 455d ....@.@.~...#.E]\n" |
| 93 // "0x0020: 7fe2 0800 6bcb 0bc6 806e ....k....n\n" | 90 // "0x0020: 7fe2 0800 6bcb 0bc6 806e ....k....n\n" |
| 94 static std::string StringToHexASCIIDump(base::StringPiece in_buffer); | 91 static std::string StringToHexASCIIDump(base::StringPiece in_buffer); |
| 95 | 92 |
| 96 static char* AsChars(unsigned char* data) { | 93 static char* AsChars(unsigned char* data) { |
| 97 return reinterpret_cast<char*>(data); | 94 return reinterpret_cast<char*>(data); |
| 98 } | 95 } |
| 99 | 96 |
| 100 static QuicPriority LowestPriority(); | |
| 101 | |
| 102 static QuicPriority HighestPriority(); | 97 static QuicPriority HighestPriority(); |
| 103 | 98 |
| 104 private: | 99 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(QuicUtils); | 100 DISALLOW_COPY_AND_ASSIGN(QuicUtils); |
| 106 }; | 101 }; |
| 107 | 102 |
| 108 // Utility function that returns an IOVector object wrapped around |str|. | 103 // Utility function that returns an IOVector object wrapped around |str|. |
| 109 inline IOVector MakeIOVector(base::StringPiece str) { | 104 inline IOVector MakeIOVector(base::StringPiece str) { |
| 110 IOVector iov; | 105 IOVector iov; |
| 111 iov.Append(const_cast<char*>(str.data()), str.size()); | 106 iov.Append(const_cast<char*>(str.data()), str.size()); |
| 112 return iov; | 107 return iov; |
| 113 } | 108 } |
| 114 | 109 |
| 115 } // namespace net | 110 } // namespace net |
| 116 | 111 |
| 117 #endif // NET_QUIC_QUIC_UTILS_H_ | 112 #endif // NET_QUIC_QUIC_UTILS_H_ |
| OLD | NEW |