Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_DNS_DNS_PROTOCOL_H_ | |
| 6 #define NET_DNS_DNS_PROTOCOL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "net/base/bigendian.h" | |
| 11 #include "net/base/net_export.h" | |
| 12 | |
| 13 namespace net { | |
|
mmenke
2011/12/02 00:53:55
nit: Google style is to have an empty line here.
szym
2011/12/05 23:06:28
Done.
| |
| 14 namespace dns_protocol { | |
| 15 | |
| 16 // DNS packet consists of a header followed by questions and/or answers. | |
| 17 // For the meaning of specific fields, please see RFC 1035 and 2535 | |
| 18 | |
| 19 // Header format. | |
| 20 // 1 1 1 1 1 1 | |
| 21 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
| 22 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 23 // | ID | | |
| 24 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 25 // |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE | | |
| 26 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 27 // | QDCOUNT | | |
| 28 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 29 // | ANCOUNT | | |
| 30 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 31 // | NSCOUNT | | |
| 32 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 33 // | ARCOUNT | | |
| 34 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 35 | |
| 36 // Question format. | |
| 37 // 1 1 1 1 1 1 | |
| 38 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
| 39 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 40 // | | | |
| 41 // / QNAME / | |
| 42 // / / | |
| 43 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 44 // | QTYPE | | |
| 45 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 46 // | QCLASS | | |
| 47 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 48 | |
| 49 // Answer format. | |
| 50 // 1 1 1 1 1 1 | |
| 51 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
| 52 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 53 // | | | |
| 54 // / / | |
| 55 // / NAME / | |
| 56 // | | | |
| 57 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 58 // | TYPE | | |
| 59 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 60 // | CLASS | | |
| 61 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 62 // | TTL | | |
| 63 // | | | |
| 64 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 65 // | RDLENGTH | | |
| 66 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| | |
| 67 // / RDATA / | |
| 68 // / / | |
| 69 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| 70 | |
| 71 #pragma pack(push) | |
| 72 #pragma pack(1) | |
| 73 | |
| 74 // On-the-wire header. All uint16 are in network order. | |
| 75 // Used internally in DnsQuery and DnsResponseParser | |
|
mmenke
2011/12/02 00:53:55
nit: Missing period.
szym
2011/12/05 23:06:28
Done.
| |
| 76 struct NET_EXPORT_PRIVATE Header { | |
| 77 uint16 id; | |
| 78 uint8 flags[2]; | |
| 79 uint16 qdcount; | |
| 80 uint16 ancount; | |
| 81 uint16 nscount; | |
| 82 uint16 arcount; | |
| 83 }; | |
| 84 | |
| 85 #pragma pack(pop) | |
| 86 | |
| 87 static const uint8 kLabelMask = 0xc0; | |
| 88 static const uint8 kLabelPointer = 0xc0; | |
| 89 static const uint8 kLabelDirect = 0x0; | |
| 90 static const uint16 kOffsetMask = 0x3fff; | |
| 91 | |
| 92 static const int kMaxNameLength = 255; | |
| 93 | |
| 94 // RFC 1035, section 4.2.1: Messages carried by UDP are restricted to 512 | |
| 95 // bytes (not counting the IP nor UDP headers). | |
| 96 static const int kMaxUDPSize = 512; | |
| 97 | |
| 98 // DNS class types. | |
| 99 static const uint16 kClassIN = 1; | |
| 100 | |
| 101 // DNS resource record types. See | |
| 102 // http://www.iana.org/assignments/dns-parameters | |
| 103 static const uint16 kTypeA = 1; | |
| 104 static const uint16 kTypeCNAME = 5; | |
| 105 static const uint16 kTypeTXT = 16; | |
| 106 static const uint16 kTypeAAAA = 28; | |
| 107 | |
| 108 // DNS rcode values. | |
| 109 static const uint8 kRcodeMask = 0xf; | |
| 110 static const uint8 kRcodeNOERROR = 0; | |
| 111 static const uint8 kRcodeFORMERR = 1; | |
| 112 static const uint8 kRcodeSERVFAIL = 2; | |
| 113 static const uint8 kRcodeNXDOMAIN = 3; | |
| 114 static const uint8 kRcodeNOTIMP = 4; | |
| 115 static const uint8 kRcodeREFUSED = 5; | |
| 116 | |
| 117 } // namespace dns_protocol | |
|
mmenke
2011/12/02 00:53:55
nit: add a blank line.
szym
2011/12/05 23:06:28
Done.
| |
| 118 } // namespace net | |
| 119 | |
| 120 #endif // NET_DNS_DNS_PROTOCOL_H_ | |
| 121 | |
| OLD | NEW |