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 <stddef.h> |
| 11 #include <stdint.h> |
| 12 |
10 #include <string> | 13 #include <string> |
11 | 14 |
| 15 #include "base/macros.h" |
12 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
13 #include "net/base/int128.h" | 17 #include "net/base/int128.h" |
14 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
15 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
16 | 20 |
17 namespace net { | 21 namespace net { |
18 | 22 |
19 class NET_EXPORT_PRIVATE QuicUtils { | 23 class NET_EXPORT_PRIVATE QuicUtils { |
20 public: | 24 public: |
21 enum Priority { | 25 enum Priority { |
22 LOCAL_PRIORITY, | 26 LOCAL_PRIORITY, |
23 PEER_PRIORITY, | 27 PEER_PRIORITY, |
24 }; | 28 }; |
25 | 29 |
26 // Returns the 64 bit FNV1a hash of the data. See | 30 // Returns the 64 bit FNV1a hash of the data. See |
27 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param | 31 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
28 static uint64 FNV1a_64_Hash(const char* data, int len); | 32 static uint64_t FNV1a_64_Hash(const char* data, int len); |
29 | 33 |
30 // returns the 128 bit FNV1a hash of the data. See | 34 // returns the 128 bit FNV1a hash of the data. See |
31 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param | 35 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
32 static uint128 FNV1a_128_Hash(const char* data1, int len1); | 36 static uint128 FNV1a_128_Hash(const char* data1, int len1); |
33 | 37 |
34 // returns the 128 bit FNV1a hash of the two sequences of data. See | 38 // returns the 128 bit FNV1a hash of the two sequences of data. See |
35 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param | 39 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
36 static uint128 FNV1a_128_Hash_Two(const char* data1, | 40 static uint128 FNV1a_128_Hash_Two(const char* data1, |
37 int len1, | 41 int len1, |
38 const char* data2, | 42 const char* data2, |
(...skipping 13 matching lines...) Expand all Loading... |
52 // match in |their_tags| is written to |out_index|. | 56 // match in |their_tags| is written to |out_index|. |
53 static bool FindMutualTag(const QuicTagVector& our_tags, | 57 static bool FindMutualTag(const QuicTagVector& our_tags, |
54 const QuicTag* their_tags, | 58 const QuicTag* their_tags, |
55 size_t num_their_tags, | 59 size_t num_their_tags, |
56 Priority priority, | 60 Priority priority, |
57 QuicTag* out_result, | 61 QuicTag* out_result, |
58 size_t* out_index); | 62 size_t* out_index); |
59 | 63 |
60 // SerializeUint128 writes the first 96 bits of |v| in little-endian form | 64 // SerializeUint128 writes the first 96 bits of |v| in little-endian form |
61 // to |out|. | 65 // to |out|. |
62 static void SerializeUint128Short(uint128 v, uint8* out); | 66 static void SerializeUint128Short(uint128 v, uint8_t* out); |
63 | 67 |
64 // Returns the name of the QuicRstStreamErrorCode as a char* | 68 // Returns the name of the QuicRstStreamErrorCode as a char* |
65 static const char* StreamErrorToString(QuicRstStreamErrorCode error); | 69 static const char* StreamErrorToString(QuicRstStreamErrorCode error); |
66 | 70 |
67 // Returns the name of the QuicErrorCode as a char* | 71 // Returns the name of the QuicErrorCode as a char* |
68 static const char* ErrorToString(QuicErrorCode error); | 72 static const char* ErrorToString(QuicErrorCode error); |
69 | 73 |
70 // Returns the level of encryption as a char* | 74 // Returns the level of encryption as a char* |
71 static const char* EncryptionLevelToString(EncryptionLevel level); | 75 static const char* EncryptionLevelToString(EncryptionLevel level); |
72 | 76 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { | 108 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { |
105 iov->iov_base = const_cast<char*>(str.data()); | 109 iov->iov_base = const_cast<char*>(str.data()); |
106 iov->iov_len = static_cast<size_t>(str.size()); | 110 iov->iov_len = static_cast<size_t>(str.size()); |
107 QuicIOVector quic_iov(iov, 1, str.size()); | 111 QuicIOVector quic_iov(iov, 1, str.size()); |
108 return quic_iov; | 112 return quic_iov; |
109 } | 113 } |
110 | 114 |
111 } // namespace net | 115 } // namespace net |
112 | 116 |
113 #endif // NET_QUIC_QUIC_UTILS_H_ | 117 #endif // NET_QUIC_QUIC_UTILS_H_ |
OLD | NEW |