Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: net/dns/record_rdata.h

Issue 15733008: Multicast DNS implementation (initial) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_implementation2
Patch Set: Renamed files from "listener" to "client" Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 class DnsRecordParser; 22 class DnsRecordParser;
23 23
24 // Parsed represenation of the extra data in a record. Does not include standard 24 // Parsed represenation of the extra data in a record. Does not include standard
25 // DNS record data such as TTL, Name, Type and Class. 25 // DNS record data such as TTL, Name, Type and Class.
26 class NET_EXPORT_PRIVATE RecordRdata { 26 class NET_EXPORT_PRIVATE RecordRdata {
27 public: 27 public:
28 virtual ~RecordRdata() {} 28 virtual ~RecordRdata() {}
29 29
30 virtual bool IsEqual(const RecordRdata* other) const = 0; 30 virtual bool IsEqual(const RecordRdata* other) const = 0;
31 virtual uint16 Type() const = 0; 31 virtual uint16 Type() const = 0;
32 virtual scoped_ptr<const RecordRdata> Clone() const = 0;
32 33
33 protected: 34 protected:
34 RecordRdata(); 35 RecordRdata();
35 36
36 DISALLOW_COPY_AND_ASSIGN(RecordRdata); 37 DISALLOW_COPY_AND_ASSIGN(RecordRdata);
37 }; 38 };
38 39
39 // SRV record format (http://www.ietf.org/rfc/rfc2782.txt): 40 // SRV record format (http://www.ietf.org/rfc/rfc2782.txt):
40 // 2 bytes network-order unsigned priority 41 // 2 bytes network-order unsigned priority
41 // 2 bytes network-order unsigned weight 42 // 2 bytes network-order unsigned weight
42 // 2 bytes network-order unsigned port 43 // 2 bytes network-order unsigned port
43 // target: domain name (on-the-wire representation) 44 // target: domain name (on-the-wire representation)
44 class NET_EXPORT_PRIVATE SrvRecordRdata : public RecordRdata { 45 class NET_EXPORT_PRIVATE SrvRecordRdata : public RecordRdata {
45 public: 46 public:
46 static const uint16 kType = dns_protocol::kTypeSRV; 47 static const uint16 kType = dns_protocol::kTypeSRV;
47 48
48 virtual ~SrvRecordRdata(); 49 virtual ~SrvRecordRdata();
49 static scoped_ptr<SrvRecordRdata> Create(const base::StringPiece& data, 50 static scoped_ptr<SrvRecordRdata> Create(const base::StringPiece& data,
50 const DnsRecordParser& parser); 51 const DnsRecordParser& parser);
51 52
52 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; 53 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE;
53 virtual uint16 Type() const OVERRIDE; 54 virtual uint16 Type() const OVERRIDE;
55 virtual scoped_ptr<const RecordRdata> Clone() const OVERRIDE;
54 56
55 uint16 priority() const { return priority_; } 57 uint16 priority() const { return priority_; }
56 uint16 weight() const { return weight_; } 58 uint16 weight() const { return weight_; }
57 uint16 port() const { return port_; } 59 uint16 port() const { return port_; }
58 60
59 const std::string& target() const { return target_; } 61 const std::string& target() const { return target_; }
60 62
61 private: 63 private:
62 SrvRecordRdata(); 64 SrvRecordRdata();
63 65
(...skipping 10 matching lines...) Expand all
74 // 4 bytes for IP address. 76 // 4 bytes for IP address.
75 class NET_EXPORT_PRIVATE ARecordRdata : public RecordRdata { 77 class NET_EXPORT_PRIVATE ARecordRdata : public RecordRdata {
76 public: 78 public:
77 static const uint16 kType = dns_protocol::kTypeA; 79 static const uint16 kType = dns_protocol::kTypeA;
78 80
79 virtual ~ARecordRdata(); 81 virtual ~ARecordRdata();
80 static scoped_ptr<ARecordRdata> Create(const base::StringPiece& data, 82 static scoped_ptr<ARecordRdata> Create(const base::StringPiece& data,
81 const DnsRecordParser& parser); 83 const DnsRecordParser& parser);
82 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; 84 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE;
83 virtual uint16 Type() const OVERRIDE; 85 virtual uint16 Type() const OVERRIDE;
86 virtual scoped_ptr<const RecordRdata> Clone() const OVERRIDE;
84 87
85 const IPAddressNumber& address() const { return address_; } 88 const IPAddressNumber& address() const { return address_; }
86 89
87 private: 90 private:
88 ARecordRdata(); 91 ARecordRdata();
89 92
90 IPAddressNumber address_; 93 IPAddressNumber address_;
91 94
92 DISALLOW_COPY_AND_ASSIGN(ARecordRdata); 95 DISALLOW_COPY_AND_ASSIGN(ARecordRdata);
93 }; 96 };
94 97
95 // AAAA Record format (http://www.ietf.org/rfc/rfc1035.txt): 98 // AAAA Record format (http://www.ietf.org/rfc/rfc1035.txt):
96 // 16 bytes for IP address. 99 // 16 bytes for IP address.
97 class NET_EXPORT_PRIVATE AAAARecordRdata : public RecordRdata { 100 class NET_EXPORT_PRIVATE AAAARecordRdata : public RecordRdata {
98 public: 101 public:
99 static const uint16 kType = dns_protocol::kTypeAAAA; 102 static const uint16 kType = dns_protocol::kTypeAAAA;
100 103
101 virtual ~AAAARecordRdata(); 104 virtual ~AAAARecordRdata();
102 static scoped_ptr<AAAARecordRdata> Create(const base::StringPiece& data, 105 static scoped_ptr<AAAARecordRdata> Create(const base::StringPiece& data,
103 const DnsRecordParser& parser); 106 const DnsRecordParser& parser);
104 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; 107 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE;
105 virtual uint16 Type() const OVERRIDE; 108 virtual uint16 Type() const OVERRIDE;
109 virtual scoped_ptr<const RecordRdata> Clone() const OVERRIDE;
106 110
107 const IPAddressNumber& address() const { return address_; } 111 const IPAddressNumber& address() const { return address_; }
108 112
109 private: 113 private:
110 AAAARecordRdata(); 114 AAAARecordRdata();
111 115
112 IPAddressNumber address_; 116 IPAddressNumber address_;
113 117
114 DISALLOW_COPY_AND_ASSIGN(AAAARecordRdata); 118 DISALLOW_COPY_AND_ASSIGN(AAAARecordRdata);
115 }; 119 };
116 120
117 // CNAME record format (http://www.ietf.org/rfc/rfc1035.txt): 121 // CNAME record format (http://www.ietf.org/rfc/rfc1035.txt):
118 // cname: On the wire representation of domain name. 122 // cname: On the wire representation of domain name.
119 class NET_EXPORT_PRIVATE CnameRecordRdata : public RecordRdata { 123 class NET_EXPORT_PRIVATE CnameRecordRdata : public RecordRdata {
120 public: 124 public:
121 static const uint16 kType = dns_protocol::kTypeCNAME; 125 static const uint16 kType = dns_protocol::kTypeCNAME;
122 126
123 virtual ~CnameRecordRdata(); 127 virtual ~CnameRecordRdata();
124 static scoped_ptr<CnameRecordRdata> Create(const base::StringPiece& data, 128 static scoped_ptr<CnameRecordRdata> Create(const base::StringPiece& data,
125 const DnsRecordParser& parser); 129 const DnsRecordParser& parser);
126 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; 130 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE;
127 virtual uint16 Type() const OVERRIDE; 131 virtual uint16 Type() const OVERRIDE;
132 virtual scoped_ptr<const RecordRdata> Clone() const OVERRIDE;
128 133
129 std::string cname() const { return cname_; } 134 std::string cname() const { return cname_; }
130 135
131 private: 136 private:
132 CnameRecordRdata(); 137 CnameRecordRdata();
133 138
134 std::string cname_; 139 std::string cname_;
135 140
136 DISALLOW_COPY_AND_ASSIGN(CnameRecordRdata); 141 DISALLOW_COPY_AND_ASSIGN(CnameRecordRdata);
137 }; 142 };
138 143
139 // PTR record format (http://www.ietf.org/rfc/rfc1035.txt): 144 // PTR record format (http://www.ietf.org/rfc/rfc1035.txt):
140 // domain: On the wire representation of domain name. 145 // domain: On the wire representation of domain name.
141 class NET_EXPORT_PRIVATE PtrRecordRdata : public RecordRdata { 146 class NET_EXPORT_PRIVATE PtrRecordRdata : public RecordRdata {
142 public: 147 public:
143 static const uint16 kType = dns_protocol::kTypePTR; 148 static const uint16 kType = dns_protocol::kTypePTR;
144 149
145 virtual ~PtrRecordRdata(); 150 virtual ~PtrRecordRdata();
146 static scoped_ptr<PtrRecordRdata> Create(const base::StringPiece& data, 151 static scoped_ptr<PtrRecordRdata> Create(const base::StringPiece& data,
147 const DnsRecordParser& parser); 152 const DnsRecordParser& parser);
148 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; 153 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE;
149 virtual uint16 Type() const OVERRIDE; 154 virtual uint16 Type() const OVERRIDE;
155 virtual scoped_ptr<const RecordRdata> Clone() const OVERRIDE;
150 156
151 std::string ptrdomain() const { return ptrdomain_; } 157 std::string ptrdomain() const { return ptrdomain_; }
152 158
153 private: 159 private:
154 PtrRecordRdata(); 160 PtrRecordRdata();
155 161
156 std::string ptrdomain_; 162 std::string ptrdomain_;
157 163
158 DISALLOW_COPY_AND_ASSIGN(PtrRecordRdata); 164 DISALLOW_COPY_AND_ASSIGN(PtrRecordRdata);
159 }; 165 };
160 166
161 // TXT record format (http://www.ietf.org/rfc/rfc1035.txt): 167 // TXT record format (http://www.ietf.org/rfc/rfc1035.txt):
162 // texts: One or more <character-string>s. 168 // texts: One or more <character-string>s.
163 // a <character-string> is a length octet followed by as many characters. 169 // a <character-string> is a length octet followed by as many characters.
164 class NET_EXPORT_PRIVATE TxtRecordRdata : public RecordRdata { 170 class NET_EXPORT_PRIVATE TxtRecordRdata : public RecordRdata {
165 public: 171 public:
166 static const uint16 kType = dns_protocol::kTypeTXT; 172 static const uint16 kType = dns_protocol::kTypeTXT;
167 173
168 virtual ~TxtRecordRdata(); 174 virtual ~TxtRecordRdata();
169 static scoped_ptr<TxtRecordRdata> Create(const base::StringPiece& data, 175 static scoped_ptr<TxtRecordRdata> Create(const base::StringPiece& data,
170 const DnsRecordParser& parser); 176 const DnsRecordParser& parser);
171 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; 177 virtual bool IsEqual(const RecordRdata* other) const OVERRIDE;
172 virtual uint16 Type() const OVERRIDE; 178 virtual uint16 Type() const OVERRIDE;
179 virtual scoped_ptr<const RecordRdata> Clone() const OVERRIDE;
173 180
174 const std::vector<std::string>& texts() const { return texts_; } 181 const std::vector<std::string>& texts() const { return texts_; }
175 182
176 private: 183 private:
177 TxtRecordRdata(); 184 TxtRecordRdata();
178 185
179 std::vector<std::string> texts_; 186 std::vector<std::string> texts_;
180 187
181 DISALLOW_COPY_AND_ASSIGN(TxtRecordRdata); 188 DISALLOW_COPY_AND_ASSIGN(TxtRecordRdata);
182 }; 189 };
183 190
184 } // namespace net 191 } // namespace net
185 192
186 #endif // NET_DNS_RECORD_RDATA_H_ 193 #endif // NET_DNS_RECORD_RDATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698