Chromium Code Reviews| Index: cloud_print/gcp20/prototype/dns_response_builder.h |
| diff --git a/cloud_print/gcp20/prototype/dns_response_builder.h b/cloud_print/gcp20/prototype/dns_response_builder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1705d0323aaf92f911b2ef497e8489453299c4d7 |
| --- /dev/null |
| +++ b/cloud_print/gcp20/prototype/dns_response_builder.h |
| @@ -0,0 +1,55 @@ |
| +// 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_DNS_RESPONSE_BUILDER_H_ |
| +#define CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "cloud_print/gcp20/prototype/service_parameters.h" |
| +#include "net/base/io_buffer.h" |
| +#include "net/dns/dns_protocol.h" |
| +#include "net/dns/dns_response.h" |
| + |
| +// Class for building service-specified responses. |
| +class DnsResponseBuilder { |
| + public: |
| + // Initializes builder. |
| + explicit DnsResponseBuilder(uint16 id); |
| + |
| + // Destroys the object. |
| + ~DnsResponseBuilder() {} |
| + |
| + // Methods for appending different types of responses to packet. |
| + void AppendPtr(uint32 ttl, const ServiceParameters& serv_params); |
|
gene
2013/06/19 05:40:51
I would suggest having record specific input param
maksymb
2013/06/19 21:47:21
Done.
|
| + void AppendSrv(uint32 ttl, const ServiceParameters& serv_params); |
| + void AppendA(uint32 ttl, const ServiceParameters& serv_params); |
| + void AppendTxt(uint32 ttl, const ServiceParameters& serv_params, |
| + const std::string& txt); |
| + |
| + // Serializes packet to byte sequence. |
| + scoped_refptr<net::IOBufferWithSize> Build() const; |
| + |
| + // Builds DNS packet for announcement with certain TTL. |
| + scoped_refptr<net::IOBufferWithSize> BuildAnnouncement(uint32 ttl); |
|
gene
2013/06/19 05:40:51
const?
maksymb
2013/06/19 21:47:21
Sorry, I forgot to delete declaration. This method
|
| + |
| + private: |
| + // Appends response to packet. |
| + void AddResponse(const std::string& name, |
| + uint16 type, |
| + uint32 ttl, |
| + const std::string& rdata); |
| + |
| + std::vector<uint8> responses_; |
|
gene
2013/06/19 05:40:51
Usually it is easier to collect all records in som
maksymb
2013/06/19 21:47:21
Done.
|
| + |
| + // Header of response package. |
| + net::dns_protocol::Header header_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DnsResponseBuilder); |
| +}; |
| + |
| +#endif // CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_ |
| + |