blob: 76e9b37fe331521b172cc40b0278b4dd3127b4c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_DNS_RECORD_RDATA_H_
#define NET_DNS_RECORD_RDATA_H_
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "net/base/big_endian.h"
#include "net/base/net_export.h"
#include "net/base/net_util.h"
#include "net/dns/dns_protocol.h"
namespace net {
class DnsRecordParser;
// Parsed represenation of the extra data in a record. Does not include standard
// DNS record data such as TTL, Name, Type and Class.
class NET_EXPORT_PRIVATE RecordRdata {
public:
virtual ~RecordRdata() {}
protected:
RecordRdata();
DISALLOW_COPY_AND_ASSIGN(RecordRdata);
};
// SRV record format (http://www.ietf.org/rfc/rfc2782.txt):
// 2 bytes network-order unsigned priority
// 2 bytes network-order unsigned weight
// 2 bytes network-order unsigned port
// target: domain name (on-the-wire representation)
class NET_EXPORT_PRIVATE SrvRecordRdata : public RecordRdata {
public:
static const uint16 kType = dns_protocol::kTypeSRV;
virtual ~SrvRecordRdata();
static scoped_ptr<SrvRecordRdata> Create(const base::StringPiece& data,
const DnsRecordParser& parser);
uint16 priority() const { return priority_; }
uint16 weight() const { return weight_; }
uint16 port() const { return port_; }
const std::string& target() const { return target_; }
private:
SrvRecordRdata();
uint16 priority_;
uint16 weight_;
uint16 port_;
std::string target_;
DISALLOW_COPY_AND_ASSIGN(SrvRecordRdata);
};
// A Record format (http://www.ietf.org/rfc/rfc1035.txt):
// 4 bytes for IP address.
class NET_EXPORT_PRIVATE ARecordRdata : public RecordRdata {
public:
static const uint16 kType = dns_protocol::kTypeA;
virtual ~ARecordRdata();
static scoped_ptr<ARecordRdata> Create(const base::StringPiece& data,
const DnsRecordParser& parser);
const IPAddressNumber& address() const { return address_; }
private:
ARecordRdata();
IPAddressNumber address_;
DISALLOW_COPY_AND_ASSIGN(ARecordRdata);
};
// CNAME record format (http://www.ietf.org/rfc/rfc1035.txt):
// cname: On the wire representation of domain name.
class NET_EXPORT_PRIVATE CnameRecordRdata : public RecordRdata {
public:
static const uint16 kType = dns_protocol::kTypeCNAME;
virtual ~CnameRecordRdata();
static scoped_ptr<CnameRecordRdata> Create(const base::StringPiece& data,
const DnsRecordParser& parser);
std::string cname() const { return cname_; }
private:
CnameRecordRdata();
std::string cname_;
DISALLOW_COPY_AND_ASSIGN(CnameRecordRdata);
};
// PTR record format (http://www.ietf.org/rfc/rfc1035.txt):
// domain: On the wire representation of domain name.
class NET_EXPORT_PRIVATE PtrRecordRdata : public RecordRdata {
public:
static const uint16 kType = dns_protocol::kTypePTR;
virtual ~PtrRecordRdata();
static scoped_ptr<PtrRecordRdata> Create(const base::StringPiece& data,
const DnsRecordParser& parser);
std::string ptrdomain() const { return ptrdomain_; }
private:
PtrRecordRdata();
std::string ptrdomain_;
DISALLOW_COPY_AND_ASSIGN(PtrRecordRdata);
};
// TXT record format (http://www.ietf.org/rfc/rfc1035.txt):
// texts: One or more <character-string>s.
// a <character-string> is a length octet followed by as many characters.
class NET_EXPORT_PRIVATE TxtRecordRdata : public RecordRdata {
public:
static const uint16 kType = dns_protocol::kTypeTXT;
virtual ~TxtRecordRdata();
static scoped_ptr<TxtRecordRdata> Create(const base::StringPiece& data,
const DnsRecordParser& parser);
const std::vector<std::string>& texts() const { return texts_; }
private:
TxtRecordRdata();
std::vector<std::string> texts_;
DISALLOW_COPY_AND_ASSIGN(TxtRecordRdata);
};
}
#endif // NET_DNS_RECORD_RDATA_H_
|