1 // Copyright 2013 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.
5 #ifndef CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_
6 #define CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_
11 #include "base/basictypes.h"
12 #include "net/base/net_util.h"
13 #include "net/dns/dns_protocol.h"
17 class IOBufferWithSize;
21 // Record for storing response data.
22 struct DnsResponseRecord {
26 std::string name; // in dotted form
33 // Class for building service-specified responses.
34 class DnsResponseBuilder {
36 // Initializes builder.
37 explicit DnsResponseBuilder(uint16 id);
39 // Destroys the object.
40 ~DnsResponseBuilder();
42 // Methods for appending different types of responses to packet.
43 void AppendPtr(const std::string& service_type,
45 const std::string& service_name,
48 void AppendSrv(const std::string& service_name,
51 uint16 weight, uint16 http_port,
52 const std::string& service_domain_name,
55 void AppendA(const std::string& service_domain_name,
57 net::IPAddressNumber http_ipv4,
60 void AppendAAAA(const std::string& service_domain_name,
62 net::IPAddressNumber http_ipv6,
65 void AppendTxt(const std::string& service_name,
67 const std::vector<std::string>& metadata,
70 // Serializes packet to byte sequence.
71 scoped_refptr<net::IOBufferWithSize> Build();
74 // Appends response to packet.
75 void AddResponse(const std::string& name,
78 const std::string& rdata,
81 std::vector<DnsResponseRecord> responses_;
83 // Header of response package.
84 net::dns_protocol::Header header_;
86 DISALLOW_COPY_AND_ASSIGN(DnsResponseBuilder);
89 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_