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, uint32 ttl,
44 const std::string& service_name);
45 void AppendSrv(const std::string& service_name, uint32 ttl, uint16 priority,
46 uint16 weight, uint16 http_port,
47 const std::string& service_domain_name);
48 void AppendA(const std::string& service_domain_name, uint32 ttl,
49 net::IPAddressNumber http_ipv4);
50 void AppendTxt(const std::string& service_name, uint32 ttl,
51 const std::vector<std::string>& metadata);
53 // Serializes packet to byte sequence.
54 scoped_refptr<net::IOBufferWithSize> Build();
57 // Appends response to packet.
58 void AddResponse(const std::string& name, uint16 type, uint32 ttl,
59 const std::string& rdata);
61 std::vector<DnsResponseRecord> responses_;
63 // Header of response package.
64 net::dns_protocol::Header header_;
66 DISALLOW_COPY_AND_ASSIGN(DnsResponseBuilder);
69 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_