Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8818)

Unified Diff: cloud_print/gcp20/prototype/dns_response_builder.h

Issue 16975004: Finished DNS-SD server. Finished Privet-specified DNS-SD server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixel little mistake in GetLocalIp. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..591ab1532d23c8ac07626c1e05294c3e99577c91
--- /dev/null
+++ b/cloud_print/gcp20/prototype/dns_response_builder.h
@@ -0,0 +1,66 @@
+// 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"
+
+// Record for storing response data.
+struct DnsResponseRecord {
+ DnsResponseRecord();
+ ~DnsResponseRecord();
+
+ std::string name; // in dotted form
+ uint16 type;
+ uint16 klass;
+ uint32 ttl;
+ std::string rdata;
+};
+
+// 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(const std::string& service_type, uint32 ttl,
+ const std::string& service_name);
+ void AppendSrv(const std::string& service_name, uint32 ttl, uint16 priority,
+ uint16 weight, uint16 http_port,
+ const std::string& service_domain_name);
+ void AppendA(const std::string& service_domain_name, uint32 ttl,
+ net::IPAddressNumber http_ipv4);
+ void AppendTxt(const std::string& service_name, uint32 ttl,
+ const std::vector<std::string>& metadata);
+
+ // Serializes packet to byte sequence.
+ scoped_refptr<net::IOBufferWithSize> Build();
+
+ private:
+ // Appends response to packet.
+ void AddResponse(const std::string& name, uint16 type, uint32 ttl,
+ const std::string& rdata);
+
+ std::vector<DnsResponseRecord> responses_;
+
+ // Header of response package.
+ net::dns_protocol::Header header_;
+
+ DISALLOW_COPY_AND_ASSIGN(DnsResponseBuilder);
+};
+
+#endif // CLOUD_PRINT_GCP20_PROTOTYPE_DNS_RESPONSE_BUILDER_H_
+

Powered by Google App Engine
This is Rietveld 408576698