| 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_DNS_DNS_PROTOCOL_H_ | 5 #ifndef NET_DNS_DNS_PROTOCOL_H_ |
| 6 #define NET_DNS_DNS_PROTOCOL_H_ | 6 #define NET_DNS_DNS_PROTOCOL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
| 9 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| 10 | 11 |
| 11 namespace net { | 12 namespace net { |
| 12 | 13 |
| 13 namespace dns_protocol { | 14 namespace dns_protocol { |
| 14 | 15 |
| 15 static const uint16 kDefaultPort = 53; | 16 static const uint16_t kDefaultPort = 53; |
| 16 static const uint16 kDefaultPortMulticast = 5353; | 17 static const uint16_t kDefaultPortMulticast = 5353; |
| 17 | 18 |
| 18 // DNS packet consists of a header followed by questions and/or answers. | 19 // DNS packet consists of a header followed by questions and/or answers. |
| 19 // For the meaning of specific fields, please see RFC 1035 and 2535 | 20 // For the meaning of specific fields, please see RFC 1035 and 2535 |
| 20 | 21 |
| 21 // Header format. | 22 // Header format. |
| 22 // 1 1 1 1 1 1 | 23 // 1 1 1 1 1 1 |
| 23 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | 24 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
| 24 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 25 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
| 25 // | ID | | 26 // | ID | |
| 26 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 27 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 67 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
| 67 // | RDLENGTH | | 68 // | RDLENGTH | |
| 68 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| | 69 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| |
| 69 // / RDATA / | 70 // / RDATA / |
| 70 // / / | 71 // / / |
| 71 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 72 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
| 72 | 73 |
| 73 #pragma pack(push) | 74 #pragma pack(push) |
| 74 #pragma pack(1) | 75 #pragma pack(1) |
| 75 | 76 |
| 76 // On-the-wire header. All uint16 are in network order. | 77 // On-the-wire header. All uint16_t are in network order. |
| 77 // Used internally in DnsQuery and DnsResponse. | 78 // Used internally in DnsQuery and DnsResponse. |
| 78 struct NET_EXPORT_PRIVATE Header { | 79 struct NET_EXPORT_PRIVATE Header { |
| 79 uint16 id; | 80 uint16_t id; |
| 80 uint16 flags; | 81 uint16_t flags; |
| 81 uint16 qdcount; | 82 uint16_t qdcount; |
| 82 uint16 ancount; | 83 uint16_t ancount; |
| 83 uint16 nscount; | 84 uint16_t nscount; |
| 84 uint16 arcount; | 85 uint16_t arcount; |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 #pragma pack(pop) | 88 #pragma pack(pop) |
| 88 | 89 |
| 89 static const uint8 kLabelMask = 0xc0; | 90 static const uint8_t kLabelMask = 0xc0; |
| 90 static const uint8 kLabelPointer = 0xc0; | 91 static const uint8_t kLabelPointer = 0xc0; |
| 91 static const uint8 kLabelDirect = 0x0; | 92 static const uint8_t kLabelDirect = 0x0; |
| 92 static const uint16 kOffsetMask = 0x3fff; | 93 static const uint16_t kOffsetMask = 0x3fff; |
| 93 | 94 |
| 94 // In MDns the most significant bit of the rrclass is designated as the | 95 // In MDns the most significant bit of the rrclass is designated as the |
| 95 // "cache-flush bit", as described in http://www.rfc-editor.org/rfc/rfc6762.txt | 96 // "cache-flush bit", as described in http://www.rfc-editor.org/rfc/rfc6762.txt |
| 96 // section 10.2. | 97 // section 10.2. |
| 97 static const uint16 kMDnsClassMask = 0x7FFF; | 98 static const uint16_t kMDnsClassMask = 0x7FFF; |
| 98 | 99 |
| 99 static const int kMaxNameLength = 255; | 100 static const int kMaxNameLength = 255; |
| 100 | 101 |
| 101 // RFC 1035, section 4.2.1: Messages carried by UDP are restricted to 512 | 102 // RFC 1035, section 4.2.1: Messages carried by UDP are restricted to 512 |
| 102 // bytes (not counting the IP nor UDP headers). | 103 // bytes (not counting the IP nor UDP headers). |
| 103 static const int kMaxUDPSize = 512; | 104 static const int kMaxUDPSize = 512; |
| 104 | 105 |
| 105 // RFC 6762, section 17: Messages over the local link are restricted by the | 106 // RFC 6762, section 17: Messages over the local link are restricted by the |
| 106 // medium's MTU, and must be under 9000 bytes | 107 // medium's MTU, and must be under 9000 bytes |
| 107 static const int kMaxMulticastSize = 9000; | 108 static const int kMaxMulticastSize = 9000; |
| 108 | 109 |
| 109 // DNS class types. | 110 // DNS class types. |
| 110 static const uint16 kClassIN = 1; | 111 static const uint16_t kClassIN = 1; |
| 111 | 112 |
| 112 // DNS resource record types. See | 113 // DNS resource record types. See |
| 113 // http://www.iana.org/assignments/dns-parameters | 114 // http://www.iana.org/assignments/dns-parameters |
| 114 static const uint16 kTypeA = 1; | 115 static const uint16_t kTypeA = 1; |
| 115 static const uint16 kTypeCNAME = 5; | 116 static const uint16_t kTypeCNAME = 5; |
| 116 static const uint16 kTypePTR = 12; | 117 static const uint16_t kTypePTR = 12; |
| 117 static const uint16 kTypeTXT = 16; | 118 static const uint16_t kTypeTXT = 16; |
| 118 static const uint16 kTypeAAAA = 28; | 119 static const uint16_t kTypeAAAA = 28; |
| 119 static const uint16 kTypeSRV = 33; | 120 static const uint16_t kTypeSRV = 33; |
| 120 static const uint16 kTypeNSEC = 47; | 121 static const uint16_t kTypeNSEC = 47; |
| 121 | |
| 122 | 122 |
| 123 // DNS rcode values. | 123 // DNS rcode values. |
| 124 static const uint8 kRcodeMask = 0xf; | 124 static const uint8_t kRcodeMask = 0xf; |
| 125 static const uint8 kRcodeNOERROR = 0; | 125 static const uint8_t kRcodeNOERROR = 0; |
| 126 static const uint8 kRcodeFORMERR = 1; | 126 static const uint8_t kRcodeFORMERR = 1; |
| 127 static const uint8 kRcodeSERVFAIL = 2; | 127 static const uint8_t kRcodeSERVFAIL = 2; |
| 128 static const uint8 kRcodeNXDOMAIN = 3; | 128 static const uint8_t kRcodeNXDOMAIN = 3; |
| 129 static const uint8 kRcodeNOTIMP = 4; | 129 static const uint8_t kRcodeNOTIMP = 4; |
| 130 static const uint8 kRcodeREFUSED = 5; | 130 static const uint8_t kRcodeREFUSED = 5; |
| 131 | 131 |
| 132 // DNS flags. | 132 // DNS flags. |
| 133 static const uint16 kFlagResponse = 0x8000; | 133 static const uint16_t kFlagResponse = 0x8000; |
| 134 static const uint16 kFlagRA = 0x80; | 134 static const uint16_t kFlagRA = 0x80; |
| 135 static const uint16 kFlagRD = 0x100; | 135 static const uint16_t kFlagRD = 0x100; |
| 136 static const uint16 kFlagTC = 0x200; | 136 static const uint16_t kFlagTC = 0x200; |
| 137 static const uint16 kFlagAA = 0x400; | 137 static const uint16_t kFlagAA = 0x400; |
| 138 | 138 |
| 139 } // namespace dns_protocol | 139 } // namespace dns_protocol |
| 140 | 140 |
| 141 } // namespace net | 141 } // namespace net |
| 142 | 142 |
| 143 #endif // NET_DNS_DNS_PROTOCOL_H_ | 143 #endif // NET_DNS_DNS_PROTOCOL_H_ |
| OLD | NEW |