| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_DNS_UTIL_H_ | 5 #ifndef NET_BASE_DNS_UTIL_H_ |
| 6 #define NET_BASE_DNS_UTIL_H_ | 6 #define NET_BASE_DNS_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/string_piece.h" |
| 12 #include "net/base/net_api.h" | 13 #include "net/base/net_api.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's | 17 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's |
| 17 // public domain DNS library. | 18 // public domain DNS library. |
| 18 // | 19 // |
| 19 // dotted: a string in dotted form: "www.google.com" | 20 // dotted: a string in dotted form: "www.google.com" |
| 20 // out: a result in DNS form: "\x03www\x06google\x03com\x00" | 21 // out: a result in DNS form: "\x03www\x06google\x03com\x00" |
| 21 NET_TEST bool DNSDomainFromDot(const std::string& dotted, std::string* out); | 22 NET_TEST bool DNSDomainFromDot(const std::string& dotted, std::string* out); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 | 48 |
| 48 // http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml | 49 // http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml |
| 49 static const uint8 kDNSSEC_RSA_SHA1 = 5; | 50 static const uint8 kDNSSEC_RSA_SHA1 = 5; |
| 50 static const uint8 kDNSSEC_RSA_SHA1_NSEC3 = 7; | 51 static const uint8 kDNSSEC_RSA_SHA1_NSEC3 = 7; |
| 51 static const uint8 kDNSSEC_RSA_SHA256 = 8; | 52 static const uint8 kDNSSEC_RSA_SHA256 = 8; |
| 52 | 53 |
| 53 // RFC 4509 | 54 // RFC 4509 |
| 54 static const uint8 kDNSSEC_SHA1 = 1; | 55 static const uint8 kDNSSEC_SHA1 = 1; |
| 55 static const uint8 kDNSSEC_SHA256 = 2; | 56 static const uint8 kDNSSEC_SHA256 = 2; |
| 56 | 57 |
| 58 // A Buffer is used for walking over a DNS response packet. |
| 59 class DnsResponseBuffer { |
| 60 public: |
| 61 DnsResponseBuffer(const uint8* p, unsigned len) |
| 62 : p_(p), |
| 63 packet_(p), |
| 64 len_(len), |
| 65 packet_len_(len) { |
| 66 } |
| 67 |
| 68 bool U8(uint8* v); |
| 69 bool U16(uint16* v); |
| 70 bool U32(uint32* v); |
| 71 bool Skip(unsigned n); |
| 72 |
| 73 bool Block(base::StringPiece* out, unsigned len); |
| 74 |
| 75 // DNSName parses a (possibly compressed) DNS name from the packet. If |name| |
| 76 // is not NULL, then the name is written into it. See RFC 1035 section 4.1.4. |
| 77 bool DNSName(std::string* name); |
| 78 |
| 79 private: |
| 80 const uint8* p_; |
| 81 const uint8* const packet_; |
| 82 unsigned len_; |
| 83 const unsigned packet_len_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(DnsResponseBuffer); |
| 86 }; |
| 87 |
| 88 |
| 57 } // namespace net | 89 } // namespace net |
| 58 | 90 |
| 59 #endif // NET_BASE_DNS_UTIL_H_ | 91 #endif // NET_BASE_DNS_UTIL_H_ |
| OLD | NEW |