Index: cloud_print/gcp20/prototype/privet_dns_response_builder.h |
diff --git a/cloud_print/gcp20/prototype/privet_dns_response_builder.h b/cloud_print/gcp20/prototype/privet_dns_response_builder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1de2be3db875cf912c73a2d23d870ff04d0d7efb |
--- /dev/null |
+++ b/cloud_print/gcp20/prototype/privet_dns_response_builder.h |
@@ -0,0 +1,85 @@ |
+// Copyright 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 CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_DNS_RESPONSE_BUILDER_H_ |
+#define CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_DNS_RESPONSE_BUILDER_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/basictypes.h" |
+#include "cloud_print/gcp20/prototype/dns_sd_server.h" |
+#include "net/base/io_buffer.h" |
+#include "net/dns/dns_protocol.h" |
+#include "net/dns/dns_response.h" |
+ |
+class PrivetDnsResponseBuilder : public DnsResponseBuilderInterface { |
+ public: |
+ // Initializes builder. |
+ PrivetDnsResponseBuilder(uint16 id, |
+ const std::string& service_name, |
+ const std::string& service_domain_name, |
+ const net::IPAddressNumber& http_ip, |
+ uint16 http_port); |
+ |
+ ~PrivetDnsResponseBuilder(); |
+ |
+ int HaveAnswers() const OVERRIDE { return !responses_.empty(); } |
+ |
+ bool IsSamePtr(const std::string& qname) OVERRIDE; |
+ bool IsSameSrv(const std::string& qname) OVERRIDE; |
+ bool IsSameA(const std::string& qname) OVERRIDE; |
+ bool IsSameTxt(const std::string& qname) OVERRIDE; |
+ |
+ void AppendPtr(uint32 ttl) OVERRIDE; |
+ void AppendSrv(uint32 ttl) OVERRIDE; |
+ void AppendA(uint32 ttl) OVERRIDE; |
+ void AppendTxt(uint32 ttl) OVERRIDE; |
+ |
+ scoped_refptr<net::IOBufferWithSize> Build() const OVERRIDE; |
+ |
+ scoped_refptr<net::IOBufferWithSize> BuildAnnouncement(uint32 ttl) OVERRIDE; |
+ |
+ private: |
+ // Appends response to packet. |
+ void AddResponse(const std::string& name, |
+ uint16 type, |
+ uint32 ttl, |
+ const std::string& rdata); |
+ |
+ std::vector<uint8> responses_; |
+ |
+ // Header of response package. |
+ net::dns_protocol::Header header_; |
+ |
+ // Information about service. |
+ const std::string service_name_; |
+ const std::string service_domain_name_; |
+ const net::IPAddressNumber http_ip_; |
+ const uint16 http_port_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PrivetDnsResponseBuilder); |
+}; |
+ |
+class PrivetDnsResponseBuilderFactory |
+ : public DnsResponseBuilderFactoryInterface { |
+ public: |
+ PrivetDnsResponseBuilderFactory(const std::string& service_name_prefix, |
+ const std::string& service_domain_name, |
+ const net::IPAddressNumber& http_ip, |
+ uint16 http_port); |
+ |
+ DnsResponseBuilderInterface* Create(uint16 id) OVERRIDE; |
+ |
+ private: |
+ // Information about service. |
+ const std::string service_type_; |
+ const std::string service_name_prefix_; |
+ const std::string service_domain_name_; |
+ const net::IPAddressNumber http_ip_; |
+ const uint16 http_port_; |
+}; |
+ |
+#endif // CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_DNS_RESPONSE_BUILDER_H_ |
+ |