OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_DNS_RECORD_RDATA_H_ | 5 #ifndef NET_DNS_RECORD_RDATA_H_ |
6 #define NET_DNS_RECORD_RDATA_H_ | 6 #define NET_DNS_RECORD_RDATA_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/logging.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
17 #include "net/base/ip_address.h" | 18 #include "net/base/ip_address.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
19 #include "net/dns/dns_protocol.h" | 20 #include "net/dns/dns_protocol.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
23 class DnsRecordParser; | 24 class DnsRecordParser; |
24 | 25 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 public: | 192 public: |
192 static const uint16_t kType = dns_protocol::kTypeNSEC; | 193 static const uint16_t kType = dns_protocol::kTypeNSEC; |
193 | 194 |
194 ~NsecRecordRdata() override; | 195 ~NsecRecordRdata() override; |
195 static std::unique_ptr<NsecRecordRdata> Create(const base::StringPiece& data, | 196 static std::unique_ptr<NsecRecordRdata> Create(const base::StringPiece& data, |
196 const DnsRecordParser& parser); | 197 const DnsRecordParser& parser); |
197 bool IsEqual(const RecordRdata* other) const override; | 198 bool IsEqual(const RecordRdata* other) const override; |
198 uint16_t Type() const override; | 199 uint16_t Type() const override; |
199 | 200 |
200 // Length of the bitmap in bits. | 201 // Length of the bitmap in bits. |
201 unsigned bitmap_length() const { return bitmap_.size() * 8; } | 202 // This will be between 8 and 256, per RFC 3845, Section 2.1.2. |
| 203 uint16_t bitmap_length() const { |
| 204 DCHECK_LE(bitmap_.size(), 32u); |
| 205 return static_cast<uint16_t>(bitmap_.size() * 8); |
| 206 } |
202 | 207 |
203 // Returns bit i-th bit in the bitmap, where bits withing a byte are organized | 208 // Returns bit i-th bit in the bitmap, where bits withing a byte are organized |
204 // most to least significant. If it is set, a record with rrtype i exists for | 209 // most to least significant. If it is set, a record with rrtype i exists for |
205 // the domain name of this nsec record. | 210 // the domain name of this nsec record. |
206 bool GetBit(unsigned i) const; | 211 bool GetBit(unsigned i) const; |
207 | 212 |
208 private: | 213 private: |
209 NsecRecordRdata(); | 214 NsecRecordRdata(); |
210 | 215 |
211 std::vector<uint8_t> bitmap_; | 216 std::vector<uint8_t> bitmap_; |
212 | 217 |
213 DISALLOW_COPY_AND_ASSIGN(NsecRecordRdata); | 218 DISALLOW_COPY_AND_ASSIGN(NsecRecordRdata); |
214 }; | 219 }; |
215 | 220 |
216 | 221 |
217 } // namespace net | 222 } // namespace net |
218 | 223 |
219 #endif // NET_DNS_RECORD_RDATA_H_ | 224 #endif // NET_DNS_RECORD_RDATA_H_ |
OLD | NEW |