| OLD | NEW | 
|---|
| 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 30 matching lines...) Expand all  Loading... | 
| 41 // 2 bytes network-order unsigned port | 41 // 2 bytes network-order unsigned port | 
| 42 // target: domain name (on-the-wire representation) | 42 // target: domain name (on-the-wire representation) | 
| 43 class NET_EXPORT_PRIVATE SrvRecordRdata : public RecordRdata { | 43 class NET_EXPORT_PRIVATE SrvRecordRdata : public RecordRdata { | 
| 44  public: | 44  public: | 
| 45   static const uint16 kType = dns_protocol::kTypeSRV; | 45   static const uint16 kType = dns_protocol::kTypeSRV; | 
| 46 | 46 | 
| 47   virtual ~SrvRecordRdata(); | 47   virtual ~SrvRecordRdata(); | 
| 48   static scoped_ptr<SrvRecordRdata> Create(const base::StringPiece& data, | 48   static scoped_ptr<SrvRecordRdata> Create(const base::StringPiece& data, | 
| 49                                            const DnsRecordParser& parser); | 49                                            const DnsRecordParser& parser); | 
| 50 | 50 | 
| 51   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 51   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 52   virtual uint16 Type() const OVERRIDE; | 52   virtual uint16 Type() const override; | 
| 53 | 53 | 
| 54   uint16 priority() const { return priority_; } | 54   uint16 priority() const { return priority_; } | 
| 55   uint16 weight() const { return weight_; } | 55   uint16 weight() const { return weight_; } | 
| 56   uint16 port() const { return port_; } | 56   uint16 port() const { return port_; } | 
| 57 | 57 | 
| 58   const std::string& target() const { return target_; } | 58   const std::string& target() const { return target_; } | 
| 59 | 59 | 
| 60  private: | 60  private: | 
| 61   SrvRecordRdata(); | 61   SrvRecordRdata(); | 
| 62 | 62 | 
| 63   uint16 priority_; | 63   uint16 priority_; | 
| 64   uint16 weight_; | 64   uint16 weight_; | 
| 65   uint16 port_; | 65   uint16 port_; | 
| 66 | 66 | 
| 67   std::string target_; | 67   std::string target_; | 
| 68 | 68 | 
| 69   DISALLOW_COPY_AND_ASSIGN(SrvRecordRdata); | 69   DISALLOW_COPY_AND_ASSIGN(SrvRecordRdata); | 
| 70 }; | 70 }; | 
| 71 | 71 | 
| 72 // A Record format (http://www.ietf.org/rfc/rfc1035.txt): | 72 // A Record format (http://www.ietf.org/rfc/rfc1035.txt): | 
| 73 // 4 bytes for IP address. | 73 // 4 bytes for IP address. | 
| 74 class NET_EXPORT_PRIVATE ARecordRdata : public RecordRdata { | 74 class NET_EXPORT_PRIVATE ARecordRdata : public RecordRdata { | 
| 75  public: | 75  public: | 
| 76   static const uint16 kType = dns_protocol::kTypeA; | 76   static const uint16 kType = dns_protocol::kTypeA; | 
| 77 | 77 | 
| 78   virtual ~ARecordRdata(); | 78   virtual ~ARecordRdata(); | 
| 79   static scoped_ptr<ARecordRdata> Create(const base::StringPiece& data, | 79   static scoped_ptr<ARecordRdata> Create(const base::StringPiece& data, | 
| 80                                          const DnsRecordParser& parser); | 80                                          const DnsRecordParser& parser); | 
| 81   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 81   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 82   virtual uint16 Type() const OVERRIDE; | 82   virtual uint16 Type() const override; | 
| 83 | 83 | 
| 84   const IPAddressNumber& address() const { return address_; } | 84   const IPAddressNumber& address() const { return address_; } | 
| 85 | 85 | 
| 86  private: | 86  private: | 
| 87   ARecordRdata(); | 87   ARecordRdata(); | 
| 88 | 88 | 
| 89   IPAddressNumber address_; | 89   IPAddressNumber address_; | 
| 90 | 90 | 
| 91   DISALLOW_COPY_AND_ASSIGN(ARecordRdata); | 91   DISALLOW_COPY_AND_ASSIGN(ARecordRdata); | 
| 92 }; | 92 }; | 
| 93 | 93 | 
| 94 // AAAA Record format (http://www.ietf.org/rfc/rfc1035.txt): | 94 // AAAA Record format (http://www.ietf.org/rfc/rfc1035.txt): | 
| 95 // 16 bytes for IP address. | 95 // 16 bytes for IP address. | 
| 96 class NET_EXPORT_PRIVATE AAAARecordRdata : public RecordRdata { | 96 class NET_EXPORT_PRIVATE AAAARecordRdata : public RecordRdata { | 
| 97  public: | 97  public: | 
| 98   static const uint16 kType = dns_protocol::kTypeAAAA; | 98   static const uint16 kType = dns_protocol::kTypeAAAA; | 
| 99 | 99 | 
| 100   virtual ~AAAARecordRdata(); | 100   virtual ~AAAARecordRdata(); | 
| 101   static scoped_ptr<AAAARecordRdata> Create(const base::StringPiece& data, | 101   static scoped_ptr<AAAARecordRdata> Create(const base::StringPiece& data, | 
| 102                                          const DnsRecordParser& parser); | 102                                          const DnsRecordParser& parser); | 
| 103   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 103   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 104   virtual uint16 Type() const OVERRIDE; | 104   virtual uint16 Type() const override; | 
| 105 | 105 | 
| 106   const IPAddressNumber& address() const { return address_; } | 106   const IPAddressNumber& address() const { return address_; } | 
| 107 | 107 | 
| 108  private: | 108  private: | 
| 109   AAAARecordRdata(); | 109   AAAARecordRdata(); | 
| 110 | 110 | 
| 111   IPAddressNumber address_; | 111   IPAddressNumber address_; | 
| 112 | 112 | 
| 113   DISALLOW_COPY_AND_ASSIGN(AAAARecordRdata); | 113   DISALLOW_COPY_AND_ASSIGN(AAAARecordRdata); | 
| 114 }; | 114 }; | 
| 115 | 115 | 
| 116 // CNAME record format (http://www.ietf.org/rfc/rfc1035.txt): | 116 // CNAME record format (http://www.ietf.org/rfc/rfc1035.txt): | 
| 117 // cname: On the wire representation of domain name. | 117 // cname: On the wire representation of domain name. | 
| 118 class NET_EXPORT_PRIVATE CnameRecordRdata : public RecordRdata { | 118 class NET_EXPORT_PRIVATE CnameRecordRdata : public RecordRdata { | 
| 119  public: | 119  public: | 
| 120   static const uint16 kType = dns_protocol::kTypeCNAME; | 120   static const uint16 kType = dns_protocol::kTypeCNAME; | 
| 121 | 121 | 
| 122   virtual ~CnameRecordRdata(); | 122   virtual ~CnameRecordRdata(); | 
| 123   static scoped_ptr<CnameRecordRdata> Create(const base::StringPiece& data, | 123   static scoped_ptr<CnameRecordRdata> Create(const base::StringPiece& data, | 
| 124                                              const DnsRecordParser& parser); | 124                                              const DnsRecordParser& parser); | 
| 125   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 125   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 126   virtual uint16 Type() const OVERRIDE; | 126   virtual uint16 Type() const override; | 
| 127 | 127 | 
| 128   std::string cname() const { return cname_; } | 128   std::string cname() const { return cname_; } | 
| 129 | 129 | 
| 130  private: | 130  private: | 
| 131   CnameRecordRdata(); | 131   CnameRecordRdata(); | 
| 132 | 132 | 
| 133   std::string cname_; | 133   std::string cname_; | 
| 134 | 134 | 
| 135   DISALLOW_COPY_AND_ASSIGN(CnameRecordRdata); | 135   DISALLOW_COPY_AND_ASSIGN(CnameRecordRdata); | 
| 136 }; | 136 }; | 
| 137 | 137 | 
| 138 // PTR record format (http://www.ietf.org/rfc/rfc1035.txt): | 138 // PTR record format (http://www.ietf.org/rfc/rfc1035.txt): | 
| 139 // domain: On the wire representation of domain name. | 139 // domain: On the wire representation of domain name. | 
| 140 class NET_EXPORT_PRIVATE PtrRecordRdata : public RecordRdata { | 140 class NET_EXPORT_PRIVATE PtrRecordRdata : public RecordRdata { | 
| 141  public: | 141  public: | 
| 142   static const uint16 kType = dns_protocol::kTypePTR; | 142   static const uint16 kType = dns_protocol::kTypePTR; | 
| 143 | 143 | 
| 144   virtual ~PtrRecordRdata(); | 144   virtual ~PtrRecordRdata(); | 
| 145   static scoped_ptr<PtrRecordRdata> Create(const base::StringPiece& data, | 145   static scoped_ptr<PtrRecordRdata> Create(const base::StringPiece& data, | 
| 146                                            const DnsRecordParser& parser); | 146                                            const DnsRecordParser& parser); | 
| 147   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 147   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 148   virtual uint16 Type() const OVERRIDE; | 148   virtual uint16 Type() const override; | 
| 149 | 149 | 
| 150   std::string ptrdomain() const { return ptrdomain_; } | 150   std::string ptrdomain() const { return ptrdomain_; } | 
| 151 | 151 | 
| 152  private: | 152  private: | 
| 153   PtrRecordRdata(); | 153   PtrRecordRdata(); | 
| 154 | 154 | 
| 155   std::string ptrdomain_; | 155   std::string ptrdomain_; | 
| 156 | 156 | 
| 157   DISALLOW_COPY_AND_ASSIGN(PtrRecordRdata); | 157   DISALLOW_COPY_AND_ASSIGN(PtrRecordRdata); | 
| 158 }; | 158 }; | 
| 159 | 159 | 
| 160 // TXT record format (http://www.ietf.org/rfc/rfc1035.txt): | 160 // TXT record format (http://www.ietf.org/rfc/rfc1035.txt): | 
| 161 // texts: One or more <character-string>s. | 161 // texts: One or more <character-string>s. | 
| 162 // a <character-string> is a length octet followed by as many characters. | 162 // a <character-string> is a length octet followed by as many characters. | 
| 163 class NET_EXPORT_PRIVATE TxtRecordRdata : public RecordRdata { | 163 class NET_EXPORT_PRIVATE TxtRecordRdata : public RecordRdata { | 
| 164  public: | 164  public: | 
| 165   static const uint16 kType = dns_protocol::kTypeTXT; | 165   static const uint16 kType = dns_protocol::kTypeTXT; | 
| 166 | 166 | 
| 167   virtual ~TxtRecordRdata(); | 167   virtual ~TxtRecordRdata(); | 
| 168   static scoped_ptr<TxtRecordRdata> Create(const base::StringPiece& data, | 168   static scoped_ptr<TxtRecordRdata> Create(const base::StringPiece& data, | 
| 169                                            const DnsRecordParser& parser); | 169                                            const DnsRecordParser& parser); | 
| 170   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 170   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 171   virtual uint16 Type() const OVERRIDE; | 171   virtual uint16 Type() const override; | 
| 172 | 172 | 
| 173   const std::vector<std::string>& texts() const { return texts_; } | 173   const std::vector<std::string>& texts() const { return texts_; } | 
| 174 | 174 | 
| 175  private: | 175  private: | 
| 176   TxtRecordRdata(); | 176   TxtRecordRdata(); | 
| 177 | 177 | 
| 178   std::vector<std::string> texts_; | 178   std::vector<std::string> texts_; | 
| 179 | 179 | 
| 180   DISALLOW_COPY_AND_ASSIGN(TxtRecordRdata); | 180   DISALLOW_COPY_AND_ASSIGN(TxtRecordRdata); | 
| 181 }; | 181 }; | 
| 182 | 182 | 
| 183 // Only the subset of the NSEC record format required by mDNS is supported. | 183 // Only the subset of the NSEC record format required by mDNS is supported. | 
| 184 // Nsec record format is described in http://www.ietf.org/rfc/rfc3845.txt and | 184 // Nsec record format is described in http://www.ietf.org/rfc/rfc3845.txt and | 
| 185 // the limited version required for mDNS described in | 185 // the limited version required for mDNS described in | 
| 186 // http://www.rfc-editor.org/rfc/rfc6762.txt Section 6.1. | 186 // http://www.rfc-editor.org/rfc/rfc6762.txt Section 6.1. | 
| 187 class NET_EXPORT_PRIVATE NsecRecordRdata : public RecordRdata { | 187 class NET_EXPORT_PRIVATE NsecRecordRdata : public RecordRdata { | 
| 188  public: | 188  public: | 
| 189   static const uint16 kType = dns_protocol::kTypeNSEC; | 189   static const uint16 kType = dns_protocol::kTypeNSEC; | 
| 190 | 190 | 
| 191   virtual ~NsecRecordRdata(); | 191   virtual ~NsecRecordRdata(); | 
| 192   static scoped_ptr<NsecRecordRdata> Create(const base::StringPiece& data, | 192   static scoped_ptr<NsecRecordRdata> Create(const base::StringPiece& data, | 
| 193                                             const DnsRecordParser& parser); | 193                                             const DnsRecordParser& parser); | 
| 194   virtual bool IsEqual(const RecordRdata* other) const OVERRIDE; | 194   virtual bool IsEqual(const RecordRdata* other) const override; | 
| 195   virtual uint16 Type() const OVERRIDE; | 195   virtual uint16 Type() const override; | 
| 196 | 196 | 
| 197   // Length of the bitmap in bits. | 197   // Length of the bitmap in bits. | 
| 198   unsigned bitmap_length() const { return bitmap_.size() * 8; } | 198   unsigned bitmap_length() const { return bitmap_.size() * 8; } | 
| 199 | 199 | 
| 200   // Returns bit i-th bit in the bitmap, where bits withing a byte are organized | 200   // Returns bit i-th bit in the bitmap, where bits withing a byte are organized | 
| 201   // most to least significant. If it is set, a record with rrtype i exists for | 201   // most to least significant. If it is set, a record with rrtype i exists for | 
| 202   // the domain name of this nsec record. | 202   // the domain name of this nsec record. | 
| 203   bool GetBit(unsigned i) const; | 203   bool GetBit(unsigned i) const; | 
| 204 | 204 | 
| 205  private: | 205  private: | 
| 206   NsecRecordRdata(); | 206   NsecRecordRdata(); | 
| 207 | 207 | 
| 208   std::vector<uint8> bitmap_; | 208   std::vector<uint8> bitmap_; | 
| 209 | 209 | 
| 210   DISALLOW_COPY_AND_ASSIGN(NsecRecordRdata); | 210   DISALLOW_COPY_AND_ASSIGN(NsecRecordRdata); | 
| 211 }; | 211 }; | 
| 212 | 212 | 
| 213 | 213 | 
| 214 }  // namespace net | 214 }  // namespace net | 
| 215 | 215 | 
| 216 #endif  // NET_DNS_RECORD_RDATA_H_ | 216 #endif  // NET_DNS_RECORD_RDATA_H_ | 
| OLD | NEW | 
|---|